WP Fastest Cache - Version 0.8.9.6

Version Description

  • to clear post's cache which contains query string if WPFC_CACHE_QUERYSTRING is defined
  • refactoring of excluding system
  • refactoring of getWpContentDir()
  • to fix the homepage cache problem when WPML with different url is used
  • to prevent directory traversal attack (discoverd by Imre Rad)
Download this release

Release Info

Developer emrevona
Plugin Icon 128x128 WP Fastest Cache
Version 0.8.9.6
Comparing to
See all releases

Code changes from version 0.8.9.5 to 0.8.9.6

Files changed (5) hide show
  1. inc/admin.php +13 -4
  2. inc/cache.php +11 -14
  3. js/cdn/cdn.js +7 -1
  4. readme.txt +8 -1
  5. wpFastestCache.php +37 -21
inc/admin.php CHANGED
@@ -683,6 +683,15 @@
683
  $trailing_slash_rule = "";
684
  $consent_cookie = "";
685
 
 
 
 
 
 
 
 
 
 
686
  if(isset($_POST["wpFastestCacheMobile"]) && $_POST["wpFastestCacheMobile"] == "on"){
687
  $mobile = "RewriteCond %{HTTP_USER_AGENT} !^.*(".$this->getMobileUserAgents().").*$ [NC]"."\n";
688
  }
@@ -725,17 +734,17 @@
725
 
726
 
727
  if(ABSPATH == "//"){
728
- $data = $data."RewriteCond %{DOCUMENT_ROOT}/".WPFC_WP_CONTENT_BASENAME."/cache/all/$1/index.html -f"."\n";
729
  }else{
730
  //WARNING: If you change the following lines, you need to update webp as well
731
- $data = $data."RewriteCond %{DOCUMENT_ROOT}/".WPFC_WP_CONTENT_BASENAME."/cache/all/$1/index.html -f [or]"."\n";
732
  // to escape spaces
733
  $tmp_WPFC_WP_CONTENT_DIR = str_replace(" ", "\ ", WPFC_WP_CONTENT_DIR);
734
 
735
- $data = $data."RewriteCond ".$tmp_WPFC_WP_CONTENT_DIR."/cache/all/".$this->getRewriteBase(true)."$1/index.html -f"."\n";
736
  }
737
 
738
- $data = $data.'RewriteRule ^(.*) "/'.$this->getRewriteBase().WPFC_WP_CONTENT_BASENAME.'/cache/all/'.$this->getRewriteBase(true).'$1/index.html" [L]'."\n";
739
 
740
  //RewriteRule !/ "/wp-content/cache/all/index.html" [L]
741
 
683
  $trailing_slash_rule = "";
684
  $consent_cookie = "";
685
 
686
+ $language_negotiation_type = apply_filters('wpml_setting', false, 'language_negotiation_type');
687
+ if(($language_negotiation_type == 2) && $this->isPluginActive('sitepress-multilingual-cms/sitepress.php')){
688
+ $cache_path = '/cache/all/%{HTTP_HOST}/';
689
+ $disable_condition = true;
690
+ }else{
691
+ $cache_path = '/cache/all/';
692
+ $disable_condition = false;
693
+ }
694
+
695
  if(isset($_POST["wpFastestCacheMobile"]) && $_POST["wpFastestCacheMobile"] == "on"){
696
  $mobile = "RewriteCond %{HTTP_USER_AGENT} !^.*(".$this->getMobileUserAgents().").*$ [NC]"."\n";
697
  }
734
 
735
 
736
  if(ABSPATH == "//"){
737
+ $data = $data."RewriteCond %{DOCUMENT_ROOT}/".WPFC_WP_CONTENT_BASENAME.$cache_path."$1/index.html -f"."\n";
738
  }else{
739
  //WARNING: If you change the following lines, you need to update webp as well
740
+ $data = $data."RewriteCond %{DOCUMENT_ROOT}/".WPFC_WP_CONTENT_BASENAME.$cache_path."$1/index.html -f [or]"."\n";
741
  // to escape spaces
742
  $tmp_WPFC_WP_CONTENT_DIR = str_replace(" ", "\ ", WPFC_WP_CONTENT_DIR);
743
 
744
+ $data = $data."RewriteCond ".$tmp_WPFC_WP_CONTENT_DIR.$cache_path.$this->getRewriteBase(true)."$1/index.html -f"."\n";
745
  }
