WP Super Cache - Version 0.6.2

Version Description

Download this release

Release Info

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

Code changes from version 0.5.3 to 0.6.2

Changelog.txt CHANGED
@@ -1,3 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  2008-01-04 11:22 donncha
2
 
3
  * wp-cache.php: Only update the hello_world option when updating
1
+ 2008-04-12 07:05 donncha
2
+
3
+ * readme.txt, wp-cache.php: Bump version number and update
4
+ .htaccess example code
5
+
6
+ 2008-04-11 23:30 donncha
7
+
8
+ * wp-cache-phase1.php, wp-cache-phase2.php: Remove "index.php" from
9
+ cached file paths
10
+
11
+ 2008-04-11 23:17 donncha
12
+
13
+ * wp-cache-config-sample.php, wp-cache.php: Add index.php to list
14
+ of not to be cached pages
15
+ Minor typo fix
16
+
17
+ 2008-04-08 09:51 donncha
18
+
19
+ * wp-cache.php: Delete all contents of cache dir, not just
20
+ supercachedir when caching disabled.
21
+
22
+ 2008-04-04 11:59 donncha
23
+
24
+ * wp-cache.php: wp_specialchars the rules
25
+
26
+ 2008-04-01 11:31 donncha
27
+
28
+ * wp-cache.php: Added wpsc_remove_marker() to remove WordPress
29
+ rewrite rules
30
+ Super Cache rules now go in the WPSuperCache marker
31
+ Check for comment cookie in one line, props askapache
32
+
33
+ 2008-03-31 08:42 donncha
34
+
35
+ * wp-cache.php: wp_specialchars() the mod_rewrite rules, props
36
+ Viper007Bond
37
+
38
+ 2008-03-30 10:42 donncha
39
+
40
+ * readme.txt, wp-cache.php: Bump the version numbers
41
+
42
+ 2008-03-30 10:41 donncha
43
+
44
+ * Changelog.txt: Updated changelog
45
+
46
+ 2008-03-30 10:41 donncha
47
+
48
+ * wp-cache.php: Warn if mod_rewrite rules are out of date and
49
+ encourage user to remove or update them manually
50
+
51
+ 2008-03-30 10:26 donncha
52
+
53
+ * Changelog.txt: Updated changelog
54
+
55
+ 2008-03-28 17:37 donncha
56
+
57
+ * wp-cache.php: Login cookie got shortened to "wordpress" in 2.5,
58
+ still backwards compatible
59
+
60
+ 2008-03-28 17:22 donncha
61
+
62
+ * wp-cache.php: Move toggleLayer js around
63
+
64
+ 2008-03-13 11:37 donncha
65
+
66
+ * readme.txt, wp-cache.php: Bump to 0.6
67
+
68
+ 2008-03-13 11:34 donncha
69
+
70
+ * readme.txt: Added compression FAQ
71
+
72
+ 2008-03-13 11:28 donncha
73
+
74
+ * wp-cache.php: Only require mod_rewrite if super cache is enabled
75
+ Hide super cache parts of page when not activated
76
+ Add "/" to mod_rewrite rules for URLs not ending in a /, props
77
+ Michael R Aulia @ http://www.michaelaulia.com/blogs/
78
+
79
+ 2008-03-13 11:25 donncha
80
+
81
+ * readme.txt: Updated documentation
82
+
83
+ 2008-03-12 18:55 donncha
84
+
85
+ * wp-cache-phase2.php: This somehow stops PHP creating directories
86
+ in the root folder, thanks to Cherie and Jennifer for their
87
+ invaluable help!
88
+
89
+ 2008-03-12 17:00 donncha
90
+
91
+ * wp-cache.php: No need for this message any more
92
+
93
+ 2008-03-11 13:04 donncha
94
+
95
+ * wp-cache.php: Don't auto update .htaccess until user wants to.
96
+ Hide listing of cached files, it's wrong anyway.
97
+ Move advanced features to the end of backend page.
98
+
99
+ 2008-02-11 20:52 donncha
100
+
101
+ * readme.txt, wp-cache.php: You must define things before loading
102
+ WordPress! (props s2j @
103
+ http://wordpress.org/support/topic/154996?replies=12#post-691402
104
+ )
105
+
106
+ 2008-02-08 10:27 donncha
107
+
108
+ * wp-cache.php: Remember to delete compressed files from directly
109
+ cached folders, props John Pozadzides
110
+
111
+ 2008-01-16 12:14 donncha
112
+
113
+ * Changelog.txt: Update changelog
114
+
115
+ 2008-01-16 12:13 donncha
116
+
117
+ * readme.txt, wp-cache.php: Bump version number
118
+ Make admin page readonly if configuration page cannot be written
119
+ to
120
+
121
+ 2008-01-04 11:23 donncha
122
+
123
+ * Changelog.txt, readme.txt, wp-cache.php: Bump version and update
124
+ changelog
125
+
126
  2008-01-04 11:22 donncha
127
 
128
  * wp-cache.php: Only update the hello_world option when updating
readme.txt CHANGED
@@ -1,10 +1,11 @@
1
  === WP Super Cache ===
2
  Contributors: donncha
3
  Tags: performance,caching,wp-cache
4
- Tested up to: 2.3.1
5
- Stable tag: 0.5.3
 
6
 
7
- A modification of WP-Cache that produces static html files.
8
 
9
  == Description ==
10
  This plugin generates static html files from your dynamic WordPress blog. After a html file is generated your webserver will serve that file instead of processing the comparatively heavier and more expensive WordPress PHP scripts.
@@ -17,8 +18,13 @@ However, because a user's details are displayed in the comment form after they l
17
 
18
  The good news is that probably more than 99% of your visitors don't do any of the above! Those users who don't see the static files will still benefit because they will see regular WP-Cache cached files and your server won't be as busy as before. This plugin should help your server cope with a front page appearance on digg.com or other social networking site.
19
 
 
 
 
 
 
20
  == Installation ==
21
- 1. You must have mod mime, mod rewrite and fancy permalinks enabled. PHP safe mode should be disabled.
22
  2. If you have WP-Cache installed already, please disable it. Edit wp-config.php and make sure the WP_CACHE define is deleted, and remove the files wp-content/wp-cache-config.php and wp-content/advanced-cache.php. These will be recreated when you install this plugin.
23
  3. Upload this directory to your plugins directory. It will create a 'wp-content/plugins/wp-super-cache/' directory.
24
  4. If you are using WordPress MU you will need to install this in 'wp-content/mu-plugins/wp-super-cache/' and the file wp-cache.php must be copied into the mu-plugins directory.
@@ -26,53 +32,85 @@ The good news is that probably more than 99% of your visitors don't do any of th
26
  6. Now go to Options->WP Super Cache and enable caching. If you see an error message or a blank screen you may need to fix it. See the "FAQ" section later in this readme for instructions.
27
  7. mod_rewrite rules will be inserted into your .htaccess file. Look in your web root directory for this file. It should look similar to this:
28
 
29
- -----------------.htaccess-----------------
30
- RewriteEngine On
31
- RewriteBase /
32
 
33
- RewriteCond %{QUERY_STRING} !.*s=.*
34
- RewriteCond %{HTTP_COOKIE} !^.*comment_author_.*$
35
- RewriteCond %{HTTP_COOKIE} !^.*wordpressuser.*$
36
- RewriteCond %{HTTP_COOKIE} !^.*wp-postpass_.*$
37
- RewriteCond %{HTTP:Accept-Encoding} gzip
38
- RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1index.html.gz -f
39
- RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1index.html.gz [L]
40
 
41
- RewriteCond %{QUERY_STRING} !.*s=.*
42
- RewriteCond %{HTTP_COOKIE} !^.*comment_author_.*$
43
- RewriteCond %{HTTP_COOKIE} !^.*wordpressuser.*$
44
- RewriteCond %{HTTP_COOKIE} !^.*wp-postpass_.*$
45
- RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1index.html -f
46
- RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1index.html [L]
47
 
48
- RewriteCond %{REQUEST_FILENAME} !-f
49
- RewriteCond %{REQUEST_FILENAME} !-d
50
- RewriteRule . /index.php [L]
51
- -----------------.htaccess-----------------
52
- 8. After you have enabled the plugin, look for "wp-content/cache/.htaccess". If it's not there you must create it. It should read:
53
- AddEncoding x-gzip .gz
54
- AddType text/html .gz
 
55
 
56
  == Frequently Asked Questions ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  If things don't work when you installed the plugin here are a few things to check:
58
 
59
  1. Is wp-content writable by the web server?
60
  2. Is there a wp-content/wp-cache-config.php ? If not, copy the file wp-super-cache/wp-cache-config-sample.php to wp-content/wp-cache-config.php and make sure WPCACHEHOME points at the right place. "plugins" should be "mu-plugins" if you're using WordPress MU.
