WP Super Cache - Version 0.9.7

Version Description

  • Fixed problem with blogs in folders.
  • Added cache file listing and delete links to admin page.
  • Added "Newest Cached Pages" listing in sidebox.
  • Made admin page translatable.
  • Added "How do I make certain parts of the page stay dynamic?" to FAQ.
  • Advanced: added "late init" feature so that plugin activates on "init". Set $wp_super_cache_late_init to true in config file to use.
  • Disable supercaching when GET parameters present instead of disabling all caching. Disable on POST (as normal) and preview.
  • Fixed problem with cron job and mutex filename.
  • Warn users they must enable mobile device support if rewrite rules detected. Better detection of when to warn that .htaccess rules must be updated (no need when rewrite rules not present)
  • Advanced: Added "wpsupercache_404" filter. Return true to cache 404 error pages.
  • Use the wordpress_test_cookie in the cache key.
  • Show correct number of cache files when compression off.
  • Fixed problem with PHP safe_mode detection.
  • Various bugfixes and documentation updates. See Changelog.txt
Download this release

Release Info

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

Code changes from version 0.9.6.1 to 0.9.7

Files changed (7) hide show
  1. Changelog.txt +267 -0
  2. readme.txt +51 -5
  3. wp-cache-config-sample.php +2 -4
  4. wp-cache-phase1.php +112 -47
  5. wp-cache-phase2.php +167 -33
  6. wp-cache.php +434 -237
  7. wp-super-cache.pot +1095 -0
Changelog.txt CHANGED
@@ -1,3 +1,270 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  2009-07-29 17:26 donncha
2
 
3
  * readme.txt, wp-cache.php: Bump version to 0.9.6.1
1
+ 2009-10-02 21:40 donncha
2
+
3
+ * readme.txt, wp-cache.php: Bump version to 0.9.7
4
+
5
+ 2009-10-02 21:39 donncha
6
+
7
+ * Changelog.txt: Updated changelog
8
+
9
+ 2009-10-02 21:34 donncha
10
+
11
+ * wp-cache-phase2.php: Don't show "blank page", "404 not cached" or
12
+ "no html tag" warnings on output unless debugging enabled.
13
+
14
+ 2009-10-02 19:45 donncha
15
+
16
+ * Changelog.txt, readme.txt: Updated changelog and readme.txt
17
+ changes
18
+
19
+ 2009-10-02 13:14 donncha
20
+
21
+ * wp-super-cache.pot: Updated POT file
22
+
23
+ 2009-10-02 13:09 donncha
24
+
25
+ * wp-cache.php: Minor text change to bio text
26
+
27
+ 2009-10-01 20:47 donncha
28
+
29
+ * wp-cache-phase2.php, wp-cache.php: Added more debugging, on cache
30
+ cleanup
31
+
32
+ 2009-10-01 20:26 donncha
33
+
34
+ * wp-cache.php: Sort the file listing by newest first.
35
+ Hide a filemtime warning, props @reverbstudios
36
+
37
+ 2009-10-01 19:57 donncha
38
+
39
+ * wp-cache-phase1.php: Load wp-cache-phase2.php all the time
40
+
41
+ 2009-10-01 17:50 donncha
42
+
43
+ * readme.txt: Added "How do I make certain parts of the page stay
44
+ dynamic?" to FAQ
45
+
46
+ 2009-09-30 09:51 donncha
47
+
48
+ * wp-cache.php: Sort the stale from the fresh wp-cache files
49
+ properly
50
+
51
+ 2009-09-29 22:21 donncha
52
+
53
+ * wp-cache-config-sample.php: Added $wp_super_cache_late_init to
54
+ config page
55
+
56
+ 2009-09-29 10:17 donncha
57
+
58
+ * wp-cache.php: Add button to delete specific cache files.
59
+
60
+ 2009-09-29 09:14 donncha
61
+
62
+ * wp-cache.php: Count wp-cached cache files correctly
63
+
64
+ 2009-09-29 08:17 donncha
65
+
66
+ * wp-cache-config-sample.php: Added "Yandex" to list of rejected UA
67
+ for not caching
68
+
69
+ 2009-09-29 08:08 donncha
70
+
71
+ * wp-cache.php: Add anchors to each section of the admin page
72
+
73
+ 2009-09-29 07:47 donncha
74
+
75
+ * wp-cache-phase2.php: Don't cache wp-admin requests
76
+
77
+ 2009-09-29 07:43 donncha
78
+
79
+ * wp-cache-phase2.php: Disable supercaching when GET parameters
80
+ present instead of all caching. Disable on POST (as normal) and
81
+ preview
82
+
83
+ 2009-09-28 21:59 donncha
84
+
85
+ * wp-cache-phase1.php: Move cron code down so that cache variables
86
+ are set.
87
+
88
+ 2009-09-28 21:37 donncha
89
+
90
+ * wp-super-cache.pot: More translatable text
91
+
92
+ 2009-09-28 21:35 donncha
93
+
94
+ * wp-cache.php: More il8n mods
95
+
96
+ 2009-09-28 17:48 donncha
97
+
98
+ * wp-cache.php: More il8n mods
99
+
100
+ 2009-09-28 13:57 donncha
101
+
102
+ * wp-cache.php: Add positional anchors
103
+
104
+ 2009-09-28 13:52 donncha
105
+
106
+ * wp-cache.php: Improve listing of cache files
107
+
108
+ 2009-09-28 13:35 donncha
109
+
110
+ * wp-cache-phase1.php, wp-cache-phase2.php, wp-cache.php: Record
111
+ the cache key in the wp-cache meta file. Show that key on the
112
+ admin page file listings and add "wp_cache_meta" filter to modify
113
+ the cache meta data
114
+
115
+ 2009-09-28 13:12 donncha
116
+
117
+ * wp-cache.php: Warn users they must enable mobile device support
118
+ if rewrite rules detected. Better detect when to warn that
119
+ .htaccess rules must be updated (no need when rewrite rules not
120
+ present)
121
+
122
+ 2009-09-28 11:12 donncha
123
+
124
+ * wp-cache.php: Allow admin to list cached files.
125
+
126
+ 2009-09-28 09:43 donncha
127
+
128
+ * wp-cache.php: More il8n changes
129
+
130
+ 2009-09-24 20:45 donncha
131
+
132
+ * wp-cache.php: Forgot the fieldset, props thunderlounge!
133
+
134
+ 2009-09-24 11:43 donncha
135
+
136
+ * wp-cache.php, wp-super-cache.pot: Renamed text domain to
137
+ wp-super-cache
138
+ Added .pot file
139
+ Load text domain as described in
140
+ http://codex.wordpress.org/I18n_for_WordPress_Developers
141
+
142
+ 2009-09-24 11:27 donncha
143
+
144
+ * wp-cache.php: First stab at internationalising wp-super-cache
145
+
146
+ 2009-09-24 10:18 donncha
147
+
148
+ * wp-cache.php: Removed REQUEST_URI from form actions
149
+
150
+ 2009-09-20 21:13 donncha
151
+
152
+ * wp-cache-phase2.php, wp-cache.php: Added "Newest Cached Pages"
153
+ option to list 10 newest pages cached by the plugin.
154
+
155
+ 2009-09-20 19:10 donncha
156
+
157
+ * wp-cache-phase2.php: Added "wpsupercache_404" filter. Return true
158
+ to cache error 404 pages. Props simonwheatley, see
159
+ http://wordpress.org/support/topic/312672
160
+
161
+ 2009-09-18 20:37 donncha
162
+
163
+ * wp-cache-phase1.php: Include the wordpress_test_cookie in the
164
+ cache key for wp-cache files.
165
+
166
+ 2009-09-16 10:23 donncha
167
+
168
+ * wp-cache-phase1.php: Late Init. Don't do anything until "init"
169
+
170
+ 2009-09-16 10:21 donncha
171
+
172
+ * wp-cache-phase2.php: Better debug messages
173
+
174
+ 2009-09-15 10:58 donncha
175
+
176
+ * wp-cache-config-sample.php, wp-cache-phase1.php,
177
+ wp-cache-phase2.php, wp-cache.php: Check if logging enabled
178
+ before calling debug function (optimization)
179
+ Improve debug admin screen
180
+
181
+ 2009-09-10 10:12 donncha
182
+
183
+ * wp-cache.php: Generate the correct rules for users ins
184
+ directories
185
+
186
+ 2009-09-10 08:41 donncha
187
+
188
+ * wp-cache.php: When cache compression is off don't divide number
189
+ of cached files by 2 as no .gz files are created. Props dpark,
190
+ http://wordpress.org/support/topic/309443
191
+
192
+ 2009-09-09 16:29 donncha
193
+
194
+ * wp-cache-phase2.php: Improved output buffer error message
195
+
196
+ 2009-09-09 12:37 donncha
197
+
198
+ * wp-cache-phase1.php, wp-cache-phase2.php, wp-cache.php: Added
199
+ debug settings section on admin page.
200
+
201
+ 2009-09-09 09:11 donncha
202
+
203
+ * wp-cache.php: Check if safe_mode is 1 or "on",
204
+ http://wordpress.org/support/topic/239579?replies=9#post-1204927
205
+
206
+ 2009-09-03 11:06 donncha
207
+
208
+ * wp-cache-phase2.php: Don't cache GET requests earlier on before
209
+ OB is set up.
210
+
211
+ 2009-09-03 11:05 donncha
212
+
213
+ * wp-cache-phase1.php: If debugging is not set then return
214
+ immediately
215
+
216
+ 2009-09-03 11:02 donncha
217
+
218
+ * wp-cache-config-sample.php, wp-cache-phase1.php,
219
+ wp-cache-phase2.php: Added logging to a file and configurable log
220
+ level
221
+
222
+ 2009-09-01 09:31 donncha
223
+
224
+ * readme.txt: Updated description of "How to tell if a page is
225
+ cached"
226
+
227
+ 2009-09-01 09:26 donncha
228
+
229
+ * wp-cache.php: Tell user that compression is enabled in half-on
230
+ mode.
231
+
232
+ 2009-08-24 13:04 donncha
233
+
234
+ * readme.txt: Added http://redbot.org/ to FAQ (thanks Alex!)
235
+
236
+ 2009-08-24 12:14 donncha
237
+
238
+ * wp-cache.php: Send the Vary header to browsers
239
+
240
+ 2009-08-24 08:49 donncha
241
+
242
+ * readme.txt: Added FAQ about caching warnings at
243
+ ismyblogworking.com
244
+
245
+ 2009-08-21 16:52 donncha
246
+
247
+ * wp-cache.php: Minor fixes for rewrite rules.
248
+ http://wordpress.org/support/topic/301570?replies=14
249
+
250
+ 2009-08-19 08:44 donncha
251
+
252
+ * readme.txt: Added troubleshooting note to use half-on mode if
253
+ timestamp keeps updating.
254
+
255
+ 2009-08-06 10:55 donncha
256
+
257
+ * wp-cache-phase2.php, wp-cache.php: Added "Cached Page" counter.
258
+
259
+ 2009-07-30 08:24 donncha
260
+
261
+ * wp-cache-phase2.php, wp-cache.php: Add support for not caching
262
+ feeds and search pages.
263
+
264
+ 2009-07-29 17:28 donncha
265
+
266
+ * Changelog.txt: Updated changelog
267
+
268
  2009-07-29 17:26 donncha
269
 
270
  * readme.txt, wp-cache.php: Bump version to 0.9.6.1
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === WP Super Cache ===
2
  Contributors: donncha
3
  Tags: performance,caching,wp-cache,wp-super-cache,cache
4
- Tested up to: 2.8.2
5
- Stable tag: 0.9.6.1
6
  Requires at least: 2.6
7
- Donate link: http://ocaoimh.ie/wordpress-plugins/gifts-and-donations/
8
 
9
  A very fast caching engine for WordPress that produces static html files.
10
 
