Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-conte.../plugins/wp-super...
File: wp-cache.php
unlink( $directory . "/index.html" );
[2000] Fix | Delete
}
[2001] Fix | Delete
if ( is_dir( $directory . "/meta" ) ) {
[2002] Fix | Delete
if ( is_file( $directory . "/meta/index.html" ) ) {
[2003] Fix | Delete
unlink( $directory . "/meta/index.html" );
[2004] Fix | Delete
}
[2005] Fix | Delete
}
[2006] Fix | Delete
}
[2007] Fix | Delete
}
[2008] Fix | Delete
}
[2009] Fix | Delete
}
[2010] Fix | Delete
[2011] Fix | Delete
function wp_cache_index_notice() {
[2012] Fix | Delete
global $wp_version, $cache_path;
[2013] Fix | Delete
[2014] Fix | Delete
if ( false == wpsupercache_site_admin() )
[2015] Fix | Delete
return false;
[2016] Fix | Delete
if ( false == get_site_option( 'wp_super_cache_index_detected' ) )
[2017] Fix | Delete
return false;
[2018] Fix | Delete
[2019] Fix | Delete
if ( strlen( $cache_path ) < strlen( ABSPATH )
[2020] Fix | Delete
|| ABSPATH != substr( $cache_path, 0, strlen( ABSPATH ) ) )
[2021] Fix | Delete
return false; // cache stored outside web root
[2022] Fix | Delete
[2023] Fix | Delete
if ( get_site_option( 'wp_super_cache_index_detected' ) == 2 ) {
[2024] Fix | Delete
update_site_option( 'wp_super_cache_index_detected', 3 );
[2025] Fix | Delete
echo "<div class='error' style='padding: 10px 10px 50px 10px'>";
[2026] Fix | Delete
echo "<h2>" . __( 'WP Super Cache Warning!', 'wp-super-cache' ) . '</h2>';
[2027] Fix | Delete
echo '<p>' . __( 'All users of this site have been logged out to refresh their login cookies.', 'wp-super-cache' ) . '</p>';
[2028] Fix | Delete
echo '</div>';
[2029] Fix | Delete
return false;
[2030] Fix | Delete
} elseif ( get_site_option( 'wp_super_cache_index_detected' ) != 3 ) {
[2031] Fix | Delete
echo "<div id='wpsc-index-warning' class='error notice' style='padding: 10px 10px 50px 10px'>";
[2032] Fix | Delete
echo "<h2>" . __( 'WP Super Cache Warning!', 'wp-super-cache' ) . '</h2>';
[2033] Fix | Delete
echo '<p>' . __( 'Your server is configured to show files and directories, which may expose sensitive data such as login cookies to attackers in the cache directories. That has been fixed by adding a file named index.html to each directory. If you use simple caching, consider moving the location of the cache directory on the Advanced Settings page.', 'wp-super-cache' ) . '</p>';
[2034] Fix | Delete
echo "<p><strong>";
[2035] Fix | Delete
_e( 'If you just installed WP Super Cache for the first time, you can dismiss this message. Otherwise, you should probably refresh the login cookies of all logged in WordPress users here by clicking the logout link below.', 'wp-super-cache' );
[2036] Fix | Delete
echo "</strong></p>";
[2037] Fix | Delete
if ( -1 == version_compare( $wp_version, '4.0' ) ) {
[2038] Fix | Delete
echo '<p>' . __( 'Your site is using a very old version of WordPress. When you update to the latest version everyone will be logged out and cookie information updated.', 'wp-super-cache' ) . '</p>';
[2039] Fix | Delete
} else {
[2040] Fix | Delete
echo '<p>' . __( 'The logout link will log out all WordPress users on this site except you. Your authentication cookie will be updated, but you will not be logged out.', 'wp-super-cache' ) . '</p>';
[2041] Fix | Delete
}
[2042] Fix | Delete
echo "<a id='wpsc-dismiss' href='#'>" . __( 'Dismiss', 'wp-super-cache' ) . "</a>";
[2043] Fix | Delete
if ( 1 == version_compare( $wp_version, '4.0' ) ) {
[2044] Fix | Delete
echo " | <a href='" . wp_nonce_url( admin_url( '?action=wpsclogout' ), 'wpsc_logout' ) . "'>" . __( 'Logout', 'wp-super-cache' ) . "</a>";
[2045] Fix | Delete
}
[2046] Fix | Delete
echo "</div>";
[2047] Fix | Delete
?>
[2048] Fix | Delete
<script type='text/javascript'>
[2049] Fix | Delete
<!--
[2050] Fix | Delete
jQuery(document).ready(function(){
[2051] Fix | Delete
jQuery('#wpsc-dismiss').on("click",function() {
[2052] Fix | Delete
jQuery.ajax({
[2053] Fix | Delete
type: "post",url: "admin-ajax.php",data: { action: 'wpsc-index-dismiss', _ajax_nonce: '<?php echo wp_create_nonce( 'wpsc-index-dismiss' ); ?>' },
[2054] Fix | Delete
beforeSend: function() {jQuery("#wpsc-index-warning").fadeOut('slow');},
[2055] Fix | Delete
});
[2056] Fix | Delete
})
[2057] Fix | Delete
})
[2058] Fix | Delete
//-->
[2059] Fix | Delete
</script>
[2060] Fix | Delete
<?php
[2061] Fix | Delete
}
[2062] Fix | Delete
}
[2063] Fix | Delete
add_action( 'admin_notices', 'wp_cache_index_notice' );
[2064] Fix | Delete
[2065] Fix | Delete
function wpsc_config_file_notices() {
[2066] Fix | Delete
global $wp_cache_config_file;
[2067] Fix | Delete
if ( ! isset( $_GET['page'] ) || $_GET['page'] != 'wpsupercache' ) {
[2068] Fix | Delete
return false;
[2069] Fix | Delete
}
[2070] Fix | Delete
$notice = get_transient( 'wpsc_config_error' );
[2071] Fix | Delete
if ( ! $notice ) {
[2072] Fix | Delete
return false;
[2073] Fix | Delete
}
[2074] Fix | Delete
switch( $notice ) {
[2075] Fix | Delete
case 'error_move_tmp_config_file':
[2076] Fix | Delete
$msg = sprintf( __( 'Error: Could not rename temporary file to configuration file. Please make sure %s is writeable by the webserver.' ), $wp_cache_config_file );
[2077] Fix | Delete
break;
[2078] Fix | Delete
case 'config_file_ro':
[2079] Fix | Delete
$msg = sprintf( __( 'Error: Configuration file is read only. Please make sure %s is writeable by the webserver.' ), $wp_cache_config_file );
[2080] Fix | Delete
break;
[2081] Fix | Delete
case 'tmp_file_ro':
[2082] Fix | Delete
$msg = sprintf( __( 'Error: The directory containing the configuration file %s is read only. Please make sure it is writeable by the webserver.' ), $wp_cache_config_file );
[2083] Fix | Delete
break;
[2084] Fix | Delete
case 'config_file_not_loaded':
[2085] Fix | Delete
$msg = sprintf( __( 'Error: Configuration file %s could not be loaded. Please reload the page.' ), $wp_cache_config_file );
[2086] Fix | Delete
break;
[2087] Fix | Delete
case 'config_file_missing':
[2088] Fix | Delete
$msg = sprintf( __( 'Error: Configuration file %s is missing. Please reload the page.' ), $wp_cache_config_file );
[2089] Fix | Delete
break;
[2090] Fix | Delete
[2091] Fix | Delete
}
[2092] Fix | Delete
echo '<div class="error"><p><strong>' . $msg . '</strong></p></div>';
[2093] Fix | Delete
}
[2094] Fix | Delete
add_action( 'admin_notices', 'wpsc_config_file_notices' );
[2095] Fix | Delete
function wpsc_dismiss_indexhtml_warning() {
[2096] Fix | Delete
check_ajax_referer( "wpsc-index-dismiss" );
[2097] Fix | Delete
update_site_option( 'wp_super_cache_index_detected', 3 );
[2098] Fix | Delete
die();
[2099] Fix | Delete
}
[2100] Fix | Delete
add_action( 'wp_ajax_wpsc-index-dismiss', 'wpsc_dismiss_indexhtml_warning' );
[2101] Fix | Delete
[2102] Fix | Delete
function wp_cache_logout_all() {
[2103] Fix | Delete
global $current_user;
[2104] Fix | Delete
if ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'wpsclogout' && wp_verify_nonce( $_GET[ '_wpnonce' ], 'wpsc_logout' ) ) {
[2105] Fix | Delete
$user_id = $current_user->ID;
[2106] Fix | Delete
WP_Session_Tokens::destroy_all_for_all_users();
[2107] Fix | Delete
wp_set_auth_cookie( $user_id, false, is_ssl() );
[2108] Fix | Delete
update_site_option( 'wp_super_cache_index_detected', 2 );
[2109] Fix | Delete
wp_redirect( admin_url() );
[2110] Fix | Delete
}
[2111] Fix | Delete
}
[2112] Fix | Delete
if ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'wpsclogout' )
[2113] Fix | Delete
add_action( 'admin_init', 'wp_cache_logout_all' );
[2114] Fix | Delete
[2115] Fix | Delete
function wp_cache_add_index_protection() {
[2116] Fix | Delete
global $cache_path, $blog_cache_dir;
[2117] Fix | Delete
[2118] Fix | Delete
if ( is_dir( $cache_path ) && false == is_file( "$cache_path/index.html" ) ) {
[2119] Fix | Delete
$page = wp_remote_get( home_url( "/wp-content/cache/" ) );
[2120] Fix | Delete
if ( false == is_wp_error( $page ) ) {
[2121] Fix | Delete
if ( false == get_site_option( 'wp_super_cache_index_detected' )
[2122] Fix | Delete
&& $page[ 'response' ][ 'code' ] == 200
[2123] Fix | Delete
&& stripos( $page[ 'body' ], 'index of' ) ) {
[2124] Fix | Delete
add_site_option( 'wp_super_cache_index_detected', 1 ); // only show this once
[2125] Fix | Delete
}
[2126] Fix | Delete
}
[2127] Fix | Delete
if ( ! function_exists( 'insert_with_markers' ) ) {
[2128] Fix | Delete
include_once( ABSPATH . 'wp-admin/includes/misc.php' );
[2129] Fix | Delete
}
[2130] Fix | Delete
insert_with_markers( $cache_path . '.htaccess', "INDEX", array( 'Options -Indexes' ) );
[2131] Fix | Delete
}
[2132] Fix | Delete
[2133] Fix | Delete
$directories = array( $cache_path, $cache_path . '/supercache/', $cache_path . '/blogs/', $blog_cache_dir, $blog_cache_dir . "/meta" );
[2134] Fix | Delete
foreach( $directories as $dir ) {
[2135] Fix | Delete
if ( false == is_dir( $dir ) )
[2136] Fix | Delete
@mkdir( $dir );
[2137] Fix | Delete
if ( is_dir( $dir ) && false == is_file( "$dir/index.html" ) ) {
[2138] Fix | Delete
$fp = @fopen( "$dir/index.html", 'w' );
[2139] Fix | Delete
if ( $fp )
[2140] Fix | Delete
fclose( $fp );
[2141] Fix | Delete
}
[2142] Fix | Delete
}
[2143] Fix | Delete
}
[2144] Fix | Delete
[2145] Fix | Delete
function wp_cache_add_site_cache_index() {
[2146] Fix | Delete
global $cache_path;
[2147] Fix | Delete
[2148] Fix | Delete
wp_cache_add_index_protection(); // root and supercache
[2149] Fix | Delete
[2150] Fix | Delete
if ( is_dir( $cache_path . "blogs" ) ) {
[2151] Fix | Delete
$dir = new DirectoryIterator( $cache_path . "blogs" );
[2152] Fix | Delete
foreach( $dir as $fileinfo ) {
[2153] Fix | Delete
if ( $fileinfo->isDot() ) {
[2154] Fix | Delete
continue;
[2155] Fix | Delete
}
[2156] Fix | Delete
if ( $fileinfo->isDir() ) {
[2157] Fix | Delete
$directory = $cache_path . "blogs/" . $fileinfo->getFilename();
[2158] Fix | Delete
if ( false == is_file( $directory . "/index.html" ) ) {
[2159] Fix | Delete
$fp = @fopen( $directory . "/index.html", 'w' );
[2160] Fix | Delete
if ( $fp )
[2161] Fix | Delete
fclose( $fp );
[2162] Fix | Delete
}
[2163] Fix | Delete
if ( is_dir( $directory . "/meta" ) ) {
[2164] Fix | Delete
if ( false == is_file( $directory . "/meta/index.html" ) ) {
[2165] Fix | Delete
$fp = @fopen( $directory . "/meta/index.html", 'w' );
[2166] Fix | Delete
if ( $fp )
[2167] Fix | Delete
fclose( $fp );
[2168] Fix | Delete
}
[2169] Fix | Delete
}
[2170] Fix | Delete
}
[2171] Fix | Delete
}
[2172] Fix | Delete
}
[2173] Fix | Delete
}
[2174] Fix | Delete
[2175] Fix | Delete
function wp_cache_verify_cache_dir() {
[2176] Fix | Delete
global $cache_path, $blog_cache_dir;
[2177] Fix | Delete
[2178] Fix | Delete
$dir = dirname($cache_path);
[2179] Fix | Delete
if ( !file_exists($cache_path) ) {
[2180] Fix | Delete
if ( !is_writeable_ACLSafe( $dir ) || !($dir = mkdir( $cache_path ) ) ) {
[2181] Fix | Delete
echo "<strong>" . __( 'Error', 'wp-super-cache' ) . ":</strong> " . sprintf( __( 'Your cache directory (<strong>%1$s</strong>) did not exist and couldn&#8217;t be created by the web server. Check %1$s permissions.', 'wp-super-cache' ), $dir );
[2182] Fix | Delete
return false;
[2183] Fix | Delete
}
[2184] Fix | Delete
}
[2185] Fix | Delete
if ( !is_writeable_ACLSafe($cache_path)) {
[2186] Fix | Delete
echo "<strong>" . __( 'Error', 'wp-super-cache' ) . ":</strong> " . sprintf( __( 'Your cache directory (<strong>%1$s</strong>) or <strong>%2$s</strong> need to be writable for this plugin to work. Double-check it.', 'wp-super-cache' ), $cache_path, $dir );
[2187] Fix | Delete
return false;
[2188] Fix | Delete
}
[2189] Fix | Delete
[2190] Fix | Delete
if ( '/' != substr($cache_path, -1)) {
[2191] Fix | Delete
$cache_path .= '/';
[2192] Fix | Delete
}
[2193] Fix | Delete
[2194] Fix | Delete
if( false == is_dir( $blog_cache_dir ) ) {
[2195] Fix | Delete
@mkdir( $cache_path . "blogs" );
[2196] Fix | Delete
if( $blog_cache_dir != $cache_path . "blogs/" )
[2197] Fix | Delete
@mkdir( $blog_cache_dir );
[2198] Fix | Delete
}
[2199] Fix | Delete
[2200] Fix | Delete
if( false == is_dir( $blog_cache_dir . 'meta' ) )
[2201] Fix | Delete
@mkdir( $blog_cache_dir . 'meta' );
[2202] Fix | Delete
[2203] Fix | Delete
wp_cache_add_index_protection();
[2204] Fix | Delete
return true;
[2205] Fix | Delete
}
[2206] Fix | Delete
[2207] Fix | Delete
function wp_cache_verify_config_file() {
[2208] Fix | Delete
global $wp_cache_config_file, $wp_cache_config_file_sample, $sem_id, $cache_path;
[2209] Fix | Delete
global $WPSC_HTTP_HOST;
[2210] Fix | Delete
[2211] Fix | Delete
$new = false;
[2212] Fix | Delete
$dir = dirname($wp_cache_config_file);
[2213] Fix | Delete
[2214] Fix | Delete
if ( file_exists($wp_cache_config_file) ) {
[2215] Fix | Delete
$lines = implode( ' ', file( $wp_cache_config_file ) );
[2216] Fix | Delete
if ( ! str_contains( $lines, 'WPCACHEHOME' ) ) {
[2217] Fix | Delete
if( is_writeable_ACLSafe( $wp_cache_config_file ) ) {
[2218] Fix | Delete
@unlink( $wp_cache_config_file );
[2219] Fix | Delete
} else {
[2220] Fix | Delete
echo "<strong>" . __( 'Error', 'wp-super-cache' ) . ":</strong> " . sprintf( __( 'Your WP-Cache config file (<strong>%s</strong>) 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 );
[2221] Fix | Delete
return false;
[2222] Fix | Delete
}
[2223] Fix | Delete
}
[2224] Fix | Delete
} elseif( !is_writeable_ACLSafe($dir)) {
[2225] Fix | Delete
echo "<strong>" . __( 'Error', 'wp-super-cache' ) . ":</strong> " . sprintf( __( 'Configuration file missing and %1$s directory (<strong>%2$s</strong>) is not writable by the web server. Check its permissions.', 'wp-super-cache' ), WP_CONTENT_DIR, $dir );
[2226] Fix | Delete
return false;
[2227] Fix | Delete
}
[2228] Fix | Delete
[2229] Fix | Delete
if ( !file_exists($wp_cache_config_file) ) {
[2230] Fix | Delete
if ( !file_exists($wp_cache_config_file_sample) ) {
[2231] Fix | Delete
echo "<strong>" . __( 'Error', 'wp-super-cache' ) . ":</strong> " . sprintf( __( 'Sample WP-Cache config file (<strong>%s</strong>) does not exist. Verify your installation.', 'wp-super-cache' ), $wp_cache_config_file_sample );
[2232] Fix | Delete
return false;
[2233] Fix | Delete
}
[2234] Fix | Delete
copy($wp_cache_config_file_sample, $wp_cache_config_file);
[2235] Fix | Delete
$dir = str_replace( str_replace( '\\', '/', WP_CONTENT_DIR ), '', str_replace( '\\', '/', __DIR__ ) );
[2236] Fix | Delete
if ( is_file( __DIR__ . '/wp-cache-config-sample.php' ) ) {
[2237] Fix | Delete
wp_cache_replace_line('define\(\ \'WPCACHEHOME', "\tdefine( 'WPCACHEHOME', WP_CONTENT_DIR . \"{$dir}/\" );", $wp_cache_config_file);
[2238] Fix | Delete
} elseif ( is_file( __DIR__ . '/wp-super-cache/wp-cache-config-sample.php' ) ) {
[2239] Fix | Delete
wp_cache_replace_line('define\(\ \'WPCACHEHOME', "\tdefine( 'WPCACHEHOME', WP_CONTENT_DIR . \"{$dir}/wp-super-cache/\" );", $wp_cache_config_file);
[2240] Fix | Delete
}
[2241] Fix | Delete
$new = true;
[2242] Fix | Delete
}
[2243] Fix | Delete
if ( $sem_id == 5419 && $cache_path != '' && $WPSC_HTTP_HOST != '' ) {
[2244] Fix | Delete
$sem_id = crc32( $WPSC_HTTP_HOST . $cache_path ) & 0x7fffffff;
[2245] Fix | Delete
wp_cache_replace_line('sem_id', '$sem_id = ' . $sem_id . ';', $wp_cache_config_file);
[2246] Fix | Delete
}
[2247] Fix | Delete
if ( $new ) {
[2248] Fix | Delete
require($wp_cache_config_file);
[2249] Fix | Delete
wpsc_set_default_gc( true );
[2250] Fix | Delete
}
[2251] Fix | Delete
return true;
[2252] Fix | Delete
}
[2253] Fix | Delete
[2254] Fix | Delete
function wp_cache_create_advanced_cache() {
[2255] Fix | Delete
global $wpsc_advanced_cache_filename, $wpsc_advanced_cache_dist_filename;
[2256] Fix | Delete
if ( file_exists( ABSPATH . 'wp-config.php') ) {
[2257] Fix | Delete
$global_config_file = ABSPATH . 'wp-config.php';
[2258] Fix | Delete
} elseif ( file_exists( dirname( ABSPATH ) . '/wp-config.php' ) ) {
[2259] Fix | Delete
$global_config_file = dirname( ABSPATH ) . '/wp-config.php';
[2260] Fix | Delete
} elseif ( defined( 'DEBIAN_FILE' ) && file_exists( DEBIAN_FILE ) ) {
[2261] Fix | Delete
$global_config_file = DEBIAN_FILE;
[2262] Fix | Delete
} else {
[2263] Fix | Delete
die('Cannot locate wp-config.php');
[2264] Fix | Delete
}
[2265] Fix | Delete
[2266] Fix | Delete
$line = 'define( \'WPCACHEHOME\', \'' . __DIR__ . '/\' );';
[2267] Fix | Delete
[2268] Fix | Delete
if ( ! apply_filters( 'wpsc_enable_wp_config_edit', true ) ) {
[2269] Fix | Delete
echo '<div class="notice notice-error"><h4>' . __( 'Warning', 'wp-super-cache' ) . "! " . sprintf( __( 'Not allowed to edit %s per configuration.', 'wp-super-cache' ), $global_config_file ) . "</h4></div>";
[2270] Fix | Delete
return false;
[2271] Fix | Delete
}
[2272] Fix | Delete
[2273] Fix | Delete
if (
[2274] Fix | Delete
! strpos( file_get_contents( $global_config_file ), "WPCACHEHOME" ) ||
[2275] Fix | Delete
(
[2276] Fix | Delete
defined( 'WPCACHEHOME' ) &&
[2277] Fix | Delete
(
[2278] Fix | Delete
constant( 'WPCACHEHOME' ) == '' ||
[2279] Fix | Delete
(
[2280] Fix | Delete
constant( 'WPCACHEHOME' ) != '' &&
[2281] Fix | Delete
! file_exists( constant( 'WPCACHEHOME' ) . '/wp-cache.php' )
[2282] Fix | Delete
)
[2283] Fix | Delete
)
[2284] Fix | Delete
)
[2285] Fix | Delete
) {
[2286] Fix | Delete
if (
[2287] Fix | Delete
! is_writeable_ACLSafe( $global_config_file ) ||
[2288] Fix | Delete
! wp_cache_replace_line( 'define *\( *\'WPCACHEHOME\'', $line, $global_config_file )
[2289] Fix | Delete
) {
[2290] Fix | Delete
echo '<div class="notice notice-error"><h4>' . __( 'Warning', 'wp-super-cache' ) . "! <em>" . sprintf( __( 'Could not update %s!</em> WPCACHEHOME must be set in config file.', 'wp-super-cache' ), $global_config_file ) . "</h4></div>";
[2291] Fix | Delete
return false;
[2292] Fix | Delete
}
[2293] Fix | Delete
}
[2294] Fix | Delete
$ret = true;
[2295] Fix | Delete
[2296] Fix | Delete
if ( file_exists( $wpsc_advanced_cache_filename ) ) {
[2297] Fix | Delete
$file = file_get_contents( $wpsc_advanced_cache_filename );
[2298] Fix | Delete
if (
[2299] Fix | Delete
! strpos( $file, "WP SUPER CACHE 0.8.9.1" ) &&
[2300] Fix | Delete
! strpos( $file, "WP SUPER CACHE 1.2" )
[2301] Fix | Delete
) {
[2302] Fix | Delete
return false;
[2303] Fix | Delete
}
[2304] Fix | Delete
}
[2305] Fix | Delete
[2306] Fix | Delete
$file = file_get_contents( $wpsc_advanced_cache_dist_filename );
[2307] Fix | Delete
$fp = @fopen( $wpsc_advanced_cache_filename, 'w' );
[2308] Fix | Delete
if( $fp ) {
[2309] Fix | Delete
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fwrite
[2310] Fix | Delete
fwrite( $fp, $file );
[2311] Fix | Delete
fclose( $fp );
[2312] Fix | Delete
do_action( 'wpsc_created_advanced_cache' );
[2313] Fix | Delete
} else {
[2314] Fix | Delete
$ret = false;
[2315] Fix | Delete
}
[2316] Fix | Delete
return $ret;
[2317] Fix | Delete
}
[2318] Fix | Delete
[2319] Fix | Delete
/**
[2320] Fix | Delete
* Identify the advanced cache plugin used
[2321] Fix | Delete
*
[2322] Fix | Delete
* @return string The name of the advanced cache plugin, BOOST, WPSC or OTHER.
[2323] Fix | Delete
*/
[2324] Fix | Delete
function wpsc_identify_advanced_cache() {
[2325] Fix | Delete
global $wpsc_advanced_cache_filename;
[2326] Fix | Delete
if ( ! file_exists( $wpsc_advanced_cache_filename ) ) {
[2327] Fix | Delete
return 'NONE';
[2328] Fix | Delete
}
[2329] Fix | Delete
$contents = file_get_contents( $wpsc_advanced_cache_filename ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
[2330] Fix | Delete
[2331] Fix | Delete
if ( false !== str_contains( $contents, 'Boost Cache Plugin' ) ) {
[2332] Fix | Delete
return 'BOOST';
[2333] Fix | Delete
}
[2334] Fix | Delete
[2335] Fix | Delete
if ( str_contains( $contents, 'WP SUPER CACHE 0.8.9.1' ) || str_contains( $contents, 'WP SUPER CACHE 1.2' ) ) {
[2336] Fix | Delete
return 'WPSC';
[2337] Fix | Delete
}
[2338] Fix | Delete
[2339] Fix | Delete
return 'OTHER';
[2340] Fix | Delete
}
[2341] Fix | Delete
[2342] Fix | Delete
function wpsc_check_advanced_cache() {
[2343] Fix | Delete
global $wpsc_advanced_cache_filename;
[2344] Fix | Delete
[2345] Fix | Delete
$ret = false;
[2346] Fix | Delete
$other_advanced_cache = false;
[2347] Fix | Delete
if ( file_exists( $wpsc_advanced_cache_filename ) ) {
[2348] Fix | Delete
$cache_type = wpsc_identify_advanced_cache();
[2349] Fix | Delete
switch ( $cache_type ) {
[2350] Fix | Delete
case 'WPSC':
[2351] Fix | Delete
return true;
[2352] Fix | Delete
case 'BOOST':
[2353] Fix | Delete
$other_advanced_cache = 'BOOST';
[2354] Fix | Delete
break;
[2355] Fix | Delete
default:
[2356] Fix | Delete
$other_advanced_cache = true;
[2357] Fix | Delete
break;
[2358] Fix | Delete
}
[2359] Fix | Delete
} else {
[2360] Fix | Delete
$ret = wp_cache_create_advanced_cache();
[2361] Fix | Delete
}
[2362] Fix | Delete
[2363] Fix | Delete
if ( false == $ret ) {
[2364] Fix | Delete
if ( $other_advanced_cache === 'BOOST' ) {
[2365] Fix | Delete
wpsc_deactivate_boost_cache_notice();
[2366] Fix | Delete
} elseif ( $other_advanced_cache ) {
[2367] Fix | Delete
echo '<div style="width: 50%" class="notice notice-error"><h2>' . __( 'Warning! You may not be allowed to use this plugin on your site.', 'wp-super-cache' ) . "</h2>";
[2368] Fix | Delete
echo '<p>' .
[2369] Fix | Delete
sprintf(
[2370] Fix | Delete
__( 'The file %s was created by another plugin or by your system administrator. Please examine the file carefully by FTP or SSH and consult your hosting documentation. ', 'wp-super-cache' ),
[2371] Fix | Delete
$wpsc_advanced_cache_filename
[2372] Fix | Delete
) .
[2373] Fix | Delete
'</p>';
[2374] Fix | Delete
echo '<p>' .
[2375] Fix | Delete
__( 'If it was created by another caching plugin please uninstall that plugin first before activating WP Super Cache. If the file is not removed by that action you should delete the file manually.', 'wp-super-cache' ),
[2376] Fix | Delete
'</p>';
[2377] Fix | Delete
echo '<p><strong>' .
[2378] Fix | Delete
__( 'If you need support for this problem contact your hosting provider.', 'wp-super-cache' ),
[2379] Fix | Delete
'</strong></p>';
[2380] Fix | Delete
echo '</div>';
[2381] Fix | Delete
} elseif ( ! is_writeable_ACLSafe( $wpsc_advanced_cache_filename ) ) {
[2382] Fix | Delete
echo '<div class="notice notice-error"><h2>' . __( 'Warning', 'wp-super-cache' ) . "! <em>" . sprintf( __( '%s/advanced-cache.php</em> cannot be updated.', 'wp-super-cache' ), WP_CONTENT_DIR ) . "</h2>";
[2383] Fix | Delete
echo '<ol>';
[2384] Fix | Delete
echo "<li>" .
[2385] Fix | Delete
sprintf(
[2386] Fix | Delete
__( 'Make %1$s writable using the chmod command through your ftp or server software. (<em>chmod 777 %1$s</em>) and refresh this page. This is only a temporary measure and you&#8217;ll have to make it read only afterwards again. (Change 777 to 755 in the previous command)', 'wp-super-cache' ),
[2387] Fix | Delete
WP_CONTENT_DIR
[2388] Fix | Delete
) .
[2389] Fix | Delete
"</li>";
[2390] Fix | Delete
echo "<li>" . sprintf( __( 'Refresh this page to update <em>%s/advanced-cache.php</em>', 'wp-super-cache' ), WP_CONTENT_DIR ) . "</li></ol>";
[2391] Fix | Delete
echo sprintf( __( 'If that doesn&#8217;t work, make sure the file <em>%s/advanced-cache.php</em> doesn&#8217;t exist:', 'wp-super-cache' ), WP_CONTENT_DIR ) . "<ol>";
[2392] Fix | Delete
echo "</ol>";
[2393] Fix | Delete
echo '</div>';
[2394] Fix | Delete
}
[2395] Fix | Delete
return false;
[2396] Fix | Delete
}
[2397] Fix | Delete
return true;
[2398] Fix | Delete
}
[2399] Fix | Delete
[2400] Fix | Delete
function wp_cache_check_global_config() {
[2401] Fix | Delete
global $wp_cache_check_wp_config;
[2402] Fix | Delete
[2403] Fix | Delete
if ( !isset( $wp_cache_check_wp_config ) )
[2404] Fix | Delete
return true;
[2405] Fix | Delete
[2406] Fix | Delete
[2407] Fix | Delete
if ( file_exists( ABSPATH . 'wp-config.php') ) {
[2408] Fix | Delete
$global_config_file = ABSPATH . 'wp-config.php';
[2409] Fix | Delete
} else {
[2410] Fix | Delete
$global_config_file = dirname( ABSPATH ) . '/wp-config.php';
[2411] Fix | Delete
}
[2412] Fix | Delete
[2413] Fix | Delete
if ( preg_match( '#^\s*(define\s*\(\s*[\'"]WP_CACHE[\'"]|const\s+WP_CACHE\s*=)#m', file_get_contents( $global_config_file ) ) === 1 ) { // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
[2414] Fix | Delete
if ( defined( 'WP_CACHE' ) && ! constant( 'WP_CACHE' ) ) {
[2415] Fix | Delete
?>
[2416] Fix | Delete
<div class="notice notice-error"><h4><?php esc_html_e( 'WP_CACHE constant set to false', 'wp-super-cache' ); ?></h4>
[2417] Fix | Delete
<p><?php esc_html_e( '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:', 'wp-super-cache' ); ?></p>
[2418] Fix | Delete
<p><code>define('WP_CACHE', true);</code></p></div>
[2419] Fix | Delete
<?php
[2420] Fix | Delete
return false;
[2421] Fix | Delete
} else {
[2422] Fix | Delete
return true;
[2423] Fix | Delete
}
[2424] Fix | Delete
}
[2425] Fix | Delete
[2426] Fix | Delete
$line = 'define(\'WP_CACHE\', true);';
[2427] Fix | Delete
if (
[2428] Fix | Delete
! is_writeable_ACLSafe( $global_config_file ) ||
[2429] Fix | Delete
! wp_cache_replace_line( 'define *\( *\'WP_CACHE\'', $line, $global_config_file )
[2430] Fix | Delete
) {
[2431] Fix | Delete
if ( defined( 'WP_CACHE' ) && constant( 'WP_CACHE' ) == false ) {
[2432] Fix | Delete
echo '<div class="notice notice-error">' . __( "<h4>WP_CACHE constant set to false</h4><p>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:<br /><br /><code>define('WP_CACHE', true);</code></p>", 'wp-super-cache' ) . "</div>";
[2433] Fix | Delete
} else {
[2434] Fix | Delete
echo '<div class="notice notice-error"><p>' . __( "<strong>Error: WP_CACHE is not enabled</strong> in your <code>wp-config.php</code> file and I couldn&#8217;t modify it.", 'wp-super-cache' ) . "</p>";
[2435] Fix | Delete
echo "<p>" . sprintf( __( "Edit <code>%s</code> and add the following line:<br /> <code>define('WP_CACHE', true);</code><br />Otherwise, <strong>WP-Cache will not be executed</strong> by WordPress core. ", 'wp-super-cache' ), $global_config_file ) . "</p></div>";
[2436] Fix | Delete
}
[2437] Fix | Delete
return false;
[2438] Fix | Delete
} else {
[2439] Fix | Delete
echo "<div class='notice notice-warning'>" . __( '<h4>WP_CACHE constant added to wp-config.php</h4><p>If you continue to see this warning message please see point 5 of the <a href="https://wordpress.org/plugins/wp-super-cache/faq/">Troubleshooting Guide</a>. The WP_CACHE line must be moved up.', 'wp-super-cache' ) . "</p></div>";
[2440] Fix | Delete
}
[2441] Fix | Delete
return true;
[2442] Fix | Delete
}
[2443] Fix | Delete
[2444] Fix | Delete
function wpsc_generate_sizes_array() {
[2445] Fix | Delete
$sizes = array();
[2446] Fix | Delete
$cache_types = apply_filters( 'wpsc_cache_types', array( 'supercache', 'wpcache' ) );
[2447] Fix | Delete
$cache_states = apply_filters( 'wpsc_cache_state', array( 'expired', 'cached' ) );
[2448] Fix | Delete
foreach( $cache_types as $type ) {
[2449] Fix | Delete
reset( $cache_states );
[2450] Fix | Delete
foreach( $cache_states as $state ) {
[2451] Fix | Delete
$sizes[ $type ][ $state ] = 0;
[2452] Fix | Delete
}
[2453] Fix | Delete
$sizes[ $type ][ 'fsize' ] = 0;
[2454] Fix | Delete
$sizes[ $type ][ 'cached_list' ] = array();
[2455] Fix | Delete
$sizes[ $type ][ 'expired_list' ] = array();
[2456] Fix | Delete
}
[2457] Fix | Delete
return $sizes;
[2458] Fix | Delete
}
[2459] Fix | Delete
[2460] Fix | Delete
function wp_cache_format_fsize( $fsize ) {
[2461] Fix | Delete
if ( $fsize > 1024 ) {
[2462] Fix | Delete
$fsize = number_format( $fsize / 1024, 2 ) . "MB";
[2463] Fix | Delete
} elseif ( $fsize != 0 ) {
[2464] Fix | Delete
$fsize = number_format( $fsize, 2 ) . "KB";
[2465] Fix | Delete
} else {
[2466] Fix | Delete
$fsize = "0KB";
[2467] Fix | Delete
}
[2468] Fix | Delete
return $fsize;
[2469] Fix | Delete
}
[2470] Fix | Delete
[2471] Fix | Delete
function wp_cache_regenerate_cache_file_stats() {
[2472] Fix | Delete
global $cache_compression, $supercachedir, $file_prefix, $wp_cache_preload_on, $cache_max_time;
[2473] Fix | Delete
[2474] Fix | Delete
if ( $supercachedir == '' )
[2475] Fix | Delete
$supercachedir = get_supercache_dir();
[2476] Fix | Delete
[2477] Fix | Delete
$sizes = wpsc_generate_sizes_array();
[2478] Fix | Delete
$now = time();
[2479] Fix | Delete
if (is_dir( $supercachedir ) ) {
[2480] Fix | Delete
if ( $dh = opendir( $supercachedir ) ) {
[2481] Fix | Delete
while ( ( $entry = readdir( $dh ) ) !== false ) {
[2482] Fix | Delete
if ( $entry != '.' && $entry != '..' ) {
[2483] Fix | Delete
$sizes = wpsc_dirsize( trailingslashit( $supercachedir ) . $entry, $sizes );
[2484] Fix | Delete
}
[2485] Fix | Delete
}
[2486] Fix | Delete
closedir( $dh );
[2487] Fix | Delete
}
[2488] Fix | Delete
}
[2489] Fix | Delete
foreach( $sizes as $cache_type => $list ) {
[2490] Fix | Delete
foreach( array( 'cached_list', 'expired_list' ) as $status ) {
[2491] Fix | Delete
$cached_list = array();
[2492] Fix | Delete
foreach( $list[ $status ] as $dir => $details ) {
[2493] Fix | Delete
if ( $details[ 'files' ] == 2 && !isset( $details[ 'upper_age' ] ) ) {
[2494] Fix | Delete
$details[ 'files' ] = 1;
[2495] Fix | Delete
}
[2496] Fix | Delete
$cached_list[ $dir ] = $details;
[2497] Fix | Delete
}
[2498] Fix | Delete
$sizes[ $cache_type ][ $status ] = $cached_list;
[2499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function