' . __( 'Warning! PHP Safe Mode Enabled!', 'wp-super-cache' ) . '

' . __( 'You may experience problems running this plugin because SAFE MODE is enabled.', 'wp-super-cache' ) . ' '; if( !ini_get( 'safe_mode_gid' ) ) { _e( 'Your server is set up to check the owner of PHP scripts before allowing them to read and write files.', 'wp-super-cache' ) . " "; printf( __( '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 safe mode manual page for further details.', 'wp-super-cache' ), WP_CONTENT_DIR ); } else { _e( 'You or an administrator must disable this. See the safe mode manual page 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' ); } echo '

'; } if ( '' == get_option( 'permalink_structure' ) ) { echo '

' . __( 'Permlink Structure Error', 'wp-super-cache' ) . '

'; echo "

" . __( 'A custom url or permalink structure is required for this plugin to work correctly. Please go to the Permalinks Options Page to configure your permalinks.' ) . "

"; echo '
'; return false; } 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' ) { ?>

Troubleshooting section of the readme.txt', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wp-super-cache/faq/' ); ?>

0.01, 'blocking' => true)); if( is_array( $cron ) ) { if( $cron[ 'response' ][ 'code' ] == '404' ) { ?>

Warning! wp-cron.php not found!

Troubleshooting section of the readme.txt', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wp-super-cache/faq/' ); ?>

' . __( "Cannot continue... fix previous problems and retry.", 'wp-super-cache' ) . '

'; return false; } if (!wp_cache_check_global_config()) { return false; } if ( 1 == ini_get( 'zlib.output_compression' ) || "on" == strtolower( ini_get( 'zlib.output_compression' ) ) ) { ?>

this page for instructions on modifying your php.ini.', 'wp-super-cache' ); ?>

%s/wp-cache-config.php and cannot be modified. That file must be writeable by the webserver to make any changes.', 'wp-super-cache' ), WP_CONTENT_DIR ); ?>

This page explains how to change file permissions.', 'wp-super-cache' ); ?>

chmod 666 /wp-cache-config.php chmod 644 /wp-cache-config.php

chmod 755 /

This page explains how to change file permissions.', 'wp-super-cache' ); ?>

' . __( 'Mobile rewrite rules detected', 'wp-super-cache' ) . "

"; echo "

" . __( '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' ) . "

" . __( 'This will have no affect on ordinary users but mobile users will see uncached pages.', 'wp-super-cache' ) . "

"; } elseif ( $wp_cache_mod_rewrite && $cache_enabled && $wp_cache_mobile_enabled && $scrules != '' && ( false === strpos( $scrules, addcslashes( implode( '|', $wp_cache_mobile_prefixes ), ' ' ) ) || false === strpos( $scrules, addcslashes( implode( '|', $wp_cache_mobile_browsers ), ' ' ) ) ) ) { ?>

  1. Update Mod_Rewrite Rules button.', 'wp-super-cache' ); ?>
  2. # BEGIN WPSuperCache and # END WPSuperCache and let the plugin regenerate them by reloading this page.', 'wp-super-cache' ), $home_path ); ?>
  3. # BEGIN WPSuperCache and # END WPSuperCache. There are two sections that look very similar. Just below the line %%{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$ add these lines: (do it twice, once for each section)', 'wp-super-cache' ), $home_path ); ?>

Update Mod_Rewrite Rules button.', 'wp-super-cache' ); ?>

__( '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 ) ) { ?>

"; foreach( $missing_mods as $req => $desc ) { echo "
  • $req - $desc
  • "; } echo ""; echo "
    "; } } return true; } add_filter( 'wp_super_cache_error_checking', 'wp_cache_manager_error_checks' ); function wp_cache_manager_updates() { global $wp_cache_mobile_enabled, $wp_supercache_cache_list, $wp_cache_config_file, $wp_cache_hello_world, $wp_cache_clear_on_post_edit, $cache_rebuild_files, $wp_cache_mutex_disabled, $wp_cache_not_logged_in, $cache_path, $wp_cache_object_cache, $_wp_using_ext_object_cache, $wp_cache_refresh_single_only, $cache_compression, $wp_cache_mod_rewrite, $wp_supercache_304, $wp_super_cache_late_init, $wp_cache_front_page_checks; if ( !wpsupercache_site_admin() ) return false; $valid_nonce = isset($_REQUEST['_wpnonce']) ? wp_verify_nonce($_REQUEST['_wpnonce'], 'wp-cache') : false; if ( $valid_nonce == false ) return false; if ( isset( $_POST[ 'action' ] ) && $_POST[ 'action' ] == 'easysetup' ) { $_POST[ 'action' ] = 'scupdates'; if( isset( $_POST[ 'wp_cache_easy_on' ] ) && $_POST[ 'wp_cache_easy_on' ] == 1 ) { $_POST[ 'wp_cache_mobile_enabled' ] = 1; $_POST[ 'wp_cache_status' ] = 'all'; $_POST[ 'super_cache_enabled' ] = 2; // PHP $_POST[ 'cache_rebuild_files' ] = 1; unset( $_POST[ 'cache_compression' ] ); } else { unset( $_POST[ 'wp_cache_status' ] ); $_POST[ 'super_cache_enabled' ] = 0; } } if( isset( $_POST[ 'action' ] ) && $_POST[ 'action' ] == 'scupdates' ) { if( isset( $_POST[ 'wp_super_cache_late_init' ] ) ) { $wp_super_cache_late_init = 1; } else { $wp_super_cache_late_init = 0; } wp_cache_replace_line('^ *\$wp_super_cache_late_init', "\$wp_super_cache_late_init = " . $wp_super_cache_late_init . ";", $wp_cache_config_file); if( isset( $_POST[ 'wp_supercache_304' ] ) ) { $wp_supercache_304 = 1; } else { $wp_supercache_304 = 0; } wp_cache_replace_line('^ *\$wp_supercache_304', "\$wp_supercache_304 = " . $wp_supercache_304 . ";", $wp_cache_config_file); if( isset( $_POST[ 'wp_cache_mobile_enabled' ] ) ) { $wp_cache_mobile_enabled = 1; } else { $wp_cache_mobile_enabled = 0; } wp_cache_replace_line('^ *\$wp_cache_mobile_enabled', "\$wp_cache_mobile_enabled = " . $wp_cache_mobile_enabled . ";", $wp_cache_config_file); if( isset( $_POST[ 'wp_cache_front_page_checks' ] ) ) { $wp_cache_front_page_checks = 1; } else { $wp_cache_front_page_checks = 0; } wp_cache_replace_line('^ *\$wp_cache_front_page_checks', "\$wp_cache_front_page_checks = " . $wp_cache_front_page_checks . ";", $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); if ( isset( $_POST[ 'wp_cache_status' ] ) ) { if ( $_POST[ 'wp_cache_status' ] == 'all' ) wp_cache_enable(); if ( isset( $_POST[ 'super_cache_enabled' ] ) ) { if ( $_POST[ 'super_cache_enabled' ] == 0 ) { wp_cache_enable(); wp_super_cache_disable(); } if( $_POST[ 'super_cache_enabled' ] == 1 ) { $wp_cache_mod_rewrite = 1; // we need this because supercached files can be served by PHP too. } else { $wp_cache_mod_rewrite = 0; } wp_cache_replace_line('^ *\$wp_cache_mod_rewrite', '$wp_cache_mod_rewrite = ' . $wp_cache_mod_rewrite . ";", $wp_cache_config_file); } } else { wp_cache_disable(); } 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 = ' . $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( isset( $_POST[ 'wp_cache_refresh_single_only' ] ) ) { $wp_cache_refresh_single_only = 1; } else { $wp_cache_refresh_single_only = 0; } wp_cache_replace_line('^ *\$wp_cache_refresh_single_only', "\$wp_cache_refresh_single_only = '" . $wp_cache_refresh_single_only . "';", $wp_cache_config_file); if ( defined( 'WPSC_DISABLE_COMPRESSION' ) ) { $cache_compression = 0; wp_cache_replace_line('^ *\$cache_compression', "\$cache_compression = " . $cache_compression . ";", $wp_cache_config_file); } else { if ( isset( $_POST[ 'cache_compression' ] ) ) { $new_cache_compression = 1; } else { $new_cache_compression = 0; } if ( 1 == ini_get( 'zlib.output_compression' ) || "on" == strtolower( ini_get( 'zlib.output_compression' ) ) ) { echo '
    ' . __( "Warning! You attempted to enable compression but zlib.output_compression is enabled. See #21 in the Troubleshooting section of the readme file.", 'wp-super-cache' ) . '
    '; } else { if ( $new_cache_compression != $cache_compression ) { $cache_compression = $new_cache_compression; 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( $_GET[ 'page' ] ) && $_GET[ 'page' ] == 'wpsupercache' ) add_action( 'admin_init', 'wp_cache_manager_updates' ); 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_not_logged_in, $wp_supercache_cache_list; global $wp_super_cache_front_page_check, $wp_cache_object_cache, $_wp_using_ext_object_cache, $wp_cache_refresh_single_only, $wp_cache_mobile_prefixes; global $wpmu_version, $cache_max_time, $wp_cache_mod_rewrite, $wp_supercache_304, $wp_super_cache_late_init, $wp_cache_front_page_checks; if ( !wpsupercache_site_admin() ) return false; // used by mod_rewrite rules and config file if ( function_exists( "cfmobi_default_browsers" ) ) { $wp_cache_mobile_browsers = cfmobi_default_browsers( "mobile" ); $wp_cache_mobile_browsers = array_merge( $wp_cache_mobile_browsers, cfmobi_default_browsers( "touch" ) ); } elseif ( function_exists( 'lite_detection_ua_contains' ) ) { $wp_cache_mobile_browsers = explode( '|', lite_detection_ua_contains() ); } else { $wp_cache_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 ( function_exists( "lite_detection_ua_prefixes" ) ) { $wp_cache_mobile_prefixes = lite_detection_ua_prefixes(); } else { $wp_cache_mobile_prefixes = array( 'w3c ', 'w3c-', 'acs-', 'alav', 'alca', 'amoi', 'audi', 'avan', 'benq', 'bird', 'blac', 'blaz', 'brew', 'cell', 'cldc', 'cmd-', 'dang', 'doco', 'eric', 'hipt', 'htc_', 'inno', 'ipaq', 'ipod', 'jigs', 'kddi', 'keji', 'leno', 'lg-c', 'lg-d', 'lg-g', 'lge-', 'lg/u', 'maui', 'maxo', 'midp', 'mits', 'mmef', 'mobi', 'mot-', 'moto', 'mwbp', 'nec-', 'newt', 'noki', 'palm', 'pana', 'pant', 'phil', 'play', 'port', 'prox', 'qwap', 'sage', 'sams', 'sany', 'sch-', 'sec-', 'send', 'seri', 'sgh-', 'shar', 'sie-', 'siem', 'smal', 'smar', 'sony', 'sph-', 'symb', 't-mo', 'teli', 'tim-', 'tosh', 'tsm-', 'upg1', 'upsi', 'vk-v', 'voda', 'wap-', 'wapa', 'wapi', 'wapp', 'wapr', 'webc', 'winw', 'winw', 'xda ', 'xda-' ); // from http://svn.wp-plugins.org/wordpress-mobile-pack/trunk/plugins/wpmp_switcher/lite_detection.php } $wp_cache_mobile_browsers = apply_filters( 'cached_mobile_browsers', $wp_cache_mobile_browsers ); // Allow mobile plugins access to modify the mobile UA list $wp_cache_mobile_prefixes = apply_filters( 'cached_mobile_prefixes', $wp_cache_mobile_prefixes ); // Allow mobile plugins access to modify the mobile UA prefix list $mobile_groups = apply_filters( 'cached_mobile_groups', array() ); // Group mobile user agents by capabilities. Lump them all together by default // mobile_groups = array( 'apple' => array( 'ipod', 'iphone' ), 'nokia' => array( 'nokia5800', 'symbianos' ) ); if ( false == apply_filters( 'wp_super_cache_error_checking', true ) ) return false; $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 */ ?> '; echo '
    '; echo '

    ' . __( 'WP Super Cache Settings', 'wp-super-cache' ) . '

    '; // set a default if ( $cache_enabled == false && isset( $wp_cache_mod_rewrite ) == false ) { $wp_cache_mod_rewrite = 0; } elseif ( !isset( $wp_cache_mod_rewrite ) && $cache_enabled && $super_cache_enabled ) { $wp_cache_mod_rewrite = 1; } if ( !isset( $_GET[ 'tab' ] ) && $cache_enabled && ( $wp_cache_mod_rewrite || $super_cache_enabled == false ) ) { $_GET[ 'tab' ] = 'settings'; echo '

    ' . __( 'Notice: Mod_rewrite or Legacy caching enabled. Showing Advanced Settings Page by default.', 'wp-super-cache' ) . '

    '; } wpsc_admin_tabs(); 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 '' . __( 'Configuration file changed, some values might be wrong. Load the page again from the "Settings" menu to reset them.', 'wp-super-cache' ) . ''; } if ( substr( get_option( 'permalink_structure' ), -1 ) == '/' ) { wp_cache_replace_line('^ *\$wp_cache_slash_check', "\$wp_cache_slash_check = 1;", $wp_cache_config_file); } else { wp_cache_replace_line('^ *\$wp_cache_slash_check', "\$wp_cache_slash_check = 0;", $wp_cache_config_file); } if( $wp_cache_mobile_enabled == 1 ) { update_cached_mobile_ua_list( $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes, $mobile_groups ); } ?>
    '; wp_cache_files(); break; case "preload": if ( !$cache_enabled ) wp_die( __( 'Caching must be enabled to use this feature', 'wp-super-cache' ) ); echo ''; if ( $super_cache_enabled == true && false == defined( 'DISABLESUPERCACHEPRELOADING' ) ) { global $wp_cache_preload_interval, $wp_cache_preload_on, $wp_cache_preload_email_me, $wp_cache_preload_email_volume, $wp_cache_preload_posts, $wpdb; $count = $wpdb->get_var( "SELECT count(*) FROM {$wpdb->posts} WHERE post_status = 'publish'" ); if ( $count > 1000 ) { $min_refresh_interval = 720; } else { $min_refresh_interval = 30; } if ( array_key_exists('action', $_POST) && $_POST[ 'action' ] == 'preload' && $valid_nonce ) { if ( $_POST[ 'posts_to_cache' ] == 'all' ) { $wp_cache_preload_posts = 'all'; } else { $wp_cache_preload_posts = (int)$_POST[ 'posts_to_cache' ]; } wp_cache_replace_line('^ *\$wp_cache_preload_posts', "\$wp_cache_preload_posts = '$wp_cache_preload_posts';", $wp_cache_config_file); if ( isset( $_POST[ 'preload' ] ) && $_POST[ 'preload' ] == __( 'Cancel Cache Preload', 'wp-super-cache' ) ) { $next_preload = wp_next_scheduled( 'wp_cache_preload_hook' ); if ( $next_preload ) { update_option( 'preload_cache_counter', array( 'c' => 0, 't' => time() ) ); wp_unschedule_event( $next_preload, 'wp_cache_preload_hook' ); } $fp = @fopen( $cache_path . "stop_preload.txt", 'w' ); @fclose( $fp ); echo "

    " . __( 'Scheduled preloading of cache cancelled.', 'wp-super-cache' ) . "

    "; } elseif ( isset( $_POST[ 'custom_preload_interval' ] ) && ( $_POST[ 'custom_preload_interval' ] == 0 || $_POST[ 'custom_preload_interval' ] >= $min_refresh_interval ) ) { // if preload interval changes than unschedule any preload jobs and schedule any new one. $_POST[ 'custom_preload_interval' ] = (int)$_POST[ 'custom_preload_interval' ]; if ( $wp_cache_preload_interval != $_POST[ 'custom_preload_interval' ] ) { $next_preload = wp_next_scheduled( 'wp_cache_full_preload_hook' ); if ( $next_preload ) { update_option( 'preload_cache_counter', array( 'c' => 0, 't' => time() ) ); add_option( 'preload_cache_stop', 1 ); wp_unschedule_event( $next_preload, 'wp_cache_full_preload_hook' ); if ( $wp_cache_preload_interval == 0 ) { echo "

    " . __( 'Scheduled preloading of cache cancelled.', 'wp-super-cache' ) . "

    "; } } if ( $_POST[ 'custom_preload_interval' ] != 0 ) wp_schedule_single_event( time() + ( $_POST[ 'custom_preload_interval' ] * 60 ), 'wp_cache_full_preload_hook' ); } $wp_cache_preload_interval = (int)$_POST[ 'custom_preload_interval' ]; wp_cache_replace_line('^ *\$wp_cache_preload_interval', "\$wp_cache_preload_interval = $wp_cache_preload_interval;", $wp_cache_config_file); if ( isset( $_POST[ 'preload_email_me' ] ) ) { $wp_cache_preload_email_me = 1; } else { $wp_cache_preload_email_me = 0; } wp_cache_replace_line('^ *\$wp_cache_preload_email_me', "\$wp_cache_preload_email_me = $wp_cache_preload_email_me;", $wp_cache_config_file); if ( isset( $_POST[ 'wp_cache_preload_email_volume' ] ) && in_array( $_POST[ 'wp_cache_preload_email_volume' ], array( 'less', 'medium', 'many' ) ) ) { $wp_cache_preload_email_volume = $_POST[ 'wp_cache_preload_email_volume' ]; } else { $wp_cache_preload_email_volume = 'medium'; } wp_cache_replace_line('^ *\$wp_cache_preload_email_volume', "\$wp_cache_preload_email_volume = '$wp_cache_preload_email_volume';", $wp_cache_config_file); if ( isset( $_POST[ 'preload_on' ] ) ) { $wp_cache_preload_on = 1; } else { $wp_cache_preload_on = 0; } wp_cache_replace_line('^ *\$wp_cache_preload_on', "\$wp_cache_preload_on = $wp_cache_preload_on;", $wp_cache_config_file); if ( isset( $_POST[ 'preload' ] ) && $_POST[ 'preload' ] == __( 'Preload Cache Now', 'wp-super-cache' ) ) { @unlink( $cache_path . "preload_mutex.tmp" ); update_option( 'preload_cache_counter', array( 'c' => 0, 't' => time() ) ); wp_schedule_single_event( time() + 10, 'wp_cache_preload_hook' ); echo "

    " . __( 'Scheduled preloading of cache in 10 seconds.' ) . "

    "; } elseif ( (int)$_POST[ 'custom_preload_interval' ] ) { @unlink( $cache_path . "preload_mutex.tmp" ); update_option( 'preload_cache_counter', array( 'c' => 0, 't' => time() ) ); wp_schedule_single_event( time() + ( (int)$_POST[ 'custom_preload_interval' ] * 60 ), 'wp_cache_full_preload_hook' ); echo "

    " . sprintf( __( 'Scheduled preloading of cache in %d minutes', 'wp-super-cache' ), (int)$_POST[ 'custom_preload_interval' ] ) . "

    "; } } } echo '

    ' . __( 'This will cache every published post and page on your site. It will create supercache static files so unknown visitors (including bots) will hit a cached page. This will probably help your Google ranking as they are using speed as a metric when judging websites now.', 'wp-super-cache' ) . '

    '; echo '

    ' . __( 'Preloading creates lots of files however. Caching is done from the newest post to the oldest so please consider only caching the newest if you have lots (10,000+) of posts. This is especially important on shared hosting.', 'wp-super-cache' ) . '

    '; echo '

    ' . __( 'In ’Preload Mode’ regular garbage collection will only clean out old legacy files for known users, not the preloaded supercache files. This is a recommended setting when the cache is preloaded.', 'wp-super-cache' ) . '

    '; echo '
    '; echo ''; echo ''; echo '

    ' . sprintf( __( 'Refresh preloaded cache files every %s minutes. (0 to disable, minimum %d minutes.)', 'wp-super-cache' ), "", $min_refresh_interval ) . '

    '; if ( $count > 100 ) { $step = (int)( $count / 10 ); $select = ""; echo '

    ' . sprintf( __( 'Preload %s posts.', 'wp-super-cache' ), $select ) . '

    '; } else { echo ''; } echo ' ' . __( 'Preload mode (garbage collection only on legacy cache files. Recommended.)', 'wp-super-cache' ) . '
    '; echo ' ' . __( 'Send me status emails when files are refreshed.', 'wp-super-cache' ) . '
    '; if ( !isset( $wp_cache_preload_email_volume ) ) $wp_cache_preload_email_volume = 'many'; echo '     ' . __( 'Many emails, 2 emails per 100 posts.', 'wp-super-cache' ) . '
    '; echo '     ' . __( 'Medium, 1 email per 100 posts.', 'wp-super-cache' ) . '
    '; echo '     ' . __( 'Less emails, 1 at the start and 1 at the end of preloading all posts.', 'wp-super-cache' ) . '
    '; $currently_preloading = false; next_preload_message( 'wp_cache_preload_hook', __( 'Refresh of cache in %d hours %d minutes and %d seconds.', 'wp-super-cache' ), 60 ); next_preload_message( 'wp_cache_full_preload_hook', __( 'Full refresh of cache in %d hours %d minutes and %d seconds.', 'wp-super-cache' ) ); $preload_counter = get_option( 'preload_cache_counter' ); if ( isset( $preload_counter[ 'first' ] ) ) // converted from int to array update_option( 'preload_cache_counter', array( 'c' => $preload_counter[ 'c' ], 't' => time() ) ); if ( is_array( $preload_counter ) && $preload_counter[ 'c' ] > 0 ) { echo '

    ' . sprintf( __( 'Currently caching from post %d to %d.', 'wp-super-cache' ), ( $preload_counter[ 'c' ] - 100 ), $preload_counter[ 'c' ] ) . '

    '; $currently_preloading = true; if ( @file_exists( $cache_path . "preload_permalink.txt" ) ) { $url = file_get_contents( $cache_path . "preload_permalink.txt" ); echo "

    " . sprintf( __( "Page last cached: %s", 'wp-super-cache' ), $url ) . "

    "; } } echo '
     '; if ( $currently_preloading ) { echo ' '; } echo '
    '; wp_nonce_field('wp-cache'); echo '
    '; } else { echo '

    ' . __( 'Preloading of cache disabled. Please disable legacy page caching or talk to your host administrator.', 'wp-super-cache' ) . '

    '; } break; case 'plugins': wpsc_plugins_tab(); break; case 'debug': wp_cache_debug_settings(); break; case 'settings': if ( isset( $wp_cache_front_page_checks ) == false ) $wp_cache_front_page_checks = true; echo '
    '; wp_nonce_field('wp-cache'); echo ''; ?>
















    (" . __( "Recommended", "wp-super-cache" ) . ")"; ?>




    1. %s is writeable by the webserver so the files advanced-cache.php and cache-config.php can be deleted automatically. (Making sure those files are writeable too is probably a good idea!)', 'wp-super-cache' ), WP_CONTENT_DIR ); ?>
    2. readme.txt for instructions on uninstalling this script. Look for the heading, "How to uninstall WP Super Cache".', 'wp-super-cache' ), WP_PLUGIN_URL ); ?>
    3. " . sprintf( __( 'Need help? Check the Super Cache readme file. It includes installation documentation, a FAQ and Troubleshooting tips. The support forum 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' ) . ""; echo "
    "; echo "
    "; wp_nonce_field('wp-cache'); ?>

    ' . __( 'Accepted Filenames & Rejected URIs', 'wp-super-cache' ) . '

    '; wp_cache_edit_rejected_pages(); echo "\n"; wp_cache_edit_rejected(); echo "\n"; wp_cache_edit_accepted(); echo '
    '; wp_cache_edit_rejected_ua(); wp_lock_down(); wp_cache_restore(); break; case "easy": default: echo '
    '; echo ''; wp_nonce_field('wp-cache'); ?>



    " . __( 'Notice: PHP caching enabled but Supercache mod_rewrite rules detected. Cached files will be served using those rules. If your site is working ok please ignore this message or you can edit the .htaccess file in the root of your install and remove the SuperCache rules.', 'wp-super-cache' ) . '

    '; } } echo "
    "; if ( $cache_enabled ) { echo "

    " . __( 'Cache Tester', 'wp-super-cache' ) . "

    "; echo '

    ' . __( 'Test your cached website by clicking the test button below.', 'wp-super-cache' ) . '

    '; if ( array_key_exists('action', $_POST) && $_POST[ 'action' ] == 'test' && $valid_nonce ) { $url = trailingslashit( get_bloginfo( 'url' ) ); if ( isset( $_POST[ 'httponly' ] ) ) $url = str_replace( 'https://', 'http://', $url ); // Prime the cache echo "

    " . sprintf( __( 'Fetching %s to prime cache: ', 'wp-super-cache' ), $url ); $page = wp_remote_get( $url, array('timeout' => 60, 'blocking' => true ) ); echo '' . __( 'OK', 'wp-super-cache' ) . '

    '; sleep( 1 ); // Get the first copy echo "

    " . sprintf( __( 'Fetching first copy of %s: ', 'wp-super-cache' ), $url ); $page = wp_remote_get( $url, array('timeout' => 60, 'blocking' => true ) ); $fp = fopen( $cache_path . "1.html", "w" ); fwrite( $fp, $page[ 'body' ] ); fclose( $fp ); echo '' . __( 'OK', 'wp-super-cache' ) . " (1.html)

    "; sleep( 1 ); // Get the second copy echo "

    " . sprintf( __( 'Fetching second copy of %s: ', 'wp-super-cache' ), $url ); $page2 = wp_remote_get( $url, array('timeout' => 60, 'blocking' => true ) ); $fp = fopen( $cache_path . "2.html", "w" ); fwrite( $fp, $page2[ 'body' ] ); fclose( $fp ); echo '' . __( 'OK', 'wp-super-cache' ) . " (2.html)

    "; if ( is_wp_error( $page ) || is_wp_error( $page2 ) || $page[ 'response' ][ 'code' ] != 200 || $page2[ 'response' ][ 'code' ] != 200 ) { echo '

    ' . __( 'One or more page requests failed:', 'wp-super-cache' ) . '

    '; $error = false; if ( is_wp_error( $page ) ) { $error = $page; } elseif ( is_wp_error( $page2 ) ) { $error = $page2; } if ( $error ) { $errors = ''; $messages = ''; foreach ( $error->get_error_codes() as $code ) { $severity = $error->get_error_data($code); foreach ( $error->get_error_messages( $code ) as $err ) { $errors .= ' ' . $err . "
    \n"; } } if ( !empty($err) ) echo '
    ' . $errors . "
    \n"; } else { echo '
    • ' . sprintf( __( 'Page %d: %d (%s)', 'wp-super-cache' ), 1, $page[ 'response' ][ 'code' ], $page[ 'response' ][ 'message' ] ) . '
    • '; echo '
    • ' . sprintf( __( 'Page %d: %d (%s)', 'wp-super-cache' ), 2, $page2[ 'response' ][ 'code' ], $page2[ 'response' ][ 'message' ] ) . '
    '; } } if ( preg_match( '/(Cached page generated by WP-Super-Cache on) ([0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*)/', $page[ 'body' ], $matches1 ) && preg_match( '/(Cached page generated by WP-Super-Cache on) ([0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*)/', $page2[ 'body' ], $matches2 ) && $matches1[2] == $matches2[2] ) { echo '

    ' . sprintf( __( 'Page 1: %s', 'wp-super-cache' ), $matches1[ 2 ] ) . '

    '; echo '

    ' . sprintf( __( 'Page 2: %s', 'wp-super-cache' ), $matches2[ 2 ] ) . '

    '; echo '

    ' . __( 'The timestamps on both pages match!', 'wp-super-cache' ) . '

    '; } else { echo '

    ' . __( 'The pages do not match! Timestamps differ or were not found!', 'wp-super-cache' ) . '

    '; } } echo '
    '; echo ''; if ( 'on' == strtolower( $_SERVER['HTTPS' ] ) ) echo " " . __( 'Send non-secure (non https) request for homepage', 'wp-super-cache' ); echo '
    '; wp_nonce_field('wp-cache'); echo '
    '; } echo "

    " . __( "Delete Cached Pages", 'wp-super-cache' ) . "

    "; echo "

    " . __( "Cached pages are stored on your server as html and PHP files. If you need to delete them use the button below.", 'wp-super-cache' ) . "

    "; echo '
    '; echo ''; echo '
    '; wp_nonce_field('wp-cache'); echo "
    \n"; ?>

    1. WP Minify reduces the number of files served by your web server by joining Javascript and CSS files together. Alternatively you can use WPSCMin, a Supercache plugin that minifies cached pages. It does not however join JS/CSS files together.', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wp-minify/', 'http://lyncd.com/wpscmin/' ); ?>
    2. Yahoo! Yslow is an extension for the Firefox add-on Firebug. It analyzes web pages and suggests ways to improve their performance based on a set of rules for high performance web pages. Also try the performance tools online at GTMetrix.', 'wp-super-cache' ), 'http://developer.yahoo.com/yslow/', 'http://gtmetrix.com/' ); ?>
    3. Use Google Libraries allows you to load some commonly used Javascript libraries from Google webservers. Ironically it may reduce your Yslow score.', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/use-google-libraries/' ); ?>
    4. CDN Sync Tool plugin will help upload files to Amazon S3/Cloudfront if you would rather not depend on origin pull. See the plugin support forum if you have any queries about this plugin.', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/cdn-sync-tool/', 'http://wordpress.org/tags/cdn-sync-tool?forum_id=10' ); ?>
    5. Advanced users only: Speed up your site with Caching and cache-control explains how to make your site more cacheable with .htaccess rules.', 'wp-super-cache' ), 'http://www.askapache.com/htaccess/speed-up-your-site-with-caching-and-cache-control.html' ); ?>
    6. Advanced users only: Install an object cache. Choose from Memcached, XCache, eAcccelerator and others.', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/memcached/', 'http://neosmart.net/dl.php?id=12', 'http://neosmart.net/dl.php?id=13' ); ?>

    WP Super Cache', 'Donncha O Caoimh' ); ?>

    Holy Shmoly', 'In Photos.org' ); ?>

    Twitter' ); ?>

    1. Installation Help', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wp-super-cache/installation/' ); ?>
    2. Frequently Asked Questions', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wp-super-cache/faq/' ); ?>
    3. Support Forum', 'wp-super-cache' ), 'http://wordpress.org/tags/wp-super-cache' ); ?>

    rate this plugin and tell me if it works for you or not. It really helps development.', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/wp-super-cache/' ); ?>

    %2$s', 'wp-super-cache' ), date( 'M j, Y', $start_date ), number_format( get_option( 'wpsupercache_count' ) ) ); ?>

      " . substr( $url[ 'url' ], 0, 20 ) . "\n"; } ?>

    \n"; } function wpsc_plugins_tab() { echo '

    ' . __( 'Cache plugins are PHP scripts that live in a plugins folder inside the wp-super-cache folder. They are loaded when Supercache loads, much sooner than regular WordPress plugins.', 'wp-super-cache' ) . '

    '; echo '

    ' . __( 'This is strictly an advanced feature only and knowledge of both PHP and WordPress actions is required to create them.', 'wp-super-cache' ) . '

    '; 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 '

    ' . __( 'Available Plugins', 'wp-super-cache' ) . '

    '; echo "
      "; echo $out; echo "
    "; } } function wpsc_admin_tabs( $current = 0 ) { global $wp_db_version; if ( $current == 0 ) { if ( isset( $_GET[ 'tab' ] ) ) { $current = $_GET[ 'tab' ]; } else { $current = 'easy'; } } $tabs = array( 'easy' => __( 'Easy', 'wp-super-cache' ), 'settings' => __( 'Advanced', 'wp-super-cache' ), 'cdn' => __( 'CDN', 'wp-super-cache' ), 'contents' => __( 'Contents', 'wp-super-cache' ), 'preload' => __( 'Preload', 'wp-super-cache' ), 'plugins' => __( 'Plugins', 'wp-super-cache' ), 'debug' => __( 'Debug', 'wp-super-cache' ) ); $links = array(); foreach( $tabs as $tab => $name ) { if ( $current == $tab ) { $links[] = "$name"; } else { $links[] = "$name"; } } if ( $wp_db_version >= 15477 ) { echo ''; } else { echo implode( " | ", $links ); } } function wsc_mod_rewrite() { global $cache_enabled, $super_cache_enabled, $valid_nonce, $cache_path, $wp_cache_mod_rewrite, $wpmu_version; if ( !$wp_cache_mod_rewrite ) return false; if ( isset( $wpmu_version ) || function_exists( 'is_multisite' ) && is_multisite() ) { if ( false == wpsupercache_site_admin() ) return false; if ( function_exists( "is_main_site" ) && false == is_main_site() || function_exists( 'is_main_blog' ) && false == is_main_blog() ) { global $current_site; $protocol = ( 'on' == strtolower( $_SERVER['HTTPS' ] ) ) ? 'https://' : 'http://'; if ( isset( $wpmu_version ) ) { $link_to_admin = admin_url( "wpmu-admin.php?page=wpsupercache" ); } else { $link_to_admin = admin_url( "ms-admin.php?page=wpsupercache" ); } echo '

    ' . sprintf( __( 'Notice: WP Super Cache mod_rewrite rule checks disabled unless running on the main site of this network.', 'wp-super-cache' ), $link_to_admin ) . '

    '; return false; } } if ( function_exists( "is_main_site" ) && false == is_main_site() || function_exists( 'is_main_blog' ) && false == is_main_blog() ) return true; ?>

    " . __( 'WordPress MU Detected', 'wp-super-cache' ) . "

    " . __( "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' ) . "

    "; } elseif( !$wprules || $wprules == '' ) { echo "

    " . __( 'Mod Rewrite rules cannot be updated!', 'wp-super-cache' ) . "

    "; echo "

    " . sprintf( __( "You must have BEGIN and END 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 "

    # BEGIN WordPress\n RewriteCond %{REQUEST_FILENAME} !-f\n RewriteCond %{REQUEST_FILENAME} !-d\n RewriteRule . /index.php [L]\n # END WordPress
    "; _e( 'Refresh this page when you have updated your .htaccess file.', 'wp-super-cache' ); echo "
    "; $dohtaccess = false; } elseif( strpos( $wprules, 'wordpressuser' ) ) { // Need to clear out old mod_rewrite rules echo "

    " . __( 'Thank you for upgrading.', 'wp-super-cache' ) . " " . 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' ), '

    RewriteCond %{HTTP_COOKIE} !^.*wordpressuser.*$
    ', '
    RewriteCond %{HTTP:Cookie} !^.*wordpress.*$
    ' ) . "

    "; echo "
    "; 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 "

    " . __( 'Trailing slash check required.', 'wp-super-cache' ) . "

    " . __( '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' ) . "

    "; echo "
    RewriteCond %{REQUEST_URI} !^.*[^/]$RewriteCond %{REQUEST_URI} !^.*//.*$
    "; echo "

    " . __( 'You can see where the rules go and examine the complete rules by clicking the "View mod_rewrite rules" link below.', 'wp-super-cache' ) . "

    "; $dohtaccess = false; } elseif( strpos( $scrules, 'supercache' ) || strpos( $wprules, 'supercache' ) ) { // only write the rules once $dohtaccess = false; } if( $dohtaccess && !$_POST[ 'updatehtaccess' ] ) { if ( $scrules == '' ) { wpsc_update_htaccess_form( 0 ); // don't hide the update htaccess form } else { wpsc_update_htaccess_form(); } } elseif( $valid_nonce && $_POST[ 'updatehtaccess' ] ) { echo "
    "; if( wpsc_update_htaccess() ) { echo "

    " . __( 'Mod Rewrite rules updated!', 'wp-super-cache' ) . "

    "; echo "

    " . 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 ) . "

    \n"; } else { echo "

    " . __( 'Mod Rewrite rules must be updated!', 'wp-super-cache' ) . "

    "; echo "

    " . 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 ) . "

    \n"; } echo "

    " . esc_html( $rules ) . "

    \n
    "; } else { ?>

    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 ); ?>

    " . sprintf( __( 'Gzip encoding rules in %s.htaccess created.', 'wp-super-cache' ), $cache_path ) . ""; } ?>

    ' . __( 'Fix Configuration', 'wp-super-cache' ) . '

    '; echo '
    '; echo ''; echo '
    '; wp_nonce_field('wp-cache'); echo "
    \n"; echo ''; } function comment_form_lockdown_message() { ?>

    ' . __( 'Disabled', 'wp-super-cache' ) . '' : '' . __( 'Enabled', 'wp-super-cache' ) . ''; ?>

    if( defined( 'WPLOCKDOWN' ) && constant( 'WPLOCKDOWN' ) ) {     echo ""; }

    '; echo ""; echo "
    "; wp_nonce_field('wp-cache'); echo "\n"; ?>

    escape( $page ); if( $page != '' ) { $cached_direct_pages[] = $page; $out .= "'$page', "; } } if( $out == '' ) { $out = "'', "; } } if( $valid_nonce && array_key_exists('new_direct_page', $_POST) && $_POST[ 'new_direct_page' ] && '' != $_POST[ 'new_direct_page' ] ) { $page = str_replace( get_option( 'siteurl' ), '', $_POST[ 'new_direct_page' ] ); if( substr( $page, 0, 1 ) != '/' ) $page = '/' . $page; $page = $wpdb->escape( $page ); if( in_array( $page, $cached_direct_pages ) == false ) { $cached_direct_pages[] = $page; $out .= "'$page', "; } } if( $out != '' ) { $out = substr( $out, 0, -2 ); $out = '$cached_direct_pages = array( ' . $out . ' );'; wp_cache_replace_line('^ *\$cached_direct_pages', "$out", $wp_cache_config_file); prune_super_cache( $cache_path, true ); } if( !empty( $expiredfiles ) ) { foreach( $expiredfiles as $file ) { if( $file != '' ) { $firstfolder = explode( '/', $file ); $firstfolder = ABSPATH . $firstfolder[1]; $file = ABSPATH . $file; @unlink( trailingslashit( $file ) . 'index.html' ); @unlink( trailingslashit( $file ) . 'index.html.gz' ); RecursiveFolderDelete( trailingslashit( $firstfolder ) ); } } } if( $valid_nonce && array_key_exists('deletepage', $_POST) && $_POST[ 'deletepage' ] ) { $page = preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', str_replace( '..', '', $_POST['deletepage']) ); $pagefile = ABSPATH . $page . 'index.html'; $firstfolder = explode( '/', $page ); $firstfolder = ABSPATH . $firstfolder[1]; $page = ABSPATH . $page; if( is_file( $pagefile ) && is_writeable_ACLSafe( $pagefile ) && is_writeable_ACLSafe( $firstfolder ) ) { @unlink( $pagefile ); @unlink( $pagefile . '.gz' ); RecursiveFolderDelete( $firstfolder ); echo "" . sprintf( __( '%s removed!', 'wp-super-cache' ), $pagefile ) . ""; prune_super_cache( $cache_path, true ); } } $readonly = ''; if( !is_writeable_ACLSafe( ABSPATH ) ) { $readonly = 'READONLY'; ?>

    '; if( is_array( $cached_direct_pages ) ) { $out = ''; foreach( $cached_direct_pages as $page ) { if( $page == '' ) continue; $generated = ''; if( is_file( ABSPATH . $page . '/index.html' ) ) $generated = ''; $out .= "$generated"; } if( $out != '' ) { ?>"; } } if( $readonly != 'READONLY' ) echo __( "Add direct page:", 'wp-super-cache' ) . ""; echo "

    " . sprintf( __( "Directly cached files are files created directly off %s where your blog lives. This feature is only useful if you are expecting a major Digg or Slashdot level of traffic to one post or page.", 'wp-super-cache' ), ABSPATH ) . "

    "; if( $readonly != 'READONLY' ) { echo "

    " . sprintf( __( 'For example: to cache %1$sabout/, you would enter %1$sabout/ or /about/. The cached file will be generated the next time an anonymous user visits that page.', 'wp-super-cache' ), trailingslashit( get_option( 'siteurl' ) ) ) . "

    "; echo "

    " . __( 'Make the textbox blank to remove it from the list of direct pages and delete the cached file.', 'wp-super-cache' ) . "

    "; } wp_nonce_field('wp-cache'); if( $readonly != 'READONLY' ) echo "
    "; echo "\n"; ?>

    '; echo ' '; echo " " . __( "seconds", 'wp-super-cache' ); echo "

    " . __( 'Garbage Collection', 'wp-super-cache' ) . "

    " . __( 'If the expiry time is more than 1800 seconds (half an hour), garbage collection will be done every 10 minutes, otherwise it will happen 10 seconds after the expiry time above.', 'wp-super-cache' ) . "

    "; echo "

    " . __( 'Checking for and deleting expired files is expensive, but it’s expensive leaving them there too. On a very busy site you should set the expiry time to 300 seconds. Experiment with different values and visit this page to see how many expired files remain at different times during the day. If you are using legacy caching aim to have less than 500 cached files if possible. You can have many times more cached files when using mod_rewrite or PHP caching.', 'wp-super-cache' ) . "

    "; echo "

    " . __( 'Set the expiry time to 0 seconds to disable garbage collection.', 'wp-super-cache' ) . "

    "; echo '
    '; wp_nonce_field('wp-cache'); echo "\n"; ?>
    $ua ) { $cache_rejected_user_agent[ $k ] = str_replace( '___', ' ', $ua ); } reset( $cache_rejected_user_agent ); } echo '

    ' . __( 'Rejected User Agents', 'wp-super-cache' ) . '

    '; echo "

    " . __( 'Strings in the HTTP ’User Agent’ header that prevent WP-Cache from caching bot, spiders, and crawlers’ requests. Note that super cached files are still sent to these agents if they already exists.', 'wp-super-cache' ) . "

    \n"; echo '
    '; echo ' '; echo '
    '; wp_nonce_field('wp-cache'); echo ''; echo "
    \n"; } function wp_cache_edit_rejected_pages() { global $wp_cache_config_file, $valid_nonce, $wp_cache_pages; if ( isset( $_POST[ 'wp_edit_rejected_pages' ] ) && $valid_nonce ) { $pages = array( 'single', 'pages', 'archives', 'tag', 'frontpage', 'home', 'category', 'feed', 'search' ); foreach( $pages as $page ) { if ( isset( $_POST[ 'wp_cache_pages' ][ $page ] ) ) { $value = 1; } else { $value = 0; } wp_cache_replace_line('^ *\$wp_cache_pages\[ "' . $page . '" \]', "\$wp_cache_pages[ \"{$page}\" ] = $value;", $wp_cache_config_file); $wp_cache_pages[ $page ] = $value; } } echo ''; echo '

    ' . __( 'Do not cache the following page types. See the Conditional Tags documentation for a complete discussion on each type.', 'wp-super-cache' ) . '

    '; echo ''; echo ''; echo '
    '; echo '
    '; echo '
    '; echo '  
    '; echo '
    '; echo '  
    '; echo '  
    '; echo '
    '; echo '
    '; echo '
    '; wp_nonce_field('wp-cache'); echo "\n"; } function wp_cache_edit_rejected() { global $cache_acceptable_files, $cache_rejected_uri, $wp_cache_config_file, $valid_nonce; if(isset($_REQUEST['wp_rejected_uri']) && $valid_nonce) { $text = wp_cache_sanitize_value( str_replace( '\\\\', '\\', $_REQUEST['wp_rejected_uri'] ), $cache_rejected_uri ); wp_cache_replace_line('^ *\$cache_rejected_uri', "\$cache_rejected_uri = $text;", $wp_cache_config_file); } echo ''; echo ''; echo "

    " . __( 'Add here strings (not a filename) that forces a page not to be cached. For example, if your URLs include year and you dont want to cache last year posts, it’s enough to specify the year, i.e. ’/2004/’. WP-Cache will search if that string is part of the URI and if so, it will not cache that page.', 'wp-super-cache' ) . "

    \n"; echo ' '; echo '
    '; wp_nonce_field('wp-cache'); echo "\n"; } function wp_cache_edit_accepted() { global $cache_acceptable_files, $cache_rejected_uri, $wp_cache_config_file, $valid_nonce; if(isset($_REQUEST['wp_accepted_files']) && $valid_nonce) { $text = wp_cache_sanitize_value($_REQUEST['wp_accepted_files'], $cache_acceptable_files); wp_cache_replace_line('^ *\$cache_acceptable_files', "\$cache_acceptable_files = $text;", $wp_cache_config_file); } echo ''; echo '
    '; echo "

    " . __( 'Add here those filenames that can be cached, even if they match one of the rejected substring specified above.', 'wp-super-cache' ) . "

    \n"; echo ' '; echo '
    '; wp_nonce_field('wp-cache'); echo "\n"; } function wp_cache_debug_settings() { global $wp_super_cache_debug, $wp_cache_debug_log, $wp_cache_debug_level, $wp_cache_debug_ip, $cache_path, $valid_nonce, $wp_cache_config_file; global $wp_super_cache_front_page_check, $wp_super_cache_front_page_clear, $wp_super_cache_front_page_text, $wp_super_cache_front_page_notification, $wp_super_cache_advanced_debug; if ( !isset( $wp_cache_debug_level ) ) $wp_cache_debug_level = 1; if ( isset( $_POST[ 'wp_cache_debug' ] ) && $valid_nonce ) { $wp_super_cache_debug = intval( $_POST[ 'wp_super_cache_debug' ] ); wp_cache_replace_line('^ *\$wp_super_cache_debug', "\$wp_super_cache_debug = '$wp_super_cache_debug';", $wp_cache_config_file); if ( $wp_super_cache_debug && ( ( isset( $wp_cache_debug_log ) && $wp_cache_debug_log == '' ) || !isset( $wp_cache_debug_log ) ) ) { $wp_cache_debug_log = md5( time() ) . ".txt"; } else { $wp_cache_debug_log = ""; } wp_cache_replace_line('^ *\$wp_cache_debug_log', "\$wp_cache_debug_log = '$wp_cache_debug_log';", $wp_cache_config_file); $wp_cache_debug_ip = esc_html( $_POST[ 'wp_cache_debug_ip' ] ); wp_cache_replace_line('^ *\$wp_cache_debug_ip', "\$wp_cache_debug_ip = '$wp_cache_debug_ip';", $wp_cache_config_file); $wp_cache_debug_level = (int)$_POST[ 'wp_cache_debug_level' ]; wp_cache_replace_line('^ *\$wp_cache_debug_level', "\$wp_cache_debug_level = '$wp_cache_debug_level';", $wp_cache_config_file); $wp_super_cache_front_page_check = (int)$_POST[ 'wp_super_cache_front_page_check' ]; wp_cache_replace_line('^ *\$wp_super_cache_front_page_check', "\$wp_super_cache_front_page_check = '$wp_super_cache_front_page_check';", $wp_cache_config_file); $wp_super_cache_front_page_clear = (int)$_POST[ 'wp_super_cache_front_page_clear' ]; wp_cache_replace_line('^ *\$wp_super_cache_front_page_clear', "\$wp_super_cache_front_page_clear = '$wp_super_cache_front_page_clear';", $wp_cache_config_file); $wp_super_cache_front_page_text = esc_html( $_POST[ 'wp_super_cache_front_page_text' ] ); wp_cache_replace_line('^ *\$wp_super_cache_front_page_text', "\$wp_super_cache_front_page_text = '$wp_super_cache_front_page_text';", $wp_cache_config_file); $wp_super_cache_front_page_notification = (int)$_POST[ 'wp_super_cache_front_page_notification' ]; wp_cache_replace_line('^ *\$wp_super_cache_front_page_notification', "\$wp_super_cache_front_page_notification = '$wp_super_cache_front_page_notification';", $wp_cache_config_file); 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 ); } } echo ''; echo '
    '; if ( isset( $wp_cache_debug_log ) && $wp_cache_debug_log != '' ) echo "

    " . sprintf( __( 'Currently logging to: %s', 'wp-super-cache' ), "$cache_path{$wp_cache_debug_log}" ) . "

    "; echo '

    ' . __( 'Fix problems with the plugin by debugging it here. It can log them to a file in your cache directory.', 'wp-super-cache' ) . '

    '; echo '
    '; echo "
    "; echo "
    "; echo ""; echo ""; echo ""; echo "
    " . __( 'Debugging', 'wp-super-cache' ) . " " . __( 'enabled', 'wp-super-cache' ) . "
    " . __( 'IP Address', 'wp-super-cache' ) . " " . sprintf( __( '(only log requests from this IP address. Your IP is %s)', 'wp-super-cache' ), $_SERVER[ 'REMOTE_ADDR' ] ) . "
    " . __( 'Log level', 'wp-super-cache' ) . " "; for( $t = 1; $t <= 5; $t++ ) { echo " $t "; } echo " " . __( '(1 = less, 5 = more, may cause severe server load.)', 'wp-super-cache' ) . "
    \n"; if ( isset( $wp_super_cache_advanced_debug ) ) { echo "

    " . __( 'Advanced', 'wp-super-cache' ) . "

    " . __( 'In very rare cases two problems may arise on some blogs:

    1. The front page may start downloading as a zip file.
    2. The wrong page is occasionally cached as the front page if your blog uses a static front page and the permalink structure is /%category%/%postname%/.
    ', 'wp-super-cache' ) . '

    '; echo "

    " . __( 'I’m 99% certain that they aren’t bugs in WP Super Cache and they only happen in very rare cases but you can run a simple check once every 5 minutes to verify that your site is ok if you’re worried. You will be emailed if there is a problem.', 'wp-super-cache' ) . "

    "; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
    " . __( 'Check front page every 5 minutes.', 'wp-super-cache' ) . "
    " . __( 'Front page text', 'wp-super-cache' ) . " (" . __( 'Text to search for on your front page. If this text is missing the cache will be cleared. Leave blank to disable.', 'wp-super-cache' ) . ")
    " . __( 'Clear cache on error.', 'wp-super-cache' ) . "
    " . __( 'Email the blog admin when checks are made. (useful for testing)', 'wp-super-cache' ) . "
    \n"; } echo '
    '; wp_nonce_field('wp-cache'); echo "\n"; echo '
    '; } function wp_cache_enable() { global $wp_cache_config_file, $cache_enabled, $supercachedir; if(get_option('gzipcompression')) { echo "" . __( 'Error: GZIP compression is enabled, disable it if you want to enable wp-cache.', 'wp-super-cache' ) . ""; return false; } if( wp_cache_replace_line('^ *\$cache_enabled', '$cache_enabled = true;', $wp_cache_config_file) ) { $cache_enabled = true; } wp_super_cache_enable(); } function wp_cache_disable() { global $wp_cache_config_file, $cache_enabled; if (wp_cache_replace_line('^ *\$cache_enabled', '$cache_enabled = false;', $wp_cache_config_file)) { $cache_enabled = false; } } function wp_super_cache_enable() { global $supercachedir, $wp_cache_config_file, $super_cache_enabled; if( is_dir( $supercachedir . ".disabled" ) ) if( is_dir( $supercachedir ) ) { prune_super_cache( $supercachedir . ".disabled", true ); @unlink( $supercachedir . ".disabled" ); } else { @rename( $supercachedir . ".disabled", $supercachedir ); } wp_cache_replace_line('^ *\$super_cache_enabled', '$super_cache_enabled = true;', $wp_cache_config_file); $super_cache_enabled = true; } function wp_super_cache_disable() { global $cache_path, $supercachedir, $wp_cache_config_file, $super_cache_enabled; wp_cache_replace_line('^ *\$super_cache_enabled', '$super_cache_enabled = false;', $wp_cache_config_file); if( is_dir( $supercachedir ) ) @rename( $supercachedir, $supercachedir . ".disabled" ); $super_cache_enabled = false; sleep( 1 ); // allow existing processes to write to the supercachedir and then delete it if (function_exists ('prune_super_cache') && is_dir( $supercachedir ) ) { prune_super_cache( $cache_path, true ); } } function wp_cache_is_enabled() { global $wp_cache_config_file; if(get_option('gzipcompression')) { echo "" . __( 'Warning', 'wp-super-cache' ) . ": " . __( "GZIP compression is enabled in WordPress, wp-cache will be bypassed until you disable gzip compression.", 'wp-super-cache' ); return false; } $lines = file($wp_cache_config_file); foreach($lines as $line) { if (preg_match('/^ *\$cache_enabled *= *true *;/', $line)) return true; } return false; } function wp_cache_replace_line($old, $new, $my_file) { if ( @is_file( $my_file ) == false ) { return false; } if (!is_writeable_ACLSafe($my_file)) { echo "Error: file $my_file is not writable.\n"; return false; } $found = false; $lines = file($my_file); foreach( (array)$lines as $line ) { if ( preg_match("/$old/", $line)) { $found = true; break; } } if ($found) { $fd = fopen($my_file, 'w'); foreach( (array)$lines as $line ) { if ( !preg_match("/$old/", $line)) fputs($fd, $line); else { fputs($fd, "$new //Added by WP-Cache Manager\n"); } } fclose($fd); return true; } $fd = fopen($my_file, 'w'); $done = false; foreach( (array)$lines as $line ) { if ( $done || !preg_match('/^(if\ \(\ \!\ )?define|\$|\?>/', $line) ) { fputs($fd, $line); } else { fputs($fd, "$new //Added by WP-Cache Manager\n"); fputs($fd, $line); $done = true; } } fclose($fd); return true; } function wp_cache_verify_cache_dir() { global $cache_path, $blog_cache_dir, $blogcacheid; $dir = dirname($cache_path); if ( !file_exists($cache_path) ) { if ( !is_writeable_ACLSafe( $dir ) || !($dir = mkdir( $cache_path ) ) ) { echo "" . __( 'Error', 'wp-super-cache' ) . ": " . sprintf( __( 'Your cache directory (%1$s) did not exist and couldn’t be created by the web server. Check %1$s permissions.', 'wp-super-cache' ), $dir ); return false; } } if ( !is_writeable_ACLSafe($cache_path)) { echo "" . __( 'Error', 'wp-super-cache' ) . ": " . sprintf( __( 'Your cache directory (%1$s) or %2$s need to be writable for this plugin to work. Double-check it.', 'wp-super-cache' ), $cache_path, $dir ); return false; } if ( '/' != substr($cache_path, -1)) { $cache_path .= '/'; } if( false == is_dir( $blog_cache_dir ) ) { @mkdir( $cache_path . "blogs" ); if( $blog_cache_dir != $cache_path . "blogs/" ) @mkdir( $blog_cache_dir ); } if( false == is_dir( $blog_cache_dir . 'meta' ) ) @mkdir( $blog_cache_dir . 'meta' ); return true; } function wp_cache_verify_config_file() { global $wp_cache_config_file, $wp_cache_config_file_sample, $sem_id, $cache_path; $new = false; $dir = dirname($wp_cache_config_file); if ( file_exists($wp_cache_config_file) ) { $lines = join( ' ', file( $wp_cache_config_file ) ); if( strpos( $lines, 'WPCACHEHOME' ) === false ) { if( is_writeable_ACLSafe( $wp_cache_config_file ) ) { @unlink( $wp_cache_config_file ); } else { echo "" . __( 'Error', 'wp-super-cache' ) . ": " . sprintf( __( 'Your WP-Cache config file (%s) is out of date and not writable by the Web server.Please delete it and refresh this page.', 'wp-super-cache' ), $wp_cache_config_file ); return false; } } } elseif( !is_writeable_ACLSafe($dir)) { echo "" . __( 'Error', 'wp-super-cache' ) . ": " . sprintf( __( 'Configuration file missing and %1$s directory (%2$s) is not writable by the Web server.Check its permissions.', 'wp-super-cache' ), WP_CONTENT_DIR, $dir ); return false; } if ( !file_exists($wp_cache_config_file) ) { if ( !file_exists($wp_cache_config_file_sample) ) { echo "" . __( 'Error', 'wp-super-cache' ) . ": " . sprintf( __( 'Sample WP-Cache config file (%s) does not exist.Verify you installation.', 'wp-super-cache' ), $wp_cache_config_file_sample ); return false; } copy($wp_cache_config_file_sample, $wp_cache_config_file); $dir = str_replace( str_replace( '\\', '/', WP_CONTENT_DIR ), '', str_replace( '\\', '/', dirname(__FILE__) ) ); if( is_file( dirname(__FILE__) . '/wp-cache-config-sample.php' ) ) { wp_cache_replace_line('define\(\ \'WPCACHEHOME', "\tdefine( 'WPCACHEHOME', WP_CONTENT_DIR . \"{$dir}/\" );", $wp_cache_config_file); } elseif( is_file( dirname(__FILE__) . '/wp-super-cache/wp-cache-config-sample.php' ) ) { wp_cache_replace_line('define\(\ \'WPCACHEHOME', "\tdefine( 'WPCACHEHOME', WP_CONTENT_DIR . \"{$dir}/wp-super-cache/\" );", $wp_cache_config_file); } $new = true; } if( $sem_id == 5419 && $cache_path != '' ) { $sem_id = crc32( $_SERVER[ 'HTTP_HOST' ] . $cache_path ) & 0x7fffffff; wp_cache_replace_line('sem_id', '$sem_id = ' . $sem_id . ';', $wp_cache_config_file); } require($wp_cache_config_file); return true; } function wp_cache_create_advanced_cache() { global $wp_cache_link, $wp_cache_file; $ret = true; $file = file_get_contents( $wp_cache_file ); $file = str_replace( 'CACHEHOME', constant( 'WPCACHEHOME' ), $file ); $fp = @fopen( $wp_cache_link, 'w' ); if( $fp ) { fputs( $fp, $file ); fclose( $fp ); } else { $ret = false; } return $ret; } function wp_cache_check_link() { global $wp_cache_link, $wp_cache_file; $ret = true; if( file_exists($wp_cache_link) ) { $file = file_get_contents( $wp_cache_link ); if( strpos( $file, "WP SUPER CACHE 0.8.9.1" ) ) { return true; } else { if( !@unlink($wp_cache_link) ) { $ret = false; } else { $ret = wp_cache_create_advanced_cache(); } } } else { $ret = wp_cache_create_advanced_cache(); } if( false == $ret ) { echo '

    ' . __( 'Warning', 'wp-super-cache' ) . "! " . sprintf( __( '%s/advanced-cache.php does not exist or cannot be updated.', 'wp-super-cache' ), WP_CONTENT_DIR ) . "

    "; echo "

    "; echo sprintf( __( 'If that doesn’t work, make sure the file %s/advanced-cache.php doesn’t exist:', 'wp-super-cache' ), WP_CONTENT_DIR ) . "
      "; printf( __( '
    1. 1. Open %1$s$wp_cache_file in a text editor.
    2. 2. Change the text CACHEHOME to %2$s
    3. 3. Save the file and copy it to %3$s and refresh this page.
    4. ', 'wp-super-cache' ), $wp_cache_file, WPCACHEHOME, $wp_cache_link ); echo "
    "; return false; } return true; } function wp_cache_check_global_config() { global $wp_cache_check_wp_config; if ( !isset( $wp_cache_check_wp_config ) ) return true; if ( file_exists( ABSPATH . 'wp-config.php') ) { $global = ABSPATH . 'wp-config.php'; } else { $global = dirname(ABSPATH) . '/wp-config.php'; } $line = 'define(\'WP_CACHE\', true);'; if (!is_writeable_ACLSafe($global) || !wp_cache_replace_line('define *\( *\'WP_CACHE\'', $line, $global) ) { if ( defined( 'WP_CACHE' ) && constant( 'WP_CACHE' ) == false ) { echo '
    ' . __( "

    WP_CACHE constant set to false

    The WP_CACHE constant is used by WordPress to load the code that serves cached pages. Unfortunately it is set to false. Please edit your wp-config.php and add or edit the following line above the final require_once command:

    define('WP_CACHE', true);

    ", 'wp-super-cache' ) . "
    "; } else { echo "

    " . __( "Error: WP_CACHE is not enabled in your wp-config.php file and I couldn’t modify it.", 'wp-super-cache' ) . "

    ";; echo "

    " . sprintf( __( "Edit %s and add the following line:
    define('WP_CACHE', true);
    Otherwise, WP-Cache will not be executed by WordPress core. ", 'wp-super-cache' ), $global ) . "

    "; } return false; } else { echo "
    " . __( '

    WP_CACHE constant added to wp-config.php

    If you continue to see this warning message please see point 5 of the FAQ. The WP_CACHE line must be moved up.', 'wp-super-cache' ) . "

    "; } return true; } function wp_cache_files() { global $cache_path, $file_prefix, $cache_max_time, $valid_nonce, $supercachedir, $cache_enabled, $super_cache_enabled, $blog_cache_dir, $cache_compression; global $wp_cache_object_cache, $wp_cache_preload_on; if ( '/' != substr($cache_path, -1)) { $cache_path .= '/'; } if ( $valid_nonce ) { if(isset($_REQUEST['wp_delete_cache'])) { wp_cache_clean_cache($file_prefix); $_GET[ 'action' ] = 'regenerate_cache_stats'; } if(isset($_REQUEST['wp_delete_expired'])) { wp_cache_clean_expired($file_prefix); $_GET[ 'action' ] = 'regenerate_cache_stats'; } } echo ""; echo '

    ' . __( 'Cache Contents', 'wp-super-cache' ) . '

    '; if ( $wp_cache_object_cache ) { echo "

    " . __( "Object cache in use. No cache listing available.", 'wp-super-cache' ) . "

    "; wp_cache_delete_buttons(); echo "
    "; return false; } $cache_stats = get_option( 'supercache_stats' ); if ( !is_array( $cache_stats ) || ( $valid_nonce && array_key_exists('action', $_GET) && $_GET[ 'action' ] == 'regenerate_cache_stats' ) ) { $list_files = false; // it doesn't list supercached files, and removing single pages is buggy $count = 0; $expired = 0; $now = time(); if ( ($handle = @opendir( $blog_cache_dir . 'meta/' )) ) { $wp_cache_fsize = 0; if ( $valid_nonce && isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'deletewpcache' ) { $deleteuri = preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', str_replace( '/index.php', '/', str_replace( '..', '', preg_replace("/(\?.*)?$/", '', base64_decode( $_GET[ 'uri' ] ) ) ) ) ); $deleteuri = str_replace( '\\', '', $deleteuri ); } else { $deleteuri = ''; } if ( $valid_nonce && isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'deletesupercache' ) { $supercacheuri = preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', str_replace( '/index.php', '/', str_replace( '..', '', preg_replace("/(\?.*)?$/", '', base64_decode( $_GET[ 'uri' ] ) ) ) ) ); $supercacheuri = trailingslashit( str_replace( '\\', '', $supercacheuri ) ); printf( __( "Deleting supercache file: %s
    ", 'wp-super-cache' ), $supercacheuri ); @unlink( $cache_path . 'supercache/' . $supercacheuri . 'index.html' ); @unlink( $cache_path . 'supercache/' . $supercacheuri . 'index.html.gz' ); prune_super_cache( $cache_path . 'supercache/' . $supercacheuri . 'page', true ); @rmdir( $cache_path . 'supercache/' . $supercacheuri ); } while( false !== ($file = readdir($handle))) { if ( preg_match("/^$file_prefix.*\.meta/", $file) ) { $content_file = preg_replace("/meta$/", "html", $file); $mtime = filemtime( $blog_cache_dir . 'meta/' . $file ); if ( ! ( $fsize = @filesize( $blog_cache_dir . $content_file ) ) ) continue; // .meta does not exists $age = $now - $mtime; if ( $valid_nonce && $_GET[ 'listfiles' ] ) { $meta = unserialize( file_get_contents( $blog_cache_dir . 'meta/' . $file ) ); if ( $deleteuri != '' && $meta[ 'uri' ] == $deleteuri ) { printf( __( "Deleting wp-cache file: %s
    ", 'wp-super-cache' ), $deleteuri ); @unlink( $blog_cache_dir . 'meta/' . $file ); @unlink( $blog_cache_dir . $content_file ); continue; } $meta[ 'age' ] = $age; if ( $cache_max_time > 0 && $age > $cache_max_time ) { $expired_list[ $age ][] = $meta; } else { $cached_list[ $age ][] = $meta; } } if ( $cache_max_time > 0 && $age > $cache_max_time ) { $expired++; } else { $count++; } $wp_cache_fsize += $fsize; $fsize = intval($fsize/1024); } } closedir($handle); } if( $wp_cache_fsize != 0 ) { $wp_cache_fsize = $wp_cache_fsize/1024; } else { $wp_cache_fsize = 0; } if( $wp_cache_fsize > 1024 ) { $wp_cache_fsize = number_format( $wp_cache_fsize / 1024, 2 ) . "MB"; } elseif( $wp_cache_fsize != 0 ) { $wp_cache_fsize = number_format( $wp_cache_fsize, 2 ) . "KB"; } else { $wp_cache_fsize = '0KB'; } // Supercache files $now = time(); $sizes = array( 'expired' => 0, 'expired_list' => array(), 'cached' => 0, 'cached_list' => array(), 'ts' => 0 ); if (is_dir($supercachedir)) { if( $dh = opendir( $supercachedir ) ) { while( ( $entry = readdir( $dh ) ) !== false ) { if ($entry != '.' && $entry != '..') { $sizes = wpsc_dirsize( trailingslashit( $supercachedir ) . $entry, $sizes ); } } closedir($dh); } } else { $filem = @filemtime( $supercachedir ); if ( false == $wp_cache_preload_on && is_file( $supercachedir ) && $cache_max_time > 0 && $filem + $cache_max_time <= $now ) { $sizes[ 'expired' ] ++; if ( $valid_nonce && $_GET[ 'listfiles' ] ) $sizes[ 'expired_list' ][ str_replace( $cache_path . 'supercache/' , '', $supercachedir ) ] = $now - $filem; } else { if ( $valid_nonce && $_GET[ 'listfiles' ] && $filem ) $sizes[ 'cached_list' ][ str_replace( $cache_path . 'supercache/' , '', $supercachedir ) ] = $now - $filem; } } $sizes[ 'ts' ] = time(); $cache_stats = array( 'generated' => time(), 'supercache' => $sizes, 'wpcache' => array( 'cached' => $count, 'expired' => $expired, 'fsize' => $wp_cache_fsize ) ); update_option( 'supercache_stats', $cache_stats ); } else { echo "

    " . __( 'Cache stats are not automatically generated. You must click the link below to regenerate the stats on this page.', 'wp-super-cache' ) . "

    "; echo " 'wpsupercache', 'tab' => 'contents', 'action' => 'regenerate_cache_stats' ) ), 'wp-cache' ) . "'>" . __( 'Regenerate cache stats', 'wp-super-cache' ) . ""; if ( is_array( $cache_stats ) ) { echo "

    " . sprintf( __( 'Cache stats last generated: %s minutes ago.', 'wp-super-cache' ), number_format( ( time() - $cache_stats[ 'generated' ] ) / 60 ) ) . "

    "; } $cache_stats = get_option( 'supercache_stats' ); }// regerate stats cache if ( is_array( $cache_stats ) ) { echo "

    " . __( 'WP-Cache', 'wp-super-cache' ) . " ({$cache_stats[ 'wpcache' ][ 'fsize' ]})

    "; echo ""; $divisor = $cache_compression == 1 ? 2 : 1; if ( array_key_exists('fsize', (array)$cache_stats[ 'supercache' ]) ) $fsize = $cache_stats[ 'supercache' ][ 'fsize' ] / 1024; else $fsize = 0; if( $fsize > 1024 ) { $fsize = number_format( $fsize / 1024, 2 ) . "MB"; } elseif( $fsize != 0 ) { $fsize = number_format( $fsize, 2 ) . "KB"; } else { $fsize = "0KB"; } echo "

    " . __( 'WP-Super-Cache', 'wp-super-cache' ) . " ({$fsize})

    "; echo ""; if ( $valid_nonce && array_key_exists('listfiles', $_GET) && $_GET[ 'listfiles' ] ) { echo "
    "; if ( is_array( $cached_list ) && !empty( $cached_list ) ) { echo "

    " . __( 'Fresh WP-Cached Files', 'wp-super-cache' ) . "

    "; echo ""; $c = 1; $flip = 1; ksort( $cached_list ); foreach( $cached_list as $age => $d ) { foreach( $d as $details ) { $bg = $flip ? 'style="background: #EAEAEA;"' : ''; echo "\n"; $flip = !$flip; $c++; } } echo "
    #" . __( 'URI', 'wp-super-cache' ) . "" . __( 'Key', 'wp-super-cache' ) . "" . __( 'Age', 'wp-super-cache' ) . "" . __( 'Delete', 'wp-super-cache' ) . "
    $c " . $details[ 'uri' ] . " " . str_replace( $details[ 'uri' ], '', $details[ 'key' ] ) . " {$age} 'wpsupercache', 'action' => 'deletewpcache', 'uri' => base64_encode( $details[ 'uri' ] ) ) ), 'wp-cache' ) . "#listfiles'>X
    "; } if ( is_array( $expired_list ) && !empty( $expired_list ) ) { echo "

    " . __( 'Stale WP-Cached Files', 'wp-super-cache' ) . "

    "; echo ""; $c = 1; $flip = 1; ksort( $expired_list ); foreach( $expired_list as $age => $d ) { foreach( $d as $details ) { $bg = $flip ? 'style="background: #EAEAEA;"' : ''; echo "\n"; $flip = !$flip; $c++; } } echo "
    #" . __( 'URI', 'wp-super-cache' ) . "" . __( 'Key', 'wp-super-cache' ) . "" . __( 'Age', 'wp-super-cache' ) . "" . __( 'Delete', 'wp-super-cache' ) . "
    $c " . $details[ 'uri' ] . " " . str_replace( $details[ 'uri' ], '', $details[ 'key' ] ) . " {$age} 'wpsupercache', 'action' => 'deletewpcache', 'uri' => base64_encode( $details[ 'uri' ] ) ) ), 'wp-cache' ) . "#listfiles'>X
    "; } if ( is_array( $sizes[ 'cached_list' ] ) & !empty( $sizes[ 'cached_list' ] ) ) { echo "

    " . __( 'Fresh Super Cached Files', 'wp-super-cache' ) . "

    "; echo ""; $c = 1; $flip = 1; ksort( $sizes[ 'cached_list' ] ); foreach( $sizes[ 'cached_list' ] as $age => $d ) { foreach( $d as $uri => $n ) { $bg = $flip ? 'style="background: #EAEAEA;"' : ''; echo "\n"; $flip = !$flip; $c++; } } echo "
    #" . __( 'URI', 'wp-super-cache' ) . "" . __( 'Age', 'wp-super-cache' ) . "" . __( 'Delete', 'wp-super-cache' ) . "
    $c " . $uri . "$age 'wpsupercache', 'action' => 'deletesupercache', 'uri' => base64_encode( $uri ) ) ), 'wp-cache' ) . "#listfiles'>X
    "; } if ( is_array( $sizes[ 'expired_list' ] ) && !empty( $sizes[ 'expired_list' ] ) ) { echo "

    " . __( 'Stale Super Cached Files', 'wp-super-cache' ) . "

    "; echo ""; $c = 1; $flip = 1; ksort( $sizes[ 'expired_list' ] ); foreach( $sizes[ 'expired_list' ] as $age => $d ) { foreach( $d as $uri => $n ) { $bg = $flip ? 'style="background: #EAEAEA;"' : ''; echo "\n"; $flip = !$flip; $c++; } } echo "
    #" . __( 'URI', 'wp-super-cache' ) . "" . __( 'Age', 'wp-super-cache' ) . "" . __( 'Delete', 'wp-super-cache' ) . "
    $c " . $uri . "$age 'wpsupercache', 'action' => 'deletesupercache', 'uri' => base64_encode( $uri ) ) ), 'wp-cache' ) . "#listfiles'>X
    "; } echo "
    "; echo "

    " . __( 'Hide file list', 'wp-super-cache' ) . "

    "; } elseif ( $cache_stats[ 'supercache' ][ 'cached' ] > 300 || $cache_stats[ 'supercache' ][ 'expired' ] > 300 || ( $cache_stats[ 'wpcache' ][ 'cached' ] / $divisor ) > 300 || ( $cache_stats[ 'wpcache' ][ 'expired' ] / $divisor) > 300 ) { echo "

    " . __( 'Too many cached files, no listing possible.', 'wp-super-cache' ) . "

    "; } else { echo "

    'wpsupercache', 'listfiles' => '1' ) ), 'wp-cache' ) . "#listfiles'>" . __( 'List all cached files', 'wp-super-cache' ) . "

    "; } $last_gc = get_option( "wpsupercache_gc_time" ); if ( $cache_max_time > 0 && $last_gc ) { $next_gc = $cache_max_time < 1800 ? $cache_max_time : 600; $next_gc_mins = ( time() - $last_gc ); echo "

    " . sprintf( __( 'Garbage Collection
    Last GC was %s minutes ago
    ', 'wp-super-cache' ), date( 'i:s', $next_gc_mins ) ); printf( __( "Next GC in %s minutes", 'wp-super-cache' ), date( 'i:s', $next_gc - $next_gc_mins ) ) . "

    "; } if ( $cache_max_time > 0 ) echo "

    " . sprintf( __( 'Expired files are files older than %s seconds. They are still used by the plugin and are deleted periodically.', 'wp-super-cache' ), $cache_max_time ) . "

    "; } // cache_stats wp_cache_delete_buttons(); echo ''; } function wp_cache_delete_buttons() { echo '
    '; echo ''; echo '
    '; wp_nonce_field('wp-cache'); echo "
    \n"; echo '
    '; echo ''; echo '
    '; wp_nonce_field('wp-cache'); echo "
    \n"; } function delete_cache_dashboard() { if ( false == wpsupercache_site_admin() ) return false; if ( function_exists('current_user_can') && !current_user_can('manage_options') ) return false; echo "
  • " . __( 'Delete Cache', 'wp-super-cache' ) . "
  • "; } add_action( 'dashmenu', 'delete_cache_dashboard' ); function wpsc_dirsize($directory, $sizes) { global $cache_max_time, $cache_path, $valid_nonce, $wp_cache_preload_on; $now = time(); if (is_dir($directory)) { if( $dh = opendir( $directory ) ) { while( ( $entry = readdir( $dh ) ) !== false ) { if ($entry != '.' && $entry != '..') { $sizes = wpsc_dirsize( trailingslashit( $directory ) . $entry, $sizes ); } } closedir($dh); } } else { if(is_file($directory) ) { $filem = filemtime( $directory ); if ( $wp_cache_preload_on == false && $cache_max_time > 0 && $filem + $cache_max_time <= $now ) { $sizes[ 'expired' ]+=1; if ( $valid_nonce && $_GET[ 'listfiles' ] ) $sizes[ 'expired_list' ][ $now - $filem ][ str_replace( $cache_path . 'supercache/' , '', str_replace( 'index.html', '', str_replace( 'index.html.gz', '', $directory ) ) ) ] = 1; } else { $sizes[ 'cached' ]+=1; if ( $valid_nonce && array_key_exists('listfiles', $_GET) && $_GET[ 'listfiles' ] ) $sizes[ 'cached_list' ][ $now - $filem ][ str_replace( $cache_path . 'supercache/' , '', str_replace( 'index.html', '', str_replace( 'index.html.gz', '', $directory ) ) ) ] = 1; } if ( ! isset( $sizes[ 'fsize' ] ) ) $sizes[ 'fsize' ] = @filesize( $directory ); else $sizes[ 'fsize' ] += @filesize( $directory ); } } return $sizes; } function wp_cache_clean_cache($file_prefix) { global $cache_path, $supercachedir, $blog_cache_dir, $wp_cache_object_cache; if ( $wp_cache_object_cache && function_exists( "reset_oc_version" ) ) reset_oc_version(); // If phase2 was compiled, use its function to avoid race-conditions if(function_exists('wp_cache_phase2_clean_cache')) { if (function_exists ('prune_super_cache')) { if( is_dir( $supercachedir ) ) { prune_super_cache( $supercachedir, true ); } elseif( is_dir( $supercachedir . '.disabled' ) ) { prune_super_cache( $supercachedir . '.disabled', true ); } prune_super_cache( $cache_path, true ); $_POST[ 'super_cache_stats' ] = 1; // regenerate super cache stats; } elseif ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Warning! prune_super_cache() not found in wp-cache.php', 1 ); return wp_cache_phase2_clean_cache($file_prefix); } elseif ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Warning! wp_cache_phase2_clean_cache() not found in wp-cache.php', 1 ); $expr = "/^$file_prefix/"; if ( ($handle = @opendir( $blog_cache_dir )) ) { while ( false !== ($file = readdir($handle))) { if ( preg_match($expr, $file) ) { @unlink( $blog_cache_dir . $file); @unlink( $blog_cache_dir . 'meta/' . str_replace( '.html', '.meta', $file ) ); } } closedir($handle); } } function wp_cache_clean_expired($file_prefix) { global $cache_path, $cache_max_time, $blog_cache_dir, $wp_cache_preload_on; if ( $cache_max_time == 0 ) { return false; } // If phase2 was compiled, use its function to avoid race-conditions if(function_exists('wp_cache_phase2_clean_expired')) { if ( $wp_cache_preload_on != 1 && function_exists ('prune_super_cache')) { $dir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $_SERVER["HTTP_HOST"]); if( is_dir( $dir ) ) { prune_super_cache( $dir ); } elseif( is_dir( $dir . '.disabled' ) ) { prune_super_cache( $dir . '.disabled' ); } $_POST[ 'super_cache_stats' ] = 1; // regenerate super cache stats; } return wp_cache_phase2_clean_expired($file_prefix); } $expr = "/^$file_prefix/"; $now = time(); if ( ($handle = @opendir( $blog_cache_dir )) ) { while ( false !== ($file = readdir($handle))) { if ( preg_match( $expr, $file ) && ( filemtime( $blog_cache_dir . $file ) + $cache_max_time ) <= $now ) { @unlink( $blog_cache_dir . $file ); @unlink( $blog_cache_dir . 'meta/' . str_replace( '.html', '.meta', $file ) ); } } closedir($handle); } } function wpsc_remove_marker( $filename, $marker ) { if (!file_exists( $filename ) || is_writeable_ACLSafe( $filename ) ) { if (!file_exists( $filename ) ) { return ''; } else { $markerdata = explode( "\n", implode( '', file( $filename ) ) ); } $f = fopen( $filename, 'w' ); $foundit = false; if ( $markerdata ) { $state = true; foreach ( $markerdata as $n => $markerline ) { if (strpos($markerline, '# BEGIN ' . $marker) !== false) $state = false; if ( $state ) { if ( $n + 1 < count( $markerdata ) ) fwrite( $f, "{$markerline}\n" ); else fwrite( $f, "{$markerline}" ); } if (strpos($markerline, '# END ' . $marker) !== false) { $state = true; } } } return true; } else { return false; } } function wp_super_cache_footer() { ?>

    WP Super Cache' ); ?>

    is_404 function wp_cache_catch_404() { global $wp_cache_404; $wp_cache_404 = false; if( is_404() ) $wp_cache_404 = true; } add_action( 'template_redirect', 'wp_cache_catch_404' ); function wp_cache_favorite_action( $actions ) { if ( false == wpsupercache_site_admin() ) return $actions; if ( function_exists('current_user_can') && !current_user_can('manage_options') ) return $actions; $actions[ wp_nonce_url( 'options-general.php?page=wpsupercache&wp_delete_cache=1&tab=contents', 'wp-cache' ) ] = array( __( 'Delete Cache', 'wp-super-cache' ), 'manage_options' ); return $actions; } add_filter( 'favorite_actions', 'wp_cache_favorite_action' ); function wp_cache_plugin_notice( $plugin ) { global $cache_enabled; if( $plugin == 'wp-super-cache/wp-cache.php' && !$cache_enabled && function_exists( "admin_url" ) ) echo '' . sprintf( __( 'WP Super Cache must be configured. Go to the admin page to enable and configure the plugin.' ), admin_url( 'options-general.php?page=wpsupercache' ) ) . ''; } add_action( 'after_plugin_row', 'wp_cache_plugin_notice' ); function wp_cache_plugin_actions( $links, $file ) { if( $file == 'wp-super-cache/wp-cache.php' && function_exists( "admin_url" ) ) { $settings_link = '' . __('Settings') . ''; array_unshift( $links, $settings_link ); // before other links } return $links; } add_filter( 'plugin_action_links', 'wp_cache_plugin_actions', 10, 2 ); function wp_cache_admin_notice() { global $cache_enabled; if( substr( $_SERVER["PHP_SELF"], -11 ) == 'plugins.php' && !$cache_enabled && function_exists( "admin_url" ) ) echo '

    ' . sprintf( __('WP Super Cache is disabled. Please go to the plugin admin page to enable caching.', 'wp-super-cache' ), admin_url( 'options-general.php?page=wpsupercache' ) ) . '

    '; if ( defined( 'ADVANCEDCACHEPROBLEM' ) ) echo '

    ' . sprintf( __( 'Warning! WP Super Cache caching broken! The script advanced-cache.php could not load wp-cache-phase1.php.

    Please edit %1$s/advanced-cache.php and make sure the path to %2$swp-cache-phase1.php is correct.', 'wp-super-cache' ), WP_CONTENT_DIR, WPCACHEHOME ) . '

    '; } add_action( 'admin_notices', 'wp_cache_admin_notice' ); function wp_cache_check_site() { global $wp_super_cache_front_page_check, $wp_super_cache_front_page_clear, $wp_super_cache_front_page_text, $wp_super_cache_front_page_notification; if ( !isset( $wp_super_cache_front_page_check ) || ( isset( $wp_super_cache_front_page_check ) && $wp_super_cache_front_page_check == 0 ) ) { return false; } if ( function_exists( "wp_remote_get" ) == false ) { return false; } $front_page = wp_remote_get( site_url(), array('timeout' => 60, 'blocking' => true ) ); if( is_array( $front_page ) ) { // Check for gzipped front page if ( $front_page[ 'headers' ][ 'content-type' ] == 'application/x-gzip' ) { if ( !isset( $wp_super_cache_front_page_clear ) || ( isset( $wp_super_cache_front_page_clear ) && $wp_super_cache_front_page_clear == 0 ) ) { wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Front page is gzipped! Please clear cache!', 'wp-super-cache' ), site_url() ), sprintf( __( "Please visit %s to clear the cache as the front page of your site is now downloading!", 'wp-super-cache' ), trailingslashit( site_url() ) . "wp-admin/options-general.php?page=wpsupercache" ) ); } else { wp_cache_clear_cache(); wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Front page is gzipped! Cache Cleared!', 'wp-super-cache' ), site_url() ), sprintf( __( "The cache on your blog has been cleared because the front page of your site is now downloading. Please visit %s to verify the cache has been cleared.", 'wp-super-cache' ), trailingslashit( site_url() ) . "wp-admin/options-general.php?page=wpsupercache" ) ); } } // Check for broken front page if ( isset( $wp_super_cache_front_page_text ) && $wp_super_cache_front_page_text != '' && false === strpos( $front_page[ 'body' ], $wp_super_cache_front_page_text ) ) { if ( !isset( $wp_super_cache_front_page_clear ) || ( isset( $wp_super_cache_front_page_clear ) && $wp_super_cache_front_page_clear == 0 ) ) { wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Front page is not correct! Please clear cache!', 'wp-super-cache' ), site_url() ), sprintf( __( 'Please visit %1$s to clear the cache as the front page of your site is not correct and missing the text, "%2$s"!', 'wp-super-cache' ), trailingslashit( site_url() ) . "wp-admin/options-general.php?page=wpsupercache", $wp_super_cache_front_page_text ) ); } else { wp_cache_clear_cache(); wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Front page is not correct! Cache Cleared!', 'wp-super-cache' ), site_url() ), sprintf( __( 'The cache on your blog has been cleared because the front page of your site is missing the text "%2$s". Please visit %1$s to verify the cache has been cleared.', 'wp-super-cache' ), trailingslashit( site_url() ) . "wp-admin/options-general.php?page=wpsupercache", $wp_super_cache_front_page_text ) ); } } } if ( isset( $wp_super_cache_front_page_notification ) && $wp_super_cache_front_page_notification == 1 ) { wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Front page check!', 'wp-super-cache' ), site_url() ), sprintf( __( "WP Super Cache has checked the front page of your blog. Please visit %s if you would like to disable this.", 'wp-super-cache' ) . "\n\n", trailingslashit( site_url() ) . "wp-admin/options-general.php?page=wpsupercache#debug" ) . print_r( $front_page, 1 ) ); } if ( !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 ); } } add_action( 'wp_cache_check_site_hook', 'wp_cache_check_site' ); function update_cached_mobile_ua_list( $mobile_browsers, $mobile_prefixes = 0, $mobile_groups = 0 ) { global $wp_cache_config_file, $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes, $wp_cache_mobile_groups; if ( is_array( $mobile_browsers ) ) { $wp_cache_mobile_browsers = $mobile_browsers; wp_cache_replace_line('^ *\$wp_cache_mobile_browsers', "\$wp_cache_mobile_browsers = '" . implode( ', ', $mobile_browsers ) . "';", $wp_cache_config_file); } if ( is_array( $mobile_prefixes ) ) { $wp_cache_mobile_prefixes = $mobile_prefixes; wp_cache_replace_line('^ *\$wp_cache_mobile_prefixes', "\$wp_cache_mobile_prefixes = '" . implode( ', ', $mobile_prefixes ) . "';", $wp_cache_config_file); } if ( is_array( $mobile_groups ) ) { $wp_cache_mobile_groups = $mobile_groups; wp_cache_replace_line('^ *\$wp_cache_mobile_groups', "\$wp_cache_mobile_groups = '" . implode( ', ', $mobile_groups ) . "';", $wp_cache_config_file); } return true; } function wpsc_update_htaccess() { extract( wpsc_get_htaccess_info() ); wpsc_remove_marker( $home_path.'.htaccess', 'WordPress' ); // remove original WP rules so SuperCache rules go on top if( insert_with_markers( $home_path.'.htaccess', 'WPSuperCache', explode( "\n", $rules ) ) && insert_with_markers( $home_path.'.htaccess', 'WordPress', explode( "\n", $wprules ) ) ) { return true; } else { return false; } } function wpsc_update_htaccess_form( $short_form = true ) { global $wpmu_version; extract( wpsc_get_htaccess_info() ); if( !is_writeable_ACLSafe( $home_path . ".htaccess" ) ) { echo "

    " . __( 'Cannot update .htaccess', 'wp-super-cache' ) . "

    " . sprintf( __( 'The file %s.htaccess cannot be modified by the web server. Please correct this using the chmod command or your ftp client.', 'wp-super-cache' ), $home_path ) . "

    " . __( 'Refresh this page when the file permissions have been modified.' ) . "

    " . sprintf( __( 'Alternatively, you can edit your %s.htaccess file manually and add the following code (before any WordPress rules):', 'wp-super-cache' ), $home_path ) . "

    "; echo "

    # BEGIN WPSuperCache\n" . esc_html( $rules ) . "# END WPSuperCache

    "; } else { if ( $short_form == false ) { echo "

    " . sprintf( __( 'To serve static html files your server must have the correct mod_rewrite rules added to a file called %s.htaccess', 'wp-super-cache' ), $home_path ) . " "; _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' ) . "

    "; echo "
    # BEGIN WPSuperCache\n" . esc_html( $rules ) . "# END WPSuperCache

    "; echo "

    " . sprintf( __( 'Rules must be added to %s too:', 'wp-super-cache' ), WP_CONTENT_DIR . "/cache/.htaccess" ) . "

    "; echo "
    # BEGIN supercache\n" . esc_html( $gziprules ) . "# END supercache

    "; } if ( !isset( $wpmu_version ) || $wpmu_version == '' ) { echo '
    '; echo ''; echo '
    '; wp_nonce_field('wp-cache'); echo "
    \n"; } } } function wpsc_get_htaccess_info() { global $wp_cache_mobile_enabled, $wp_cache_mobile_prefixes, $wp_cache_mobile_browsers; 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}'; } $content_dir_root = $document_root; if ( strpos( $document_root, '/kunden/' ) === 0 ) { // http://wordpress.org/support/topic/plugin-wp-super-cache-how-to-get-mod_rewrite-working-on-1and1-shared-hosting?replies=1 // On 1and1, PHP's directory structure starts with '/homepages'. The // Apache directory structure has an extra '/kunden' before it. // Also 1and1 does not support the %{DOCUMENT_ROOT} variable in // .htaccess files. // This prevents the $inst_root from being calculated correctly and // means that the $apache_root is wrong. // // e.g. This is an example of how Apache and PHP see the directory // structure on 1and1: // Apache: /kunden/homepages/xx/dxxxxxxxx/htdocs/site1/index.html // PHP: /homepages/xx/dxxxxxxxx/htdocs/site1/index.html // Here we fix up the paths to make mode_rewrite work on 1and1 shared hosting. $content_dir_root = substr( $content_dir_root, 7 ); $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( $content_dir_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_logged_in|wp-postpass_).*$"; $condition_rules[] = "RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\\\"]+ [NC]"; $condition_rules[] = "RewriteCond %{HTTP:Profile} !^[a-z0-9\\\"]+ [NC]"; if ( $wp_cache_mobile_enabled ) { $condition_rules[] = "RewriteCond %{HTTP_USER_AGENT} !^.*(" . addcslashes( implode( '|', $wp_cache_mobile_browsers ), ' ' ) . ").* [NC]"; $condition_rules[] = "RewriteCond %{HTTP_user_agent} !^(" . addcslashes( implode( '|', $wp_cache_mobile_prefixes ), ' ' ) . ").* [NC]"; } $condition_rules = apply_filters( 'supercacherewriteconditions', $condition_rules ); $rules = "\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 .= "\n"; $rules = apply_filters( 'supercacherewriterules', $rules ); $rules = str_replace( "CONDITION_RULES", implode( "\n", $condition_rules ) . "\n", $rules ); $gziprules = "\n \n ForceType text/html\n FileETag None\n \n AddEncoding gzip .gz\n AddType text/html .gz\n\n"; $gziprules .= "\n SetEnvIfNoCase Request_URI \.gz$ no-gzip\n\n"; $gziprules .= "\n Header set Vary \"Accept-Encoding, Cookie\"\n Header set Cache-Control 'max-age=3, must-revalidate'\n\n"; $gziprules .= "\n ExpiresActive On\n ExpiresByType text/html A3\n\n"; return array( "document_root" => $document_root, "apache_root" => $apache_root, "home_path" => $home_path, "home_root" => $home_root, "inst_root" => $inst_root, "wprules" => $wprules, "scrules" => $scrules, "condition_rules" => $condition_rules, "rules" => $rules, "gziprules" => $gziprules ); } function clear_post_supercache( $post_id ) { $dir = get_current_url_supercache_dir( $post_id ); if ( file_exists( $dir . 'index.html' ) ) { @unlink( $dir . 'index.html' ); } if ( file_exists( $dir . 'index.html.gz' ) ) { @unlink( $dir . 'index.html.gz' ); } } function wp_cron_preload_cache() { global $wpdb, $wp_cache_preload_interval, $wp_cache_preload_posts, $wp_cache_preload_email_me, $wp_cache_preload_email_volume, $cache_path; if ( get_option( 'preload_cache_stop' ) ) { delete_option( 'preload_cache_stop' ); return true; } $mutex = $cache_path . "preload_mutex.tmp"; sleep( 3 + mt_rand( 1, 5 ) ); if ( @file_exists( $mutex ) ) { if ( @filemtime( $mutex ) > ( time() - 600 ) ) { return true; } else { @unlink( $mutex ); } } $fp = @fopen( $mutex, 'w' ); @fclose( $fp ); $counter = get_option( 'preload_cache_counter' ); $c = $counter[ 'c' ]; if ( $wp_cache_preload_posts == 'all' || $c <= $wp_cache_preload_posts ) { $posts = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE (post_type = 'post' OR post_type='page') AND post_status = 'publish' ORDER BY post_date DESC LIMIT $c, 100" ); } else { $posts = false; } if ( !isset( $wp_cache_preload_email_volume ) ) $wp_cache_preload_email_volume = 'medium'; update_option( 'preload_cache_counter', array( 'c' => ( $c + 100 ), 't' => time() ) ); if ( $posts ) { if ( $wp_cache_preload_email_me && $c == 0 ) wp_mail( get_option( 'admin_email' ), sprintf( __( '[%1$s] Cache Preload Started', 'wp-super-cache' ), site_url(), '' ), '' ); if ( $wp_cache_preload_email_me && $wp_cache_preload_email_volume == 'many' ) wp_mail( get_option( 'admin_email' ), sprintf( __( '[%1$s] Refreshing posts from %2$d to %3$d', 'wp-super-cache' ), site_url(), $c, ($c+100) ), '' ); $msg = ''; $count = $c + 1; $permalink_counter_msg = $cache_path . "preload_permalink.txt"; foreach( $posts as $post_id ) { set_time_limit( 60 ); clear_post_supercache( $post_id ); $url = get_permalink( $post_id ); $fp = @fopen( $permalink_counter_msg, 'w' ); if ( $fp ) { @fwrite( $fp, $count . " " . $url ); @fclose( $fp ); } if ( @file_exists( $cache_path . "stop_preload.txt" ) ) { @unlink( $mutex ); @unlink( $cache_path . "stop_preload.txt" ); update_option( 'preload_cache_counter', array( 'c' => 0, 't' => time() ) ); if ( $wp_cache_preload_email_me ) wp_mail( get_option( 'admin_email' ), sprintf( __( '[%1$s] Cache Preload Stopped', 'wp-super-cache' ), site_url(), '' ), '' ); return true; } $msg .= "$url\n"; wp_remote_get( $url, array('timeout' => 60, 'blocking' => true ) ); sleep( 1 ); $count++; } if ( $wp_cache_preload_email_me && $wp_cache_preload_email_volume != 'less' ) wp_mail( get_option( 'admin_email' ), sprintf( __( '[%1$s] %2$d posts refreshed', 'wp-super-cache' ), $_SERVER[ 'HTTP_HOST' ], ($c+100) ), __( "Refreshed the following posts:", 'wp-super-cache' ) . "\n$msg" ); if ( defined( 'DOING_CRON' ) ) { wp_schedule_single_event( time() + 30, 'wp_cache_preload_hook' ); } } else { $msg = ''; update_option( 'preload_cache_counter', array( 'c' => 0, 't' => time() ) ); if ( (int)$wp_cache_preload_interval && defined( 'DOING_CRON' ) ) { if ( $wp_cache_preload_email_me ) $msg = sprintf( __( 'Scheduling next preload refresh in %d minutes.', 'wp-super-cache' ), (int)$wp_cache_preload_interval ); wp_schedule_single_event( time() + ( (int)$wp_cache_preload_interval * 60 ), 'wp_cache_full_preload_hook' ); } global $file_prefix, $cache_max_time; if ( $wp_cache_preload_interval > 0 ) { $cache_max_time = (int)$wp_cache_preload_interval * 60; // fool the GC into expiring really old files } else { $cache_max_time = 86400; // fool the GC into expiring really old files } if ( $wp_cache_preload_email_me ) wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Cache Preload Completed', 'wp-super-cache' ), site_url() ), __( "Cleaning up old supercache files.", 'wp-super-cache' ) . "\n" . $msg ); wp_cache_phase2_clean_expired( $file_prefix, true ); // force cleanup of old files. } @unlink( $mutex ); } add_action( 'wp_cache_preload_hook', 'wp_cron_preload_cache' ); add_action( 'wp_cache_full_preload_hook', 'wp_cron_preload_cache' ); function next_preload_message( $hook, $text, $limit = 0 ) { global $currently_preloading, $wp_cache_preload_interval; if ( $next_preload = wp_next_scheduled( $hook ) ) { $next_time = $next_preload - time(); if ( $limit != 0 && $next_time > $limit ) return false; $h = $m = $s = 0; if ( $next_time > 0 ) { // http://bytes.com/topic/php/answers/3917-seconds-converted-hh-mm-ss $m = (int)($next_time / 60); $s = $next_time % 60; $h = (int)($m / 60); $m = $m % 60; } if ( $next_time > 0 && $next_time < ( 60 * $wp_cache_preload_interval ) ) echo '

    ' . sprintf( $text, $h, $m, $s ) . '

    '; if ( ( $next_preload - time() ) <= 60 ) $currently_preloading = true; } } function option_preload_cache_counter( $value ) { if ( false == is_array( $value ) ) { $ret = array( 'c' => $value, 't' => time(), 'first' => 1 ); return $ret; } return $value; } add_filter( 'option_preload_cache_counter', 'option_preload_cache_counter' ); function check_up_on_preloading() { $value = get_option( 'preload_cache_counter' ); if ( $value[ 'c' ] > 0 && ( time() - $value[ 't' ] ) > 3600 && false == wp_next_scheduled( 'wp_cache_preload_hook' ) ) { if ( is_admin() ) wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Preload may have stalled.', 'wp-super-cache' ), get_bloginfo( 'url' ) ), sprintf( __( "Preload has been restarted.\n%s", 'wp-super-cache' ), admin_url( "options-general.php?page=wpsupercache" ) ) ); wp_schedule_single_event( time() + 30, 'wp_cache_preload_hook' ); } } add_action( 'init', 'check_up_on_preloading' ); // sometimes preloading stops working. Kickstart it. function wp_cache_disable_plugin() { global $wp_cache_config_file, $wp_rewrite; if ( file_exists( ABSPATH . 'wp-config.php') ) { $global_config_file = ABSPATH . 'wp-config.php'; } else { $global_config_file = dirname(ABSPATH) . '/wp-config.php'; } $line = 'define(\'WP_CACHE\', true);'; if ( strpos( file_get_contents( $global_config_file ), $line ) && ( !is_writeable_ACLSafe( $global_config_file ) || !wp_cache_replace_line( 'define *\( *\'WP_CACHE\'', '//' . $line, $global_config_file ) ) ) wp_die( "Could not remove WP_CACHE define from $global_config_file. Please edit that file and remove the line containing the text 'WP_CACHE'. Then refresh this page." ); uninstall_supercache( WP_CONTENT_DIR . '/cache' ); $file_not_deleted = false; if ( @file_exists( WP_CONTENT_DIR . "/advanced-cache.php" ) ) { if ( false == @unlink( WP_CONTENT_DIR . "/advanced-cache.php" ) ) $file_not_deleted[] = 'advanced-cache.php'; } if ( @file_exists( WP_CONTENT_DIR . "/wp-cache-config.php" ) ) { if ( false == unlink( WP_CONTENT_DIR . "/wp-cache-config.php" ) ) $file_not_deleted[] = 'wp-cache-config.php'; } if ( $file_not_deleted ) { $msg = "

    One or more files could not be deleted. These files and directories must be made writeable:

    \n
    1. " . WP_CONTENT_DIR . "
    2. \n"; $code = "\n"; $msg .= "
    \n

    First try fixing the directory permissions with this command and refresh this page:

    chmod 777 " . WP_CONTENT_DIR . "

    If you still see this error, you have to fix the permissions on the files themselves and refresh this page again:

    {$code}\n

    Don't forgot to fix things later:
    chmod 755 " . WP_CONTENT_DIR . "

    If you don't know what chmod is use this Google search to find out all about it.

    Please refresh this page when the permissions have been modified.

    "; wp_die( $msg ); } extract( wpsc_get_htaccess_info() ); if ( $scrules != '' && insert_with_markers( $home_path.'.htaccess', 'WPSuperCache', array() ) ) { $wp_rewrite->flush_rules(); } elseif( $scrules != '' ) { wp_mail( get_option( 'admin_email' ), __( 'Supercache Uninstall Problems', 'wp-super-cache' ), sprintf( __( "Dear User,\n\nWP Super Cache was removed from your blog but the mod_rewrite rules\nin your .htaccess were not.\n\nPlease edit the following file and remove the code\nbetween 'BEGIN WPSuperCache' and 'END WPSuperCache'. Please backup the file first!\n\n%s\n\nRegards,\nWP Super Cache Plugin\nhttp://wordpress.org/extend/plugins/wp-super-cache/", 'wp-super-cache' ), ABSPATH . '/.htaccess' ) ); } } function uninstall_supercache( $folderPath ) { // from http://www.php.net/manual/en/function.rmdir.php if ( trailingslashit( constant( 'ABSPATH' ) ) == trailingslashit( $folderPath ) ) return false; if ( @is_dir ( $folderPath ) ) { $dh = @opendir($folderPath); while( false !== ( $value = @readdir( $dh ) ) ) { if ( $value != "." && $value != ".." ) { $value = $folderPath . "/" . $value; if ( @is_dir ( $value ) ) { uninstall_supercache( $value ); } else { @unlink( $value ); } } } return @rmdir( $folderPath ); } else { return false; } } ?>