/blog/wp-content/plugins/wp-super-cache/wp-cache.php
PHP | 1840 lines | 1675 code | 125 blank | 40 comment | 390 complexity | 15970bd9668db53b0707470932ca3bfd MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- <?php
- /*
- Plugin Name: WP Super Cache
- Plugin URI: http://ocaoimh.ie/wp-super-cache/
- Description: Very fast caching plugin for WordPress.
- Version: 0.9.9
- Author: Donncha O Caoimh
- Author URI: http://ocaoimh.ie/
- */
- /* Copyright 2005-2006 Ricardo Galli Granada (email : gallir@uib.es)
- Copyright 2007-2009 Donncha O Caoimh (http://ocaoimh.ie/)
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
- // Pre-2.6 compatibility
- if( !defined('WP_CONTENT_URL') )
- define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content');
- if( !defined('WP_CONTENT_DIR') )
- define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
- $wp_cache_config_file = WP_CONTENT_DIR . '/wp-cache-config.php';
- if( !@include($wp_cache_config_file) ) {
- get_wpcachehome();
- $wp_cache_config_file_sample = WPCACHEHOME . 'wp-cache-config-sample.php';
- @include($wp_cache_config_file_sample);
- } else {
- get_wpcachehome();
- }
- $wp_cache_config_file_sample = WPCACHEHOME . 'wp-cache-config-sample.php';
- $wp_cache_link = WP_CONTENT_DIR . '/advanced-cache.php';
- $wp_cache_file = WPCACHEHOME . 'advanced-cache.php';
- if( !defined( 'WP_CACHE' ) ) {
- $wp_cache_check_wp_config = true;
- }
- include(WPCACHEHOME . 'wp-cache-base.php');
- function wp_super_cache_text_domain() {
- load_plugin_textdomain( 'wp-super-cache', WPCACHEHOME . 'languages', basename( dirname( __FILE__ ) ) . '/languages' );
- }
- add_action( 'init', 'wp_super_cache_text_domain' );
- // from legolas558 d0t users dot sf dot net at http://www.php.net/is_writable
- function is_writeable_ACLSafe($path) {
- // PHP's is_writable does not work with Win32 NTFS
-
- if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
- return is_writeable_ACLSafe($path.uniqid(mt_rand()).'.tmp');
- else if (is_dir($path))
- return is_writeable_ACLSafe($path.'/'.uniqid(mt_rand()).'.tmp');
- // check tmp file for read/write capabilities
- $rm = file_exists($path);
- $f = @fopen($path, 'a');
- if ($f===false)
- return false;
- fclose($f);
- if (!$rm)
- unlink($path);
- return true;
- }
- function get_wpcachehome() {
- if( defined( 'WPCACHEHOME' ) == false ) {
- if( is_file( dirname(__FILE__) . '/wp-cache-config-sample.php' ) ) {
- define( 'WPCACHEHOME', trailingslashit( dirname(__FILE__) ) );
- } elseif( is_file( dirname(__FILE__) . '/wp-super-cache/wp-cache-config-sample.php' ) ) {
- define( 'WPCACHEHOME', dirname(__FILE__) . '/wp-super-cache/' );
- } else {
- die( sprintf( __( 'Please create %s /wp-cache-config.php from wp-super-cache/wp-cache-config-sample.php', 'wp-super-cache' ), WP_CONTENT_DIR ) );
- }
- }
- }
- function wpsupercache_deactivate() {
- global $wp_cache_config_file, $wp_cache_link, $cache_path;
- $files = array( $wp_cache_config_file, $wp_cache_link );
- foreach( $files as $file ) {
- if( file_exists( $file ) )
- unlink( $file );
- }
- if( !function_exists( 'prune_super_cache' ) )
- include_once( 'wp-cache-phase2.php' );
- prune_super_cache ($cache_path, true);
- @unlink( $cache_path . '.htaccess' );
- @unlink( $cache_path . 'meta' );
- @unlink( $cache_path . 'supercache' );
- wp_clear_scheduled_hook( 'wp_cache_check_site_hook' );
- }
- register_deactivation_hook( __FILE__, 'wpsupercache_deactivate' );
- function wpsupercache_activate() {
- }
- register_activation_hook( __FILE__, 'wpsupercache_activate' );
- function wp_cache_add_pages() {
- if( function_exists( 'is_site_admin' ) ) {
- if( is_site_admin() ) {
- add_submenu_page('wpmu-admin.php', 'WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager');
- add_options_page('WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager');
- }
- } else {
- add_options_page('WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager');
- }
- }
- add_action('admin_menu', 'wp_cache_add_pages');
- function wp_cache_manager() {
- global $wp_cache_config_file, $valid_nonce, $supercachedir, $cache_path, $cache_enabled, $cache_compression, $super_cache_enabled, $wp_cache_hello_world;
- global $wp_cache_clear_on_post_edit, $cache_rebuild_files, $wp_cache_mutex_disabled, $wp_cache_mobile_enabled, $wp_cache_mobile_browsers;
- global $wp_cache_cron_check, $wp_cache_debug, $wp_cache_hide_donation, $wp_cache_not_logged_in, $wp_supercache_cache_list;
- global $wp_super_cache_front_page_check, $wp_cache_object_cache, $_wp_using_ext_object_cache;
- if( function_exists( 'is_site_admin' ) )
- if( !is_site_admin() )
- return;
- $supercachedir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $_SERVER["HTTP_HOST"]);
- if( get_option( 'gzipcompression' ) == 1 )
- update_option( 'gzipcompression', 0 );
- if( !isset( $cache_rebuild_files ) )
- $cache_rebuild_files = 0;
- $valid_nonce = isset($_REQUEST['_wpnonce']) ? wp_verify_nonce($_REQUEST['_wpnonce'], 'wp-cache') : false;
- /* http://www.netlobo.com/div_hiding.html */
- ?>
- <script type='text/javascript'>
- <!--
- function toggleLayer( whichLayer ) {
- var elem, vis;
- if( document.getElementById ) // this is the way the standards work
- elem = document.getElementById( whichLayer );
- else if( document.all ) // this is the way old msie versions work
- elem = document.all[whichLayer];
- else if( document.layers ) // this is the way nn4 works
- elem = document.layers[whichLayer];
- vis = elem.style;
- // if the style.display value is blank we try to figure it out here
- if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
- vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
- vis.display = (vis.display==''||vis.display=='block')?'none':'block';
- }
- // -->
- //Clicking header opens fieldset options
- jQuery(document).ready(function(){
- jQuery("fieldset h3").css("cursor","pointer").click(function(){
- jQuery(this).parent("fieldset").find("p,form,ul,blockquote").toggle("slow");
- });
- });
- </script>
- <?php
- echo '<div class="wrap">';
- echo "<h2><a href='?page=wpsupercache'>" . __( 'WP Super Cache Manager', 'wp-super-cache' ) . "</a></h2>\n";
- if ( 1 == ini_get( 'safe_mode' ) || "on" == strtolower( ini_get( 'safe_mode' ) ) ) {
- ?><h3><?php _e( 'Warning! PHP Safe Mode Enabled!', 'wp-super-cache' ); ?></h3>
- <p><?php _e( 'You may experience problems running this plugin because SAFE MODE is enabled.', 'wp-super-cache' );
- if( !ini_get( 'safe_mode_gid' ) ) {
- echo __( 'Your server is set up to check the owner of PHP scripts before allowing them to read and write files.', 'wp-super-cache' ) . "</p><p>";
- echo sprintf( __( 'You or an administrator may be able to make it work by changing the group owner of the plugin scripts to match that of the web server user. The group owner of the %s/cache/ directory must also be changed. See the <a href="http://php.net/features.safe-mode">safe mode manual page</a> for further details.', 'wp-super-cache' ), WP_CONTENT_DIR ) . "</p>";
- } else {
- echo __( 'You or an administrator must disable this. See the <a href="http://php.net/features.safe-mode">safe mode manual page</a> for further details. This cannot be disabled in a .htaccess file unfortunately. It must be done in the php.ini config file.', 'wp-super-cache' ) . "</p>";
- }
- }
- if ( '' == get_option( 'permalink_structure' ) ) {
- echo "<h3>" . __( 'Permlink Structure Error', 'wp-super-cache' ) . "</h3>";
- echo "<p>" . __( 'A custom url or permalink structure is required for this plugin to work correctly. Please go to the <a href="options-permalink.php">Permalinks Options Page</a> to configure your permalinks.' ) . "</p>";
- }
- if ( isset( $wp_super_cache_front_page_check ) && $wp_super_cache_front_page_check == 1 && !wp_next_scheduled( 'wp_cache_check_site_hook' ) ) {
- wp_schedule_single_event( time() + 360 , 'wp_cache_check_site_hook' );
- if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'scheduled wp_cache_check_site_hook for 360 seconds time.', 2 );
- }
- if(isset($_REQUEST['wp_restore_config']) && $valid_nonce) {
- unlink($wp_cache_config_file);
- echo '<strong>' . __( 'Configuration file changed, some values might be wrong. Load the page again from the "Settings" menu to reset them.', 'wp-super-cache' ) . '</strong>';
- }
- if ( !wp_cache_check_link() ||
- !wp_cache_verify_config_file() ||
- !wp_cache_verify_cache_dir() ) {
- echo '<p>' . __( "Cannot continue... fix previous problems and retry.", 'wp-super-cache' ) . '</p>';
- echo "</div>\n";
- return;
- }
- if (!wp_cache_check_global_config()) {
- echo "</div>\n";
- return;
- }
- if( $wp_cache_debug || !$wp_cache_cron_check ) {
- if( function_exists( "wp_remote_get" ) == false ) {
- $hostname = str_replace( 'http://', '', str_replace( 'https://', '', get_option( 'siteurl' ) ) );
- if( strpos( $hostname, '/' ) )
- $hostname = substr( $hostname, 0, strpos( $hostname, '/' ) );
- $ip = gethostbyname( $hostname );
- if( substr( $ip, 0, 3 ) == '127' || substr( $ip, 0, 7 ) == '192.168' ) {
- ?><h3><?php printf( __( 'Warning! Your hostname "%s" resolves to %s', 'wp-super-cache' ), $hostname, $ip ); ?></h3>
- <div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'>
- <p><?php printf( __( 'Your server thinks your hostname resolves to %s. Some services such as garbage collection by this plugin, and WordPress scheduled posts may not operate correctly.', 'wp-super-cache' ), $ip ); ?></p>
- <p><?php printf( __( 'Please see entry 16 in the <a href="%s">Troubleshooting section</a> of the readme.txt', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wp-super-cache/faq/' ); ?></p>
- </div>
- <?php
- } else {
- wp_cache_replace_line('^ *\$wp_cache_cron_check', "\$wp_cache_cron_check = 1;", $wp_cache_config_file);
- }
- } else {
- $cron_url = get_option( 'siteurl' ) . '/wp-cron.php?check=' . wp_hash('187425');
- $cron = wp_remote_get($cron_url, array('timeout' => 0.01, 'blocking' => true));
- if( is_array( $cron ) ) {
- if( $cron[ 'response' ][ 'code' ] == '404' ) {
- ?><h3>Warning! wp-cron.php not found!</h3>
- <div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'>
- <p><?php _e( 'Unfortunately WordPress cannot find the file wp-cron.php. This script is required for the the correct operation of garbage collection by this plugin, WordPress scheduled posts as well as other critical activities.', 'wp-super-cache' ); ?></p>
- <p><?php printf( __( 'Please see entry 16 in the <a href="%s">Troubleshooting section</a> of the readme.txt', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wp-super-cache/faq/' ); ?></p>
- </div>
- <?php
- } else {
- wp_cache_replace_line('^ *\$wp_cache_cron_check', "\$wp_cache_cron_check = 1;", $wp_cache_config_file);
- }
- }
- }
- }
- if ( 1 == ini_get( 'zlib.output_compression' ) || "on" == strtolower( ini_get( 'zlib.output_compression' ) ) ) {
- ?><h4 style='color: #a00'><?php _e( 'Zlib Output Compression Enabled!', 'wp-super-cache' ); ?></h4>
- <p><?php _e( 'PHP is compressing the data sent to the visitors of your site. Disabling this is recommended as the plugin caches the compressed output once instead of compressing the same page over and over again. Also see #21 in the Troubleshooting section. See <a href="http://php.net/manual/en/zlib.configuration.php">this page</a> for instructions on modifying your php.ini.', 'wp-super-cache' ); ?></p><?php
- }
- if( $cache_enabled == true && $super_cache_enabled == true && !got_mod_rewrite() ) {
- ?><h4 style='color: #a00'><?php _e( 'Mod rewrite may not be installed!', 'wp-super-cache' ); ?></h4>
- <p><?php _e( 'It appears that mod_rewrite is not installed. Sometimes this check isn’t 100% reliable, especially if you are not using Apache. Please verify that the mod_rewrite module is loaded. It is required for serving Super Cache static files. You will still be able to use half-on mode.', 'wp-super-cache' ); ?></p><?php
- }
- if( !is_writeable_ACLSafe($wp_cache_config_file) ) {
- define( "SUBMITDISABLED", 'disabled style="color: #aaa" ' );
- ?><h4 style='text-align:center; color: #a00'><?php _e( 'Read Only Mode. Configuration cannot be changed.', 'wp-super-cache' ); ?> <a href="javascript:toggleLayer('readonlywarning');" title="<?php _e( 'Why your configuration may not be changed', 'wp-super-cache' ); ?>"><?php _e( 'Why', 'wp-super-cache' ); ?></a></h4>
- <div id='readonlywarning' style='border: 1px solid #aaa; margin: 2px; padding: 2px; display: none;'>
- <p><?php printf( __( 'The WP Super Cache configuration file is <code>%s/wp-cache-config.php</code> and cannot be modified. That file must be writeable by the webserver to make any changes.', 'wp-super-cache' ), WP_CONTENT_DIR ); ?>
- <?php _e( 'A simple way of doing that is by changing the permissions temporarily using the CHMOD command or through your ftp client. Make sure it’s globally writeable and it should be fine.', 'wp-super-cache' ); ?></p>
- <?php _e( 'Writeable:', 'wp-super-cache' ); ?> <code>chmod 666 <?php echo WP_CONTENT_DIR; ?>/wp-cache-config.php</code>
- <?php _e( 'Readonly:', 'wp-super-cache' ); ?> <code>chmod 644 <?php echo WP_CONTENT_DIR; ?>/wp-cache-config.php</code></p>
- </div><?php
- } else {
- define( "SUBMITDISABLED", ' ' );
- }
- // Server could be running as the owner of the wp-content directory. Therefore, if it's
- // writable, issue a warning only if the permissions aren't 755.
- if( is_writeable_ACLSafe( WP_CONTENT_DIR . '/' ) ) {
- $wp_content_stat = stat(WP_CONTENT_DIR . '/');
- $wp_content_mode = ($wp_content_stat['mode'] & 0777);
- if( $wp_content_mode != 0755 ) {
- ?><h4 style='text-align:center; color: #a00'><?php printf( __( 'Warning! %s is writeable!', 'wp-super-cache' ), WP_CONTENT_DIR ); ?></h4>
- <p><?php printf( __( 'You should change the permissions on %s and make it more restrictive. Use your ftp client, or the following command to fix things:', 'wp-super-cache' ), WP_CONTENT_DIR ); ?><code>chmod 755 <?php echo WP_CONTENT_DIR; ?>/</code></p><?php
- }
- }
- // used by mod_rewrite rules and config file
- if ( function_exists( "cfmobi_default_browsers" ) ) {
- $mobile_browsers = cfmobi_default_browsers( "mobile" );
- $mobile_browsers = array_merge( $mobile_browsers, cfmobi_default_browsers( "touch" ) );
- } else {
- $mobile_browsers = array( '2.0 MMP', '240x320', '400X240', 'AvantGo', 'BlackBerry', 'Blazer', 'Cellphone', 'Danger', 'DoCoMo', 'Elaine/3.0', 'EudoraWeb', 'Googlebot-Mobile', 'hiptop', 'IEMobile', 'KYOCERA/WX310K', 'LG/U990', 'MIDP-2.', 'MMEF20', 'MOT-V', 'NetFront', 'Newt', 'Nintendo Wii', 'Nitro', 'Nokia', 'Opera Mini', 'Palm', 'PlayStation Portable', 'portalmmm', 'Proxinet', 'ProxiNet', 'SHARP-TQ-GX10', 'SHG-i900', 'Small', 'SonyEricsson', 'Symbian OS', 'SymbianOS', 'TS21i-10', 'UP.Browser', 'UP.Link', 'webOS', 'Windows CE', 'WinWAP', 'YahooSeeker/M1A1-R2D2', 'iPhone', 'iPod', 'Android', 'BlackBerry9530', 'LG-TU915 Obigo', 'LGE VX', 'webOS', 'Nokia5800' );
- }
- if ( $valid_nonce ) {
- if( isset( $_POST[ 'wp_cache_status' ] ) ) {
- if( isset( $_POST[ 'wp_cache_mobile_enabled' ] ) ) {
- $wp_cache_mobile_enabled = 1;
- } else {
- $wp_cache_mobile_enabled = 0;
- }
- if( $wp_cache_mobile_enabled == 1 ) {
- wp_cache_replace_line('^ *\$wp_cache_mobile_browsers', "\$wp_cache_mobile_browsers = '" . implode( ', ', $mobile_browsers ) . "';", $wp_cache_config_file);
- }
- wp_cache_replace_line('^ *\$wp_cache_mobile_enabled', "\$wp_cache_mobile_enabled = " . $wp_cache_mobile_enabled . ";", $wp_cache_config_file);
- $wp_supercache_cache_list = $_POST[ 'wp_supercache_cache_list' ] == 1 ? 1 : 0;
- wp_cache_replace_line('^ *\$wp_supercache_cache_list', "\$wp_supercache_cache_list = " . $wp_supercache_cache_list . ";", $wp_cache_config_file);
- switch( $_POST[ 'wp_cache_status' ] ) {
- case 'all':
- wp_cache_enable();
- break;
- case 'none':
- wp_cache_disable();
- break;
- case 'wpcache':
- wp_cache_enable();
- wp_super_cache_disable();
- break;
- }
- if( isset( $_POST[ 'wp_cache_hello_world' ] ) ) {
- $wp_cache_hello_world = 1;
- } else {
- $wp_cache_hello_world = 0;
- }
- wp_cache_replace_line('^ *\$wp_cache_hello_world', '$wp_cache_hello_world = ' . (int)$wp_cache_hello_world . ";", $wp_cache_config_file);
- if( isset( $_POST[ 'wp_cache_clear_on_post_edit' ] ) ) {
- $wp_cache_clear_on_post_edit = 1;
- } else {
- $wp_cache_clear_on_post_edit = 0;
- }
- wp_cache_replace_line('^ *\$wp_cache_clear_on_post_edit', "\$wp_cache_clear_on_post_edit = " . $wp_cache_clear_on_post_edit . ";", $wp_cache_config_file);
- if( isset( $_POST[ 'cache_rebuild_files' ] ) ) {
- $cache_rebuild_files = 1;
- } else {
- $cache_rebuild_files = 0;
- }
- wp_cache_replace_line('^ *\$cache_rebuild_files', "\$cache_rebuild_files = " . $cache_rebuild_files . ";", $wp_cache_config_file);
- if( isset( $_POST[ 'wp_cache_mutex_disabled' ] ) ) {
- $wp_cache_mutex_disabled = 0;
- } else {
- $wp_cache_mutex_disabled = 1;
- }
- if( defined( 'WPSC_DISABLE_LOCKING' ) ) {
- $wp_cache_mutex_disabled = 1;
- }
- wp_cache_replace_line('^ *\$wp_cache_mutex_disabled', "\$wp_cache_mutex_disabled = " . $wp_cache_mutex_disabled . ";", $wp_cache_config_file);
- if( isset( $_POST[ 'wp_cache_not_logged_in' ] ) ) {
- if( $wp_cache_not_logged_in == 0 && function_exists( 'prune_super_cache' ) )
- prune_super_cache ($cache_path, true);
- $wp_cache_not_logged_in = 1;
- } else {
- $wp_cache_not_logged_in = 0;
- }
- wp_cache_replace_line('^ *\$wp_cache_not_logged_in', "\$wp_cache_not_logged_in = " . $wp_cache_not_logged_in . ";", $wp_cache_config_file);
- if( $_wp_using_ext_object_cache && isset( $_POST[ 'wp_cache_object_cache' ] ) ) {
- if( $wp_cache_object_cache == 0 && function_exists( 'prune_super_cache' ) )
- prune_super_cache ($cache_path, true);
- $wp_cache_object_cache = 1;
- } else {
- $wp_cache_object_cache = 0;
- }
- wp_cache_replace_line('^ *\$wp_cache_object_cache', "\$wp_cache_object_cache = " . $wp_cache_object_cache . ";", $wp_cache_config_file);
- }
- if( defined( 'WPSC_DISABLE_COMPRESSION' ) ) {
- $cache_compression_changed = false;
- $cache_compression = 0;
- wp_cache_replace_line('^ *\$cache_compression', "\$cache_compression = " . $cache_compression . ";", $wp_cache_config_file);
- } elseif( isset( $_POST[ 'cache_compression' ] ) && $_POST[ 'cache_compression' ] != $cache_compression ) {
- if ( $_POST[ 'cache_compression' ] && 1 == ini_get( 'zlib.output_compression' ) || "on" == strtolower( ini_get( 'zlib.output_compression' ) ) ) {
- _e( "<strong>Warning!</strong> You attempted to enable compression but <code>zlib.output_compression</code> is enabled. See #21 in the Troubleshooting section of the readme file.", 'wp-super-cache' );
- } else {
- $cache_compression = intval( $_POST[ 'cache_compression' ] );
- $cache_compression_changed = true;
- wp_cache_replace_line('^ *\$cache_compression', "\$cache_compression = " . $cache_compression . ";", $wp_cache_config_file);
- if( function_exists( 'prune_super_cache' ) )
- prune_super_cache ($cache_path, true);
- delete_option( 'super_cache_meta' );
- }
- }
- if( isset( $_POST[ 'wp_cache_hide_donation' ] ) && $_POST[ 'wp_cache_hide_donation' ] != $wp_cache_hide_donation ) {
- $wp_cache_hide_donation = intval( $_POST[ 'wp_cache_hide_donation' ] );
- wp_cache_replace_line('^ *\$wp_cache_hide_donation', "\$wp_cache_hide_donation = " . $wp_cache_hide_donation . ";", $wp_cache_config_file);
- }
- }
- echo '<a name="top"></a>';
- ?>
- <table><td><fieldset class="options" id="show-this-fieldset">
- <h3><?php _e( 'WP Super Cache Status', 'wp-super-cache' ); ?></h3><?php
- echo '<form name="wp_manager" action="#top" method="post">';
- ?>
- <label><input type='radio' name='wp_cache_status' value='all' <?php if( $cache_enabled == true && $super_cache_enabled == true ) { echo 'checked=checked'; } ?>> <strong><?php _e( 'ON', 'wp-super-cache' ); ?></strong> <span class="setting-description"><?php _e( 'WP Cache and Super Cache enabled', 'wp-super-cache' ); ?></span></label><br />
- <label><input type='radio' name='wp_cache_status' value='wpcache' <?php if( $cache_enabled == true && $super_cache_enabled == false ) { echo 'checked=checked'; } ?>> <strong><?php _e( 'HALF ON', 'wp-super-cache' ); ?></strong> <span class="setting-description"><?php _e( 'Super Cache Disabled, only legacy WP-Cache caching.', 'wp-super-cache' ); ?></span></label><br />
- <label><input type='radio' name='wp_cache_status' value='none' <?php if( $cache_enabled == false ) { echo 'checked=checked'; } ?>> <strong><?php _e( 'OFF', 'wp-super-cache' ); ?></strong> <span class="setting-description"><?php _e( 'WP Cache and Super Cache disabled', 'wp-super-cache' ); ?></span></label><br />
- <p><label><input type='checkbox' name='wp_cache_not_logged_in' <?php if( $wp_cache_not_logged_in ) echo "checked"; ?> value='1'> <?php _e( 'Don’t cache pages for logged in users.', 'wp-super-cache' ); ?></label></p>
- <p><label><input type='checkbox' name='wp_cache_hello_world' <?php if( $wp_cache_hello_world ) echo "checked"; ?> value='1'> <?php _e( 'Proudly tell the world your server is Digg proof! (places a message in your blog’s footer)', 'wp-super-cache' ); ?></label></p>
- <p><label><input type='checkbox' name='wp_cache_clear_on_post_edit' <?php if( $wp_cache_clear_on_post_edit ) echo "checked"; ?> value='1'> <?php _e( 'Clear all cache files when a post or page is published. (This may significantly slow down saving of posts.)', 'wp-super-cache' ); ?></label></p>
- <p><label><input type='checkbox' name='cache_rebuild_files' <?php if( $cache_rebuild_files ) echo "checked"; ?> value='1'> <?php _e( 'Cache rebuild. Serve a supercache file to anonymous users while a new file is being generated. Recommended for <em>very</em> busy websites with lots of comments. Makes "directly cached pages" and "Lockdown mode" obsolete.', 'wp-super-cache' ); ?></label></p>
- <?php if( false == defined( 'WPSC_DISABLE_LOCKING' ) ) { ?>
- <p><label><input type='checkbox' name='wp_cache_mutex_disabled' <?php if( !$wp_cache_mutex_disabled ) echo "checked"; ?> value='0'> <?php _e( 'Coarse file locking. You probably don’t need this but it may help if your server is underpowered. Warning! <em>May cause your server to lock up in very rare cases!</em>', 'wp-super-cache' ); ?></label></p>
- <?php } ?>
- <p><label><input type='checkbox' name='wp_supercache_cache_list' <?php if( $wp_supercache_cache_list ) echo "checked"; ?> value='1'> <?php _e( 'List the newest cached pages (may be expensive to run on busy sites, use with caution.)', 'wp-super-cache' ); ?></label>
- <p><label><input type='checkbox' name='wp_cache_mobile_enabled' <?php if( $wp_cache_mobile_enabled ) echo "checked"; ?> value='1'> <?php printf( __( 'Mobile device support using <a href="%s">WordPress Mobile Edition</a>.', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wordpress-mobile-edition/' ); ?></label>
- <?php
- $home_path = trailingslashit( get_home_path() );
- $scrules = implode( "\n", extract_from_markers( $home_path.'.htaccess', 'WPSuperCache' ) );
- if ( !$wp_cache_mobile_enabled && strpos( $scrules, addcslashes( implode( '|', $mobile_browsers ), ' ' ) ) ) {
- echo "<blockquote style='background-color:#feefb3; padding: 5px; margin: 5px;'><h4>" . __( 'Mobile rewrite rules detected', 'wp-super-cache' ) . "</h4>";
- echo "<p>" . __( 'For best performance you should enable "Mobile device support" or delete the mobile rewrite rules in your .htaccess. Look for the 2 lines with the text "2.0\ MMP|240x320" and delete those.', 'wp-super-cache' ) . "</p><p>" . __( 'This will have no affect on ordinary users but mobile users will see uncached pages.', 'wp-super-cache' ) . "</p></blockquote>";
- } elseif ( $wp_cache_mobile_enabled && $scrules != '' && false === strpos( $scrules, addcslashes( implode( '|', $mobile_browsers ), ' ' ) ) ) {
- ?>
- <blockquote style='background-color:#fefeb3; padding: 5px; margin: 5px;'><h4><?php _e( 'Rewrite rules must be updated', 'wp-super-cache' ); ?></h4>
- <p><?php _e( 'The rewrite rules required by this plugin have changed or are missing. ', 'wp-super-cache' ); ?>
- <?php _e( 'Mobile support requires extra rules in your .htaccess file, or you can set the plugin to half-on mode. Here are your options (in order of difficulty):', 'wp-super-cache' ); ?>
- <ol><li> <?php _e( 'Set the plugin to half on mode and enable mobile support.', 'wp-super-cache' ); ?></li>
- <li> <?php printf( __( 'Delete the plugin mod_rewrite rules in %s.htaccess enclosed by <code># BEGIN WPSuperCache</code> and <code># END WPSuperCache</code> and let the plugin regenerate them by reloading this page.', 'wp-super-cache' ), $home_path ); ?></li>
- <li> <?php printf( __( 'Add the rules yourself. Edit %s.htaccess and find the block of code enclosed by the lines <code># BEGIN WPSuperCache</code> and <code># END WPSuperCache</code>. There are two sections that look very similar. Just below the line <code>%{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$</code> add this line: (do it twice, once for each section)', 'wp-super-cache' ), $home_path ); ?></p>
- <div style='padding: 2px; margin: 2px; border: 1px solid #333; width:400px; overflow: scroll'><pre>RewriteCond %{HTTP_user_agent} !^.*(<?php echo addcslashes( implode( '|', $mobile_browsers ), ' ' ); ?>).*</pre></div></li></ol></blockquote>
- <?php } ?>
- <p><strong><?php _e( 'Note:', 'wp-super-cache' ); ?></strong> <?php printf( __( 'If uninstalling this plugin, make sure the directory <em>%s</em> is writeable by the webserver so the files <em>advanced-cache.php</em> and <em>cache-config.php</em> can be deleted automatically. (Making sure those files are writeable too is probably a good idea!)', 'wp-super-cache' ), WP_CONTENT_DIR ); ?></p>
- <p><?php printf( __( 'Uninstall using the <a href="%1$s/wp-super-cache/uninstall.php">uninstall script</a> to remove files and directories created by the plugin. (Please see <a href="%1$s/wp-super-cache/readme.txt">readme.txt</a> for instructions on uninstalling this script.)', 'wp-super-cache' ), WP_PLUGIN_URL ); ?></p>
- <?php if ( $_wp_using_ext_object_cache ) {
- ?><p><label><input type='checkbox' name='wp_cache_object_cache' <?php if( $wp_cache_object_cache ) echo "checked"; ?> value='1'> <?php echo __( 'Use object cache to store cached files.', 'wp-super-cache' ) . ' ' . __( '(Experimental)', 'wp-super-cache' ); ?></label></p><?php
- }
- echo "<p><em>" . sprintf( __( 'Need help? Check the <a href="%1$s">Super Cache readme file</a>. It includes installation documentation, a FAQ and Troubleshooting tips. The <a href="%2$s">support forum</a> is also available. Your question may already have been answered.', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wp-super-cache/', 'http://wordpress.org/tags/wp-super-cache?forum_id=10' ) . "</em></p>";
- echo "<div class='submit'><input type='submit' " . SUBMITDISABLED . " value='" . __( 'Update Status', 'wp-super-cache' ) . " »' /></div>";
- wp_nonce_field('wp-cache');
- ?>
- </form>
- <?php
- if( $super_cache_enabled && function_exists( 'apache_get_modules' ) ) {
- $mods = apache_get_modules();
- $required_modules = array( 'mod_mime' => __( 'Required to serve compressed supercache files properly.', 'wp-super-cache' ), 'mod_headers' => __( 'Required to set caching information on supercache pages. IE7 users will see old pages without this module.', 'wp-super-cache' ), 'mod_expires' => __( 'Set the expiry date on supercached pages. Visitors may not see new pages when they refresh or leave comments without this module.', 'wp-super-cache' ) );
- foreach( $required_modules as $req => $desc ) {
- if( !in_array( $req, $mods ) ) {
- $missing_mods[ $req ] = $desc;
- }
- }
- if( isset( $missing_mods) && is_array( $missing_mods ) ) {
- echo "<h3>" . __( 'Missing Apache Modules', 'wp-super-cache' ) . "</h3>";
- echo "<p>" . __( 'The following Apache modules are missing. The plugin will work in half-on mode without them. In full Supercache mode, your visitors may see corrupted pages or out of date content however.', 'wp-super-cache' ) . "</p>";
- echo "<ul>";
- foreach( $missing_mods as $req => $desc ) {
- echo "<li> $req - $desc</li>";
- }
- echo "</ul>";
- }
- }
- ?>
- </fieldset>
- </td><td valign='top'>
- <div style='background: #ffc; border: 1px solid #333; margin: 2px; padding: 5px'>
- <h3 align='center'><?php _e( 'Make WordPress Faster', 'wp-super-cache' ); ?></h3>
- <?php if( $wp_cache_hide_donation != 1 ) { ?>
- <p><?php printf( __( '%1$s really makes your blog go faster. Make it go faster<sup>*</sup> by buying me an <a href="%2$s">Amazon gift card</a>! Make it out to "%3$s" for whatever amount you want. Every penny helps!', 'wp-super-cache' ), '<a href="http://ocaoimh.ie/wp-super-cache/?r=wpsc">WP Super Cache</a>', 'http://ocaoimh.ie/agc', 'donncha@ocaoimh.ie' ) ?>;</p>
- <p><?php printf( __( 'If Amazon isn’t your thing, there’s also PayPal. Click the "Donate" button below or take a quick peek at my <a href="%s">wishlist</a>.', 'wp-super-cache' ), 'http://ocaoimh.ie/wish' ); ?></p>
- <p><?php _e( 'Thanks in advance!', 'wp-super-cache' ); ?><br />Donncha<br />
- <small>* <?php _e( 'Ok, it won’t go any faster but you’ll make this plugin author very happy!', 'wp-super-cache' ); ?></small></p>
- <div align='center'>
- <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
- <input type="hidden" name="cmd" value="_s-xclick"/>
- <input type="hidden" name="hosted_button_id" value="3244504"/>
- <input type="image" src="https://www.paypal.com/en_GB/i/btn/btn_donate_SM.gif" border="0" name="submit" alt=""/>
- <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"/><br />
- </form>
- <p><?php _e( 'Don’t show me this again.', 'wp-super-cache' ); ?> <form action="#top" method="post"><input type='hidden' name='wp_cache_hide_donation' value='1' /><input type='submit' value='<?php _e( 'Hide', 'wp-super-cache' ); ?>' /><?php wp_nonce_field('wp-cache'); ?></form></p>
- </div>
- <?php } else { ?>
- <p><?php printf( __( '%1$s is maintained and developed by %2$s with contributions from many others.', 'wp-super-cache' ), '<a href="http://ocaoimh.ie/wp-super-cache/?r=supercache">WP Super Cache</a>', '<a href="http://ocaoimh.ie/?r=supercache">Donncha O Caoimh</a>' ); ?></p>
- <p><?php printf( __( 'He blogs at %1$s, posts photos at %2$s and <a href="%3$s">wishes</a> he had more time to read and relax.', 'wp-super-cache' ), '<a href="http://ocaoimh.ie/?r=supercache">Holy Shmoly</a>', '<a href="http://inphotos.org/?r=supercache">In Photos.org</a>', 'http://ocaoimh.ie/gad' ); ?></p>
- <p><?php printf( __( 'Please say hi to him on %s too!', 'wp-super-cache' ), '<a href="http://twitter.com/donncha/">Twitter</a>' ); ?></p>
- <?php
- }
- if ( isset( $wp_supercache_cache_list ) && $wp_supercache_cache_list ) {
- $start_date = get_option( 'wpsupercache_start' );
- if ( !$start_date ) {
- $start_date = time();
- }
- ?>
- <p><?php printf( __( 'Cached pages since %1$s : <strong>%2$s</strong>', 'wp-super-cache' ), date( 'M j, Y', $start_date ), number_format( get_option( 'wpsupercache_count' ) ) ); ?></p>
- <p><?php _e( 'Newest Cached Pages:', 'wp-super-cache' ); ?><ol>
- <?php
- foreach( array_reverse( (array)get_option( 'supercache_last_cached' ) ) as $url ) {
- $since = time() - strtotime( $url[ 'date' ] );
- echo "<li><a title='" . sprintf( __( 'Cached %s seconds ago', 'wp-super-cache' ), $since ) . "' href='" . site_url( $url[ 'url' ] ) . "'>{$url[ 'url' ]}</a></li>\n";
- }
- ?></ol>
- <small><?php _e( '(may not always be accurate on busy sites)', 'wp-super-cache' ); ?></small>
- </p><?php
- } else {
- $start_date = get_option( 'wpsupercache_start' );
- if ( $start_date ) {
- update_option( 'wpsupercache_start', $start_date );
- update_option( 'wpsupercache_count', 0 );
- }
- }
- ?>
- </div>
- </td></table>
- <?php
- wp_cache_files();
- wsc_mod_rewrite( $mobile_browsers );
- wp_cache_edit_max_time();
- echo '<a name="files"></a><fieldset class="options"><h3>' . __( 'Accepted Filenames & Rejected URIs', 'wp-super-cache' ) . '</h3>';
- wp_cache_edit_rejected_pages();
- echo "\n";
- wp_cache_edit_rejected();
- echo "\n";
- wp_cache_edit_accepted();
- echo '</fieldset>';
- wp_cache_edit_rejected_ua();
- wp_cache_debug_settings();
- wp_lock_down();
- wp_cache_restore();
- ob_start();
- if( defined( 'WP_CACHE' ) ) {
- if( function_exists( 'do_cacheaction' ) ) {
- do_cacheaction( 'cache_admin_page' );
- }
- }
- $out = ob_get_contents();
- ob_end_clean();
- if( SUBMITDISABLED == ' ' && $out != '' ) {
- echo '<fieldset class="options"><h3>' . __( 'Cache Plugins', 'wp-super-cache' ) . '</h3>';
- echo $out;
- echo '</fieldset>';
- }
- echo "</div>\n";
- }
- function wsc_mod_rewrite( $mobile_browsers ) {
- global $cache_enabled, $super_cache_enabled, $cache_compression, $cache_compression_changed, $valid_nonce, $cache_path;
- if( $super_cache_enabled == false && $cache_enabled == true ) {
- ?><h3><?php _e( 'Super Cache Compression', 'wp-super-cache' ); ?></h3>
- <p><?php _e( 'Compression is enabled by default when in <em>HALF ON</em> mode.', 'wp-super-cache' ); ?></p>
- <?php
- return;
- } elseif ( $super_cache_enabled == false ) {
- return;
- }
- if( false == defined( 'WPSC_DISABLE_COMPRESSION' ) ) {
- ?>
- <a name='rewrite'></a>
- <fieldset class="options">
- <h3><?php _e( 'Super Cache Compression', 'wp-super-cache' ); ?></h3>
- <form name="wp_manager" action="#rewrite" method="post">
- <label><input type="radio" name="cache_compression" value="1" <?php if( $cache_compression ) { echo "checked=checked"; } ?>> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label>
- <label><input type="radio" name="cache_compression" value="0" <?php if( !$cache_compression ) { echo "checked=checked"; } ?>> <?php _e( 'Disabled', 'wp-super-cache' ); ?></label>
- <p><?php _e( 'Compression is disabled by default because some hosts have problems with compressed files. Switching this on and off clears the cache.', 'wp-super-cache' ); ?></p>
- <?php
- if( isset( $cache_compression_changed ) && isset( $_POST[ 'cache_compression' ] ) && !$cache_compression ) {
- ?><p><strong><?php _e( 'Super Cache compression is now disabled.', 'wp-super-cache' ); ?></strong></p> <?php
- } elseif( isset( $cache_compression_changed ) && isset( $_POST[ 'cache_compression' ] ) && $cache_compression ) {
- ?><p><strong><?php _e( 'Super Cache compression is now enabled.', 'wps-uper-cache' ); ?></strong></p><?php
- }
- echo '<div class="submit"><input ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update Compression', 'wp-super-cache' ) . ' »" /></div>';
- wp_nonce_field('wp-cache');
- echo "</form>\n";
- ?></fieldset>
- <?php } ?>
- <a name="modrewrite"></a><fieldset class="options">
- <h3><?php _e( 'Mod Rewrite Rules', 'wp-super-cache' ); ?></h3><?php
- if ( isset( $_SERVER[ "PHP_DOCUMENT_ROOT" ] ) ) {
- $document_root = $_SERVER[ "PHP_DOCUMENT_ROOT" ];
- $apache_root = $_SERVER[ "PHP_DOCUMENT_ROOT" ];
- } else {
- $document_root = $_SERVER[ "DOCUMENT_ROOT" ];
- $apache_root = '%{DOCUMENT_ROOT}';
- }
- $home_path = get_home_path();
- $home_root = parse_url(get_bloginfo('url'));
- $home_root = isset( $home_root['path'] ) ? trailingslashit( $home_root['path'] ) : '/';
- $inst_root = str_replace( '//', '/', '/' . trailingslashit( str_replace( $document_root, '', str_replace( '\\', '/', WP_CONTENT_DIR ) ) ) );
- $wprules = implode( "\n", extract_from_markers( $home_path.'.htaccess', 'WordPress' ) );
- $wprules = str_replace( "RewriteEngine On\n", '', $wprules );
- $wprules = str_replace( "RewriteBase $home_root\n", '', $wprules );
- $scrules = implode( "\n", extract_from_markers( $home_path.'.htaccess', 'WPSuperCache' ) );
- if( substr( get_option( 'permalink_structure' ), -1 ) == '/' ) {
- $condition_rules[] = "RewriteCond %{REQUEST_URI} !^.*[^/]$";
- $condition_rules[] = "RewriteCond %{REQUEST_URI} !^.*//.*$";
- }
- $condition_rules[] = "RewriteCond %{REQUEST_METHOD} !POST";
- $condition_rules[] = "RewriteCond %{QUERY_STRING} !.*=.*";
- $condition_rules[] = "RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$";
- $condition_rules[] = "RewriteCond %{HTTP_USER_AGENT} !^.*(" . addcslashes( implode( '|', $mobile_browsers ), ' ' ) . ").*";
- $condition_rules = apply_filters( 'supercacherewriteconditions', $condition_rules );
- $rules = "<IfModule mod_rewrite.c>\n";
- $rules .= "RewriteEngine On\n";
- $rules .= "RewriteBase $home_root\n"; // props Chris Messina
- $charset = get_option('blog_charset') == '' ? 'UTF-8' : get_option('blog_charset');
- $rules .= "AddDefaultCharset {$charset}\n";
- $rules .= "CONDITION_RULES";
- $rules .= "RewriteCond %{HTTP:Accept-Encoding} gzip\n";
- $rules .= "RewriteCond {$apache_root}{$inst_root}cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html.gz -f\n";
- $rules .= "RewriteRule ^(.*) {$inst_root}cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html.gz [L]\n\n";
- $rules .= "CONDITION_RULES";
- $rules .= "RewriteCond {$apache_root}{$inst_root}cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html -f\n";
- $rules .= "RewriteRule ^(.*) {$inst_root}cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html [L]\n";
- $rules .= "</IfModule>\n";
- $rules = apply_filters( 'supercacherewriterules', $rules );
- $rules = str_replace( "CONDITION_RULES", implode( "\n", $condition_rules ) . "\n", $rules );
- $dohtaccess = true;
- if( function_exists( 'is_site_admin' ) ) {
- echo "<h4 style='color: #a00'>" . __( 'WordPress MU Detected', 'wp-super-cache' ) . "</h4><p>" . __( "Unfortunately the rewrite rules cannot be updated automatically when running WordPress MU. Please open your .htaccess and add the following mod_rewrite rules above any other rules in that file.", 'wp-super-cache' ) . "</p>";
- } elseif( !$wprules || $wprules == '' ) {
- echo "<h4 style='color: #a00'>" . __( 'Mod Rewrite rules cannot be updated!', 'wp-super-cache' ) . "</h4>";
- echo "<p>" . sprintf( __( "You must have <strong>BEGIN</strong> and <strong>END</strong> markers in %s.htaccess for the auto update to work. They look like this and surround the main WordPress mod_rewrite rules:", 'wp-super-cache' ), $home_path );
- echo "<blockquote><pre><em># BEGIN WordPress</em>\n RewriteCond %{REQUEST_FILENAME} !-f\n RewriteCond %{REQUEST_FILENAME} !-d\n RewriteRule . /index.php [L]\n <em># END WordPress</em></pre></blockquote>";
- _e( 'Refresh this page when you have updated your .htaccess file.', 'wp-super-cache' );
- echo "</fieldset></div>";
- return;
- } elseif( strpos( $wprules, 'wordpressuser' ) ) { // Need to clear out old mod_rewrite rules
- echo "<p><strong>" . __( 'Thank you for upgrading.', 'wp-super-cache' ) . "</strong> " . sprintf( __( 'The mod_rewrite rules changed since you last installed this plugin. Unfortunately you must remove the old supercache rules before the new ones are updated. Refresh this page when you have edited your .htaccess file. If you wish to manually upgrade, change the following line: %1$s so it looks like this: %2$s The only changes are "HTTP_COOKIE" becomes "HTTP:Cookie" and "wordpressuser" becomes "wordpress". This is a WordPress 2.5 change but it’s backwards compatible with older versions if you’re brave enough to use them.', 'wp-super-cache' ), '<blockquote><code>RewriteCond %{HTTP_COOKIE} !^.*wordpressuser.*$</code></blockquote>', '<blockquote><code>RewriteCond %{HTTP:Cookie} !^.*wordpress.*$</code></blockquote>' ) . "</p>";
- echo "</fieldset></div>";
- return;
- } elseif( $scrules != '' && strpos( $scrules, '%{REQUEST_URI} !^.*[^/]$' ) === false && substr( get_option( 'permalink_structure' ), -1 ) == '/' ) { // permalink structure has a trailing slash, need slash check in rules.
- echo "<div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><h4>" . __( 'Trailing slash check required.', 'wp-super-cache' ) . "</h4><p>" . __( 'It looks like your blog has URLs that end with a "/". Unfortunately since you installed this plugin a duplicate content bug has been found where URLs not ending in a "/" end serve the same content as those with the "/" and do not redirect to the proper URL. To fix, you must edit your .htaccess file and add these two rules to the two groups of Super Cache rules:', 'wp-super-cache' ) . "</p>";
- echo "<blockquote><code>RewriteCond %{REQUEST_URI} !^.*[^/]$RewriteCond %{REQUEST_URI} !^.*//.*$</code></blockquote>";
- echo "<p>" . __( 'You can see where the rules go and examine the complete rules by clicking the "View mod_rewrite rules" link below.', 'wp-super-cache' ) . "</p></div>";
- $dohtaccess = false;
- } elseif( strpos( $scrules, 'supercache' ) || strpos( $wprules, 'supercache' ) ) { // only write the rules once
- $dohtaccess = false;
- }
- // cache/.htaccess rules
- $gziprules = "<IfModule mod_mime.c>\n <FilesMatch \"\\.html\\.gz\$\">\n ForceType text/html\n FileETag None\n </FilesMatch>\n AddEncoding gzip .gz\n AddType text/html .gz\n</IfModule>\n";
- $gziprules .= "<IfModule mod_deflate.c>\n SetEnvIfNoCase Request_URI \.gz$ no-gzip\n</IfModule>\n";
- $gziprules .= "<IfModule mod_headers.c>\n Header set Vary \"Accept-Encoding, Cookie\"\n Header set Cache-Control 'max-age=300, must-revalidate'\n</IfModule>\n";
- $gziprules .= "<IfModule mod_expires.c>\n ExpiresActive On\n ExpiresByType text/html A300\n</IfModule>\n";
- if( $dohtaccess && !$_POST[ 'updatehtaccess' ] ) {
- if( !is_writeable_ACLSafe( $home_path . ".htaccess" ) ) {
- echo "<div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><h4>" . __( 'Cannot update .htaccess', 'wp-super-cache' ) . "</h4><p>" . sprintf( __( 'The file <code>%s.htaccess</code> cannot be modified by the web server. Please correct this using the chmod command or your ftp client.', 'wp-super-cache' ), $home_path ) . "</p><p>" . __( 'Refresh this page when the file permissions have been modified.' ) . "</p><p>" . sprintf( __( 'Alternatively, you can edit your <code>%s.htaccess</code> file manually and add the following code (before any WordPress rules):', 'wp-super-cache' ), $home_path ) . "</p>";
- echo "<p><pre># BEGIN WPSuperCache\n" . wp_specialchars( $rules ) . "# END WPSuperCache</pre></p></div>";
- } else {
- echo "<div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><p>" . sprintf( __( 'To serve static html files your server must have the correct mod_rewrite rules added to a file called <code>%s.htaccess</code>', 'wp-super-cache' ), $home_path ) . " ";
- if( !function_exists( 'is_site_admin' ) ) {
- _e( "You must edit the file yourself add the following rules.", 'wp-super-cache' );
- } else {
- _e( "You can edit the file yourself add the following rules.", 'wp-super-cache' );
- }
- echo __( " Make sure they appear before any existing WordPress rules. ", 'wp-super-cache' ) . "</p>";
- echo "<pre># BEGIN WPSuperCache\n" . wp_specialchars( $rules ) . "# END WPSuperCache</pre></p>";
- echo "<p>" . sprintf( __( 'Rules must be added to %s too:', 'wp-super-cache' ), WP_CONTENT_DIR . "/cache/.htaccess" ) . "</p>";
- echo "<pre># BEGIN supercache\n" . wp_specialchars( $gziprules ) . "# END supercache</pre></p>";
- if( !function_exists( 'is_site_admin' ) ) {
- echo '<form name="updatehtaccess" action="#modrewrite" method="post">';
- echo '<input type="hidden" name="updatehtaccess" value="1" />';
- echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'id="updatehtaccess" value="' . __( 'Update Mod_Rewrite Rules', 'wp-super-cache' ) . ' »" /></div>';
- wp_nonce_field('wp-cache');
- echo "</form></div>\n";
- }
- }
- } elseif( $dohtaccess && $valid_nonce && $_POST[ 'updatehtaccess' ] ) {
- wpsc_remove_marker( $home_path.'.htaccess', 'WordPress' ); // remove original WP rules so SuperCache rules go on top
- echo "<div style='padding:0 8px;color:#4f8a10;background-color:#dff2bf;border:1px solid #4f8a10;'>";
- if( insert_with_markers( $home_path.'.htaccess', 'WPSuperCache', explode( "\n", $rules ) ) && insert_with_markers( $home_path.'.htaccess', 'WordPress', explode( "\n", $wprules ) ) ) {
- echo "<h4>" . __( 'Mod Rewrite rules updated!', 'wp-super-cache' ) . "</h4>";
- echo "<p><strong>" . sprintf( __( '%s.htaccess has been updated with the necessary mod_rewrite rules. Please verify they are correct. They should look like this:', 'wp-super-cache' ), $home_path ) . "</strong></p>\n";
- } else {
- echo "<h4>" . __( 'Mod Rewrite rules must be updated!', 'wp-super-cache' ) . "</h4>";
- echo "<p><strong>" . sprintf( __( 'Your %s.htaccess is not writable by the webserver and must be updated with the necessary mod_rewrite rules. The new rules go above the regular WordPress rules as shown in the code below:', 'wp-super-cache' ), $home_path ) . "</strong></p>\n";
- }
- echo "<p><pre>" . wp_specialchars( $rules ) . "</pre></p>\n</div>";
- } else {
- ?>
- <p><?php printf( __( 'WP Super Cache mod rewrite rules were detected in your %s.htaccess file.<br /> Click the following link to see the lines added to that file. If you have upgraded the plugin make sure these rules match.', 'wp-super-cache' ), $home_path ); ?><br /><br />
- <a href="javascript:toggleLayer('rewriterules');" class="button"><?php _e( 'View Mod_Rewrite Rules', 'wp-super-cache' ); ?></a>
- <div id='rewriterules' style='display: none;'>
- <?php echo "<p><pre># BEGIN WPSuperCache\n" . wp_specialchars( $rules ) . "# END WPSuperCache</pre></p>\n";
- echo "<p>" . sprintf( __( 'Rules must be added to %s too:', 'wp-super-cache' ), WP_CONTENT_DIR . "/cache/.htaccess" ) . "</p>";
- echo "<pre># BEGIN supercache\n" . wp_specialchars( $gziprules ) . "# END supercache</pre></p>"; ?>
- </div>
- <?php
- }
- // http://allmybrain.com/2007/11/08/making-wp-super-cache-gzip-compression-work/
- if( !is_file( $cache_path . '.htaccess' ) ) {
- $gziprules = insert_with_markers( $cache_path . '.htaccess', 'supercache', explode( "\n", $gziprules ) );
- echo "<h4>" . sprintf( __( 'Gzip encoding rules in %s.htaccess created.', 'wp-super-cache' ), $cache_path ) . "</h4>";
- }
- ?></fieldset><?php
- }
- function wp_cache_restore() {
- echo '<fieldset class="options"><h3>' . __( 'Fix Configuration', 'wp-super-cache' ) . '</h3>';
- echo '<form name="wp_restore" action="#top" method="post">';
- echo '<input type="hidden" name="wp_restore_config" />';
- echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'id="deletepost" value="' . __( 'Restore Default Configuration', 'wp-super-cache' ) . ' »" /></div>';
- wp_nonce_field('wp-cache');
- echo "</form>\n";
- echo '</fieldset>';
- }
- function comment_form_lockdown_message() {
- ?><p><?php _e( "Comment moderation is enabled. Your comment may take some time to appear.", 'wp-super-cache' ); ?></p><?php
- }
- if( defined( 'WPLOCKDOWN' ) && constant( 'WPLOCKDOWN' ) )
- add_action( 'comment_form', 'comment_form_lockdown_message' );
- function wp_lock_down() {
- global $wpdb, $cache_path, $wp_cache_config_file, $valid_nonce, $cached_direct_pages, $cache_enabled, $super_cache_enabled;
- if(isset($_POST['wp_lock_down']) && $valid_nonce) {
- $wp_lock_down = $_POST['wp_lock_down'] == '1' ? '1' : '0';
- wp_cache_replace_line('^.*WPLOCKDOWN', "define( 'WPLOCKDOWN', '$wp_lock_down' );", $wp_cache_config_file);
- if( $wp_lock_down == '0' && function_exists( 'prune_super_cache' ) )
- prune_super_cache( $cache_path, true ); // clear the cache after lockdown
- }
- if( !isset( $wp_lock_down ) ) {
- if( defined( 'WPLOCKDOWN' ) ) {
- $wp_lock_down = constant( 'WPLOCKDOWN' );
- } else {
- $wp_lock_down = '0';
- }
- }
- ?><a name='lockdown'></a>
- <fieldset class="options">
- <h3><?php _e( 'Lock Down:', 'wp-super-cache' ); ?> <?php echo $wp_lock_down == '0' ? '<span style="color:red">' . __( 'Disabled', 'wp-super-cache' ) . '</span>' : '<span style="color:green">' . __( 'Enabled', 'wp-super-cache' ) . '</span>'; ?></h3>
- <p><?php _e( 'Prepare your server for an expected spike in traffic by enabling the lock down. When this is enabled, new comments on a post will not refresh the cached static files.', 'wp-super-cache' ); ?></p>
- <p><?php _e( 'Developers: Make your plugin lock down compatible by checking the "WPLOCKDOWN" constant. The following code will make sure your plugin respects the WPLOCKDOWN setting.', 'wp-super-cache' ); ?>
- <blockquote><code>if( defined( 'WPLOCKDOWN' ) && constant( 'WPLOCKDOWN' ) ) {
- echo "<?php _e( 'Sorry. My blog is locked down. Updates will appear shortly', 'wp-super-cache' ); ?>";
- }</code></blockquote>
- <?php
- if( $wp_lock_down == '1' ) {
- ?><p><?php _e( 'WordPress is locked down. Super Cache static files will not be deleted when new comments are made.', 'wp-super-cache' ); ?></p><?php
- } else {
- ?><p><?php _e( 'WordPress is not locked down. New comments will refresh Super Cache static files as normal.', 'wp-super-cache' ); ?></p><?php
- }
- $new_lockdown = $wp_lock_down == '1' ? '0' : '1';
- $new_lockdown_desc = $wp_lock_down == '1' ? __( 'Disable', 'wp-super-cache' ) : __( 'Enable', 'wp-super-cache' );
- echo '<form name="wp_lock_down" action="#lockdown" method="post">';
- echo "<input type='hidden' name='wp_lock_down' value='{$new_lockdown}' />";
- echo "<div class='submit'><input type='submit' " . SUBMITDISABLED . " value='{$new_lockdown_desc} " . __( 'Lock Down', 'wp-super-cache' ) . " »' /></div>";
- wp_nonce_field('wp-cache');
- echo "</form>\n";
- ?></fieldset><?php
- if( $cache_enabled == true && $super_cache_enabled == true ) {
- ?><a name='direct'></a>
- <fieldset class="options">
- <h3><?p…
Large files files are truncated, but you can click here to view the full file