Version Description
- Fixed minified files not being hosted by CDN when enabled if "host minified files" is disabled
- Fixed warning thrown when purge all was selected (via nigrosimone)
- Fixed undefined offset error in fragment cache
- Fixed MaxCDN test button failure when debug mode is enabled
- Fixed purging of feeds when cache feeds option is enabeld
- Improved handling of errors when full site delivery isn't set
- Improved nginx.conf to support xml caching
- Improved nginx.conf to support HSTS for static files
- Improved minify's handling of query strings
- Improved database caching, frequent wp_options no longer flush posts or comments data
- Improved Limelight Networks CDN integration
- Improved FAQ, they're now hosted in the GitHub public repository
- Improved handling for /<![CDATA[/ in HTML minify engine
- Imporved garbage collection for basic disk caching
- Improved HSTS support (via Dave Welsh)
- Improved reliabilty of CSS embed options
- Improved New Relic requirements in compatibility test
- Added StackPath CDN integration (including full site delivery)
- Added support for page cache priming via WP-CLI via prime function
- Added filter support for managing cache groups
- Added API for flushing individual cache groups via flush_group function
- Added purge support for JSON cache e.g. cached REST API requests
- Added filter support for managing database cache settings
- Added filter support before (w3tc_process_content) and after (w3tc_processed_content) a cache object is created
- Added compatibility for AMPforWP plugin
- Added JSON caching support for Pro subscribers
- Added additional security headers (via amiga-500)
Download this release
Release Info
Developer | fredericktownes |
Plugin | ![]() |
Version | 0.9.7 |
Comparing to | |
See all releases |
Code changes from version 0.9.6 to 0.9.7
- BrowserCache_ConfigLabels.php +34 -1
- BrowserCache_Environment.php +227 -5
- CacheFlush.php +11 -0
- CacheFlush_Locally.php +10 -4
- Cache_Apc.php +1 -1
- Cache_Apcu.php +1 -1
- Cache_Base.php +1 -1
- Cache_Eaccelerator.php +1 -1
- Cache_File.php +7 -7
- Cache_File_Cleaner_Generic.php +26 -13
- Cache_File_Cleaner_Generic_HardDelete.php +20 -0
- Cache_File_Generic.php +30 -16
- Cache_Memcache.php +3 -1
- Cache_Memcached.php +3 -1
- Cache_Redis.php +1 -1
- Cache_Wincache.php +1 -1
- Cache_Xcache.php +1 -1
- CdnEngine.php +8 -0
- CdnEngine_Base.php +3 -5
- CdnEngine_Mirror_LimeLight.php +136 -0
- CdnEngine_Mirror_StackPath.php +113 -0
- Cdn_AdminActions.php +4 -2
- Cdn_CacheFlush.php +1 -1
- Cdn_Core.php +131 -89
- Cdn_Core_Admin.php +1 -1
- Cdn_LimeLight_Page.php +18 -0
- Cdn_LimeLight_Page_View.js +42 -0
- Cdn_LimeLight_Page_View.php +51 -0
- Cdn_LimeLight_Popup.php +75 -0
- Cdn_LimeLight_Popup_View_Intro.php +57 -0
- Cdn_LimeLight_Popup_View_Success.php +22 -0
- Cdn_MaxCdn_Page_View.js +0 -6
- Cdn_MaxCdn_Popup.php +2 -2
- Cdn_Plugin.php +32 -51
- Cdn_Plugin_Admin.php +36 -0
- Cdn_Plugin_WidgetMaxCdn.php +78 -102
- Cdn_Plugin_WidgetMaxCdn_View.css +95 -0
- Cdn_Plugin_WidgetMaxCdn_View.js +62 -0
- Cdn_Plugin_WidgetMaxCdn_View_Authorized.php +86 -0
- Cdn_Plugin_WidgetMaxCdn_View_Unauthorized.php +17 -0
- Cdn_StackPath_Api.php +249 -0
- Cdn_StackPath_Page.php +28 -0
- Cdn_StackPath_Page_View.js +62 -0
- Cdn_StackPath_Page_View.php +96 -0
- Cdn_StackPath_Popup.php +276 -0
- Cdn_StackPath_Popup_View_Intro.php +39 -0
- Cdn_StackPath_Popup_View_Success.php +23 -0
- Cdn_StackPath_Popup_View_Zone.php +42 -0
- Cdn_StackPath_Popup_View_Zones.php +53 -0
- Cdn_StackPath_Widget.php +141 -0
- Cdn_StackPath_Widget_View.css +98 -0
- Cdn_StackPath_Widget_View.js +62 -0
- Cdn_StackPath_Widget_View_Authorized.php +75 -0
- Cdn_StackPath_Widget_View_Unauthorized.php +17 -0
- Cdn_Util.php +8 -1
- Cdnfsd_CacheFlush.php +11 -3
- Cdnfsd_Core.php +9 -2
- Cdnfsd_Limelight_Api.php → Cdnfsd_LimeLight_Api.php +1 -1
- Cdnfsd_Limelight_Engine.php → Cdnfsd_LimeLight_Engine.php +3 -3
- Cdnfsd_Limelight_Page.php → Cdnfsd_LimeLight_Page.php +3 -3
- Cdnfsd_Limelight_Page_View.js → Cdnfsd_LimeLight_Page_View.js +0 -0
- Cdnfsd_Limelight_Page_View.php → Cdnfsd_LimeLight_Page_View.php +0 -0
- Cdnfsd_Limelight_Popup.php → Cdnfsd_LimeLight_Popup.php +5 -5
- Cdnfsd_Limelight_Popup_View_Intro.php → Cdnfsd_LimeLight_Popup_View_Intro.php +1 -1
- Cdnfsd_Limelight_Popup_View_Success.php → Cdnfsd_LimeLight_Popup_View_Success.php +0 -0
- Cdnfsd_MaxCdn_Popup.php +1 -1
- Cdnfsd_Plugin.php +6 -0
- Cdnfsd_Plugin_Admin.php +20 -5
- Cdnfsd_StackPath_Engine.php +48 -0
- Cdnfsd_StackPath_Page.php +20 -0
- Cdnfsd_StackPath_Page_View.js +102 -0
- Cdnfsd_StackPath_Page_View.php +61 -0
- Cdnfsd_StackPath_Popup.php +319 -0
- Cdnfsd_StackPath_Popup_View_Intro.php +39 -0
- Cdnfsd_StackPath_Popup_View_Success.php +26 -0
- Cdnfsd_StackPath_Popup_View_Zone.php +59 -0
- Cdnfsd_StackPath_Popup_View_Zones.php +53 -0
- Cli.php +38 -6
- ConfigCompiler.php +9 -0
- ConfigKeys.php +225 -7
- DbCache_Wpdb.php +2 -2
- DbCache_WpdbInjection.php +1 -1
- DbCache_WpdbInjection_QueryCaching.php +131 -39
- Enterprise_CacheFlush_MakeSnsEvent.php +9 -0
- Enterprise_SnsServer.php +4 -0
- Extension_Amp_Plugin.php +7 -2
- Extension_CloudFlare_AdminActions.php +1 -1
- Extension_CloudFlare_Api.php +6 -1
- Extension_CloudFlare_Plugin.php +1 -1
- Extension_FragmentCache_WpObjectCache.php +1 -1
- Extension_NewRelic_Page_View_Apm.php +1 -1
- Extension_NewRelic_Service.php +4 -5
- Extension_NewRelic_Widget_View.css +3 -3
- Extension_Swarmify_Plugin_Admin.php +0 -25
- Generic_AdminActions_Default.php +37 -22
- Generic_AdminActions_Flush.php +1 -1
- Generic_Faq.php +40 -80
- Generic_Page_Faq.php +0 -32
- Generic_Plugin.php +4 -2
- Generic_Plugin_Admin.php +28 -34
- Generic_Plugin_AdminNotifications.php +13 -5
- inc/options/common/help.php → Generic_Plugin_Admin_View_Faq.php +2 -4
- Generic_WidgetSpreadTheWord.js +4 -0
- Generic_WidgetSpreadTheWord_View.php +7 -5
- Minify_ContentMinifier.php +1 -1
- Minify_MinifiedFileRequestHandler.php +12 -8
- Minify_Plugin.php +17 -11
- ObjectCache_WpObjectCache_Regular.php +14 -13
- PgCache_ContentGrabber.php +87 -46
- PgCache_Environment.php +5 -1
- PgCache_Flush.php +35 -13
- PgCache_Plugin.php +37 -2
- PgCache_Plugin_Admin.php +29 -27
- Root_AdminMenu.php +12 -7
- Root_Loader.php +2 -1
- Util_Environment.php +43 -25
- Util_PageUrls.php +46 -0
- Util_Ui.php +30 -11
- inc/lightbox/self_test.php +1 -1
- inc/lightbox/support_us.php +26 -27
- inc/lightbox/upgrade.php +7 -4
- inc/options/browsercache.php +359 -11
- inc/options/cdn.php +5 -4
- inc/options/common/header.php +2 -1
- inc/options/dashboard.php +1 -1
- inc/options/faq.php +0 -40
- inc/options/general.php +1 -2
- inc/options/pgcache.php +29 -2
- inc/widget/maxcdn.php +0 -64
- inc/widget/maxcdn_signup.php +0 -22
- ini/apache_conf/mod_deflate.conf +48 -0
- ini/apache_conf/mod_expires.conf +95 -0
- ini/apache_conf/mod_mime.conf +59 -0
- ini/apache_conf/mod_rewrite.conf +18 -0
- languages/faq-en_US.xml +0 -826
- languages/faq-enterprise-en_US.xml +0 -61
- languages/faq-pro-en_US.xml +0 -221
- lib/Minify/Minify.php +2 -1
- lib/Minify/Minify/HTML.php +3 -2
- lib/NetDNA/NetDNA.php +0 -66
- lib/OAuth/W3tcOAuth.php +14 -11
- pub/css/lightbox.css +21 -0
- pub/css/options.css +16 -7
- pub/css/widget.css +0 -63
- pub/img/cspref.png +0 -0
- pub/img/w3tc_stackpath-logo-retina.png +0 -0
- pub/img/w3tc_stackpath-logo.png +0 -0
- pub/js/lightbox.js +7 -0
- pub/js/options.js +1435 -1355
- readme.txt +34 -5
- w3-total-cache-api.php +20 -5
- w3-total-cache.php +1 -1
BrowserCache_ConfigLabels.php
CHANGED
@@ -35,7 +35,40 @@ class BrowserCache_ConfigLabels {
|
|
35 |
'browsercache.other.w3tc' => __( 'Set W3 Total Cache header', 'w3-total-cache' ),
|
36 |
'browsercache.other.compression' => __( 'Enable <acronym title="Hypertext Transfer Protocol">HTTP</acronym> (gzip) compression</label>', 'w3-total-cache' ),
|
37 |
'browsercache.other.replace' => __( 'Prevent caching of objects after settings change', 'w3-total-cache' ),
|
38 |
-
'browsercache.other.nocookies' => __( 'Disable cookies for static files', 'w3-total-cache' )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
) );
|
40 |
}
|
41 |
}
|
35 |
'browsercache.other.w3tc' => __( 'Set W3 Total Cache header', 'w3-total-cache' ),
|
36 |
'browsercache.other.compression' => __( 'Enable <acronym title="Hypertext Transfer Protocol">HTTP</acronym> (gzip) compression</label>', 'w3-total-cache' ),
|
37 |
'browsercache.other.replace' => __( 'Prevent caching of objects after settings change', 'w3-total-cache' ),
|
38 |
+
'browsercache.other.nocookies' => __( 'Disable cookies for static files', 'w3-total-cache' ),
|
39 |
+
'browsercache.security.session.cookie_httponly' => __( 'Access session cookies through the <acronym title="Hypertext Transfer Protocol">HTTP</acronym> only:', 'w3-total-cache' ),
|
40 |
+
'browsercache.security.session.cookie_secure' => __( 'Send session cookies only to secure connections:', 'w3-total-cache' ),
|
41 |
+
'browsercache.security.session.use_only_cookies' => __( 'Use cookies to store session IDs:', 'w3-total-cache' ),
|
42 |
+
'browsercache.hsts' => __( '<acronym title="Hypertext Transfer Protocol">HTTP</acronym> Strict Transport Security policy', 'w3-total-cache' ),
|
43 |
+
'browsercache.security.hsts.directive' => __( 'Directive:', 'w3-total-cache' ),
|
44 |
+
'browsercache.security.xfo' => __( 'X-Frame-Options', 'w3-total-cache' ),
|
45 |
+
'browsercache.security.xfo.directive' => __( 'Directive:', 'w3-total-cache' ),
|
46 |
+
'browsercache.security.xss' => __( 'X-XSS-Protection', 'w3-total-cache' ),
|
47 |
+
'browsercache.security.xss.directive' => __( 'Directive:', 'w3-total-cache' ),
|
48 |
+
'browsercache.security.xcto' => __( 'X-Content-Type-Options', 'w3-total-cache' ),
|
49 |
+
'browsercache.security.pkp' => __( '<acronym title="Hypertext Transfer Protocol">HTTP</acronym> Public Key Pinning', 'w3-total-cache' ),
|
50 |
+
'browsercache.security.pkp.pin' => __( 'Public Key:', 'w3-total-cache' ),
|
51 |
+
'browsercache.security.pkp.pin.backup' => __( 'Public Key (Backup):', 'w3-total-cache' ),
|
52 |
+
'browsercache.security.pkp.extra' => __( 'Extra Parameters:', 'w3-total-cache' ),
|
53 |
+
'browsercache.security.pkp.report.url' => __( 'Report <acronym title="Uniform Resource Locator">URL</acronym>:', 'w3-total-cache' ),
|
54 |
+
'browsercache.security.pkp.report.only' => __( 'Report Mode Only:', 'w3-total-cache' ),
|
55 |
+
'browsercache.security.referrer.policy' => __( 'Referrer Policy', 'w3-total-cache' ),
|
56 |
+
'browsercache.security.referrer.policy.directive' => __( 'Directive:', 'w3-total-cache' ),
|
57 |
+
'browsercache.security.csp' => __( 'Content Security Policy', 'w3-total-cache' ),
|
58 |
+
'browsercache.security.csp.base' => __( 'base-uri:', 'w3-total-cache' ),
|
59 |
+
'browsercache.security.csp.frame' => __( 'frame-src:', 'w3-total-cache' ),
|
60 |
+
'browsercache.security.csp.connect' => __( 'connect-src:', 'w3-total-cache' ),
|
61 |
+
'browsercache.security.csp.font' => __( 'font-src:', 'w3-total-cache' ),
|
62 |
+
'browsercache.security.csp.script' => __( 'script-src:', 'w3-total-cache' ),
|
63 |
+
'browsercache.security.csp.style' => __( 'style-src:', 'w3-total-cache' ),
|
64 |
+
'browsercache.security.csp.img' => __( 'img-src:', 'w3-total-cache' ),
|
65 |
+
'browsercache.security.csp.media' => __( 'media-src:', 'w3-total-cache' ),
|
66 |
+
'browsercache.security.csp.object' => __( 'object-src:', 'w3-total-cache' ),
|
67 |
+
'browsercache.security.csp.plugin' => __( 'plugin-types:', 'w3-total-cache' ),
|
68 |
+
'browsercache.security.csp.form' => __( 'form-action:', 'w3-total-cache' ),
|
69 |
+
'browsercache.security.csp.frame.ancestors' => __( 'frame-ancestors:', 'w3-total-cache' ),
|
70 |
+
'browsercache.security.csp.sandbox' => __( 'sandbox:', 'w3-total-cache' ),
|
71 |
+
'browsercache.security.csp.default' => __( 'default-src:', 'w3-total-cache' )
|
72 |
) );
|
73 |
}
|
74 |
}
|
BrowserCache_Environment.php
CHANGED
@@ -258,7 +258,6 @@ class BrowserCache_Environment {
|
|
258 |
|
259 |
$rules .= "</IfModule>\n";
|
260 |
|
261 |
-
|
262 |
$rules .= "<IfModule mod_expires.c>\n";
|
263 |
$rules .= " ExpiresActive On\n";
|
264 |
|
@@ -335,10 +334,121 @@ class BrowserCache_Environment {
|
|
335 |
$rules .= $this->_rules_cache_generate_apache_for_type( $config,
|
336 |
$extensions, $type );
|
337 |
|
338 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
339 |
$lifetime = $config->get_integer( 'browsercache.other.lifetime' );
|
|
|
340 |
$rules .= "<IfModule mod_headers.c>\n";
|
341 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
342 |
$rules .= "</IfModule>\n";
|
343 |
}
|
344 |
|
@@ -562,9 +672,109 @@ class BrowserCache_Environment {
|
|
562 |
$this->_rules_cache_generate_nginx_for_type( $config, $rules,
|
563 |
$extensions, $type );
|
564 |
|
565 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
566 |
$lifetime = $config->get_integer( 'browsercache.other.lifetime' );
|
567 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
568 |
}
|
569 |
|
570 |
$rules .= W3TC_MARKER_END_BROWSERCACHE_CACHE . "\n";
|
@@ -808,6 +1018,18 @@ class BrowserCache_Environment {
|
|
808 |
return $rules;
|
809 |
}
|
810 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
811 |
/**
|
812 |
* Takes an array of extensions single per row and/or extensions delimited by |
|
813 |
*
|
258 |
|
259 |
$rules .= "</IfModule>\n";
|
260 |
|
|
|
261 |
$rules .= "<IfModule mod_expires.c>\n";
|
262 |
$rules .= " ExpiresActive On\n";
|
263 |
|
334 |
$rules .= $this->_rules_cache_generate_apache_for_type( $config,
|
335 |
$extensions, $type );
|
336 |
|
337 |
+
$sec = '';
|
338 |
+
$v = $config->get_string( 'browsercache.security.session.cookie_httponly' );
|
339 |
+
if ( !empty( $v ) ) {
|
340 |
+
$sec .= ' php_flag session.cookie_httponly ' .
|
341 |
+
( $v == 'on' ? 'on' : 'off' ) . "\n";
|
342 |
+
}
|
343 |
+
$v = $config->get_string( 'browsercache.security.session.cookie_secure' );
|
344 |
+
if ( !empty( $v ) ) {
|
345 |
+
$sec .= ' php_flag session.cookie_secure ' .
|
346 |
+
( $v == 'on' ? 'on' : 'off' ) . "\n";
|
347 |
+
}
|
348 |
+
$v = $config->get_string( 'browsercache.security.session.use_only_cookies' );
|
349 |
+
if ( !empty( $v ) ) {
|
350 |
+
$sec .= ' php_flag session.use_only_cookies ' .
|
351 |
+
( $v == 'on' ? 'on' : 'off' ) . "\n";
|
352 |
+
}
|
353 |
+
|
354 |
+
if ( !empty( $sec ) ) {
|
355 |
+
$rules .= "<IfModule mod_php5.c>\n";
|
356 |
+
$rules .= $sec;
|
357 |
+
$rules .= "</IfModule>\n";
|
358 |
+
$rules .= "<IfModule mod_php7.c>\n";
|
359 |
+
$rules .= $sec;
|
360 |
+
$rules .= "</IfModule>\n";
|
361 |
+
$rules .= "<IfModule mod_suphp.c>\n";
|
362 |
+
$rules .= $sec;
|
363 |
+
$rules .= "</IfModule>\n";
|
364 |
+
}
|
365 |
+
|
366 |
+
if ( $config->get_boolean( 'browsercache.hsts' ) ||
|
367 |
+
$config->get_boolean( 'browsercache.security.xfo' ) ||
|
368 |
+
$config->get_boolean( 'browsercache.security.xss' ) ||
|
369 |
+
$config->get_boolean( 'browsercache.security.xcto' ) ||
|
370 |
+
$config->get_boolean( 'browsercache.security.pkp' ) ||
|
371 |
+
$config->get_boolean( 'browsercache.security.referrer.policy' ) ||
|
372 |
+
$config->get_boolean( 'browsercache.security.csp' )
|
373 |
+
) {
|
374 |
$lifetime = $config->get_integer( 'browsercache.other.lifetime' );
|
375 |
+
|
376 |
$rules .= "<IfModule mod_headers.c>\n";
|
377 |
+
|
378 |
+
if ( $config->get_boolean( 'browsercache.hsts' ) ) {
|
379 |
+
$dir = $config->get_string( 'browsercache.security.hsts.directive' );
|
380 |
+
$rules .= " Header set Strict-Transport-Security \"max-age=$lifetime" . ( strpos( $dir,"inc" ) ? "; includeSubDomains" : "" ) . ( strpos( $dir, "pre" ) ? "; preload" : "" ) . "\"\n";
|
381 |
+
}
|
382 |
+
|
383 |
+
if ( $config->get_boolean( 'browsercache.security.xfo' ) ) {
|
384 |
+
$dir = $config->get_string( 'browsercache.security.xfo.directive' );
|
385 |
+
$url = trim( $config->get_string( 'browsercache.security.xfo.allow' ) );
|
386 |
+
if ( empty( $url ) ) {
|
387 |
+
$url = Util_Environment::home_url_maybe_https();
|
388 |
+
}
|
389 |
+
$rules .= " Header always append X-Frame-Options \"" . ( $dir == "same" ? "SAMEORIGIN" : ( $dir == "deny" ? "DENY" : "ALLOW-FROM $url" ) ) . "\"\n";
|
390 |
+
}
|
391 |
+
|
392 |
+
if ( $config->get_boolean( 'browsercache.security.xss' ) ) {
|
393 |
+
$dir = $config->get_string( 'browsercache.security.xss.directive' );
|
394 |
+
$rules .= " Header set X-XSS-Protection \"" . ( $dir == "block" ? "1; mode=block" : $dir ) . "\"\n";
|
395 |
+
|
396 |
+
}
|
397 |
+
|
398 |
+
if ( $config->get_boolean( 'browsercache.security.xcto' ) ) {
|
399 |
+
$rules .= " Header set X-Content-Type-Options \"nosniff\"\n";
|
400 |
+
}
|
401 |
+
|
402 |
+
if ( $config->get_boolean( 'browsercache.security.pkp' ) ) {
|
403 |
+
$pin = trim( $config->get_string( 'browsercache.security.pkp.pin' ) );
|
404 |
+
$pinbak = trim( $config->get_string( 'browsercache.security.pkp.pin.backup' ) );
|
405 |
+
$extra = $config->get_string( 'browsercache.security.pkp.extra' );
|
406 |
+
$url = trim( $config->get_string( 'browsercache.security.pkp.report.url' ) );
|
407 |
+
$rep_only = $config->get_string( 'browsercache.security.pkp.report.only' ) == '1' ? true : false;
|
408 |
+
$rules .= " Header set " . ( $rep_only ? "Public-Key-Pins-Report-Only" : "Public-Key-Pins" ) . " \"pin-sha256=\\\"$pin\\\"; pin-sha256=\\\"$pinbak\\\"; max-age=$lifetime" . ( strpos( $extra,"inc" ) ? "; includeSubDomains" : "" ) . ( !empty( $url ) ? "; report-uri=\\\"$url\\\"" : "" ) . "\"\n";
|
409 |
+
}
|
410 |
+
|
411 |
+
if ( $config->get_boolean( 'browsercache.security.referrer.policy' ) ) {
|
412 |
+
$dir = $config->get_string( 'browsercache.security.referrer.policy.directive' );
|
413 |
+
$rules .= " Header set Referrer-Policy \"" . ($dir == "0" ? "" : $dir ) . "\"\n";
|
414 |
+
}
|
415 |
+
|
416 |
+
if ( $config->get_boolean( 'browsercache.security.csp' ) ) {
|
417 |
+
$base = trim( $config->get_string( 'browsercache.security.csp.base' ) );
|
418 |
+
$frame = trim( $config->get_string( 'browsercache.security.csp.frame' ) );
|
419 |
+
$connect = trim( $config->get_string( 'browsercache.security.csp.connect' ) );
|
420 |
+
$font = trim( $config->get_string( 'browsercache.security.csp.font' ) );
|
421 |
+
$script = trim( $config->get_string( 'browsercache.security.csp.script' ) );
|
422 |
+
$style = trim( $config->get_string( 'browsercache.security.csp.style' ) );
|
423 |
+
$img = trim( $config->get_string( 'browsercache.security.csp.img' ) );
|
424 |
+
$media = trim( $config->get_string( 'browsercache.security.csp.media' ) );
|
425 |
+
$object = trim( $config->get_string( 'browsercache.security.csp.object' ) );
|
426 |
+
$plugin = trim( $config->get_string( 'browsercache.security.csp.plugin' ) );
|
427 |
+
$form = trim( $config->get_string( 'browsercache.security.csp.form' ) );
|
428 |
+
$frame_ancestors = trim( $config->get_string( 'browsercache.security.csp.frame.ancestors' ) );
|
429 |
+
$sandbox = $config->get_string( 'browsercache.security.csp.sandbox' );
|
430 |
+
$default = trim( $config->get_string( 'browsercache.security.csp.default' ) );
|
431 |
+
|
432 |
+
$dir = rtrim( ( !empty( $base ) ? "base-uri $base; " : "" ).
|
433 |
+
( !empty( $frame ) ? "frame-src $frame; " : "" ).
|
434 |
+
( !empty( $connect ) ? "connect-src $connect; " : "" ).
|
435 |
+
( !empty( $font ) ? "font-src $font; " : "" ).
|
436 |
+
( !empty( $script ) ? "script-src $script; " : "" ).
|
437 |
+
( !empty( $style ) ? "style-src $style; " : "" ).
|
438 |
+
( !empty( $img ) ? "img-src $img; " : "" ).
|
439 |
+
( !empty( $media ) ? "media-src $media; " : "" ).
|
440 |
+
( !empty( $object ) ? "object-src $object; " : "" ).
|
441 |
+
( !empty( $plugin ) ? "plugin-types $plugin; " : "" ).
|
442 |
+
( !empty( $form ) ? "form-action $form; " : "" ).
|
443 |
+
( !empty( $frame_ancestors ) ? "frame-ancestors $frame_ancestors; " : "" ).
|
444 |
+
( !empty( $sandbox ) ? "sandbox " . trim( $sandbox ) . "; " : "" ).
|
445 |
+
( !empty( $default ) ? "default-src $default;" : "" ), "; " );
|
446 |
+
|
447 |
+
if ( !empty( $dir ) ) {
|
448 |
+
$rules .= " Header set Content-Security-Policy \"$dir\"\n";
|
449 |
+
}
|
450 |
+
}
|
451 |
+
|
452 |
$rules .= "</IfModule>\n";
|
453 |
}
|
454 |
|
672 |
$this->_rules_cache_generate_nginx_for_type( $config, $rules,
|
673 |
$extensions, $type );
|
674 |
|
675 |
+
$sec = '';
|
676 |
+
$v = $config->get_string( 'browsercache.security.session.cookie_httponly' );
|
677 |
+
if ( !empty( $v ) ) {
|
678 |
+
$sec .= 'session.cookie_httponly=' .
|
679 |
+
( $v == 'on' ? "on" : "off" ) . "\n";
|
680 |
+
}
|
681 |
+
$v = $config->get_string( 'browsercache.security.session.cookie_secure' );
|
682 |
+
if ( !empty( $v ) ) {
|
683 |
+
$sec .= 'session.cookie_secure=' .
|
684 |
+
( $v == 'on' ? "on" : "off" ) . "\n";
|
685 |
+
}
|
686 |
+
$v = $config->get_string( 'browsercache.security.session.use_only_cookies' );
|
687 |
+
if ( !empty( $v ) ) {
|
688 |
+
$sec .= 'session.use_only_cookies=' .
|
689 |
+
( $v == 'on' ? "on" : "off" ) . "\n";
|
690 |
+
}
|
691 |
+
if ( !empty( $sec ) ) {
|
692 |
+
$rules .= "fastcgi_param PHP_FLAG \"$sec\";";
|
693 |
+
}
|
694 |
+
|
695 |
+
if ( $config->get_boolean( 'browsercache.hsts' ) ||
|
696 |
+
$config->get_boolean( 'browsercache.security.xfo' ) ||
|
697 |
+
$config->get_boolean( 'browsercache.security.xss' ) ||
|
698 |
+
$config->get_boolean( 'browsercache.security.xcto' ) ||
|
699 |
+
$config->get_boolean( 'browsercache.security.pkp' ) ||
|
700 |
+
$config->get_boolean( 'browsercache.security.referrer.policy' ) ||
|
701 |
+
$config->get_boolean( 'browsercache.security.csp' )
|
702 |
+
) {
|
703 |
$lifetime = $config->get_integer( 'browsercache.other.lifetime' );
|
704 |
+
|
705 |
+
if ( $config->get_boolean( 'browsercache.hsts' ) ) {
|
706 |
+
$dir = $config->get_string( 'browsercache.security.hsts.directive' );
|
707 |
+
$rules .= "add_header Strict-Transport-Security \"max-age=$lifetime" . ( strpos( $dir,"inc" ) ? "; includeSubDomains" : "" ) . ( strpos( $dir, "pre" ) ? "; preload" : "" ) . "\";\n";
|
708 |
+
}
|
709 |
+
|
710 |
+
if ( $config->get_boolean( 'browsercache.security.xfo' ) ) {
|
711 |
+
$dir = $config->get_string( 'browsercache.security.xfo.directive' );
|
712 |
+
$url = trim( $config->get_string( 'browsercache.security.xfo.allow' ) );
|
713 |
+
if ( empty( $url ) ) {
|
714 |
+
$url = Util_Environment::home_url_maybe_https();
|
715 |
+
}
|
716 |
+
$rules .= "add_header X-Frame-Options \"" . ( $dir == "same" ? "SAMEORIGIN" : ( $dir == "deny" ? "DENY" : "ALLOW-FROM $url" ) ) . "\";\n";
|
717 |
+
}
|
718 |
+
|
719 |
+
if ( $config->get_boolean( 'browsercache.security.xss' ) ) {
|
720 |
+
$dir = $config->get_string( 'browsercache.security.xss.directive' );
|
721 |
+
$rules .= "add_header X-XSS-Protection \"" . ( $dir == "block" ? "1; mode=block" : $dir ) . "\";\n";
|
722 |
+
|
723 |
+
}
|
724 |
+
|
725 |
+
if ( $config->get_boolean( 'browsercache.security.xcto' ) ) {
|
726 |
+
$rules .= "add_header X-Content-Type-Options \"nosniff\";\n";
|
727 |
+
}
|
728 |
+
|
729 |
+
if ( $config->get_boolean( 'browsercache.security.pkp' ) ) {
|
730 |
+
$pin = trim( $config->get_string( 'browsercache.security.pkp.pin' ) );
|
731 |
+
$pinbak = trim( $config->get_string( 'browsercache.security.pkp.pin.backup' ) );
|
732 |
+
$extra = $config->get_string( 'browsercache.security.pkp.extra' );
|
733 |
+
$url = trim( $config->get_string( 'browsercache.security.pkp.report.url' ) );
|
734 |
+
$rep_only = $config->get_string( 'browsercache.security.pkp.report.only' ) == '1' ? true : false;
|
735 |
+
$rules .= "add_header " . ( $rep_only ? "Public-Key-Pins-Report-Only" : "Public-Key-Pins" ) . " 'pin-sha256=\"$pin\"; pin-sha256=\"$pinbak\"; max-age=$lifetime" . ( strpos( $extra,"inc" ) ? "; includeSubDomains" : "" ) . ( !empty( $url ) ? "; report-uri=\"$url\"" : "" ) . "';\n";
|
736 |
+
}
|
737 |
+
|
738 |
+
if ( $config->get_boolean( 'browsercache.security.referrer.policy' ) ) {
|
739 |
+
$dir = $config->get_string( 'browsercache.security.referrer.policy.directive' );
|
740 |
+
$rules .= "add_header Referrer-Policy \"" . ( $dir == "0" ? "" : $dir ) . "\";\n";
|
741 |
+
}
|
742 |
+
|
743 |
+
if ( $config->get_boolean( 'browsercache.security.csp' ) ) {
|
744 |
+
$base = trim( $config->get_string( 'browsercache.security.csp.base' ) );
|
745 |
+
$frame = trim( $config->get_string( 'browsercache.security.csp.frame' ) );
|
746 |
+
$connect = trim( $config->get_string( 'browsercache.security.csp.connect' ) );
|
747 |
+
$font = trim( $config->get_string( 'browsercache.security.csp.font' ) );
|
748 |
+
$script = trim( $config->get_string( 'browsercache.security.csp.script' ) );
|
749 |
+
$style = trim( $config->get_string( 'browsercache.security.csp.style' ) );
|
750 |
+
$img = trim( $config->get_string( 'browsercache.security.csp.img' ) );
|
751 |
+
$media = trim( $config->get_string( 'browsercache.security.csp.media' ) );
|
752 |
+
$object = trim( $config->get_string( 'browsercache.security.csp.object' ) );
|
753 |
+
$plugin = trim( $config->get_string( 'browsercache.security.csp.plugin' ) );
|
754 |
+
$form = trim( $config->get_string( 'browsercache.security.csp.form' ) );
|
755 |
+
$frame_ancestors = trim( $config->get_string( 'browsercache.security.csp.frame.ancestors' ) );
|
756 |
+
$sandbox = $config->get_string( 'browsercache.security.csp.sandbox' );
|
757 |
+
$default = trim( $config->get_string( 'browsercache.security.csp.default' ) );
|
758 |
+
|
759 |
+
$dir = rtrim( ( !empty( $base ) ? "base-uri $base; " : "" ).
|
760 |
+
( !empty( $frame ) ? "frame-src $frame; " : "" ).
|
761 |
+
( !empty( $connect ) ? "connect-src $connect; " : "" ).
|
762 |
+
( !empty( $font ) ? "font-src $font; " : "" ).
|
763 |
+
( !empty( $script ) ? "script-src $script; " : "" ).
|
764 |
+
( !empty( $style ) ? "style-src $style; " : "" ).
|
765 |
+
( !empty( $img ) ? "img-src $img; " : "" ).
|
766 |
+
( !empty( $media ) ? "media-src $media; " : "" ).
|
767 |
+
( !empty( $object ) ? "object-src $object; " : "" ).
|
768 |
+
( !empty( $plugin ) ? "plugin-types $plugin; " : "" ).
|
769 |
+
( !empty( $form ) ? "form-action $form; " : "" ).
|
770 |
+
( !empty( $frame_ancestors ) ? "frame-ancestors $frame_ancestors; " : "" ).
|
771 |
+
( !empty( $sandbox ) ? "sandbox " . trim( $sandbox ) . "; " : "" ).
|
772 |
+
( !empty( $default ) ? "default-src $default;" : "" ), "; " );
|
773 |
+
|
774 |
+
if ( !empty( $dir ) ) {
|
775 |
+
$rules .= "add_header Content-Security-Policy \"$dir\";\n";
|
776 |
+
}
|
777 |
+
}
|
778 |
}
|
779 |
|
780 |
$rules .= W3TC_MARKER_END_BROWSERCACHE_CACHE . "\n";
|
1018 |
return $rules;
|
1019 |
}
|
1020 |
|
1021 |
+
/**
|
1022 |
+
* Returns the apache, nginx version
|
1023 |
+
*
|
1024 |
+
* @return string
|
1025 |
+
*/
|
1026 |
+
private function _get_server_version() {
|
1027 |
+
$sig= explode( '/', $_SERVER['SERVER_SOFTWARE'] );
|
1028 |
+
$temp = isset( $sig[1] ) ? explode( ' ', $sig[1] ) : array( '0' );
|
1029 |
+
$version = $temp[0];
|
1030 |
+
return $version;
|
1031 |
+
}
|
1032 |
+
|
1033 |
/**
|
1034 |
* Takes an array of extensions single per row and/or extensions delimited by |
|
1035 |
*
|
CacheFlush.php
CHANGED
@@ -159,6 +159,17 @@ class CacheFlush {
|
|
159 |
}
|
160 |
}
|
161 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
/**
|
163 |
* Purges/Flushes url
|
164 |
*/
|
159 |
}
|
160 |
}
|
161 |
|
162 |
+
/**
|
163 |
+
* Purges/Flushes cache group
|
164 |
+
*/
|
165 |
+
function flush_group( $group, $extras = null ) {
|
166 |
+
static $flushed_groups = array();
|
167 |
+
if ( !isset( $flushed_groups[$group] ) ) {
|
168 |
+
$flushed_groups[$group] = '*';
|
169 |
+
$this->_executor->flush_group( $group, $extras );
|
170 |
+
}
|
171 |
+
}
|
172 |
+
|
173 |
/**
|
174 |
* Purges/Flushes url
|
175 |
*/
|
CacheFlush_Locally.php
CHANGED
@@ -26,7 +26,7 @@ class CacheFlush_Locally {
|
|
26 |
if ( !method_exists( $GLOBALS['wpdb'], 'flush_cache' ) )
|
27 |
return false;
|
28 |
|
29 |
-
return $GLOBALS['wpdb']->flush_cache();
|
30 |
}
|
31 |
|
32 |
/**
|
@@ -81,7 +81,7 @@ class CacheFlush_Locally {
|
|
81 |
}
|
82 |
|
83 |
function minifycache_flush_all( $extras = array() ) {
|
84 |
-
if ( $extras['minify'] == 'purge_map' )
|
85 |
delete_option( 'w3tc_minify' );
|
86 |
|
87 |
$this->minifycache_flush( $extras );
|
@@ -125,7 +125,7 @@ class CacheFlush_Locally {
|
|
125 |
do_action( 'w3tc_cdn_purge_files', $purgefiles );
|
126 |
$common = Dispatcher::component( 'Cdn_Core' );
|
127 |
$results = array();
|
128 |
-
$v = $common->purge( $purgefiles,
|
129 |
do_action( 'w3tc_cdn_purge_files_after', $purgefiles );
|
130 |
|
131 |
return $v;
|
@@ -189,7 +189,7 @@ class CacheFlush_Locally {
|
|
189 |
if ( $config->get_boolean( 'dbcache.enabled' ) )
|
190 |
add_action( 'w3tc_flush_all',
|
191 |
array( $this, 'dbcache_flush' ),
|
192 |
-
100,
|
193 |
if ( $config->get_boolean( 'objectcache.enabled' ) )
|
194 |
add_action( 'w3tc_flush_all',
|
195 |
array( $this, 'objectcache_flush' ),
|
@@ -207,6 +207,12 @@ class CacheFlush_Locally {
|
|
207 |
do_action( 'w3tc_flush_all', $extras );
|
208 |
}
|
209 |
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
/**
|
211 |
* Purges/Flushes url from page cache, varnish and cdn cache
|
212 |
*/
|
26 |
if ( !method_exists( $GLOBALS['wpdb'], 'flush_cache' ) )
|
27 |
return false;
|
28 |
|
29 |
+
return $GLOBALS['wpdb']->flush_cache( $extras );
|
30 |
}
|
31 |
|
32 |
/**
|
81 |
}
|
82 |
|
83 |
function minifycache_flush_all( $extras = array() ) {
|
84 |
+
if ( isset( $extras['minify'] ) && $extras['minify'] == 'purge_map' )
|
85 |
delete_option( 'w3tc_minify' );
|
86 |
|
87 |
$this->minifycache_flush( $extras );
|
125 |
do_action( 'w3tc_cdn_purge_files', $purgefiles );
|
126 |
$common = Dispatcher::component( 'Cdn_Core' );
|
127 |
$results = array();
|
128 |
+
$v = $common->purge( $purgefiles, $results );
|
129 |
do_action( 'w3tc_cdn_purge_files_after', $purgefiles );
|
130 |
|
131 |
return $v;
|
189 |
if ( $config->get_boolean( 'dbcache.enabled' ) )
|
190 |
add_action( 'w3tc_flush_all',
|
191 |
array( $this, 'dbcache_flush' ),
|
192 |
+
100, 2 );
|
193 |
if ( $config->get_boolean( 'objectcache.enabled' ) )
|
194 |
add_action( 'w3tc_flush_all',
|
195 |
array( $this, 'objectcache_flush' ),
|
207 |
do_action( 'w3tc_flush_all', $extras );
|
208 |
}
|
209 |
|
210 |
+
function flush_group( $group, $extras ) {
|
211 |
+
$do_flush = apply_filters( 'w3tc_preflush_group', true, $group, $extras );
|
212 |
+
if ( $do_flush )
|
213 |
+
do_action( 'w3tc_flush_group', $group, $extras );
|
214 |
+
}
|
215 |
+
|
216 |
/**
|
217 |
* Purges/Flushes url from page cache, varnish and cdn cache
|
218 |
*/
|
Cache_Apc.php
CHANGED
@@ -135,7 +135,7 @@ class Cache_Apc extends Cache_Base {
|
|
135 |
* @param unknown $key
|
136 |
* @return bool
|
137 |
*/
|
138 |
-
function hard_delete( $key ) {
|
139 |
$storage_key = $this->get_item_key( $key );
|
140 |
return apc_delete( $storage_key );
|
141 |
}
|
135 |
* @param unknown $key
|
136 |
* @return bool
|
137 |
*/
|
138 |
+
function hard_delete( $key, $group = '' ) {
|
139 |
$storage_key = $this->get_item_key( $key );
|
140 |
return apc_delete( $storage_key );
|
141 |
}
|
Cache_Apcu.php
CHANGED
@@ -134,7 +134,7 @@ class Cache_Apcu extends Cache_Base {
|
|
134 |
* @param unknown $key
|
135 |
* @return bool
|
136 |
*/
|
137 |
-
function hard_delete( $key ) {
|
138 |
$storage_key = $this->get_item_key( $key );
|
139 |
return apcu_delete( $storage_key );
|
140 |
}
|
134 |
* @param unknown $key
|
135 |
* @return bool
|
136 |
*/
|
137 |
+
function hard_delete( $key, $group = '' ) {
|
138 |
$storage_key = $this->get_item_key( $key );
|
139 |
return apcu_delete( $storage_key );
|
140 |
}
|
Cache_Base.php
CHANGED
@@ -153,7 +153,7 @@ class Cache_Base {
|
|
153 |
* @param string $key
|
154 |
* @return boolean
|
155 |
*/
|
156 |
-
function hard_delete( $key ) {
|
157 |
return false;
|
158 |
}
|
159 |
|
153 |
* @param string $key
|
154 |
* @return boolean
|
155 |
*/
|
156 |
+
function hard_delete( $key, $group = '' ) {
|
157 |
return false;
|
158 |
}
|
159 |
|
Cache_Eaccelerator.php
CHANGED
@@ -135,7 +135,7 @@ class Cache_Eaccelerator extends Cache_Base {
|
|
135 |
* @param unknown $key
|
136 |
* @return bool
|
137 |
*/
|
138 |
-
function hard_delete( $key ) {
|
139 |
$storage_key = $this->get_item_key( $key );
|
140 |
return eaccelerator_rm( $storage_key );
|
141 |
}
|
135 |
* @param unknown $key
|
136 |
* @return bool
|
137 |
*/
|
138 |
+
function hard_delete( $key, $group = '' ) {
|
139 |
$storage_key = $this->get_item_key( $key );
|
140 |
return eaccelerator_rm( $storage_key );
|
141 |
}
|
Cache_File.php
CHANGED
@@ -151,7 +151,7 @@ class Cache_File extends Cache_Base {
|
|
151 |
|
152 |
$path = $this->_cache_dir . DIRECTORY_SEPARATOR .
|
153 |
( $group ? $group . DIRECTORY_SEPARATOR : '' ) .
|
154 |
-
$this->_get_path( $storage_key );
|
155 |
if ( !is_readable( $path ) )
|
156 |
return array( null, $has_old_data );
|
157 |
|
@@ -227,7 +227,7 @@ class Cache_File extends Cache_Base {
|
|
227 |
|
228 |
$path = $this->_cache_dir . DIRECTORY_SEPARATOR .
|
229 |
( $group ? $group . DIRECTORY_SEPARATOR : '' ) .
|
230 |
-
$this->_get_path( $storage_key );
|
231 |
|
232 |
if ( !file_exists( $path ) )
|
233 |
return true;
|
@@ -259,9 +259,9 @@ class Cache_File extends Cache_Base {
|
|
259 |
*
|
260 |
* @return bool
|
261 |
*/
|
262 |
-
function hard_delete( $key ) {
|
263 |
$key = $this->get_item_key( $key );
|
264 |
-
$path = $this->_cache_dir . DIRECTORY_SEPARATOR . $this->_get_path( $key );
|
265 |
return @unlink( $path );
|
266 |
}
|
267 |
|
@@ -292,7 +292,7 @@ class Cache_File extends Cache_Base {
|
|
292 |
$path =
|
293 |
$this->_cache_dir . DIRECTORY_SEPARATOR .
|
294 |
( $group ? $group . DIRECTORY_SEPARATOR : '' ) .
|
295 |
-
$this->_get_path( $key );
|
296 |
|
297 |
if ( file_exists( $path ) ) {
|
298 |
return @filemtime( $path );
|
@@ -307,7 +307,7 @@ class Cache_File extends Cache_Base {
|
|
307 |
* @param string $key
|
308 |
* @return string
|
309 |
*/
|
310 |
-
function _get_path( $key ) {
|
311 |
if ( $this->_use_wp_hash && function_exists( 'wp_hash' ) )
|
312 |
$hash = wp_hash( $key );
|
313 |
else
|
@@ -438,7 +438,7 @@ class Cache_File extends Cache_Base {
|
|
438 |
private function fopen_write( $key, $group, $mode ) {
|
439 |
$storage_key = $this->get_item_key( $key );
|
440 |
|
441 |
-
$sub_path = $this->_get_path( $storage_key );
|
442 |
$path = $this->_cache_dir . DIRECTORY_SEPARATOR .
|
443 |
( $group ? $group . DIRECTORY_SEPARATOR : '' ) . $sub_path;
|
444 |
|
151 |
|
152 |
$path = $this->_cache_dir . DIRECTORY_SEPARATOR .
|
153 |
( $group ? $group . DIRECTORY_SEPARATOR : '' ) .
|
154 |
+
$this->_get_path( $storage_key, $group );
|
155 |
if ( !is_readable( $path ) )
|
156 |
return array( null, $has_old_data );
|
157 |
|
227 |
|
228 |
$path = $this->_cache_dir . DIRECTORY_SEPARATOR .
|
229 |
( $group ? $group . DIRECTORY_SEPARATOR : '' ) .
|
230 |
+
$this->_get_path( $storage_key, $group );
|
231 |
|
232 |
if ( !file_exists( $path ) )
|
233 |
return true;
|
259 |
*
|
260 |
* @return bool
|
261 |
*/
|
262 |
+
function hard_delete( $key, $group = '' ) {
|
263 |
$key = $this->get_item_key( $key );
|
264 |
+
$path = $this->_cache_dir . DIRECTORY_SEPARATOR . $this->_get_path( $key, $group );
|
265 |
return @unlink( $path );
|
266 |
}
|
267 |
|
292 |
$path =
|
293 |
$this->_cache_dir . DIRECTORY_SEPARATOR .
|
294 |
( $group ? $group . DIRECTORY_SEPARATOR : '' ) .
|
295 |
+
$this->_get_path( $key, $group );
|
296 |
|
297 |
if ( file_exists( $path ) ) {
|
298 |
return @filemtime( $path );
|
307 |
* @param string $key
|
308 |
* @return string
|
309 |
*/
|
310 |
+
function _get_path( $key, $group = '' ) {
|
311 |
if ( $this->_use_wp_hash && function_exists( 'wp_hash' ) )
|
312 |
$hash = wp_hash( $key );
|
313 |
else
|
438 |
private function fopen_write( $key, $group, $mode ) {
|
439 |
$storage_key = $this->get_item_key( $key );
|
440 |
|
441 |
+
$sub_path = $this->_get_path( $storage_key, $group );
|
442 |
$path = $this->_cache_dir . DIRECTORY_SEPARATOR .
|
443 |
( $group ? $group . DIRECTORY_SEPARATOR : '' ) . $sub_path;
|
444 |
|
Cache_File_Cleaner_Generic.php
CHANGED
@@ -18,6 +18,8 @@ class Cache_File_Cleaner_Generic extends Cache_File_Cleaner {
|
|
18 |
*/
|
19 |
var $_expire = 0;
|
20 |
|
|
|
|
|
21 |
/**
|
22 |
* PHP5-style constructor
|
23 |
*
|
@@ -47,7 +49,8 @@ class Cache_File_Cleaner_Generic extends Cache_File_Cleaner {
|
|
47 |
|
48 |
$full_path = $path . DIRECTORY_SEPARATOR . $entry;
|
49 |
|
50 |
-
if ( substr( $entry, -4 ) === '_old' &&
|
|
|
51 |
continue;
|
52 |
}
|
53 |
|
@@ -60,18 +63,8 @@ class Cache_File_Cleaner_Generic extends Cache_File_Cleaner {
|
|
60 |
|
61 |
if ( @is_dir( $full_path ) ) {
|
62 |
$this->_clean( $full_path );
|
63 |
-
}
|
64 |
-
$this->
|
65 |
-
@unlink( $full_path );
|
66 |
-
} elseif ( !$this->is_valid( $full_path ) ) {
|
67 |
-
$old_entry_path = $full_path . '_old';
|
68 |
-
$this->processed_count++;
|
69 |
-
if ( !@rename( $full_path, $old_entry_path ) ) {
|
70 |
-
// if we can delete old entry - do second attempt to store in old-entry file
|
71 |
-
if ( @unlink( $old_entry_path ) ) {
|
72 |
-
@rename( $full_path, $old_entry_path );
|
73 |
-
}
|
74 |
-
}
|
75 |
}
|
76 |
}
|
77 |
|
@@ -81,6 +74,26 @@ class Cache_File_Cleaner_Generic extends Cache_File_Cleaner {
|
|
81 |
}
|
82 |
}
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
/**
|
85 |
* Checks if file is valid
|
86 |
*
|
18 |
*/
|
19 |
var $_expire = 0;
|
20 |
|
21 |
+
private $hard_delete = false;
|
22 |
+
|
23 |
/**
|
24 |
* PHP5-style constructor
|
25 |
*
|
49 |
|
50 |
$full_path = $path . DIRECTORY_SEPARATOR . $entry;
|
51 |
|
52 |
+
if ( substr( $entry, -4 ) === '_old' &&
|
53 |
+
!$this->is_old_file_expired( $full_path ) ) {
|
54 |
continue;
|
55 |
}
|
56 |
|
63 |
|
64 |
if ( @is_dir( $full_path ) ) {
|
65 |
$this->_clean( $full_path );
|
66 |
+
} else {
|
67 |
+
$this->_clean_file( $entry, $full_path );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
}
|
69 |
}
|
70 |
|
74 |
}
|
75 |
}
|
76 |
|
77 |
+
function _clean_file( $entry, $full_path ) {
|
78 |
+
if ( substr( $entry, -4 ) === '_old' ) {
|
79 |
+
$this->processed_count++;
|
80 |
+
@unlink( $full_path );
|
81 |
+
} elseif ( !$this->is_valid( $full_path ) ) {
|
82 |
+
$old_entry_path = $full_path . '_old';
|
83 |
+
$this->processed_count++;
|
84 |
+
if ( !@rename( $full_path, $old_entry_path ) ) {
|
85 |
+
// if we can delete old entry -
|
86 |
+
// do second attempt to store in old-entry file
|
87 |
+
if ( @unlink( $old_entry_path ) ) {
|
88 |
+
if ( !@rename( $full_path, $old_entry_path ) ) {
|
89 |
+
// last attempt - just remove entry
|
90 |
+
@unlink( $full_path );
|
91 |
+
}
|
92 |
+
}
|
93 |
+
}
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
/**
|
98 |
* Checks if file is valid
|
99 |
*
|
Cache_File_Cleaner_Generic_HardDelete.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace W3TC;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Disk-enhanced file cache cleaner
|
6 |
+
*/
|
7 |
+
class Cache_File_Cleaner_Generic_HardDelete extends Cache_File_Cleaner_Generic {
|
8 |
+
function __construct( $config = array() ) {
|
9 |
+
parent::__construct( $config );
|
10 |
+
}
|
11 |
+
|
12 |
+
function _clean_file( $entry, $full_path ) {
|
13 |
+
if ( substr( $entry, -4 ) === '_old' ) {
|
14 |
+
$this->processed_count++;
|
15 |
+
@unlink( $full_path );
|
16 |
+
} elseif ( !$this->is_valid( $full_path ) ) {
|
17 |
+
@unlink( $full_path );
|
18 |
+
}
|
19 |
+
}
|
20 |
+
}
|
Cache_File_Generic.php
CHANGED
@@ -38,8 +38,8 @@ class Cache_File_Generic extends Cache_File {
|
|
38 |
*/
|
39 |
function set( $key, $var, $expire = 0, $group = '' ) {
|
40 |
$key = $this->get_item_key( $key );
|
41 |
-
$sub_path = $this->_get_path( $key );
|
42 |
-
$path = $this->_cache_dir .
|
43 |
|
44 |
$dir = dirname( $path );
|
45 |
|
@@ -112,7 +112,8 @@ class Cache_File_Generic extends Cache_File {
|
|
112 |
}
|
113 |
|
114 |
if ( !empty($rules) ) {
|
115 |
-
@file_put_contents( dirname( $path ) .
|
|
|
116 |
}
|
117 |
}
|
118 |
|
@@ -129,7 +130,8 @@ class Cache_File_Generic extends Cache_File {
|
|
129 |
function get_with_old( $key, $group = '' ) {
|
130 |
$has_old_data = false;
|
131 |
$key = $this->get_item_key( $key );
|
132 |
-
$path = $this->_cache_dir .
|
|
|
133 |
|
134 |
$data = $this->_read( $path );
|
135 |
if ( $data != null )
|
@@ -202,7 +204,7 @@ class Cache_File_Generic extends Cache_File {
|
|
202 |
*/
|
203 |
function delete( $key, $group = '' ) {
|
204 |
$key = $this->get_item_key( $key );
|
205 |
-
$path = $this->_cache_dir . DIRECTORY_SEPARATOR . $this->_get_path( $key );
|
206 |
|
207 |
if ( !file_exists( $path ) )
|
208 |
return true;
|
@@ -225,9 +227,9 @@ class Cache_File_Generic extends Cache_File {
|
|
225 |
* @param unknown $key
|
226 |
* @return bool
|
227 |
*/
|
228 |
-
function hard_delete( $key ) {
|
229 |
$key = $this->get_item_key( $key );
|
230 |
-
$path = $this->_cache_dir . DIRECTORY_SEPARATOR . $this->_get_path( $key );
|
231 |
$old_entry_path = $path . '_old';
|
232 |
@unlink( $old_entry_path );
|
233 |
|
@@ -249,11 +251,21 @@ class Cache_File_Generic extends Cache_File {
|
|
249 |
$sitemap_regex = $config->get_string( 'pgcache.purge.sitemap_regex' );
|
250 |
$this->_flush_based_on_regex( $sitemap_regex );
|
251 |
} else {
|
252 |
-
$
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
|
258 |
$c->clean();
|
259 |
}
|
@@ -265,8 +277,8 @@ class Cache_File_Generic extends Cache_File {
|
|
265 |
* @param string $key
|
266 |
* @return string
|
267 |
*/
|
268 |
-
function _get_path( $key ) {
|
269 |
-
return $key;
|
270 |
}
|
271 |
|
272 |
function get_item_key( $key ) {
|
@@ -285,9 +297,11 @@ class Cache_File_Generic extends Cache_File {
|
|
285 |
$parsed = parse_url( $domain );
|
286 |
$host = $parsed['host'];
|
287 |
$path = isset( $parsed['path'] ) ? '/' . trim( $parsed['path'], '/' ) : '';
|
288 |
-
$flush_dir = W3TC_CACHE_PAGE_ENHANCED_DIR .
|
|
|
289 |
} else
|
290 |
-
$flush_dir = W3TC_CACHE_PAGE_ENHANCED_DIR .
|
|
|
291 |
|
292 |
$dir = @opendir( $flush_dir );
|
293 |
if ( $dir ) {
|
38 |
*/
|
39 |
function set( $key, $var, $expire = 0, $group = '' ) {
|
40 |
$key = $this->get_item_key( $key );
|
41 |
+
$sub_path = $this->_get_path( $key, $group );
|
42 |
+
$path = $this->_cache_dir . DIRECTORY_SEPARATOR . $sub_path;
|
43 |
|
44 |
$dir = dirname( $path );
|
45 |
|
112 |
}
|
113 |
|
114 |
if ( !empty($rules) ) {
|
115 |
+
@file_put_contents( dirname( $path ) .
|
116 |
+
DIRECTORY_SEPARATOR . '.htaccess', $rules );
|
117 |
}
|
118 |
}
|
119 |
|
130 |
function get_with_old( $key, $group = '' ) {
|
131 |
$has_old_data = false;
|
132 |
$key = $this->get_item_key( $key );
|
133 |
+
$path = $this->_cache_dir . DIRECTORY_SEPARATOR .
|
134 |
+
$this->_get_path( $key, $group );
|
135 |
|
136 |
$data = $this->_read( $path );
|
137 |
if ( $data != null )
|
204 |
*/
|
205 |
function delete( $key, $group = '' ) {
|
206 |
$key = $this->get_item_key( $key );
|
207 |
+
$path = $this->_cache_dir . DIRECTORY_SEPARATOR . $this->_get_path( $key, $group );
|
208 |
|
209 |
if ( !file_exists( $path ) )
|
210 |
return true;
|
227 |
* @param unknown $key
|
228 |
* @return bool
|
229 |
*/
|
230 |
+
function hard_delete( $key, $group = '' ) {
|
231 |
$key = $this->get_item_key( $key );
|
232 |
+
$path = $this->_cache_dir . DIRECTORY_SEPARATOR . $this->_get_path( $key, $group );
|
233 |
$old_entry_path = $path . '_old';
|
234 |
@unlink( $old_entry_path );
|
235 |
|
251 |
$sitemap_regex = $config->get_string( 'pgcache.purge.sitemap_regex' );
|
252 |
$this->_flush_based_on_regex( $sitemap_regex );
|
253 |
} else {
|
254 |
+
$dir = $this->_flush_dir;
|
255 |
+
if ( !empty( $group ) ) {
|
256 |
+
$c = new Cache_File_Cleaner_Generic_HardDelete( array(
|
257 |
+
'cache_dir' => $this->_flush_dir .
|
258 |
+
DIRECTORY_SEPARATOR . $group,
|
259 |
+
'exclude' => $this->_exclude,
|
260 |
+
'clean_timelimit' => $this->_flush_timelimit
|
261 |
+
) );
|
262 |
+
} else {
|
263 |
+
$c = new Cache_File_Cleaner_Generic( array(
|
264 |
+
'cache_dir' => $this->_flush_dir,
|
265 |
+
'exclude' => $this->_exclude,
|
266 |
+
'clean_timelimit' => $this->_flush_timelimit
|
267 |
+
) );
|
268 |
+
}
|
269 |
|
270 |
$c->clean();
|
271 |
}
|
277 |
* @param string $key
|
278 |
* @return string
|
279 |
*/
|
280 |
+
function _get_path( $key, $group = '' ) {
|
281 |
+
return ( empty( $group ) ? '' : $group . DIRECTORY_SEPARATOR ) . $key;
|
282 |
}
|
283 |
|
284 |
function get_item_key( $key ) {
|
297 |
$parsed = parse_url( $domain );
|
298 |
$host = $parsed['host'];
|
299 |
$path = isset( $parsed['path'] ) ? '/' . trim( $parsed['path'], '/' ) : '';
|
300 |
+
$flush_dir = W3TC_CACHE_PAGE_ENHANCED_DIR .
|
301 |
+
DIRECTORY_SEPARATOR . $host . $path;
|
302 |
} else
|
303 |
+
$flush_dir = W3TC_CACHE_PAGE_ENHANCED_DIR .
|
304 |
+
DIRECTORY_SEPARATOR . Util_Environment::host();
|
305 |
|
306 |
$dir = @opendir( $flush_dir );
|
307 |
if ( $dir ) {
|
Cache_Memcache.php
CHANGED
@@ -168,7 +168,7 @@ class Cache_Memcache extends Cache_Base {
|
|
168 |
* @param unknown $key
|
169 |
* @return bool
|
170 |
*/
|
171 |
-
function hard_delete( $key ) {
|
172 |
$storage_key = $this->get_item_key( $key );
|
173 |
return @$this->_memcache->delete( $storage_key, 0 );
|
174 |
}
|
@@ -223,6 +223,8 @@ class Cache_Memcache extends Cache_Base {
|
|
223 |
* @return boolean
|
224 |
*/
|
225 |
private function _set_key_version( $v, $group = '' ) {
|
|
|
|
|
226 |
@$this->_memcache->set( $this->_get_key_version_key( $group ), $v, false, 0 );
|
227 |
}
|
228 |
|
168 |
* @param unknown $key
|
169 |
* @return bool
|
170 |
*/
|
171 |
+
function hard_delete( $key, $group = '' ) {
|
172 |
$storage_key = $this->get_item_key( $key );
|
173 |
return @$this->_memcache->delete( $storage_key, 0 );
|
174 |
}
|
223 |
* @return boolean
|
224 |
*/
|
225 |
private function _set_key_version( $v, $group = '' ) {
|
226 |
+
// expiration has to be as long as possible since
|
227 |
+
// all cache data expires when key version expires
|
228 |
@$this->_memcache->set( $this->_get_key_version_key( $group ), $v, false, 0 );
|
229 |
}
|
230 |
|
Cache_Memcached.php
CHANGED
@@ -206,7 +206,7 @@ class Cache_Memcached extends Cache_Base {
|
|
206 |
* @param unknown $key
|
207 |
* @return bool
|
208 |
*/
|
209 |
-
function hard_delete( $key ) {
|
210 |
$storage_key = $this->get_item_key( $key );
|
211 |
return @$this->_memcache->delete( $storage_key );
|
212 |
}
|
@@ -278,6 +278,8 @@ class Cache_Memcached extends Cache_Base {
|
|
278 |
* @return boolean
|
279 |
*/
|
280 |
private function _set_key_version( $v, $group = '' ) {
|
|
|
|
|
281 |
@$this->_memcache->set( $this->_get_key_version_key( $group ), $v, 0 );
|
282 |
}
|
283 |
|
206 |
* @param unknown $key
|
207 |
* @return bool
|
208 |
*/
|
209 |
+
function hard_delete( $key, $group = '' ) {
|
210 |
$storage_key = $this->get_item_key( $key );
|
211 |
return @$this->_memcache->delete( $storage_key );
|
212 |
}
|
278 |
* @return boolean
|
279 |
*/
|
280 |
private function _set_key_version( $v, $group = '' ) {
|
281 |
+
// expiration has to be as long as possible since
|
282 |
+
// all cache data expires when key version expires
|
283 |
@$this->_memcache->set( $this->_get_key_version_key( $group ), $v, 0 );
|
284 |
}
|
285 |
|
Cache_Redis.php
CHANGED
@@ -161,7 +161,7 @@ class Cache_Redis extends Cache_Base {
|
|
161 |
* @param unknown $key
|
162 |
* @return bool
|
163 |
*/
|
164 |
-
function hard_delete( $key ) {
|
165 |
$storage_key = $this->get_item_key( $key );
|
166 |
$accessor = $this->_get_accessor( $storage_key );
|
167 |
if ( is_null( $accessor ) )
|
161 |
* @param unknown $key
|
162 |
* @return bool
|
163 |
*/
|
164 |
+
function hard_delete( $key, $group = '' ) {
|
165 |
$storage_key = $this->get_item_key( $key );
|
166 |
$accessor = $this->_get_accessor( $storage_key );
|
167 |
if ( is_null( $accessor ) )
|
Cache_Wincache.php
CHANGED
@@ -131,7 +131,7 @@ class Cache_Wincache extends Cache_Base {
|
|
131 |
* @param unknown $key
|
132 |
* @return bool
|
133 |
*/
|
134 |
-
function hard_delete( $key ) {
|
135 |
$storage_key = $this->get_item_key( $key );
|
136 |
return wincache_ucache_delete( $storage_key );
|
137 |
}
|
131 |
* @param unknown $key
|
132 |
* @return bool
|
133 |
*/
|
134 |
+
function hard_delete( $key, $group = '' ) {
|
135 |
$storage_key = $this->get_item_key( $key );
|
136 |
return wincache_ucache_delete( $storage_key );
|
137 |
}
|
Cache_Xcache.php
CHANGED
@@ -135,7 +135,7 @@ class Cache_Xcache extends Cache_Base {
|
|
135 |
* @param unknown $key
|
136 |
* @return bool
|
137 |
*/
|
138 |
-
function hard_delete( $key ) {
|
139 |
$storage_key = $this->get_item_key( $key );
|
140 |
return xcache_unset( $storage_key );
|
141 |
}
|
135 |
* @param unknown $key
|
136 |
* @return bool
|
137 |
*/
|
138 |
+
function hard_delete( $key, $group = '' ) {
|
139 |
$storage_key = $this->get_item_key( $key );
|
140 |
return xcache_unset( $storage_key );
|
141 |
}
|
CdnEngine.php
CHANGED
@@ -59,6 +59,10 @@ class CdnEngine {
|
|
59 |
$instances[$instance_key] = new CdnEngine_Mirror_Highwinds( $config );
|
60 |
break;
|
61 |
|
|
|
|
|
|
|
|
|
62 |
case 'maxcdn':
|
63 |
$instances[$instance_key] = new CdnEngine_Mirror_MaxCdn( $config );
|
64 |
break;
|
@@ -84,6 +88,10 @@ class CdnEngine {
|
|
84 |
$instances[$instance_key] = new CdnEngine_S3_Compatible( $config );
|
85 |
break;
|
86 |
|
|
|
|
|
|
|
|
|
87 |
default :
|
88 |
trigger_error( 'Incorrect CDN engine', E_USER_WARNING );
|
89 |
$instances[$instance_key] = new CdnEngine_Base();
|
59 |
$instances[$instance_key] = new CdnEngine_Mirror_Highwinds( $config );
|
60 |
break;
|
61 |
|
62 |
+
case 'limelight':
|
63 |
+
$instances[$instance_key] = new CdnEngine_Mirror_LimeLight( $config );
|
64 |
+
break;
|
65 |
+
|
66 |
case 'maxcdn':
|
67 |
$instances[$instance_key] = new CdnEngine_Mirror_MaxCdn( $config );
|
68 |
break;
|
88 |
$instances[$instance_key] = new CdnEngine_S3_Compatible( $config );
|
89 |
break;
|
90 |
|
91 |
+
case 'stackpath':
|
92 |
+
$instances[$instance_key] = new CdnEngine_Mirror_StackPath( $config );
|
93 |
+
break;
|
94 |
+
|
95 |
default :
|
96 |
trigger_error( 'Incorrect CDN engine', E_USER_WARNING );
|
97 |
$instances[$instance_key] = new CdnEngine_Base();
|
CdnEngine_Base.php
CHANGED
@@ -181,7 +181,7 @@ class CdnEngine_Base {
|
|
181 |
default:
|
182 |
if ( !isset( $domains[0] ) ) {
|
183 |
$scheme = $this->_get_scheme();
|
184 |
-
if ( 'https' == $scheme &&
|
185 |
return $domains['https_default'];
|
186 |
} else {
|
187 |
return isset( $domains['http_default'] ) ? $domains['http_default'] :
|
@@ -515,10 +515,8 @@ class CdnEngine_Base {
|
|
515 |
$hostname = $_domain;
|
516 |
}
|
517 |
|
518 |
-
if (
|
519 |
-
|
520 |
-
|
521 |
-
return false;
|
522 |
}
|
523 |
|
524 |
if ( gethostbyname( $hostname ) === $hostname ) {
|
181 |
default:
|
182 |
if ( !isset( $domains[0] ) ) {
|
183 |
$scheme = $this->_get_scheme();
|
184 |
+
if ( 'https' == $scheme && !empty( $domains['https_default'] ) ) {
|
185 |
return $domains['https_default'];
|
186 |
} else {
|
187 |
return isset( $domains['http_default'] ) ? $domains['http_default'] :
|
515 |
$hostname = $_domain;
|
516 |
}
|
517 |
|
518 |
+
if ( empty( $hostname ) ) {
|
519 |
+
continue;
|
|
|
|
|
520 |
}
|
521 |
|
522 |
if ( gethostbyname( $hostname ) === $hostname ) {
|
CdnEngine_Mirror_LimeLight.php
ADDED
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace W3TC;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* class CdnEngine_Mirror_Highwinds
|
6 |
+
*/
|
7 |
+
class CdnEngine_Mirror_LimeLight extends CdnEngine_Mirror {
|
8 |
+
private $short_name;
|
9 |
+
private $username;
|
10 |
+
private $api_key;
|
11 |
+
private $debug;
|
12 |
+
private $domains;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* PHP5 Constructor
|
16 |
+
*
|
17 |
+
* @param array $config
|
18 |
+
* account_hash
|
19 |
+
* username
|
20 |
+
* password
|
21 |
+
*/
|
22 |
+
function __construct( $config = array() ) {
|
23 |
+
$this->short_name = $config['short_name'];
|
24 |
+
$this->username = $config['username'];
|
25 |
+
$this->api_key = $config['api_key'];
|
26 |
+
$this->debug = $config['debug'];
|
27 |
+
|
28 |
+
$this->domains = (array)$config['domains'];
|
29 |
+
|
30 |
+
parent::__construct( $config );
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Purges remote files
|
35 |
+
*
|
36 |
+
* @param array $files
|
37 |
+
* @param array $results
|
38 |
+
* @return boolean
|
39 |
+
*/
|
40 |
+
function purge( $files, &$results ) {
|
41 |
+
if ( empty( $this->short_name ) || empty( $this->username ) ||
|
42 |
+
empty( $this->api_key ) )
|
43 |
+
throw new \Exception( __( 'Credentials are not specified.', 'w3-total-cache' ) );
|
44 |
+
|
45 |
+
$api = new Cdnfsd_LimeLight_Api( $this->short_name, $this->username, $this->api_key );
|
46 |
+
|
47 |
+
$results = array();
|
48 |
+
try {
|
49 |
+
$items = array();
|
50 |
+
foreach ( $files as $file ) {
|
51 |
+
$url = $this->_format_url( $file['remote_path'] );
|
52 |
+
$items[] = array(
|
53 |
+
'pattern' => $url,
|
54 |
+
'exact' => true,
|
55 |
+
'evict' => false,
|
56 |
+
'incqs' => false
|
57 |
+
);
|
58 |
+
|
59 |
+
// max number of items per request based on API docs
|
60 |
+
if ( count( $items ) >= 100 ) {
|
61 |
+
if ( $this->debug ) {
|
62 |
+
Util_Debug::log( 'cdn', json_encode( $items, JSON_PRETTY_PRINT ) );
|
63 |
+
}
|
64 |
+
|
65 |
+
$api->purge( $items );
|
66 |
+
$items = array();
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
if ( $this->debug ) {
|
71 |
+
Util_Debug::log( 'cdn', json_encode( $items, JSON_PRETTY_PRINT ) );
|
72 |
+
}
|
73 |
+
|
74 |
+
$api->purge( $items );
|
75 |
+
|
76 |
+
$results[] = $this->_get_result( '', '', W3TC_CDN_RESULT_OK, 'OK' );
|
77 |
+
} catch ( \Exception $e ) {
|
78 |
+
$results[] = $this->_get_result( '', '', W3TC_CDN_RESULT_HALT,
|
79 |
+
__( 'Failed to purge: ', 'w3-total-cache' ) . $e->getMessage() );
|
80 |
+
}
|
81 |
+
|
82 |
+
return !$this->_is_error( $results );
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Purge CDN completely
|
87 |
+
*
|
88 |
+
* @param unknown $results
|
89 |
+
* @return bool
|
90 |
+
*/
|
91 |
+
function purge_all( &$results ) {
|
92 |
+
if ( empty( $this->short_name ) || empty( $this->username ) ||
|
93 |
+
empty( $this->api_key ) )
|
94 |
+
throw new \Exception( __( 'Access key not specified.', 'w3-total-cache' ) );
|
95 |
+
|
96 |
+
$api = new Cdnfsd_LimeLight_Api( $this->short_name, $this->username, $this->api_key );
|
97 |
+
|
98 |
+
$results = array();
|
99 |
+
try {
|
100 |
+
$items = array();
|
101 |
+
foreach ( $this->domains as $domain ) {
|
102 |
+
$items[] = array(
|
103 |
+
'pattern' => 'http://' . $domain . '/*',
|
104 |
+
'exact' => false,
|
105 |
+
'evict' => false,
|
106 |
+
'incqs' => false
|
107 |
+
);
|
108 |
+
$items[] = array(
|
109 |
+
'pattern' => 'https://' . $domain . '/*',
|
110 |
+
'exact' => false,
|
111 |
+
'evict' => false,
|
112 |
+
'incqs' => false
|
113 |
+
);
|
114 |
+
}
|
115 |
+
|
116 |
+
if ( $this->debug ) {
|
117 |
+
Util_Debug::log( 'cdn', json_encode( $items, JSON_PRETTY_PRINT ) );
|
118 |
+
}
|
119 |
+
|
120 |
+
$api->purge( $items );
|
121 |
+
|
122 |
+
$results[] = $this->_get_result( '', '', W3TC_CDN_RESULT_OK, 'OK' );
|
123 |
+
} catch ( \Exception $e ) {
|
124 |
+
$results[] = $this->_get_result( '', '', W3TC_CDN_RESULT_HALT,
|
125 |
+
__( 'Failed to purge all: ', 'w3-total-cache' ) . $e->getMessage() );
|
126 |
+
}
|
127 |
+
|
128 |
+
return !$this->_is_error( $results );
|
129 |
+
}
|
130 |
+
|
131 |
+
|
132 |
+
|
133 |
+
function get_domains() {
|
134 |
+
return $this->domains;
|
135 |
+
}
|
136 |
+
}
|
CdnEngine_Mirror_StackPath.php
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace W3TC;
|
3 |
+
|
4 |
+
class CdnEngine_Mirror_StackPath extends CdnEngine_Mirror {
|
5 |
+
/**
|
6 |
+
* PHP5 Constructor
|
7 |
+
*
|
8 |
+
* @param array $config
|
9 |
+
*/
|
10 |
+
function __construct( $config = array() ) {
|
11 |
+
$config = array_merge( array(
|
12 |
+
'authorization_key' => '',
|
13 |
+
'alias' => '',
|
14 |
+
'consumerkey' => '',
|
15 |
+
'consumersecret' => '',
|
16 |
+
'zone_id' => 0
|
17 |
+
), $config );
|
18 |
+
$split_keys = explode( '+', $config['authorization_key'] );
|
19 |
+
if ( sizeof( $split_keys )==3 )
|
20 |
+
list( $config['alias'], $config['consumerkey'], $config['consumersecret'] ) = $split_keys;
|
21 |
+
parent::__construct( $config );
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Purges remote files
|
26 |
+
*
|
27 |
+
* @param array $files
|
28 |
+
* @param array $results
|
29 |
+
* @return boolean
|
30 |
+
*/
|
31 |
+
function purge( $files, &$results ) {
|
32 |
+
if ( empty( $this->_config['authorization_key'] ) ) {
|
33 |
+
$results = $this->_get_results( $files, W3TC_CDN_RESULT_HALT, __( 'Empty Authorization Key.', 'w3-total-cache' ) );
|
34 |
+
|
35 |
+
return false;
|
36 |
+
}
|
37 |
+
|
38 |
+
if ( empty( $this->_config['alias'] ) ||
|
39 |
+
empty( $this->_config['consumerkey'] ) ||
|
40 |
+
empty( $this->_config['consumersecret'] ) ) {
|
41 |
+
$results = $this->_get_results( $files, W3TC_CDN_RESULT_HALT, __( 'Malformed Authorization Key.', 'w3-total-cache' ) );
|
42 |
+
|
43 |
+
return false;
|
44 |
+
}
|
45 |
+
|
46 |
+
$api = new Cdn_StackPath_Api( $this->_config['alias'],
|
47 |
+
$this->_config['consumerkey'], $this->_config['consumersecret'] );
|
48 |
+
$results = array();
|
49 |
+
|
50 |
+
try {
|
51 |
+
$zone_id = $this->_config['zone_id'];
|
52 |
+
|
53 |
+
if ( $zone_id == 0 || is_null( $zone_id ) ) {
|
54 |
+
$results[] = $this->_get_result( '', '', W3TC_CDN_RESULT_ERROR,
|
55 |
+
__( 'No zone defined', 'w3-total-cache' ) );
|
56 |
+
return !$this->_is_error( $results );
|
57 |
+
}
|
58 |
+
|
59 |
+
|
60 |
+
$files_to_pass = array();
|
61 |
+
foreach ( $files as $file )
|
62 |
+
$files_to_pass[] = '/' . $file['remote_path'];
|
63 |
+
$params = array( 'files' => $files_to_pass );
|
64 |
+
$api->delete_site_cache( $zone_id, $params );
|
65 |
+
|
66 |
+
$results[] = $this->_get_result( '', '', W3TC_CDN_RESULT_OK, 'OK' );
|
67 |
+
} catch ( \Exception $e ) {
|
68 |
+
$results[] = $this->_get_result( '', '', W3TC_CDN_RESULT_HALT, __( 'Failure to pull zone: ', 'w3-total-cache' ) . $e->getMessage() );
|
69 |
+
}
|
70 |
+
|
71 |
+
return !$this->_is_error( $results );
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Purge CDN completely
|
76 |
+
*
|
77 |
+
* @param unknown $results
|
78 |
+
* @return bool
|
79 |
+
*/
|
80 |
+
function purge_all( &$results ) {
|
81 |
+
if ( empty( $this->_config['authorization_key'] ) ) {
|
82 |
+
$results = $this->_get_results( array(), W3TC_CDN_RESULT_HALT, __( 'Empty Authorization Key.', 'w3-total-cache' ) );
|
83 |
+
|
84 |
+
return false;
|
85 |
+
}
|
86 |
+
|
87 |
+
if ( empty( $this->_config['alias'] ) || empty( $this->_config['consumerkey'] ) || empty( $this->_config['consumersecret'] ) ) {
|
88 |
+
$results = $this->_get_results( array(), W3TC_CDN_RESULT_HALT, __( 'Malformed Authorization Key.', 'w3-total-cache' ) );
|
89 |
+
|
90 |
+
return false;
|
91 |
+
}
|
92 |
+
|
93 |
+
$api = new Cdn_StackPath_Api( $this->_config['alias'], $this->_config['consumerkey'], $this->_config['consumersecret'] );
|
94 |
+
|
95 |
+
$results = array();
|
96 |
+
|
97 |
+
try {
|
98 |
+
$zone_id = $this->_config['zone_id'];
|
99 |
+
|
100 |
+
if ( $zone_id == 0 || is_null( $zone_id ) ) {
|
101 |
+
$results[] = $this->_get_result( '', '', W3TC_CDN_RESULT_ERROR,
|
102 |
+
__( 'No zone defined', 'w3-total-cache' ) );
|
103 |
+
return !$this->_is_error( $results );
|
104 |
+
}
|
105 |
+
|
106 |
+
$file_purge = $api->delete_site_cache( $zone_id );
|
107 |
+
} catch ( \Exception $e ) {
|
108 |
+
$results[] = $this->_get_result( '', '', W3TC_CDN_RESULT_HALT, __( 'Failure to pull zone: ', 'w3-total-cache' ) . $e->getMessage() );
|
109 |
+
}
|
110 |
+
|
111 |
+
return !$this->_is_error( $results );
|
112 |
+
}
|
113 |
+
}
|
Cdn_AdminActions.php
CHANGED
@@ -96,7 +96,7 @@ class Cdn_AdminActions {
|
|
96 |
), true );
|
97 |
} else {
|
98 |
Util_Admin::redirect_with_custom_messages2( array(
|
99 |
-
'errors' => array( 'Failed to
|
100 |
implode( ', ', $errors ) )
|
101 |
), true );
|
102 |
}
|
@@ -340,7 +340,7 @@ class Cdn_AdminActions {
|
|
340 |
}
|
341 |
|
342 |
if ( count( $purge ) ) {
|
343 |
-
$common->purge( $purge,
|
344 |
} else {
|
345 |
$errors[] = __( 'Empty files list.', 'w3-total-cache' );
|
346 |
}
|
@@ -406,6 +406,8 @@ class Cdn_AdminActions {
|
|
406 |
|
407 |
if ( $result ) {
|
408 |
if ( $engine == 'google_drive' || $engine == 'highwinds' ||
|
|
|
|
|
409 |
$engine == 'rackspace_cdn' ||
|
410 |
$engine == 'rscf' || $engine == 's3_compatible' ) {
|
411 |
// those use already stored w3tc config
|
96 |
), true );
|
97 |
} else {
|
98 |
Util_Admin::redirect_with_custom_messages2( array(
|
99 |
+
'errors' => array( 'Failed to purge CDN: ' .
|
100 |
implode( ', ', $errors ) )
|
101 |
), true );
|
102 |
}
|
340 |
}
|
341 |
|
342 |
if ( count( $purge ) ) {
|
343 |
+
$common->purge( $purge, $results );
|
344 |
} else {
|
345 |
$errors[] = __( 'Empty files list.', 'w3-total-cache' );
|
346 |
}
|
406 |
|
407 |
if ( $result ) {
|
408 |
if ( $engine == 'google_drive' || $engine == 'highwinds' ||
|
409 |
+
$engine == 'limelight' ||
|
410 |
+
$engine == 'maxcdn' || $engine == 'stackpath' ||
|
411 |
$engine == 'rackspace_cdn' ||
|
412 |
$engine == 'rscf' || $engine == 's3_compatible' ) {
|
413 |
// those use already stored w3tc config
|
Cdn_CacheFlush.php
CHANGED
@@ -51,7 +51,7 @@ class Cdn_CacheFlush {
|
|
51 |
$remote_path = $common->uri_to_cdn_uri( $local_site_path );
|
52 |
$files[] = $common->build_file_descriptor( $local_site_path, $remote_path );
|
53 |
$this->_flushed_urls[] = $url;
|
54 |
-
$common->purge( $files,
|
55 |
}
|
56 |
|
57 |
/**
|
51 |
$remote_path = $common->uri_to_cdn_uri( $local_site_path );
|
52 |
$files[] = $common->build_file_descriptor( $local_site_path, $remote_path );
|
53 |
$this->_flushed_urls[] = $url;
|
54 |
+
$common->purge( $files, $results );
|
55 |
}
|
56 |
|
57 |
/**
|
Cdn_Core.php
CHANGED
@@ -15,12 +15,14 @@ class Cdn_Core {
|
|
15 |
* Config
|
16 |
*/
|
17 |
private $_config = null;
|
|
|
18 |
|
19 |
/**
|
20 |
* Runs plugin
|
21 |
*/
|
22 |
function __construct() {
|
23 |
$this->_config = Dispatcher::config();
|
|
|
24 |
}
|
25 |
|
26 |
/**
|
@@ -175,6 +177,11 @@ class Cdn_Core {
|
|
175 |
* @return boolean
|
176 |
*/
|
177 |
function upload( $files, $queue_failed, &$results, $timeout_time = NULL ) {
|
|
|
|
|
|
|
|
|
|
|
178 |
$cdn = $this->get_cdn();
|
179 |
$force_rewrite = $this->_config->get_boolean( 'cdn.force.rewrite' );
|
180 |
|
@@ -208,6 +215,10 @@ class Cdn_Core {
|
|
208 |
@set_time_limit( $this->_config->get_integer( 'timelimit.cdn_delete' ) );
|
209 |
|
210 |
$return = $cdn->delete( $files, $results );
|
|
|
|
|
|
|
|
|
211 |
|
212 |
if ( !$return && $queue_failed ) {
|
213 |
foreach ( $results as $result ) {
|
@@ -228,7 +239,12 @@ class Cdn_Core {
|
|
228 |
* @param array $results
|
229 |
* @return boolean
|
230 |
*/
|
231 |
-
function purge( $files,
|
|
|
|
|
|
|
|
|
|
|
232 |
/**
|
233 |
* Purge varnish servers before mirror purging
|
234 |
*/
|
@@ -288,7 +304,11 @@ class Cdn_Core {
|
|
288 |
*/
|
289 |
function queue_upload_url( $url ) {
|
290 |
$docroot_filename = Util_Environment::url_to_docroot_filename( $url );
|
291 |
-
|
|
|
|
|
|
|
|
|
292 |
|
293 |
$a = parse_url( $url );
|
294 |
$uri = $a['path'];
|
@@ -325,98 +345,99 @@ class Cdn_Core {
|
|
325 |
static $cdn = array();
|
326 |
|
327 |
if ( !isset( $cdn[0] ) ) {
|
328 |
-
$
|
329 |
-
$
|
|
|
330 |
|
331 |
switch ( $engine ) {
|
332 |
case 'akamai':
|
333 |
$engine_config = array(
|
334 |
-
'username' => $
|
335 |
-
'password' => $
|
336 |
-
'zone' => $
|
337 |
-
'domain' => $
|
338 |
-
'ssl' => $
|
339 |
-
'email_notification' => $
|
340 |
'compression' => false
|
341 |
);
|
342 |
break;
|
343 |
|
344 |
case 'att':
|
345 |
$engine_config = array(
|
346 |
-
'account' => $
|
347 |
-
'token' => $
|
348 |
-
'domain' => $
|
349 |
-
'ssl' => $
|
350 |
'compression' => false
|
351 |
);
|
352 |
break;
|
353 |
|
354 |
case 'azure':
|
355 |
$engine_config = array(
|
356 |
-
'user' => $
|
357 |
-
'key' => $
|
358 |
-
'container' => $
|
359 |
-
'cname' => $
|
360 |
-
'ssl' => $
|
361 |
'compression' => false
|
362 |
);
|
363 |
break;
|
364 |
|
365 |
case 'cf':
|
366 |
$engine_config = array(
|
367 |
-
'key' => $
|
368 |
-
'secret' => $
|
369 |
-
'bucket' => $
|
370 |
-
'bucket_location' => $
|
371 |
-
'id' => $
|
372 |
-
'cname' => $
|
373 |
-
'ssl' => $
|
374 |
'compression' => $compression
|
375 |
);
|
376 |
break;
|
377 |
|
378 |
case 'cf2':
|
379 |
$engine_config = array(
|
380 |
-
'key' => $
|
381 |
-
'secret' => $
|
382 |
-
'id' => $
|
383 |
-
'cname' => $
|
384 |
-
'ssl' => $
|
385 |
'compression' => false
|
386 |
);
|
387 |
break;
|
388 |
|
389 |
case 'cotendo':
|
390 |
$engine_config = array(
|
391 |
-
'username' => $
|
392 |
-
'password' => $
|
393 |
-
'zones' => $
|
394 |
-
'domain' => $
|
395 |
-
'ssl' => $
|
396 |
'compression' => false
|
397 |
);
|
398 |
break;
|
399 |
|
400 |
case 'edgecast':
|
401 |
$engine_config = array(
|
402 |
-
'account' => $
|
403 |
-
'token' => $
|
404 |
-
'domain' => $
|
405 |
-
'ssl' => $
|
406 |
'compression' => false
|
407 |
);
|
408 |
break;
|
409 |
|
410 |
case 'ftp':
|
411 |
$engine_config = array(
|
412 |
-
'host' => $
|
413 |
-
'type' => $
|
414 |
-
'user' => $
|
415 |
-
'pass' => $
|
416 |
-
'path' => $
|
417 |
-
'pasv' => $
|
418 |
-
'domain' => $
|
419 |
-
'ssl' => $
|
420 |
'compression' => false,
|
421 |
'docroot' => Util_Environment::document_root()
|
422 |
);
|
@@ -427,15 +448,15 @@ class Cdn_Core {
|
|
427 |
|
428 |
$engine_config = array(
|
429 |
'client_id' =>
|
430 |
-
$
|
431 |
'access_token' =>
|
432 |
$state->get_string( 'cdn.google_drive.access_token' ),
|
433 |
'refresh_token' =>
|
434 |
-
$
|
435 |
'root_url' =>
|
436 |
-
$
|
437 |
'root_folder_id' =>
|
438 |
-
$
|
439 |
'new_access_token_callback' => array(
|
440 |
$this,
|
441 |
'on_google_drive_new_access_token'
|
@@ -448,32 +469,42 @@ class Cdn_Core {
|
|
448 |
|
449 |
$engine_config = array(
|
450 |
'domains' =>
|
451 |
-
$
|
452 |
'ssl' =>
|
453 |
-
$
|
454 |
'api_token' =>
|
455 |
-
$
|
456 |
'account_hash' =>
|
457 |
-
$
|
458 |
'host_hash_code' =>
|
459 |
-
$
|
460 |
);
|
461 |
break;
|
462 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
463 |
case 'maxcdn':
|
464 |
$engine_config = array(
|
465 |
-
'authorization_key' => $
|
466 |
-
'zone_id' => $
|
467 |
-
'domain' => $
|
468 |
-
'ssl' => $
|
469 |
'compression' => false
|
470 |
);
|
471 |
break;
|
472 |
|
473 |
case 'mirror':
|
474 |
$engine_config = array(
|
475 |
-
'domain' => $
|
476 |
-
'ssl' => $
|
477 |
'compression' => false
|
478 |
);
|
479 |
break;
|
@@ -482,13 +513,13 @@ class Cdn_Core {
|
|
482 |
$state = Dispatcher::config_state();
|
483 |
|
484 |
$engine_config = array(
|
485 |
-
'user_name' => $
|
486 |
-
'api_key' => $
|
487 |
-
'region' => $
|
488 |
-
'service_access_url' => $
|
489 |
-
'service_id' => $
|
490 |
-
'service_protocol' => $
|
491 |
-
'domains' => $
|
492 |
'access_state' =>
|
493 |
$state->get_string( 'cdn.rackspace_cdn.access_state' ),
|
494 |
'new_access_state_callback' => array(
|
@@ -502,12 +533,12 @@ class Cdn_Core {
|
|
502 |
$state = Dispatcher::config_state();
|
503 |
|
504 |
$engine_config = array(
|
505 |
-
'user_name' => $
|
506 |
-
'api_key' => $
|
507 |
-
'region' => $
|
508 |
-
'container' => $
|
509 |
-
'cname' => $
|
510 |
-
'ssl' => $
|
511 |
'compression' => false,
|
512 |
'access_state' =>
|
513 |
$state->get_string( 'cdn.rackspace_cf.access_state' ),
|
@@ -521,31 +552,42 @@ class Cdn_Core {
|
|
521 |
|
522 |
case 's3':
|
523 |
$engine_config = array(
|
524 |
-
'key' => $
|
525 |
-
'secret' => $
|
526 |
-
'bucket' => $
|
527 |
-
'bucket_location' => $
|
528 |
-
'cname' => $
|
529 |
-
'ssl' => $
|
530 |
'compression' => $compression
|
531 |
);
|
532 |
break;
|
533 |
|
534 |
case 's3_compatible':
|
535 |
$engine_config = array(
|
536 |
-
'key' => $
|
537 |
-
'secret' => $
|
538 |
-
'bucket' => $
|
539 |
-
'cname' => $
|
540 |
-
'ssl' => $
|
541 |
'compression' => $compression,
|
542 |
-
'api_host' => $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
543 |
);
|
544 |
break;
|
|
|
545 |
}
|
546 |
|
547 |
$engine_config = array_merge( $engine_config, array(
|
548 |
-
'debug' => $
|
549 |
) );
|
550 |
|
551 |
$cdn[0] = CdnEngine::instance( $engine, $engine_config );
|
15 |
* Config
|
16 |
*/
|
17 |
private $_config = null;
|
18 |
+
private $debug;
|
19 |
|
20 |
/**
|
21 |
* Runs plugin
|
22 |
*/
|
23 |
function __construct() {
|
24 |
$this->_config = Dispatcher::config();
|
25 |
+
$this->debug = $this->_config->get_boolean( 'cdn.debug' );
|
26 |
}
|
27 |
|
28 |
/**
|
177 |
* @return boolean
|
178 |
*/
|
179 |
function upload( $files, $queue_failed, &$results, $timeout_time = NULL ) {
|
180 |
+
if ( $this->debug ) {
|
181 |
+
Util_Debug::log( 'cdn', 'upload: ' .
|
182 |
+
json_encode( $files, JSON_PRETTY_PRINT ) );
|
183 |
+
}
|
184 |
+
|
185 |
$cdn = $this->get_cdn();
|
186 |
$force_rewrite = $this->_config->get_boolean( 'cdn.force.rewrite' );
|
187 |
|
215 |
@set_time_limit( $this->_config->get_integer( 'timelimit.cdn_delete' ) );
|
216 |
|
217 |
$return = $cdn->delete( $files, $results );
|
218 |
+
if ( $this->debug ) {
|
219 |
+
Util_Debug::log( 'cdn', 'delete: ' .
|
220 |
+
json_encode( $files, JSON_PRETTY_PRINT ) );
|
221 |
+
}
|
222 |
|
223 |
if ( !$return && $queue_failed ) {
|
224 |
foreach ( $results as $result ) {
|
239 |
* @param array $results
|
240 |
* @return boolean
|
241 |
*/
|
242 |
+
function purge( $files, &$results ) {
|
243 |
+
if ( $this->debug ) {
|
244 |
+
Util_Debug::log( 'cdn', 'purge: ' .
|
245 |
+
json_encode( $files, JSON_PRETTY_PRINT ) );
|
246 |
+
}
|
247 |
+
|
248 |
/**
|
249 |
* Purge varnish servers before mirror purging
|
250 |
*/
|
304 |
*/
|
305 |
function queue_upload_url( $url ) {
|
306 |
$docroot_filename = Util_Environment::url_to_docroot_filename( $url );
|
307 |
+
if ( is_null( $docroot_filename ) ) {
|
308 |
+
return;
|
309 |
+
}
|
310 |
+
|
311 |
+
$filename = Util_Environment::docroot_to_full_filename( $docroot_filename );
|
312 |
|
313 |
$a = parse_url( $url );
|
314 |
$uri = $a['path'];
|
345 |
static $cdn = array();
|
346 |
|
347 |
if ( !isset( $cdn[0] ) ) {
|
348 |
+
$c = $this->_config;
|
349 |
+
$engine = $c->get_string( 'cdn.engine' );
|
350 |
+
$compression = ( $c->get_boolean( 'browsercache.enabled' ) && $c->get_boolean( 'browsercache.html.compression' ) );
|
351 |
|
352 |
switch ( $engine ) {
|
353 |
case 'akamai':
|
354 |
$engine_config = array(
|
355 |
+
'username' => $c->get_string( 'cdn.akamai.username' ),
|
356 |
+
'password' => $c->get_string( 'cdn.akamai.password' ),
|
357 |
+
'zone' => $c->get_string( 'cdn.akamai.zone' ),
|
358 |
+
'domain' => $c->get_array( 'cdn.akamai.domain' ),
|
359 |
+
'ssl' => $c->get_string( 'cdn.akamai.ssl' ),
|
360 |
+
'email_notification' => $c->get_array( 'cdn.akamai.email_notification' ),
|
361 |
'compression' => false
|
362 |
);
|
363 |
break;
|
364 |
|
365 |
case 'att':
|
366 |
$engine_config = array(
|
367 |
+
'account' => $c->get_string( 'cdn.att.account' ),
|
368 |
+
'token' => $c->get_string( 'cdn.att.token' ),
|
369 |
+
'domain' => $c->get_array( 'cdn.att.domain' ),
|
370 |
+
'ssl' => $c->get_string( 'cdn.att.ssl' ),
|
371 |
'compression' => false
|
372 |
);
|
373 |
break;
|
374 |
|
375 |
case 'azure':
|
376 |
$engine_config = array(
|
377 |
+
'user' => $c->get_string( 'cdn.azure.user' ),
|
378 |
+
'key' => $c->get_string( 'cdn.azure.key' ),
|
379 |
+
'container' => $c->get_string( 'cdn.azure.container' ),
|
380 |
+
'cname' => $c->get_array( 'cdn.azure.cname' ),
|
381 |
+
'ssl' => $c->get_string( 'cdn.azure.ssl' ),
|
382 |
'compression' => false
|
383 |
);
|
384 |
break;
|
385 |
|
386 |
case 'cf':
|
387 |
$engine_config = array(
|
388 |
+
'key' => $c->get_string( 'cdn.cf.key' ),
|
389 |
+
'secret' => $c->get_string( 'cdn.cf.secret' ),
|
390 |
+
'bucket' => $c->get_string( 'cdn.cf.bucket' ),
|
391 |
+
'bucket_location' => $c->get_string( 'cdn.cf.bucket.location' ),
|
392 |
+
'id' => $c->get_string( 'cdn.cf.id' ),
|
393 |
+
'cname' => $c->get_array( 'cdn.cf.cname' ),
|
394 |
+
'ssl' => $c->get_string( 'cdn.cf.ssl' ),
|
395 |
'compression' => $compression
|
396 |
);
|
397 |
break;
|
398 |
|
399 |
case 'cf2':
|
400 |
$engine_config = array(
|
401 |
+
'key' => $c->get_string( 'cdn.cf2.key' ),
|
402 |
+
'secret' => $c->get_string( 'cdn.cf2.secret' ),
|
403 |
+
'id' => $c->get_string( 'cdn.cf2.id' ),
|
404 |
+
'cname' => $c->get_array( 'cdn.cf2.cname' ),
|
405 |
+
'ssl' => $c->get_string( 'cdn.cf2.ssl' ),
|
406 |
'compression' => false
|
407 |
);
|
408 |
break;
|
409 |
|
410 |
case 'cotendo':
|
411 |
$engine_config = array(
|
412 |
+
'username' => $c->get_string( 'cdn.cotendo.username' ),
|
413 |
+
'password' => $c->get_string( 'cdn.cotendo.password' ),
|
414 |
+
'zones' => $c->get_array( 'cdn.cotendo.zones' ),
|
415 |
+
'domain' => $c->get_array( 'cdn.cotendo.domain' ),
|
416 |
+
'ssl' => $c->get_string( 'cdn.cotendo.ssl' ),
|
417 |
'compression' => false
|
418 |
);
|
419 |
break;
|
420 |
|
421 |
case 'edgecast':
|
422 |
$engine_config = array(
|
423 |
+
'account' => $c->get_string( 'cdn.edgecast.account' ),
|
424 |
+
'token' => $c->get_string( 'cdn.edgecast.token' ),
|
425 |
+
'domain' => $c->get_array( 'cdn.edgecast.domain' ),
|
426 |
+
'ssl' => $c->get_string( 'cdn.edgecast.ssl' ),
|
427 |
'compression' => false
|
428 |
);
|
429 |
break;
|
430 |
|
431 |
case 'ftp':
|
432 |
$engine_config = array(
|
433 |
+
'host' => $c->get_string( 'cdn.ftp.host' ),
|
434 |
+
'type' => $c->get_string( 'cdn.ftp.type' ),
|
435 |
+
'user' => $c->get_string( 'cdn.ftp.user' ),
|
436 |
+
'pass' => $c->get_string( 'cdn.ftp.pass' ),
|
437 |
+
'path' => $c->get_string( 'cdn.ftp.path' ),
|
438 |
+
'pasv' => $c->get_boolean( 'cdn.ftp.pasv' ),
|
439 |
+
'domain' => $c->get_array( 'cdn.ftp.domain' ),
|
440 |
+
'ssl' => $c->get_string( 'cdn.ftp.ssl' ),
|
441 |
'compression' => false,
|
442 |
'docroot' => Util_Environment::document_root()
|
443 |
);
|
448 |
|
449 |
$engine_config = array(
|
450 |
'client_id' =>
|
451 |
+
$c->get_string( 'cdn.google_drive.client_id' ),
|
452 |
'access_token' =>
|
453 |
$state->get_string( 'cdn.google_drive.access_token' ),
|
454 |
'refresh_token' =>
|
455 |
+
$c->get_string( 'cdn.google_drive.refresh_token' ),
|
456 |
'root_url' =>
|
457 |
+
$c->get_string( 'cdn.google_drive.folder.url' ),
|
458 |
'root_folder_id' =>
|
459 |
+
$c->get_string( 'cdn.google_drive.folder.id' ),
|
460 |
'new_access_token_callback' => array(
|
461 |
$this,
|
462 |
'on_google_drive_new_access_token'
|
469 |
|
470 |
$engine_config = array(
|
471 |
'domains' =>
|
472 |
+
$c->get_array( 'cdn.highwinds.host.domains' ),
|
473 |
'ssl' =>
|
474 |
+
$c->get_string( 'cdn.highwinds.ssl' ),
|
475 |
'api_token' =>
|
476 |
+
$c->get_string( 'cdn.highwinds.api_token' ),
|
477 |
'account_hash' =>
|
478 |
+
$c->get_string( 'cdn.highwinds.account_hash' ),
|
479 |
'host_hash_code' =>
|
480 |
+
$c->get_string( 'cdn.highwinds.host.hash_code' )
|
481 |
);
|
482 |
break;
|
483 |
|
484 |
+
case 'limelight':
|
485 |
+
$engine_config = array(
|
486 |
+
'short_name' => $c->get_string( 'cdn.limelight.short_name' ),
|
487 |
+
'username' => $c->get_string( 'cdn.limelight.username' ),
|
488 |
+
'api_key' => $c->get_string( 'cdn.limelight.api_key' ),
|
489 |
+
'domains' => $c->get_array( 'cdn.limelight.host.domains' ),
|
490 |
+
'debug' => $c->get_string( 'cdn.debug' )
|
491 |
+
);
|
492 |
+
break;
|
493 |
+
|
494 |
case 'maxcdn':
|
495 |
$engine_config = array(
|
496 |
+
'authorization_key' => $c->get_string( 'cdn.maxcdn.authorization_key' ),
|
497 |
+
'zone_id' => $c->get_integer( 'cdn.maxcdn.zone_id' ),
|
498 |
+
'domain' => $c->get_array( 'cdn.maxcdn.domain' ),
|
499 |
+
'ssl' => $c->get_string( 'cdn.maxcdn.ssl' ),
|
500 |
'compression' => false
|
501 |
);
|
502 |
break;
|
503 |
|
504 |
case 'mirror':
|
505 |
$engine_config = array(
|
506 |
+
'domain' => $c->get_array( 'cdn.mirror.domain' ),
|
507 |
+
'ssl' => $c->get_string( 'cdn.mirror.ssl' ),
|
508 |
'compression' => false
|
509 |
);
|
510 |
break;
|
513 |
$state = Dispatcher::config_state();
|
514 |
|
515 |
$engine_config = array(
|
516 |
+
'user_name' => $c->get_string( 'cdn.rackspace_cdn.user_name' ),
|
517 |
+
'api_key' => $c->get_string( 'cdn.rackspace_cdn.api_key' ),
|
518 |
+
'region' => $c->get_string( 'cdn.rackspace_cdn.region' ),
|
519 |
+
'service_access_url' => $c->get_string( 'cdn.rackspace_cdn.service.access_url' ),
|
520 |
+
'service_id' => $c->get_string( 'cdn.rackspace_cdn.service.id' ),
|
521 |
+
'service_protocol' => $c->get_string( 'cdn.rackspace_cdn.service.protocol' ),
|
522 |
+
'domains' => $c->get_array( 'cdn.rackspace_cdn.domains' ),
|
523 |
'access_state' =>
|
524 |
$state->get_string( 'cdn.rackspace_cdn.access_state' ),
|
525 |
'new_access_state_callback' => array(
|
533 |
$state = Dispatcher::config_state();
|
534 |
|
535 |
$engine_config = array(
|
536 |
+
'user_name' => $c->get_string( 'cdn.rscf.user' ),
|
537 |
+
'api_key' => $c->get_string( 'cdn.rscf.key' ),
|
538 |
+
'region' => $c->get_string( 'cdn.rscf.location' ),
|
539 |
+
'container' => $c->get_string( 'cdn.rscf.container' ),
|
540 |
+
'cname' => $c->get_array( 'cdn.rscf.cname' ),
|
541 |
+
'ssl' => $c->get_string( 'cdn.rscf.ssl' ),
|
542 |
'compression' => false,
|
543 |
'access_state' =>
|
544 |
$state->get_string( 'cdn.rackspace_cf.access_state' ),
|
552 |
|
553 |
case 's3':
|
554 |
$engine_config = array(
|
555 |
+
'key' => $c->get_string( 'cdn.s3.key' ),
|
556 |
+
'secret' => $c->get_string( 'cdn.s3.secret' ),
|
557 |
+
'bucket' => $c->get_string( 'cdn.s3.bucket' ),
|
558 |
+
'bucket_location' => $c->get_string( 'cdn.s3.bucket.location' ),
|
559 |
+
'cname' => $c->get_array( 'cdn.s3.cname' ),
|
560 |
+
'ssl' => $c->get_string( 'cdn.s3.ssl' ),
|
561 |
'compression' => $compression
|
562 |
);
|
563 |
break;
|
564 |
|
565 |
case 's3_compatible':
|
566 |
$engine_config = array(
|
567 |
+
'key' => $c->get_string( 'cdn.s3.key' ),
|
568 |
+
'secret' => $c->get_string( 'cdn.s3.secret' ),
|
569 |
+
'bucket' => $c->get_string( 'cdn.s3.bucket' ),
|
570 |
+
'cname' => $c->get_array( 'cdn.s3.cname' ),
|
571 |
+
'ssl' => $c->get_string( 'cdn.s3.ssl' ),
|
572 |
'compression' => $compression,
|
573 |
+
'api_host' => $c->get_string( 'cdn.s3_compatible.api_host' )
|
574 |
+
);
|
575 |
+
break;
|
576 |
+
|
577 |
+
case 'stackpath':
|
578 |
+
$engine_config = array(
|
579 |
+
'authorization_key' => $c->get_string( 'cdn.stackpath.authorization_key' ),
|
580 |
+
'zone_id' => $c->get_integer( 'cdn.stackpath.zone_id' ),
|
581 |
+
'domain' => $c->get_array( 'cdn.stackpath.domain' ),
|
582 |
+
'ssl' => $c->get_string( 'cdn.stackpath.ssl' ),
|
583 |
+
'compression' => false
|