Version Description
- Improved error messages with AWS S3 CDN
- Added SSL support for CDN
- Added control for CDN queue upload interval
- Added option for 404 file exceptions list in browser cache
- Added exception for NextGen Gallery flash image rotator to CDN settings
- Fixed bug with external file imports
- Fixed bug with document root detection for CDN
- Fixed bug with minify file search
- Fixed bugs with AWS CloudFront distribution creation and saving
- Fixed bug with Rackspace Cloud Files API
Download this release
Release Info
Developer | fredericktownes |
Plugin | W3 Total Cache |
Version | 0.9.1.3 |
Comparing to | |
See all releases |
Code changes from version 0.9.1.2 to 0.9.1.3
- inc/define.php +1 -1
- inc/options/browsercache.phtml +3 -3
- inc/options/cdn.phtml +8 -1
- inc/options/cdn/cf.phtml +11 -0
- inc/options/cdn/ftp.phtml +11 -0
- inc/options/cdn/mirror.phtml +11 -0
- inc/options/cdn/netdna.phtml +11 -0
- inc/options/cdn/rscf.phtml +11 -0
- inc/options/cdn/s3.phtml +11 -0
- inc/options/common/header.phtml +1 -1
- inc/options/faq.xml +1 -1
- inc/options/general.phtml +4 -4
- inc/options/mobile.phtml +1 -1
- inc/options/support_email.phtml +0 -22
- lib/CF/cloudfiles_http.php +4 -4
- lib/W3/Cdn/Base.php +105 -51
- lib/W3/Cdn/Cf.php +32 -8
- lib/W3/Cdn/S3.php +87 -6
- lib/W3/Config.php +18 -2
- lib/W3/Plugin/Cdn.php +234 -96
- lib/W3/Plugin/TotalCache.php +14 -6
- readme.txt +22 -7
- w3-total-cache.php +1 -1
inc/define.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
define('W3TC_VERSION', '0.9.1.
|
4 |
define('W3TC_POWERED_BY', 'W3 Total Cache/' . W3TC_VERSION);
|
5 |
define('W3TC_EMAIL', 'w3tc@w3-edge.com');
|
6 |
define('W3TC_PAYPAL_URL', 'https://www.paypal.com/cgi-bin/webscr');
|
1 |
<?php
|
2 |
|
3 |
+
define('W3TC_VERSION', '0.9.1.3');
|
4 |
define('W3TC_POWERED_BY', 'W3 Total Cache/' . W3TC_VERSION);
|
5 |
define('W3TC_EMAIL', 'w3tc@w3-edge.com');
|
6 |
define('W3TC_PAYPAL_URL', 'https://www.paypal.com/cgi-bin/webscr');
|
inc/options/browsercache.phtml
CHANGED
@@ -45,14 +45,14 @@
|
|
45 |
<th colspan="2">
|
46 |
<input type="hidden" name="browsercache.no404wp" value="0" />
|
47 |
<label><input type="checkbox" name="browsercache.no404wp" value="1"<?php checked($this->_config->get_boolean('browsercache.no404wp'), true); ?> /> Do not process 404 errors for static objects with WordPress</label>
|
48 |
-
<br /><span class="description">Reduce server load by allowing the web server to handle 404 errors for static files
|
49 |
</th>
|
50 |
</tr>
|
51 |
<tr>
|
52 |
-
<th valign="top"><label for="browsercache_no404wp_exceptions">404
|
53 |
<td>
|
54 |
<textarea id="browsercache_no404wp_exceptions" name="browsercache.no404wp.exceptions" cols="40" rows="5"><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('browsercache.no404wp.exceptions'))); ?></textarea><br />
|
55 |
-
<span class="description">
|
56 |
</td>
|
57 |
</tr>
|
58 |
</table>
|
45 |
<th colspan="2">
|
46 |
<input type="hidden" name="browsercache.no404wp" value="0" />
|
47 |
<label><input type="checkbox" name="browsercache.no404wp" value="1"<?php checked($this->_config->get_boolean('browsercache.no404wp'), true); ?> /> Do not process 404 errors for static objects with WordPress</label>
|
48 |
+
<br /><span class="description">Reduce server load by allowing the web server to handle 404 (not found) errors for static files (images etc).</span>
|
49 |
</th>
|
50 |
</tr>
|
51 |
<tr>
|
52 |
+
<th valign="top"><label for="browsercache_no404wp_exceptions">404 error exception list:</label></th>
|
53 |
<td>
|
54 |
<textarea id="browsercache_no404wp_exceptions" name="browsercache.no404wp.exceptions" cols="40" rows="5"><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('browsercache.no404wp.exceptions'))); ?></textarea><br />
|
55 |
+
<span class="description">Never process 404 (not found) events for the specified files.</span>
|
56 |
</td>
|
57 |
</tr>
|
58 |
</table>
|
inc/options/cdn.phtml
CHANGED
@@ -82,6 +82,7 @@
|
|
82 |
<span class="description">If modified files are not always detected and replaced, use this option to over-write them.</span>
|
83 |
</th>
|
84 |
</tr>
|
|
|
85 |
<tr>
|
86 |
<th colspan="2">
|
87 |
<input type="hidden" name="cdn.import.external" value="0" />
|
@@ -89,7 +90,6 @@
|
|
89 |
<span class="description">Download attachments hosted elsewhere into your media library and deliver them via <acronym title="Content Delivery Network">CDN</acronym>.</span>
|
90 |
</th>
|
91 |
</tr>
|
92 |
-
<?php endif; ?>
|
93 |
</table>
|
94 |
|
95 |
<p class="submit">
|
@@ -138,6 +138,13 @@
|
|
138 |
<span class="description">Automatically attempt to find and upload changed files.</span>
|
139 |
</td>
|
140 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
<tr>
|
142 |
<th><label for="cdn_limit_queue">Re-transfer cycle limit:</label></th>
|
143 |
<td>
|
82 |
<span class="description">If modified files are not always detected and replaced, use this option to over-write them.</span>
|
83 |
</th>
|
84 |
</tr>
|
85 |
+
<?php endif; ?>
|
86 |
<tr>
|
87 |
<th colspan="2">
|
88 |
<input type="hidden" name="cdn.import.external" value="0" />
|
90 |
<span class="description">Download attachments hosted elsewhere into your media library and deliver them via <acronym title="Content Delivery Network">CDN</acronym>.</span>
|
91 |
</th>
|
92 |
</tr>
|
|
|
93 |
</table>
|
94 |
|
95 |
<p class="submit">
|
138 |
<span class="description">Automatically attempt to find and upload changed files.</span>
|
139 |
</td>
|
140 |
</tr>
|
141 |
+
<tr>
|
142 |
+
<th><label for="cdn_limit_interval">Re-transfer cycle interval:</label></th>
|
143 |
+
<td>
|
144 |
+
<input id="cdn_limit_interval" type="text" name="cdn.queue.interval" value="<?php echo htmlspecialchars($this->_config->get_integer('cdn.queue.interval')); ?>" size="10" /> seconds<br />
|
145 |
+
<span class="description">The number of seconds to wait before upload attempt.</span>
|
146 |
+
</td>
|
147 |
+
</tr>
|
148 |
<tr>
|
149 |
<th><label for="cdn_limit_queue">Re-transfer cycle limit:</label></th>
|
150 |
<td>
|
inc/options/cdn/cf.phtml
CHANGED
@@ -18,6 +18,17 @@
|
|
18 |
<span id="cdn_create_container_status" class="w3tc-status w3tc-process"></span>
|
19 |
</td>
|
20 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
<tr>
|
22 |
<th><label for="cdn_cf_id">Replace site's hostname with:</label></th>
|
23 |
<td>
|
18 |
<span id="cdn_create_container_status" class="w3tc-status w3tc-process"></span>
|
19 |
</td>
|
20 |
</tr>
|
21 |
+
<tr>
|
22 |
+
<th><label for="cdn_cf_ssl"><acronym title="Secure Sockets Layer">SSL</acronym> support:</label></th>
|
23 |
+
<td>
|
24 |
+
<select id="cdn_cf_ssl" name="cdn.cf.ssl">
|
25 |
+
<option value="auto"<?php selected($this->_config->get_string('cdn.cf.ssl'), 'auto'); ?>>Auto (determine connection type automatically)</option>
|
26 |
+
<option value="enabled"<?php selected($this->_config->get_string('cdn.cf.ssl'), 'enabled'); ?>>Enabled (always use SSL)</option>
|
27 |
+
<option value="disabled"<?php selected($this->_config->get_string('cdn.cf.ssl'), 'disabled'); ?>>Disabled (always use HTTP)</option>
|
28 |
+
</select>
|
29 |
+
<br /><span class="description">Some <acronym>CDN</acronym> providers may or may not support <acronym title="Secure Sockets Layer">SSL</acronym>, contact your vendor for more information.</span>
|
30 |
+
</td>
|
31 |
+
</tr>
|
32 |
<tr>
|
33 |
<th><label for="cdn_cf_id">Replace site's hostname with:</label></th>
|
34 |
<td>
|
inc/options/cdn/ftp.phtml
CHANGED
@@ -31,6 +31,17 @@
|
|
31 |
<span class="description">Specify the directory where files must be uploaded to be accessible in a web browser (the document root).</span>
|
32 |
</td>
|
33 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
<tr>
|
35 |
<th><label for="cdn_cnames">Replace site's hostname with:</label></th>
|
36 |
<td>
|
31 |
<span class="description">Specify the directory where files must be uploaded to be accessible in a web browser (the document root).</span>
|
32 |
</td>
|
33 |
</tr>
|
34 |
+
<tr>
|
35 |
+
<th><label for="cdn_ftp_ssl"><acronym title="Secure Sockets Layer">SSL</acronym> support:</label></th>
|
36 |
+
<td>
|
37 |
+
<select id="cdn_ftp_ssl" name="cdn.ftp.ssl">
|
38 |
+
<option value="auto"<?php selected($this->_config->get_string('cdn.ftp.ssl'), 'auto'); ?>>Auto (determine connection type automatically)</option>
|
39 |
+
<option value="enabled"<?php selected($this->_config->get_string('cdn.ftp.ssl'), 'enabled'); ?>>Enabled (always use SSL)</option>
|
40 |
+
<option value="disabled"<?php selected($this->_config->get_string('cdn.ftp.ssl'), 'disabled'); ?>>Disabled (always use HTTP)</option>
|
41 |
+
</select>
|
42 |
+
<br /><span class="description">Some <acronym>CDN</acronym> providers may or may not support <acronym title="Secure Sockets Layer">SSL</acronym>, contact your vendor for more information.</span>
|
43 |
+
</td>
|
44 |
+
</tr>
|
45 |
<tr>
|
46 |
<th><label for="cdn_cnames">Replace site's hostname with:</label></th>
|
47 |
<td>
|
inc/options/cdn/mirror.phtml
CHANGED
@@ -1,3 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<tr>
|
2 |
<th style="width:300px;"><label for="cdn_cnames">Replace site's hostname with:</label></th>
|
3 |
<td>
|
1 |
+
<tr>
|
2 |
+
<th><label for="cdn_mirror_ssl"><acronym title="Secure Sockets Layer">SSL</acronym> support:</label></th>
|
3 |
+
<td>
|
4 |
+
<select id="cdn_mirror_ssl" name="cdn.mirror.ssl">
|
5 |
+
<option value="auto"<?php selected($this->_config->get_string('cdn.mirror.ssl'), 'auto'); ?>>Auto (determine connection type automatically)</option>
|
6 |
+
<option value="enabled"<?php selected($this->_config->get_string('cdn.mirror.ssl'), 'enabled'); ?>>Enabled (always use SSL)</option>
|
7 |
+
<option value="disabled"<?php selected($this->_config->get_string('cdn.mirror.ssl'), 'disabled'); ?>>Disabled (always use HTTP)</option>
|
8 |
+
</select>
|
9 |
+
<br /><span class="description">Some <acronym>CDN</acronym> providers may or may not support <acronym title="Secure Sockets Layer">SSL</acronym>, contact your vendor for more information.</span>
|
10 |
+
</td>
|
11 |
+
</tr>
|
12 |
<tr>
|
13 |
<th style="width:300px;"><label for="cdn_cnames">Replace site's hostname with:</label></th>
|
14 |
<td>
|
inc/options/cdn/netdna.phtml
CHANGED
@@ -10,6 +10,17 @@
|
|
10 |
<input id="cdn_netdna_apikey" type="text" name="cdn.netdna.apikey" value="<?php echo htmlspecialchars($this->_config->get_string('cdn.netdna.apikey')); ?>" size="60" />
|
11 |
</td>
|
12 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
<tr>
|
14 |
<th><label for="cdn_cnames">Replace site's hostname with:</label></th>
|
15 |
<td>
|
10 |
<input id="cdn_netdna_apikey" type="text" name="cdn.netdna.apikey" value="<?php echo htmlspecialchars($this->_config->get_string('cdn.netdna.apikey')); ?>" size="60" />
|
11 |
</td>
|
12 |
</tr>
|
13 |
+
<tr>
|
14 |
+
<th><label for="cdn_netdna_ssl"><acronym title="Secure Sockets Layer">SSL</acronym> support:</label></th>
|
15 |
+
<td>
|
16 |
+
<select id="cdn_netdna_ssl" name="cdn.netdna.ssl">
|
17 |
+
<option value="auto"<?php selected($this->_config->get_string('cdn.netdna.ssl'), 'auto'); ?>>Auto (determine connection type automatically)</option>
|
18 |
+
<option value="enabled"<?php selected($this->_config->get_string('cdn.netdna.ssl'), 'enabled'); ?>>Enabled (always use SSL)</option>
|
19 |
+
<option value="disabled"<?php selected($this->_config->get_string('cdn.netdna.ssl'), 'disabled'); ?>>Disabled (always use HTTP)</option>
|
20 |
+
</select>
|
21 |
+
<br /><span class="description">Some <acronym>CDN</acronym> providers may or may not support <acronym title="Secure Sockets Layer">SSL</acronym>, contact your vendor for more information.</span>
|
22 |
+
</td>
|
23 |
+
</tr>
|
24 |
<tr>
|
25 |
<th><label for="cdn_cnames">Replace site's hostname with:</label></th>
|
26 |
<td>
|
inc/options/cdn/rscf.phtml
CHANGED
@@ -18,6 +18,17 @@
|
|
18 |
<span id="cdn_create_container_status" class="w3tc-status w3tc-process"></span>
|
19 |
</td>
|
20 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
<tr>
|
22 |
<th><label for="cdn_rscf_id">Replace site's hostname with:</label></th>
|
23 |
<td>
|
18 |
<span id="cdn_create_container_status" class="w3tc-status w3tc-process"></span>
|
19 |
</td>
|
20 |
</tr>
|
21 |
+
<tr>
|
22 |
+
<th><label for="cdn_rscf_ssl"><acronym title="Secure Sockets Layer">SSL</acronym> support:</label></th>
|
23 |
+
<td>
|
24 |
+
<select id="cdn_rscf_ssl" name="cdn.rscf.ssl">
|
25 |
+
<option value="auto"<?php selected($this->_config->get_string('cdn.rscf.ssl'), 'auto'); ?>>Auto (determine connection type automatically)</option>
|
26 |
+
<option value="enabled"<?php selected($this->_config->get_string('cdn.rscf.ssl'), 'enabled'); ?>>Enabled (always use SSL)</option>
|
27 |
+
<option value="disabled"<?php selected($this->_config->get_string('cdn.rscf.ssl'), 'disabled'); ?>>Disabled (always use HTTP)</option>
|
28 |
+
</select>
|
29 |
+
<br /><span class="description">Some <acronym>CDN</acronym> providers may or may not support <acronym title="Secure Sockets Layer">SSL</acronym>, contact your vendor for more information.</span>
|
30 |
+
</td>
|
31 |
+
</tr>
|
32 |
<tr>
|
33 |
<th><label for="cdn_rscf_id">Replace site's hostname with:</label></th>
|
34 |
<td>
|
inc/options/cdn/s3.phtml
CHANGED
@@ -18,6 +18,17 @@
|
|
18 |
<span id="cdn_create_container_status" class="w3tc-status w3tc-process"></span>
|
19 |
</td>
|
20 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
<tr>
|
22 |
<th><label for="cdn_cnames">Replace site's hostname with:</label></th>
|
23 |
<td>
|
18 |
<span id="cdn_create_container_status" class="w3tc-status w3tc-process"></span>
|
19 |
</td>
|
20 |
</tr>
|
21 |
+
<tr>
|
22 |
+
<th><label for="cdn_s3_ssl"><acronym title="Secure Sockets Layer">SSL</acronym> support:</label></th>
|
23 |
+
<td>
|
24 |
+
<select id="cdn_s3_ssl" name="cdn.s3.ssl">
|
25 |
+
<option value="auto"<?php selected($this->_config->get_string('cdn.s3.ssl'), 'auto'); ?>>Auto (determine connection type automatically)</option>
|
26 |
+
<option value="enabled"<?php selected($this->_config->get_string('cdn.s3.ssl'), 'enabled'); ?>>Enabled (always use SSL)</option>
|
27 |
+
<option value="disabled"<?php selected($this->_config->get_string('cdn.s3.ssl'), 'disabled'); ?>>Disabled (always use HTTP)</option>
|
28 |
+
</select>
|
29 |
+
<br /><span class="description">Some <acronym>CDN</acronym> providers may or may not support <acronym title="Secure Sockets Layer">SSL</acronym>, contact your vendor for more information.</span>
|
30 |
+
</td>
|
31 |
+
</tr>
|
32 |
<tr>
|
33 |
<th><label for="cdn_cnames">Replace site's hostname with:</label></th>
|
34 |
<td>
|
inc/options/common/header.phtml
CHANGED
@@ -37,7 +37,7 @@ jQuery(function($) {
|
|
37 |
<option value="w3tc_objectcache"<?php selected($this->_page, 'w3tc_objectcache'); ?>>Object Cache Settings</option>
|
38 |
<option value="w3tc_browsercache"<?php selected($this->_page, 'w3tc_browsercache'); ?>>Browser Cache Settings</option>
|
39 |
<option value="w3tc_mobile"<?php selected($this->_page, 'w3tc_mobile'); ?>>User Agent Groups Settings</option>
|
40 |
-
<option value="w3tc_cdn"<?php selected($this->_page, 'w3tc_cdn'); ?>>Content Delivery Network Settings </option>
|
41 |
</optgroup>
|
42 |
<optgroup label="Help:">
|
43 |
<option value="w3tc_faq"<?php selected($this->_page, 'w3tc_faq'); ?>>Frequently Asked Questions</option>
|
37 |
<option value="w3tc_objectcache"<?php selected($this->_page, 'w3tc_objectcache'); ?>>Object Cache Settings</option>
|
38 |
<option value="w3tc_browsercache"<?php selected($this->_page, 'w3tc_browsercache'); ?>>Browser Cache Settings</option>
|
39 |
<option value="w3tc_mobile"<?php selected($this->_page, 'w3tc_mobile'); ?>>User Agent Groups Settings</option>
|
40 |
+
<option value="w3tc_cdn"<?php selected($this->_page, 'w3tc_cdn'); ?>>Content Delivery Network (CDN) Settings </option>
|
41 |
</optgroup>
|
42 |
<optgroup label="Help:">
|
43 |
<option value="w3tc_faq"<?php selected($this->_page, 'w3tc_faq'); ?>>Frequently Asked Questions</option>
|
inc/options/faq.xml
CHANGED
@@ -105,7 +105,7 @@
|
|
105 |
</entry>
|
106 |
<entry>
|
107 |
<question><![CDATA[ Which WordPress versions are supported? ]]></question>
|
108 |
-
<answer><![CDATA[ <p>To use all features in the suite, a minimum version of 2.
|
109 |
</entry>
|
110 |
<entry>
|
111 |
<question><![CDATA[ I understand the database caching and the page caching, but what's minify all about? ]]></question>
|
105 |
</entry>
|
106 |
<entry>
|
107 |
<question><![CDATA[ Which WordPress versions are supported? ]]></question>
|
108 |
+
<answer><![CDATA[ <p>To use all features in the suite, a minimum version of 2.8 is required. Earlier versions will benefit from our Media Library Importer to get them back on the upgrade path and into a <acronym title="Content Delivery Network">CDN</acronym> of their choosing.</p> ]]></answer>
|
109 |
</entry>
|
110 |
<entry>
|
111 |
<question><![CDATA[ I understand the database caching and the page caching, but what's minify all about? ]]></question>
|
inc/options/general.phtml
CHANGED
@@ -54,7 +54,7 @@
|
|
54 |
<fieldset>
|
55 |
<legend><a href="admin.php?page=w3tc_pgcache">Page Cache</a></legend>
|
56 |
|
57 |
-
<p>Enable page caching to decrease the response time of your
|
58 |
|
59 |
<table class="form-table">
|
60 |
<tr>
|
@@ -147,7 +147,7 @@
|
|
147 |
<td>
|
148 |
<input type="hidden" name="dbcache.enabled" value="0" />
|
149 |
<label><input class="enabled" type="checkbox" name="dbcache.enabled" value="1"<?php checked($dbcache_enabled, true); ?> /> <strong>Enable</strong></label>
|
150 |
-
<br /><span class="description">Caching database objects
|
151 |
</td>
|
152 |
</tr>
|
153 |
<tr>
|
@@ -187,7 +187,7 @@
|
|
187 |
<td>
|
188 |
<input type="hidden" name="objectcache.enabled" value="0" />
|
189 |
<label><input class="enabled" type="checkbox" name="objectcache.enabled" value="1"<?php checked($objectcache_enabled, true); ?> /> <strong>Enable</strong></label>
|
190 |
-
<br /><span class="description">Object caching greatly increases performance for highly dynamic sites (that use the Object Cache API).</span>
|
191 |
</td>
|
192 |
</tr>
|
193 |
<tr>
|
@@ -218,7 +218,7 @@
|
|
218 |
<fieldset>
|
219 |
<legend><a href="admin.php?page=w3tc_cdn">Content Delivery Network</a></legend>
|
220 |
|
221 |
-
<p>Host static files with your content delivery network provider to reduce load time.</p>
|
222 |
|
223 |
<table class="form-table">
|
224 |
<tr>
|
54 |
<fieldset>
|
55 |
<legend><a href="admin.php?page=w3tc_pgcache">Page Cache</a></legend>
|
56 |
|
57 |
+
<p>Enable page caching to decrease the response time of your site.</p>
|
58 |
|
59 |
<table class="form-table">
|
60 |
<tr>
|
147 |
<td>
|
148 |
<input type="hidden" name="dbcache.enabled" value="0" />
|
149 |
<label><input class="enabled" type="checkbox" name="dbcache.enabled" value="1"<?php checked($dbcache_enabled, true); ?> /> <strong>Enable</strong></label>
|
150 |
+
<br /><span class="description">Caching database objects decreases the response time of your site. Best used if object caching is not possible.</span>
|
151 |
</td>
|
152 |
</tr>
|
153 |
<tr>
|
187 |
<td>
|
188 |
<input type="hidden" name="objectcache.enabled" value="0" />
|
189 |
<label><input class="enabled" type="checkbox" name="objectcache.enabled" value="1"<?php checked($objectcache_enabled, true); ?> /> <strong>Enable</strong></label>
|
190 |
+
<br /><span class="description">Object caching greatly increases performance for highly dynamic sites (that use the Object Cache <acronym title="Application Programming Interface">API</acronym>).</span>
|
191 |
</td>
|
192 |
</tr>
|
193 |
<tr>
|
218 |
<fieldset>
|
219 |
<legend><a href="admin.php?page=w3tc_cdn">Content Delivery Network</a></legend>
|
220 |
|
221 |
+
<p>Host static files with your content delivery network provider to reduce page load time.</p>
|
222 |
|
223 |
<table class="form-table">
|
224 |
<tr>
|
inc/options/mobile.phtml
CHANGED
@@ -50,7 +50,7 @@ mobile_themes['<?php echo addslashes($theme_key); ?>'] = '<?php echo addslashes(
|
|
50 |
<option value="<?php echo htmlspecialchars($theme_key); ?>"<?php selected($theme_key, $group_config['theme']); ?>><?php echo htmlspecialchars($theme_name); ?></option>
|
51 |
<?php endforeach; ?>
|
52 |
</select>
|
53 |
-
<br /><span class="description">Assign this group of user agents to a specific
|
54 |
</td>
|
55 |
</tr>
|
56 |
<tr>
|
50 |
<option value="<?php echo htmlspecialchars($theme_key); ?>"<?php selected($theme_key, $group_config['theme']); ?>><?php echo htmlspecialchars($theme_name); ?></option>
|
51 |
<?php endforeach; ?>
|
52 |
</select>
|
53 |
+
<br /><span class="description">Assign this group of user agents to a specific theme. Selecting "Pass-through" allows any plugin(s) (e.g. mobile plugins) to properly handle requests for these user agents. If the "redirect users to" field is not empty, this setting is ignored.</span>
|
54 |
</td>
|
55 |
</tr>
|
56 |
<tr>
|
inc/options/support_email.phtml
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
<html>
|
2 |
-
<head></head>
|
3 |
-
<body>
|
4 |
-
<p>
|
5 |
-
Date: <?php echo date('m/d/Y H:i:s'); ?><br />
|
6 |
-
Request type: <?php echo htmlspecialchars($request_type); ?><br />
|
7 |
-
URL: <a href="<?php echo htmlspecialchars($url); ?>"><?php echo htmlspecialchars($url); ?></a><br />
|
8 |
-
Forum Topic URL: <a href="<?php echo htmlspecialchars($forum_url); ?>"><?php echo htmlspecialchars($forum_url); ?></a><br />
|
9 |
-
<?php if ($request_data_url): ?>
|
10 |
-
Request data: <a href="<?php echo htmlspecialchars($request_data_url); ?>"><?php echo htmlspecialchars($request_data_url); ?></a>
|
11 |
-
<?php endif; ?>
|
12 |
-
</p>
|
13 |
-
<p>
|
14 |
-
<?php echo nl2br(htmlspecialchars($description)); ?>
|
15 |
-
</p>
|
16 |
-
<hr />
|
17 |
-
<font size="-1" color="#ccc">
|
18 |
-
E-mail sent from IP: <?php echo htmlspecialchars($_SERVER['REMOTE_ADDR']); ?><br />
|
19 |
-
User Agent: <?php echo htmlspecialchars($_SERVER['HTTP_USER_AGENT']); ?>
|
20 |
-
</font>
|
21 |
-
</body>
|
22 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/CF/cloudfiles_http.php
CHANGED
@@ -29,7 +29,7 @@
|
|
29 |
*/
|
30 |
require_once("cloudfiles_exceptions.php");
|
31 |
|
32 |
-
define("PHP_CF_VERSION", "1.7.
|
33 |
define("USER_AGENT", sprintf("PHP-CloudFiles/%s", PHP_CF_VERSION));
|
34 |
define("ACCOUNT_CONTAINER_COUNT", "X-Account-Container-Count");
|
35 |
define("ACCOUNT_BYTES_USED", "X-Account-Bytes-Used");
|
@@ -156,7 +156,7 @@ class CF_Http
|
|
156 |
# connect to SSL Websites. It is the first 3 letters of the PHP_OS
|
157 |
# variable.
|
158 |
$OS_CAFILE_NONUPDATED=array(
|
159 |
-
"win",
|
160 |
);
|
161 |
|
162 |
if (in_array((strtolower (substr(PHP_OS, 0,3))), $OS_CAFILE_NONUPDATED))
|
@@ -1187,7 +1187,7 @@ class CF_Http
|
|
1187 |
if ($conn_type == "PUT_OBJ") {
|
1188 |
curl_setopt($ch, CURLOPT_PUT, 1);
|
1189 |
curl_setopt($ch, CURLOPT_READFUNCTION, array(&$this, '_read_cb'));
|
1190 |
-
|
1191 |
}
|
1192 |
if ($conn_type == "HEAD") {
|
1193 |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "HEAD");
|
@@ -1300,7 +1300,7 @@ class CF_Http
|
|
1300 |
curl_setopt($this->connections[$conn_type],
|
1301 |
CURLOPT_URL, $url_path);
|
1302 |
|
1303 |
-
if (!curl_exec($this->connections[$conn_type])) {
|
1304 |
$this->error_str = "(curl error: "
|
1305 |
. curl_errno($this->connections[$conn_type]) . ") ";
|
1306 |
$this->error_str .= curl_error($this->connections[$conn_type]);
|
29 |
*/
|
30 |
require_once("cloudfiles_exceptions.php");
|
31 |
|
32 |
+
define("PHP_CF_VERSION", "1.7.4");
|
33 |
define("USER_AGENT", sprintf("PHP-CloudFiles/%s", PHP_CF_VERSION));
|
34 |
define("ACCOUNT_CONTAINER_COUNT", "X-Account-Container-Count");
|
35 |
define("ACCOUNT_BYTES_USED", "X-Account-Bytes-Used");
|
156 |
# connect to SSL Websites. It is the first 3 letters of the PHP_OS
|
157 |
# variable.
|
158 |
$OS_CAFILE_NONUPDATED=array(
|
159 |
+
"win","dar"
|
160 |
);
|
161 |
|
162 |
if (in_array((strtolower (substr(PHP_OS, 0,3))), $OS_CAFILE_NONUPDATED))
|
1187 |
if ($conn_type == "PUT_OBJ") {
|
1188 |
curl_setopt($ch, CURLOPT_PUT, 1);
|
1189 |
curl_setopt($ch, CURLOPT_READFUNCTION, array(&$this, '_read_cb'));
|
1190 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
1191 |
}
|
1192 |
if ($conn_type == "HEAD") {
|
1193 |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "HEAD");
|
1300 |
curl_setopt($this->connections[$conn_type],
|
1301 |
CURLOPT_URL, $url_path);
|
1302 |
|
1303 |
+
if (!curl_exec($this->connections[$conn_type]) && curl_errno($this->connections[$conn_type]) !== 0) {
|
1304 |
$this->error_str = "(curl error: "
|
1305 |
. curl_errno($this->connections[$conn_type]) . ") ";
|
1306 |
$this->error_str .= curl_error($this->connections[$conn_type]);
|
lib/W3/Cdn/Base.php
CHANGED
@@ -127,14 +127,70 @@ class W3_Cdn_Base
|
|
127 |
/**
|
128 |
* Returns first domain
|
129 |
*
|
|
|
130 |
* @return string
|
131 |
*/
|
132 |
-
function get_domain()
|
133 |
{
|
134 |
$domains = $this->get_domains();
|
|
|
135 |
|
136 |
-
if (count
|
137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
}
|
139 |
|
140 |
return false;
|
@@ -174,48 +230,11 @@ class W3_Cdn_Base
|
|
174 |
*/
|
175 |
function format_url($path)
|
176 |
{
|
177 |
-
$
|
178 |
-
$count = count($domains);
|
179 |
|
180 |
-
if ($
|
181 |
-
|
182 |
-
|
183 |
-
* Reserved CSS
|
184 |
-
*/
|
185 |
-
case (isset($domains[0]) && $this->_is_css($path)):
|
186 |
-
$host = $domains[0];
|
187 |
-
break;
|
188 |
-
|
189 |
-
/**
|
190 |
-
* Reserved JS in head
|
191 |
-
*/
|
192 |
-
case (isset($domains[1]) && $this->_is_js($path)):
|
193 |
-
$host = $domains[1];
|
194 |
-
break;
|
195 |
-
|
196 |
-
/**
|
197 |
-
* Reserved JS after body
|
198 |
-
*/
|
199 |
-
case (isset($domains[2]) && $this->_is_js_body($path)):
|
200 |
-
$host = $domains[2];
|
201 |
-
break;
|
202 |
-
|
203 |
-
/**
|
204 |
-
* Reserved JS before /body
|
205 |
-
*/
|
206 |
-
case (isset($domains[3]) && $this->_is_js_footer($path)):
|
207 |
-
$host = $domains[3];
|
208 |
-
break;
|
209 |
-
|
210 |
-
default:
|
211 |
-
if ($count > 4) {
|
212 |
-
$host = $this->_get_host(array_slice($domains, 4), $path);
|
213 |
-
} else {
|
214 |
-
$host = $this->_get_host($domains, $path);
|
215 |
-
}
|
216 |
-
}
|
217 |
-
|
218 |
-
$url = sprintf('%s://%s/%s', (w3_is_https() ? 'https' : 'http'), $host, $path);
|
219 |
|
220 |
return $url;
|
221 |
}
|
@@ -372,10 +391,20 @@ class W3_Cdn_Base
|
|
372 |
}
|
373 |
|
374 |
foreach ($domains as $domain) {
|
375 |
-
|
376 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
377 |
|
378 |
-
|
|
|
|
|
|
|
|
|
379 |
}
|
380 |
}
|
381 |
|
@@ -427,13 +456,13 @@ class W3_Cdn_Base
|
|
427 |
}
|
428 |
|
429 |
/**
|
430 |
-
* Returns
|
431 |
*
|
432 |
* @param array $domains
|
433 |
* @param string $path
|
434 |
* @return string
|
435 |
*/
|
436 |
-
function
|
437 |
{
|
438 |
$count = count($domains);
|
439 |
|
@@ -442,9 +471,9 @@ class W3_Cdn_Base
|
|
442 |
* Use for equal URLs same host to allow caching by browser
|
443 |
*/
|
444 |
$hash = $this->_get_hash($path);
|
445 |
-
$
|
446 |
|
447 |
-
return $
|
448 |
}
|
449 |
|
450 |
return false;
|
@@ -462,4 +491,29 @@ class W3_Cdn_Base
|
|
462 |
|
463 |
return $hash;
|
464 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
465 |
}
|
127 |
/**
|
128 |
* Returns first domain
|
129 |
*
|
130 |
+
* @param string $path
|
131 |
* @return string
|
132 |
*/
|
133 |
+
function get_domain($path = '')
|
134 |
{
|
135 |
$domains = $this->get_domains();
|
136 |
+
$count = count($domains);
|
137 |
|
138 |
+
if ($count) {
|
139 |
+
switch (true) {
|
140 |
+
/**
|
141 |
+
* Reserved CSS
|
142 |
+
*/
|
143 |
+
case (isset($domains[0]) && $this->_is_css($path)):
|
144 |
+
$domain = $domains[0];
|
145 |
+
break;
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Reserved JS in head
|
149 |
+
*/
|
150 |
+
case (isset($domains[1]) && $this->_is_js($path)):
|
151 |
+
$domain = $domains[1];
|
152 |
+
break;
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Reserved JS after body
|
156 |
+
*/
|
157 |
+
case (isset($domains[2]) && $this->_is_js_body($path)):
|
158 |
+
$domain = $domains[2];
|
159 |
+
break;
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Reserved JS before /body
|
163 |
+
*/
|
164 |
+
case (isset($domains[3]) && $this->_is_js_footer($path)):
|
165 |
+
$domain = $domains[3];
|
166 |
+
break;
|
167 |
+
|
168 |
+
default:
|
169 |
+
if ($count > 4) {
|
170 |
+
$domain = $this->_get_domain(array_slice($domains, 4), $path);
|
171 |
+
} else {
|
172 |
+
$domain = $this->_get_domain($domains, $path);
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* Custom host for SSL
|
178 |
+
*/
|
179 |
+
list($domain_http, $domain_https) = array_map('trim', explode(',', $domain . ','));
|
180 |
+
|
181 |
+
$scheme = $this->_get_scheme();
|
182 |
+
|
183 |
+
switch ($scheme) {
|
184 |
+
case 'http':
|
185 |
+
$domain = $domain_http;
|
186 |
+
break;
|
187 |
+
|
188 |
+
case 'https':
|
189 |
+
$domain = ($domain_https ? $domain_https : $domain_http);
|
190 |
+
break;
|
191 |
+
}
|
192 |
+
|
193 |
+
return $domain;
|
194 |
}
|
195 |
|
196 |
return false;
|
230 |
*/
|
231 |
function format_url($path)
|
232 |
{
|
233 |
+
$domain = $this->get_domain($path);
|
|
|
234 |
|
235 |
+
if ($domain) {
|
236 |
+
$scheme = $this->_get_scheme();
|
237 |
+
$url = sprintf('%s://%s/%s', $scheme, $domain, $path);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
|
239 |
return $url;
|
240 |
}
|
391 |
}
|
392 |
|
393 |
foreach ($domains as $domain) {
|
394 |
+
$_domains = array_map('trim', explode(',', $domain));
|
395 |
+
|
396 |
+
foreach ($_domains as $_domain) {
|
397 |
+
if (!$_domain) {
|
398 |
+
$error = 'Empty domain';
|
399 |
+
|
400 |
+
return false;
|
401 |
+
}
|
402 |
|
403 |
+
if (gethostbyname($_domain) === $_domain) {
|
404 |
+
$error = sprintf('Unable to resolve domain: %s.', $_domain);
|
405 |
+
|
406 |
+
return false;
|
407 |
+
}
|
408 |
}
|
409 |
}
|
410 |
|
456 |
}
|
457 |
|
458 |
/**
|
459 |
+
* Returns domain for path
|
460 |
*
|
461 |
* @param array $domains
|
462 |
* @param string $path
|
463 |
* @return string
|
464 |
*/
|
465 |
+
function _get_domain($domains, $path)
|
466 |
{
|
467 |
$count = count($domains);
|
468 |
|
471 |
* Use for equal URLs same host to allow caching by browser
|
472 |
*/
|
473 |
$hash = $this->_get_hash($path);
|
474 |
+
$domain = $domains[$hash % $count];
|
475 |
|
476 |
+
return $domain;
|
477 |
}
|
478 |
|
479 |
return false;
|
491 |
|
492 |
return $hash;
|
493 |
}
|
494 |
+
|
495 |
+
/**
|
496 |
+
* Returns scheme
|
497 |
+
*
|
498 |
+
* @return string
|
499 |
+
*/
|
500 |
+
function _get_scheme()
|
501 |
+
{
|
502 |
+
switch ($this->_config['ssl']) {
|
503 |
+
default:
|
504 |
+
case 'auto':
|
505 |
+
$scheme = (w3_is_https() ? 'https' : 'http');
|
506 |
+
break;
|
507 |
+
|
508 |
+
case 'enabled':
|
509 |
+
$scheme = 'https';
|
510 |
+
break;
|
511 |
+
|
512 |
+
case 'disabled':
|
513 |
+
$scheme = 'http';
|
514 |
+
break;
|
515 |
+
}
|
516 |
+
|
517 |
+
return $scheme;
|
518 |
+
}
|
519 |
}
|
lib/W3/Cdn/Cf.php
CHANGED
@@ -41,10 +41,14 @@ class W3_Cdn_Cf extends W3_Cdn_S3
|
|
41 |
/**
|
42 |
* Search active CF distribution
|
43 |
*/
|
|
|
|
|
44 |
$dists = @$this->_s3->listDistributions();
|
45 |
|
|
|
|
|
46 |
if (!$dists) {
|
47 |
-
$error = 'Unable to list distributions.';
|
48 |
|
49 |
return false;
|
50 |
}
|
@@ -78,10 +82,14 @@ class W3_Cdn_Cf extends W3_Cdn_S3
|
|
78 |
$cnames = (isset($dist['cnames']) ? (array) $dist['cnames'] : array());
|
79 |
|
80 |
foreach ($domains as $domain) {
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
|
|
85 |
}
|
86 |
}
|
87 |
} elseif (!empty($this->_config['id'])) {
|
@@ -107,12 +115,28 @@ class W3_Cdn_Cf extends W3_Cdn_S3
|
|
107 |
function create_container(&$container_id, &$error)
|
108 |
{
|
109 |
if (parent::create_container($container_id, $error)) {
|
110 |
-
$cnames =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
|
112 |
-
$
|
113 |
|
114 |
if (!$dist) {
|
115 |
-
$error = sprintf('Unable to create distribution for bucket %s.', $this->_config['bucket']);
|
116 |
|
117 |
return false;
|
118 |
}
|
41 |
/**
|
42 |
* Search active CF distribution
|
43 |
*/
|
44 |
+
$this->set_error_handler();
|
45 |
+
|
46 |
$dists = @$this->_s3->listDistributions();
|
47 |
|
48 |
+
$this->restore_error_handler();
|
49 |
+
|
50 |
if (!$dists) {
|
51 |
+
$error = sprintf('Unable to list distributions (%s).', $this->get_last_error());
|
52 |
|
53 |
return false;
|
54 |
}
|
82 |
$cnames = (isset($dist['cnames']) ? (array) $dist['cnames'] : array());
|
83 |
|
84 |
foreach ($domains as $domain) {
|
85 |
+
$_domains = array_map('trim', explode(',', $domain));
|
86 |
+
|
87 |
+
foreach ($_domains as $_domain) {
|
88 |
+
if (!in_array($_domain, $cnames)) {
|
89 |
+
$error = sprintf('Domain name %s is not in distribution CNAME list.', $_domain);
|
90 |
+
|
91 |
+
return false;
|
92 |
+
}
|
93 |
}
|
94 |
}
|
95 |
} elseif (!empty($this->_config['id'])) {
|
115 |
function create_container(&$container_id, &$error)
|
116 |
{
|
117 |
if (parent::create_container($container_id, $error)) {
|
118 |
+
$cnames = array();
|
119 |
+
|
120 |
+
if (!empty($this->_config['cname'])) {
|
121 |
+
$domains = (array) $this->_config['cname'];
|
122 |
+
|
123 |
+
foreach ($domains as $domain) {
|
124 |
+
$_domains = array_map('trim', explode(',', $domain));
|
125 |
+
|
126 |
+
foreach ($_domains as $_domain) {
|
127 |
+
$cnames[] = $_domain;
|
128 |
+
}
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
132 |
+
$this->set_error_handler();
|
133 |
+
|
134 |
+
$dist = @$this->_s3->createDistribution($this->_config['bucket'], true, $cnames);
|
135 |
|
136 |
+
$this->restore_error_handler();
|
137 |
|
138 |
if (!$dist) {
|
139 |
+
$error = sprintf('Unable to create distribution for bucket %s (%s).', $this->_config['bucket'], $this->get_last_error());
|
140 |
|
141 |
return false;
|
142 |
}
|
lib/W3/Cdn/S3.php
CHANGED
@@ -28,6 +28,13 @@ class W3_Cdn_S3 extends W3_Cdn_Base
|
|
28 |
*/
|
29 |
var $_gzip_extension = '.gzip';
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
/**
|
32 |
* Inits S3 object
|
33 |
*
|
@@ -239,10 +246,14 @@ class W3_Cdn_S3 extends W3_Cdn_Base
|
|
239 |
return false;
|
240 |
}
|
241 |
|
|
|
|
|
242 |
$buckets = @$this->_s3->listBuckets();
|
243 |
|
244 |
if (!$buckets) {
|
245 |
-
$error = 'Unable to list buckets (
|
|
|
|
|
246 |
|
247 |
return false;
|
248 |
}
|
@@ -250,34 +261,47 @@ class W3_Cdn_S3 extends W3_Cdn_Base
|
|
250 |
if (!in_array($this->_config['bucket'], (array) $buckets)) {
|
251 |
$error = sprintf('Bucket doesn\'t exist: %s', $this->_config['bucket']);
|
252 |
|
|
|
|
|
253 |
return false;
|
254 |
}
|
255 |
|
256 |
if (!@$this->_s3->putObjectString($string, $this->_config['bucket'], $string, S3::ACL_PUBLIC_READ)) {
|
257 |
-
$error = 'Unable to put object.';
|
|
|
|
|
258 |
|
259 |
return false;
|
260 |
}
|
261 |
|
262 |
if (!($object = @$this->_s3->getObject($this->_config['bucket'], $string))) {
|
263 |
-
$error = 'Unable to get object.';
|
|
|
|
|
264 |
|
265 |
return false;
|
266 |
}
|
267 |
|
268 |
if ($object->body != $string) {
|
269 |
@$this->_s3->deleteObject($this->_config['bucket'], $string);
|
|
|
270 |
$error = 'Objects are not equal.';
|
271 |
|
|
|
|
|
272 |
return false;
|
273 |
}
|
274 |
|
275 |
if (!@$this->_s3->deleteObject($this->_config['bucket'], $string)) {
|
276 |
-
$error = 'Unable to delete object.';
|
|
|
|
|
277 |
|
278 |
return false;
|
279 |
}
|
280 |
|
|
|
|
|
281 |
return true;
|
282 |
}
|
283 |
|
@@ -324,10 +348,14 @@ class W3_Cdn_S3 extends W3_Cdn_Base
|
|
324 |
return false;
|
325 |
}
|
326 |
|
|
|
|
|
327 |
$buckets = @$this->_s3->listBuckets();
|
328 |
|
329 |
if (!$buckets) {
|
330 |
-
$error = 'Unable to list buckets (
|
|
|
|
|
331 |
|
332 |
return false;
|
333 |
}
|
@@ -335,15 +363,21 @@ class W3_Cdn_S3 extends W3_Cdn_Base
|
|
335 |
if (in_array($this->_config['bucket'], (array) $buckets)) {
|
336 |
$error = sprintf('Bucket already exists: %s.', $this->_config['bucket']);
|
337 |
|
|
|
|
|
338 |
return false;
|
339 |
}
|
340 |
|
341 |
if (!@$this->_s3->putBucket($this->_config['bucket'], S3::ACL_PUBLIC_READ)) {
|
342 |
-
$error = sprintf('Unable to create bucket: %s.', $this->_config['bucket']);
|
|
|
|
|
343 |
|
344 |
return false;
|
345 |
}
|
346 |
|
|
|
|
|
347 |
return true;
|
348 |
}
|
349 |
|
@@ -368,4 +402,51 @@ class W3_Cdn_S3 extends W3_Cdn_Base
|
|
368 |
|
369 |
return $url;
|
370 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
371 |
}
|
28 |
*/
|
29 |
var $_gzip_extension = '.gzip';
|
30 |
|
31 |
+
/**
|
32 |
+
* Last error
|
33 |
+
*
|
34 |
+
* @var string
|
35 |
+
*/
|
36 |
+
var $_last_error = '';
|
37 |
+
|
38 |
/**
|
39 |
* Inits S3 object
|
40 |
*
|
246 |
return false;
|
247 |
}
|
248 |
|
249 |
+
$this->set_error_handler();
|
250 |
+
|
251 |
$buckets = @$this->_s3->listBuckets();
|
252 |
|
253 |
if (!$buckets) {
|
254 |
+
$error = sprintf('Unable to list buckets (%s).', $this->get_last_error());
|
255 |
+
|
256 |
+
$this->restore_error_handler();
|
257 |
|
258 |
return false;
|
259 |
}
|
261 |
if (!in_array($this->_config['bucket'], (array) $buckets)) {
|
262 |
$error = sprintf('Bucket doesn\'t exist: %s', $this->_config['bucket']);
|
263 |
|
264 |
+
$this->restore_error_handler();
|
265 |
+
|
266 |
return false;
|
267 |
}
|
268 |
|
269 |
if (!@$this->_s3->putObjectString($string, $this->_config['bucket'], $string, S3::ACL_PUBLIC_READ)) {
|
270 |
+
$error = sprintf('Unable to put object (%s).', $this->get_last_error());
|
271 |
+
|
272 |
+
$this->restore_error_handler();
|
273 |
|
274 |
return false;
|
275 |
}
|
276 |
|
277 |
if (!($object = @$this->_s3->getObject($this->_config['bucket'], $string))) {
|
278 |
+
$error = sprintf('Unable to get object (%s).', $this->get_last_error());
|
279 |
+
|
280 |
+
$this->restore_error_handler();
|
281 |
|
282 |
return false;
|
283 |
}
|
284 |
|
285 |
if ($object->body != $string) {
|
286 |
@$this->_s3->deleteObject($this->_config['bucket'], $string);
|
287 |
+
|
288 |
$error = 'Objects are not equal.';
|
289 |
|
290 |
+
$this->restore_error_handler();
|
291 |
+
|
292 |
return false;
|
293 |
}
|
294 |
|
295 |
if (!@$this->_s3->deleteObject($this->_config['bucket'], $string)) {
|
296 |
+
$error = sprintf('Unable to delete object (%s).', $this->get_last_error());
|
297 |
+
|
298 |
+
$this->restore_error_handler();
|
299 |
|
300 |
return false;
|
301 |
}
|
302 |
|
303 |
+
$this->restore_error_handler();
|
304 |
+
|
305 |
return true;
|
306 |
}
|
307 |
|
348 |
return false;
|
349 |
}
|
350 |
|
351 |
+
$this->set_error_handler();
|
352 |
+
|
353 |
$buckets = @$this->_s3->listBuckets();
|
354 |
|
355 |
if (!$buckets) {
|
356 |
+
$error = sprintf('Unable to list buckets (%s).', $this->get_last_error());
|
357 |
+
|
358 |
+
$this->restore_error_handler();
|
359 |
|
360 |
return false;
|
361 |
}
|
363 |
if (in_array($this->_config['bucket'], (array) $buckets)) {
|
364 |
$error = sprintf('Bucket already exists: %s.', $this->_config['bucket']);
|
365 |
|
366 |
+
$this->restore_error_handler();
|
367 |
+
|
368 |
return false;
|
369 |
}
|
370 |
|
371 |
if (!@$this->_s3->putBucket($this->_config['bucket'], S3::ACL_PUBLIC_READ)) {
|
372 |
+
$error = sprintf('Unable to create bucket: %s (%s).', $this->_config['bucket'], $this->get_last_error());
|
373 |
+
|
374 |
+
$this->restore_error_handler();
|
375 |
|
376 |
return false;
|
377 |
}
|
378 |
|
379 |
+
$this->restore_error_handler();
|
380 |
+
|
381 |
return true;
|
382 |
}
|
383 |
|
402 |
|
403 |
return $url;
|
404 |
}
|
405 |
+
|
406 |
+
/**
|
407 |
+
* Our error handler
|
408 |
+
*
|
409 |
+
* @param integer $errno
|
410 |
+
* @param string $errstr
|
411 |
+
* @return boolean
|
412 |
+
*/
|
413 |
+
function error_handler($errno, $errstr)
|
414 |
+
{
|
415 |
+
$this->_last_error = $errstr;
|
416 |
+
|
417 |
+
return false;
|
418 |
+
}
|
419 |
+
|
420 |
+
/**
|
421 |
+
* Returns last error
|
422 |
+
*
|
423 |
+
* @return string
|
424 |
+
*/
|
425 |
+
function get_last_error()
|
426 |
+
{
|
427 |
+
return $this->_last_error;
|
428 |
+
}
|
429 |
+
|
430 |
+
/**
|
431 |
+
* Set our error handler
|
432 |
+
*
|
433 |
+
* @return void
|
434 |
+
*/
|
435 |
+
function set_error_handler()
|
436 |
+
{
|
437 |
+
set_error_handler(array(
|
438 |
+
&$this,
|
439 |
+
'error_handler'
|
440 |
+
));
|
441 |
+
}
|
442 |
+
|
443 |
+
/**
|
444 |
+
* Restore prev error handler
|
445 |
+
*
|
446 |
+
* @return void
|
447 |
+
*/
|
448 |
+
function restore_error_handler()
|
449 |
+
{
|
450 |
+
restore_error_handler();
|
451 |
+
}
|
452 |
}
|
lib/W3/Config.php
CHANGED
@@ -126,34 +126,41 @@ class W3_Config
|
|
126 |
'cdn.custom.files' => 'array',
|
127 |
'cdn.import.external' => 'boolean',
|
128 |
'cdn.import.files' => 'string',
|
|
|
129 |
'cdn.queue.limit' => 'integer',
|
130 |
'cdn.force.rewrite' => 'boolean',
|
131 |
'cdn.autoupload.enabled' => 'boolean',
|
132 |
'cdn.autoupload.interval' => 'integer',
|
133 |
'cdn.mirror.domain' => 'array',
|
|
|
134 |
'cdn.netdna.apiid' => 'string',
|
135 |
'cdn.netdna.apikey' => 'string',
|
136 |
'cdn.netdna.domain' => 'array',
|
|
|
137 |
'cdn.ftp.host' => 'string',
|
138 |
'cdn.ftp.user' => 'string',
|
139 |
'cdn.ftp.pass' => 'string',
|
140 |
'cdn.ftp.path' => 'string',
|
141 |
'cdn.ftp.pasv' => 'boolean',
|
142 |
'cdn.ftp.domain' => 'array',
|
|
|
143 |
'cdn.s3.key' => 'string',
|
144 |
'cdn.s3.secret' => 'string',
|
145 |
'cdn.s3.bucket' => 'string',
|
146 |
'cdn.s3.cname' => 'array',
|
|
|
147 |
'cdn.cf.key' => 'string',
|
148 |
'cdn.cf.secret' => 'string',
|
149 |
'cdn.cf.bucket' => 'string',
|
150 |
'cdn.cf.id' => 'string',
|
151 |
'cdn.cf.cname' => 'array',
|
|
|
152 |
'cdn.rscf.user' => 'string',
|
153 |
'cdn.rscf.key' => 'string',
|
154 |
'cdn.rscf.container' => 'string',
|
155 |
'cdn.rscf.id' => 'string',
|
156 |
'cdn.rscf.cname' => 'array',
|
|
|
157 |
'cdn.reject.ua' => 'array',
|
158 |
'cdn.reject.uri' => 'array',
|
159 |
'cdn.reject.files' => 'array',
|
@@ -361,44 +368,53 @@ class W3_Config
|
|
361 |
),
|
362 |
'cdn.import.external' => false,
|
363 |
'cdn.import.files' => '*.jpg;*.png;*.gif;*.avi;*.wmv;*.mpg;*.wav;*.mp3;*.txt;*.rtf;*.doc;*.xls;*.rar;*.zip;*.tar;*.gz;*.exe',
|
|
|
364 |
'cdn.queue.limit' => 25,
|
365 |
'cdn.force.rewrite' => false,
|
366 |
'cdn.autoupload.enabled' => false,
|
367 |
'cdn.autoupload.interval' => 3600,
|
368 |
'cdn.mirror.domain' => array(),
|
|
|
369 |
'cdn.netdna.apiid' => '',
|
370 |
'cdn.netdna.apikey' => '',
|
371 |
'cdn.netdna.domain' => array(),
|
|
|
372 |
'cdn.ftp.host' => '',
|
373 |
'cdn.ftp.user' => '',
|
374 |
'cdn.ftp.pass' => '',
|
375 |
'cdn.ftp.path' => '',
|
376 |
'cdn.ftp.pasv' => false,
|
377 |
'cdn.ftp.domain' => array(),
|
|
|
378 |
'cdn.s3.key' => '',
|
379 |
'cdn.s3.secret' => '',
|
380 |
'cdn.s3.bucket' => '',
|
381 |
'cdn.s3.cname' => array(),
|
|
|
382 |
'cdn.cf.key' => '',
|
383 |
'cdn.cf.secret' => '',
|
384 |
'cdn.cf.bucket' => '',
|
385 |
'cdn.cf.id' => '',
|
386 |
'cdn.cf.cname' => array(),
|
|
|
387 |
'cdn.rscf.user' => '',
|
388 |
'cdn.rscf.key' => '',
|
389 |
'cdn.rscf.container' => '',
|
390 |
'cdn.rscf.id' => '',
|
391 |
'cdn.rscf.cname' => array(),
|
|
|
392 |
'cdn.reject.ua' => array(),
|
393 |
'cdn.reject.uri' => array(),
|
394 |
'cdn.reject.files' => array(
|
395 |
-
'wp-content/uploads/wpcf7_captcha/*'
|
|
|
396 |
),
|
397 |
|
398 |
'browsercache.enabled' => true,
|
399 |
'browsercache.no404wp' => false,
|
400 |
'browsercache.no404wp.exceptions' => array(
|
401 |
-
'robots\.txt'
|
|
|
402 |
),
|
403 |
'browsercache.cssjs.compression' => true,
|
404 |
'browsercache.cssjs.expires' => false,
|
126 |
'cdn.custom.files' => 'array',
|
127 |
'cdn.import.external' => 'boolean',
|
128 |
'cdn.import.files' => 'string',
|
129 |
+
'cdn.queue.interval' => 'integer',
|
130 |
'cdn.queue.limit' => 'integer',
|
131 |
'cdn.force.rewrite' => 'boolean',
|
132 |
'cdn.autoupload.enabled' => 'boolean',
|
133 |
'cdn.autoupload.interval' => 'integer',
|
134 |
'cdn.mirror.domain' => 'array',
|
135 |
+
'cdn.mirror.ssl' => 'string',
|
136 |
'cdn.netdna.apiid' => 'string',
|
137 |
'cdn.netdna.apikey' => 'string',
|
138 |
'cdn.netdna.domain' => 'array',
|
139 |
+
'cdn.netdna.ssl' => 'string',
|
140 |
'cdn.ftp.host' => 'string',
|
141 |
'cdn.ftp.user' => 'string',
|
142 |
'cdn.ftp.pass' => 'string',
|
143 |
'cdn.ftp.path' => 'string',
|
144 |
'cdn.ftp.pasv' => 'boolean',
|
145 |
'cdn.ftp.domain' => 'array',
|
146 |
+
'cdn.ftp.ssl' => 'string',
|
147 |
'cdn.s3.key' => 'string',
|
148 |
'cdn.s3.secret' => 'string',
|
149 |
'cdn.s3.bucket' => 'string',
|
150 |
'cdn.s3.cname' => 'array',
|
151 |
+
'cdn.s3.ssl' => 'string',
|
152 |
'cdn.cf.key' => 'string',
|
153 |
'cdn.cf.secret' => 'string',
|
154 |
'cdn.cf.bucket' => 'string',
|
155 |
'cdn.cf.id' => 'string',
|
156 |
'cdn.cf.cname' => 'array',
|
157 |
+
'cdn.cf.ssl' => 'string',
|
158 |
'cdn.rscf.user' => 'string',
|
159 |
'cdn.rscf.key' => 'string',
|
160 |
'cdn.rscf.container' => 'string',
|
161 |
'cdn.rscf.id' => 'string',
|
162 |
'cdn.rscf.cname' => 'array',
|
163 |
+
'cdn.rscf.ssl' => 'string',
|
164 |
'cdn.reject.ua' => 'array',
|
165 |
'cdn.reject.uri' => 'array',
|
166 |
'cdn.reject.files' => 'array',
|
368 |
),
|
369 |
'cdn.import.external' => false,
|
370 |
'cdn.import.files' => '*.jpg;*.png;*.gif;*.avi;*.wmv;*.mpg;*.wav;*.mp3;*.txt;*.rtf;*.doc;*.xls;*.rar;*.zip;*.tar;*.gz;*.exe',
|
371 |
+
'cdn.queue.interval' => 900,
|
372 |
'cdn.queue.limit' => 25,
|
373 |
'cdn.force.rewrite' => false,
|
374 |
'cdn.autoupload.enabled' => false,
|
375 |
'cdn.autoupload.interval' => 3600,
|
376 |
'cdn.mirror.domain' => array(),
|
377 |
+
'cdn.mirror.ssl' => 'auto',
|
378 |
'cdn.netdna.apiid' => '',
|
379 |
'cdn.netdna.apikey' => '',
|
380 |
'cdn.netdna.domain' => array(),
|
381 |
+
'cdn.netdna.ssl' => 'auto',
|
382 |
'cdn.ftp.host' => '',
|
383 |
'cdn.ftp.user' => '',
|
384 |
'cdn.ftp.pass' => '',
|
385 |
'cdn.ftp.path' => '',
|
386 |
'cdn.ftp.pasv' => false,
|
387 |
'cdn.ftp.domain' => array(),
|
388 |
+
'cdn.ftp.ssl' => 'auto',
|
389 |
'cdn.s3.key' => '',
|
390 |
'cdn.s3.secret' => '',
|
391 |
'cdn.s3.bucket' => '',
|
392 |
'cdn.s3.cname' => array(),
|
393 |
+
'cdn.s3.ssl' => 'auto',
|
394 |
'cdn.cf.key' => '',
|
395 |
'cdn.cf.secret' => '',
|
396 |
'cdn.cf.bucket' => '',
|
397 |
'cdn.cf.id' => '',
|
398 |
'cdn.cf.cname' => array(),
|
399 |
+
'cdn.cf.ssl' => 'auto',
|
400 |
'cdn.rscf.user' => '',
|
401 |
'cdn.rscf.key' => '',
|
402 |
'cdn.rscf.container' => '',
|
403 |
'cdn.rscf.id' => '',
|
404 |
'cdn.rscf.cname' => array(),
|
405 |
+
'cdn.rscf.ssl' => 'auto',
|
406 |
'cdn.reject.ua' => array(),
|
407 |
'cdn.reject.uri' => array(),
|
408 |
'cdn.reject.files' => array(
|
409 |
+
'wp-content/uploads/wpcf7_captcha/*',
|
410 |
+
'wp-content/uploads/imagerotator.swf'
|
411 |
),
|
412 |
|
413 |
'browsercache.enabled' => true,
|
414 |
'browsercache.no404wp' => false,
|
415 |
'browsercache.no404wp.exceptions' => array(
|
416 |
+
'robots\.txt',
|
417 |
+
'sitemap\.xml(\.gz)?'
|
418 |
),
|
419 |
'browsercache.cssjs.compression' => true,
|
420 |
'browsercache.cssjs.expires' => false,
|
lib/W3/Plugin/Cdn.php
CHANGED
@@ -59,11 +59,21 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
59 |
'delete_attachment'
|
60 |
));
|
61 |
|
|
|
|
|
|
|
|
|
|
|
62 |
add_filter('wp_generate_attachment_metadata', array(
|
63 |
&$this,
|
64 |
'generate_attachment_metadata'
|
65 |
));
|
66 |
|
|
|
|
|
|
|
|
|
|
|
67 |
add_action('w3_cdn_cron_queue_process', array(
|
68 |
&$this,
|
69 |
'cron_queue_process'
|
@@ -229,13 +239,13 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
229 |
function cron_upload()
|
230 |
{
|
231 |
$files = $this->get_files();
|
232 |
-
$
|
233 |
|
234 |
$upload = array();
|
235 |
$results = array();
|
236 |
|
237 |
foreach ($files as $file) {
|
238 |
-
$upload[
|
239 |
}
|
240 |
|
241 |
$this->upload($upload, true, $results);
|
@@ -243,12 +253,17 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
243 |
|
244 |
/**
|
245 |
* On attachment add action
|
|
|
|
|
246 |
*
|
247 |
* @param integer $attachment_id
|
|
|
248 |
*/
|
249 |
function add_attachment($attachment_id)
|
250 |
{
|
251 |
-
$
|
|
|
|
|
252 |
$files = apply_filters('w3tc_cdn_add_attachment', $files);
|
253 |
|
254 |
$results = array();
|
@@ -256,8 +271,49 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
256 |
$this->upload($files, true, $results);
|
257 |
}
|
258 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
259 |
/**
|
260 |
* Generate attachment metadata filter
|
|
|
|
|
261 |
*
|
262 |
* @param array $metadata
|
263 |
* @return array
|
@@ -275,30 +331,36 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
275 |
}
|
276 |
|
277 |
/**
|
278 |
-
*
|
279 |
-
*
|
280 |
-
*
|
|
|
|
|
|
|
281 |
*/
|
282 |
-
function
|
283 |
{
|
284 |
-
$files = $this->
|
285 |
-
$files = apply_filters('
|
286 |
|
287 |
$results = array();
|
288 |
|
289 |
-
$this->
|
|
|
|
|
290 |
}
|
291 |
|
292 |
/**
|
293 |
* Purge attachment
|
294 |
*
|
|
|
|
|
295 |
* @param integer $attachment_id
|
296 |
* @return boolean
|
297 |
*/
|
298 |
function purge_attachment($attachment_id)
|
299 |
{
|
300 |
$files = $this->get_attachment_files($attachment_id);
|
301 |
-
$results = array();
|
302 |
|
303 |
if ($this->_config->get_string('cdn.engine') == 'netdna') {
|
304 |
$queue_failed = false;
|
@@ -306,6 +368,8 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
306 |
$queue_failed = true;
|
307 |
}
|
308 |
|
|
|
|
|
309 |
return $this->purge($files, $queue_failed, $results);
|
310 |
}
|
311 |
|
@@ -317,16 +381,17 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
317 |
*/
|
318 |
function cron_schedules($schedules)
|
319 |
{
|
320 |
-
$
|
|
|
321 |
|
322 |
return array_merge($schedules, array(
|
323 |
'w3_cdn_cron_queue_process' => array(
|
324 |
-
'interval' =>
|
325 |
-
'display' => '[W3TC] CDN queue process (every
|
326 |
),
|
327 |
'w3_cdn_cron_upload' => array(
|
328 |
-
'interval' => $
|
329 |
-
'display' => sprintf('[W3TC] CDN auto upload (every %d seconds)', $
|
330 |
)
|
331 |
));
|
332 |
}
|
@@ -354,33 +419,109 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
354 |
}
|
355 |
|
356 |
/**
|
357 |
-
* Returns
|
358 |
-
*
|
359 |
-
* @param
|
360 |
* @return array
|
361 |
*/
|
362 |
-
function
|
363 |
{
|
364 |
$files = array();
|
365 |
$upload_info = w3_upload_info();
|
366 |
|
367 |
if ($upload_info) {
|
368 |
-
$
|
369 |
-
$attachment_metadata = get_post_meta($attachment_id, '_wp_attachment_metadata', true);
|
370 |
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
376 |
|
377 |
-
$files
|
378 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
379 |
|
380 |
-
if ($
|
381 |
-
$files = array_merge($files, $this->
|
382 |
}
|
383 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
384 |
return $files;
|
385 |
}
|
386 |
|
@@ -461,44 +602,6 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
461 |
return $buffer;
|
462 |
}
|
463 |
|
464 |
-
/**
|
465 |
-
* Returns attachment files by metadata
|
466 |
-
*
|
467 |
-
* @param array $metadata
|
468 |
-
* @return array
|
469 |
-
*/
|
470 |
-
function get_metadata_files($metadata)
|
471 |
-
{
|
472 |
-
$files = array();
|
473 |
-
|
474 |
-
$upload_info = w3_upload_info();
|
475 |
-
|
476 |
-
if ($upload_info) {
|
477 |
-
if (isset($metadata['file'])) {
|
478 |
-
$file = $this->normalize_attachment_file($metadata['file']);
|
479 |
-
|
480 |
-
if (isset($metadata['sizes'])) {
|
481 |
-
$file_dir = w3_dirname($file);
|
482 |
-
|
483 |
-
if ($file_dir) {
|
484 |
-
$file_dir .= '/';
|
485 |
-
}
|
486 |
-
|
487 |
-
foreach ((array) $metadata['sizes'] as $size) {
|
488 |
-
if (isset($size['file'])) {
|
489 |
-
$local_file = $upload_info['basedir'] . '/' . $file_dir . $size['file'];
|
490 |
-
$remote_file = ltrim($upload_info['baseurlpath'] . $file_dir . $size['file'], '/');
|
491 |
-
|
492 |
-
$files[$local_file] = $remote_file;
|
493 |
-
}
|
494 |
-
}
|
495 |
-
}
|
496 |
-
}
|
497 |
-
}
|
498 |
-
|
499 |
-
return $files;
|
500 |
-
}
|
501 |
-
|
502 |
/**
|
503 |
* Adds file to queue
|
504 |
*
|
@@ -828,6 +931,8 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
828 |
$results = array();
|
829 |
|
830 |
$upload_info = w3_upload_info();
|
|
|
|
|
831 |
|
832 |
@set_time_limit(300);
|
833 |
|
@@ -887,7 +992,7 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
887 |
$error = '';
|
888 |
$result = false;
|
889 |
|
890 |
-
$src =
|
891 |
$dst = '';
|
892 |
|
893 |
/**
|
@@ -905,9 +1010,15 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
905 |
list($dst, $dst_url) = $attachments[$src];
|
906 |
$result = true;
|
907 |
} else {
|
908 |
-
|
909 |
-
|
910 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
911 |
|
912 |
$src_filename = pathinfo($src, PATHINFO_FILENAME);
|
913 |
$src_extension = pathinfo($src, PATHINFO_EXTENSION);
|
@@ -924,10 +1035,12 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
924 |
}
|
925 |
|
926 |
$dst_basename = basename($dst);
|
927 |
-
$dst_dirname = str_replace($upload_dir, '', $upload_info['basedir']);
|
928 |
$dst_url = sprintf('%s/%s', $upload_url, $dst_basename);
|
|
|
929 |
|
930 |
-
|
|
|
|
|
931 |
|
932 |
$download_result = false;
|
933 |
|
@@ -951,7 +1064,7 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
951 |
/**
|
952 |
* Otherwise copy file from local path
|
953 |
*/
|
954 |
-
$src_path =
|
955 |
|
956 |
if (file_exists($src_path)) {
|
957 |
$download_result = @copy($src_path, $dst);
|
@@ -970,7 +1083,7 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
970 |
if ($download_result) {
|
971 |
$title = $dst_basename;
|
972 |
$guid = ltrim($upload_info['baseurlpath'] . $title, ',');
|
973 |
-
$mime_type = w3_get_mime_type($
|
974 |
|
975 |
$GLOBALS['wp_rewrite'] = & new WP_Rewrite();
|
976 |
|
@@ -1018,16 +1131,19 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
1018 |
} else {
|
1019 |
$error = 'File type rejected';
|
1020 |
}
|
1021 |
-
} else
|
|
|
|
|
1022 |
$error = 'File already exists in the media library';
|
1023 |
}
|
1024 |
|
1025 |
/**
|
1026 |
* Add new entry to the log file
|
1027 |
*/
|
|
|
1028 |
$results[] = array(
|
1029 |
'src' => $src,
|
1030 |
-
'dst' => $
|
1031 |
'result' => $result,
|
1032 |
'error' => $error
|
1033 |
);
|
@@ -1222,7 +1338,11 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
1222 |
*/
|
1223 |
function get_files_includes()
|
1224 |
{
|
1225 |
-
$
|
|
|
|
|
|
|
|
|
1226 |
|
1227 |
return $files;
|
1228 |
}
|
@@ -1237,13 +1357,16 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
1237 |
* we should upload whole themes directory
|
1238 |
*/
|
1239 |
if ($this->_config->get_boolean('mobile.enabled')) {
|
1240 |
-
$
|
1241 |
} else {
|
1242 |
-
$
|
1243 |
}
|
1244 |
|
1245 |
-
$
|
1246 |
-
$
|
|
|
|
|
|
|
1247 |
|
1248 |
return $files;
|
1249 |
}
|
@@ -1258,6 +1381,11 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
1258 |
if (W3TC_PHP5 && $this->_config->get_boolean('minify.rewrite')) {
|
1259 |
require_once W3TC_LIB_W3_DIR . '/Plugin/Minify.php';
|
1260 |
$minify = & W3_Plugin_Minify::instance();
|
|
|
|
|
|
|
|
|
|
|
1261 |
$urls = $minify->get_urls();
|
1262 |
|
1263 |
if ($this->_config->get_string('minify.engine') == 'file') {
|
@@ -1265,23 +1393,26 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
1265 |
w3_http_get($url);
|
1266 |
}
|
1267 |
|
1268 |
-
$files = $this->search_files(
|
1269 |
} else {
|
|
|
|
|
1270 |
foreach ($urls as $url) {
|
1271 |
-
$file =
|
1272 |
$file = w3_translate_file($file);
|
1273 |
|
1274 |
if (!w3_is_url($file)) {
|
1275 |
-
$file =
|
|
|
1276 |
|
1277 |
$dir = dirname($file);
|
1278 |
|
1279 |
if ($dir) {
|
1280 |
-
w3_mkdir($dir, 0755,
|
1281 |
}
|
1282 |
|
1283 |
-
if (w3_download($url,
|
1284 |
-
$files[] =
|
1285 |
}
|
1286 |
}
|
1287 |
}
|
@@ -1297,6 +1428,7 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
1297 |
function get_files_custom()
|
1298 |
{
|
1299 |
$files = array();
|
|
|
1300 |
$custom_files = $this->_config->get_array('cdn.custom.files');
|
1301 |
|
1302 |
foreach ($custom_files as $custom_file) {
|
@@ -1309,7 +1441,7 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
1309 |
}
|
1310 |
|
1311 |
$mask = basename($custom_file);
|
1312 |
-
$files = array_merge($files, $this->search_files(
|
1313 |
}
|
1314 |
}
|
1315 |
|
@@ -1501,7 +1633,8 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
1501 |
switch ($engine) {
|
1502 |
case 'mirror':
|
1503 |
$engine_config = array(
|
1504 |
-
'domain' => $this->_config->get_array('cdn.mirror.domain')
|
|
|
1505 |
);
|
1506 |
break;
|
1507 |
|
@@ -1509,7 +1642,8 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
1509 |
$engine_config = array(
|
1510 |
'apiid' => $this->_config->get_string('cdn.netdna.apiid'),
|
1511 |
'apikey' => $this->_config->get_string('cdn.netdna.apikey'),
|
1512 |
-
'domain' => $this->_config->get_array('cdn.netdna.domain')
|
|
|
1513 |
);
|
1514 |
break;
|
1515 |
|
@@ -1520,7 +1654,8 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
1520 |
'pass' => $this->_config->get_string('cdn.ftp.pass'),
|
1521 |
'path' => $this->_config->get_string('cdn.ftp.path'),
|
1522 |
'pasv' => $this->_config->get_boolean('cdn.ftp.pasv'),
|
1523 |
-
'domain' => $this->_config->get_array('cdn.ftp.domain')
|
|
|
1524 |
);
|
1525 |
break;
|
1526 |
|
@@ -1530,7 +1665,8 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
1530 |
'secret' => $this->_config->get_string('cdn.s3.secret'),
|
1531 |
'bucket' => $this->_config->get_string('cdn.s3.bucket'),
|
1532 |
'cname' => $this->_config->get_array('cdn.s3.cname'),
|
1533 |
-
'compression' => ($this->_config->get_boolean('browsercache.enabled') && $this->_config->get_boolean('browsercache.html.compression'))
|
|
|
1534 |
);
|
1535 |
break;
|
1536 |
|
@@ -1541,7 +1677,8 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
1541 |
'bucket' => $this->_config->get_string('cdn.cf.bucket'),
|
1542 |
'id' => $this->_config->get_string('cdn.cf.id'),
|
1543 |
'cname' => $this->_config->get_array('cdn.cf.cname'),
|
1544 |
-
'compression' => ($this->_config->get_boolean('browsercache.enabled') && $this->_config->get_boolean('browsercache.html.compression'))
|
|
|
1545 |
);
|
1546 |
break;
|
1547 |
|
@@ -1551,7 +1688,8 @@ class W3_Plugin_Cdn extends W3_Plugin
|
|
1551 |
'key' => $this->_config->get_string('cdn.rscf.key'),
|
1552 |
'container' => $this->_config->get_string('cdn.rscf.container'),
|
1553 |
'id' => $this->_config->get_string('cdn.rscf.id'),
|
1554 |
-
'cname' => $this->_config->get_array('cdn.rscf.cname')
|
|
|
1555 |
);
|
1556 |
break;
|
1557 |
}
|
59 |
'delete_attachment'
|
60 |
));
|
61 |
|
62 |
+
add_filter('update_attached_file', array(
|
63 |
+
&$this,
|
64 |
+
'update_attached_file'
|
65 |
+
));
|
66 |
+
|
67 |
add_filter('wp_generate_attachment_metadata', array(
|
68 |
&$this,
|
69 |
'generate_attachment_metadata'
|
70 |
));
|
71 |
|
72 |
+
add_filter('wp_update_attachment_metadata', array(
|
73 |
+
&$this,
|
74 |
+
'update_attachment_metadata'
|
75 |
+
));
|
76 |
+
|
77 |
add_action('w3_cdn_cron_queue_process', array(
|
78 |
&$this,
|
79 |
'cron_queue_process'
|
239 |
function cron_upload()
|
240 |
{
|
241 |
$files = $this->get_files();
|
242 |
+
$document_root = w3_get_document_root();
|
243 |
|
244 |
$upload = array();
|
245 |
$results = array();
|
246 |
|
247 |
foreach ($files as $file) {
|
248 |
+
$upload[$document_root . '/' . $file] = $file;
|
249 |
}
|
250 |
|
251 |
$this->upload($upload, true, $results);
|
253 |
|
254 |
/**
|
255 |
* On attachment add action
|
256 |
+
*
|
257 |
+
* Upload _wp_attached_file
|
258 |
*
|
259 |
* @param integer $attachment_id
|
260 |
+
* @return void
|
261 |
*/
|
262 |
function add_attachment($attachment_id)
|
263 |
{
|
264 |
+
$attached_file = get_post_meta($attachment_id, '_wp_attached_file', true);
|
265 |
+
|
266 |
+
$files = $this->get_files_for_upload($attached_file);
|
267 |
$files = apply_filters('w3tc_cdn_add_attachment', $files);
|
268 |
|
269 |
$results = array();
|
271 |
$this->upload($files, true, $results);
|
272 |
}
|
273 |
|
274 |
+
/**
|
275 |
+
* Update attachment file
|
276 |
+
*
|
277 |
+
* Upload _wp_attached_file
|
278 |
+
*
|
279 |
+
* @param string $attached_file
|
280 |
+
* @return string
|
281 |
+
*/
|
282 |
+
function update_attached_file($attached_file)
|
283 |
+
{
|
284 |
+
$files = $this->get_files_for_upload($attached_file);
|
285 |
+
$files = apply_filters('w3tc_cdn_update_attachment', $files);
|
286 |
+
|
287 |
+
$results = array();
|
288 |
+
|
289 |
+
$this->upload($files, true, $results);
|
290 |
+
|
291 |
+
return $attached_file;
|
292 |
+
}
|
293 |
+
|
294 |
+
/**
|
295 |
+
* On attachment delete action
|
296 |
+
*
|
297 |
+
* Delete _wp_attached_file, _wp_attachment_metadata, _wp_attachment_backup_sizes
|
298 |
+
*
|
299 |
+
* @param integer $attachment_id
|
300 |
+
*/
|
301 |
+
function delete_attachment($attachment_id)
|
302 |
+
{
|
303 |
+
$files = array();
|
304 |
+
|
305 |
+
$files = $this->get_attachment_files($attachment_id);
|
306 |
+
$files = apply_filters('w3tc_cdn_delete_attachment', $files);
|
307 |
+
|
308 |
+
$results = array();
|
309 |
+
|
310 |
+
$this->delete($files, true, $results);
|
311 |
+
}
|
312 |
+
|
313 |
/**
|
314 |
* Generate attachment metadata filter
|
315 |
+
*
|
316 |
+
* Upload _wp_attachment_metadata
|
317 |
*
|
318 |
* @param array $metadata
|
319 |
* @return array
|
331 |
}
|
332 |
|
333 |
/**
|
334 |
+
* Update attachment metadata filter
|
335 |
+
*
|
336 |
+
* Upload _wp_attachment_metadata
|
337 |
+
*
|
338 |
+
* @param array $metadata
|
339 |
+
* @return array
|
340 |
*/
|
341 |
+
function update_attachment_metadata($metadata)
|
342 |
{
|
343 |
+
$files = $this->get_metadata_files($metadata);
|
344 |
+
$files = apply_filters('w3tc_cdn_update_attachment_metadata', $files);
|
345 |
|
346 |
$results = array();
|
347 |
|
348 |
+
$this->upload($files, true, $results);
|
349 |
+
|
350 |
+
return $metadata;
|
351 |
}
|
352 |
|
353 |
/**
|
354 |
* Purge attachment
|
355 |
*
|
356 |
+
* Upload _wp_attached_file, _wp_attachment_metadata, _wp_attachment_backup_sizes
|
357 |
+
*
|
358 |
* @param integer $attachment_id
|
359 |
* @return boolean
|
360 |
*/
|
361 |
function purge_attachment($attachment_id)
|
362 |
{
|
363 |
$files = $this->get_attachment_files($attachment_id);
|
|
|
364 |
|
365 |
if ($this->_config->get_string('cdn.engine') == 'netdna') {
|
366 |
$queue_failed = false;
|
368 |
$queue_failed = true;
|
369 |
}
|
370 |
|
371 |
+
$results = array();
|
372 |
+
|
373 |
return $this->purge($files, $queue_failed, $results);
|
374 |
}
|
375 |
|
381 |
*/
|
382 |
function cron_schedules($schedules)
|
383 |
{
|
384 |
+
$queue_interval = $this->_config->get_integer('cdn.queue.interval');
|
385 |
+
$autoupload_interval = $this->_config->get_integer('cdn.autoupload.interval');
|
386 |
|
387 |
return array_merge($schedules, array(
|
388 |
'w3_cdn_cron_queue_process' => array(
|
389 |
+
'interval' => $queue_interval,
|
390 |
+
'display' => sprintf('[W3TC] CDN queue process (every %d seconds)', $queue_interval)
|
391 |
),
|
392 |
'w3_cdn_cron_upload' => array(
|
393 |
+
'interval' => $autoupload_interval,
|
394 |
+
'display' => sprintf('[W3TC] CDN auto upload (every %d seconds)', $autoupload_interval)
|
395 |
)
|
396 |
));
|
397 |
}
|
419 |
}
|
420 |
|
421 |
/**
|
422 |
+
* Returns array of local_file => remote_file for specified file
|
423 |
+
*
|
424 |
+
* @param string $file
|
425 |
* @return array
|
426 |
*/
|
427 |
+
function get_files_for_upload($file)
|
428 |
{
|
429 |
$files = array();
|
430 |
$upload_info = w3_upload_info();
|
431 |
|
432 |
if ($upload_info) {
|
433 |
+
$file = $this->normalize_attachment_file($file);
|
|
|
434 |
|
435 |
+
$local_file = $upload_info['basedir'] . '/' . $file;
|
436 |
+
$remote_file = ltrim($upload_info['baseurlpath'] . $file, '/');
|
437 |
+
|
438 |
+
$files[$local_file] = $remote_file;
|
439 |
+
}
|
440 |
+
|
441 |
+
return $files;
|
442 |
+
}
|
443 |
+
|
444 |
+
/**
|
445 |
+
* Returns array of files from sizes array
|
446 |
+
*
|
447 |
+
* @param string $base_dir
|
448 |
+
* @param array $sizes
|
449 |
+
* @return array
|
450 |
+
*/
|
451 |
+
function get_sizes_files($attached_file, $sizes)
|
452 |
+
{
|
453 |
+
$files = array();
|
454 |
+
$base_dir = w3_dirname($attached_file);
|
455 |
+
|
456 |
+
foreach ((array) $sizes as $size) {
|
457 |
+
if (isset($size['file'])) {
|
458 |
+
if ($base_dir) {
|
459 |
+
$file = $base_dir . '/' . $size['file'];
|
460 |
+
} else {
|
461 |
+
$file = $size['file'];
|
462 |
+
}
|
463 |
|
464 |
+
$files = array_merge($files, $this->get_files_for_upload($file));
|
465 |
}
|
466 |
+
}
|
467 |
+
|
468 |
+
return $files;
|
469 |
+
}
|
470 |
+
|
471 |
+
/**
|
472 |
+
* Returns attachment files by metadata
|
473 |
+
*
|
474 |
+
* @param array $metadata
|
475 |
+
* @return array
|
476 |
+
*/
|
477 |
+
function get_metadata_files($metadata)
|
478 |
+
{
|
479 |
+
$files = array();
|
480 |
+
|
481 |
+
if (isset($metadata['file']) && isset($metadata['sizes'])) {
|
482 |
+
$files = array_merge($files, $this->get_sizes_files($metadata['file'], $metadata['sizes']));
|
483 |
+
}
|
484 |
+
|
485 |
+
return $files;
|
486 |
+
}
|
487 |
+
|
488 |
+
/**
|
489 |
+
* Returns attachment files by attachment ID
|
490 |
+
*
|
491 |
+
* @param integer $attachment_id
|
492 |
+
* @return array
|
493 |
+
*/
|
494 |
+
function get_attachment_files($attachment_id)
|
495 |
+
{
|
496 |
+
$files = array();
|
497 |
+
|
498 |
+
/**
|
499 |
+
* Get attached file
|
500 |
+
*/
|
501 |
+
$attached_file = get_post_meta($attachment_id, '_wp_attached_file', true);
|
502 |
+
|
503 |
+
if ($attached_file != '') {
|
504 |
+
$files = array_merge($files, $this->get_files_for_upload($attached_file));
|
505 |
+
|
506 |
+
/**
|
507 |
+
* Get backup sizes files
|
508 |
+
*/
|
509 |
+
$attachment_backup_sizes = get_post_meta($attachment_id, '_wp_attachment_backup_sizes', true);
|
510 |
|
511 |
+
if (is_array($attachment_backup_sizes)) {
|
512 |
+
$files = array_merge($files, $this->get_sizes_files($attached_file, $attachment_backup_sizes));
|
513 |
}
|
514 |
}
|
515 |
+
|
516 |
+
/**
|
517 |
+
* Get files from metadata
|
518 |
+
*/
|
519 |
+
$attachment_metadata = get_post_meta($attachment_id, '_wp_attachment_metadata', true);
|
520 |
+
|
521 |
+
if (is_array($attachment_metadata)) {
|
522 |
+
$files = array_merge($files, $this->get_metadata_files($attachment_metadata));
|
523 |
+
}
|
524 |
+
|
525 |
return $files;
|
526 |
}
|
527 |
|
602 |
return $buffer;
|
603 |
}
|
604 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
605 |
/**
|
606 |
* Adds file to queue
|
607 |
*
|
931 |
$results = array();
|
932 |
|
933 |
$upload_info = w3_upload_info();
|
934 |
+
$uploads_use_yearmonth_folders = get_option('uploads_use_yearmonth_folders');
|
935 |
+
$document_root = w3_get_document_root();
|
936 |
|
937 |
@set_time_limit(300);
|
938 |
|
992 |
$error = '';
|
993 |
$result = false;
|
994 |
|
995 |
+
$src = w3_normalize_file_minify($origin);
|
996 |
$dst = '';
|
997 |
|
998 |
/**
|
1010 |
list($dst, $dst_url) = $attachments[$src];
|
1011 |
$result = true;
|
1012 |
} else {
|
1013 |
+
if ($uploads_use_yearmonth_folders) {
|
1014 |
+
$upload_subdir = date('Y/m', strtotime($post->post_date));
|
1015 |
+
$upload_dir = sprintf('%s/%s', $upload_info['basedir'], $upload_subdir);
|
1016 |
+
$upload_url = sprintf('%s/%s', $upload_info['baseurl'], $upload_subdir);
|
1017 |
+
} else {
|
1018 |
+
$upload_subdir = '';
|
1019 |
+
$upload_dir = $upload_info['basedir'];
|
1020 |
+
$upload_url = $upload_info['baseurl'];
|
1021 |
+
}
|
1022 |
|
1023 |
$src_filename = pathinfo($src, PATHINFO_FILENAME);
|
1024 |
$src_extension = pathinfo($src, PATHINFO_EXTENSION);
|
1035 |
}
|
1036 |
|
1037 |
$dst_basename = basename($dst);
|
|
|
1038 |
$dst_url = sprintf('%s/%s', $upload_url, $dst_basename);
|
1039 |
+
$dst_path = ltrim(str_replace($document_root, '', w3_path($dst)), '/');
|
1040 |
|
1041 |
+
if ($upload_subdir) {
|
1042 |
+
w3_mkdir($upload_subdir, 0755, $upload_info['basedir']);
|
1043 |
+
}
|
1044 |
|
1045 |
$download_result = false;
|
1046 |
|
1064 |
/**
|
1065 |
* Otherwise copy file from local path
|
1066 |
*/
|
1067 |
+
$src_path = $document_root . '/' . urldecode($src);
|
1068 |
|
1069 |
if (file_exists($src_path)) {
|
1070 |
$download_result = @copy($src_path, $dst);
|
1083 |
if ($download_result) {
|
1084 |
$title = $dst_basename;
|
1085 |
$guid = ltrim($upload_info['baseurlpath'] . $title, ',');
|
1086 |
+
$mime_type = w3_get_mime_type($dst);
|
1087 |
|
1088 |
$GLOBALS['wp_rewrite'] = & new WP_Rewrite();
|
1089 |
|
1131 |
} else {
|
1132 |
$error = 'File type rejected';
|
1133 |
}
|
1134 |
+
} else
|
1135 |
+
|
1136 |
+
{
|
1137 |
$error = 'File already exists in the media library';
|
1138 |
}
|
1139 |
|
1140 |
/**
|
1141 |
* Add new entry to the log file
|
1142 |
*/
|
1143 |
+
|
1144 |
$results[] = array(
|
1145 |
'src' => $src,
|
1146 |
+
'dst' => $dst_path,
|
1147 |
'result' => $result,
|
1148 |
'error' => $error
|
1149 |
);
|
1338 |
*/
|
1339 |
function get_files_includes()
|
1340 |
{
|
1341 |
+
$includes_root = w3_path(ABSPATH . WPINC);
|
1342 |
+
$document_root = w3_get_document_root();
|
1343 |
+
$includes_path = ltrim(str_replace($document_root, '', $includes_root), '/');
|
1344 |
+
|
1345 |
+
$files = $this->search_files($includes_root, $includes_path, $this->_config->get_string('cdn.includes.files'));
|
1346 |
|
1347 |
return $files;
|
1348 |
}
|
1357 |
* we should upload whole themes directory
|
1358 |
*/
|
1359 |
if ($this->_config->get_boolean('mobile.enabled')) {
|
1360 |
+
$themes_root = get_theme_root();
|
1361 |
} else {
|
1362 |
+
$themes_root = get_stylesheet_directory();
|
1363 |
}
|
1364 |
|
1365 |
+
$themes_root = w3_path($themes_root);
|
1366 |
+
$document_root = w3_get_document_root();
|
1367 |
+
$themes_path = ltrim(str_replace($document_root, '', $themes_root), '/');
|
1368 |
+
|
1369 |
+
$files = $this->search_files($themes_root, $themes_path, $this->_config->get_string('cdn.theme.files'));
|
1370 |
|
1371 |
return $files;
|
1372 |
}
|
1381 |
if (W3TC_PHP5 && $this->_config->get_boolean('minify.rewrite')) {
|
1382 |
require_once W3TC_LIB_W3_DIR . '/Plugin/Minify.php';
|
1383 |
$minify = & W3_Plugin_Minify::instance();
|
1384 |
+
|
1385 |
+
$document_root = w3_get_document_root();
|
1386 |
+
$minify_root = w3_path(W3TC_CACHE_FILE_MINIFY_DIR);
|
1387 |
+
$minify_path = ltrim(str_replace($document_root, '', $minify_root), '/');
|
1388 |
+
|
1389 |
$urls = $minify->get_urls();
|
1390 |
|
1391 |
if ($this->_config->get_string('minify.engine') == 'file') {
|
1393 |
w3_http_get($url);
|
1394 |
}
|
1395 |
|
1396 |
+
$files = $this->search_files($minify_root, $minify_path, '*.css;*.js');
|
1397 |
} else {
|
1398 |
+
$domain_url_regexp = '~' . w3_get_domain_url_regexp() . '~';
|
1399 |
+
|
1400 |
foreach ($urls as $url) {
|
1401 |
+
$file = w3_normalize_file_minify($url);
|
1402 |
$file = w3_translate_file($file);
|
1403 |
|
1404 |
if (!w3_is_url($file)) {
|
1405 |
+
$file = $document_root . '/' . $file;
|
1406 |
+
$file = ltrim(str_replace($minify_root, '', $file), '/');
|
1407 |
|
1408 |
$dir = dirname($file);
|
1409 |
|
1410 |
if ($dir) {
|
1411 |
+
w3_mkdir($dir, 0755, $minify_root);
|
1412 |
}
|
1413 |
|
1414 |
+
if (w3_download($url, $minify_root . '/' . $file) !== false) {
|
1415 |
+
$files[] = $minify_path . '/' . $file;
|
1416 |
}
|
1417 |
}
|
1418 |
}
|
1428 |
function get_files_custom()
|
1429 |
{
|
1430 |
$files = array();
|
1431 |
+
$document_root = w3_get_document_root();
|
1432 |
$custom_files = $this->_config->get_array('cdn.custom.files');
|
1433 |
|
1434 |
foreach ($custom_files as $custom_file) {
|
1441 |
}
|
1442 |
|
1443 |
$mask = basename($custom_file);
|
1444 |
+
$files = array_merge($files, $this->search_files($document_root . '/' . $dir, $dir, $mask));
|
1445 |
}
|
1446 |
}
|
1447 |
|
1633 |
switch ($engine) {
|
1634 |
case 'mirror':
|
1635 |
$engine_config = array(
|
1636 |
+
'domain' => $this->_config->get_array('cdn.mirror.domain'),
|
1637 |
+
'ssl' => $this->_config->get_string('cdn.mirror.ssl')
|
1638 |
);
|
1639 |
break;
|
1640 |
|
1642 |
$engine_config = array(
|
1643 |
'apiid' => $this->_config->get_string('cdn.netdna.apiid'),
|
1644 |
'apikey' => $this->_config->get_string('cdn.netdna.apikey'),
|
1645 |
+
'domain' => $this->_config->get_array('cdn.netdna.domain'),
|
1646 |
+
'ssl' => $this->_config->get_string('cdn.netdna.ssl')
|
1647 |
);
|
1648 |
break;
|
1649 |
|
1654 |
'pass' => $this->_config->get_string('cdn.ftp.pass'),
|
1655 |
'path' => $this->_config->get_string('cdn.ftp.path'),
|
1656 |
'pasv' => $this->_config->get_boolean('cdn.ftp.pasv'),
|
1657 |
+
'domain' => $this->_config->get_array('cdn.ftp.domain'),
|
1658 |
+
'ssl' => $this->_config->get_string('cdn.ftp.ssl')
|
1659 |
);
|
1660 |
break;
|
1661 |
|
1665 |
'secret' => $this->_config->get_string('cdn.s3.secret'),
|
1666 |
'bucket' => $this->_config->get_string('cdn.s3.bucket'),
|
1667 |
'cname' => $this->_config->get_array('cdn.s3.cname'),
|
1668 |
+
'compression' => ($this->_config->get_boolean('browsercache.enabled') && $this->_config->get_boolean('browsercache.html.compression')),
|
1669 |
+
'ssl' => $this->_config->get_string('cdn.s3.ssl')
|
1670 |
);
|
1671 |
break;
|
1672 |
|
1677 |
'bucket' => $this->_config->get_string('cdn.cf.bucket'),
|
1678 |
'id' => $this->_config->get_string('cdn.cf.id'),
|
1679 |
'cname' => $this->_config->get_array('cdn.cf.cname'),
|
1680 |
+
'compression' => ($this->_config->get_boolean('browsercache.enabled') && $this->_config->get_boolean('browsercache.html.compression')),
|
1681 |
+
'ssl' => $this->_config->get_string('cdn.cf.ssl')
|
1682 |
);
|
1683 |
break;
|
1684 |
|
1688 |
'key' => $this->_config->get_string('cdn.rscf.key'),
|
1689 |
'container' => $this->_config->get_string('cdn.rscf.container'),
|
1690 |
'id' => $this->_config->get_string('cdn.rscf.id'),
|
1691 |
+
'cname' => $this->_config->get_array('cdn.rscf.cname'),
|
1692 |
+
'ssl' => $this->_config->get_string('cdn.rscf.ssl')
|
1693 |
);
|
1694 |
break;
|
1695 |
}
|
lib/W3/Plugin/TotalCache.php
CHANGED
@@ -3429,13 +3429,13 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
3429 |
$w3_plugin_cdn = & W3_Plugin_Cdn::instance();
|
3430 |
|
3431 |
$files = W3_Request::get_array('files');
|
3432 |
-
$
|
3433 |
|
3434 |
$upload = array();
|
3435 |
$results = array();
|
3436 |
|
3437 |
foreach ($files as $file) {
|
3438 |
-
$upload[
|
3439 |
}
|
3440 |
|
3441 |
$w3_plugin_cdn->upload($upload, false, $results);
|
@@ -3459,13 +3459,13 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
3459 |
$w3_plugin_cdn = & W3_Plugin_Cdn::instance();
|
3460 |
|
3461 |
$files = $w3_plugin_cdn->get_files_minify();
|
3462 |
-
$
|
3463 |
|
3464 |
$upload = array();
|
3465 |
$results = array();
|
3466 |
|
3467 |
foreach ($files as $file) {
|
3468 |
-
$upload[
|
3469 |
}
|
3470 |
|
3471 |
return $w3_plugin_cdn->upload($upload, true, $results);
|
@@ -3484,13 +3484,17 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
3484 |
$w3_plugin_cdn = & W3_Plugin_Cdn::instance();
|
3485 |
$w3_plugin_browsercache = & W3_Plugin_BrowserCache::instance();
|
3486 |
|
|
|
|
|
|
|
|
|
3487 |
$path = W3TC_TMP_DIR . '/htaccess_ftp.txt';
|
3488 |
$rules = $w3_plugin_browsercache->generate_rules_cache();
|
3489 |
|
3490 |
if (@file_put_contents($path, $rules)) {
|
3491 |
$results = array();
|
3492 |
$upload = array(
|
3493 |
-
$path => '
|
3494 |
);
|
3495 |
|
3496 |
return $w3_plugin_cdn->upload($upload, true, $results);
|
@@ -3512,11 +3516,15 @@ class W3_Plugin_TotalCache extends W3_Plugin
|
|
3512 |
$w3_plugin_cdn = & W3_Plugin_Cdn::instance();
|
3513 |
$w3_plugin_browsercache = & W3_Plugin_BrowserCache::instance();
|
3514 |
|
|
|
|
|
|
|
|
|
3515 |
$path = W3TC_TMP_DIR . '/htaccess_ftp.txt';
|
3516 |
|
3517 |
$results = array();
|
3518 |
$delete = array(
|
3519 |
-
$path => '
|
3520 |
);
|
3521 |
|
3522 |
return $w3_plugin_cdn->delete($delete, true, $results);
|
3429 |
$w3_plugin_cdn = & W3_Plugin_Cdn::instance();
|
3430 |
|
3431 |
$files = W3_Request::get_array('files');
|
3432 |
+
$document_root = w3_get_document_root();
|
3433 |
|
3434 |
$upload = array();
|
3435 |
$results = array();
|
3436 |
|
3437 |
foreach ($files as $file) {
|
3438 |
+
$upload[$document_root . '/' . $file] = $file;
|
3439 |
}
|
3440 |
|
3441 |
$w3_plugin_cdn->upload($upload, false, $results);
|
3459 |
$w3_plugin_cdn = & W3_Plugin_Cdn::instance();
|
3460 |
|
3461 |
$files = $w3_plugin_cdn->get_files_minify();
|
3462 |
+
$document_root = w3_get_document_root();
|
3463 |
|
3464 |
$upload = array();
|
3465 |
$results = array();
|
3466 |
|
3467 |
foreach ($files as $file) {
|
3468 |
+
$upload[$document_root . '/' . $file] = $file;
|
3469 |
}
|
3470 |
|
3471 |
return $w3_plugin_cdn->upload($upload, true, $results);
|
3484 |
$w3_plugin_cdn = & W3_Plugin_Cdn::instance();
|
3485 |
$w3_plugin_browsercache = & W3_Plugin_BrowserCache::instance();
|
3486 |
|
3487 |
+
$tmp_root = W3TC_TMP_DIR;
|
3488 |
+
$document_root = w3_get_document_root();
|
3489 |
+
$tmp_path = ltrim(str_replace($document_root, '', $tmp_root), '/');
|
3490 |
+
|
3491 |
$path = W3TC_TMP_DIR . '/htaccess_ftp.txt';
|
3492 |
$rules = $w3_plugin_browsercache->generate_rules_cache();
|
3493 |
|
3494 |
if (@file_put_contents($path, $rules)) {
|
3495 |
$results = array();
|
3496 |
$upload = array(
|
3497 |
+
$path => $tmp_path . '/.htaccess'
|
3498 |
);
|
3499 |
|
3500 |
return $w3_plugin_cdn->upload($upload, true, $results);
|
3516 |
$w3_plugin_cdn = & W3_Plugin_Cdn::instance();
|
3517 |
$w3_plugin_browsercache = & W3_Plugin_BrowserCache::instance();
|
3518 |
|
3519 |
+
$tmp_root = W3TC_TMP_DIR;
|
3520 |
+
$document_root = w3_get_document_root();
|
3521 |
+
$tmp_path = ltrim(str_replace($document_root, '', $tmp_root), '/');
|
3522 |
+
|
3523 |
$path = W3TC_TMP_DIR . '/htaccess_ftp.txt';
|
3524 |
|
3525 |
$results = array();
|
3526 |
$delete = array(
|
3527 |
+
$path => $tmp_path . '/.htaccess'
|
3528 |
);
|
3529 |
|
3530 |
return $w3_plugin_cdn->delete($delete, true, $results);
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: fredericktownes
|
3 |
Tags: user experience, cache, caching, page cache, css cache, js cache, db cache, disk cache, disk caching, database cache, http compression, gzip, deflate, minify, CDN, content delivery network, media library, performance, speed, multiple hosts, CSS, merge, combine, unobtrusive javascript, compress, optimize, optimizer, JavaScript, JS, cascading style sheet, plugin, yslow, YUI, google, google rank, google page speed, S3, CloudFront, AWS, Amazon Web Services, cloud files, rackspace, batcache, wp cache, wp super cache, w3 total cache, buddypress
|
4 |
Requires at least: 2.8
|
5 |
-
Tested up to: 3.
|
6 |
-
Stable tag: 0.9.1.
|
7 |
|
8 |
Easily optimize the speed and user experience of your site with caching: browser, page, object, database, minify and content delivery network support.
|
9 |
|
@@ -65,13 +65,9 @@ Rarely do readers take the time to complain. They typically just stop browsing e
|
|
65 |
|
66 |
It's in every web site owner's best interest is to make sure that the performance of your site is not hindering its success.
|
67 |
|
68 |
-
= And how many years of university do I need to use this thing? =
|
69 |
-
|
70 |
-
-4 - That's right; a youngster in junior high school can get started with this plugin. Seriously, if you did your own WordPress install or have ever installed a plugin before you're in good shape. If you need help, let us know or perhaps we'll make some videos or the like.
|
71 |
-
|
72 |
= Which WordPress versions are supported? =
|
73 |
|
74 |
-
To use all features in the suite, a minimum of version WordPress 2.
|
75 |
|
76 |
= What about comments? Does the plugin slow down the rate at which comments appear? =
|
77 |
|
@@ -242,8 +238,15 @@ Install the plugin to read the full FAQ.
|
|
242 |
|
243 |
== Press: Mentions, Tutorials & Reviews ==
|
244 |
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
**August 2010:**
|
246 |
|
|
|
247 |
* [How to configure WordPress Blogs Search Engine Friendly](http://solvater.com/2010/09/how-to-configure-wordpress-blog-search-engine-friendly-complete-beginners-guide-for-wordpress-seo/), Arafath Hashmi
|
248 |
* [How to Install and Setup W3 Total Cache for Beginners](http://www.wpbeginner.com/plugins/how-to-install-and-setup-w3-total-cache-for-beginners/)
|
249 |
* [20 Most Useful WordPress Plugins](http://zemalf.posterous.com/20-most-useful-wordpress-plugins), Antti Kokkonen
|
@@ -359,6 +362,18 @@ Please reach out to all of these people and support their projects if you're so
|
|
359 |
|
360 |
== Changelog ==
|
361 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
362 |
= 0.9.1.2 =
|
363 |
* Improved media library import compatibility
|
364 |
* Improved various notifications
|
2 |
Contributors: fredericktownes
|
3 |
Tags: user experience, cache, caching, page cache, css cache, js cache, db cache, disk cache, disk caching, database cache, http compression, gzip, deflate, minify, CDN, content delivery network, media library, performance, speed, multiple hosts, CSS, merge, combine, unobtrusive javascript, compress, optimize, optimizer, JavaScript, JS, cascading style sheet, plugin, yslow, YUI, google, google rank, google page speed, S3, CloudFront, AWS, Amazon Web Services, cloud files, rackspace, batcache, wp cache, wp super cache, w3 total cache, buddypress
|
4 |
Requires at least: 2.8
|
5 |
+
Tested up to: 3.0.2
|
6 |
+
Stable tag: 0.9.1.3
|
7 |
|
8 |
Easily optimize the speed and user experience of your site with caching: browser, page, object, database, minify and content delivery network support.
|
9 |
|
65 |
|
66 |
It's in every web site owner's best interest is to make sure that the performance of your site is not hindering its success.
|
67 |
|
|
|
|
|
|
|
|
|
68 |
= Which WordPress versions are supported? =
|
69 |
|
70 |
+
To use all features in the suite, a minimum of version WordPress 2.8 with PHP 5 is required. Earlier versions will benefit from our Media Library Importer to get them back on the upgrade path and into a CDN of their choosing.
|
71 |
|
72 |
= What about comments? Does the plugin slow down the rate at which comments appear? =
|
73 |
|
238 |
|
239 |
== Press: Mentions, Tutorials & Reviews ==
|
240 |
|
241 |
+
**September 2010:**
|
242 |
+
|
243 |
+
* [Performance Unleashed: How To Optimize Websites For Speed](http://diythemes.com/thesis/improve-website-pagespeed/), Willie Jackson
|
244 |
+
* [5 Best WordPress Plugins To Improve The Loading Speed Of a Blog](http://www.gadgetcage.com/2010/09/5-best-wordpress-plugins-to-improve-the-loading-speed-of-a-blog.html/)
|
245 |
+
* [WordPress Fat-Loss Diet to Speed Up & Ease Load](http://www.daljinskapodrska.com/wordpress-fat-loss-diet-to-speed-up-ease-load/)
|
246 |
+
|
247 |
**August 2010:**
|
248 |
|
249 |
+
* [WordPress Speed and Optimization Guide](http://thesocialmediaguide.com.au/2010/08/30/wordpress-speed-and-optimization-guide/), Matthew Tommasi
|
250 |
* [How to configure WordPress Blogs Search Engine Friendly](http://solvater.com/2010/09/how-to-configure-wordpress-blog-search-engine-friendly-complete-beginners-guide-for-wordpress-seo/), Arafath Hashmi
|
251 |
* [How to Install and Setup W3 Total Cache for Beginners](http://www.wpbeginner.com/plugins/how-to-install-and-setup-w3-total-cache-for-beginners/)
|
252 |
* [20 Most Useful WordPress Plugins](http://zemalf.posterous.com/20-most-useful-wordpress-plugins), Antti Kokkonen
|
362 |
|
363 |
== Changelog ==
|
364 |
|
365 |
+
= 0.9.1.3 =
|
366 |
+
* Improved error messages with AWS S3 CDN
|
367 |
+
* Added SSL support for CDN
|
368 |
+
* Added control for CDN queue upload interval
|
369 |
+
* Added option for 404 file exceptions list in browser cache
|
370 |
+
* Added exception for NextGen Gallery flash image rotator to CDN settings
|
371 |
+
* Fixed bug with external file imports
|
372 |
+
* Fixed bug with document root detection for CDN
|
373 |
+
* Fixed bug with minify file search
|
374 |
+
* Fixed bugs with AWS CloudFront distribution creation and saving
|
375 |
+
* Fixed bug with Rackspace Cloud Files API
|
376 |
+
|
377 |
= 0.9.1.2 =
|
378 |
* Improved media library import compatibility
|
379 |
* Improved various notifications
|
w3-total-cache.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*
|
3 |
Plugin Name: W3 Total Cache
|
4 |
Description: The fastest and most complete WordPress performance plugin. Dramatically improve the speed and user experience of your site. Add browser, page, object and database caching as well as minify and content delivery network (CDN) to WordPress.
|
5 |
-
Version: 0.9.1.
|
6 |
Plugin URI: http://www.w3-edge.com/wordpress-plugins/w3-total-cache/
|
7 |
Author: Frederick Townes
|
8 |
Author URI: http://www.linkedin.com/in/w3edge
|
2 |
/*
|
3 |
Plugin Name: W3 Total Cache
|
4 |
Description: The fastest and most complete WordPress performance plugin. Dramatically improve the speed and user experience of your site. Add browser, page, object and database caching as well as minify and content delivery network (CDN) to WordPress.
|
5 |
+
Version: 0.9.1.3
|
6 |
Plugin URI: http://www.w3-edge.com/wordpress-plugins/w3-total-cache/
|
7 |
Author: Frederick Townes
|
8 |
Author URI: http://www.linkedin.com/in/w3edge
|