61
- 3. Is there a wp-content/advanced-cache.php ? If not, then you must symlink wp-super-cache/wp-cache-phase1.php to it with the command while in the wp-content folder. `ln -s plugins/wp-super-cache/wp-cache-phase1.php advanced-cache.php` If you can't do that, then copy the file. That will work too.
62
- 4. Make sure the following line is in wp-config.php : `define( 'WP_CACHE', true );`
 
 
 
 
 
63
  5. Try the Options->WP Super Cache page again and enable cache.
64
  6. Look in wp-content/cache/supercache/. Are there directories and files there?
65
  7. Anything in your php error_log?
66
  8. If your browser keeps asking you to save the file after the super cache is installed you must disable Super Cache compression. Go to the Options->WP Super Cache page and disable it there.
67
  9. The plugin does not work very well when PHP's safe mode is active. This must be disabled by your administrator.
 
68
 
69
  == Custom Caching ==
70
  It is now possible to hook into the caching process using the add_cacheacton() function.
 
71
  Three hooks are available:
72
 
73
  1. 'wp_cache_get_cookies_values' - modify the key used by WP Cache.
74
  2. 'add_cacheaction' - runs in phase2. Allows a plugin to add WordPress hooks.
75
- 3. 'cache_admin_page' - runs in the admin page. Use it to add modify that page.
76
 
77
  There is one regular WordPress filter too. Use the "do_createsupercache" filter
78
  to customize the checks made before caching. The filter accepts one parameter.
