$header) { // godaddy fix, via http://blog.gneu.org/2008/05/wp-supercache-on-godaddy/ and http://www.littleredrails.com/blog/2007/09/08/using-wp-cache-on-godaddy-500-error/ if( strpos( $header, 'Last-Modified:' ) === false ) header($header); } if ( isset( $wpsc_served_header ) && $wpsc_served_header ) { header( 'X-WP-Super-Cache: Served WPCache cache file' ); } if ( $wp_cache_object_cache ) { if ( $cache ) { if ( $ungzip ) { // attempt to uncompress the cached file just in case it's gzipped $uncompressed = gzuncompress( $cache ); if ( $uncompressed ) { wp_cache_debug( "Uncompressed gzipped cache file from object cache", 1 ); $cache = $uncompressed; unset( $uncompressed ); } } if ( isset( $meta[ 'dynamic' ] ) && $meta[ 'dynamic' ] ) { wp_cache_debug( "Serving wp-cache dynamic file from object cache", 5 ); echo do_cacheaction( 'wpsc_cachedata', $cache ); } else { wp_cache_debug( "Serving wp-cache static file from object cache", 5 ); echo $cache; } wp_cache_debug( "exit request", 5 ); die(); } } else { if ( isset( $meta[ 'dynamic' ] ) ) { wp_cache_debug( "Serving wp-cache dynamic file", 5 ); if ( $ungzip ) { // attempt to uncompress the cached file just in case it's gzipped $cache = wp_cache_get_legacy_cache( $cache_file ); $uncompressed = @gzuncompress( $cache ); if ( $uncompressed ) { wp_cache_debug( "Uncompressed gzipped cache file from wp-cache", 1 ); unset( $cache ); echo do_cacheaction( 'wpsc_cachedata', $uncompressed ); } else { echo do_cacheaction( 'wpsc_cachedata', $cache ); } } else { echo do_cacheaction( 'wpsc_cachedata', wp_cache_get_legacy_cache( $cache_file ) ); } } else { wp_cache_debug( "Serving wp-cache static file", 5 ); if ( $ungzip ) { $cache = wp_cache_get_legacy_cache( $cache_file ); $uncompressed = gzuncompress( $cache ); if ( $uncompressed ) { wp_cache_debug( "Uncompressed gzipped cache file from wp-cache", 1 ); echo $uncompressed; } else { echo $cache; } } else { echo( wp_cache_get_legacy_cache( $cache_file ) ); } } wp_cache_debug( "exit request", 5 ); die(); } } function wp_cache_get_legacy_cache( $cache_file ) { return substr( @file_get_contents( $cache_file ), 15 ); } if(defined('DOING_CRON')) { extract( wp_super_cache_init() ); // $key, $cache_filename, $meta_file, $cache_file, $meta_pathname return true; } if ( !isset( $wp_super_cache_late_init ) || ( isset( $wp_super_cache_late_init ) && false == $wp_super_cache_late_init ) ) { wp_cache_serve_cache_file(); } function wp_cache_postload() { global $cache_enabled, $wp_super_cache_late_init; if ( !$cache_enabled ) return true; if ( isset( $wp_super_cache_late_init ) && true == $wp_super_cache_late_init ) { wp_cache_debug( "Supercache Late Init: add wp_cache_serve_cache_file to init", 3 ); add_action( 'init', 'wp_cache_late_loader', 9999 ); } else { wp_super_cache_init(); wp_cache_phase2(); } } function wp_cache_late_loader() { wp_cache_debug( "Supercache Late Loader running on init", 3 ); wp_cache_serve_cache_file(); wp_cache_phase2(); } function wp_cache_get_cookies_values() { static $string = ''; if ( $string != '' ) { wp_cache_debug( "wp_cache_get_cookies_values: cached: $string" ); return $string; } if ( defined( 'COOKIEHASH' ) ) $cookiehash = preg_quote( constant( 'COOKIEHASH' ) ); else $cookiehash = ''; $regex = "/^wp-postpass_$cookiehash|^comment_author_$cookiehash"; if ( defined( 'LOGGED_IN_COOKIE' ) ) $regex .= "|^" . preg_quote( constant( 'LOGGED_IN_COOKIE' ) ); else $regex .= "|^wordpress_logged_in_$cookiehash"; $regex .= "/"; while ($key = key($_COOKIE)) { if ( preg_match( $regex, $key ) ) { wp_cache_debug( "wp_cache_get_cookies_values: $regex Cookie detected: $key", 5 ); $string .= $_COOKIE[ $key ] . ","; } next($_COOKIE); } reset($_COOKIE); // If you use this hook, make sure you update your .htaccess rules with the same conditions $string = do_cacheaction( 'wp_cache_get_cookies_values', $string ); if ( $string != '' ) $string = md5( $string ); wp_cache_debug( "wp_cache_get_cookies_values: return: $string", 5 ); return $string; } function add_cacheaction( $action, $func ) { global $wp_supercache_actions; $wp_supercache_actions[ $action ][] = $func; } function do_cacheaction( $action, $value = '' ) { global $wp_supercache_actions; if ( !isset( $wp_supercache_actions ) || !is_array( $wp_supercache_actions ) ) return $value; if( array_key_exists($action, $wp_supercache_actions) && is_array( $wp_supercache_actions[ $action ] ) ) { $actions = $wp_supercache_actions[ $action ]; foreach( $actions as $func ) { $value = call_user_func_array( $func, array( $value ) ); } } return $value; } function wp_cache_mobile_group( $user_agent ) { global $wp_cache_mobile_groups; foreach( (array)$wp_cache_mobile_groups as $name => $group ) { foreach( (array)$group as $browser ) { $browser = trim( strtolower( $browser ) ); if ( $browser != '' && strstr( $user_agent, $browser ) ) { return $browser; } } } return "mobile"; } // From http://wordpress.org/plugins/wordpress-mobile-edition/ by Alex King function wp_cache_check_mobile( $cache_key ) { global $wp_cache_mobile_enabled, $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes; if ( !isset( $wp_cache_mobile_enabled ) || false == $wp_cache_mobile_enabled ) return $cache_key; wp_cache_debug( "wp_cache_check_mobile: $cache_key" ); // allow plugins to short circuit mobile check. Cookie, extra UA checks? switch( do_cacheaction( 'wp_cache_check_mobile', $cache_key ) ) { case "normal": wp_cache_debug( "wp_cache_check_mobile: desktop user agent detected by wp_cache_check_mobile action" ); return $cache_key; break; case "mobile": wp_cache_debug( "wp_cache_check_mobile: mobile user agent detected by wp_cache_check_mobile action" ); return $cache_key . "-mobile"; break; } if ( !isset( $_SERVER[ "HTTP_USER_AGENT" ] ) ) { return $cache_key; } if ( do_cacheaction( 'disable_mobile_check', false ) ) { wp_cache_debug( "wp_cache_check_mobile: disable_mobile_check disabled mobile check" ); return $cache_key; } $browsers = explode( ',', $wp_cache_mobile_browsers ); $user_agent = strtolower( $_SERVER['HTTP_USER_AGENT'] ); foreach ($browsers as $browser) { if ( strstr( $user_agent, trim( strtolower( $browser ) ) ) ) { wp_cache_debug( "mobile browser detected: " . $_SERVER[ "HTTP_USER_AGENT" ], 5 ); return $cache_key . '-' . wp_cache_mobile_group( $user_agent ); } } if (isset($_SERVER['HTTP_X_WAP_PROFILE']) ) return $cache_key . '-' . $_SERVER['HTTP_X_WAP_PROFILE']; if (isset($_SERVER['HTTP_PROFILE']) ) return $cache_key . '-' . $_SERVER['HTTP_PROFILE']; if ( isset( $wp_cache_mobile_prefixes ) ) { $browsers = explode( ',', $wp_cache_mobile_prefixes ); foreach ($browsers as $browser_prefix) { if ( substr($user_agent, 0, 4) == $browser_prefix ) { wp_cache_debug( "mobile browser (prefix) detected: " . $_SERVER[ "HTTP_USER_AGENT" ], 5 ); return $cache_key . '-' . $browser_prefix; } } } $accept = isset( $_SERVER[ 'HTTP_ACCEPT' ] ) ? strtolower( $_SERVER[ 'HTTP_ACCEPT' ] ) : ''; if (strpos($accept, 'wap') !== false) { return $cache_key . '-' . 'wap'; } if (isset($_SERVER['ALL_HTTP']) && strpos(strtolower($_SERVER['ALL_HTTP']), 'operamini') !== false) { return $cache_key . '-' . 'operamini'; } return $cache_key; } /** * Add a log message to the file, if debugging is turned on * * @param $message string The message that should be added to the log * @param $level int */ function wp_cache_debug( $message, $level = 1 ) { global $wp_cache_debug_log, $cache_path, $wp_cache_debug_ip, $wp_super_cache_debug; // If either of the debug or log globals aren't set, then we can stop if ( !isset($wp_super_cache_debug) || !isset($wp_cache_debug_log) ) return false; // If either the debug or log globals are false or empty, we can stop if ( $wp_super_cache_debug == false || $wp_cache_debug_log == '' ) return false; // If the debug_ip has been set, but it doesn't match the ip of the requester // then we can stop. if ( isset($wp_cache_debug_ip) && $wp_cache_debug_ip != '' && $wp_cache_debug_ip != $_SERVER[ 'REMOTE_ADDR' ] ) return false; // Log message: Date URI Message $log_message = date('H:i:s') . " " . getmypid() . " {$_SERVER['REQUEST_URI']} {$message}" . PHP_EOL; // path to the log file in the cache folder $log_file = $cache_path . str_replace('/', '', str_replace('..', '', $wp_cache_debug_log)); if ( ! file_exists( $log_file ) && function_exists( 'wpsc_create_debug_log' ) ) { global $wp_cache_debug_username; if ( ! isset( $wp_cache_debug_username ) ) { $wp_cache_debug_username = ''; } wpsc_create_debug_log( $wp_cache_debug_log, $wp_cache_debug_username ); } error_log( $log_message, 3, $log_file ); } function wp_cache_user_agent_is_rejected() { global $cache_rejected_user_agent; if (!function_exists('apache_request_headers')) return false; $headers = apache_request_headers(); if (!isset($headers["User-Agent"])) return false; if ( false == is_array( $cache_rejected_user_agent ) ) return false; foreach ($cache_rejected_user_agent as $expr) { if (strlen($expr) > 0 && stristr($headers["User-Agent"], $expr)) return true; } return false; } function get_supercache_dir( $blog_id = 0 ) { global $cache_path; if ( $blog_id == 0 ) { $home = get_option( 'home' ); } else { $home = get_blog_option( $blog_id, 'home' ); } return trailingslashit( apply_filters( 'wp_super_cache_supercachedir', $cache_path . 'supercache/' . trailingslashit( strtolower( preg_replace( '/:.*$/', '', str_replace( 'http://', '', str_replace( 'https://', '', $home ) ) ) ) ) ) ); } function get_current_url_supercache_dir( $post_id = 0 ) { global $cached_direct_pages, $cache_path, $wp_cache_request_uri, $WPSC_HTTP_HOST, $wp_cache_home_path; static $saved_supercache_dir = array(); if ( isset( $saved_supercache_dir[ $post_id ] ) ) { return $saved_supercache_dir[ $post_id ]; } $DONOTREMEMBER = 0; if ( $post_id != 0 ) { $site_url = site_url(); $permalink = get_permalink( $post_id ); if ( false === strpos( $permalink, $site_url ) ) { /* * Sometimes site_url doesn't return the siteurl. See http://wordpress.org/support/topic/wp-super-cache-not-refreshing-post-after-comments-made */ $DONOTREMEMBER = 1; wp_cache_debug( "get_current_url_supercache_dir: warning! site_url ($site_url) not found in permalink ($permalink).", 1 ); if ( $WPSC_HTTP_HOST == '' || false === strpos( $permalink, $WPSC_HTTP_HOST ) ) { wp_cache_debug( "get_current_url_supercache_dir: WARNING! SERVER_NAME ({$WPSC_HTTP_HOST}) not found in permalink ($permalink). ", 1 ); $p = parse_url( $permalink ); if ( is_array( $p ) ) { $uri = $p[ 'path' ]; wp_cache_debug( "get_current_url_supercache_dir: WARNING! Using $uri as permalink. Used parse_url.", 1 ); } else { wp_cache_debug( "get_current_url_supercache_dir: WARNING! Permalink ($permalink) could not be understood by parse_url. Using front page.", 1 ); $uri = ''; } } else { wp_cache_debug( "get_current_url_supercache_dir: Removing SERVER_NAME ({$WPSC_HTTP_HOST}) from permalink ($permalink). Is the url right?", 1 ); $uri = str_replace( $WPSC_HTTP_HOST, '', $permalink ); $uri = str_replace( 'http://', '', $uri ); $uri = str_replace( 'https://', '', $uri ); } } else { $uri = str_replace( $site_url, '', $permalink ); if ( strpos( $uri, $wp_cache_home_path ) !== 0 ) $uri = rtrim( $wp_cache_home_path, '/' ) . $uri; } } else { $uri = strtolower( $wp_cache_request_uri ); } $uri = wpsc_deep_replace( array( '..', '\\', 'index.php', ), preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', preg_replace( "/(\?.*)?$/", '', $uri ) ) ); $dir = preg_replace( '/:.*$/', '', $WPSC_HTTP_HOST ) . $uri; // To avoid XSS attacks if ( function_exists( "apply_filters" ) ) { $dir = apply_filters( 'supercache_dir', $dir ); } else { $dir = do_cacheaction( 'supercache_dir', $dir ); } $dir = $cache_path . 'supercache/' . $dir . '/'; if( is_array( $cached_direct_pages ) && in_array( $_SERVER[ 'REQUEST_URI' ], $cached_direct_pages ) ) { $dir = ABSPATH . $uri . '/'; } $dir = str_replace( '..', '', str_replace( '//', '/', $dir ) ); wp_cache_debug( "supercache dir: $dir", 5 ); if ( $DONOTREMEMBER == 0 ) $saved_supercache_dir[ $post_id ] = $dir; return $dir; } /* * Delete (or rebuild) all the files in one directory. * Checks if it is in the cache directory but doesn't allow files in the following directories to be deleted: * wp-content/cache/ * wp-content/cache/blogs/ * wp-content/cache/supercache/ * */ function wpsc_rebuild_files( $dir ) { return wpsc_delete_files( $dir, false ); } // realpath() doesn't always remove the trailing slash function wpsc_get_realpath( $directory ) { if ( $directory == '/' ) { return false; } $original_dir = $directory; $directory = realpath( $directory ); if ( ! $directory ) { wp_cache_debug( "wpsc_get_realpath: directory does not exist - $original_dir" ); return false; } if ( substr( $directory, -1 ) == '/' || substr( $directory, -1 ) == '\\' ) { $directory = substr( $directory, 0, -1 ); // remove trailing slash } return $directory; } // return true if directory is in the cache directory function wpsc_is_in_cache_directory( $directory ) { global $cache_path; static $rp_cache_path = ''; if ( $directory == '' ) { wp_cache_debug( "wpsc_is_in_cache_directory: exiting as directory is blank" ); return false; } if ( $cache_path == '' ) { wp_cache_debug( "wpsc_is_in_cache_directory: exiting as cache_path is blank" ); return false; } if ( $rp_cache_path == '' ) { $rp_cache_path = wpsc_get_realpath( $cache_path ); } if ( ! $rp_cache_path ) { wp_cache_debug( "wpsc_is_in_cache_directory: exiting as cache_path directory does not exist" ); return false; } $directory = wpsc_get_realpath( $directory ); if ( ! $directory ) { wp_cache_debug( "wpsc_is_in_cache_directory: directory does not exist" ); return false; } if ( substr( $directory, 0, strlen( $rp_cache_path ) ) == $rp_cache_path ) { return true; } else { return false; } } function wpsc_delete_files( $dir, $delete = true ) { global $cache_path; static $protected = ''; if ( $dir == '' ) { wp_cache_debug( "wpsc_delete_files: directory is blank" ); return false; } // only do this once, this function will be called many times if ( $protected == '' ) { $protected = array( $cache_path, $cache_path . "blogs/", $cache_path . 'supercache' ); foreach( $protected as $id => $directory ) { $protected[ $id ] = trailingslashit( wpsc_get_realpath( $directory ) ); } } $dir = wpsc_get_realpath( $dir ); if ( ! $dir ) { wp_cache_debug( "wpsc_delete_files: directory does not exist" ); return false; } $dir = trailingslashit( $dir ); if ( ! wpsc_is_in_cache_directory( $dir ) ) { return false; } if ( in_array( $dir, $protected ) ) return false; if ( is_dir( $dir ) && $dh = @opendir( $dir ) ) { while ( ( $file = readdir( $dh ) ) !== false ) { if ( $file != '.' && $file != '..' && $file != '.htaccess' && is_file( $dir . $file ) ) if ( $delete ) @unlink( $dir . $file ); else @wp_cache_rebuild_or_delete( $dir . $file ); } closedir( $dh ); if ( $delete ) @rmdir( $dir ); } return true; } function get_all_supercache_filenames( $dir = '' ) { global $wp_cache_mobile_enabled, $cache_path; $dir = wpsc_get_realpath( $dir ); if ( ! $dir ) { wp_cache_debug( "get_all_supercache_filenames: directory does not exist" ); return array(); } if ( ! wpsc_is_in_cache_directory( $dir ) ) { return array(); } $filenames = array( 'index.html', 'index-https.html', 'index.html.php' ); if ( $dir != '' && isset( $wp_cache_mobile_enabled ) && $wp_cache_mobile_enabled ) { // open directory and look for index-*.html files if ( is_dir( $dir ) && $dh = @opendir( $dir ) ) { while ( ( $file = readdir( $dh ) ) !== false ) { if ( substr( $file, 0, 6 ) == 'index-' && strpos( $file, '.html' ) ) $filenames[] = $file; } closedir( $dh ); } } if ( function_exists( "apply_filters" ) ) { $filenames = apply_filters( 'all_supercache_filenames', $filenames ); } else { $filenames = do_cacheaction( 'all_supercache_filenames', $filenames ); } foreach( $filenames as $file ) { $out[] = $file; $out[] = $file . '.gz'; } return $out; } function supercache_filename() { global $cached_direct_pages; //Add support for https and http caching $is_https = ( ( isset( $_SERVER[ 'HTTPS' ] ) && 'on' == strtolower( $_SERVER[ 'HTTPS' ] ) ) || ( isset( $_SERVER[ 'HTTP_X_FORWARDED_PROTO' ] ) && 'https' == strtolower( $_SERVER[ 'HTTP_X_FORWARDED_PROTO' ] ) ) ); //Also supports https requests coming from an nginx reverse proxy $extra_str = $is_https ? '-https' : ''; if ( function_exists( "apply_filters" ) ) { $extra_str = apply_filters( 'supercache_filename_str', $extra_str ); } else { $extra_str = do_cacheaction( 'supercache_filename_str', $extra_str ); } if ( is_array( $cached_direct_pages ) && in_array( $_SERVER[ 'REQUEST_URI' ], $cached_direct_pages ) ) { $extra_str = ''; } $filename = 'index' . $extra_str . '.html'; return $filename; } function get_oc_version() { $wp_cache_oc_key = wp_cache_get( "wp_cache_oc_key" ); if ( ! $wp_cache_oc_key ) { $wp_cache_oc_key[ 'key' ] = reset_oc_version(); } elseif ( $wp_cache_oc_key[ 'ts' ] < time() - 600 ) wp_cache_set( "wp_cache_oc_key", array( 'ts' => time(), 'key' => $wp_cache_oc_key[ 'key' ] ) ); return $wp_cache_oc_key[ 'key' ]; } function reset_oc_version( $version = 1 ) { if ( $version == 1 ) $version = mt_rand(); wp_cache_set( "wp_cache_oc_key", array( 'ts' => time(), 'key' => $version ) ); return $version; } function get_oc_key( $url = false ) { global $wp_cache_gzip_encoding, $WPSC_HTTP_HOST; if ( $url ) { $key = intval( $_SERVER[ 'SERVER_PORT' ] ) . strtolower( preg_replace( '/:.*$/', '', $WPSC_HTTP_HOST ) ) . $url; } else { $key = get_current_url_supercache_dir(); } return $key . $wp_cache_gzip_encoding . get_oc_version(); } function wp_supercache_cache_for_admins() { if ( isset( $_GET[ 'preview' ] ) || function_exists( "is_admin" ) && is_admin() || defined( 'DOING_AJAX' ) ) return true; if ( false == do_cacheaction( 'wp_supercache_remove_cookies', true ) ) return true; if ( $_SERVER[ "REQUEST_METHOD" ] != 'GET' || strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-json/' ) !== false ) return true; $cookie_keys = array( 'wordpress_logged_in', 'comment_author_' ); if ( defined( 'LOGGED_IN_COOKIE' ) ) $cookie_keys[] = constant( 'LOGGED_IN_COOKIE' ); reset( $_COOKIE ); foreach( $_COOKIE as $cookie => $val ) { reset( $cookie_keys ); foreach( $cookie_keys as $key ) { if ( strpos( $cookie, $key ) !== FALSE ) { wp_cache_debug( 'Removing auth from $_COOKIE to allow caching for logged in user (' . $cookie . ')', 5 ); unset( $_COOKIE[ $cookie ] ); } } } } /* returns true/false depending on location of $dir. */ function wp_cache_confirm_delete( $dir ) { global $cache_path, $blog_cache_dir; // don't allow cache_path, blog cache dir, blog meta dir, supercache. $dir = wpsc_get_realpath( $dir ); if ( ! $dir ) { wp_cache_debug( "wp_cache_confirm_delete: directory does not exist" ); return false; } if ( ! wpsc_is_in_cache_directory( $dir ) ) { return false; } $rp_cache_path = wpsc_get_realpath( $cache_path ); if ( ! $rp_cache_path ) { wp_cache_debug( "wp_cache_confirm_delete: cache_path does not exist: $cache_path" ); return false; } if ( $dir == '' || $dir == $rp_cache_path || $dir == wpsc_get_realpath( $blog_cache_dir ) || $dir == wpsc_get_realpath( $blog_cache_dir . "meta/" ) || $dir == wpsc_get_realpath( $cache_path . "supercache" ) ) { return false; } else { return true; } } // copy of _deep_replace() to be used before WordPress loads function wpsc_deep_replace( $search, $subject ) { $subject = (string) $subject; $count = 1; while ( $count ) { $subject = str_replace( $search, '', $subject, $count ); } return $subject; } function wpsc_get_protected_directories() { global $cache_path, $blog_cache_dir; return apply_filters( 'wpsc_protected_directories', array( $cache_path . '.htaccess', $cache_path . "index.html", $blog_cache_dir, $blog_cache_dir . "index.html", $blog_cache_dir . 'meta', $blog_cache_dir . 'meta/index.html', $cache_path . 'supercache/index.html', $cache_path . 'supercache' ) ); } function wpsc_create_debug_log( $filename = '', $username = '' ) { global $cache_path, $wp_cache_debug_username, $wp_cache_debug_log; if ( $filename != '' ) { $wp_cache_debug_log = $filename; } else { $wp_cache_debug_log = md5( time() + mt_rand() ) . ".php"; } if ( $username != '' ) { $wp_cache_debug_username = $username; } else { $wp_cache_debug_username = md5( time() + mt_rand() ); } $msg = ' if ( !isset( $_SERVER[ "PHP_AUTH_USER" ] ) || ( $_SERVER[ "PHP_AUTH_USER" ] != "' . $wp_cache_debug_username . '" && $_SERVER[ "PHP_AUTH_PW" ] != "' . $wp_cache_debug_username . '" ) ) { header( "WWW-Authenticate: Basic realm=\"WP-Super-Cache Debug Log\"" ); header("HTTP/1.0 401 Unauthorized"); echo "You must login to view the debug log"; exit; }' . PHP_EOL; $fp = fopen( $cache_path . $wp_cache_debug_log, 'w' ); if ( $fp ) { fwrite( $fp, '<' . "?php\n" ); fwrite( $fp, $msg ); fwrite( $fp, '?' . ">
" . PHP_EOL );
		fwrite( $fp, '<' . '?php // END HEADER ?' . '>' . PHP_EOL );
		fclose( $fp );
		wp_cache_setting( 'wp_cache_debug_log', $wp_cache_debug_log );
		wp_cache_setting( 'wp_cache_debug_username', $wp_cache_debug_username );
	}
	$fp = fopen( $cache_path . 'view_' . $wp_cache_debug_log, 'w' );
	if ( $fp ) {
		fwrite( $fp, '<' . "?php" . PHP_EOL );
		$msg .= '$debug_log = file( "./' . $wp_cache_debug_log . '" );
$start_log = 1 + array_search( "<" . "?php // END HEADER ?" . ">" . PHP_EOL, $debug_log );
if ( $start_log > 1 ) {
	$debug_log = array_slice( $debug_log, $start_log );
}
?' . '>
<' . '?php $checks = array( "wp-admin", "exclude_filter", "wp-content", "wp-json" ); foreach( $checks as $check ) { if ( isset( $_GET[ $check ] ) ) { $$check = 1; } else { $$check = 0; } } if ( isset( $_GET[ "filter" ] ) ) { $filter = htmlspecialchars( $_GET[ "filter" ] ); } else { $filter = ""; } unset( $checks[1] ); // exclude_filter ?' . '> Exclude requests:
<' . '?php foreach ( $checks as $check ) { ?>
<' . '?php } ?' . '>
Text to filter by:
/> Exclude by filter instead of include.
<' . '?php foreach ( $debug_log as $t => $line ) { foreach( $checks as $check ) { if ( $$check && false !== strpos( $line, " /$check/" ) ) { unset( $debug_log[ $t ] ); } } if ( $filter ) { if ( false !== strpos( $line, $filter ) && $exclude_filter ) { unset( $debug_log[ $t ] ); } elseif ( false === strpos( $line, $filter ) && ! $exclude_filter ) { unset( $debug_log[ $t ] ); } } } foreach( $debug_log as $line ) { echo $line . "
"; }'; fwrite( $fp, $msg ); fclose( $fp ); } return array( 'wp_cache_debug_log' => $wp_cache_debug_log, 'wp_cache_debug_username' => $wp_cache_debug_username ); } function wpsc_delete_url_cache( $url ) { if ( false !== strpos( $url, '?' ) ) { wp_cache_debug( 'wpsc_delete_url_cache: URL contains the character "?". Not deleting URL: ' . $url ); return false; } $dir = str_replace( get_option( 'home' ), '', $url ); if ( $dir != '' ) { $supercachedir = get_supercache_dir(); wpsc_delete_files( $supercachedir . $dir ); prune_super_cache( $supercachedir . $dir . '/page', true ); return true; } else { return false; } } ?>