WP Super Cache - Version 0.6.6

Version Description

Download this release

Release Info

Developer donncha
Plugin Icon 128x128 WP Super Cache
Version 0.6.6
Comparing to
See all releases

Code changes from version 0.6.5 to 0.6.6

Changelog.txt CHANGED
@@ -1,3 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  2008-07-15 10:15 donncha
2
 
3
  * readme.txt, wp-cache.php: Bump the version number to 0.6.5
1
+ 2008-07-31 10:47 donncha
2
+
3
+ * readme.txt, wp-cache.php: Bump version numbers
4
+
5
+ 2008-07-29 19:52 donncha
6
+
7
+ * wp-cache-config-sample.php, wp-cache-phase1.php, wp-cache.php: WP
8
+ 2.6 fixes. Use WP_CONTENT_DIR. Have not added to .htaccess rules
9
+ yet
10
+
11
+ 2008-07-28 09:37 donncha
12
+
13
+ * readme.txt, wp-cache.php: Change wp-super-cache expiry to 3600
14
+ seconds.
15
+ Avoid foreach error on empty directories
16
+ Minor change to status message
17
+
18
+ 2008-07-24 16:26 donncha
19
+
20
+ * wp-cache-phase2.php, wp-cache.php: Removed debug error log
21
+ Catch 404 file not found requests when themes use query_posts()
22
+
23
+ 2008-07-24 13:17 donncha
24
+
25
+ * wp-cache-phase2.php: If we can't get a file lock, warn user.
26
+
27
+ 2008-07-23 18:30 donncha
28
+
29
+ * readme.txt: Update FAQ on cache times.
30
+
31
+ 2008-07-23 18:27 donncha
32
+
33
+ * readme.txt, wp-cache.php: Added p= parameter to htacess rules so
34
+ they'll be served by wp-cache only,
35
+ http://wordpress.org/support/topic/191275?replies=3
36
+
37
+ 2008-07-17 09:48 donncha
38
+
39
+ * wp-cache.php: Handle if wp-config.php has been moved ../ in
40
+ WordPress 2.6
41
+
42
+ 2008-07-16 11:12 donncha
43
+
44
+ * wp-cache.php: Don't warn the user wp-content is writable if
45
+ webserver is running as user.
46
+ Create correct .htaccess rules when WordPress is installed in a
47
+ different location. Both fixes props Allan Bazinet @
48
+ http://sneezingfrog.com/blog/
49
+
50
+ 2008-07-15 10:17 donncha
51
+
52
+ * Changelog.txt: Update changelog
53
+
54
  2008-07-15 10:15 donncha
55
 
56
  * readme.txt, wp-cache.php: Bump the version number to 0.6.5
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: donncha
3
  Tags: performance,caching,wp-cache
4
  Tested up to: 2.6
5
- Stable tag: 0.6.5
6
  Requires at least: 2.2
7
 
8
  A very fast caching engine for WordPress that produces static html files.