@@ -81,12 +119,9 @@ The output of WP-Cache's wp_cache_get_cookies_values() function.
81
  See plugins/searchengine.php as an example I use for my [No Adverts for Friends](plugin at http://ocaoimh.ie/no-adverts-for-friends/)
82
 
83
  == Updates ==
84
- Updates to the plugin will be posted here, to http://ocaoimh.ie/ and the page
85
- http://ocaoimh.ie/wp-super-cache/ will always link to the newest version.
86
 
87
  == Thanks ==
88
- I would sincerely like to thank [John Pozadzides](http://onemansblog.com/) for
89
- giving me the idea for this, for writing the "How it works" section and for
90
- testing the plugin through 2 front page appearances on digg.com
91
- Thanks to James Farmer and Andrew Billits of [Edu Blogs](http://edublogs.org/) fame who helped me
92
- make this more WordPress MU friendly.
1
  === WP Super Cache ===
2
  Contributors: donncha
3
  Tags: performance,caching,wp-cache
4
+ Tested up to: 2.5
5
+ Stable tag: 0.6.2
6
+ Requires at least: 2.2
7
 
8
+ A very fast caching engine for WordPress that produces static html files.
9
 
10
  == Description ==
11
  This plugin generates static html files from your dynamic WordPress blog. After a html file is generated your webserver will serve that file instead of processing the comparatively heavier and more expensive WordPress PHP scripts.
18
 
19
  The good news is that probably more than 99% of your visitors don't do any of the above! Those users who don't see the static files will still benefit because they will see regular WP-Cache cached files and your server won't be as busy as before. This plugin should help your server cope with a front page appearance on digg.com or other social networking site.
20
 
21
+ As this plugin is based on the older WP-Cache plugin you can switch off the Super Cache static html caching. Caching will still be performed, but every request will require loading the PHP engine. In normal circumstances this isn't that bad, but if your server is underpowered, or you're experiencing heavy traffic you may run into trouble.
22
+ Super Cached html files will be server more quickly than PHP generated cached files so there's very little reason not to use the Super Cache feature.
23
+
24
+ See the [WP Super Cache homepage](http://ocaoimh.ie/wp-super-cache/) for further information.
25
+
26
  == Installation ==
27
+ 1. You should have mod mime, mod rewrite and fancy permalinks enabled. PHP safe mode should be disabled. If any of those are missing or off you can still use the slower WP-Cache part of the plugin.
28
  2. If you have WP-Cache installed already, please disable it. Edit wp-config.php and make sure the WP_CACHE define is deleted, and remove the files wp-content/wp-cache-config.php and wp-content/advanced-cache.php. These will be recreated when you install this plugin.
29
  3. Upload this directory to your plugins directory. It will create a 'wp-content/plugins/wp-super-cache/' directory.
30
  4. If you are using WordPress MU you will need to install this in 'wp-content/mu-plugins/wp-super-cache/' and the file wp-cache.php must be copied into the mu-plugins directory.
32
  6. Now go to Options->WP Super Cache and enable caching. If you see an error message or a blank screen you may need to fix it. See the "FAQ" section later in this readme for instructions.
33
  7. mod_rewrite rules will be inserted into your .htaccess file. Look in your web root directory for this file. It should look similar to this:
34
 
35
+ `-----------------.htaccess-----------------`
36
+ `RewriteEngine On`
37
+ `RewriteBase /`
38
 
39
+ `RewriteCond %{QUERY_STRING} !.*s=.*`
40
+ `RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$`
41
+ `RewriteCond %{HTTP:Accept-Encoding} gzip`
42
+ `RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz -f`
43
+ `RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz [L]`
 
 
44
 
45
+ `RewriteCond %{QUERY_STRING} !.*s=.*`
46
+ `RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$`
47
+ `RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f`
48
+ `RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html [L]`
 
 
49
 
50
+ `RewriteCond %{REQUEST_FILENAME} !-f`
51
+ `RewriteCond %{REQUEST_FILENAME} !-d`
52
+ `RewriteRule . /index.php [L]`
53
+ `-----------------.htaccess-----------------`
54
+ 8. After you have enabled the plugin, look for the file "wp-content/cache/.htaccess". If it's not there you must create it. It should read:
55
+
56
+ `AddEncoding x-gzip .gz`
57
+ `AddType text/html .gz`
58
 
59
  == Frequently Asked Questions ==
60
+
61
+ = Why is WP-Super-Cache better than WP-Cache? =
62
+
63
+ This plugin is based on the excellent WP-Cache plugin and therefore brings all the benefits of that plugin to WordPress. On top of that it creates copies of every page that is accessed on a blog in a form that is quickly served by the web server. It's almost as quick as if the you had saved a page in your browser and uploaded it to replace your homepage.
64
+
65
+ = Will comments and other dynamic parts of my blog update immediately? =
66
+
67
+ Comments will show as soon as they are moderated, depending on the comment policy of the blog owner. Other dynamic elements on a page may not update unless they are written in Javascript, Flash, Java or another client side browser language. The plugin really produces static html pages. No PHP is executed when those pages are served. "Popularity Contest" is one such plugin that will not work.
68
+
69
+ = Why are there two expiry times? =
70
+
71
+ 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.
72
+
73
+ = Will the Super Cache compression slow down my server? =
74
+
75
+ No, it will do the opposite in fact. Super Cache files are compressed and stored that way so the heavy compression is done only once. These files are generally much smaller and are sent to a visitor's browser much more quickly than uncompressed html. As a result, your server spends less time talking over the network which saves CPU time and bandwidth, and can also serve the next request much more quickly.
76
+
77
+ = How do I uninstall WP Super Cache? =
78
+
79
+ 1. Clear the cache in the backend page and then deactivate it on the plugins page.
80
+ 1. Remove the Super Cache mod_rewrite rules from your .htaccess file.
81
+ 1. Remove the WP_CACHE define from wp-config.php
82
+ 1. Remove the files wp-content/advanced-cache.php and wp-content/wp-cache-config.php
83
+ 1. Remove the directory wp-content/cache/
84
+ 1. Remove the directory wp-super-cache from your plugins directory.
85
+
86
+ = Troubleshooting =
87
+
88
  If things don't work when you installed the plugin here are a few things to check:
89
 
90
  1. Is wp-content writable by the web server?
91
  2. Is there a wp-content/wp-cache-config.php ? If not, copy the file wp-super-cache/wp-cache-config-sample.php to wp-content/wp-cache-config.php and make sure WPCACHEHOME points at the right place. "plugins" should be "mu-plugins" if you're using WordPress MU.
92
+ 3. Is there a wp-content/advanced-cache.php ? If not, then you must symlink wp-super-cache/wp-cache-phase1.php to it with this command while in the wp-content folder.
93
+
94
+ `ln -s plugins/wp-super-cache/wp-cache-phase1.php advanced-cache.php`
95
+ If you can't do that, then copy the file. That will work too.
96
+ 4. Make sure the following line is in wp-config.php and it is ABOVE the "require_once(ABSPATH.'wp-settings.php');" line:
97
+
98
+ `define( 'WP_CACHE', true );`
99
  5. Try the Options->WP Super Cache page again and enable cache.
100
  6. Look in wp-content/cache/supercache/. Are there directories and files there?
101
  7. Anything in your php error_log?
102
  8. If your browser keeps asking you to save the file after the super cache is installed you must disable Super Cache compression. Go to the Options->WP Super Cache page and disable it there.
103
  9. The plugin does not work very well when PHP's safe mode is active. This must be disabled by your administrator.
104
+ 10. 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.
105
 
106
  == Custom Caching ==
107
  It is now possible to hook into the caching process using the add_cacheacton() function.
108
+
109
  Three hooks are available:
110
 
111
  1. 'wp_cache_get_cookies_values' - modify the key used by WP Cache.
112
  2. 'add_cacheaction' - runs in phase2. Allows a plugin to add WordPress hooks.
113
+ 3. 'cache_admin_page' - runs in the admin page. Use it to modify that page, perhaps by adding new configuration options.
114
 
115
  There is one regular WordPress filter too. Use the "do_createsupercache" filter
116
  to customize the checks made before caching. The filter accepts one parameter.
119
  See plugins/searchengine.php as an example I use for my [No Adverts for Friends](plugin at http://ocaoimh.ie/no-adverts-for-friends/)
120
 
121
  == Updates ==
122
+ Updates to the plugin will be posted here, to [Holy Shmoly!](http://ocaoimh.ie/) and the [WP Super Cache homepage](http://ocaoimh.ie/wp-super-cache/) will always link to the newest version.
 
123
 
124
  == Thanks ==
125
+ I would sincerely like to thank [John Pozadzides](http://onemansblog.com/) for giving me the idea for this, for writing the "How it works" section and for testing the plugin through 2 front page appearances on digg.com
126
+
127
+ Thanks to James Farmer and Andrew Billits of [Edu Blogs](http://edublogs.org/) fame who helped me make this more WordPress MU friendly.
 
 
wp-cache-config-sample.php CHANGED
@@ -40,7 +40,7 @@ if( defined( 'VHOST' ) ) {
40
  // Array of files that have 'wp-' but should still be cached
41
  $cache_acceptable_files = array( 'wp-atom.php', 'wp-comments-popup.php', 'wp-commentsrss2.php', 'wp-links-opml.php', 'wp-locations.php', 'wp-rdf.php', 'wp-rss.php', 'wp-rss2.php');
42
 
43
- $cache_rejected_uri = array('wp-.*.php');
44
  $cache_rejected_user_agent = array ( 0 => 'bot', 1 => 'ia_archive', 2 => 'slurp', 3 => 'crawl', 4 => 'spider');
45
 
46
  // Just modify it if you have conflicts with semaphores
40
  // Array of files that have 'wp-' but should still be cached
41
  $cache_acceptable_files = array( 'wp-atom.php', 'wp-comments-popup.php', 'wp-commentsrss2.php', 'wp-links-opml.php', 'wp-locations.php', 'wp-rdf.php', 'wp-rss.php', 'wp-rss2.php');
42
 
43
+ $cache_rejected_uri = array('wp-.*.php', 'index.php');
44
  $cache_rejected_user_agent = array ( 0 => 'bot', 1 => 'ia_archive', 2 => 'slurp', 3 => 'crawl', 4 => 'spider');
45
 
46
  // Just modify it if you have conflicts with semaphores
wp-cache-phase1.php CHANGED
@@ -42,7 +42,7 @@ if ($cache_compression) {
42
  $wp_cache_gzip_encoding = gzip_accepted();
43
  }
44
 
45
- $key = $blogcacheid . md5($_SERVER['HTTP_HOST'].preg_replace('/#.*$/', '', $_SERVER['REQUEST_URI']).$wp_cache_gzip_encoding.wp_cache_get_cookies_values());
46
 
47
  $cache_filename = $file_prefix . $key . '.html';
48
  $meta_file = $file_prefix . $key . '.meta';
42
  $wp_cache_gzip_encoding = gzip_accepted();
43
  }
44
 
45
+ $key = $blogcacheid . md5($_SERVER['HTTP_HOST'].preg_replace('/#.*$/', '', str_replace( '/index.php', '/', $_SERVER['REQUEST_URI'] ) ).$wp_cache_gzip_encoding.wp_cache_get_cookies_values());
46
 
47
  $cache_filename = $file_prefix . $key . '.html';
48
  $meta_file = $file_prefix . $key . '.meta';
wp-cache-phase2.php CHANGED
@@ -152,7 +152,7 @@ function wp_cache_ob_callback($buffer) {
152
  the file was expired and its mtime is less than 5 seconds
153
  */
154
  if( !((!$file_expired && $mtime) || ($mtime && $file_expired && (time() - $mtime) < 5)) ) {
155
- $uri = preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', str_replace( '..', '', $_SERVER['REQUEST_URI']) );
156
  $dir = strtolower(preg_replace('/:.*$/', '', $_SERVER["HTTP_HOST"])) . $uri; // To avoid XSS attacs
157
  $dir = trailingslashit( $cache_path . 'supercache/' . $dir );
158
  if( is_array( $cached_direct_pages ) && in_array( $_SERVER[ 'REQUEST_URI' ], $cached_direct_pages ) ) {
@@ -166,6 +166,7 @@ function wp_cache_ob_callback($buffer) {
166
  if (!$fr)
167
  $buffer = "Couldn't write to: " . $cache_path . $cache_filename . "\n";
168
  if( $super_cache_enabled ) {
 
169
  if( @is_dir( $dir ) == false )
170
  @wp_mkdir_p( $dir );
171
 
152
  the file was expired and its mtime is less than 5 seconds
153
  */
154
  if( !((!$file_expired && $mtime) || ($mtime && $file_expired && (time() - $mtime) < 5)) ) {
155
+ $uri = preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', str_replace( '/index.php', '/', str_replace( '..', '', $_SERVER['REQUEST_URI']) ) );
156
  $dir = strtolower(preg_replace('/:.*$/', '', $_SERVER["HTTP_HOST"])) . $uri; // To avoid XSS attacs
157
  $dir = trailingslashit( $cache_path . 'supercache/' . $dir );
158
  if( is_array( $cached_direct_pages ) && in_array( $_SERVER[ 'REQUEST_URI' ], $cached_direct_pages ) ) {
166
  if (!$fr)
167
  $buffer = "Couldn't write to: " . $cache_path . $cache_filename . "\n";
168
  if( $super_cache_enabled ) {
169
+ $dir = str_replace( '//', '/', $dir );
170
  if( @is_dir( $dir ) == false )
171
  @wp_mkdir_p( $dir );
172
 
wp-cache.php CHANGED
@@ -3,12 +3,12 @@
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.5.3
7
  Author: Donncha O Caoimh
8
  Author URI: http://ocaoimh.ie/
9
  */
10
  /* Copyright 2005-2006 Ricardo Galli Granada (email : gallir@uib.es)
11
- Some code copyright 2007 Donncha O Caoimh (http://ocaoimh.ie/)
12
 
13
  This program is free software; you can redistribute it and/or modify
14
  it under the terms of the GNU General Public License as published by
@@ -75,7 +75,27 @@ function wp_cache_manager() {
75
  if( get_option( 'gzipcompression' ) == 1 )
76
  update_option( 'gzipcompression', 0 );
77
  $valid_nonce = wp_verify_nonce($_REQUEST['_wpnonce'], 'wp-cache');
78
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  echo '<div class="wrap">';
80
  echo "<h2>WP Super Cache Manager</h2>\n";
81
  if( ini_get( 'safe_mode' ) ) {
@@ -105,14 +125,22 @@ function wp_cache_manager() {
105
  return;
106
  }
107
 
108
- if( !got_mod_rewrite() ) {
109
  ?><h4 style='color: #a00'>Mod rewrite may not be installed!</h4>
110
  <p>It appears that mod_rewrite is not installed. Sometimes this check isn't 100% reliable, especially if you are not using Apache. Please verify that the mod_rewrite module is loaded. It is required for serving Super Cache static files. You will still be able to use WP-Cache.</p><?php
111
  }
112
 
113
- if( is_writeable( ABSPATH ) ) {
114
- ?><h4 style='color: #a00'>Warning! <?php echo ABSPATH; ?> is writeable!</h4>
115
- <p>Your blog root directory is writeable by the webserver. Unless you are creating direct cached files it is recommended that this be changed to read-only.</p><?php
 
 
 
 
 
 
 
 
116
  }
117
 
118
  if ( $valid_nonce ) {
@@ -150,18 +178,19 @@ function wp_cache_manager() {
150
  <legend>WP Super Cache Status</legend><?php
151
  echo '<form name="wp_manager" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
152
  ?>
153
- <label><input type='radio' name='wp_cache_status' value='all' <?php if( $cache_enabled == true && $super_cache_enabled == true ) { echo 'checked=checked'; } ?>> WP Cache and Super Cache enabled</label><br />
154
- <label><input type='radio' name='wp_cache_status' value='none' <?php if( $cache_enabled == false ) { echo 'checked=checked'; } ?>> WP Cache and Super Cache disabled</label><br />
155
- <label><input type='radio' name='wp_cache_status' value='wpcache' <?php if( $cache_enabled == true && $super_cache_enabled == false ) { echo 'checked=checked'; } ?>> Super Cache Disabled</label><br />
156
  <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>
157
  <?php
158
- echo '<div class="submit"><input type="submit"value="Update Status &raquo;" /></div>';
159
  wp_nonce_field('wp-cache');
160
  ?>
161
  </form>
162
- </fieldset><br />
163
 
164
- <fieldset style='border: 1px solid #aaa' class="options">
 
165
  <legend>Super Cache Compression</legend>
166
  <form name="wp_manager" action="<?php echo $_SERVER["REQUEST_URI"]; ?>" method="post">
167
  <label><input type="radio" name="cache_compression" value="1" <?php if( $cache_compression ) { echo "checked=checked"; } ?>> Enabled</label>
@@ -173,7 +202,7 @@ function wp_cache_manager() {
173
  } elseif( isset( $cache_compression_changed ) && isset( $_POST[ 'cache_compression' ] ) && $cache_compression ) {
174
  ?><p><strong>Super Cache compression is now enabled.</strong></p><?php
175
  }
176
- echo '<div class="submit"><input type="submit"value="Update Compression &raquo;" /></div>';
177
  wp_nonce_field('wp-cache');
178
  echo "</form>\n";
179
  ?></fieldset><br />
@@ -186,70 +215,59 @@ function wp_cache_manager() {
186
  $wprules = implode( "\n", extract_from_markers( $home_path.'.htaccess', 'WordPress' ) );
187
  $wprules = str_replace( "RewriteEngine On\n", '', $wprules );
188
  $wprules = str_replace( "RewriteBase $home_root\n", '', $wprules );
 
189
 
190
- $dohtaccess = false;
191
  if( !$wprules || $wprules == '' ) {
192
- echo "<h4 style='color: #a00'>Mod Rewrite rules not updated!</h4>";
193
  echo "<p>You must have <strong>BEGIN</strong> and <strong>END</strong> markers in {$home_path}.htaccess for the auto update to work. They look like this and surround the main WordPress mod_rewrite rules:
194
  <blockquote><code><em># BEGIN WordPress</em><br /> RewriteCond %{REQUEST_FILENAME} !-f<br /> RewriteCond %{REQUEST_FILENAME} !-d<br /> RewriteRule . /index.php [L]<br /> <em># END WordPress</em></code></blockquote>
195
- Refresh this page when you have updated your .htaccess file to add the Super Cache rules.";
196
- } elseif( strpos( $wprules, 'supercache' ) == false ) { // only write the rules once
197
- $dohtaccess = true;
 
 
 
 
 
198
  }
199
  $rules = "<IfModule mod_rewrite.c>\n";
200
  $rules .= "RewriteEngine On\n";
201
  $rules .= "RewriteBase $home_root\n"; // props Chris Messina
202
  $rules .= "RewriteCond %{QUERY_STRING} !.*s=.*\n";
203
- $rules .= "RewriteCond %{HTTP_COOKIE} !^.*comment_author_.*$\n";
204
- $rules .= "RewriteCond %{HTTP_COOKIE} !^.*wordpressuser.*$\n";
205
- $rules .= "RewriteCond %{HTTP_COOKIE} !^.*wp-postpass_.*$\n";
206
  $rules .= "RewriteCond %{HTTP:Accept-Encoding} gzip\n";
207
- $rules .= "RewriteCond %{DOCUMENT_ROOT}{$home_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1index.html.gz -f\n";
208
- $rules .= "RewriteRule ^(.*) {$home_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1index.html.gz [L]\n\n";
209
 
210
  $rules .= "RewriteCond %{QUERY_STRING} !.*s=.*\n";
211
- $rules .= "RewriteCond %{HTTP_COOKIE} !^.*comment_author_.*$\n";
212
- $rules .= "RewriteCond %{HTTP_COOKIE} !^.*wordpressuser.*$\n";
213
- $rules .= "RewriteCond %{HTTP_COOKIE} !^.*wp-postpass_.*$\n";
214
- $rules .= "RewriteCond %{DOCUMENT_ROOT}{$home_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1index.html -f\n";
215
- $rules .= "RewriteRule ^(.*) {$home_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1index.html [L]\n";
216
- $rules .= "WPRULES\n";
217
- $rules .= "</IfModule>";
218
- if( $dohtaccess ) {
219
- $rules = str_replace( 'WPRULES', $wprules, $rules );
220
- if( insert_with_markers( $home_path.'.htaccess', 'WordPress', explode( "\n", $rules ) ) ) {
 
 
 
 
 
221
  echo "<h4>Mod Rewrite rules updated!</h4>";
222
- echo "<p><strong>" . ABSPATH . ".htaccess has been updated with the necessary mod_rewrite rules. Please verify they are correct. The file should look like this:</strong></p>\n";
223
  } else {
224
  echo "<h4>Mod Rewrite rules must be updated!</h4>";
225
  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";
226
  }
227
- echo "<p><pre># BEGIN WordPress\n{$rules}# END WordPress</pre></p>\n";
228
  } else {
229
- $rules = str_replace( 'WPRULES', '', $rules );
230
- /* http://www.netlobo.com/div_hiding.html */
231
  ?>
232
- <script type='text/javascript'>
233
- <!--
234
- function toggleLayer( whichLayer ) {
235
- var elem, vis;
236
- if( document.getElementById ) // this is the way the standards work
237
- elem = document.getElementById( whichLayer );
238
- else if( document.all ) // this is the way old msie versions work
239
- elem = document.all[whichLayer];
240
- else if( document.layers ) // this is the way nn4 works
241
- elem = document.layers[whichLayer];
242
- vis = elem.style;
243
- // if the style.display value is blank we try to figure it out here
244
- if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
245
- vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
246
- vis.display = (vis.display==''||vis.display=='block')?'none':'block';
247
- }
248
- // -->
249
- </script>
250
  <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>
251
  <div id='rewriterules' style='display: none;'>
252
- <?php echo "<p><pre># BEGIN WordPress\n{$rules}# END WordPress</pre></p>\n"; ?>
253
  </div>
254
  <?php
255
  }
@@ -263,6 +281,8 @@ function toggleLayer( whichLayer ) {
263
 
264
  ?></fieldset><?php
265
 
 
 
266
  wp_cache_edit_max_time();
267
 
268
  echo '<br /><a name="files"></a><fieldset style="border: 1px solid #aaa" class="options"><legend>Accepted filenames, rejected URIs</legend>';
@@ -273,10 +293,11 @@ function toggleLayer( whichLayer ) {
273
 
274
  wp_cache_edit_rejected_ua();
275
 
276
- wp_lock_down();
277
 
278
  wp_cache_files();
279
 
 
 
280
  wp_cache_restore();
281
 
282
  ob_start();
@@ -287,7 +308,7 @@ function toggleLayer( whichLayer ) {
287
  }
288
  $out = ob_get_contents();
289
  ob_end_clean();
290
- if( $out != '' ) {
291
  echo '<fieldset class="options"><legend>Cache Plugins</legend>';
292
  echo $out;
293
  echo '</fieldset>';
@@ -301,7 +322,7 @@ function wp_cache_restore() {
301
  echo '<br /><fieldset style="border: 1px solid #aaa" class="options"><legend>Configuration messed up?</legend>';
302
  echo '<form name="wp_restore" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
303
  echo '<input type="hidden" name="wp_restore_config" />';
304
- echo '<div class="submit"><input type="submit" id="deletepost" value="Restore default configuration &raquo;" /></div>';
305
  wp_nonce_field('wp-cache');
306
  echo "</form>\n";
307
  echo '</fieldset>';
@@ -315,7 +336,7 @@ if( defined( 'WPLOCKDOWN' ) && constant( 'WPLOCKDOWN' ) )
315
  add_action( 'comment_form', 'comment_form_lockdown_message' );
316
 
317
  function wp_lock_down() {
318
- global $wpdb, $cache_path, $wp_cache_config_file, $valid_nonce, $cached_direct_pages;
319
 
320
  if(isset($_POST['wp_lock_down']) && $valid_nonce) {
321
  $wp_lock_down = $_POST['wp_lock_down'] == '1' ? '1' : '0';
@@ -331,8 +352,8 @@ function wp_lock_down() {
331
  $wp_lock_down = '0';
332
  }
333
  }
334
- ?><br /><fieldset style='border: 1px solid #aaa' class="options">
335
- <legend>Lock Down: <span style='color: #f00'><?php echo $wp_lock_down == '0' ? 'disabled' : 'enabled'; ?></span></legend>
336
  <p>Prepare your server for an expected spike in traffic by enabling the lock down. When this is enabled, new comments on a post will not refresh the cached static files.</p>
337
  <p>Developers: Make your plugin lock down compatible by checking the 'WPLOCKDOWN' constant. The following code will make sure your plugin respects the WPLOCKDOWN setting.
338
  <blockquote><code>if( defined( 'WPLOCKDOWN' ) && constant( 'WPLOCKDOWN' ) ) { <br />
@@ -348,11 +369,12 @@ function wp_lock_down() {
348
  $new_lockdown_desc = $wp_lock_down == '1' ? 'Disable' : 'Enable';
349
  echo '<form name="wp_lock_down" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
350
  echo "<input type='hidden' name='wp_lock_down' value='{$new_lockdown}' />";
351
- echo "<div class='submit'><input type='submit' value='{$new_lockdown_desc} Lock Down &raquo;' /></div>";
352
  wp_nonce_field('wp-cache');
353
  echo "</form>\n";
354
 
355
  ?></fieldset><br /><?php
 
356
  ?><fieldset style='border: 1px solid #aaa' class="options">
357
  <legend>Directly Cached Files (advanced use only)</legend><?php
358
 
@@ -395,7 +417,8 @@ function wp_lock_down() {
395
  $firstfolder = explode( '/', $file );
396
  $firstfolder = ABSPATH . $firstfolder[1];
397
  $file = ABSPATH . $file;
398
- unlink( trailingslashit( $file ) . 'index.html' );
 
399
  RecursiveFolderDelete( trailingslashit( $firstfolder ) );
400
  }
401
  }
@@ -408,7 +431,8 @@ function wp_lock_down() {
408
  $firstfolder = ABSPATH . $firstfolder[1];
409
  $page = ABSPATH . $page;
410
  if( is_file( $pagefile ) && is_writable( $pagefile ) && is_writable( $firstfolder ) ) {
411
- unlink( $pagefile );
 
412
  RecursiveFolderDelete( $firstfolder );
413
  echo "<strong>$pagefile removed!</strong><br />";
414
  prune_super_cache( $cache_path, true );
@@ -449,9 +473,10 @@ function wp_lock_down() {
449
 
450
  wp_nonce_field('wp-cache');
451
  if( $readonly != 'READONLY' )
452
- echo "<div class='submit'><input type='submit' value='Update direct pages &raquo;' /></div>";
453
  echo "</form>\n";
454
  ?></fieldset><?php
 
455
  }
456
 
457
  function RecursiveFolderDelete ( $folderPath ) { // from http://www.php.net/manual/en/function.rmdir.php
@@ -474,7 +499,7 @@ function RecursiveFolderDelete ( $folderPath ) { // from http://www.php.net/manu
474
  }
475
 
476
  function wp_cache_edit_max_time () {
477
- global $super_cache_max_time, $cache_max_time, $wp_cache_config_file, $valid_nonce;
478
 
479
  if( !isset( $super_cache_max_time ) )
480
  $super_cache_max_time = 21600;
@@ -498,9 +523,11 @@ function wp_cache_edit_max_time () {
498
  echo '<form name="wp_edit_max_time" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
499
  echo '<label for="wp_max_time">Expire time:</label> ';
500
  echo "<input type=\"text\" size=6 name=\"wp_max_time\" value=\"$cache_max_time\" /> seconds<br />";
501
- echo '<label for="super_cache_max_time">Super Cache Expire time:</label> ';
502
- echo "<input type=\"text\" size=6 name=\"super_cache_max_time\" value=\"$super_cache_max_time\" /> seconds";
503
- echo '<div class="submit"><input type="submit" value="Change expiration &raquo;" /></div>';
 
 
504
  wp_nonce_field('wp-cache');
505
  echo "</form>\n";
506
  ?></fieldset><?php
@@ -536,7 +563,7 @@ function wp_cache_edit_rejected_ua() {
536
  echo wp_specialchars($ua) . "\n";
537
  }
538
  echo '</textarea> ';
539
- echo '<div class="submit"><input type="submit" value="Save UA strings &raquo;" /></div>';
540
  wp_nonce_field('wp-cache');
541
  echo '</form>';
542
  echo "</fieldset>\n";
@@ -552,7 +579,7 @@ function wp_cache_edit_rejected() {
552
  }
553
 
554
 
555
- echo "<p>Add here strings (not a filename) that forces a page not to be cached. For example, if your URLs include year and you dont want to cache last year posts, it's enough to specify the year, i.e. '/2004/'. WP-Cache will search if that string is part of the URI and if so, it will no cache that page.</p>\n";
556
  echo '<form name="wp_edit_rejected" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
557
  echo '<label for="wp_rejected_uri">Rejected URIs</label>';
558
  echo '<textarea name="wp_rejected_uri" cols="40" rows="4" style="width: 70%; font-size: 12px;" class="code">';
@@ -560,7 +587,7 @@ function wp_cache_edit_rejected() {
560
  echo wp_specialchars($file) . "\n";
561
  }
562
  echo '</textarea> ';
563
- echo '<div class="submit"><input type="submit" value="Save strings &raquo;" /></div>';
564
  wp_nonce_field('wp-cache');
565
  echo "</form>\n";
566
  }
@@ -582,7 +609,7 @@ function wp_cache_edit_accepted() {
582
  echo wp_specialchars($file) . "\n";
583
  }
584
  echo '</textarea> ';
585
- echo '<div class="submit"><input type="submit" value=" &raquo;Save files &raquo;" /></div>';
586
  wp_nonce_field('wp-cache');
587
  echo "</form>\n";
588
  }
@@ -601,12 +628,16 @@ function wp_cache_enable() {
601
  }
602
 
603
  function wp_cache_disable() {
604
- global $wp_cache_config_file, $cache_enabled, $supercachedir, $cache_path;
605
 
606
  if (wp_cache_replace_line('^ *\$cache_enabled', '$cache_enabled = false;', $wp_cache_config_file)) {
607
  $cache_enabled = false;
608
  }
609
  wp_super_cache_disable();
 
 
 
 
610
  }
611
  function wp_super_cache_enable() {
612
  global $supercachedir, $wp_cache_config_file, $super_cache_enabled;
@@ -624,10 +655,6 @@ function wp_super_cache_disable() {
624
  if( is_dir( $supercachedir ) )
625
  rename( $supercachedir, $supercachedir . ".disabled" );
626
  $super_cache_enabled = false;
627
- sleep( 1 ); // allow existing processes to write to the supercachedir and then delete it
628
- if (function_exists ('prune_super_cache') && is_dir( $supercachedir ) ) {
629
- prune_super_cache( $supercachedir, true );
630
- }
631
  }
632
 
633
  function wp_cache_is_enabled() {
@@ -720,10 +747,6 @@ function wp_cache_verify_config_file() {
720
  $new = false;
721
  $dir = dirname($wp_cache_config_file);
722
 
723
- if ( !is_writable($dir)) {
724
- echo "<b>Error:</b> wp-content directory (<b>$dir</b>) is not writable by the Web server.<br />Check its permissions.";
725
- return false;
726
- }
727
  if ( file_exists($wp_cache_config_file) ) {
728
  $lines = join( ' ', file( $wp_cache_config_file ) );
729
  if( strpos( $lines, 'WPCACHEHOME' ) === false ) {
@@ -734,6 +757,9 @@ function wp_cache_verify_config_file() {
734
  return false;
735
  }
736
  }
 
 
 
737
  }
738
 
739
  if ( !file_exists($wp_cache_config_file) ) {
@@ -749,10 +775,6 @@ function wp_cache_verify_config_file() {
749
  }
750
  $new = true;
751
  }
752
- if ( !is_writable($wp_cache_config_file)) {
753
- echo "<b>Error:</b> Your WP-Cache config file (<b>$wp_cache_config_file</b>) is not writable by the Web server.<br />Check its permissions.";
754
- return false;
755
- }
756
  require($wp_cache_config_file);
757
  return true;
758
  }
@@ -810,7 +832,7 @@ function wp_cache_check_global_config() {
810
  }
811
 
812
  function wp_cache_files() {
813
- global $cache_path, $file_prefix, $cache_max_time, $super_cache_max_time, $valid_nonce, $supercachedir;
814
 
815
  if ( '/' != substr($cache_path, -1)) {
816
  $cache_path .= '/';
@@ -834,11 +856,14 @@ function wp_cache_files() {
834
  $list_mess = "List files";
835
 
836
  echo '<br /><a name="list"></a><fieldset style="border: 1px solid #aaa" class="options"><legend>Cache contents</legend>';
 
837
  echo '<form name="wp_cache_content_list" action="'. $_SERVER["REQUEST_URI"] . '#list" method="post">';
838
  echo '<input type="hidden" name="wp_list_cache" />';
839
- echo '<div class="submit"><input type="submit" value="'.$list_mess.' &raquo;" /></div>';
840
  echo "</form>\n";
 
841
 
 
842
  $count = 0;
843
  $expired = 0;
844
  $now = time();
@@ -871,7 +896,7 @@ function wp_cache_files() {
871
  echo '<td><form name="wp_delete_cache_file" action="'. $_SERVER["REQUEST_URI"] . '#list" method="post">';
872
  echo '<input type="hidden" name="wp_list_cache" />';
873
  echo '<input type="hidden" name="wp_delete_cache_file" value="'.preg_replace("/^(.*)\.meta$/", "$1", $file).'" />';
874
- echo '<div class="submit"><input id="deletepost" type="submit" value="Remove" /></div>';
875
  wp_nonce_field('wp-cache');
876
  echo "</form></td></tr>\n";
877
  }
@@ -880,12 +905,8 @@ function wp_cache_files() {
880
  closedir($handle);
881
  if ($list_files) echo "</table>";
882
  }
883
- $sizes = get_option( 'super_cache_meta' );
884
- if( !$sizes )
885
- $sizes = array( 'expired' => 0, 'cached' => 0, 'ts' => 0 );
886
-
887
- $now = time();
888
- if( $_POST[ 'super_cache_stats' ] == 1 || $sizes[ 'cached' ] == 0 || $sizes[ 'ts' ] + 3600 <= $now ) {
889
  $sizes = array( 'expired' => 0, 'cached' => 0, 'ts' => 0 );
890
 
891
  if (is_dir($supercachedir)) {
@@ -900,35 +921,31 @@ function wp_cache_files() {
900
  $sizes[ 'expired' ] ++;
901
  }
902
  $sizes[ 'ts' ] = time();
903
- update_option( 'super_cache_meta', $sizes );
904
  }
 
905
  echo "<p><strong>WP-Cache</strong></p>";
906
  echo "<ul><li>$count cached pages</li>";
907
  echo "<li>$expired expired pages</li></ul>";
908
- echo "<p><strong>WP-Super-Cache</strong></p>";
909
- echo "<ul><li>" . intval($sizes['cached']/2) . " cached pages</li>";
910
- $age = intval(($now - $sizes['ts'])/60);
911
- echo "<li>" . intval($sizes['expired']/2) . " expired pages. (Generated $age minutes ago. Refresh in " . (60 - $age) . " minutes. )</li></ul>";
 
 
912
 
913
  echo '<form name="wp_cache_content_expired" action="'. $_SERVER["REQUEST_URI"] . '#list" method="post">';
914
  echo '<input type="hidden" name="wp_delete_expired" />';
915
- echo '<div class="submit"><input type="submit" value="Delete expired &raquo;" /></div>';
916
  wp_nonce_field('wp-cache');
917
  echo "</form>\n";
918
 
919
 
920
  echo '<form name="wp_cache_content_delete" action="'. $_SERVER["REQUEST_URI"] . '#list" method="post">';
921
  echo '<input type="hidden" name="wp_delete_cache" />';
922
- echo '<div class="submit"><input id="deletepost" type="submit" value="Delete cache &raquo;" /></div>';
923
-
924
  wp_nonce_field('wp-cache');
925
  echo "</form>\n";
926
 
927
- echo '<form name="wp_super_cache_stats" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
928
- echo '<input type="hidden" name="super_cache_stats" value="1" />';
929
- echo '<div class="submit"><input type="submit" value="Regenerate Super Cache Stats &raquo;" /></div>';
930
- wp_nonce_field('wp-cache');
931
- echo "</form>\n";
932
  echo '</fieldset>';
933
  }
934
 
@@ -1018,6 +1035,38 @@ function wp_cache_clean_expired($file_prefix) {
1018
 
1019
  add_action('admin_menu', 'wp_cache_add_pages');
1020
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1021
  function wp_super_cache_footer() {
1022
  ?><p><?php bloginfo('name'); ?> is Digg proof thanks to caching by <a href="http://ocaoimh.ie/wp-super-cache/">WP Super Cache</a>!</p><?php
1023
  }
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.2
7
  Author: Donncha O Caoimh
8
  Author URI: http://ocaoimh.ie/
9
  */
10
  /* Copyright 2005-2006 Ricardo Galli Granada (email : gallir@uib.es)
11
+ Some code copyright 2007-2008 Donncha O Caoimh (http://ocaoimh.ie/)
12
 
13
  This program is free software; you can redistribute it and/or modify
14
  it under the terms of the GNU General Public License as published by
75
  if( get_option( 'gzipcompression' ) == 1 )
76
  update_option( 'gzipcompression', 0 );
77
  $valid_nonce = wp_verify_nonce($_REQUEST['_wpnonce'], 'wp-cache');
78
+ /* http://www.netlobo.com/div_hiding.html */
79
+ ?>
80
+ <script type='text/javascript'>
81
+ <!--
82
+ function toggleLayer( whichLayer ) {
83
+ var elem, vis;
84
+ if( document.getElementById ) // this is the way the standards work
85
+ elem = document.getElementById( whichLayer );
86
+ else if( document.all ) // this is the way old msie versions work
87
+ elem = document.all[whichLayer];
88
+ else if( document.layers ) // this is the way nn4 works
89
+ elem = document.layers[whichLayer];
90
+ vis = elem.style;
91
+ // if the style.display value is blank we try to figure it out here
92
+ if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
93
+ vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
94
+ vis.display = (vis.display==''||vis.display=='block')?'none':'block';
95
+ }
96
+ // -->
97
+ </script>
98
+ <?php
99
  echo '<div class="wrap">';
100
  echo "<h2>WP Super Cache Manager</h2>\n";
101
  if( ini_get( 'safe_mode' ) ) {
125
  return;
126
  }
127
 
128
+ if( $cache_enabled == true && $super_cache_enabled == true && !got_mod_rewrite() ) {
129
  ?><h4 style='color: #a00'>Mod rewrite may not be installed!</h4>
130
  <p>It appears that mod_rewrite is not installed. Sometimes this check isn't 100% reliable, especially if you are not using Apache. Please verify that the mod_rewrite module is loaded. It is required for serving Super Cache static files. You will still be able to use WP-Cache.</p><?php
131
  }
132
 
133
+ if( !is_writeable( ABSPATH . 'wp-content/' ) || !is_writable($wp_cache_config_file) ) {
134
+ define( "SUBMITDISABLED", 'disabled style="color: #aaa" ' );
135
+ ?><h4 style='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>
136
+ <div id='readonlywarning' style='border: 1px solid #aaa; margin: 2px; padding: 2px; display: none;'>
137
+ <p>The WP Super Cache configuration file is <code><?php echo ABSPATH ?>wp-content/wp-cache-config.php</code> and cannot be modified. The wp-content directory and wp-cache-config.php file must be writeable by the webserver to make any changes.<br />
138
+ 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 />
139
+ Writeable: <code>chmod 777 wp-content; chmod 666 wp-content/wp-cache-config.php</code><br />
140
+ Readonly: <code>chmod 755 wp-content; chmod 644 wp-content/wp-cache-config.php</code></p>
141
+ </div><?php
142
+ } else {
143
+ define( "SUBMITDISABLED", ' ' );
144
  }
145
 
146
  if ( $valid_nonce ) {
178
  <legend>WP Super Cache Status</legend><?php
179
  echo '<form name="wp_manager" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
180
  ?>
181
+ <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 />
182
+ <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 />
183
+ <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 />
184
  <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>
185
  <?php
186
+ echo "<div class='submit'><input " . SUBMITDISABLED . "type='submit' value='Update Status &raquo;' /></div>";
187
  wp_nonce_field('wp-cache');
188
  ?>
189
  </form>
190
+ </fieldset>
191
 
192
+ <?php if( $cache_enabled == true && $super_cache_enabled == true ) { ?>
193
+ <br /><fieldset style='border: 1px solid #aaa' class="options">
194
  <legend>Super Cache Compression</legend>
195
  <form name="wp_manager" action="<?php echo $_SERVER["REQUEST_URI"]; ?>" method="post">
196
  <label><input type="radio" name="cache_compression" value="1" <?php if( $cache_compression ) { echo "checked=checked"; } ?>> Enabled</label>
202
  } elseif( isset( $cache_compression_changed ) && isset( $_POST[ 'cache_compression' ] ) && $cache_compression ) {
203
  ?><p><strong>Super Cache compression is now enabled.</strong></p><?php
204
  }
205
+ echo '<div class="submit"><input ' . SUBMITDISABLED . 'type="submit" value="Update Compression &raquo;" /></div>';
206
  wp_nonce_field('wp-cache');
207
  echo "</form>\n";
208
  ?></fieldset><br />
215
  $wprules = implode( "\n", extract_from_markers( $home_path.'.htaccess', 'WordPress' ) );
216
  $wprules = str_replace( "RewriteEngine On\n", '', $wprules );
217
  $wprules = str_replace( "RewriteBase $home_root\n", '', $wprules );
218
+ $scrules = implode( "\n", extract_from_markers( $home_path.'.htaccess', 'WPSuperCache' ) );
219
 
220
+ $dohtaccess = true;
221
  if( !$wprules || $wprules == '' ) {
222
+ echo "<h4 style='color: #a00'>Mod Rewrite rules cannot be updated!</h4>";
223
  echo "<p>You must have <strong>BEGIN</strong> and <strong>END</strong> markers in {$home_path}.htaccess for the auto update to work. They look like this and surround the main WordPress mod_rewrite rules:
224
  <blockquote><code><em># BEGIN WordPress</em><br /> RewriteCond %{REQUEST_FILENAME} !-f<br /> RewriteCond %{REQUEST_FILENAME} !-d<br /> RewriteRule . /index.php [L]<br /> <em># END WordPress</em></code></blockquote>
225
+ Refresh this page when you have updated your .htaccess file.";
226
+ } elseif( strpos( $wprules, 'wordpressuser' ) ) { // Need to clear out old mod_rewrite rules
227
+ echo "<p><strong>Thank you for upgrading.</strong> The mod_rewrite rules changed since you last installed this plugin. Unfortunately you must remove the old supercache rules before the new ones are updated. Refresh this page when you have edited your .htaccess file. If you wish to manually upgrade, change the following line: <blockquote><code>RewriteCond %{HTTP_COOKIE} !^.*wordpressuser.*\$</code></blockquote> so it looks like this: <blockquote><code>RewriteCond %{HTTP_COOKIE} !^.*wordpress.*\$</code></blockquote> The only change is 'wordpressuser' becomes 'wordpress'. This is a WordPress 2.5 change but it's backwards compatible with older versions if you're brave enough to use them.</p>";
228
+ echo "</fieldset>";
229
+ echo "</div>\n";
230
+ return;
231
+ } elseif( strpos( $scrules, 'supercache' ) || strpos( $wprules, 'supercache' ) ) { // only write the rules once
232
+ $dohtaccess = false;
233
  }
234
  $rules = "<IfModule mod_rewrite.c>\n";
235
  $rules .= "RewriteEngine On\n";
236
  $rules .= "RewriteBase $home_root\n"; // props Chris Messina
237
  $rules .= "RewriteCond %{QUERY_STRING} !.*s=.*\n";
238
+ $rules .= "RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$\n";
 
 
239
  $rules .= "RewriteCond %{HTTP:Accept-Encoding} gzip\n";
240
+ $rules .= "RewriteCond %{DOCUMENT_ROOT}{$home_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html.gz -f\n";
241
+ $rules .= "RewriteRule ^(.*) {$home_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html.gz [L]\n\n";
242
 
243
  $rules .= "RewriteCond %{QUERY_STRING} !.*s=.*\n";
244
+ $rules .= "RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$\n";
245
+ $rules .= "RewriteCond %{DOCUMENT_ROOT}{$home_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html -f\n";
246
+ $rules .= "RewriteRule ^(.*) {$home_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html [L]\n";
247
+ $rules .= "</IfModule>\n";
248
+ if( $dohtaccess && !$_POST[ 'updatehtaccess' ] ) {
249
+ 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.";
250
+ echo "<pre>" . wp_specialchars( $rules ) . "</pre></p>";
251
+ echo '<form name="updatehtaccess" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
252
+ echo '<input type="hidden" name="updatehtaccess" value="1" />';
253
+ echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'id="updatehtaccess" value="Update mod_rewrite rules &raquo;" /></div>';
254
+ wp_nonce_field('wp-cache');
255
+ echo "</form>\n";
256
+ } elseif( $dohtaccess && $valid_nonce && $_POST[ 'updatehtaccess' ] ) {
257
+ wpsc_remove_marker( $home_path.'.htaccess', 'WordPress' ); // remove original WP rules so SuperCache rules go on top
258
+ if( insert_with_markers( $home_path.'.htaccess', 'WPSuperCache', explode( "\n", $rules ) ) && insert_with_markers( $home_path.'.htaccess', 'WordPress', explode( "\n", $wprules ) ) ) {
259
  echo "<h4>Mod Rewrite rules updated!</h4>";
260
+ 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";
261
  } else {
262
  echo "<h4>Mod Rewrite rules must be updated!</h4>";
263
  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";
264
  }
265
+ echo "<p><pre>" . wp_specialchars( $rules ) . "</pre></p>\n";
266
  } else {
 
 
267
  ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
268
  <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>
269
  <div id='rewriterules' style='display: none;'>
270
+ <?php echo "<p><pre>" . wp_specialchars( $rules ) . "</pre></p>\n"; ?>
271
  </div>
272
  <?php
273
  }
281
 
282
  ?></fieldset><?php
283
 
284
+ } // if $super_cache_enabled
285
+
286
  wp_cache_edit_max_time();
287
 
288
  echo '<br /><a name="files"></a><fieldset style="border: 1px solid #aaa" class="options"><legend>Accepted filenames, rejected URIs</legend>';
293
 
294
  wp_cache_edit_rejected_ua();
295
 
 
296
 
297
  wp_cache_files();
298
 
299
+ wp_lock_down();
300
+
301
  wp_cache_restore();
302
 
303
  ob_start();
308
  }
309
  $out = ob_get_contents();
310
  ob_end_clean();
311
+ if( SUBMITDISABLED == ' ' && $out != '' ) {
312
  echo '<fieldset class="options"><legend>Cache Plugins</legend>';
313
  echo $out;
314
  echo '</fieldset>';
322
  echo '<br /><fieldset style="border: 1px solid #aaa" class="options"><legend>Configuration messed up?</legend>';
323
  echo '<form name="wp_restore" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
324
  echo '<input type="hidden" name="wp_restore_config" />';
325
+ echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'id="deletepost" value="Restore default configuration &raquo;" /></div>';
326
  wp_nonce_field('wp-cache');
327
  echo "</form>\n";
328
  echo '</fieldset>';
336
  add_action( 'comment_form', 'comment_form_lockdown_message' );
337
 
338
  function wp_lock_down() {
339
+ global $wpdb, $cache_path, $wp_cache_config_file, $valid_nonce, $cached_direct_pages, $cache_enabled, $super_cache_enabled;
340
 
341
  if(isset($_POST['wp_lock_down']) && $valid_nonce) {
342
  $wp_lock_down = $_POST['wp_lock_down'] == '1' ? '1' : '0';
352
  $wp_lock_down = '0';
353
  }
354
  }
355
+ ?><br /><br /><fieldset style='border: 1px solid #aaa' class="options">
356
+ <legend>Lock Down: <span style='color: #f00'><?php echo $wp_lock_down == '0' ? 'disabled' : 'enabled'; ?></span> (advanced use only)</legend>
357
  <p>Prepare your server for an expected spike in traffic by enabling the lock down. When this is enabled, new comments on a post will not refresh the cached static files.</p>
358
  <p>Developers: Make your plugin lock down compatible by checking the 'WPLOCKDOWN' constant. The following code will make sure your plugin respects the WPLOCKDOWN setting.
359
  <blockquote><code>if( defined( 'WPLOCKDOWN' ) && constant( 'WPLOCKDOWN' ) ) { <br />
369
  $new_lockdown_desc = $wp_lock_down == '1' ? 'Disable' : 'Enable';
370
  echo '<form name="wp_lock_down" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
371
  echo "<input type='hidden' name='wp_lock_down' value='{$new_lockdown}' />";
372
+ echo "<div class='submit'><input type='submit' " . SUBMITDISABLED . "value='{$new_lockdown_desc} Lock Down &raquo;' /></div>";
373
  wp_nonce_field('wp-cache');
374
  echo "</form>\n";
375
 
376
  ?></fieldset><br /><?php
377
+ if( $cache_enabled == true && $super_cache_enabled == true ) {
378
  ?><fieldset style='border: 1px solid #aaa' class="options">
379
  <legend>Directly Cached Files (advanced use only)</legend><?php
380
 
417
  $firstfolder = explode( '/', $file );
418
  $firstfolder = ABSPATH . $firstfolder[1];
419
  $file = ABSPATH . $file;
420
+ @unlink( trailingslashit( $file ) . 'index.html' );
421
+ @unlink( trailingslashit( $file ) . 'index.html.gz' );
422
  RecursiveFolderDelete( trailingslashit( $firstfolder ) );
423
  }
424
  }
431
  $firstfolder = ABSPATH . $firstfolder[1];
432
  $page = ABSPATH . $page;
433
  if( is_file( $pagefile ) && is_writable( $pagefile ) && is_writable( $firstfolder ) ) {
434
+ @unlink( $pagefile );
435
+ @unlink( $pagefile . '.gz' );
436
  RecursiveFolderDelete( $firstfolder );
437
  echo "<strong>$pagefile removed!</strong><br />";
438
  prune_super_cache( $cache_path, true );
473
 
474
  wp_nonce_field('wp-cache');
475
  if( $readonly != 'READONLY' )
476
+ echo "<div class='submit'><input type='submit' ' . SUBMITDISABLED . 'value='Update direct pages &raquo;' /></div>";
477
  echo "</form>\n";
478
  ?></fieldset><?php
479
+ } // if $super_cache_enabled
480
  }
481
 
482
  function RecursiveFolderDelete ( $folderPath ) { // from http://www.php.net/manual/en/function.rmdir.php
499
  }
500
 
501
  function wp_cache_edit_max_time () {
502
+ global $super_cache_max_time, $cache_max_time, $wp_cache_config_file, $valid_nonce, $cache_enabled, $super_cache_enabled;
503
 
504
  if( !isset( $super_cache_max_time ) )
505
  $super_cache_max_time = 21600;
523
  echo '<form name="wp_edit_max_time" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
524
  echo '<label for="wp_max_time">Expire time:</label> ';
525
  echo "<input type=\"text\" size=6 name=\"wp_max_time\" value=\"$cache_max_time\" /> seconds<br />";
526
+ if( $cache_enabled == true && $super_cache_enabled == true ) {
527
+ echo '<label for="super_cache_max_time">Super Cache Expire time:</label> ';
528
+ echo "<input type=\"text\" size=6 name=\"super_cache_max_time\" value=\"$super_cache_max_time\" /> seconds";
529
+ }
530
+ echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="Change expiration &raquo;" /></div>';
531
  wp_nonce_field('wp-cache');
532
  echo "</form>\n";
533
  ?></fieldset><?php
563
  echo wp_specialchars($ua) . "\n";
564
  }
565
  echo '</textarea> ';
566
+ echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="Save UA strings &raquo;" /></div>';
567
  wp_nonce_field('wp-cache');
568
  echo '</form>';
569
  echo "</fieldset>\n";
579
  }
580
 
581
 
582
+ echo "<p>Add here strings (not a filename) that forces a page not to be cached. For example, if your URLs include year and you dont want to cache last year posts, it's enough to specify the year, i.e. '/2004/'. WP-Cache will search if that string is part of the URI and if so, it will not cache that page.</p>\n";
583
  echo '<form name="wp_edit_rejected" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
584
  echo '<label for="wp_rejected_uri">Rejected URIs</label>';
585
  echo '<textarea name="wp_rejected_uri" cols="40" rows="4" style="width: 70%; font-size: 12px;" class="code">';
587
  echo wp_specialchars($file) . "\n";
588
  }
589
  echo '</textarea> ';
590
+ echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="Save strings &raquo;" /></div>';
591
  wp_nonce_field('wp-cache');
592
  echo "</form>\n";
593
  }
609
  echo wp_specialchars($file) . "\n";
610
  }
611
  echo '</textarea> ';
612
+ echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="Save files &raquo;" /></div>';
613
  wp_nonce_field('wp-cache');
614
  echo "</form>\n";
615
  }
628
  }
629
 
630
  function wp_cache_disable() {
631
+ global $cache_path, $wp_cache_config_file, $cache_enabled, $supercachedir, $cache_path;
632
 
633
  if (wp_cache_replace_line('^ *\$cache_enabled', '$cache_enabled = false;', $wp_cache_config_file)) {
634
  $cache_enabled = false;
635
  }
636
  wp_super_cache_disable();
637
+ sleep( 1 ); // allow existing processes to write to the supercachedir and then delete it
638
+ if (function_exists ('prune_super_cache') && is_dir( $supercachedir ) ) {
639
+ prune_super_cache( $cache_path, true );
640
+ }
641
  }
642
  function wp_super_cache_enable() {
643
  global $supercachedir, $wp_cache_config_file, $super_cache_enabled;
655
  if( is_dir( $supercachedir ) )
656
  rename( $supercachedir, $supercachedir . ".disabled" );
657
  $super_cache_enabled = false;
 
 
 
 
658
  }
659
 
660
  function wp_cache_is_enabled() {
747
  $new = false;
748
  $dir = dirname($wp_cache_config_file);
749
 
 
 
 
 
750
  if ( file_exists($wp_cache_config_file) ) {
751
  $lines = join( ' ', file( $wp_cache_config_file ) );
752
  if( strpos( $lines, 'WPCACHEHOME' ) === false ) {
757
  return false;
758
  }
759
  }
760
+ } elseif( !is_writable($dir)) {
761
+ 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.";
762
+ return false;
763
  }
764
 
765
  if ( !file_exists($wp_cache_config_file) ) {
775
  }
776
  $new = true;
777
  }
 
 
 
 
778
  require($wp_cache_config_file);
779
  return true;
780
  }
832
  }
833
 
834
  function wp_cache_files() {
835
+ global $cache_path, $file_prefix, $cache_max_time, $super_cache_max_time, $valid_nonce, $supercachedir, $cache_enabled, $super_cache_enabled;
836
 
837
  if ( '/' != substr($cache_path, -1)) {
838
  $cache_path .= '/';
856
  $list_mess = "List files";
857
 
858
  echo '<br /><a name="list"></a><fieldset style="border: 1px solid #aaa" class="options"><legend>Cache contents</legend>';
859
+ /*
860
  echo '<form name="wp_cache_content_list" action="'. $_SERVER["REQUEST_URI"] . '#list" method="post">';
861
  echo '<input type="hidden" name="wp_list_cache" />';
862
+ echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="'.$list_mess.' &raquo;" /></div>';
863
  echo "</form>\n";
864
+ */
865
 
866
+ $list_files = false; // it doesn't list supercached files, and removing single pages is buggy
867
  $count = 0;
868
  $expired = 0;
869
  $now = time();
896
  echo '<td><form name="wp_delete_cache_file" action="'. $_SERVER["REQUEST_URI"] . '#list" method="post">';
897
  echo '<input type="hidden" name="wp_list_cache" />';
898
  echo '<input type="hidden" name="wp_delete_cache_file" value="'.preg_replace("/^(.*)\.meta$/", "$1", $file).'" />';
899
+ echo '<div class="submit"><input id="deletepost" ' . SUBMITDISABLED . 'type="submit" value="Remove" /></div>';
900
  wp_nonce_field('wp-cache');
901
  echo "</form></td></tr>\n";
902
  }
905
  closedir($handle);
906
  if ($list_files) echo "</table>";
907
  }
908
+ if( $cache_enabled == true && $super_cache_enabled == true ) {
909
+ $now = time();
 
 
 
 
910
  $sizes = array( 'expired' => 0, 'cached' => 0, 'ts' => 0 );
911
 
912
  if (is_dir($supercachedir)) {
921
  $sizes[ 'expired' ] ++;
922
  }
923
  $sizes[ 'ts' ] = time();
 
924
  }
925
+
926
  echo "<p><strong>WP-Cache</strong></p>";
927
  echo "<ul><li>$count cached pages</li>";
928
  echo "<li>$expired expired pages</li></ul>";
929
+ if( $cache_enabled == true && $super_cache_enabled == true ) {
930
+ echo "<p><strong>WP-Super-Cache</strong></p>";
931
+ echo "<ul><li>" . intval($sizes['cached']/2) . " cached pages</li>";
932
+ $age = intval(($now - $sizes['ts'])/60);
933
+ echo "<li>" . intval($sizes['expired']/2) . " expired pages.</li></ul>";
934
+ }
935
 
936
  echo '<form name="wp_cache_content_expired" action="'. $_SERVER["REQUEST_URI"] . '#list" method="post">';
937
  echo '<input type="hidden" name="wp_delete_expired" />';
938
+ echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="Delete expired &raquo;" /></div>';
939
  wp_nonce_field('wp-cache');
940
  echo "</form>\n";
941
 
942
 
943
  echo '<form name="wp_cache_content_delete" action="'. $_SERVER["REQUEST_URI"] . '#list" method="post">';
944
  echo '<input type="hidden" name="wp_delete_cache" />';
945
+ echo '<div class="submit"><input id="deletepost" type="submit" ' . SUBMITDISABLED . 'value="Delete cache &raquo;" /></div>';
 
946
  wp_nonce_field('wp-cache');
947
  echo "</form>\n";
948
 
 
 
 
 
 
949
  echo '</fieldset>';
950
  }
951
 
1035
 
1036
  add_action('admin_menu', 'wp_cache_add_pages');
1037
 
1038
+ function wpsc_remove_marker( $filename, $marker ) {
1039
+ if (!file_exists( $filename ) || is_writeable( $filename ) ) {
1040
+ if (!file_exists( $filename ) ) {
1041
+ return '';
1042
+ } else {
1043
+ $markerdata = explode( "\n", implode( '', file( $filename ) ) );
1044
+ }
1045
+
1046
+ $f = fopen( $filename, 'w' );
1047
+ $foundit = false;
1048
+ if ( $markerdata ) {
1049
+ $state = true;
1050
+ foreach ( $markerdata as $n => $markerline ) {
1051
+ if (strpos($markerline, '# BEGIN ' . $marker) !== false)
1052
+ $state = false;
1053
+ if ( $state ) {
1054
+ if ( $n + 1 < count( $markerdata ) )
1055
+ fwrite( $f, "{$markerline}\n" );
1056
+ else
1057
+ fwrite( $f, "{$markerline}" );
1058
+ }
1059
+ if (strpos($markerline, '# END ' . $marker) !== false) {
1060
+ $state = true;
1061
+ }
1062
+ }
1063
+ }
1064
+ return true;
1065
+ } else {
1066
+ return false;
1067
+ }
1068
+ }
1069
+
1070
  function wp_super_cache_footer() {
1071
  ?><p><?php bloginfo('name'); ?> is Digg proof thanks to caching by <a href="http://ocaoimh.ie/wp-super-cache/">WP Super Cache</a>!</p><?php
1072
  }