Version Description
Download this release
Release Info
Developer | donncha |
Plugin | WP Super Cache |
Version | 1.6.9 |
Comparing to | |
See all releases |
Code changes from version 1.6.8 to 1.6.9
- readme.txt +9 -2
- wp-cache-config-sample.php +1 -0
- wp-cache-phase2.php +29 -13
- wp-cache.php +49 -52
readme.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
* Contributors: donncha, automattic, kraftbj
|
3 |
* Tags: performance, caching, wp-cache, wp-super-cache, cache
|
4 |
* Tested up to: 5.2.2
|
5 |
-
* Stable tag: 1.6.
|
6 |
* Requires at least: 3.1
|
7 |
* Requires PHP: 5.2.4
|
8 |
* License: GPLv2 or later
|
@@ -266,6 +266,13 @@ Your theme is probably responsive which means it resizes the page to suit whatev
|
|
266 |
|
267 |
## Changelog ##
|
268 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
### 1.6.8 ###
|
270 |
* Added new constants, WPSC_SERVE_DISABLED (disable serving of cached files) and WPSC_SUPERCACHE_ONLY (only serve supercache cache files). #682 and #672
|
271 |
* Hide get_post() warning on some sites. #684
|
@@ -729,4 +736,4 @@ Your theme is probably responsive which means it resizes the page to suit whatev
|
|
729 |
|
730 |
|
731 |
## Upgrade Notice ##
|
732 |
-
|
2 |
* Contributors: donncha, automattic, kraftbj
|
3 |
* Tags: performance, caching, wp-cache, wp-super-cache, cache
|
4 |
* Tested up to: 5.2.2
|
5 |
+
* Stable tag: 1.6.9
|
6 |
* Requires at least: 3.1
|
7 |
* Requires PHP: 5.2.4
|
8 |
* License: GPLv2 or later
|
266 |
|
267 |
## Changelog ##
|
268 |
|
269 |
+
### 1.6.9 ###
|
270 |
+
* Improve the variables and messaging used by advanced-cache.php code. #687
|
271 |
+
* Add a warning message to the debug log viewer. #688
|
272 |
+
* Disable raw viewing of the debug log. #691
|
273 |
+
* Clean up the debug log. #692 #694
|
274 |
+
* Added wpsc_update_check() in 9659af156344a77ae247dc582d52053d95c79b93.
|
275 |
+
|
276 |
### 1.6.8 ###
|
277 |
* Added new constants, WPSC_SERVE_DISABLED (disable serving of cached files) and WPSC_SUPERCACHE_ONLY (only serve supercache cache files). #682 and #672
|
278 |
* Hide get_post() warning on some sites. #684
|
736 |
|
737 |
|
738 |
## Upgrade Notice ##
|
739 |
+
Fix security issue with debug log.
|
wp-cache-config-sample.php
CHANGED
@@ -101,4 +101,5 @@ $cache_gc_email_me = 0;
|
|
101 |
$wpsc_save_headers = 0;
|
102 |
$cache_schedule_interval = 'daily';
|
103 |
$wp_super_cache_comments = 1;
|
|
|
104 |
?>
|
101 |
$wpsc_save_headers = 0;
|
102 |
$cache_schedule_interval = 'daily';
|
103 |
$wp_super_cache_comments = 1;
|
104 |
+
$wpsc_version = 169;
|
105 |
?>
|
wp-cache-phase2.php
CHANGED
@@ -214,7 +214,7 @@ function wp_cache_serve_cache_file() {
|
|
214 |
} else {
|
215 |
$ungzip = false;
|
216 |
}
|
217 |
-
foreach ( $meta['headers'] as $t => $header
|
218 |
// 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/
|
219 |
if ( strpos( $header, 'Last-Modified:' ) === false ) {
|
220 |
header( $header );
|
@@ -391,7 +391,7 @@ function wp_cache_get_cookies_values() {
|
|
391 |
$regex .= "/";
|
392 |
while ($key = key($_COOKIE)) {
|
393 |
if ( preg_match( $regex, $key ) ) {
|
394 |
-
wp_cache_debug( "wp_cache_get_cookies_values:
|
395 |
$string .= $_COOKIE[ $key ] . ",";
|
396 |
}
|
397 |
next($_COOKIE);
|
@@ -488,7 +488,7 @@ function wp_cache_check_mobile( $cache_key ) {
|
|
488 |
$user_agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
|
489 |
foreach ($browsers as $browser) {
|
490 |
if ( strstr( $user_agent, trim( strtolower( $browser ) ) ) ) {
|
491 |
-
wp_cache_debug( 'mobile browser detected: ' . $
|
492 |
return $cache_key . '-' . wp_cache_mobile_group( $user_agent );
|
493 |
}
|
494 |
}
|
@@ -501,7 +501,7 @@ function wp_cache_check_mobile( $cache_key ) {
|
|
501 |
$browsers = explode( ',', $wp_cache_mobile_prefixes );
|
502 |
foreach ($browsers as $browser_prefix) {
|
503 |
if ( substr($user_agent, 0, 4) == $browser_prefix ) {
|
504 |
-
wp_cache_debug( 'mobile browser (prefix) detected: ' . $
|
505 |
return $cache_key . '-' . $browser_prefix;
|
506 |
}
|
507 |
}
|
@@ -526,6 +526,12 @@ function wp_cache_check_mobile( $cache_key ) {
|
|
526 |
*/
|
527 |
function wp_cache_debug( $message, $level = 1 ) {
|
528 |
global $wp_cache_debug_log, $cache_path, $wp_cache_debug_ip, $wp_super_cache_debug;
|
|
|
|
|
|
|
|
|
|
|
|
|
529 |
|
530 |
// If either of the debug or log globals aren't set, then we can stop
|
531 |
if ( !isset($wp_super_cache_debug)
|
@@ -1014,13 +1020,7 @@ function wpsc_create_debug_log( $filename = '', $username = '' ) {
|
|
1014 |
$wp_cache_debug_username = wpsc_debug_username();
|
1015 |
}
|
1016 |
|
1017 |
-
$msg = '
|
1018 |
-
if ( !isset( $_SERVER[ "PHP_AUTH_USER" ] ) || ( $_SERVER[ "PHP_AUTH_USER" ] != "' . $wp_cache_debug_username . '" && $_SERVER[ "PHP_AUTH_PW" ] != "' . $wp_cache_debug_username . '" ) ) {
|
1019 |
-
header( "WWW-Authenticate: Basic realm=\"WP-Super-Cache Debug Log\"" );
|
1020 |
-
header( $_SERVER[ "SERVER_PROTOCOL" ] . " 401 Unauthorized" );
|
1021 |
-
echo "You must login to view the debug log";
|
1022 |
-
exit;
|
1023 |
-
}' . PHP_EOL;
|
1024 |
$fp = fopen( $cache_path . $wp_cache_debug_log, 'w' );
|
1025 |
if ( $fp ) {
|
1026 |
fwrite( $fp, '<' . "?php\n" );
|
@@ -1031,6 +1031,15 @@ if ( !isset( $_SERVER[ "PHP_AUTH_USER" ] ) || ( $_SERVER[ "PHP_AUTH_USER" ] != "
|
|
1031 |
wp_cache_setting( 'wp_cache_debug_log', $wp_cache_debug_log );
|
1032 |
wp_cache_setting( 'wp_cache_debug_username', $wp_cache_debug_username );
|
1033 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1034 |
$fp = fopen( $cache_path . 'view_' . $wp_cache_debug_log, 'w' );
|
1035 |
if ( $fp ) {
|
1036 |
fwrite( $fp, '<' . "?php" . PHP_EOL );
|
@@ -1058,6 +1067,10 @@ if ( isset( $_GET[ "filter" ] ) ) {
|
|
1058 |
|
1059 |
unset( $checks[1] ); // exclude_filter
|
1060 |
?' . '>
|
|
|
|
|
|
|
|
|
1061 |
Exclude requests: <br />
|
1062 |
<' . '?php foreach ( $checks as $check ) { ?>
|
1063 |
<label><input type="checkbox" name="<' . '?php echo $check; ?' . '>" value="1" <' . '?php if ( $$check ) { echo "checked"; } ?' . '> /> <' . '?php echo $check; ?' . '></label><br />
|
@@ -1070,7 +1083,10 @@ Text to filter by:
|
|
1070 |
<input type="submit" value="Submit" />
|
1071 |
</form>
|
1072 |
<' . '?php
|
|
|
1073 |
foreach ( $debug_log as $t => $line ) {
|
|
|
|
|
1074 |
foreach( $checks as $check ) {
|
1075 |
if ( $$check && false !== strpos( $line, " /$check/" ) ) {
|
1076 |
unset( $debug_log[ $t ] );
|
@@ -1085,7 +1101,7 @@ foreach ( $debug_log as $t => $line ) {
|
|
1085 |
}
|
1086 |
}
|
1087 |
foreach( $debug_log as $line ) {
|
1088 |
-
echo $line . "<br />";
|
1089 |
}';
|
1090 |
fwrite( $fp, $msg );
|
1091 |
fclose( $fp );
|
@@ -1200,7 +1216,7 @@ function wp_cache_replace_line( $old, $new, $my_file ) {
|
|
1200 |
}
|
1201 |
|
1202 |
$tmp_config_filename = tempnam( $GLOBALS['cache_path'], 'wpsc' );
|
1203 |
-
rename( $tmp_config_filename, $tmp_config_filename. ".php" );
|
1204 |
$tmp_config_filename .= ".php";
|
1205 |
wp_cache_debug( 'wp_cache_replace_line: writing to ' . $tmp_config_filename );
|
1206 |
$fd = fopen( $tmp_config_filename, 'w' );
|
214 |
} else {
|
215 |
$ungzip = false;
|
216 |
}
|
217 |
+
foreach ( $meta[ 'headers' ] as $t => $header) {
|
218 |
// 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/
|
219 |
if ( strpos( $header, 'Last-Modified:' ) === false ) {
|
220 |
header( $header );
|
391 |
$regex .= "/";
|
392 |
while ($key = key($_COOKIE)) {
|
393 |
if ( preg_match( $regex, $key ) ) {
|
394 |
+
wp_cache_debug( "wp_cache_get_cookies_values: Login/postpass cookie detected" );
|
395 |
$string .= $_COOKIE[ $key ] . ",";
|
396 |
}
|
397 |
next($_COOKIE);
|
488 |
$user_agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
|
489 |
foreach ($browsers as $browser) {
|
490 |
if ( strstr( $user_agent, trim( strtolower( $browser ) ) ) ) {
|
491 |
+
wp_cache_debug( 'mobile browser detected: ' . $browser );
|
492 |
return $cache_key . '-' . wp_cache_mobile_group( $user_agent );
|
493 |
}
|
494 |
}
|
501 |
$browsers = explode( ',', $wp_cache_mobile_prefixes );
|
502 |
foreach ($browsers as $browser_prefix) {
|
503 |
if ( substr($user_agent, 0, 4) == $browser_prefix ) {
|
504 |
+
wp_cache_debug( 'mobile browser (prefix) detected: ' . $browser_prefix );
|
505 |
return $cache_key . '-' . $browser_prefix;
|
506 |
}
|
507 |
}
|
526 |
*/
|
527 |
function wp_cache_debug( $message, $level = 1 ) {
|
528 |
global $wp_cache_debug_log, $cache_path, $wp_cache_debug_ip, $wp_super_cache_debug;
|
529 |
+
static $last_message = '';
|
530 |
+
|
531 |
+
if ( $last_message == $message ) {
|
532 |
+
return false;
|
533 |
+
}
|
534 |
+
$last_message = $message;
|
535 |
|
536 |
// If either of the debug or log globals aren't set, then we can stop
|
537 |
if ( !isset($wp_super_cache_debug)
|
1020 |
$wp_cache_debug_username = wpsc_debug_username();
|
1021 |
}
|
1022 |
|
1023 |
+
$msg = 'die( "Please use the viewer" );' . PHP_EOL;
|
|
|
|
|
|
|
|
|
|
|
|
|
1024 |
$fp = fopen( $cache_path . $wp_cache_debug_log, 'w' );
|
1025 |
if ( $fp ) {
|
1026 |
fwrite( $fp, '<' . "?php\n" );
|
1031 |
wp_cache_setting( 'wp_cache_debug_log', $wp_cache_debug_log );
|
1032 |
wp_cache_setting( 'wp_cache_debug_username', $wp_cache_debug_username );
|
1033 |
}
|
1034 |
+
|
1035 |
+
$msg = '
|
1036 |
+
if ( !isset( $_SERVER[ "PHP_AUTH_USER" ] ) || ( $_SERVER[ "PHP_AUTH_USER" ] != "' . $wp_cache_debug_username . '" && $_SERVER[ "PHP_AUTH_PW" ] != "' . $wp_cache_debug_username . '" ) ) {
|
1037 |
+
header( "WWW-Authenticate: Basic realm=\"WP-Super-Cache Debug Log\"" );
|
1038 |
+
header( $_SERVER[ "SERVER_PROTOCOL" ] . " 401 Unauthorized" );
|
1039 |
+
echo "You must login to view the debug log";
|
1040 |
+
exit;
|
1041 |
+
}' . PHP_EOL;
|
1042 |
+
|
1043 |
$fp = fopen( $cache_path . 'view_' . $wp_cache_debug_log, 'w' );
|
1044 |
if ( $fp ) {
|
1045 |
fwrite( $fp, '<' . "?php" . PHP_EOL );
|
1067 |
|
1068 |
unset( $checks[1] ); // exclude_filter
|
1069 |
?' . '>
|
1070 |
+
<h2>WP Super Cache Log Viewer</h2>
|
1071 |
+
<h3>Warning! Do not copy and paste this log file to a public website!</h3>
|
1072 |
+
<p>This log file contains sensitive information about your website such as cookies and directories.</p>
|
1073 |
+
<p>If you must share it please remove any cookies and remove any directories such as ' . ABSPATH . '.</p>
|
1074 |
Exclude requests: <br />
|
1075 |
<' . '?php foreach ( $checks as $check ) { ?>
|
1076 |
<label><input type="checkbox" name="<' . '?php echo $check; ?' . '>" value="1" <' . '?php if ( $$check ) { echo "checked"; } ?' . '> /> <' . '?php echo $check; ?' . '></label><br />
|
1083 |
<input type="submit" value="Submit" />
|
1084 |
</form>
|
1085 |
<' . '?php
|
1086 |
+
$path_to_site = "' . ABSPATH . '";
|
1087 |
foreach ( $debug_log as $t => $line ) {
|
1088 |
+
$line = str_replace( $path_to_site, "ABSPATH/", $line );
|
1089 |
+
$debug_log[ $t ] = $line;
|
1090 |
foreach( $checks as $check ) {
|
1091 |
if ( $$check && false !== strpos( $line, " /$check/" ) ) {
|
1092 |
unset( $debug_log[ $t ] );
|
1101 |
}
|
1102 |
}
|
1103 |
foreach( $debug_log as $line ) {
|
1104 |
+
echo htmlspecialchars( $line ) . "<br />";
|
1105 |
}';
|
1106 |
fwrite( $fp, $msg );
|
1107 |
fclose( $fp );
|
1216 |
}
|
1217 |
|
1218 |
$tmp_config_filename = tempnam( $GLOBALS['cache_path'], 'wpsc' );
|
1219 |
+
rename( $tmp_config_filename, $tmp_config_filename . ".php" );
|
1220 |
$tmp_config_filename .= ".php";
|
1221 |
wp_cache_debug( 'wp_cache_replace_line: writing to ' . $tmp_config_filename );
|
1222 |
$fd = fopen( $tmp_config_filename, 'w' );
|
wp-cache.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: WP Super Cache
|
4 |
Plugin URI: https://wordpress.org/plugins/wp-super-cache/
|
5 |
Description: Very fast caching plugin for WordPress.
|
6 |
-
Version: 1.6.
|
7 |
Author: Automattic
|
8 |
Author URI: https://automattic.com/
|
9 |
License: GPL2+
|
@@ -41,25 +41,25 @@ if ( ! defined( 'PHP_VERSION_ID' ) ) {
|
|
41 |
}
|
42 |
|
43 |
function wpsc_init() {
|
44 |
-
global $wp_cache_config_file, $wp_cache_config_file_sample, $
|
45 |
|
46 |
$wp_cache_config_file = WP_CONTENT_DIR . '/wp-cache-config.php';
|
47 |
|
48 |
if ( !defined( 'WPCACHEHOME' ) ) {
|
49 |
define( 'WPCACHEHOME', dirname( __FILE__ ) . '/' );
|
50 |
$wp_cache_config_file_sample = WPCACHEHOME . 'wp-cache-config-sample.php';
|
51 |
-
$
|
52 |
} elseif ( realpath( WPCACHEHOME ) != realpath( dirname( __FILE__ ) ) ) {
|
53 |
$wp_cache_config_file_sample = dirname( __FILE__ ) . '/wp-cache-config-sample.php';
|
54 |
-
$
|
55 |
if ( ! defined( 'ADVANCEDCACHEPROBLEM' ) ) {
|
56 |
define( 'ADVANCEDCACHEPROBLEM', 1 ); // force an update of WPCACHEHOME
|
57 |
}
|
58 |
} else {
|
59 |
$wp_cache_config_file_sample = WPCACHEHOME . 'wp-cache-config-sample.php';
|
60 |
-
$
|
61 |
}
|
62 |
-
$
|
63 |
|
64 |
if ( !defined( 'WP_CACHE' ) || ( defined( 'WP_CACHE' ) && constant( 'WP_CACHE' ) == false ) ) {
|
65 |
$wp_cache_check_wp_config = true;
|
@@ -102,10 +102,6 @@ function wp_super_cache_init_action() {
|
|
102 |
load_plugin_textdomain( 'wp-super-cache', false, basename( dirname( __FILE__ ) ) . '/languages' );
|
103 |
|
104 |
wpsc_register_post_hooks();
|
105 |
-
|
106 |
-
if ( is_admin() ) {
|
107 |
-
wpsc_fix_164();
|
108 |
-
}
|
109 |
}
|
110 |
add_action( 'init', 'wp_super_cache_init_action' );
|
111 |
|
@@ -138,14 +134,14 @@ function get_wpcachehome() {
|
|
138 |
}
|
139 |
|
140 |
function wpsc_remove_advanced_cache() {
|
141 |
-
global $
|
142 |
-
if ( file_exists( $
|
143 |
-
$file = file_get_contents( $
|
144 |
if (
|
145 |
strpos( $file, "WP SUPER CACHE 0.8.9.1" ) ||
|
146 |
strpos( $file, "WP SUPER CACHE 1.2" )
|
147 |
) {
|
148 |
-
unlink( $
|
149 |
}
|
150 |
}
|
151 |
}
|
@@ -178,7 +174,7 @@ if ( is_admin() ) {
|
|
178 |
}
|
179 |
|
180 |
function wpsupercache_deactivate() {
|
181 |
-
global $wp_cache_config_file, $
|
182 |
|
183 |
wpsc_remove_advanced_cache();
|
184 |
|
@@ -206,9 +202,11 @@ function wpsupercache_activate() {
|
|
206 |
ob_start();
|
207 |
wpsc_init();
|
208 |
|
209 |
-
if (
|
210 |
-
!
|
211 |
-
!
|
|
|
|
|
212 |
$text = ob_get_contents();
|
213 |
ob_end_clean();
|
214 |
return false;
|
@@ -312,9 +310,11 @@ function wp_cache_manager_error_checks() {
|
|
312 |
}
|
313 |
}
|
314 |
|
315 |
-
if (
|
316 |
-
!
|
317 |
-
!
|
|
|
|
|
318 |
echo '<p>' . __( "Cannot continue... fix previous problems and retry.", 'wp-super-cache' ) . '</p>';
|
319 |
return false;
|
320 |
}
|
@@ -2126,12 +2126,13 @@ function wp_cache_debug_settings() {
|
|
2126 |
if ( ! isset( $wp_cache_debug_log ) || $wp_cache_debug_log == '' ) {
|
2127 |
extract( wpsc_create_debug_log() ); // $wp_cache_debug_log, $wp_cache_debug_username
|
2128 |
}
|
2129 |
-
|
2130 |
-
$
|
|
|
2131 |
if ( $wp_super_cache_debug == 1 ) {
|
2132 |
-
echo "<p>" . sprintf( __( 'Currently logging to: %s
|
2133 |
} else {
|
2134 |
-
echo "<p>" . sprintf( __( 'Last Logged to: %s
|
2135 |
}
|
2136 |
echo "<p>" . sprintf( __( 'Username/Password: %s', 'wp-super-cache' ), $wp_cache_debug_username ) . "</p>";
|
2137 |
|
@@ -2564,7 +2565,7 @@ function wp_cache_verify_config_file() {
|
|
2564 |
}
|
2565 |
|
2566 |
function wp_cache_create_advanced_cache() {
|
2567 |
-
global $
|
2568 |
if ( file_exists( ABSPATH . 'wp-config.php') ) {
|
2569 |
$global_config_file = ABSPATH . 'wp-config.php';
|
2570 |
} else {
|
@@ -2601,18 +2602,18 @@ function wp_cache_create_advanced_cache() {
|
|
2601 |
}
|
2602 |
$ret = true;
|
2603 |
|
2604 |
-
if ( file_exists( $
|
2605 |
-
$file = file_get_contents( $
|
2606 |
if (
|
2607 |
! strpos( $file, "WP SUPER CACHE 0.8.9.1" ) &&
|
2608 |
! strpos( $file, "WP SUPER CACHE 1.2" )
|
2609 |
) {
|
2610 |
-
wp_die( '<div class="notice notice-error"><h4>' . __( 'Warning!', 'wp-super-cache' ) . "</h4><p>" . sprintf( __( 'The file %s already exists. Please manually delete it before using this plugin.', 'wp-super-cache' ), $
|
2611 |
}
|
2612 |
}
|
2613 |
|
2614 |
-
$file = file_get_contents( $
|
2615 |
-
$fp = @fopen( $
|
2616 |
if( $fp ) {
|
2617 |
fputs( $fp, $file );
|
2618 |
fclose( $fp );
|
@@ -2622,12 +2623,12 @@ function wp_cache_create_advanced_cache() {
|
|
2622 |
return $ret;
|
2623 |
}
|
2624 |
|
2625 |
-
function
|
2626 |
-
global $
|
2627 |
|
2628 |
$ret = true;
|
2629 |
-
if( file_exists($
|
2630 |
-
$file = file_get_contents( $
|
2631 |
if( strpos( $file, "WP SUPER CACHE 0.8.9.1" ) || strpos( $file, "WP SUPER CACHE 1.2" ) ) {
|
2632 |
return true;
|
2633 |
} else {
|
@@ -4284,25 +4285,21 @@ function wpsc_get_extra_cookies() {
|
|
4284 |
}
|
4285 |
}
|
4286 |
|
4287 |
-
|
4288 |
-
|
4289 |
-
*/
|
4290 |
-
function wpsc_fix_164() {
|
4291 |
-
global $wpsc_fix_164;
|
4292 |
-
|
4293 |
-
if (
|
4294 |
-
isset( $wpsc_fix_164 ) &&
|
4295 |
-
$wpsc_fix_164
|
4296 |
-
) {
|
4297 |
-
return false;
|
4298 |
-
}
|
4299 |
|
4300 |
if (
|
4301 |
-
|
4302 |
-
|
4303 |
) {
|
4304 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4305 |
}
|
4306 |
-
|
4307 |
-
wp_cache_setting( 'wpsc_fix_164', 1 );
|
4308 |
}
|
|
3 |
Plugin Name: WP Super Cache
|
4 |
Plugin URI: https://wordpress.org/plugins/wp-super-cache/
|
5 |
Description: Very fast caching plugin for WordPress.
|
6 |
+
Version: 1.6.9
|
7 |
Author: Automattic
|
8 |
Author URI: https://automattic.com/
|
9 |
License: GPL2+
|
41 |
}
|
42 |
|
43 |
function wpsc_init() {
|
44 |
+
global $wp_cache_config_file, $wp_cache_config_file_sample, $wpsc_advanced_cache_dist_filename, $wp_cache_check_wp_config, $wpsc_advanced_cache_filename;
|
45 |
|
46 |
$wp_cache_config_file = WP_CONTENT_DIR . '/wp-cache-config.php';
|
47 |
|
48 |
if ( !defined( 'WPCACHEHOME' ) ) {
|
49 |
define( 'WPCACHEHOME', dirname( __FILE__ ) . '/' );
|
50 |
$wp_cache_config_file_sample = WPCACHEHOME . 'wp-cache-config-sample.php';
|
51 |
+
$wpsc_advanced_cache_dist_filename = WPCACHEHOME . 'advanced-cache.php';
|
52 |
} elseif ( realpath( WPCACHEHOME ) != realpath( dirname( __FILE__ ) ) ) {
|
53 |
$wp_cache_config_file_sample = dirname( __FILE__ ) . '/wp-cache-config-sample.php';
|
54 |
+
$wpsc_advanced_cache_dist_filename = dirname( __FILE__ ) . '/advanced-cache.php';
|
55 |
if ( ! defined( 'ADVANCEDCACHEPROBLEM' ) ) {
|
56 |
define( 'ADVANCEDCACHEPROBLEM', 1 ); // force an update of WPCACHEHOME
|
57 |
}
|
58 |
} else {
|
59 |
$wp_cache_config_file_sample = WPCACHEHOME . 'wp-cache-config-sample.php';
|
60 |
+
$wpsc_advanced_cache_dist_filename = WPCACHEHOME . 'advanced-cache.php';
|
61 |
}
|
62 |
+
$wpsc_advanced_cache_filename = WP_CONTENT_DIR . '/advanced-cache.php';
|
63 |
|
64 |
if ( !defined( 'WP_CACHE' ) || ( defined( 'WP_CACHE' ) && constant( 'WP_CACHE' ) == false ) ) {
|
65 |
$wp_cache_check_wp_config = true;
|
102 |
load_plugin_textdomain( 'wp-super-cache', false, basename( dirname( __FILE__ ) ) . '/languages' );
|
103 |
|
104 |
wpsc_register_post_hooks();
|
|
|
|
|
|
|
|
|
105 |
}
|
106 |
add_action( 'init', 'wp_super_cache_init_action' );
|
107 |
|
134 |
}
|
135 |
|
136 |
function wpsc_remove_advanced_cache() {
|
137 |
+
global $wpsc_advanced_cache_filename;
|
138 |
+
if ( file_exists( $wpsc_advanced_cache_filename ) ) {
|
139 |
+
$file = file_get_contents( $wpsc_advanced_cache_filename );
|
140 |
if (
|
141 |
strpos( $file, "WP SUPER CACHE 0.8.9.1" ) ||
|
142 |
strpos( $file, "WP SUPER CACHE 1.2" )
|
143 |
) {
|
144 |
+
unlink( $wpsc_advanced_cache_filename );
|
145 |
}
|
146 |
}
|
147 |
}
|
174 |
}
|
175 |
|
176 |
function wpsupercache_deactivate() {
|
177 |
+
global $wp_cache_config_file, $wpsc_advanced_cache_filename, $cache_path;
|
178 |
|
179 |
wpsc_remove_advanced_cache();
|
180 |
|
202 |
ob_start();
|
203 |
wpsc_init();
|
204 |
|
205 |
+
if (
|
206 |
+
! wpsc_check_advanced_cache() ||
|
207 |
+
! wp_cache_verify_config_file() ||
|
208 |
+
! wp_cache_verify_cache_dir()
|
209 |
+
) {
|
210 |
$text = ob_get_contents();
|
211 |
ob_end_clean();
|
212 |
return false;
|
310 |
}
|
311 |
}
|
312 |
|
313 |
+
if (
|
314 |
+
! wpsc_check_advanced_cache() ||
|
315 |
+
! wp_cache_verify_config_file() ||
|
316 |
+
! wp_cache_verify_cache_dir()
|
317 |
+
) {
|
318 |
echo '<p>' . __( "Cannot continue... fix previous problems and retry.", 'wp-super-cache' ) . '</p>';
|
319 |
return false;
|
320 |
}
|
2126 |
if ( ! isset( $wp_cache_debug_log ) || $wp_cache_debug_log == '' ) {
|
2127 |
extract( wpsc_create_debug_log() ); // $wp_cache_debug_log, $wp_cache_debug_username
|
2128 |
}
|
2129 |
+
|
2130 |
+
$log_file_link = "<a href='" . site_url( str_replace( ABSPATH, '', "{$cache_path}view_{$wp_cache_debug_log}?wp-admin=1&wp-json=1&filter=" ) ) . "'>$wp_cache_debug_log</a>";
|
2131 |
+
|
2132 |
if ( $wp_super_cache_debug == 1 ) {
|
2133 |
+
echo "<p>" . sprintf( __( 'Currently logging to: %s', 'wp-super-cache' ), $log_file_link ) . "</p>";
|
2134 |
} else {
|
2135 |
+
echo "<p>" . sprintf( __( 'Last Logged to: %s', 'wp-super-cache' ), $log_file_link ) . "</p>";
|
2136 |
}
|
2137 |
echo "<p>" . sprintf( __( 'Username/Password: %s', 'wp-super-cache' ), $wp_cache_debug_username ) . "</p>";
|
2138 |
|
2565 |
}
|
2566 |
|
2567 |
function wp_cache_create_advanced_cache() {
|
2568 |
+
global $wpsc_advanced_cache_filename, $wpsc_advanced_cache_dist_filename;
|
2569 |
if ( file_exists( ABSPATH . 'wp-config.php') ) {
|
2570 |
$global_config_file = ABSPATH . 'wp-config.php';
|
2571 |
} else {
|
2602 |
}
|
2603 |
$ret = true;
|
2604 |
|
2605 |
+
if ( file_exists( $wpsc_advanced_cache_filename ) ) {
|
2606 |
+
$file = file_get_contents( $wpsc_advanced_cache_filename );
|
2607 |
if (
|
2608 |
! strpos( $file, "WP SUPER CACHE 0.8.9.1" ) &&
|
2609 |
! strpos( $file, "WP SUPER CACHE 1.2" )
|
2610 |
) {
|
2611 |
+
wp_die( '<div class="notice notice-error"><h4>' . __( 'Warning!', 'wp-super-cache' ) . "</h4><p>" . sprintf( __( 'The file %s already exists. Please manually delete it before using this plugin. If you continue to see this message after deleting it please contact your hosting support.', 'wp-super-cache' ), $wpsc_advanced_cache_filename ) . "</p></div>" );
|
2612 |
}
|
2613 |
}
|
2614 |
|
2615 |
+
$file = file_get_contents( $wpsc_advanced_cache_dist_filename );
|
2616 |
+
$fp = @fopen( $wpsc_advanced_cache_filename, 'w' );
|
2617 |
if( $fp ) {
|
2618 |
fputs( $fp, $file );
|
2619 |
fclose( $fp );
|
2623 |
return $ret;
|
2624 |
}
|
2625 |
|
2626 |
+
function wpsc_check_advanced_cache() {
|
2627 |
+
global $wpsc_advanced_cache_filename;
|
2628 |
|
2629 |
$ret = true;
|
2630 |
+
if ( file_exists( $wpsc_advanced_cache_filename ) ) {
|
2631 |
+
$file = file_get_contents( $wpsc_advanced_cache_filename );
|
2632 |
if( strpos( $file, "WP SUPER CACHE 0.8.9.1" ) || strpos( $file, "WP SUPER CACHE 1.2" ) ) {
|
2633 |
return true;
|
2634 |
} else {
|
4285 |
}
|
4286 |
}
|
4287 |
|
4288 |
+
function wpsc_update_check() {
|
4289 |
+
global $wpsc_version;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4290 |
|
4291 |
if (
|
4292 |
+
! isset( $wpsc_version ) ||
|
4293 |
+
$wpsc_version != 169
|
4294 |
) {
|
4295 |
+
wp_cache_setting( 'wpsc_version', 169 );
|
4296 |
+
global $wp_cache_debug_log, $cache_path;
|
4297 |
+
$log_file = $cache_path . str_replace('/', '', str_replace('..', '', $wp_cache_debug_log));
|
4298 |
+
if ( ! file_exists( $log_file ) ) {
|
4299 |
+
return false;
|
4300 |
+
}
|
4301 |
+
@unlink( $log_file );
|
4302 |
+
wp_cache_debug( 'wpsc_update_check: Deleted old log file on plugin update.' );
|
4303 |
}
|
|
|
|
|
4304 |
}
|
4305 |
+
add_action( 'admin_init', 'wpsc_update_check' );
|