@@ -28,6 +28,23 @@ The [changelog](http://svn.wp-plugins.org/wp-super-cache/trunk/Changelog.txt) is
28
 
29
  == Changelog ==
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  = 0.9.6.1 =
32
  * Move "not logged in" message init below check for POST.
33
  * Add is_admin() check so plugin definitely can't cache the backend.
@@ -151,7 +168,8 @@ To manually uninstall:
151
 
152
  = How do I know my blog is being cached? =
153
 
154
- View the source of any page on your site. When a page is first created, you'll see the text "Dynamic page generated in XXXX seconds." and "Cached page generated by WP-Super-Cache on YYYY-MM-DD HH:MM:SS" at the end of the source code. On reload, a cached page will show the same timestamp so wait a few seconds before checking. If you have compression enabled, the text "Compression = gzip" will be added. If compression is disabled and the page is served as a static html file, the text "super cache" will be added. The only other way to check if your cached file was served by PHP script or from the static cache is by looking at the HTTP headers. WP-Cache (PHP) cached pages will have the header "WP-Super-Cache: WP-Cache". I used the <a href="https://addons.mozilla.org/en-US/firefox/addon/3829">Live HTTP Headers</a> extension for Firefox to examine the headers. You should also check your cache directory in wp-content/cache/supercache/hostname/ for static cache files.
 
155
 
156
  = Why is WP-Super-Cache better than WP-Cache? =
157
 
@@ -165,9 +183,27 @@ Comments will show as soon as they are moderated, depending on the comment polic
165
 
166
  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.
167
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  = Why doesn't WP UserOnline, Popularity Contest, WP Postratings or plugin X not work or update on my blog now? =
169
 
170
- This plugin caches entire pages and some plugins think they can run PHP code every time a page loads. To fix this, the plugin needs to use Javascript or AJAX methods to update. If the plugin displays information on the page, that must be a Javascript request too.
171
 
172
  = Why doesn't the plugin cache requests by search engine bots by default? =
173
 
@@ -186,6 +222,15 @@ A tiny proportion of websites will have problems with the following configuratio
186
 
187
  Sometimes a category page is cached as the homepage of the site instead of the static page. I can't [replicate the problem](http://wordpress.org/support/topic/237415/page/2?replies=38) but a simple solution is to switch the plugin to half-on mode. For normal traffic you will see no difference in the speed of your site.
188
 
 
 
 
 
 
 
 
 
 
189
  = Troubleshooting =
190
 
191
  If things don't work when you installed the plugin here are a few things to check:
@@ -213,6 +258,7 @@ If things don't work when you installed the plugin here are a few things to chec
213
  A line like "127.0.0.1 localhost localhost.localdomain" is ok.
214
  17. If old pages are being served to your visitors via the supercache, you may be missing Apache modules (or their equivalents if you don't use Apache). 3 modules are required: mod_mime, mod_headers and mod_expires. The last two are especially important for making sure browsers load new versions of existing pages on your site.
215
  18. The error message, "WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed!" appears at the end of every page. Open the file wp-content/advanced-cache.php in your favourite editor. Is the path to wp-cache-phase1.php correct? If it is not the caching engine will not load.
 
216
 
217
  == Custom Caching ==
218
  It is now possible to hook into the caching process using the add_cacheaction() function.
1
  === WP Super Cache ===
2
  Contributors: donncha
3
  Tags: performance,caching,wp-cache,wp-super-cache,cache
4
+ Tested up to: 2.8.4
5
+ Stable tag: 0.9.7
6
  Requires at least: 2.6
7
+ Donate link: http://ocaoimh.ie/gad/
8
 
9
  A very fast caching engine for WordPress that produces static html files.
10
 
28
 
29
  == Changelog ==
30
 
31
+ = 0.9.7 =
32
+ * Fixed problem with blogs in folders.
33
+ * Added cache file listing and delete links to admin page.
34
+ * Added "Newest Cached Pages" listing in sidebox.
35
+ * Made admin page translatable.
36
+ * Added "How do I make certain parts of the page stay dynamic?" to FAQ.
37
+ * Advanced: added "late init" feature so that plugin activates on "init". Set $wp_super_cache_late_init to true in config file to use.
38
+ * Disable supercaching when GET parameters present instead of disabling all caching. Disable on POST (as normal) and preview.
39
+ * Fixed problem with cron job and mutex filename.
40
+ * Warn users they must enable mobile device support if rewrite rules detected. Better detection of when to warn that .htaccess rules must be updated (no need when rewrite rules not present)
41
+ * Advanced: Added "wpsupercache_404" filter. Return true to cache 404 error pages.
42
+ * Use the wordpress_test_cookie in the cache key.
43
+ * Show correct number of cache files when compression off.
44
+ * Fixed problem with PHP safe_mode detection.
45
+ * Various bugfixes and documentation updates. See Changelog.txt
46
+
47
+
48
  = 0.9.6.1 =
49
  * Move "not logged in" message init below check for POST.
50
  * Add is_admin() check so plugin definitely can't cache the backend.
168
 
169
  = How do I know my blog is being cached? =
170
 
171
+ View the source of any page on your site. When a page is first created, you'll see the text "Dynamic page generated in XXXX seconds." and "Cached page generated by WP-Super-Cache on YYYY-MM-DD HH:MM:SS" at the end of the source code. On reload, a cached page will show the same timestamp so wait a few seconds before checking.
172
+ In "HALF-ON" mode, if you have compression enabled, the text "Compression = gzip" will be added. If compression is disabled and the page is served as a static html file, the text "super cache" will be added. The only other way to check if your cached file was served by PHP script or from the static cache is by looking at the HTTP headers. WP-Cache (PHP) cached pages will have the header "WP-Super-Cache: WP-Cache". I used the <a href="https://addons.mozilla.org/en-US/firefox/addon/3829">Live HTTP Headers</a> extension for Firefox to examine the headers. You should also check your cache directory in wp-content/cache/supercache/hostname/ for static cache files.
173
 
174
  = Why is WP-Super-Cache better than WP-Cache? =
175
 
183
 
184
  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.
185
 
186
+ = How do I make certain parts of the page stay dynamic? =
187
+
188
+ WP Super Cache retains the dynamic loading code of WP Cache but only works in "half on" mode.
189
+
190
+ There are two ways to do this, you can have functions that stay dynamic or you can include other files on every page load. To have a dynamic function in the cached PHP page use this syntax around the function:
191
+
192
+ `<!--mfunc function_name( 'parameter', 'another_parameter' ) -->
193
+ <?php function_name( 'parameter', 'another_parameter' ) ?>
194
+ <!--/mfunc-->`
195
+
196
+ The HTML comments around the mirrored PHP allow it to be executed in the static page. To include another file try this:
197
+
198
+ `<!--mclude file.php-->
199
+ <?php include_once( ABSPATH . 'file.php' ); ?>
200
+ <!--/mclude-->`
201
+
202
+ That will include file.php under the ABSPATH directory, which is the same as where your wp-config.php file is located.
203
+
204
  = Why doesn't WP UserOnline, Popularity Contest, WP Postratings or plugin X not work or update on my blog now? =
205
 
206
+ This plugin caches entire pages but some plugins think they can run PHP code every time a page loads. To fix this, the plugin needs to use Javascript/AJAX methods or the mfunc/mclude code described in the previous answer to update or display dynamic information.
207
 
208
  = Why doesn't the plugin cache requests by search engine bots by default? =
209
 
222
 
223
  Sometimes a category page is cached as the homepage of the site instead of the static page. I can't [replicate the problem](http://wordpress.org/support/topic/237415/page/2?replies=38) but a simple solution is to switch the plugin to half-on mode. For normal traffic you will see no difference in the speed of your site.
224
 
225
+ = Why do I get warnings about caching from http://ismyblogworking.com/ =
226
+
227
+ "Your blog doesn't support client caching (no 304 response to If-modified-since)."
228
+ "Your feed doesn't support caching (no 304 response to If-modified-since)"
229
+
230
+ Supercache doesn't support 304 header checks. This is caching done by your browser, not your server. It is a check your browser does to ask the server if an updated version of the current page is available. If not, it doesn't download the old version again.
231
+ The page is still cached by your server, just not by the browsers of your visitors. WordPress doesn't support 304 caching either so you're not losing out.
232
+ Try the Cacheability Engine at http://www.ircache.net/cgi-bin/cacheability.py or http://redbot.org/ for further analysis.
233
+
234
  = Troubleshooting =
235
 
236
  If things don't work when you installed the plugin here are a few things to check:
258
  A line like "127.0.0.1 localhost localhost.localdomain" is ok.
259
  17. If old pages are being served to your visitors via the supercache, you may be missing Apache modules (or their equivalents if you don't use Apache). 3 modules are required: mod_mime, mod_headers and mod_expires. The last two are especially important for making sure browsers load new versions of existing pages on your site.
260
  18. The error message, "WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed!" appears at the end of every page. Open the file wp-content/advanced-cache.php in your favourite editor. Is the path to wp-cache-phase1.php correct? If it is not the caching engine will not load.
261
+ 19. Caching doesn't work. The timestamp on my blog keeps changing when I reload. Check that the path in your .htaccess rules matches where the supercache directory is. You may have to hardcode it. Or use the plugin in Half-On mode.
262
 
263
  == Custom Caching ==
264
  It is now possible to hook into the caching process using the add_cacheaction() function.
wp-cache-config-sample.php CHANGED
@@ -42,13 +42,10 @@ if( defined( 'VHOST' ) ) {
42
  $cache_acceptable_files = array( 'wp-comments-popup.php', 'wp-links-opml.php', 'wp-locations.php' );
43
 
44
  $cache_rejected_uri = array('wp-.*\\.php', 'index\\.php');
45
- $cache_rejected_user_agent = array ( 0 => 'bot', 1 => 'ia_archive', 2 => 'slurp', 3 => 'crawl', 4 => 'spider');
46
 
47
  $cache_rebuild_files = 1;
48
 
49
- // DEBUG mode. Change this to your email address to be sent debug emails.
50
- // Remove comment (//) to enable and add back to disable.
51
- //$wp_cache_debug = "you@example.com";
52
 
53
  // Disable the file locking system.
54
  // If you are experiencing problems with clearing or creating cache files
@@ -72,4 +69,5 @@ $wp_cache_gzip_first = 0;
72
  $wp_cache_plugins_dir = WPCACHEHOME . 'plugins';
73
  // set to 1 to do garbage collection during normal process shutdown instead of wp-cron
74
  $wp_cache_shutdown_gc = 0;
 
75
  ?>
42
  $cache_acceptable_files = array( 'wp-comments-popup.php', 'wp-links-opml.php', 'wp-locations.php' );
43
 
44
  $cache_rejected_uri = array('wp-.*\\.php', 'index\\.php');
45
+ $cache_rejected_user_agent = array ( 0 => 'bot', 1 => 'ia_archive', 2 => 'slurp', 3 => 'crawl', 4 => 'spider', 5 => 'Yandex' );
46
 
47
  $cache_rebuild_files = 1;
48
 
 
 
 
49
 
50
  // Disable the file locking system.
51
  // If you are experiencing problems with clearing or creating cache files
69
  $wp_cache_plugins_dir = WPCACHEHOME . 'plugins';
70
  // set to 1 to do garbage collection during normal process shutdown instead of wp-cron
71
  $wp_cache_shutdown_gc = 0;
72
+ $wp_super_cache_late_init = 0;
73
  ?>
wp-cache-phase1.php CHANGED
@@ -16,11 +16,6 @@ if( $blogcacheid != '' ) {
16
  $blog_cache_dir = $cache_path;
17
  }
18
 
19
- if(defined('DOING_CRON')) {
20
- require_once( WPCACHEHOME . 'wp-cache-phase2.php');
21
- return true;
22
- }
23
-
24
  $mutex_filename = 'wp_cache_mutex.lock';
25
  $new_cache = false;
26
 
@@ -28,6 +23,9 @@ $new_cache = false;
28
 
29
  if( !isset( $wp_cache_plugins_dir ) )
30
  $wp_cache_plugins_dir = WPCACHEHOME . 'plugins';
 
 
 
31
  $plugins = glob( $wp_cache_plugins_dir . '/*.php' );
32
  if( is_array( $plugins ) ) {
33
  foreach ( $plugins as $plugin ) {
@@ -63,8 +61,6 @@ add_cacheaction( 'wp_cache_get_cookies_values', 'wp_cache_check_mobile' );
63
 
64
  $wp_cache_request_uri = $_SERVER[ 'REQUEST_URI' ]; // Cache this in case any plugin modifies it.
65
 
66
- $key = $blogcacheid . md5( do_cacheaction( 'wp_cache_key', $_SERVER['HTTP_HOST'].preg_replace('/#.*$/', '', str_replace( '/index.php', '/', $wp_cache_request_uri ) ).$wp_cache_gzip_encoding.wp_cache_get_cookies_values() ) );
67
-
68
  if( false == @is_dir( $blog_cache_dir ) ) {
69
  @mkdir( $cache_path . "blogs" );
70
  @mkdir( $blog_cache_dir );
@@ -74,55 +70,103 @@ if( false == @is_dir( $blog_cache_dir . 'meta' ) )
74
  @mkdir( $blog_cache_dir . 'meta' );
75
 
76
 
77
- $cache_filename = $file_prefix . $key . '.html';
78
- $meta_file = $file_prefix . $key . '.meta';
79
- $cache_file = realpath( $blog_cache_dir . $cache_filename );
80
- $meta_pathname = realpath( $blog_cache_dir . 'meta/' . $meta_file );
81
-
82
  $wp_start_time = microtime();
83
- if( file_exists( $cache_file ) && !wp_cache_user_agent_is_rejected() ) {
84
- if (! ($meta = unserialize(@file_get_contents($meta_pathname))) )
85
- return true;
86
- if( is_array( $meta ) == false ) {
87
- @unlink( $meta_pathname );
88
- @unlink( $cache_file );
89
- return true;
90
- }
91
- $cache_file = do_cacheaction( 'wp_cache_served_cache_file', $cache_file );
92
- // Sometimes the gzip headers are lost. If this is a gzip capable client, send those headers.
93
- if( $wp_cache_gzip_encoding && !in_array( 'Content-Encoding: ' . $wp_cache_gzip_encoding, $meta[ 'headers' ] ) ) {
94
- $meta[ 'headers' ][ 'Content-Encoding' ] = 'Content-Encoding: ' . $wp_cache_gzip_encoding;
95
- $meta[ 'headers' ][ 'Vary' ] = 'Vary: Accept-Encoding, Cookie';
96
- wp_cache_debug( "Had to add gzip headers to the page {$_SERVER[ 'REQUEST_URI' ]}." );
97
- }
98
- foreach ($meta[ 'headers' ] as $t => $header) {
99
- // godaddy fix, via http://blog.gneu.org/2008/05/wp-supercache-on-godaddy/ and http://www.littleredrails.com/blog/2007/09/08/using-wp-cache-on-godaddy-500-error/
100
- if( strpos( $header, 'Last-Modified:' ) === false )
101
- header($header);
102
- }
103
- header( 'WP-Super-Cache: WP-Cache' );
104
- if ( $meta[ 'dynamic' ] ) {
105
- include($cache_file);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  } else {
107
- readfile( $cache_file );
108
  }
109
- die();
 
 
 
 
 
 
 
 
110
  }
111
 
112
  function wp_cache_postload() {
113
- global $cache_enabled;
114
 
115
  if ( !$cache_enabled || isset( $_GET[ 'preview' ] ) )
116
  return true;
117
- require_once( WPCACHEHOME . 'wp-cache-phase2.php');
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  wp_cache_phase2();
119
  }
120
 
121
  function wp_cache_get_cookies_values() {
122
  $string = '';
123
  while ($key = key($_COOKIE)) {
124
- if ( preg_match( "/^wp-postpass|^wordpress|^comment_author_/", $key ) && $_COOKIE[ $key ] != 'WP Cookie check' ) {
125
- $string .= $_COOKIE[$key] . ",";
 
126
  }
127
  next($_COOKIE);
128
  }
@@ -162,6 +206,7 @@ function wp_cache_check_mobile( $cache_key ) {
162
  $whitelist = explode( ',', $wp_cache_mobile_whitelist );
163
  foreach ($whitelist as $browser) {
164
  if (strstr($_SERVER["HTTP_USER_AGENT"], trim($browser))) {
 
165
  return $cache_key;
166
  }
167
  }
@@ -169,18 +214,38 @@ function wp_cache_check_mobile( $cache_key ) {
169
  $browsers = explode( ',', $wp_cache_mobile_browsers );
170
  foreach ($browsers as $browser) {
171
  if (strstr($_SERVER["HTTP_USER_AGENT"], trim( $browser ))) {
 
172
  return $cache_key . $browser;
173
  }
174
  }
175
  return $cache_key;
176
  }
177
 
178
- function wp_cache_debug( $message ) {
179
- global $wp_cache_debug;
180
- if( !isset( $wp_cache_debug ) )
181
- return;
182
- $message .= "\n\nDisable these emails by commenting out or deleting the line containing\n\$wp_cache_debug in wp-content/wp-cache-config.php on your server.\n";
183
- mail( $wp_cache_debug, '[' . addslashes( $_SERVER[ 'HTTP_HOST' ] ) . "] WP Super Cache Debug", $message );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
  }
185
 
186
  function wp_cache_user_agent_is_rejected() {
16
  $blog_cache_dir = $cache_path;
17
  }
18
 
 
 
 
 
 
19
  $mutex_filename = 'wp_cache_mutex.lock';
20
  $new_cache = false;
21
 
23
 
24
  if( !isset( $wp_cache_plugins_dir ) )
25
  $wp_cache_plugins_dir = WPCACHEHOME . 'plugins';
26
+
27
+ require_once( WPCACHEHOME . 'wp-cache-phase2.php');
28
+
29
  $plugins = glob( $wp_cache_plugins_dir . '/*.php' );
30
  if( is_array( $plugins ) ) {
31
  foreach ( $plugins as $plugin ) {
61
 
62
  $wp_cache_request_uri = $_SERVER[ 'REQUEST_URI' ]; // Cache this in case any plugin modifies it.
63
 
 
 
64
  if( false == @is_dir( $blog_cache_dir ) ) {
65
  @mkdir( $cache_path . "blogs" );
66
  @mkdir( $blog_cache_dir );
70
  @mkdir( $blog_cache_dir . 'meta' );
71
 
72
 
 
 
 
 
 
73
  $wp_start_time = microtime();
74
+
75
+ function wp_super_cache_init() {
76
+ global $wp_cache_key, $key, $blogcacheid, $wp_cache_request_uri, $file_prefix, $blog_cache_dir, $meta_file, $cache_file, $cache_filename, $wp_super_cache_debug, $meta_pathname, $wp_cache_gzip_encoding, $meta;
77
+
78
+ $wp_cache_key = do_cacheaction( 'wp_cache_key', $_SERVER['HTTP_HOST'].preg_replace('/#.*$/', '', str_replace( '/index.php', '/', $wp_cache_request_uri ) ).$wp_cache_gzip_encoding.wp_cache_get_cookies_values() );
79
+ $key = $blogcacheid . md5( $wp_cache_key );
80
+ $wp_cache_key = $blogcacheid . $wp_cache_key;
81
+
82
+ $cache_filename = $file_prefix . $key . '.html';
83
+ $meta_file = $file_prefix . $key . '.meta';
84
+ $cache_file = realpath( $blog_cache_dir . $cache_filename );
85
+ $meta_pathname = realpath( $blog_cache_dir . 'meta/' . $meta_file );
86
+ return compact( 'key', 'cache_filename', 'meta_file', 'cache_file', 'meta_pathname' );
87
+ }
88
+
89
+ function wp_cache_serve_cache_file() {
90
+ global $key, $blogcacheid, $wp_cache_request_uri, $file_prefix, $blog_cache_dir, $meta_file, $cache_file, $cache_filename, $wp_super_cache_debug, $meta_pathname, $wp_cache_gzip_encoding, $meta;
91
+
92
+ extract( wp_super_cache_init() );
93
+
94
+ if ( file_exists( $cache_file ) && !wp_cache_user_agent_is_rejected() ) {
95
+ if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "wp-cache file exists", 5 );
96
+ if ( !( $meta = unserialize( @file_get_contents( $meta_pathname) ) ) ) {
97
+ if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "couldn't load wp-cache meta file", 5 );
98
+ return true;
99
+ }
100
+ if ( is_array( $meta ) == false ) {
101
+ if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "meta array corrupt, deleting $meta_pathname and $cache_file", 1 );
102
+ @unlink( $meta_pathname );
103
+ @unlink( $cache_file );
104
+ return true;
105
+ }
106
+ $cache_file = do_cacheaction( 'wp_cache_served_cache_file', $cache_file );
107
+ // Sometimes the gzip headers are lost. If this is a gzip capable client, send those headers.
108
+ if( $wp_cache_gzip_encoding && !in_array( 'Content-Encoding: ' . $wp_cache_gzip_encoding, $meta[ 'headers' ] ) ) {
109
+ $meta[ 'headers' ][ 'Content-Encoding' ] = 'Content-Encoding: ' . $wp_cache_gzip_encoding;
110
+ $meta[ 'headers' ][ 'Vary' ] = 'Vary: Accept-Encoding, Cookie';
111
+ if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "added gzip headers before serving.", 1 );
112
+ }
113
+ foreach ($meta[ 'headers' ] as $t => $header) {
114
+ // godaddy fix, via http://blog.gneu.org/2008/05/wp-supercache-on-godaddy/ and http://www.littleredrails.com/blog/2007/09/08/using-wp-cache-on-godaddy-500-error/
115
+ if( strpos( $header, 'Last-Modified:' ) === false )
116
+ header($header);
117
+ }
118
+ header( 'WP-Super-Cache: WP-Cache' );
119
+ if ( $meta[ 'dynamic' ] ) {
120
+ if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Serving wp-cache dynamic file", 5 );
121
+ include($cache_file);
122
+ } else {
123
+ if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Serving wp-cache static file", 5 );
124
+ readfile( $cache_file );
125
+ }
126
+ if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "exit request", 5 );
127
+ die();
128
  } else {
129
+ if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "No wp-cache file exists or user agent rejected.", 5 );
130
  }
131
+ }
132
+
133
+ if(defined('DOING_CRON')) {
134
+ extract( wp_super_cache_init() );
135
+ return true;
136
+ }
137
+
138
+ if ( !isset( $wp_super_cache_late_init ) || ( isset( $wp_super_cache_late_init ) && false == $wp_super_cache_late_init ) ) {
139
+ wp_cache_serve_cache_file();
140
  }
141
 
142
  function wp_cache_postload() {
143
+ global $cache_enabled, $wp_super_cache_late_init, $wp_super_cache_debug;
144
 
145
  if ( !$cache_enabled || isset( $_GET[ 'preview' ] ) )
146
  return true;
147
+
148
+ if ( isset( $wp_super_cache_late_init ) && true == $wp_super_cache_late_init ) {
149
+ if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Supercache Late Init: add wp_cache_serve_cache_file to init", 3 );
150
+ add_action( 'init', 'wp_cache_late_loader', 9999 );
151
+ } else {
152
+ wp_super_cache_init();
153
+ wp_cache_phase2();
154
+ }
155
+ }
156
+
157
+ function wp_cache_late_loader() {
158
+ global $wp_super_cache_debug;
159
+ if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Supercache Late Loader running on init", 3 );
160
+ wp_cache_serve_cache_file();
161
  wp_cache_phase2();
162
  }
163
 
164
  function wp_cache_get_cookies_values() {
165
  $string = '';
166
  while ($key = key($_COOKIE)) {
167
+ if ( preg_match( "/^wp-postpass|^wordpress|^comment_author_/", $key ) ) {
168
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Cookie detected: $key", 5 );
169
+ $string .= $_COOKIE[ $key ] . ",";
170
  }
171
  next($_COOKIE);
172
  }
206
  $whitelist = explode( ',', $wp_cache_mobile_whitelist );
207
  foreach ($whitelist as $browser) {
208
  if (strstr($_SERVER["HTTP_USER_AGENT"], trim($browser))) {
209
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "whitelst mobile browser detected: " . $_SERVER[ "HTTP_USER_AGENT" ], 5 );
210
  return $cache_key;
211
  }
212
  }
214
  $browsers = explode( ',', $wp_cache_mobile_browsers );
215
  foreach ($browsers as $browser) {
216
  if (strstr($_SERVER["HTTP_USER_AGENT"], trim( $browser ))) {
217
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "mobile browser detected: " . $_SERVER[ "HTTP_USER_AGENT" ], 5 );
218
  return $cache_key . $browser;
219
  }
220
  }
221
  return $cache_key;
222
  }
223
 
224
+ function wp_cache_debug( $message, $level = 1 ) {
225
+ global $wp_cache_debug_level, $wp_cache_debug_log, $wp_cache_debug_email, $cache_path, $wp_cache_debug_ip, $wp_super_cache_debug;
226
+
227
+ if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug == false )
228
+ return false;
229
+
230
+ if ( isset( $wp_cache_debug_email ) == false && isset( $wp_cache_debug_log ) == false )
231
+ return false;
232
+
233
+ if ( isset( $wp_cache_debug_level ) == false )
234
+ $wp_cache_debug_level = 1;
235
+ if ( $wp_cache_debug_level < $level )
236
+ return false;
237
+
238
+ if ( isset( $wp_cache_debug_ip ) && $wp_cache_debug_ip != '' && $wp_cache_debug_ip != $_SERVER[ 'REMOTE_ADDR' ] )
239
+ return false;
240
+
241
+ if ( isset( $wp_cache_debug_log ) && $wp_cache_debug_log != '' ) {
242
+ error_log( date( 'H:i:s' ) . " " . $_SERVER[ 'REQUEST_URI' ] . " " . $message . "\n", 3, $cache_path . str_replace( '/', '', str_replace( '..', '', $wp_cache_debug_log ) ) );
243
+ }
244
+
245
+ if ( isset( $wp_cache_debug_email ) && $wp_cache_debug_email != '' ) {
246
+ $message .= "\n\nDisable these emails by commenting out or deleting the line containing\n\$wp_cache_debug_email in wp-content/wp-cache-config.php on your server.\n";
247
+ mail( $wp_cache_debug_email, '[' . addslashes( $_SERVER[ 'HTTP_HOST' ] ) . "] WP Super Cache Debug", $message );
248
+ }
249
  }
250
 
251
  function wp_cache_user_agent_is_rejected() {
wp-cache-phase2.php CHANGED
@@ -2,13 +2,15 @@
2
 
3
  function wp_cache_phase2() {
4
  global $cache_filename, $cache_acceptable_files, $wp_cache_gzip_encoding, $super_cache_enabled, $cache_rebuild_files, $wp_cache_gmt_offset, $wp_cache_blog_charset, $wp_cache_last_gc;
5
- global $cache_max_time, $wp_cache_not_logged_in, $wp_cache_request_uri;
 
6
 
7
  $wp_cache_gmt_offset = get_option( 'gmt_offset' ); // caching for later use when wpdb is gone. http://wordpress.org/support/topic/224349
8
  $wp_cache_blog_charset = get_option( 'blog_charset' );
9
 
10
  wp_cache_mutex_init();
11
  if(function_exists('add_action') && ( !defined( 'WPLOCKDOWN' ) || ( defined( 'WPLOCKDOWN' ) && constant( 'WPLOCKDOWN' ) == '0' ) ) ) {
 
12
  // Post ID is received
13
  add_action('publish_post', 'wp_cache_post_edit', 0);
14
  add_action('edit_post', 'wp_cache_post_change', 0); // leaving a comment called edit_post
@@ -30,23 +32,47 @@ function wp_cache_phase2() {
30
  do_cacheaction( 'add_cacheaction' );
31
  }
32
 
33
- if( $_SERVER["REQUEST_METHOD"] == 'POST' || !empty( $_POST ) || get_option('gzipcompression'))
 
34
  return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
  if ( $wp_cache_not_logged_in && is_user_logged_in() && !is_feed() && !is_admin() ) {
 
37
  register_shutdown_function( 'wpcache_logged_in_message' );
38
  return false;
39
  }
40
 
41
  $script = basename($_SERVER['PHP_SELF']);
42
- if (!in_array($script, $cache_acceptable_files) && wp_cache_is_rejected($wp_cache_request_uri))
 
43
  return false;
44
- if (wp_cache_user_agent_is_rejected()) return;
 
 
 
 
45
  if($wp_cache_gzip_encoding)
46
  header('Vary: Accept-Encoding, Cookie');
47
  else
48
  header('Vary: Cookie');
49
  ob_start( 'wp_cache_ob_callback' );
 
50
 
51
  // restore old supercache file temporarily
52
  if( $super_cache_enabled && $cache_rebuild_files ) {
@@ -60,10 +86,12 @@ function wp_cache_phase2() {
60
  continue;
61
  $mtime = @filemtime($cache_file . '.needs-rebuild');
62
  if( $mtime && (time() - $mtime) < 30 ) {
 
63
  @rename( $cache_file . '.needs-rebuild', $cache_file );
64
  }
65
  // cleanup old files or if rename fails
66
  if( @file_exists( $cache_file . '.needs-rebuild' ) ) {
 
67
  @unlink( $cache_file . '.needs-rebuild' );
68
  }
69
  }
@@ -83,7 +111,10 @@ function wp_cache_phase2() {
83
 
84
  global $wp_cache_shutdown_gc;
85
  if( !isset( $wp_cache_shutdown_gc ) || $wp_cache_shutdown_gc == 0 ) {
86
- if(!wp_next_scheduled('wp_cache_gc')) wp_schedule_single_event(time() + 10 , 'wp_cache_gc');
 
 
 
87
  } else {
88
  global $time_to_gc_cache;
89
  $time_to_gc_cache = 1; // tell the "shutdown gc" to run!
@@ -142,7 +173,10 @@ function wp_cache_is_rejected($uri) {
142
  }
143
 
144
  function wp_cache_mutex_init() {
145
- global $use_flock, $mutex, $cache_path, $mutex_filename, $sem_id, $blog_cache_dir;
 
 
 
146
 
147
  if(!is_bool($use_flock)) {
148
  if(function_exists('sem_get'))
@@ -152,10 +186,13 @@ function wp_cache_mutex_init() {
152
  }
153
 
154
  $mutex = false;
155
- if ($use_flock)
 
156
  $mutex = @fopen($blog_cache_dir . $mutex_filename, 'w');
157
- else
 
158
  $mutex = @sem_get($sem_id, 1, 0644 | IPC_CREAT, 1);
 
159
  }
160
 
161
  function wp_cache_writers_entry() {
@@ -164,13 +201,18 @@ function wp_cache_writers_entry() {
164
  if( isset( $wp_cache_mutex_disabled ) && $wp_cache_mutex_disabled )
165
  return true;
166
 
167
- if( !$mutex )
 
168
  return false;
 
169
 
170
- if ($use_flock)
 
171
  flock($mutex, LOCK_EX);
172
- else
 
173
  sem_acquire($mutex);
 
174
 
175
  return true;
176
  }
@@ -181,13 +223,18 @@ function wp_cache_writers_exit() {
181
  if( isset( $wp_cache_mutex_disabled ) && $wp_cache_mutex_disabled )
182
  return true;
183
 
184
- if( !$mutex )
 
185
  return false;
 
186
 
187
- if ($use_flock)
 
188
  flock($mutex, LOCK_UN);
189
- else
 
190
  sem_release($mutex);
 
191
  }
192
 
193
  function get_current_url_supercache_dir() {
@@ -201,6 +248,7 @@ function get_current_url_supercache_dir() {
201
  $dir = trailingslashit( ABSPATH . $uri );
202
  }
203
  $dir = str_replace( '//', '/', $dir );
 
204
  return $dir;
205
  }
206
 
@@ -208,6 +256,7 @@ function wp_cache_ob_callback( $buffer ) {
208
  global $wp_cache_pages;
209
  if( defined( 'DONOTCACHEPAGE' ) )
210
  return $buffer;
 
211
 
212
  if ( isset( $wp_cache_pages[ 'single' ] ) && $wp_cache_pages[ 'single' ] == 1 && is_single() ) {
213
  return $buffer;
@@ -223,6 +272,10 @@ function wp_cache_ob_callback( $buffer ) {
223
  return $buffer;
224
  } elseif ( isset( $wp_cache_pages[ 'home' ] ) && $wp_cache_pages[ 'home' ] == 1 && is_home() ) {
225
  return $buffer;
 
 
 
 
226
  }
227
  $buffer = &wp_cache_get_ob( $buffer );
228
  wp_cache_shutdown_callback();
@@ -235,22 +288,39 @@ function wp_cache_get_ob(&$buffer) {
235
  global $new_cache, $wp_cache_meta, $file_expired, $blog_id, $cache_compression;
236
  global $wp_cache_gzip_encoding, $super_cache_enabled, $cached_direct_pages;
237
  global $wp_cache_404, $gzsize, $supercacheonly, $wp_cache_gzip_first, $wp_cache_gmt_offset;
238
- global $blog_cache_dir, $wp_cache_request_uri;
239
 
240
  $new_cache = true;
241
  $wp_cache_meta = '';
242
 
243
  /* Mode paranoic, check for closing tags
244
  * we avoid caching incomplete files */
245
- if( $wp_cache_404 ) {
246
  $new_cache = false;
247
- $buffer .= "\n<!-- Page not cached by WP Super Cache. 404. -->\n";
 
 
 
 
 
 
 
 
 
 
 
248
  }
249
 
250
  if (!preg_match('/(<\/html>|<\/rss>|<\/feed>)/i',$buffer) ) {
251
  $new_cache = false;
252
- if( false === strpos( $_SERVER[ 'REQUEST_URI' ], 'robots.txt' ) )
253
- $buffer .= "\n<!-- Page not cached by WP Super Cache. No closing HTML tag. Check your theme. -->\n";
 
 
 
 
 
 
254
  }
255
 
256
  if( !$new_cache )
@@ -262,25 +332,31 @@ function wp_cache_get_ob(&$buffer) {
262
 
263
  if( !wp_cache_writers_entry() ) {
264
  $buffer .= "\n<!-- Page not cached by WP Super Cache. Could not get mutex lock. -->\n";
 
265
  return $buffer;
266
  }
267
 
268
  $dir = get_current_url_supercache_dir();
269
  $supercachedir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $_SERVER["HTTP_HOST"]);
270
- if( !empty( $_GET ) || is_feed() || ( $super_cache_enabled == true && is_dir( substr( $supercachedir, 0, -1 ) . '.disabled' ) ) )
 
271
  $super_cache_enabled = false;
 
272
 
273
  $tmp_wpcache_filename = $cache_path . uniqid( mt_rand(), true ) . '.tmp';
274
 
275
  // Don't create wp-cache files for anon users
276
  $supercacheonly = false;
277
- if( $super_cache_enabled && wp_cache_get_cookies_values() == '' )
 
278
  $supercacheonly = true;
 
279
 
280
  if( !$supercacheonly ) {
281
  if ( !@file_exists( $blog_cache_dir . $cache_filename ) || ( @file_exists( $blog_cache_dir . $cache_filename ) && ( time() - @filemtime( $blog_cache_dir . $cache_filename ) ) > 5 ) ) {
282
  $fr = @fopen($tmp_wpcache_filename, 'w');
283
  if (!$fr) {
 
284
  $buffer .= "<!-- File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $cache_path ) . $cache_filename . " -->\n";
285
  return $buffer;
286
  }
@@ -299,6 +375,7 @@ function wp_cache_get_ob(&$buffer) {
299
  if ( !@file_exists( $cache_fname ) || ( @file_exists( $cache_fname ) && ( time() - @filemtime( $cache_fname ) ) > 5 ) ) {
300
  $fr2 = @fopen( $tmp_cache_filename, 'w' );
301
  if (!$fr2) {
 
302
  $buffer .= "<!-- File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $tmp_cache_filename ) . " -->\n";
303
  @fclose( $fr );
304
  @unlink( $tmp_wpcache_filename );
@@ -306,6 +383,7 @@ function wp_cache_get_ob(&$buffer) {
306
  } elseif( $cache_compression ) {
307
  $gz = @fopen( $tmp_cache_filename . ".gz", 'w');
308
  if (!$gz) {
 
309
  $buffer .= "<!-- File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $tmp_cache_filename ) . ".gz -->\n";
310
  @fclose( $fr );
311
  @unlink( $tmp_wpcache_filename );
@@ -319,6 +397,7 @@ function wp_cache_get_ob(&$buffer) {
319
  }
320
 
321
  if (preg_match('/<!--mclude|<!--mfunc/', $buffer)) { //Dynamic content
 
322
  $store = preg_replace('|<!--mclude (.*?)-->(.*?)<!--/mclude-->|is',
323
  "<!--mclude-->\n<?php include_once('" . ABSPATH . "$1'); ?>\n<!--/mclude-->", $buffer);
324
  $store = preg_replace('|<!--mfunc (.*?)-->(.*?)<!--/mfunc-->|is',
@@ -339,6 +418,7 @@ function wp_cache_get_ob(&$buffer) {
339
  $buffer .= "<!-- Cached page generated by WP-Super-Cache on " . gmdate('Y-m-d H:i:s', (time() + ( $wp_cache_gmt_offset * 3600))) . " -->\n";
340
 
341
  if( $gz || $wp_cache_gzip_encoding ) {
 
342
  $gzdata = gzencode( $buffer . "<!-- Compression = gzip -->", 3, FORCE_GZIP );
343
  $gzsize = strlen($gzdata);
344
  }
@@ -346,20 +426,29 @@ function wp_cache_get_ob(&$buffer) {
346
  $wp_cache_meta[ 'headers' ][ 'Content-Encoding' ] = 'Content-Encoding: ' . $wp_cache_gzip_encoding;
347
  $wp_cache_meta[ 'headers' ][ 'Vary' ] = 'Vary: Accept-Encoding, Cookie';
348
  // Return uncompressed data & store compressed for later use
349
- if( $fr )
 
350
  fputs($fr, $gzdata);
 
351
  } else { // no compression
352
  $wp_cache_meta[ 'headers' ][ 'Vary' ] = 'Vary: Cookie';
353
- if( $fr )
 
354
  fputs($fr, $buffer);
 
355
  }
356
- if( $fr2 )
 
357
  fputs($fr2, $buffer . '<!-- super cache -->' );
358
- if( $gz )
 
 
359
  fwrite($gz, $gzdata );
 
360
  $buffer .= $log;
361
  }
362
  $new_cache = true;
 
363
  if( $fr ) {
364
  $supercacheonly = false;
365
  fclose($fr);
@@ -367,6 +456,8 @@ function wp_cache_get_ob(&$buffer) {
367
  unlink( $blog_cache_dir . $cache_filename );
368
  rename( $tmp_wpcache_filename, $blog_cache_dir . $cache_filename );
369
  }
 
 
370
  }
371
  if( $fr2 ) {
372
  fclose($fr2);
@@ -374,6 +465,8 @@ function wp_cache_get_ob(&$buffer) {
374
  @unlink( $cache_fname );
375
  @rename( $tmp_cache_filename, $cache_fname );
376
  }
 
 
377
  }
378
  if( $gz ) {
379
  fclose($gz);
@@ -381,14 +474,26 @@ function wp_cache_get_ob(&$buffer) {
381
  @unlink( $cache_fname . '.gz' );
382
  @rename( $tmp_cache_filename . '.gz', $cache_fname . '.gz' );
383
  }
 
 
 
 
 
 
 
 
 
 
384
  }
385
  wp_cache_writers_exit();
386
  if ( !headers_sent() && isset( $wp_cache_gzip_first ) && 1 == $wp_cache_gzip_first && $wp_cache_gzip_encoding && $gzdata) {
 
387
  header( 'Content-Encoding: ' . $wp_cache_gzip_encoding );
388
  header( 'Vary: Accept-Encoding, Cookie' );
389
  header( 'Content-Length: ' . $gzsize );
390
  return $gzdata;
391
  } else {
 
392
  return $buffer;
393
  }
394
  }
@@ -398,6 +503,7 @@ function wp_cache_phase2_clean_cache($file_prefix) {
398
 
399
  if( !wp_cache_writers_entry() )
400
  return false;
 
401
  if ( ( $handle = @opendir( $blog_cache_dir ) ) ) {
402
  while ( false !== ($file = @readdir($handle))) {
403
  if ( preg_match("/^$file_prefix/", $file) )
@@ -444,8 +550,10 @@ function prune_super_cache( $directory, $force = false, $rename = false ) {
444
  }
445
  if( $donotdelete )
446
  continue;
447
- if( !$rename )
448
  @rmdir( $entry );
 
 
449
  }
450
  }
451
  closedir($dh);
@@ -469,11 +577,14 @@ function wp_cache_rebuild_or_delete( $file ) {
469
  if( $cache_rebuild_files && substr( $file, -14 ) != '.needs-rebuild' ) {
470
  if( @rename($file, $file . '.needs-rebuild') ) {
471
  @touch( $file . '.needs-rebuild' );
 
472
  } else {
473
  @unlink( $file );
 
474
  }
475
  } else {
476
  @unlink( $file );
 
477
  }
478
  }
479
 
@@ -484,22 +595,27 @@ function wp_cache_phase2_clean_expired($file_prefix) {
484
  if( !wp_cache_writers_entry() )
485
  return false;
486
  $now = time();
 
487
  if ( ( $handle = @opendir( $blog_cache_dir ) ) ) {
488
  while ( false !== ($file = readdir($handle))) {
489
  if ( preg_match("/^$file_prefix/", $file) &&
490
  (@filemtime( $blog_cache_dir . $file) + $cache_max_time) <= $now ) {
491
  @unlink( $blog_cache_dir . $file );
492
  @unlink( $blog_cache_dir . 'meta/' . str_replace( '.html', '.meta', $file ) );
 
493
  continue;
494
  }
495
  if($file != '.' && $file != '..') {
496
  if( is_dir( $blog_cache_dir . $file ) == false && (@filemtime($blog_cache_dir . $file) + $cache_max_time) <= $now ) {
497
- if( substr( $file, -9 ) != '.htaccess' )
498
  @unlink($blog_cache_dir . $file);
 
 
499
  }
500
  }
501
  }
502
  closedir($handle);
 
503
  prune_super_cache( $cache_path . 'supercache' );
504
  }
505
 
@@ -509,11 +625,13 @@ function wp_cache_phase2_clean_expired($file_prefix) {
509
 
510
  function wp_cache_shutdown_callback() {
511
  global $cache_path, $cache_max_time, $file_expired, $file_prefix, $meta_file, $new_cache, $wp_cache_meta, $known_headers, $blog_id, $wp_cache_gzip_encoding, $gzsize, $cache_filename, $supercacheonly, $blog_cache_dir;
512
- global $wp_cache_blog_charset, $wp_cache_request_uri;
513
 
514
  $wp_cache_meta[ 'uri' ] = $_SERVER["SERVER_NAME"].preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', $wp_cache_request_uri); // To avoid XSS attacks
515
  $wp_cache_meta[ 'blog_id' ] = $blog_id;
516
  $wp_cache_meta[ 'post' ] = wp_cache_post_id();
 
 
517
 
518
  $response = wp_cache_get_response_headers();
519
  foreach ($known_headers as $key) {
@@ -554,18 +672,21 @@ function wp_cache_shutdown_callback() {
554
  }
555
  $value .= "; charset=\"" . $wp_cache_blog_charset . "\"";
556
 
 
557
  @header("Content-Type: $value");
558
  $wp_cache_meta[ 'headers' ][ 'Content-Type' ] = "Content-Type: $value";
559
  }
560
 
561
  if ( ! $supercacheonly && $new_cache ) {
562
  if( $wp_cache_gzip_encoding && !in_array( 'Content-Encoding: ' . $wp_cache_gzip_encoding, $wp_cache_meta[ 'headers' ] ) ) {
 
563
  $wp_cache_meta[ 'headers' ][ 'Content-Encoding' ] = 'Content-Encoding: ' . $wp_cache_gzip_encoding;
564
  $wp_cache_meta[ 'headers' ][ 'Vary' ] = 'Vary: Accept-Encoding, Cookie';
565
  }
566
 
567
  $serial = serialize($wp_cache_meta);
568
  if( wp_cache_writers_entry() ) {
 
569
  $tmp_meta_filename = $blog_cache_dir . 'meta/' . uniqid( mt_rand(), true ) . '.tmp';
570
  $fr = @fopen( $tmp_meta_filename, 'w');
571
  if( !$fr )
@@ -582,8 +703,10 @@ function wp_cache_shutdown_callback() {
582
  }
583
  }
584
  global $time_to_gc_cache;
585
- if( isset( $time_to_gc_cache ) && $time_to_gc_cache == 1 )
 
586
  do_action( 'wp_cache_gc' );
 
587
  }
588
 
589
  function wp_cache_no_postid($id) {
@@ -598,25 +721,32 @@ function wp_cache_get_postid_from_comment($comment_id) {
598
  // http://ocaoimh.ie/2006/12/05/caching-wordpress-with-wp-cache-in-a-spam-filled-world
599
  if( !preg_match('/wp-admin\//', $wp_cache_request_uri) )
600
  if( $comment['comment_approved'] == 'spam' ) { // changed from 1 to "spam"
 
601
  return $postid;
602
  } elseif( $comment['comment_approved'] == '0' ) {
 
603
  $super_cache_enabled = 0; // don't remove the super cache static file until comment is approved
604
  }
605
  // We must check it up again due to WP bugs calling two different actions
606
  // for delete, for example both wp_set_comment_status and delete_comment
607
  // are called when deleting a comment
608
- if ($postid > 0)
 
609
  return wp_cache_post_change($postid);
610
- else
 
611
  return wp_cache_post_change(wp_cache_post_id());
 
612
  }
613
 
614
  function wp_cache_post_edit($post_id) {
615
  global $wp_cache_clear_on_post_edit, $cache_path, $blog_cache_dir;
616
  if( $wp_cache_clear_on_post_edit ) {
 
617
  prune_super_cache( $blog_cache_dir, true );
618
  prune_super_cache( $cache_path . 'supercache/', true );
619
  } else {
 
620
  wp_cache_post_change( $post_id );
621
  }
622
  }
@@ -630,8 +760,10 @@ function wp_cache_post_id_gc( $siteurl, $post_id ) {
630
 
631
  $permalink = trailingslashit( str_replace( get_option( 'home' ), '', post_permalink( $post_id ) ) );
632
  $dir = $cache_path . 'supercache/' . $siteurl;
 
633
  prune_super_cache( $dir . $permalink, true, true );
634
  @rmdir( $dir . $permalink );
 
635
  prune_super_cache( $dir . 'page/', true );
636
  }
637
 
@@ -648,6 +780,7 @@ function wp_cache_post_change($post_id) {
648
  if( $super_cache_enabled ) {
649
  $siteurl = trailingslashit( strtolower( preg_replace( '/:.*$/', '', str_replace( 'http://', '', get_option( 'home' ) ) ) ) );
650
  // make sure the front page has a rebuild file
 
651
  prune_super_cache( $cache_path . 'supercache/' . $siteurl . 'index.html', true, true );
652
  prune_super_cache( $cache_path . 'supercache/' . $siteurl . 'index.html.gz', true, true );
653
  wp_cache_post_id_gc( $siteurl, $post_id );
@@ -710,17 +843,18 @@ function wp_cache_post_id() {
710
 
711
  function wp_cache_gc_cron() {
712
  global $file_prefix, $cache_max_time;
 
713
 
714
  if( !isset( $cache_max_time ) )
715
  $cache_max_time = 600;
716
 
717
  $start = time();
718
  if( !wp_cache_phase2_clean_expired($file_prefix ) ) {
719
- wp_cache_debug( 'Cache Expiry cron job failed. Probably mutex locked.' );
720
  update_option( 'wpsupercache_gc_time', time() - ( $cache_max_time - 10 ) ); // if GC failed then run it again in one minute
721
  }
722
  if( time() - $start > 30 )
723
- wp_cache_debug( "Cache Expiry cron job took more than 30 seconds to execute.\nYou should reduce the Expiry Time in the WP Super Cache admin page\nas you probably have more cache files than your server can handle efficiently." );
724
  }
725
 
726
  ?>
2
 
3
  function wp_cache_phase2() {
4
  global $cache_filename, $cache_acceptable_files, $wp_cache_gzip_encoding, $super_cache_enabled, $cache_rebuild_files, $wp_cache_gmt_offset, $wp_cache_blog_charset, $wp_cache_last_gc;
5
+ global $cache_max_time, $wp_cache_not_logged_in, $wp_cache_request_uri, $super_cache_enabled;
6
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'In WP Cache Phase 2', 5 );
7
 
8
  $wp_cache_gmt_offset = get_option( 'gmt_offset' ); // caching for later use when wpdb is gone. http://wordpress.org/support/topic/224349
9
  $wp_cache_blog_charset = get_option( 'blog_charset' );
10
 
11
  wp_cache_mutex_init();
12
  if(function_exists('add_action') && ( !defined( 'WPLOCKDOWN' ) || ( defined( 'WPLOCKDOWN' ) && constant( 'WPLOCKDOWN' ) == '0' ) ) ) {
13
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Setting up WordPress actions', 5 );
14
  // Post ID is received
15
  add_action('publish_post', 'wp_cache_post_edit', 0);
16
  add_action('edit_post', 'wp_cache_post_change', 0); // leaving a comment called edit_post
32
  do_cacheaction( 'add_cacheaction' );
33
  }
34
 
35
+ if ( is_admin() ) {
36
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching wp-admin requests.', 5 );
37
  return false;
38
+ }
39
+
40
+ if ( $_SERVER["REQUEST_METHOD"] == 'POST' || !empty( $_POST ) || get_option( 'gzipcompression' ) ) {
41
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching POST request.', 5 );
42
+ return false;
43
+ }
44
+
45
+ if ( isset( $_GET[ 'preview' ] ) ) {
46
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching preview post.', 2 );
47
+ return false;
48
+ }
49
+
50
+ if ( !empty( $_GET ) ) {
51
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Supercache caching disabled. Non empty GET request.', 5 );
52
+ $super_cache_enabled = false;
53
+ }
54
 
55
  if ( $wp_cache_not_logged_in && is_user_logged_in() && !is_feed() && !is_admin() ) {
56
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'not caching for logged in user', 5 );
57
  register_shutdown_function( 'wpcache_logged_in_message' );
58
  return false;
59
  }
60
 
61
  $script = basename($_SERVER['PHP_SELF']);
62
+ if (!in_array($script, $cache_acceptable_files) && wp_cache_is_rejected($wp_cache_request_uri)) {
63
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'URI rejected. Not Caching', 2 );
64
  return false;
65
+ }
66
+ if (wp_cache_user_agent_is_rejected()) {
67
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "USER AGENT ({$_SERVER[ 'HTTP_USER_AGENT' ]}) rejected. Not Caching", 4 );
68
+ return;
69
+ }
70
  if($wp_cache_gzip_encoding)
71
  header('Vary: Accept-Encoding, Cookie');
72
  else
73
  header('Vary: Cookie');
74
  ob_start( 'wp_cache_ob_callback' );
75
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Created output buffer', 4 );
76
 
77
  // restore old supercache file temporarily
78
  if( $super_cache_enabled && $cache_rebuild_files ) {
86
  continue;
87
  $mtime = @filemtime($cache_file . '.needs-rebuild');
88
  if( $mtime && (time() - $mtime) < 30 ) {
89
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Rebuild file renamed to cache file temporarily", 3 );
90
  @rename( $cache_file . '.needs-rebuild', $cache_file );
91
  }
92
  // cleanup old files or if rename fails
93
  if( @file_exists( $cache_file . '.needs-rebuild' ) ) {
94
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Rebuild file deleted", 3 );
95
  @unlink( $cache_file . '.needs-rebuild' );
96
  }
97
  }
111
 
112
  global $wp_cache_shutdown_gc;
113
  if( !isset( $wp_cache_shutdown_gc ) || $wp_cache_shutdown_gc == 0 ) {
114
+ if(!wp_next_scheduled('wp_cache_gc')) {
115
+ wp_schedule_single_event(time() + 10 , 'wp_cache_gc');
116
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'scheduled wp_cache_gc for 10 seconds time.', 5 );
117
+ }
118
  } else {
119
  global $time_to_gc_cache;
120
  $time_to_gc_cache = 1; // tell the "shutdown gc" to run!
173
  }
174
 
175
  function wp_cache_mutex_init() {
176
+ global $use_flock, $mutex, $cache_path, $mutex_filename, $sem_id, $blog_cache_dir, $wp_cache_mutex_disabled;
177
+
178
+ if( isset( $wp_cache_mutex_disabled ) && $wp_cache_mutex_disabled )
179
+ return true;
180
 
181
  if(!is_bool($use_flock)) {
182
  if(function_exists('sem_get'))
186
  }
187
 
188
  $mutex = false;
189
+ if ($use_flock) {
190
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Created mutex lock on filename: {$blog_cache_dir}{$mutex_filename}", 5 );
191
  $mutex = @fopen($blog_cache_dir . $mutex_filename, 'w');
192
+ } else {
193
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Created mutex lock on semaphore: $sem_id", 5 );
194
  $mutex = @sem_get($sem_id, 1, 0644 | IPC_CREAT, 1);
195
+ }
196
  }
197
 
198
  function wp_cache_writers_entry() {
201
  if( isset( $wp_cache_mutex_disabled ) && $wp_cache_mutex_disabled )
202
  return true;
203
 
204
+ if( !$mutex ) {
205
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "(writers entry) mutex lock not created. not caching.", 2 );
206
  return false;
207
+ }
208
 
209
+ if ($use_flock) {
210
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "grabbing lock using flock()", 5 );
211
  flock($mutex, LOCK_EX);
212
+ } else {
213
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "grabbing lock using sem_acquire()", 5 );
214
  sem_acquire($mutex);
215
+ }
216
 
217
  return true;
218
  }
223
  if( isset( $wp_cache_mutex_disabled ) && $wp_cache_mutex_disabled )
224
  return true;
225
 
226
+ if( !$mutex ) {
227
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "(writers exit) mutex lock not created. not caching.", 2 );
228
  return false;
229
+ }
230
 
231
+ if ($use_flock) {
232
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "releasing lock using flock()", 5 );
233
  flock($mutex, LOCK_UN);
234
+ } else {
235
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "releasing lock using sem_release()", 5 );
236
  sem_release($mutex);
237
+ }
238
  }
239
 
240
  function get_current_url_supercache_dir() {
248
  $dir = trailingslashit( ABSPATH . $uri );
249
  }
250
  $dir = str_replace( '//', '/', $dir );
251
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "supercache dir: $dir", 5 );
252
  return $dir;
253
  }
254
 
256
  global $wp_cache_pages;
257
  if( defined( 'DONOTCACHEPAGE' ) )
258
  return $buffer;
259
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Output buffer callback', 4 );
260
 
261
  if ( isset( $wp_cache_pages[ 'single' ] ) && $wp_cache_pages[ 'single' ] == 1 && is_single() ) {
262
  return $buffer;
272
  return $buffer;
273
  } elseif ( isset( $wp_cache_pages[ 'home' ] ) && $wp_cache_pages[ 'home' ] == 1 && is_home() ) {
274
  return $buffer;
275
+ } elseif ( isset( $wp_cache_pages[ 'search' ] ) && $wp_cache_pages[ 'search' ] == 1 && is_search() ) {
276
+ return $buffer;
277
+ } elseif ( isset( $wp_cache_pages[ 'feed' ] ) && $wp_cache_pages[ 'feed' ] == 1 && is_feed() ) {
278
+ return $buffer;
279
  }
280
  $buffer = &wp_cache_get_ob( $buffer );
281
  wp_cache_shutdown_callback();
288
  global $new_cache, $wp_cache_meta, $file_expired, $blog_id, $cache_compression;
289
  global $wp_cache_gzip_encoding, $super_cache_enabled, $cached_direct_pages;
290
  global $wp_cache_404, $gzsize, $supercacheonly, $wp_cache_gzip_first, $wp_cache_gmt_offset;
291
+ global $blog_cache_dir, $wp_cache_request_uri, $wp_supercache_cache_list;
292
 
293
  $new_cache = true;
294
  $wp_cache_meta = '';
295
 
296
  /* Mode paranoic, check for closing tags
297
  * we avoid caching incomplete files */
298
+ if ( $buffer == '' ) {
299
  $new_cache = false;
300
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) {
301
+ wp_cache_debug( "Buffer is blank. Output buffer may have been corrupted by another plugin or this is a redirected URL. Look for text 'ob_start' in the files of your plugins directory.", 2 );
302
+ $buffer .= "\n<!-- Page not cached by WP Super Cache. Blank Page. Check output buffer usage by plugins. -->\n";
303
+ }
304
+ }
305
+
306
+ if ( $wp_cache_404 && false == apply_filters( 'wpsupercache_404', false ) ) {
307
+ $new_cache = false;
308
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) {
309
+ wp_cache_debug( "404 file not found not cached", 2 );
310
+ $buffer .= "\n<!-- Page not cached by WP Super Cache. 404. -->\n";
311
+ }
312
  }
313
 
314
  if (!preg_match('/(<\/html>|<\/rss>|<\/feed>)/i',$buffer) ) {
315
  $new_cache = false;
316
+ if( false === strpos( $_SERVER[ 'REQUEST_URI' ], 'robots.txt' ) ) {
317
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) {
318
+ wp_cache_debug( "No closing html tag. Not caching.", 2 );
319
+ $buffer .= "\n<!-- Page not cached by WP Super Cache. No closing HTML tag. Check your theme. -->\n";
320
+ }
321
+ } else {
322
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "robots.txt detected. Not caching.", 2 );
323
+ }
324
  }
325
 
326
  if( !$new_cache )
332
 
333
  if( !wp_cache_writers_entry() ) {
334
  $buffer .= "\n<!-- Page not cached by WP Super Cache. Could not get mutex lock. -->\n";
335
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Could not get mutex lock. Not caching.", 1 );
336
  return $buffer;
337
  }
338
 
339
  $dir = get_current_url_supercache_dir();
340
  $supercachedir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $_SERVER["HTTP_HOST"]);
341
+ if( !empty( $_GET ) || is_feed() || ( $super_cache_enabled == true && is_dir( substr( $supercachedir, 0, -1 ) . '.disabled' ) ) ) {
342
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Supercache disabled: GET or feed detected or disabled by config.", 2 );
343
  $super_cache_enabled = false;
344
+ }
345
 
346
  $tmp_wpcache_filename = $cache_path . uniqid( mt_rand(), true ) . '.tmp';
347
 
348
  // Don't create wp-cache files for anon users
349
  $supercacheonly = false;
350
+ if( $super_cache_enabled && wp_cache_get_cookies_values() == '' ) {
351
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Anonymous user detected. Only creating Supercache file.", 3 );
352
  $supercacheonly = true;
353
+ }
354
 
355
  if( !$supercacheonly ) {
356
  if ( !@file_exists( $blog_cache_dir . $cache_filename ) || ( @file_exists( $blog_cache_dir . $cache_filename ) && ( time() - @filemtime( $blog_cache_dir . $cache_filename ) ) > 5 ) ) {
357
  $fr = @fopen($tmp_wpcache_filename, 'w');
358
  if (!$fr) {
359
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Error. Supercache could not write to " . str_replace( ABSPATH, '', $cache_path ) . $cache_filename, 1 );
360
  $buffer .= "<!-- File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $cache_path ) . $cache_filename . " -->\n";
361
  return $buffer;
362
  }
375
  if ( !@file_exists( $cache_fname ) || ( @file_exists( $cache_fname ) && ( time() - @filemtime( $cache_fname ) ) > 5 ) ) {
376
  $fr2 = @fopen( $tmp_cache_filename, 'w' );
377
  if (!$fr2) {
378
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Error. Supercache could not write to " . str_replace( ABSPATH, '', $tmp_cache_filename ), 1 );
379
  $buffer .= "<!-- File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $tmp_cache_filename ) . " -->\n";
380
  @fclose( $fr );
381
  @unlink( $tmp_wpcache_filename );
383
  } elseif( $cache_compression ) {
384
  $gz = @fopen( $tmp_cache_filename . ".gz", 'w');
385
  if (!$gz) {
386
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Error. Supercache could not write to " . str_replace( ABSPATH, '', $tmp_cache_filename ) . ".gz", 1 );
387
  $buffer .= "<!-- File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $tmp_cache_filename ) . ".gz -->\n";
388
  @fclose( $fr );
389
  @unlink( $tmp_wpcache_filename );
397
  }
398
 
399
  if (preg_match('/<!--mclude|<!--mfunc/', $buffer)) { //Dynamic content
400
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Dynamic content found in buffer.", 4 );
401
  $store = preg_replace('|<!--mclude (.*?)-->(.*?)<!--/mclude-->|is',
402
  "<!--mclude-->\n<?php include_once('" . ABSPATH . "$1'); ?>\n<!--/mclude-->", $buffer);
403
  $store = preg_replace('|<!--mfunc (.*?)-->(.*?)<!--/mfunc-->|is',
418
  $buffer .= "<!-- Cached page generated by WP-Super-Cache on " . gmdate('Y-m-d H:i:s', (time() + ( $wp_cache_gmt_offset * 3600))) . " -->\n";
419
 
420
  if( $gz || $wp_cache_gzip_encoding ) {
421
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Gzipping buffer.", 5 );
422
  $gzdata = gzencode( $buffer . "<!-- Compression = gzip -->", 3, FORCE_GZIP );
423
  $gzsize = strlen($gzdata);
424
  }
426
  $wp_cache_meta[ 'headers' ][ 'Content-Encoding' ] = 'Content-Encoding: ' . $wp_cache_gzip_encoding;
427
  $wp_cache_meta[ 'headers' ][ 'Vary' ] = 'Vary: Accept-Encoding, Cookie';
428
  // Return uncompressed data & store compressed for later use
429
+ if( $fr ) {
430
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Writing gzipped buffer to wp-cache cache file.", 5 );
431
  fputs($fr, $gzdata);
432
+ }
433
  } else { // no compression
434
  $wp_cache_meta[ 'headers' ][ 'Vary' ] = 'Vary: Cookie';
435
+ if( $fr ) {
436
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Writing non-gzipped buffer to wp-cache cache file.", 5 );
437
  fputs($fr, $buffer);
438
+ }
439
  }
440
+ if( $fr2 ) {
441
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Writing non-gzipped buffer to supercache file.", 5 );
442
  fputs($fr2, $buffer . '<!-- super cache -->' );
443
+ }
444
+ if( $gz ) {
445
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Writing gzipped buffer to supercache file.", 5 );
446
  fwrite($gz, $gzdata );
447
+ }
448
  $buffer .= $log;
449
  }
450
  $new_cache = true;
451
+ $added_cache = 0;
452
  if( $fr ) {
453
  $supercacheonly = false;
454
  fclose($fr);
456
  unlink( $blog_cache_dir . $cache_filename );
457
  rename( $tmp_wpcache_filename, $blog_cache_dir . $cache_filename );
458
  }
459
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Renamed temp wp-cache file to {$blog_cache_dir}$cache_filename", 5 );
460
+ $added_cache = 1;
461
  }
462
  if( $fr2 ) {
463
  fclose($fr2);
465
  @unlink( $cache_fname );
466
  @rename( $tmp_cache_filename, $cache_fname );
467
  }
468
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Renamed temp supercache file to $cache_fname", 5 );
469
+ $added_cache = 1;
470
  }
471
  if( $gz ) {
472
  fclose($gz);
474
  @unlink( $cache_fname . '.gz' );
475
  @rename( $tmp_cache_filename . '.gz', $cache_fname . '.gz' );
476
  }
477
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Renamed temp supercache gz file to {$cache_fname}.gz", 5 );
478
+ $added_cache = 1;
479
+ }
480
+ if ( $added_cache && isset( $wp_supercache_cache_list ) && $wp_supercache_cache_list ) {
481
+ update_option( 'wpsupercache_count', ( get_option( 'wpsupercache_count' ) + 1 ) );
482
+ $last_urls = (array)get_option( 'supercache_last_cached' );
483
+ if ( count( $last_urls ) >= 10 )
484
+ $last_urls = array_slice( $last_urls, 1, 9 );
485
+ $last_urls[] = array( 'url' => $_SERVER[ 'REQUEST_URI' ], 'date' => date( 'Y-m-d H:i:s' ) );
486
+ update_option( 'supercache_last_cached', $last_urls );
487
  }
488
  wp_cache_writers_exit();
489
  if ( !headers_sent() && isset( $wp_cache_gzip_first ) && 1 == $wp_cache_gzip_first && $wp_cache_gzip_encoding && $gzdata) {
490
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Writing gzip content headers. Sending buffer to browser", 5 );
491
  header( 'Content-Encoding: ' . $wp_cache_gzip_encoding );
492
  header( 'Vary: Accept-Encoding, Cookie' );
493
  header( 'Content-Length: ' . $gzsize );
494
  return $gzdata;
495
  } else {
496
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Sending buffer to browser", 5 );
497
  return $buffer;
498
  }
499
  }
503
 
504
  if( !wp_cache_writers_entry() )
505
  return false;
506
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Cleaning cache in $blog_cache_dir", 3 );
507
  if ( ( $handle = @opendir( $blog_cache_dir ) ) ) {
508
  while ( false !== ($file = @readdir($handle))) {
509
  if ( preg_match("/^$file_prefix/", $file) )
550
  }
551
  if( $donotdelete )
552
  continue;
553
+ if( !$rename ) {
554
  @rmdir( $entry );
555
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "gc: deleted $entry", 2 );
556
+ }
557
  }
558
  }
559
  closedir($dh);
577
  if( $cache_rebuild_files && substr( $file, -14 ) != '.needs-rebuild' ) {
578
  if( @rename($file, $file . '.needs-rebuild') ) {
579
  @touch( $file . '.needs-rebuild' );
580
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "rebuild_or_gc: rename to {$file}.needs-rebuild", 2 );
581
  } else {
582
  @unlink( $file );
583
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "rebuild_or_gc: deleted $file", 2 );
584
  }
585
  } else {
586
  @unlink( $file );
587
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "rebuild_or_gc: deleted $file", 2 );
588
  }
589
  }
590
 
595
  if( !wp_cache_writers_entry() )
596
  return false;
597
  $now = time();
598
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Cleaning expired cache files in $blog_cache_dir", 2 );
599
  if ( ( $handle = @opendir( $blog_cache_dir ) ) ) {
600
  while ( false !== ($file = readdir($handle))) {
601
  if ( preg_match("/^$file_prefix/", $file) &&
602
  (@filemtime( $blog_cache_dir . $file) + $cache_max_time) <= $now ) {
603
  @unlink( $blog_cache_dir . $file );
604
  @unlink( $blog_cache_dir . 'meta/' . str_replace( '.html', '.meta', $file ) );
605
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Deleting $blog_cache_dir{$file} (plus meta)", 5 );
606
  continue;
607
  }
608
  if($file != '.' && $file != '..') {
609
  if( is_dir( $blog_cache_dir . $file ) == false && (@filemtime($blog_cache_dir . $file) + $cache_max_time) <= $now ) {
610
+ if( substr( $file, -9 ) != '.htaccess' ) {
611
  @unlink($blog_cache_dir . $file);
612
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Deleting $blog_cache_dir{$file}", 5 );
613
+ }
614
  }
615
  }
616
  }
617
  closedir($handle);
618
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Doing GC on supercache dir: {$cache_path}supercache", 2 );
619
  prune_super_cache( $cache_path . 'supercache' );
620
  }
621
 
625
 
626
  function wp_cache_shutdown_callback() {
627
  global $cache_path, $cache_max_time, $file_expired, $file_prefix, $meta_file, $new_cache, $wp_cache_meta, $known_headers, $blog_id, $wp_cache_gzip_encoding, $gzsize, $cache_filename, $supercacheonly, $blog_cache_dir;
628
+ global $wp_cache_blog_charset, $wp_cache_request_uri, $wp_cache_key;
629
 
630
  $wp_cache_meta[ 'uri' ] = $_SERVER["SERVER_NAME"].preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', $wp_cache_request_uri); // To avoid XSS attacks
631
  $wp_cache_meta[ 'blog_id' ] = $blog_id;
632
  $wp_cache_meta[ 'post' ] = wp_cache_post_id();
633
+ $wp_cache_meta[ 'key' ] = $wp_cache_key;
634
+ $wp_cache_meta = apply_filters( 'wp_cache_meta', $wp_cache_meta );
635
 
636
  $response = wp_cache_get_response_headers();
637
  foreach ($known_headers as $key) {
672
  }
673
  $value .= "; charset=\"" . $wp_cache_blog_charset . "\"";
674
 
675
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Sending 'Content-Type: $value' header.", 2 );
676
  @header("Content-Type: $value");
677
  $wp_cache_meta[ 'headers' ][ 'Content-Type' ] = "Content-Type: $value";
678
  }
679
 
680
  if ( ! $supercacheonly && $new_cache ) {
681
  if( $wp_cache_gzip_encoding && !in_array( 'Content-Encoding: ' . $wp_cache_gzip_encoding, $wp_cache_meta[ 'headers' ] ) ) {
682
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Sending gzip headers.", 2 );
683
  $wp_cache_meta[ 'headers' ][ 'Content-Encoding' ] = 'Content-Encoding: ' . $wp_cache_gzip_encoding;
684
  $wp_cache_meta[ 'headers' ][ 'Vary' ] = 'Vary: Accept-Encoding, Cookie';
685
  }
686
 
687
  $serial = serialize($wp_cache_meta);
688
  if( wp_cache_writers_entry() ) {
689
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Writing meta file: {$blog_cache_dir}meta/{$meta_file}", 2 );
690
  $tmp_meta_filename = $blog_cache_dir . 'meta/' . uniqid( mt_rand(), true ) . '.tmp';
691
  $fr = @fopen( $tmp_meta_filename, 'w');
692
  if( !$fr )
703
  }
704
  }
705
  global $time_to_gc_cache;
706
+ if( isset( $time_to_gc_cache ) && $time_to_gc_cache == 1 ) {
707
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Executing wp_cache_gc action.", 3 );
708
  do_action( 'wp_cache_gc' );
709
+ }
710
  }
711
 
712
  function wp_cache_no_postid($id) {
721
  // http://ocaoimh.ie/2006/12/05/caching-wordpress-with-wp-cache-in-a-spam-filled-world
722
  if( !preg_match('/wp-admin\//', $wp_cache_request_uri) )
723
  if( $comment['comment_approved'] == 'spam' ) { // changed from 1 to "spam"
724
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Spam comment. Don't delete any cache files.", 4 );
725
  return $postid;
726
  } elseif( $comment['comment_approved'] == '0' ) {
727
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Moderated comment. Don't delete supercache file until comment approved.", 4 );
728
  $super_cache_enabled = 0; // don't remove the super cache static file until comment is approved
729
  }
730
  // We must check it up again due to WP bugs calling two different actions
731
  // for delete, for example both wp_set_comment_status and delete_comment
732
  // are called when deleting a comment
733
+ if ($postid > 0) {
734
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Post $postid changed. Update cache.", 4 );
735
  return wp_cache_post_change($postid);
736
+ } else {
737
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Unknown post changed. Update cache.", 4 );
738
  return wp_cache_post_change(wp_cache_post_id());
739
+ }
740
  }
741
 
742
  function wp_cache_post_edit($post_id) {
743
  global $wp_cache_clear_on_post_edit, $cache_path, $blog_cache_dir;
744
  if( $wp_cache_clear_on_post_edit ) {
745
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Clearing cache $blog_cache_dir and {$cache_path}supercache/ on post edit per config.", 2 );
746
  prune_super_cache( $blog_cache_dir, true );
747
  prune_super_cache( $cache_path . 'supercache/', true );
748
  } else {
749
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Clearing cache for post $post_id on post edit.", 2 );
750
  wp_cache_post_change( $post_id );
751
  }
752
  }
760
 
761
  $permalink = trailingslashit( str_replace( get_option( 'home' ), '', post_permalink( $post_id ) ) );
762
  $dir = $cache_path . 'supercache/' . $siteurl;
763
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_post_id_gc clearing cache in $dir{$permalink}.", 4 );
764
  prune_super_cache( $dir . $permalink, true, true );
765
  @rmdir( $dir . $permalink );
766
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_post_id_gc clearing cache in {$dir}page/.", 4 );
767
  prune_super_cache( $dir . 'page/', true );
768
  }
769
 
780
  if( $super_cache_enabled ) {
781
  $siteurl = trailingslashit( strtolower( preg_replace( '/:.*$/', '', str_replace( 'http://', '', get_option( 'home' ) ) ) ) );
782
  // make sure the front page has a rebuild file
783
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Post change: deleting cache files in " . $cache_path . 'supercache/' . $siteurl, 4 );
784
  prune_super_cache( $cache_path . 'supercache/' . $siteurl . 'index.html', true, true );
785
  prune_super_cache( $cache_path . 'supercache/' . $siteurl . 'index.html.gz', true, true );
786
  wp_cache_post_id_gc( $siteurl, $post_id );
843
 
844
  function wp_cache_gc_cron() {
845
  global $file_prefix, $cache_max_time;
846
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Cache garbage collection.', 5 );
847
 
848
  if( !isset( $cache_max_time ) )
849
  $cache_max_time = 600;
850
 
851
  $start = time();
852
  if( !wp_cache_phase2_clean_expired($file_prefix ) ) {
853
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Cache Expiry cron job failed. Probably mutex locked.', 1 );
854
  update_option( 'wpsupercache_gc_time', time() - ( $cache_max_time - 10 ) ); // if GC failed then run it again in one minute
855
  }
856
  if( time() - $start > 30 )
857
+ if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Cache Expiry cron job took more than 30 seconds to execute.\nYou should reduce the Expiry Time in the WP Super Cache admin page\nas you probably have more cache files than your server can handle efficiently.", 1 );
858
  }
859
 
860
  ?>
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 plugin for WordPress.
6
- Version: 0.9.6.1
7
  Author: Donncha O Caoimh
8
  Author URI: http://ocaoimh.ie/
9
  */
@@ -48,6 +48,10 @@ $wp_cache_file = WPCACHEHOME . 'advanced-cache.php';
48
 
49
  include(WPCACHEHOME . 'wp-cache-base.php');
50
 
 
 
 
 
51
 
52
  // from legolas558 d0t users dot sf dot net at http://www.php.net/is_writable
53
  function is_writeable_ACLSafe($path) {
@@ -76,7 +80,7 @@ function get_wpcachehome() {
76
  } elseif( is_file( dirname(__FILE__) . '/wp-super-cache/wp-cache-config-sample.php' ) ) {
77
  define( 'WPCACHEHOME', dirname(__FILE__) . '/wp-super-cache/' );
78
  } else {
79
- die( 'Please create ' . WP_CONTENT_DIR . '/wp-cache-config.php from wp-super-cache/wp-cache-config-sample.php' );
80
  }
81
  }
82
  }
@@ -100,7 +104,7 @@ register_deactivation_hook( __FILE__, 'wpsupercache_deactivate' );
100
  function wp_cache_add_pages() {
101
  if( function_exists( 'is_site_admin' ) ) {
102
  if( is_site_admin() ) {
103
- add_submenu_page('wpmu-admin.php', __('WP Super Cache'), __('WP Super Cache'), 'manage_options', 'wpsupercache', 'wp_cache_manager');
104
  add_options_page('WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager');
105
  }
106
  } else {
@@ -112,7 +116,7 @@ add_action('admin_menu', 'wp_cache_add_pages');
112
  function wp_cache_manager() {
113
  global $wp_cache_config_file, $valid_nonce, $supercachedir, $cache_path, $cache_enabled, $cache_compression, $super_cache_enabled, $wp_cache_hello_world;
114
  global $wp_cache_clear_on_post_edit, $cache_rebuild_files, $wp_cache_mutex_disabled, $wp_cache_mobile_enabled, $wp_cache_mobile_whitelist, $wp_cache_mobile_browsers;
115
- global $wp_cache_cron_check, $wp_cache_debug, $wp_cache_hide_donation, $wp_cache_not_logged_in;
116
 
117
  if( function_exists( 'is_site_admin' ) )
118
  if( !is_site_admin() )
@@ -154,24 +158,25 @@ jQuery(document).ready(function(){
154
  <?php
155
  echo '<div class="wrap">';
156
  echo "<h2>WP Super Cache Manager</h2>\n";
157
- if( ini_get( 'safe_mode' ) ) {
158
- ?><h3>Warning! PHP Safe Mode Enabled!</h3>
159
- <p>You may experience problems running this plugin because SAFE MODE is enabled. <?php
160
  if( !ini_get( 'safe_mode_gid' ) ) {
161
- ?>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
 
162
  } else {
163
- ?>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
164
  }
165
  }
166
  if(isset($_REQUEST['wp_restore_config']) && $valid_nonce) {
167
  unlink($wp_cache_config_file);
168
- echo '<strong>Configuration file changed, some values might be wrong. Load the page again from the "Settings" menu to reset them.</strong>';
169
  }
170
 
171
  if ( !wp_cache_check_link() ||
172
  !wp_cache_verify_config_file() ||
173
  !wp_cache_verify_cache_dir() ) {
174
- echo "Cannot continue... fix previous problems and retry.";
175
  echo "</div>\n";
176
  return;
177
  }
@@ -187,10 +192,10 @@ jQuery(document).ready(function(){
187
  $hostname = substr( $hostname, 0, strpos( $hostname, '/' ) );
188
  $ip = gethostbyname( $hostname );
189
  if( substr( $ip, 0, 3 ) == '127' || substr( $ip, 0, 7 ) == '192.168' ) {
190
- ?><h3>Warning! Your hostname "<?php echo $hostname; ?>" resolves to <?php echo $ip; ?></h3>
191
  <div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'>
192
- <p>Your server thinks your hostname resolves to <?php echo $ip; ?>. Some services such as garbage collection by this plugin, and WordPress scheduled posts may not operate correctly.</p>
193
- <p>Please see entry 16 in the <a href="http://wordpress.org/extend/plugins/wp-super-cache/faq/">Troubleshooting section</a> of the readme.txt</p>
194
  </div>
195
  <?php
196
  } else {
@@ -203,8 +208,8 @@ jQuery(document).ready(function(){
203
  if( $cron[ 'response' ][ 'code' ] == '404' ) {
204
  ?><h3>Warning! wp-cron.php not found!</h3>
205
  <div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'>
206
- <p>Unfortunately WordPress cannot find the file wp-cron.php. This script is required for the the correct operation of garbage collection by this plugin, WordPress scheduled posts as well as other critical activities.</p>
207
- <p>Please see entry 16 in the <a href="http://wordpress.org/extend/plugins/wp-super-cache/faq/">Troubleshooting section</a> of the readme.txt</p>
208
  </div>
209
  <?php
210
  } else {
@@ -215,18 +220,18 @@ jQuery(document).ready(function(){
215
  }
216
 
217
  if( $cache_enabled == true && $super_cache_enabled == true && !got_mod_rewrite() ) {
218
- ?><h4 style='color: #a00'>Mod rewrite may not be installed!</h4>
219
- <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
220
  }
221
 
222
  if( !is_writeable_ACLSafe($wp_cache_config_file) ) {
223
  define( "SUBMITDISABLED", 'disabled style="color: #aaa" ' );
224
- ?><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>
225
  <div id='readonlywarning' style='border: 1px solid #aaa; margin: 2px; padding: 2px; display: none;'>
226
- <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.
227
- 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.
228
- Writeable: <code>chmod 666 <?php echo WP_CONTENT_DIR; ?>/wp-cache-config.php</code>
229
- Readonly: <code>chmod 644 <?php echo WP_CONTENT_DIR; ?>/wp-cache-config.php</code></p>
230
  </div><?php
231
  } else {
232
  define( "SUBMITDISABLED", ' ' );
@@ -238,8 +243,8 @@ jQuery(document).ready(function(){
238
  $wp_content_stat = stat(WP_CONTENT_DIR . '/');
239
  $wp_content_mode = ($wp_content_stat['mode'] & 0777);
240
  if( $wp_content_mode != 0755 ) {
241
- ?><h4 style='text-align:center; color: #a00'>Warning! <?php echo WP_CONTENT_DIR; ?> is writeable!</h4>
242
- <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:<code>chmod 755 <?php echo WP_CONTENT_DIR; ?>/</code></p><?php
243
  }
244
  }
245
 
@@ -257,6 +262,10 @@ jQuery(document).ready(function(){
257
  wp_cache_replace_line('^ *\$wp_cache_mobile_browsers', "\$wp_cache_mobile_browsers = 'Android, 2.0 MMP, 240x320, AvantGo, BlackBerry, Blazer, Cellphone, Danger, DoCoMo, Elaine/3.0, EudoraWeb, hiptop, IEMobile, iPhone, iPod, KYOCERA/WX310K, LG/U990, MIDP-2.0, MMEF20, MOT-V, NetFront, Newt, Nintendo Wii, Nitro, Nokia, Opera Mini, Palm, Playstation Portable, portalmmm, Proxinet, ProxiNet, SHARP-TQ-GX10, Small, SonyEricsson, Symbian OS, SymbianOS, TS21i-10, UP.Browser, UP.Link, Windows CE, WinWAP';", $wp_cache_config_file);
258
  }
259
  wp_cache_replace_line('^ *\$wp_cache_mobile_enabled', "\$wp_cache_mobile_enabled = " . $wp_cache_mobile_enabled . ";", $wp_cache_config_file);
 
 
 
 
260
  switch( $_POST[ 'wp_cache_status' ] ) {
261
  case 'all':
262
  wp_cache_enable();
@@ -323,51 +332,57 @@ jQuery(document).ready(function(){
323
  }
324
  }
325
 
 
326
  ?>
327
  <table><td><fieldset class="options" id="show-this-fieldset">
328
- <h3>WP Super Cache Status</h3><?php
329
- echo '<form name="wp_manager" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
330
  ?>
331
- <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> <span class="setting-description">WP Cache and Super Cache enabled</span></label><br />
332
- <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> <span class="setting-description">Super Cache Disabled, only legacy WP-Cache caching.</span></label><br />
333
- <label><input type='radio' name='wp_cache_status' value='none' <?php if( $cache_enabled == false ) { echo 'checked=checked'; } ?>> <strong>OFF</strong> <span class="setting-description">WP Cache and Super Cache disabled</span></label><br />
334
- <p><label><input type='checkbox' name='wp_cache_not_logged_in' <?php if( $wp_cache_not_logged_in ) echo "checked"; ?> value='1'> Don't cache pages for logged in users.</label></p>
335
- <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>
336
- <p><label><input type='checkbox' name='wp_cache_clear_on_post_edit' <?php if( $wp_cache_clear_on_post_edit ) echo "checked"; ?> value='1'> Clear all cache files when a post or page is published. (This may significantly slow down saving of posts.)</label></p>
337
- <p><label><input type='checkbox' name='cache_rebuild_files' <?php if( $cache_rebuild_files ) echo "checked"; ?> value='1'> Cache rebuild. Serve a supercache file to anonymous users while a new file is being generated. Recommended for <em>very</em> busy websites with lots of comments. Makes "directly cached pages" and "Lockdown mode" obsolete.</label></p>
338
  <?php if( false == defined( 'WPSC_DISABLE_LOCKING' ) ) { ?>
339
- <p><label><input type='checkbox' name='wp_cache_mutex_disabled' <?php if( !$wp_cache_mutex_disabled ) echo "checked"; ?> value='0'> Coarse file locking. You probably don't need this but it may help if your server is underpowered. Warning! <em>May cause your server to lock up in very rare cases!</em></label></p>
340
  <?php } ?>
341
- <p><label><input type='checkbox' name='wp_cache_mobile_enabled' <?php if( $wp_cache_mobile_enabled ) echo "checked"; ?> value='1'> Mobile device support.</label>
 
342
  <?php
343
  $home_path = trailingslashit( get_home_path() );
344
- if ( false === strpos( implode( "\n", extract_from_markers( $home_path.'.htaccess', 'WPSuperCache' ) ), 'SHARP-TQ-GX10' ) ) { // we don't have the rewrite rules
 
 
 
 
345
  ?>
346
- <blockquote><p>Mobile support requires extra rules in your .htaccess file, or you can set the plugin to half-on mode. Here's your options (in order of difficulty):
347
- <ol><li> 1. Set the plugin to half on mode and enable mobile support.</li>
348
- <li> 2. Delete the plugin mod_rewrite rules in <?php echo $home_path; ?>.htaccess enclosed by <code># BEGIN WPSuperCache</code> and <code># END WPSuperCache</code> and let the plugin regenerate them by reloading this page.</li>
349
- <li> 3. Add the rules yourself. Edit <?php echo $home_path; ?>.htaccess and find the block of code enclosed by the lines <code># BEGIN WPSuperCache</code> and <code># END WPSuperCache</code>. There are two sections that look very similar. Just below the line <code>%{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$</code> add this line: (do it twice, once for each section)</p>
350
- <div style='border: 1px solid #333; width:400px; overflow: scroll'><pre>RewriteCond %{HTTP_user_agent} !^.*(Android|2.0\ MMP|240x320|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|hiptop|IEMobile|iPhone|iPod|KYOCERA/WX310K|LG/U990|MIDP-2.0|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|Playstation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|Windows\ CE|WinWAP).*</pre></div></li></ol></blockquote>
351
- <?php } ?>
352
- <p><strong>Note:</strong> If uninstalling this plugin, make sure the directory <em><?php echo WP_CONTENT_DIR; ?></em> is writeable by the webserver so the files <em>advanced-cache.php</em> and <em>cache-config.php</em> can be deleted automatically. (Making sure those files are writeable too is probably a good idea!)</p>
353
- <p>Uninstall using the <a href="<?php echo WP_PLUGIN_URL; ?>/wp-super-cache/uninstall.php">uninstall script</a> to remove files and directories created by the plugin. (Please see <a href="<?php echo WP_PLUGIN_URL; ?>/wp-super-cache/readme.txt">readme.txt</a> for instructions on uninstalling this script.)</p>
354
  <?php
355
- echo "<div class='submit'><input type='submit' " . SUBMITDISABLED . " value='Update Status &raquo;' /></div>";
356
  wp_nonce_field('wp-cache');
357
  ?>
358
  </form>
359
  <?php
360
  if( $super_cache_enabled && function_exists( 'apache_get_modules' ) ) {
361
  $mods = apache_get_modules();
362
- $required_modules = array( 'mod_mime' => 'Required to serve compressed supercache files properly.', 'mod_headers' => 'Required to set caching information on supercache pages. IE7 users will see old pages without this module.', 'mod_expires' => 'Set the expiry date on supercached pages. Visitors may not see new pages when they refresh or leave comments without this module.' );
363
  foreach( $required_modules as $req => $desc ) {
364
  if( !in_array( $req, $mods ) ) {
365
  $missing_mods[ $req ] = $desc;
366
  }
367
  }
368
  if( isset( $missing_mods) && is_array( $missing_mods ) ) {
369
- echo "<h3>Missing Apache Modules</h3>";
370
- echo "<p>The following Apache modules are missing. The plugin will work in half-on mode without them. In full Supercache mode, your visitors may see corrupted pages or out of date content however.</p>";
371
  echo "<ul>";
372
  foreach( $missing_mods as $req => $desc ) {
373
  echo "<li> $req - $desc</li>";
@@ -379,12 +394,12 @@ jQuery(document).ready(function(){
379
  </fieldset>
380
  </td><td valign='top'>
381
  <div style='background: #ffc; border: 1px solid #333; margin: 2px; padding: 5px'>
382
- <h3 align='center'>Make WordPress Faster</h3>
383
  <?php if( $wp_cache_hide_donation != 1 ) { ?>
384
- <p><a href="http://ocaoimh.ie/wp-super-cache/?r=wpsc">WP Super Cache</a> really makes your blog go faster. Make it go faster<sup>*</sup> by buying me an <a href="http://ocaoimh.ie/agc">Amazon gift card</a>! Make it out to "donncha@ocaoimh.ie". A £10 card would be nice but it's up to you how much you think this plugin is worth to you.</p>
385
- <p>If Amazon isn't your thing, there's also PayPal. Click the "Donate" button below or take a quick peek at my <a href="http://ocaoimh.ie/wish">wishlist</a>.</p>
386
- <p>Thanks in advance!<br />Donncha<br />
387
- <small>* Ok, it won't go any faster but you'll make this plugin author very happy!</small></p>
388
  <div align='center'>
389
  <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
390
  <input type="hidden" name="cmd" value="_s-xclick"/>
@@ -392,12 +407,38 @@ jQuery(document).ready(function(){
392
  <input type="image" src="https://www.paypal.com/en_GB/i/btn/btn_donate_SM.gif" border="0" name="submit" alt=""/>
393
  <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"/><br />
394
  </form>
395
- <p>Don't show me this again. <form action="<?php echo $_SERVER["REQUEST_URI"]; ?>" method="post"><input type='hidden' name='wp_cache_hide_donation' value='1' /><input type='submit' value='Hide' /><?php wp_nonce_field('wp-cache'); ?></form></p>
396
  </div>
397
  <?php } else { ?>
398
- <p><a href="http://ocaoimh.ie/wp-super-cache/?r=supercache">WP Super Cache</a> is maintained and developed by <a href="http://ocaoimh.ie/?r=supercache">Donncha O Caoimh</a> with contributions from many others.</p>
399
- <p>He blogs at <a href="http://ocaoimh.ie/?r=supercache">Holy Shmoly</a>, posts photos at <a href="http://inphotos.org/?r=supercache">In Photos.org</a> and <a href="http://ocaoimh.ie/gad">wishes</a> he had more time to read and relax.</p><p>Please say hi to him on <a href="http://twitter.com/donncha/">Twitter</a> too!</p>
400
- <?php } ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
401
  </div>
402
 
403
  </td></table>
@@ -409,7 +450,7 @@ jQuery(document).ready(function(){
409
 
410
  wp_cache_edit_max_time();
411
 
412
- echo '<a name="files"></a><fieldset class="options"><h3>Accepted Filenames &amp; Rejected URIs</h3>';
413
  wp_cache_edit_rejected_pages();
414
  echo "\n";
415
  wp_cache_edit_rejected();
@@ -419,6 +460,7 @@ jQuery(document).ready(function(){
419
 
420
  wp_cache_edit_rejected_ua();
421
 
 
422
 
423
  wp_lock_down();
424
 
@@ -433,7 +475,7 @@ jQuery(document).ready(function(){
433
  $out = ob_get_contents();
434
  ob_end_clean();
435
  if( SUBMITDISABLED == ' ' && $out != '' ) {
436
- echo '<fieldset class="options"><h3>Cache Plugins</h3>';
437
  echo $out;
438
  echo '</fieldset>';
439
  }
@@ -442,24 +484,31 @@ jQuery(document).ready(function(){
442
  }
443
 
444
  function wsc_mod_rewrite() {
445
- global $super_cache_enabled, $cache_compression, $cache_compression_changed, $valid_nonce, $cache_path;
446
- if( $super_cache_enabled == false )
 
 
 
447
  return;
 
 
 
448
  if( false == defined( 'WPSC_DISABLE_COMPRESSION' ) ) {
449
  ?>
 
450
  <fieldset class="options">
451
- <h3>Super Cache Compression</h3>
452
- <form name="wp_manager" action="<?php echo $_SERVER["REQUEST_URI"]; ?>" method="post">
453
- <label><input type="radio" name="cache_compression" value="1" <?php if( $cache_compression ) { echo "checked=checked"; } ?>> Enabled</label>
454
- <label><input type="radio" name="cache_compression" value="0" <?php if( !$cache_compression ) { echo "checked=checked"; } ?>> Disabled</label>
455
- <p>Compression is disabled by default because some hosts have problems with compressed files. Switching this on and off clears the cache.</p>
456
  <?php
457
  if( isset( $cache_compression_changed ) && isset( $_POST[ 'cache_compression' ] ) && !$cache_compression ) {
458
- ?><p><strong>Super Cache compression is now disabled.</strong></p> <?php
459
  } elseif( isset( $cache_compression_changed ) && isset( $_POST[ 'cache_compression' ] ) && $cache_compression ) {
460
- ?><p><strong>Super Cache compression is now enabled.</strong></p><?php
461
  }
462
- echo '<div class="submit"><input ' . SUBMITDISABLED . 'type="submit" value="Update Compression &raquo;" /></div>';
463
  wp_nonce_field('wp-cache');
464
  echo "</form>\n";
465
  ?></fieldset>
@@ -476,7 +525,6 @@ function wsc_mod_rewrite() {
476
  }
477
  $home_path = get_home_path();
478
  $home_root = parse_url(get_bloginfo('url'));
479
- $home_root = trailingslashit($home_root['path']);
480
  $home_root = isset( $home_root['path'] ) ? trailingslashit( $home_root['path'] ) : '/';
481
  $inst_root = str_replace( '//', '/', '/' . trailingslashit( str_replace( $document_root, '', str_replace( '\\', '/', WP_CONTENT_DIR ) ) ) );
482
  $wprules = implode( "\n", extract_from_markers( $home_path.'.htaccess', 'WordPress' ) );
@@ -488,10 +536,10 @@ function wsc_mod_rewrite() {
488
  $condition_rules[] = "RewriteCond %{REQUEST_URI} !^.*[^/]$";
489
  $condition_rules[] = "RewriteCond %{REQUEST_URI} !^.*//.*$";
490
  }
491
- $condition_rules[] = "RewriteCond %{REQUEST_METHOD} !=POST";
492
  $condition_rules[] = "RewriteCond %{QUERY_STRING} !.*=.*";
493
- $condition_rules[] = "RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$";
494
- $condition_rules[] = "RewriteCond %{HTTP_user_agent} !^.*(Android|2.0\\ MMP|240x320|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|hiptop|IEMobile|iPhone|iPod|KYOCERA/WX310K|LG/U990|MIDP-2.0|MMEF20|MOT-V|NetFront|Newt|Nintendo\\ Wii|Nitro|Nokia|Opera\\ Mini|Palm|Playstation\\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|Small|SonyEricsson|Symbian\\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|Windows\\ CE|WinWAP).*";
495
  $condition_rules = apply_filters( 'supercacherewriteconditions', $condition_rules );
496
 
497
  $rules = "<IfModule mod_rewrite.c>\n";
@@ -514,23 +562,22 @@ function wsc_mod_rewrite() {
514
 
515
  $dohtaccess = true;
516
  if( function_exists( 'is_site_admin' ) ) {
517
- echo "<h4 style='color: #a00'>WordPress MU Detected</h4><p>Unfortunately the rewrite rules cannot be updated automatically when running WordPress MU. Please open your .htaccess and add the following mod_rewrite rules above any other rules in that file.</p>";
518
  } elseif( !$wprules || $wprules == '' ) {
519
- echo "<h4 style='color: #a00'>Mod Rewrite rules cannot be updated!</h4>";
520
- 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:
521
- <blockquote><pre><em># BEGIN WordPress</em>\n RewriteCond %{REQUEST_FILENAME} !-f\n RewriteCond %{REQUEST_FILENAME} !-d\n RewriteRule . /index.php [L]\n <em># END WordPress</em></pre></blockquote>
522
- Refresh this page when you have updated your .htaccess file.";
523
  echo "</fieldset></div>";
524
  return;
525
  } elseif( strpos( $wprules, 'wordpressuser' ) ) { // Need to clear out old mod_rewrite rules
526
- 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 changes are 'HTTP_COOKIE' becomes 'HTTP:Cookie' and '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>";
527
  echo "</fieldset></div>";
528
  return;
529
  } elseif( $scrules != '' && strpos( $scrules, '%{REQUEST_URI} !^.*[^/]$' ) === false && substr( get_option( 'permalink_structure' ), -1 ) == '/' ) { // permalink structure has a trailing slash, need slash check in rules.
530
- echo "<div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><h4>Trailing slash check required.</h4><p>It looks like your blog has URLs that end with a '/'. Unfortunately since you installed this plugin a duplicate content bug has been found where URLs not ending in a '/' end serve the same content as those with the '/' and do not redirect to the proper URL.";
531
- echo "To fix, you must edit your .htaccess file and add these two rules to the two groups of Super Cache rules:</p>";
532
  echo "<blockquote><code>RewriteCond %{REQUEST_URI} !^.*[^/]$RewriteCond %{REQUEST_URI} !^.*//.*$</code></blockquote>";
533
- echo "<p>You can see where the rules go and examine the complete rules by clicking the 'View mod_rewrite rules' link below.</p></div>";
534
  $dohtaccess = false;
535
  } elseif( strpos( $scrules, 'supercache' ) || strpos( $wprules, 'supercache' ) ) { // only write the rules once
536
  $dohtaccess = false;
@@ -538,27 +585,27 @@ function wsc_mod_rewrite() {
538
  // cache/.htaccess rules
539
  $gziprules = "<IfModule mod_mime.c>\n <FilesMatch \"\\.html\\.gz\$\">\n ForceType text/html\n FileETag None\n </FilesMatch>\n AddEncoding gzip .gz\n AddType text/html .gz\n</IfModule>\n";
540
  $gziprules .= "<IfModule mod_deflate.c>\n SetEnvIfNoCase Request_URI \.gz$ no-gzip\n</IfModule>\n";
541
- $gziprules .= "<IfModule mod_headers.c>\n Header set Cache-Control 'max-age=300, must-revalidate'\n</IfModule>\n";
542
  $gziprules .= "<IfModule mod_expires.c>\n ExpiresActive On\n ExpiresByType text/html A300\n</IfModule>\n";
543
  if( $dohtaccess && !$_POST[ 'updatehtaccess' ] ) {
544
  if( !is_writeable_ACLSafe( $home_path . ".htaccess" ) ) {
545
- echo "<div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><h4>Cannot update .htaccess</h4><p>The file <code>{$home_path}.htaccess</code> cannot be modified by the web server. Please correct this using the chmod command or your ftp client.</p><p>Refresh this page when the file permissions have been modified.</p><p>Alternatively, you can edit your <code>{$home_path}.htaccess</code> file manually and add the following code (before any WordPress rules):</p>";
546
  echo "<p><pre># BEGIN WPSuperCache\n" . wp_specialchars( $rules ) . "# END WPSuperCache</pre></p></div>";
547
  } else {
548
- echo "<div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><p>To serve static html files your server must have the correct mod_rewrite rules added to a file called <code>{$home_path}.htaccess</code> ";
549
  if( !function_exists( 'is_site_admin' ) ) {
550
- echo "You must edit the file yourself add the following rules.";
551
  } else {
552
- echo "You can edit the file yourself add the following rules.";
553
  }
554
- echo " Make sure they appear before any existing WordPress rules.</p>";
555
  echo "<pre># BEGIN WPSuperCache\n" . wp_specialchars( $rules ) . "# END WPSuperCache</pre></p>";
556
- echo "<p>Rules must be added to " . WP_CONTENT_DIR . "/cache/.htaccess too:</p>";
557
  echo "<pre># BEGIN supercache\n" . wp_specialchars( $gziprules ) . "# END supercache</pre></p>";
558
  if( !function_exists( 'is_site_admin' ) ) {
559
- echo '<form name="updatehtaccess" action="'. $_SERVER["REQUEST_URI"] . '#modrewrite" method="post">';
560
  echo '<input type="hidden" name="updatehtaccess" value="1" />';
561
- echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'id="updatehtaccess" value="Update Mod_Rewrite Rules &raquo;" /></div>';
562
  wp_nonce_field('wp-cache');
563
  echo "</form></div>\n";
564
  }
@@ -567,17 +614,17 @@ function wsc_mod_rewrite() {
567
  wpsc_remove_marker( $home_path.'.htaccess', 'WordPress' ); // remove original WP rules so SuperCache rules go on top
568
  echo "<div style='padding:0 8px;color:#4f8a10;background-color:#dff2bf;border:1px solid #4f8a10;'>";
569
  if( insert_with_markers( $home_path.'.htaccess', 'WPSuperCache', explode( "\n", $rules ) ) && insert_with_markers( $home_path.'.htaccess', 'WordPress', explode( "\n", $wprules ) ) ) {
570
- echo "<h4>Mod Rewrite rules updated!</h4>";
571
- 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";
572
  } else {
573
- echo "<h4>Mod Rewrite rules must be updated!</h4>";
574
- 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";
575
  }
576
  echo "<p><pre>" . wp_specialchars( $rules ) . "</pre></p>\n</div>";
577
  } else {
578
  ?>
579
- <p>WP Super Cache mod rewrite rules were detected in your <?php echo $home_path ?>.htaccess file.<br /> Click the following link to see the lines added to that file. If you have upgraded the plugin make sure these rules match.<br /><br />
580
- <a href="javascript:toggleLayer('rewriterules');" class="button">View Mod_Rewrite Rules</a>
581
  <div id='rewriterules' style='display: none;'>
582
  <?php echo "<p><pre># BEGIN WPSuperCache\n" . wp_specialchars( $rules ) . "# END WPSuperCache</pre></p>\n";
583
  echo "<p>Rules must be added to " . WP_CONTENT_DIR ."/cache/.htaccess too:</p>";
@@ -588,17 +635,17 @@ function wsc_mod_rewrite() {
588
  // http://allmybrain.com/2007/11/08/making-wp-super-cache-gzip-compression-work/
589
  if( !is_file( $cache_path . '.htaccess' ) ) {
590
  $gziprules = insert_with_markers( $cache_path . '.htaccess', 'supercache', explode( "\n", $gziprules ) );
591
- echo "<h4>Gzip encoding rules in {$cache_path}.htaccess created.</h4>";
592
  }
593
 
594
  ?></fieldset><?php
595
  }
596
 
597
  function wp_cache_restore() {
598
- echo '<fieldset class="options"><h3>Fix Configuration</h3>';
599
- echo '<form name="wp_restore" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
600
  echo '<input type="hidden" name="wp_restore_config" />';
601
- echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'id="deletepost" value="Restore Default Configuration &raquo;" /></div>';
602
  wp_nonce_field('wp-cache');
603
  echo "</form>\n";
604
  echo '</fieldset>';
@@ -606,7 +653,7 @@ function wp_cache_restore() {
606
  }
607
 
608
  function comment_form_lockdown_message() {
609
- ?><p><?php _e( "Comment moderation is enabled. Your comment may take some time to appear." ); ?></p><?php
610
  }
611
  if( defined( 'WPLOCKDOWN' ) && constant( 'WPLOCKDOWN' ) )
612
  add_action( 'comment_form', 'comment_form_lockdown_message' );
@@ -628,31 +675,33 @@ function wp_lock_down() {
628
  $wp_lock_down = '0';
629
  }
630
  }
631
- ?><fieldset class="options">
632
- <h3>Lock Down: <?php echo $wp_lock_down == '0' ? '<span style="color:red">Disabled</span>' : '<span style="color:green">Enabled</span>'; ?></h3>
633
- <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>
634
- <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.
 
635
  <blockquote><code>if( defined( 'WPLOCKDOWN' ) && constant( 'WPLOCKDOWN' ) ) {
636
- &nbsp;&nbsp;&nbsp;&nbsp;echo "Sorry. My blog is locked down. Updates will appear shortly";
637
  }</code></blockquote>
638
  <?php
639
  if( $wp_lock_down == '1' ) {
640
- ?><p>WordPress is locked down. Super Cache static files will not be deleted when new comments are made.</p><?php
641
  } else {
642
- ?><p>WordPress is not locked down. New comments will refresh Super Cache static files as normal.</p><?php
643
  }
644
  $new_lockdown = $wp_lock_down == '1' ? '0' : '1';
645
- $new_lockdown_desc = $wp_lock_down == '1' ? 'Disable' : 'Enable';
646
- echo '<form name="wp_lock_down" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
647
  echo "<input type='hidden' name='wp_lock_down' value='{$new_lockdown}' />";
648
- echo "<div class='submit'><input type='submit' " . SUBMITDISABLED . " value='{$new_lockdown_desc} Lock Down &raquo;' /></div>";
649
  wp_nonce_field('wp-cache');
650
  echo "</form>\n";
651
 
652
  ?></fieldset><?php
653
  if( $cache_enabled == true && $super_cache_enabled == true ) {
654
- ?><fieldset class="options">
655
- <h3>Directly Cached Files</h3><?php
 
656
 
657
  $out = '';
658
  if( $valid_nonce && is_array( $_POST[ 'direct_pages' ] ) && !empty( $_POST[ 'direct_pages' ] ) ) {
@@ -710,7 +759,7 @@ function wp_lock_down() {
710
  @unlink( $pagefile );
711
  @unlink( $pagefile . '.gz' );
712
  RecursiveFolderDelete( $firstfolder );
713
- echo "<strong>$pagefile removed!</strong>";
714
  prune_super_cache( $cache_path, true );
715
  }
716
  }
@@ -718,11 +767,11 @@ function wp_lock_down() {
718
  $readonly = '';
719
  if( !is_writeable_ACLSafe( ABSPATH ) ) {
720
  $readonly = 'READONLY';
721
- ?><p style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><strong>Warning!</strong> You must make <?php echo ABSPATH ?> writable to enable this feature. As this is a security risk please make it readonly after your page is generated.</p><?php
722
  } else {
723
- ?><p style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><strong>Warning!</strong> <?php echo ABSPATH ?> is writable. Please make it readonly after your page is generated as this is a security risk.</p><?php
724
  }
725
- echo '<form name="direct_page" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
726
  if( is_array( $cached_direct_pages ) ) {
727
  $out = '';
728
  foreach( $cached_direct_pages as $page ) {
@@ -734,22 +783,22 @@ function wp_lock_down() {
734
  $out .= "<tr><td><input type='text' $readonly name='direct_pages[]' size='30' value='$page' /></td><td>$generated</td></tr>";
735
  }
736
  if( $out != '' ) {
737
- ?><table><tr><th>Existing direct page</th><th>Delete cached file</th></tr><?php
738
  echo "$out</table>";
739
  }
740
  }
741
  if( $readonly != 'READONLY' )
742
- echo "Add direct page: <input type='text' $readonly name='new_direct_page' size='30' value='' />";
743
 
744
- echo "<p>Directly cached files are files created directly off " . ABSPATH . " where your blog lives. This feature is only useful if you are expecting a major Digg or Slashdot level of traffic to one post or page.</p>";
745
  if( $readonly != 'READONLY' ) {
746
- echo "<p>For example: to cache <em>'" . trailingslashit( get_option( 'siteurl' ) ) . "about/'</em>, you would enter '" . trailingslashit( get_option( 'siteurl' ) ) . "about/' or '/about/'. The cached file will be generated the next time an anonymous user visits that page.</p>";
747
- echo "<p>Make the textbox blank to remove it from the list of direct pages and delete the cached file.</p>";
748
  }
749
 
750
  wp_nonce_field('wp-cache');
751
  if( $readonly != 'READONLY' )
752
- echo "<div class='submit'><input type='submit' ' . SUBMITDISABLED . 'value='Update Direct Pages &raquo;' /></div>";
753
  echo "</form>\n";
754
  ?></fieldset><?php
755
  } // if $super_cache_enabled
@@ -788,13 +837,14 @@ function wp_cache_edit_max_time () {
788
  }
789
  }
790
  ?><fieldset class="options">
791
- <h3>Expiry Time &amp; Garbage Collection</h3><?php
792
- echo '<form name="wp_edit_max_time" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
793
- echo '<label for="wp_max_time">Expire time:</label> ';
794
- echo "<input type=\"text\" size=6 name=\"wp_max_time\" value=\"$cache_max_time\" /> seconds";
795
- echo "<h4>Garbage Collection</h4><p>If expiry time is more than 1800 seconds (half an hour), garbage collection will be done every 10 minutes, otherwise it will happen 10 seconds after the expiry time above.</p>";
796
- echo "<p>Checking for and deleting expired files is expensive, but it's expensive leaving them there too. On a very busy site you should set the expiry time to <em>300 seconds</em>. Experiment with different values and visit this page to see how many expired files remain at different times during the day. Aim to have less than 500 cached files if possible.</p>";
797
- echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="Change Expiration &raquo;" /></div>';
 
798
  wp_nonce_field('wp-cache');
799
  echo "</form>\n";
800
  ?></fieldset><?php
@@ -833,17 +883,15 @@ function wp_cache_edit_rejected_ua() {
833
  wp_cache_replace_line('^ *\$cache_rejected_user_agent', "\$cache_rejected_user_agent = $text;", $wp_cache_config_file);
834
  }
835
 
836
- echo '<a name="user-agents"></a><fieldset class="options"><h3>Rejected User Agents</h3>';
837
- echo "<p>Strings in the HTTP 'User Agent' header that prevent WP-Cache from
838
- caching bot, spiders, and crawlers' requests.
839
- Note that super cached files are still sent to these agents if they already exists.</p>\n";
840
- echo '<form name="wp_edit_rejected_user_agent" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
841
  echo '<textarea name="wp_rejected_user_agent" cols="40" rows="4" style="width: 50%; font-size: 12px;" class="code">';
842
  foreach ($cache_rejected_user_agent as $ua) {
843
  echo wp_specialchars($ua) . "\n";
844
  }
845
  echo '</textarea> ';
846
- echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="Save UA Strings &raquo;" /></div>';
847
  wp_nonce_field('wp-cache');
848
  echo '</form>';
849
  echo "</fieldset>\n";
@@ -853,7 +901,7 @@ function wp_cache_edit_rejected_pages() {
853
  global $wp_cache_config_file, $valid_nonce, $wp_cache_pages;
854
 
855
  if ( isset( $_POST[ 'wp_edit_rejected_pages' ] ) && $valid_nonce ) {
856
- $pages = array( 'single', 'pages', 'archives', 'tag', 'frontpage', 'home', 'category' );
857
  foreach( $pages as $page ) {
858
  if ( isset( $_POST[ 'wp_cache_pages' ][ $page ] ) ) {
859
  $value = 1;
@@ -865,18 +913,21 @@ function wp_cache_edit_rejected_pages() {
865
  }
866
  }
867
 
868
- echo '<p>Do not cache the following page types. See the <a href="http://codex.wordpress.org/Conditional_Tags">Conditional Tags</a> documentation for a complete discussion on each type.</p>';
869
- echo '<form name="wp_edit_rejected_pages" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
 
870
  echo '<input type="hidden" name="wp_edit_rejected_pages" value="1" />';
871
- echo '<label><input type="checkbox" value="1" name="wp_cache_pages[single]" ' . checked( 1, $wp_cache_pages[ 'single' ], false ) . ' /> Single Posts (is_single)</label><br />';
872
- echo '<label><input type="checkbox" value="1" name="wp_cache_pages[pages]" ' . checked( 1, $wp_cache_pages[ 'pages' ], false ) . ' /> Pages (is_page)</label><br />';
873
- echo '<label><input type="checkbox" value="1" name="wp_cache_pages[frontpage]" ' . checked( 1, $wp_cache_pages[ 'frontpage' ], false ) . ' /> Front Page (is_front_page)</label><br />';
874
- echo '&nbsp;&nbsp;<label><input type="checkbox" value="1" name="wp_cache_pages[home]" ' . checked( 1, $wp_cache_pages[ 'home' ], false ) . ' /> Home (is_home)</label><br />';
875
- echo '<label><input type="checkbox" value="1" name="wp_cache_pages[archives]" ' . checked( 1, $wp_cache_pages[ 'archives' ], false ) . ' /> Archives (is_archive)</label><br />';
876
- echo '&nbsp;&nbsp;<label><input type="checkbox" value="1" name="wp_cache_pages[tag]" ' . checked( 1, $wp_cache_pages[ 'tag' ], false ) . ' /> Tags (is_tag)</label><br />';
877
- echo '&nbsp;&nbsp;<label><input type="checkbox" value="1" name="wp_cache_pages[category]" ' . checked( 1, $wp_cache_pages[ 'category' ], false ) . ' /> Category (is_category)</label><br />';
878
-
879
- echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="Save &raquo;" /></div>';
 
 
880
  wp_nonce_field('wp-cache');
881
  echo "</form>\n";
882
 
@@ -891,14 +942,15 @@ function wp_cache_edit_rejected() {
891
  }
892
 
893
 
894
- echo '<form name="wp_edit_rejected" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
895
- 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";
 
896
  echo '<textarea name="wp_rejected_uri" cols="40" rows="4" style="width: 50%; font-size: 12px;" class="code">';
897
  foreach ($cache_rejected_uri as $file) {
898
  echo wp_specialchars( $file ) . "\n";
899
  }
900
  echo '</textarea> ';
901
- echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="Save Strings &raquo;" /></div>';
902
  wp_nonce_field('wp-cache');
903
  echo "</form>\n";
904
  }
@@ -912,23 +964,85 @@ function wp_cache_edit_accepted() {
912
  }
913
 
914
 
915
- echo '<div style="clear:both"></div><form name="wp_edit_accepted" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
916
- echo "<p>Add here those filenames that can be cached, even if they match one of the rejected substring specified above.</p>\n";
 
917
  echo '<textarea name="wp_accepted_files" cols="40" rows="8" style="width: 50%; font-size: 12px;" class="code">';
918
  foreach ($cache_acceptable_files as $file) {
919
  echo wp_specialchars($file) . "\n";
920
  }
921
  echo '</textarea> ';
922
- echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="Save Files &raquo;" /></di