@@ -40,6 +40,7 @@ The [changelog](http://svn.wp-plugins.org/wp-super-cache/trunk/Changelog.txt) is
40
 
41
  `RewriteCond %{REQUEST_METHOD} !=POST`
42
  `RewriteCond %{QUERY_STRING} !.*s=.*`
 
43
  `RewriteCond %{QUERY_STRING} !.*attachment_id=.*`
44
  `RewriteCond %{QUERY_STRING} !.*wp-subscription-manager=.*`
45
  `RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$`
@@ -49,6 +50,7 @@ The [changelog](http://svn.wp-plugins.org/wp-super-cache/trunk/Changelog.txt) is
49
 
50
  `RewriteCond %{REQUEST_METHOD} !=POST`
51
  `RewriteCond %{QUERY_STRING} !.*s=.*`
 
52
  `RewriteCond %{QUERY_STRING} !.*wp-subscription-manager=.*`
53
  `RewriteCond %{QUERY_STRING} !.*attachment_id=.*`
54
  `RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$`
@@ -76,7 +78,7 @@ Comments will show as soon as they are moderated, depending on the comment polic
76
 
77
  = Why are there two expiry times? =
78
 
79
- WP Super Cache stores it's cached files in a different way to WP Cache that lets it work better even when there are very many cached files. That is why the Super Cache expiry time is so much longer by default.
80
 
81
  = Will the Super Cache compression slow down my server? =
82
 
@@ -112,6 +114,7 @@ If you can't do that, then copy the file. That will work too.
112
  10. The plugin does not work very well when PHP's safe mode is active. This must be disabled by your administrator.
113
  11. If pages are randomly super cached and sometimes not, your blog can probably be viewed with and without the "www" prefix on the URL. You should choose one way and install the [Enforce www preference](http://txfx.net/code/wordpress/enforce-www-preference/) plugin.
114
  12. Private Server users at Dreamhost should edit wp-content/wp-cache-config.php and set the cache dir to "/tmp/" if they are getting errors about increasing CPU usage. See this [discussion](http://wordpress.org/support/topic/145895?replies=42) for more.
 
115
 
116
  == Custom Caching ==
117
  It is now possible to hook into the caching process using the add_cacheacton() function.
2
  Contributors: donncha
3
  Tags: performance,caching,wp-cache
4
  Tested up to: 2.6
5
+ Stable tag: 0.6.6
6
  Requires at least: 2.2
7
 
8
  A very fast caching engine for WordPress that produces static html files.
40
 
41
  `RewriteCond %{REQUEST_METHOD} !=POST`
42
  `RewriteCond %{QUERY_STRING} !.*s=.*`
43
+ `RewriteCond %{QUERY_STRING} !.*p=.*`
44
  `RewriteCond %{QUERY_STRING} !.*attachment_id=.*`
45
  `RewriteCond %{QUERY_STRING} !.*wp-subscription-manager=.*`
46
  `RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$`
50
 
51
  `RewriteCond %{REQUEST_METHOD} !=POST`
52
  `RewriteCond %{QUERY_STRING} !.*s=.*`
53
+ `RewriteCond %{QUERY_STRING} !.*p=.*`
54
  `RewriteCond %{QUERY_STRING} !.*wp-subscription-manager=.*`
55
  `RewriteCond %{QUERY_STRING} !.*attachment_id=.*`
56
  `RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$`
78
 
79
  = Why are there two expiry times? =
80
 
81
+ WP Super Cache stores it's cached files in a different way to WP Cache that lets it work better even when there are very many cached files. That is why the Super Cache expiry time is so much longer by default. If your site starts to slow down and there are too many cached files reduce these times and change the garbage collection number too.
82
 
83
  = Will the Super Cache compression slow down my server? =
84
 
114
  10. The plugin does not work very well when PHP's safe mode is active. This must be disabled by your administrator.
115
  11. If pages are randomly super cached and sometimes not, your blog can probably be viewed with and without the "www" prefix on the URL. You should choose one way and install the [Enforce www preference](http://txfx.net/code/wordpress/enforce-www-preference/) plugin.
116
  12. Private Server users at Dreamhost should edit wp-content/wp-cache-config.php and set the cache dir to "/tmp/" if they are getting errors about increasing CPU usage. See this [discussion](http://wordpress.org/support/topic/145895?replies=42) for more.
117
+ 13. sem_acquire() errors such as "failed to acquire key 0x152b: Permission denied in..." are a sign that you must use file locking. Edit wp-content/wp-cache-config.php and uncomment "$use_flock = true" or set $sem_id to a different value.
118
 
119
  == Custom Caching ==
120
  It is now possible to hook into the caching process using the add_cacheacton() function.
wp-cache-config-sample.php CHANGED
@@ -5,7 +5,7 @@ WP-Cache Config Sample File
5
  See wp-cache.php for author details.
6
  */
7
 
8
- define( 'WPCACHEHOME', ABSPATH . 'wp-content/plugins/wp-super-cache/' );
9
 
10
  $cache_compression = 0; // Super cache compression
11
  $cache_enabled = false;
@@ -13,7 +13,7 @@ $super_cache_enabled = false;
13
  $cache_max_time = 3600; //in seconds
14
  //$use_flock = true; // Set it true or false if you know what to use
15
  $super_cache_max_time = 21600; // in seconds
16
- $cache_path = ABSPATH . 'wp-content/cache/';
17
  $file_prefix = 'wp-cache-';
18
 
19
  // We want to be able to identify each blog in a WordPress MU install
5
  See wp-cache.php for author details.
6
  */
7
 
8
+ define( 'WPCACHEHOME', WP_CONTENT_DIR . '/plugins/wp-super-cache/' );
9
 
10
  $cache_compression = 0; // Super cache compression
11
  $cache_enabled = false;
13
  $cache_max_time = 3600; //in seconds
14
  //$use_flock = true; // Set it true or false if you know what to use
15
  $super_cache_max_time = 21600; // in seconds
16
+ $cache_path = WP_CONTENT_DIR . '/cache/';
17
  $file_prefix = 'wp-cache-';
18
 
19
  // We want to be able to identify each blog in a WordPress MU install
wp-cache-phase1.php CHANGED
@@ -1,7 +1,10 @@
1
  <?php
2
- if( !@include(ABSPATH . 'wp-content/wp-cache-config.php') ) {
 
 
 
 
3
  return;
4
- }
5
  if( !defined( 'WPCACHEHOME' ) )
6
  define('WPCACHEHOME', dirname(__FILE__).'/');
7
 
1
  <?php
2
+ // Pre-2.6 compatibility
3
+ if( !defined('WP_CONTENT_DIR') )
4
+ define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
5
+
6
+ if( !include( WP_CONTENT_DIR . '/wp-cache-config.php' ) )
7
  return;
 
8
  if( !defined( 'WPCACHEHOME' ) )
9
  define('WPCACHEHOME', dirname(__FILE__).'/');
10
 
wp-cache-phase2.php CHANGED
@@ -124,12 +124,13 @@ function wp_cache_ob_callback($buffer) {
124
  global $cache_path, $cache_filename, $meta_file, $wp_start_time, $supercachedir;
125
  global $new_cache, $wp_cache_meta_object, $file_expired, $blog_id, $cache_compression;
126
  global $wp_cache_gzip_encoding, $super_cache_enabled, $cached_direct_pages;
 
127
 
128
  $new_cache = true;
129
 
130
  /* Mode paranoic, check for closing tags
131
  * we avoid caching incomplete files */
132
- if (is_404()) {
133
  $new_cache = false;
134
  $buffer .= "\n<!-- Page not cached by WP Super Cache. 404. -->\n";
135
  }
@@ -146,8 +147,11 @@ function wp_cache_ob_callback($buffer) {
146
  $duration = sprintf("%0.3f", $duration);
147
  $buffer .= "\n<!-- Dynamic Page Served (once) in $duration seconds -->\n";
148
 
149
- if( !wp_cache_writers_entry() )
150
- return false;
 
 
 
151
  $mtime = @filemtime($cache_path . $cache_filename);
152
  /* Return if:
153
  the file didn't exist before but it does exist now (another connection created)
124
  global $cache_path, $cache_filename, $meta_file, $wp_start_time, $supercachedir;
125
  global $new_cache, $wp_cache_meta_object, $file_expired, $blog_id, $cache_compression;
126
  global $wp_cache_gzip_encoding, $super_cache_enabled, $cached_direct_pages;
127
+ global $wp_cache_404;
128
 
129
  $new_cache = true;
130
 
131
  /* Mode paranoic, check for closing tags
132
  * we avoid caching incomplete files */
133
+ if( $wp_cache_404 ) {
134
  $new_cache = false;
135
  $buffer .= "\n<!-- Page not cached by WP Super Cache. 404. -->\n";
136
  }
147
  $duration = sprintf("%0.3f", $duration);
148
  $buffer .= "\n<!-- Dynamic Page Served (once) in $duration seconds -->\n";
149
 
150
+ if( !wp_cache_writers_entry() ) {
151
+ $buffer .= "\n<!-- Page not cached by WP Super Cache. Could not get mutex lock. -->\n";
152
+ return $buffer;
153
+ }
154
+
155
  $mtime = @filemtime($cache_path . $cache_filename);
156
  /* Return if:
157
  the file didn't exist before but it does exist now (another connection created)
wp-cache.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP Super Cache
4
  Plugin URI: http://ocaoimh.ie/wp-super-cache/
5
  Description: Very fast caching module for WordPress. Once enabled, you must <a href="options-general.php?page=wp-super-cache/wp-cache.php">enable the cache</a>. Based on WP-Cache by <a href="http://mnm.uib.es/gallir/">Ricardo Galli Granada</a>.
6
- Version: 0.6.5
7
  Author: Donncha O Caoimh
8
  Author URI: http://ocaoimh.ie/
9
  */
@@ -25,7 +25,13 @@ Author URI: http://ocaoimh.ie/
25
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
  */
27
 
28
- $wp_cache_config_file = ABSPATH . 'wp-content/wp-cache-config.php';
 
 
 
 
 
 
29
 
30
  if( !@include($wp_cache_config_file) ) {
31
  get_wpcachehome();
@@ -36,7 +42,7 @@ if( !@include($wp_cache_config_file) ) {
36
  }
37
 
38
  $wp_cache_config_file_sample = WPCACHEHOME . 'wp-cache-config-sample.php';
39
- $wp_cache_link = ABSPATH . 'wp-content/advanced-cache.php';
40
  $wp_cache_file = WPCACHEHOME . 'wp-cache-phase1.php';
41
 
42
  include(WPCACHEHOME . 'wp-cache-base.php');
@@ -48,7 +54,7 @@ function get_wpcachehome() {
48
  } elseif( is_file( dirname(__FILE__) . '/wp-super-cache/wp-cache-config-sample.php' ) ) {
49
  define( 'WPCACHEHOME', dirname(__FILE__) . '/wp-super-cache/' );
50
  } else {
51
- die( 'Please create wp-content/wp-cache-config.php from wp-super-cache/wp-cache-config-sample.php' );
52
  }
53
  }
54
  }
@@ -103,7 +109,7 @@ function toggleLayer( whichLayer ) {
103
  ?><h3>Warning! PHP safe mode enabled!</h3>
104
  <p>You may experience problems running this plugin because SAFE MODE is enabled. <?php
105
  if( !ini_get( 'safe_mode_gid' ) ) {
106
- ?>Your server is set up to check the owner of PHP scripts before allowing them to read and write files.</p><p>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 wp-content/cache/ directory must also be changed. See the <a href='http://php.net/features.safe-mode'>safe mode manual page</a> for further details.</p><?php
107
  } else {
108
  ?>You or an administrator must disable this. See the <a href='http://php.net/features.safe-mode'>safe mode manual page</a> for further details. This cannot be disabled in a .htaccess file unfortunately. It must be done in the php.ini config file.</p><?php
109
  }
@@ -135,19 +141,24 @@ function toggleLayer( whichLayer ) {
135
  define( "SUBMITDISABLED", 'disabled style="color: #aaa" ' );
136
  ?><h4 style='text-align:center; color: #a00'>Read Only Mode. Configuration cannot be changed. <a href="javascript:toggleLayer('readonlywarning');" title="Why your configuration may not be changed">Why</a></h4>
137
  <div id='readonlywarning' style='border: 1px solid #aaa; margin: 2px; padding: 2px; display: none;'>
138
- <p>The WP Super Cache configuration file is <code><?php echo ABSPATH ?>wp-content/wp-cache-config.php</code> and cannot be modified. The file wp-content/wp-cache-config.php must be writeable by the webserver to make any changes.<br />
139
  A simple way of doing that is by changing the permissions temporarily using the CHMOD command or through your ftp client. Make sure it's globally writeable and it should be fine.<br />
140
- Writeable: <code>chmod 666 wp-content/wp-cache-config.php</code><br />
141
- Readonly: <code>chmod 644 wp-content/wp-cache-config.php</code></p>
142
  </div><?php
143
  } else {
144
  define( "SUBMITDISABLED", ' ' );
145
  }
146
 
147
- if( is_writable( ABSPATH . 'wp-content/' ) ) {
148
- ?><h4 style='text-align:center; color: #a00'>Warning! wp-content is writeable!</h4>
149
- <p>You should change the permissions on <?php echo ABSPATH; ?>wp-content/ and make it more restrictive. Use your ftp client, or the following command to fix things:<br /><code>chmod 755 <?php echo ABSPATH; ?>wp-content/</code></p><?php
150
-
 
 
 
 
 
151
  }
152
 
153
  if ( $valid_nonce ) {
@@ -187,7 +198,7 @@ function toggleLayer( whichLayer ) {
187
  ?>
188
  <label><input type='radio' name='wp_cache_status' value='all' <?php if( $cache_enabled == true && $super_cache_enabled == true ) { echo 'checked=checked'; } ?>> <strong>ON</strong> (WP Cache and Super Cache enabled)</label><br />
189
  <label><input type='radio' name='wp_cache_status' value='none' <?php if( $cache_enabled == false ) { echo 'checked=checked'; } ?>> <strong>OFF</strong> (WP Cache and Super Cache disabled)</label><br />
190
- <label><input type='radio' name='wp_cache_status' value='wpcache' <?php if( $cache_enabled == true && $super_cache_enabled == false ) { echo 'checked=checked'; } ?>> <strong>HALF ON</strong> (Super Cache Disabled)</label><br />
191
  <p><label><input type='checkbox' name='wp_cache_hello_world' <?php if( $wp_cache_hello_world ) echo "checked"; ?> value='1'> Proudly tell the world your server is Digg proof! (places a message in your blog's footer)</label></p>
192
  <?php
193
  echo "<div class='submit'><input " . SUBMITDISABLED . "type='submit' value='Update Status &raquo;' /></div>";
@@ -217,8 +228,10 @@ function toggleLayer( whichLayer ) {
217
  <fieldset style='border: 1px solid #aaa' class="options">
218
  <legend>Mod Rewrite Rules</legend><?php
219
  $home_path = get_home_path();
220
- $home_root = parse_url(get_option('home'));
221
  $home_root = trailingslashit($home_root['path']);
 
 
222
  $wprules = implode( "\n", extract_from_markers( $home_path.'.htaccess', 'WordPress' ) );
223
  $wprules = str_replace( "RewriteEngine On\n", '', $wprules );
224
  $wprules = str_replace( "RewriteBase $home_root\n", '', $wprules );
@@ -245,23 +258,25 @@ function toggleLayer( whichLayer ) {
245
  $rules .= "AddDefaultCharset {$charset}\n";
246
  $rules .= "RewriteCond %{REQUEST_METHOD} !=POST\n";
247
  $rules .= "RewriteCond %{QUERY_STRING} !.*s=.*\n";
 
248
  $rules .= "RewriteCond %{QUERY_STRING} !.*attachment_id=.*\n";
249
  $rules .= "RewriteCond %{QUERY_STRING} !.*wp-subscription-manager=.*\n";
250
  $rules .= "RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$\n";
251
  $rules .= "RewriteCond %{HTTP:Accept-Encoding} gzip\n";
252
- $rules .= "RewriteCond %{DOCUMENT_ROOT}{$home_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html.gz -f\n";
253
- $rules .= "RewriteRule ^(.*) {$home_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html.gz [L]\n\n";
254
 
255
  $rules .= "RewriteCond %{REQUEST_METHOD} !=POST\n";
256
  $rules .= "RewriteCond %{QUERY_STRING} !.*s=.*\n";
 
257
  $rules .= "RewriteCond %{QUERY_STRING} !.*attachment_id=.*\n";
258
  $rules .= "RewriteCond %{QUERY_STRING} !.*wp-subscription-manager=.*\n";
259
  $rules .= "RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$\n";
260
- $rules .= "RewriteCond %{DOCUMENT_ROOT}{$home_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html -f\n";
261
- $rules .= "RewriteRule ^(.*) {$home_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html [L]\n";
262
  $rules .= "</IfModule>\n";
263
  if( $dohtaccess && !$_POST[ 'updatehtaccess' ] ) {
264
- echo "<p>In order to serve static html files your server must have the correct mod_rewrite rules added to a file called <code>" . ABSPATH . ".htaccess</code><br /> This can be done automatically by clicking the <em>'Update mod_rewrite rules &raquo;'</em> button or you can edit the file yourself and add the following rules. Make sure they appear before any existing WordPress rules.";
265
  echo "<pre>" . wp_specialchars( $rules ) . "</pre></p>";
266
  echo '<form name="updatehtaccess" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
267
  echo '<input type="hidden" name="updatehtaccess" value="1" />';
@@ -272,15 +287,15 @@ function toggleLayer( whichLayer ) {
272
  wpsc_remove_marker( $home_path.'.htaccess', 'WordPress' ); // remove original WP rules so SuperCache rules go on top
273
  if( insert_with_markers( $home_path.'.htaccess', 'WPSuperCache', explode( "\n", $rules ) ) && insert_with_markers( $home_path.'.htaccess', 'WordPress', explode( "\n", $wprules ) ) ) {
274
  echo "<h4>Mod Rewrite rules updated!</h4>";
275
- echo "<p><strong>" . ABSPATH . ".htaccess has been updated with the necessary mod_rewrite rules. Please verify they are correct. They should look like this:</strong></p>\n";
276
  } else {
277
  echo "<h4>Mod Rewrite rules must be updated!</h4>";
278
- echo "<p><strong> Your " . ABSPATH . ".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:</strong></p>\n";
279
  }
280
  echo "<p><pre>" . wp_specialchars( $rules ) . "</pre></p>\n";
281
  } else {
282
  ?>
283
- <p>WP Super Cache has modified your <?php echo ABSPATH ?>.htaccess file. Click the following link to see the lines added. If you have upgraded the plugin make sure these rules match. <a href="javascript:toggleLayer('rewriterules');" title="See your mod_rewrite rules">View mod_rewrite rules</a>
284
  <div id='rewriterules' style='display: none;'>
285
  <?php echo "<p><pre>" . wp_specialchars( $rules ) . "</pre></p>\n"; ?>
286
  </div>
@@ -517,7 +532,7 @@ function wp_cache_edit_max_time () {
517
  global $super_cache_max_time, $cache_max_time, $wp_cache_config_file, $valid_nonce, $cache_enabled, $super_cache_enabled, $wp_cache_gc;
518
 
519
  if( !isset( $super_cache_max_time ) )
520
- $super_cache_max_time = 21600;
521
 
522
  if(isset($_POST['wp_max_time']) && $valid_nonce) {
523
  $max_time = (int)$_POST['wp_max_time'];
@@ -786,7 +801,7 @@ function wp_cache_verify_config_file() {
786
  }
787
  }
788
  } elseif( !is_writable($dir)) {
789
- echo "<b>Error:</b> Configuration file missing and wp-content directory (<b>$dir</b>) is not writable by the Web server.<br />Check its permissions.";
790
  return false;
791
  }
792
 
@@ -842,7 +857,11 @@ function wp_cache_check_link() {
842
 
843
  function wp_cache_check_global_config() {
844
 
845
- $global = ABSPATH . 'wp-config.php';
 
 
 
 
846
 
847
  $lines = file($global);
848
  foreach($lines as $line) {
@@ -939,7 +958,7 @@ function wp_cache_files() {
939
 
940
  if (is_dir($supercachedir)) {
941
  $entries = glob($supercachedir. '/*');
942
- foreach ($entries as $entry) {
943
  if ($entry != '.' && $entry != '..') {
944
  $sizes = wpsc_dirsize( $entry, $sizes );
945
  }
@@ -1102,4 +1121,13 @@ if( isset( $wp_cache_hello_world ) && $wp_cache_hello_world )
1102
  if( get_option( 'gzipcompression' ) )
1103
  update_option( 'gzipcompression', 0 );
1104
 
 
 
 
 
 
 
 
 
 
1105
  ?>
3
  Plugin Name: WP Super Cache
4
  Plugin URI: http://ocaoimh.ie/wp-super-cache/
5
  Description: Very fast caching module for WordPress. Once enabled, you must <a href="options-general.php?page=wp-super-cache/wp-cache.php">enable the cache</a>. Based on WP-Cache by <a href="http://mnm.uib.es/gallir/">Ricardo Galli Granada</a>.
6
+ Version: 0.6.6
7
  Author: Donncha O Caoimh
8
  Author URI: http://ocaoimh.ie/
9
  */
25
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
  */
27
 
28
+ // Pre-2.6 compatibility
29
+ if( !defined('WP_CONTENT_URL') )
30
+ define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content');
31
+ if( !defined('WP_CONTENT_DIR') )
32
+ define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
33
+
34
+ $wp_cache_config_file = WP_CONTENT_DIR . '/wp-cache-config.php';
35
 
36
  if( !@include($wp_cache_config_file) ) {
37
  get_wpcachehome();
42
  }
43
 
44
  $wp_cache_config_file_sample = WPCACHEHOME . 'wp-cache-config-sample.php';
45
+ $wp_cache_link = WP_CONTENT_DIR . '/advanced-cache.php';
46
  $wp_cache_file = WPCACHEHOME . 'wp-cache-phase1.php';
47
 
48
  include(WPCACHEHOME . 'wp-cache-base.php');
54
  } elseif( is_file( dirname(__FILE__) . '/wp-super-cache/wp-cache-config-sample.php' ) ) {
55
  define( 'WPCACHEHOME', dirname(__FILE__) . '/wp-super-cache/' );
56
  } else {
57
+ die( 'Please create ' . WP_CONTENT_DIR . '/wp-cache-config.php from wp-super-cache/wp-cache-config-sample.php' );
58
  }
59
  }
60
  }
109
  ?><h3>Warning! PHP safe mode enabled!</h3>
110
  <p>You may experience problems running this plugin because SAFE MODE is enabled. <?php
111
  if( !ini_get( 'safe_mode_gid' ) ) {
112
+ ?>Your server is set up to check the owner of PHP scripts before allowing them to read and write files.</p><p>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 <?php echo WP_CONTENT_DIR; ?>/cache/ directory must also be changed. See the <a href='http://php.net/features.safe-mode'>safe mode manual page</a> for further details.</p><?php
113
  } else {
114
  ?>You or an administrator must disable this. See the <a href='http://php.net/features.safe-mode'>safe mode manual page</a> for further details. This cannot be disabled in a .htaccess file unfortunately. It must be done in the php.ini config file.</p><?php
115
  }
141
  define( "SUBMITDISABLED", 'disabled style="color: #aaa" ' );
142
  ?><h4 style='text-align:center; color: #a00'>Read Only Mode. Configuration cannot be changed. <a href="javascript:toggleLayer('readonlywarning');" title="Why your configuration may not be changed">Why</a></h4>
143
  <div id='readonlywarning' style='border: 1px solid #aaa; margin: 2px; padding: 2px; display: none;'>
144
+ <p>The WP Super Cache configuration file is <code><?php echo WP_CONTENT_DIR; ?>/wp-cache-config.php</code> and cannot be modified. The file <?php echo WP_CONTENT_DIR; ?>/wp-cache-config.php must be writeable by the webserver to make any changes.<br />
145
  A simple way of doing that is by changing the permissions temporarily using the CHMOD command or through your ftp client. Make sure it's globally writeable and it should be fine.<br />
146
+ Writeable: <code>chmod 666 <?php echo WP_CONTENT_DIR; ?>/wp-cache-config.php</code><br />
147
+ Readonly: <code>chmod 644 <?php echo WP_CONTENT_DIR; ?>/wp-cache-config.php</code></p>
148
  </div><?php
149
  } else {
150
  define( "SUBMITDISABLED", ' ' );
151
  }
152
 
153
+ // Server could be running as the owner of the wp-content directory. Therefore, if it's
154
+ // writable, issue a warning only if the permissions aren't 755.
155
+ if( is_writable( WP_CONTENT_DIR . '/' ) ) {
156
+ $wp_content_stat = stat(WP_CONTENT_DIR . '/');
157
+ $wp_content_mode = ($wp_content_stat['mode'] & 0777);
158
+ if( $wp_content_mode != 0755 ) {
159
+ ?><h4 style='text-align:center; color: #a00'>Warning! <?php echo WP_CONTENT_DIR; ?> is writeable!</h4>
160
+ <p>You should change the permissions on <?php echo WP_CONTENT_DIR; ?> and make it more restrictive. Use your ftp client, or the following command to fix things:<br /><code>chmod 755 <?php echo WP_CONTENT_DIR; ?>/</code></p><?php
161
+ }
162
  }
163
 
164
  if ( $valid_nonce ) {
198
  ?>
199
  <label><input type='radio' name='wp_cache_status' value='all' <?php if( $cache_enabled == true && $super_cache_enabled == true ) { echo 'checked=checked'; } ?>> <strong>ON</strong> (WP Cache and Super Cache enabled)</label><br />
200
  <label><input type='radio' name='wp_cache_status' value='none' <?php if( $cache_enabled == false ) { echo 'checked=checked'; } ?>> <strong>OFF</strong> (WP Cache and Super Cache disabled)</label><br />
201
+ <label><input type='radio' name='wp_cache_status' value='wpcache' <?php if( $cache_enabled == true && $super_cache_enabled == false ) { echo 'checked=checked'; } ?>> <strong>HALF ON</strong> (Super Cache Disabled, only legacy WP-Cache caching.)</label><br />
202
  <p><label><input type='checkbox' name='wp_cache_hello_world' <?php if( $wp_cache_hello_world ) echo "checked"; ?> value='1'> Proudly tell the world your server is Digg proof! (places a message in your blog's footer)</label></p>
203
  <?php
204
  echo "<div class='submit'><input " . SUBMITDISABLED . "type='submit' value='Update Status &raquo;' /></div>";
228
  <fieldset style='border: 1px solid #aaa' class="options">
229
  <legend>Mod Rewrite Rules</legend><?php
230
  $home_path = get_home_path();
231
+ $home_root = parse_url(get_bloginfo('url'));
232
  $home_root = trailingslashit($home_root['path']);
233
+ $inst_root = parse_url(get_bloginfo('wpurl'));
234
+ $inst_root = trailingslashit($inst_root['path']);
235
  $wprules = implode( "\n", extract_from_markers( $home_path.'.htaccess', 'WordPress' ) );
236
  $wprules = str_replace( "RewriteEngine On\n", '', $wprules );
237
  $wprules = str_replace( "RewriteBase $home_root\n", '', $wprules );
258
  $rules .= "AddDefaultCharset {$charset}\n";
259
  $rules .= "RewriteCond %{REQUEST_METHOD} !=POST\n";
260
  $rules .= "RewriteCond %{QUERY_STRING} !.*s=.*\n";
261
+ $rules .= "RewriteCond %{QUERY_STRING} !.*p=.*\n";
262
  $rules .= "RewriteCond %{QUERY_STRING} !.*attachment_id=.*\n";
263
  $rules .= "RewriteCond %{QUERY_STRING} !.*wp-subscription-manager=.*\n";
264
  $rules .= "RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$\n";
265
  $rules .= "RewriteCond %{HTTP:Accept-Encoding} gzip\n";
266
+ $rules .= "RewriteCond %{DOCUMENT_ROOT}{$inst_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html.gz -f\n";
267
+ $rules .= "RewriteRule ^(.*) {$inst_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html.gz [L]\n\n";
268
 
269
  $rules .= "RewriteCond %{REQUEST_METHOD} !=POST\n";
270
  $rules .= "RewriteCond %{QUERY_STRING} !.*s=.*\n";
271
+ $rules .= "RewriteCond %{QUERY_STRING} !.*p=.*\n";
272
  $rules .= "RewriteCond %{QUERY_STRING} !.*attachment_id=.*\n";
273
  $rules .= "RewriteCond %{QUERY_STRING} !.*wp-subscription-manager=.*\n";
274
  $rules .= "RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$\n";
275
+ $rules .= "RewriteCond %{DOCUMENT_ROOT}{$inst_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html -f\n";
276
+ $rules .= "RewriteRule ^(.*) {$inst_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html [L]\n";
277
  $rules .= "</IfModule>\n";
278
  if( $dohtaccess && !$_POST[ 'updatehtaccess' ] ) {
279
+ echo "<p>In order to serve static html files your server must have the correct mod_rewrite rules added to a file called <code> {$home_path}.htaccess</code><br /> This can be done automatically by clicking the <em>'Update mod_rewrite rules &raquo;'</em> button or you can edit the file yourself and add the following rules. Make sure they appear before any existing WordPress rules.";
280
  echo "<pre>" . wp_specialchars( $rules ) . "</pre></p>";
281
  echo '<form name="updatehtaccess" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
282
  echo '<input type="hidden" name="updatehtaccess" value="1" />';
287
  wpsc_remove_marker( $home_path.'.htaccess', 'WordPress' ); // remove original WP rules so SuperCache rules go on top
288
  if( insert_with_markers( $home_path.'.htaccess', 'WPSuperCache', explode( "\n", $rules ) ) && insert_with_markers( $home_path.'.htaccess', 'WordPress', explode( "\n", $wprules ) ) ) {
289
  echo "<h4>Mod Rewrite rules updated!</h4>";
290
+ echo "<p><strong>{$home_path}.htaccess has been updated with the necessary mod_rewrite rules. Please verify they are correct. They should look like this:</strong></p>\n";
291
  } else {
292
  echo "<h4>Mod Rewrite rules must be updated!</h4>";
293
+ echo "<p><strong> Your {$home_path}.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:</strong></p>\n";
294
  }
295
  echo "<p><pre>" . wp_specialchars( $rules ) . "</pre></p>\n";
296
  } else {
297
  ?>
298
+ <p>WP Super Cache has modified your <?php echo $home_path ?>.htaccess file. Click the following link to see the lines added. If you have upgraded the plugin make sure these rules match. <a href="javascript:toggleLayer('rewriterules');" title="See your mod_rewrite rules">View mod_rewrite rules</a>
299
  <div id='rewriterules' style='display: none;'>
300
  <?php echo "<p><pre>" . wp_specialchars( $rules ) . "</pre></p>\n"; ?>
301
  </div>
532
  global $super_cache_max_time, $cache_max_time, $wp_cache_config_file, $valid_nonce, $cache_enabled, $super_cache_enabled, $wp_cache_gc;
533
 
534
  if( !isset( $super_cache_max_time ) )
535
+ $super_cache_max_time = 3600;
536
 
537
  if(isset($_POST['wp_max_time']) && $valid_nonce) {
538
  $max_time = (int)$_POST['wp_max_time'];
801
  }
802
  }
803
  } elseif( !is_writable($dir)) {
804
+ echo "<b>Error:</b> Configuration file missing and " . WP_CONTENT_DIR . " directory (<b>$dir</b>) is not writable by the Web server.<br />Check its permissions.";
805
  return false;
806
  }
807
 
857
 
858
  function wp_cache_check_global_config() {
859
 
860
+ if ( file_exists( ABSPATH . 'wp-config.php') ) {
861
+ $global = ABSPATH . 'wp-config.php';
862
+ } else {
863
+ $global = dirname(ABSPATH) . '/wp-config.php';
864
+ }
865
 
866
  $lines = file($global);
867
  foreach($lines as $line) {
958
 
959
  if (is_dir($supercachedir)) {
960
  $entries = glob($supercachedir. '/*');
961
+ foreach( (array) $entries as $entry) {
962
  if ($entry != '.' && $entry != '..') {
963
  $sizes = wpsc_dirsize( $entry, $sizes );
964
  }
1121
  if( get_option( 'gzipcompression' ) )
1122
  update_option( 'gzipcompression', 0 );
1123
 
1124
+ // Catch 404 requests. Themes that use query_posts() destroy $wp_query->is_404
1125
+ function wp_cache_catch_404() {
1126
+ global $wp_cache_404;
1127
+ $wp_cache_404 = false;
1128
+ if( is_404() )
1129
+ $wp_cache_404 = true;
1130
+ }
1131
+ add_action( 'template_redirect', 'wp_cache_catch_404' );
1132
+
1133
  ?>