746
 
747
+ $data = $data.'RewriteRule ^(.*) "/'.$this->getRewriteBase().WPFC_WP_CONTENT_BASENAME.$cache_path.$this->getRewriteBase(true).'$1/index.html" [L]'."\n";
748
 
749
  //RewriteRule !/ "/wp-content/cache/all/index.html" [L]
750
 
inc/cache.php CHANGED
@@ -97,16 +97,6 @@
97
  }
98
  }
99
 
100
- //WPML language switch
101
- //https://wpml.org/forums/topic/wpml-language-switch-wp-fastest-cache-issue/
102
- $language_negotiation_type = apply_filters('wpml_setting', false, 'language_negotiation_type');
103
- if ($this->isPluginActive('sitepress-multilingual-cms/sitepress.php') && 2 == $language_negotiation_type){
104
- $current_language = apply_filters('wpml_current_language', false);
105
-
106
- $this->cacheFilePath = str_replace('/cache/all/', '/cache/all/'.$current_language.'/', $this->cacheFilePath);
107
- $this->cacheFilePath = str_replace('/cache/wpfc-mobile-cache/', '/cache/wpfc-mobile-cache/'.$current_language.'/', $this->cacheFilePath);
108
- }
109
-
110
 
111
 
112
  $this->cacheFilePath = $this->cacheFilePath ? rtrim($this->cacheFilePath, "/")."/" : "";
@@ -141,6 +131,11 @@
141
  if($this->cacheFilePath){
142
  $this->cacheFilePath = urldecode($this->cacheFilePath);
143
  }
 
 
 
 
 
144
  }
145
 
146
  public function remove_url_paramters(){
@@ -481,11 +476,11 @@
481
  if(preg_match("/utm_(source|medium|campaign|content|term)/i", $request_url)){
482
  return true;
483
  }
484
- }else if($buffer && isset($value->prefix) && $value->prefix && ($value->type == "page")){
485
  $value->content = trim($value->content);
486
  $value->content = trim($value->content, "/");
487
 
488
- if(preg_match("/^(homepage|category|tag|post|page|archive|attachment)$/", $value->prefix)){
489
  if(preg_match('/<\!--WPFC_PAGE_TYPE_'.$value->prefix.'-->/i', $buffer)){
490
  return true;
491
  }
@@ -500,8 +495,10 @@
500
  $preg_match_rule = preg_quote($value->content, "/");
501
  }
502
 
503
- if(preg_match("/".$preg_match_rule."/i", $request_url)){
504
- return true;
 
 
505
  }
506
  }
507
  }else if($value->type == "useragent"){
97
  }
98
  }
99
 
 
 
 
 
 
 
 
 
 
 
100
 
101
 
102
  $this->cacheFilePath = $this->cacheFilePath ? rtrim($this->cacheFilePath, "/")."/" : "";
131
  if($this->cacheFilePath){
132
  $this->cacheFilePath = urldecode($this->cacheFilePath);
133
  }
134
+
135
+ // for security
136
+ if(preg_match("/\.{2,}/", $this->cacheFilePath)){
137
+ $this->cacheFilePath = false;
138
+ }
139
  }
140
 
141
  public function remove_url_paramters(){
476
  if(preg_match("/utm_(source|medium|campaign|content|term)/i", $request_url)){
477
  return true;
478
  }
479
+ }else if(isset($value->prefix) && $value->prefix && ($value->type == "page")){
480
  $value->content = trim($value->content);
481
  $value->content = trim($value->content, "/");
482
 
483
+ if($buffer && preg_match("/^(homepage|category|tag|post|page|archive|attachment)$/", $value->prefix)){
484
  if(preg_match('/<\!--WPFC_PAGE_TYPE_'.$value->prefix.'-->/i', $buffer)){
485
  return true;
486
  }
495
  $preg_match_rule = preg_quote($value->content, "/");
496
  }
497
 
498
+ if($preg_match_rule){
499
+ if(preg_match("/".$preg_match_rule."/i", $request_url)){
500
+ return true;
501
+ }
502
  }
503
  }
504
  }else if($value->type == "useragent"){
js/cdn/cdn.js CHANGED
@@ -287,7 +287,13 @@ var WpfcCDN = {
287
  }
288
 
289
  if(jQuery("#wpfc-modal-" + this.id).find(".wpfc-cdn-pages-container div.wiz-cont:visible").attr("wpfc-cdn-page") > 1){
290
- self.show_button("back");
 
 
 
 
 
 
291
  }
292
  }else{
293
  self.show_button("close");
287
  }
288
 
289
  if(jQuery("#wpfc-modal-" + this.id).find(".wpfc-cdn-pages-container div.wiz-cont:visible").attr("wpfc-cdn-page") > 1){
290
+ if(current_page.attr("wpfc-cdn-page") == 2){
291
+ if(self.id == "maxcdn"){
292
+ self.show_button("back");
293
+ }
294
+ }else{
295
+ self.show_button("back");
296
+ }
297
  }
298
  }else{
299
  self.show_button("close");
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://profiles.wordpress.org/emrevona/
4
  Tags: cache, caching, performance, wp-cache, total cache, super cache, cdn
5
  Requires at least: 3.3
6
  Tested up to: 5.2
7
- Stable tag: 0.8.9.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -103,6 +103,13 @@ Wpfc supports Wordpress Multisite [<a target="_blank" href="https://www.wpfastes
103
 
104
  == Changelog ==
105
 
 
 
 
 
 
 
 
106
  = 0.8.9.5 =
107
  * to check the page is 404 or not with http_response_code() if is_404() does not work
108
  * <strong>[FEATURE]</strong> to add Custom Taxonomies on the preload feature
4
  Tags: cache, caching, performance, wp-cache, total cache, super cache, cdn
5
  Requires at least: 3.3
6
  Tested up to: 5.2
7
+ Stable tag: 0.8.9.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
103
 
104
  == Changelog ==
105
 
106
+ = 0.8.9.6 =
107
+ * to clear post's cache which contains query string if WPFC_CACHE_QUERYSTRING is defined
108
+ * refactoring of excluding system
109
+ * refactoring of getWpContentDir()
110
+ * to fix the homepage cache problem when WPML with different url is used
111
+ * to prevent directory traversal attack (discoverd by Imre Rad)
112
+
113
  = 0.8.9.5 =
114
  * to check the page is 404 or not with http_response_code() if is_404() does not work
115
  * <strong>[FEATURE]</strong> to add Custom Taxonomies on the preload feature
wpFastestCache.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP Fastest Cache
4
  Plugin URI: http://wordpress.org/plugins/wp-fastest-cache/
5
  Description: The simplest and fastest WP Cache system
6
- Version: 0.8.9.5
7
  Author: Emre Vona
8
  Author URI: http://tr.linkedin.com/in/emrevona
9
  Text Domain: wp-fastest-cache
@@ -245,6 +245,11 @@ GNU General Public License for more details.
245
  }
246
  }else{
247
  if(preg_match("/wpfc-minified\/([^\/]+)\/([^\/]+)/", $this->current_url(), $path)){
 
 
 
 
 
248
  if($sources = @scandir(WPFC_WP_CONTENT_DIR."/cache/wpfc-minified/".$path[1], 1)){
249
  if(isset($sources[0])){
250
  // $exist_url = str_replace($path[2], $sources[0], $this->current_url());
@@ -765,9 +770,11 @@ GNU General Public License for more details.
765
  */
766
 
767
  if($path){
768
- if($current_language = apply_filters('wpml_current_language', false)){
769
- //https://wpml.org/forums/topic/wpml-language-switch-wp-fastest-cache-issue/
770
- $path = preg_replace("/(\/cache\/wpfc-widget-cache\/)(.+\.html)$/", "$1/$current_language-$2", $path);
 
 
771
  }
772
 
773
  if(is_multisite()){
@@ -925,31 +932,40 @@ GNU General Public License for more details.
925
  $permalink = preg_replace("/__trashed\/(\d+)$/", "/$1", $permalink);
926
 
927
  if(preg_match("/https?:\/\/[^\/]+\/(.+)/", $permalink, $out)){
 
 
928
 
929
- //WPML language switch
930
- //https://wpml.org/forums/topic/wpml-language-switch-wp-fastest-cache-issue/
931
- if($this->isPluginActive('sitepress-multilingual-cms/sitepress.php')){
932
- $current_language = apply_filters('wpml_current_language', false);
933
-
934
- $path = $this->getWpContentDir("/cache/all/").$current_language."/".$out[1];
935
- $mobile_path = $this->getWpContentDir("/cache/wpfc-mobile-cache/").$current_language."/".$out[1];
936
- }else{
937
- $path = $this->getWpContentDir("/cache/all/").$out[1];
938
- $mobile_path = $this->getWpContentDir("/cache/wpfc-mobile-cache/").$out[1];
939
  }
940
 
 
 
941
  if(is_dir($path)){
942
- if($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")){
943
- include_once $this->get_premium_path("logs.php");
944
- $log = new WpFastestCacheLogs("delete");
945
- $log->action();
 
 
 
 
 
 
 
 
 
946
  }
947
 
948
- $this->rm_folder_recursively($path);
 
 
949
  }
950
 
951
- if(is_dir($mobile_path)){
952
- $this->rm_folder_recursively($mobile_path);
953
  }
954
  }
955
 
3
  Plugin Name: WP Fastest Cache
4
  Plugin URI: http://wordpress.org/plugins/wp-fastest-cache/
5
  Description: The simplest and fastest WP Cache system
6
+ Version: 0.8.9.6
7
  Author: Emre Vona
8
  Author URI: http://tr.linkedin.com/in/emrevona
9
  Text Domain: wp-fastest-cache
245
  }
246
  }else{
247
  if(preg_match("/wpfc-minified\/([^\/]+)\/([^\/]+)/", $this->current_url(), $path)){
248
+ // for security
249
+ if(preg_match("/\.{2,}/", $this->current_url())){
250
+ die("May be Directory Traversal Attack");
251
+ }
252
+
253
  if($sources = @scandir(WPFC_WP_CONTENT_DIR."/cache/wpfc-minified/".$path[1], 1)){
254
  if(isset($sources[0])){
255
  // $exist_url = str_replace($path[2], $sources[0], $this->current_url());
770
  */
771
 
772
  if($path){
773
+ //WPML language switch
774
+ //https://wpml.org/forums/topic/wpml-language-switch-wp-fastest-cache-issue/
775
+ $language_negotiation_type = apply_filters('wpml_setting', false, 'language_negotiation_type');
776
+ if(($language_negotiation_type == 2) && $this->isPluginActive('sitepress-multilingual-cms/sitepress.php')){
777
+ $path = preg_replace("/\/cache\/(all|wpfc-mobile-cache)/", "/cache/".$_SERVER['HTTP_HOST']."/$1", $path);
778
  }
779
 
780
  if(is_multisite()){
932
  $permalink = preg_replace("/__trashed\/(\d+)$/", "/$1", $permalink);
933
 
934
  if(preg_match("/https?:\/\/[^\/]+\/(.+)/", $permalink, $out)){
935
+ $path = $this->getWpContentDir("/cache/all/").$out[1];
936
+ $mobile_path = $this->getWpContentDir("/cache/wpfc-mobile-cache/").$out[1];
937
 
938
+ if($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")){
939
+ include_once $this->get_premium_path("logs.php");
940
+ $log = new WpFastestCacheLogs("delete");
941
+ $log->action();
 
 
 
 
 
 
942
  }
943
 
944
+ $files = array();
945
+
946
  if(is_dir($path)){
947
+ array_push($files, $path);
948
+ }
949
+
950
+ if(is_dir($mobile_path)){
951
+ array_push($files, $mobile_path);
952
+ }
953
+
954
+ if(defined('WPFC_CACHE_QUERYSTRING') && WPFC_CACHE_QUERYSTRING){
955
+ $files_with_query_string = glob($path."\?*");
956
+ $mobile_files_with_query_string = glob($mobile_path."\?*");
957
+
958
+ if(is_array($files_with_query_string) && (count($files_with_query_string) > 0)){
959
+ $files = array_merge($files, $files_with_query_string);
960
  }
961
 
962
+ if(is_array($mobile_files_with_query_string) && (count($mobile_files_with_query_string) > 0)){
963
+ $files = array_merge($files, $mobile_files_with_query_string);
964
+ }
965
  }
966
 
967
+ foreach((array)$files as $file){
968
+ $this->rm_folder_recursively($file);
969
  }
970
  }
971