+
+
+
+
+
+
+ "wpfc-options","title" => __("Settings", "wp-fastest-cache" )));
+ array_push($tabs, array("id"=>"wpfc-deleteCache","title" => __("Clear Cache", "wp-fastest-cache" )));
+ array_push($tabs, array("id"=>"wpfc-imageOptimisation","title" => __("Image Optimization", "wp-fastest-cache" )));
+
+ if(!class_exists("WpFastestCachePowerfulHtml")){
+ array_push($tabs, array("id"=>"wpfc-premium","title"=>"Premium"));
+ }
+
+ array_push($tabs, array("id"=>"wpfc-exclude","title"=>__("Exclude", "wp-fastest-cache" )));
+ array_push($tabs, array("id"=>"wpfc-cdn","title"=>"CDN"));
+ array_push($tabs, array("id"=>"wpfc-db","title"=>"DB"));
+
+ foreach ($tabs as $key => $value){
+ $checked = "";
+
+ //tab of "delete css and js" has been removed so there is need to check it
+ if(isset($_POST["wpFastestCachePage"]) && $_POST["wpFastestCachePage"] && $_POST["wpFastestCachePage"] == "deleteCssAndJsCache"){
+ $_POST["wpFastestCachePage"] = "deleteCache";
+ }
+
+ if(!isset($_POST["wpFastestCachePage"]) && $value["id"] == "wpfc-options"){
+ $checked = ' checked="checked" ';
+ }else if((isset($_POST["wpFastestCachePage"])) && ("wpfc-".$_POST["wpFastestCachePage"] == $value["id"])){
+ $checked = ' checked="checked" ';
+ }
+ echo '
'."\n";
+ echo '
'.esc_html($value["title"]).' '."\n";
+ }
+ ?>
+
+
+
+
+ Show Logs
+ Hide Logs
+
+
+ statics();
+ }else{
+ ?>
+
+
+ Show Logs
+ Hide Logs
+
+
+
+
+
+
+
+
+
+
+
+
+
+ printLogs();
+ }
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ class="wpfc-add-new-timeout-button wpfc-dialog-buttons" style="display: inline-block;padding: 4px 10px;">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ class="wpfc-add-new-csp-button wpfc-dialog-buttons" style="display: inline-block;padding: 4px 10px;">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Reverse Proxy Cache
+
+
+
+
">
+
+
Varnish Cache
+
Varnish Cache is a web application accelerator also known as a caching HTTP reverse proxy.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ statics(); ?>
+ imageList(); ?>
+
+
+
+
+
+
+
+
+
+
+
+
1 License Number of Licenses
5,000 Image Credits per License
∞ Support and Updates
" width="40" height="40" /> One-Time Fee " width="40" height="40" /> 1 year license transfer right " width="40" height="40" /> 30 Day Money Back Guarantee
+
3 Licenses Number of Licenses
5,000 Image Credits per License
∞ Support and Updates
" width="40" height="40" /> One-Time Fee " width="40" height="40" /> 1 year license transfer right " width="40" height="40" /> 30 Day Money Back Guarantee
+
5 Licenses Number of Licenses
5,000 Image Credits per License
∞ Support and Updates
" width="40" height="40" /> One-Time Fee " width="40" height="40" /> 1 year license transfer right " width="40" height="40" /> 30 Day Money Back Guarantee
+
10 Licenses Number of Licenses
5,000 Image Credits per License
∞ Support and Updates
" width="40" height="40" /> One-Time Fee " width="40" height="40" /> 1 year license transfer right " width="40" height="40" /> 30 Day Money Back Guarantee
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
" />
+
+
CDN by Bunny
+
Speed up content with next-generation CDN
+
+
+
+
+
+
+
" />
+
+
Other CDN Providers
+
You can use any cdn provider.
+
+
+
+
+
+
+
" />
+
+
CDN by Cloudflare
+
CDN, DNS, DDoS protection and security
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")){ ?>
+
+
+
+
+
+
+
+
+ "all_warnings",
+ "class" => "int-item-left",
+ "icon" => "flaticon-technology",
+ "title" => "ALL",
+ "desc" => "Clean all of them"
+ ],
+ [
+ "name" => "post_revisions",
+ "class" => "int-item-right",
+ "icon" => "flaticon-draft",
+ "title" => "Post Revisions",
+ "desc" => "Clean all post revisions"
+ ],
+ [
+ "name" => "trashed_contents",
+ "class" => "int-item-left",
+ "icon" => "flaticon-recycling",
+ "title" => "Trashed Contents",
+ "desc" => "Clean all trashed posts & pages"
+ ],
+ [
+ "name" => "trashed_spam_comments",
+ "class" => "int-item-right",
+ "icon" => "flaticon-interface",
+ "title" => "Trashed & Spam Comments",
+ "desc" => "Clean all comments from trash & spam"
+ ],
+ [
+ "name" => "trackback_pingback",
+ "class" => "int-item-left",
+ "icon" => "flaticon-pingback",
+ "title" => "Trackbacks and Pingbacks",
+ "desc" => "Clean all trackbacks and pingbacks"
+ ],
+ [
+ "name" => "transient_options",
+ "class" => "int-item-right",
+ "icon" => "flaticon-file",
+ "title" => "Transient Options",
+ "desc" => "Clean all transient options"
+ ],
+ [
+ "name" => "orphaned_post_meta",
+ "class" => "int-item-left",
+ "icon" => "flaticon-xxx",
+ "title" => "Orphaned Post Meta",
+ "desc" => "Clean all orphaned post meta"
+ ],
+ [
+ "name" => "orphaned_comment_meta",
+ "class" => "int-item-right",
+ "icon" => "flaticon-xxx",
+ "title" => "Orphaned Comment Meta",
+ "desc" => "Clean all orphaned comment meta"
+ ],
+ [
+ "name" => "orphaned_user_meta",
+ "class" => "int-item-left",
+ "icon" => "flaticon-user",
+ "title" => "Orphaned User Meta",
+ "desc" => "Clean all orphaned user meta"
+ ],
+ [
+ "name" => "orphaned_term_meta",
+ "class" => "int-item-right",
+ "icon" => "flaticon-tag",
+ "title" => "Orphaned Term Meta",
+ "desc" => "Clean all orphaned term meta"
+ ],
+ [
+ "name" => "orphaned_term_relationships",
+ "class" => "int-item-left",
+ "icon" => "flaticon-connection",
+ "title" => "Orphaned Term Relationships",
+ "desc" => "Clean all orphaned term relationships"
+ ]
+ ];
+
+
+ foreach ($items as $item) {
+ echo '
+
+
+
+
+
'.$item['title'].' (0)
+
'.$item['desc'].'
+
+
+
';
+ }
+ ?>
+
+
+
+
+
+
+
+
+
+ options->wpFastestCacheStatus)){
+ if(isset($_SERVER["HTTP_CDN_LOOP"]) && $_SERVER["HTTP_CDN_LOOP"] && $_SERVER["HTTP_CDN_LOOP"] == "cloudflare"){
+ $cloudflare_integration_exist = false;
+ $cdn_values = get_option("WpFastestCacheCDN");
+
+ if($cdn_values){
+ $std_obj = json_decode($cdn_values);
+
+ foreach($std_obj as $key => $value){
+ if($value->id == "cloudflare"){
+ $cloudflare_integration_exist = true;
+ break;
+ }
+ }
+ }
+
+ if(!$cloudflare_integration_exist){
+ include_once(WPFC_MAIN_PATH."templates/cloudflare_warning.html");
+ }
+ }
+ }
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ check_htaccess();
+ }
+ }
+ }
+ }
+?>
\ No newline at end of file
diff --git a/wp-content/plugins/wp-fastest-cache/inc/cache.php b/wp-content/plugins/wp-fastest-cache/inc/cache.php
new file mode 100644
index 00000000..44a99b64
--- /dev/null
+++ b/wp-content/plugins/wp-fastest-cache/inc/cache.php
@@ -0,0 +1,1445 @@
+preload_user_agent = true;
+ }else{
+ $this->preload_user_agent = false;
+ }
+
+
+ $this->options = $this->getOptions();
+
+ $this->set_cdn();
+
+ $this->set_cache_file_path();
+
+ $this->set_exclude_rules();
+
+ if(isset($this->options->wpFastestCacheDisableEmojis) && $this->options->wpFastestCacheDisableEmojis){
+ add_action('init', array($this, 'disable_emojis'));
+ }
+ }
+
+ public function disable_emojis(){
+ remove_action('wp_head', 'print_emoji_detection_script', 7);
+ remove_action('admin_print_scripts', 'print_emoji_detection_script');
+ remove_filter('the_content_feed', 'wp_staticize_emoji');
+ remove_filter('comment_text_rss', 'wp_staticize_emoji');
+ remove_action('wp_print_styles', 'print_emoji_styles');
+ remove_action('admin_print_styles', 'print_emoji_styles');
+ remove_filter('wp_mail', 'wp_staticize_emoji_for_email');
+ // remove the DNS prefetch
+ add_filter('emoji_svg_url', '__return_false');
+ }
+
+ public function detect_current_page_type(){
+ if(preg_match("/\?/", $_SERVER["REQUEST_URI"])){
+ return true;
+ }
+
+ if(preg_match("/^\/wp-json/", $_SERVER["REQUEST_URI"])){
+ return true;
+ }
+
+ if(is_front_page()){
+ echo "";
+ }else if(is_category()){
+ echo "";
+ }else if(is_tag()){
+ echo "";
+ }else if(is_singular('post')){
+ echo "";
+ }else if(is_page()){
+ echo "";
+ }else if(is_attachment()){
+ echo "";
+ }else if(is_archive()){
+ echo "";
+ }
+ }
+
+ public function set_exclude_rules(){
+ if($json_data = get_option("WpFastestCacheExclude")){
+ $this->exclude_rules = json_decode($json_data);
+ }
+ }
+
+ public function set_cache_file_path(){
+ $type = "all";
+
+ if($this->isMobile() && isset($this->options->wpFastestCacheMobile)){
+ if(class_exists("WpFcMobileCache") && isset($this->options->wpFastestCacheMobileTheme)){
+ $type = "wpfc-mobile-cache";
+ }
+ }
+
+ if($this->isPluginActive('gtranslate/gtranslate.php')){
+ if(isset($_SERVER["HTTP_X_GT_LANG"])){
+ $this->cacheFilePath = $this->getWpContentDir("/cache/".$type."/").$_SERVER["HTTP_X_GT_LANG"].$_SERVER["REQUEST_URI"];
+ }else if(isset($_SERVER["REDIRECT_URL"]) && $_SERVER["REDIRECT_URL"] != "/index.php"){
+ $redirect_url = $_SERVER["REDIRECT_URL"];
+
+ if(isset($_SERVER["REDIRECT_QUERY_STRING"]) && defined('WPFC_CACHE_QUERYSTRING') && WPFC_CACHE_QUERYSTRING){
+ $redirect_url .= "?".$_SERVER["REDIRECT_QUERY_STRING"];
+ }
+
+ $this->cacheFilePath = $this->getWpContentDir("/cache/" . $type . "/") . $redirect_url;
+ }else if(isset($_SERVER["REQUEST_URI"])){
+ $this->cacheFilePath = $this->getWpContentDir("/cache/".$type."/").$_SERVER["REQUEST_URI"];
+ }
+ }else{
+ $this->cacheFilePath = $this->getWpContentDir("/cache/".$type."/").$_SERVER["REQUEST_URI"];
+
+ // for /?s=
+ $this->cacheFilePath = preg_replace("/(\/\?s\=)/", "$1/", $this->cacheFilePath);
+ }
+
+
+ $this->cacheFilePath = $this->cacheFilePath ? rtrim($this->cacheFilePath, "/")."/" : "";
+
+ /*
+ /public_html/wp-content/cache/all/sample-page
+ */
+ $this->cacheFilePath = preg_replace("/\/cache\/(all|wpfc-mobile-cache)\/\//", "/cache/$1/", $this->cacheFilePath);
+
+ /*
+ /public_html/wp-content/cache/all/DOMAIN.COM/sample-page
+ */
+ $this->cacheFilePath = preg_replace("/\/cache\/([^\/]+)\/(all|wpfc-mobile-cache)\/\//", "/cache/$1/$2/", $this->cacheFilePath);
+
+
+ if(strlen($_SERVER["REQUEST_URI"]) > 1){ // for the sub-pages
+ if(!preg_match("/\.(html|xml)/i", $_SERVER["REQUEST_URI"])){
+ if($this->is_trailing_slash()){
+ if(!preg_match("/\/$/", $_SERVER["REQUEST_URI"])){
+ if(isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] && defined('WPFC_CACHE_QUERYSTRING') && WPFC_CACHE_QUERYSTRING){
+
+ }else if(preg_match("/y(ad|s)?clid\=/i", $this->cacheFilePath)){
+ // yclid
+ // yadclid
+ // ysclid
+ }else if(preg_match("/gclid\=/i", $this->cacheFilePath)){
+
+ }else if(preg_match("/fbclid\=/i", $this->cacheFilePath)){
+
+ }else if(preg_match("/utm_(source|medium|campaign|content|term)/i", $this->cacheFilePath)){
+
+ }else if(preg_match("/srsltid\=/i", $this->cacheFilePath)){
+
+ }else{
+ $this->cacheFilePath = false;
+ }
+ }
+ }else{
+ //toDo
+ }
+ }
+ }
+
+ $this->remove_url_paramters();
+
+ $this->cacheFilePath = trim($this->cacheFilePath);
+
+ // to decode path if it is not utf-8
+ if($this->cacheFilePath){
+ $this->cacheFilePath = urldecode($this->cacheFilePath);
+ }
+
+ // for security
+ if(preg_match("/\.{2,}/", $this->cacheFilePath)){
+ $this->cacheFilePath = false;
+ }
+
+ if(preg_match("/\/{2,}/", $this->cacheFilePath)){
+ $this->cacheFilePath = false;
+ }
+
+ if($this->cacheFilePath == "/"){
+ $this->cacheFilePath = false;
+ }
+
+ if($this->isMobile()){
+ if(isset($this->options->wpFastestCacheMobile)){
+ if(!class_exists("WpFcMobileCache")){
+ $this->cacheFilePath = false;
+ }else{
+ if(!isset($this->options->wpFastestCacheMobileTheme)){
+ $this->cacheFilePath = false;
+ }
+ }
+ }
+ }
+ }
+
+ public function remove_url_paramters(){
+ if(isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"]){
+
+ $query_params = explode("&", $_SERVER["QUERY_STRING"]);
+
+ $action = true;
+
+ foreach ($query_params as $key => $query_param) {
+
+ // Google Ads Click & Conversion Parameters
+ if(preg_match("/^(gclid|gbraid|wbraid|gclsrc)\=/i", $query_param)){
+ continue;
+ }
+
+ // Google Analytics / GA4 Parameters
+ if(preg_match("/^(_ga|_gid|_gl|_gac)\=/i", $query_param)){
+ continue;
+ }
+
+ // Google UTM Campaign Parameters
+ if(preg_match("/^utm_(source|medium|campaign|content|term)/i", $query_param)){
+ continue;
+ }
+
+ // Google Merchant Center
+ if(preg_match("/^srsltid\=/i", $query_param)){
+ continue;
+ }
+
+ //to remove query strings for cache if Yandex parameters are set
+ if(preg_match("/^y(ad|s)?clid\=/i", $query_param)){
+ // yclid
+ // yadclid
+ // ysclid
+
+ continue;
+ }
+
+ //to remove query strings for cache if facebook parameters are set
+ if(preg_match("/^fbclid\=/i", $query_param)){
+ continue;
+ }
+
+ $action = false;
+
+ }
+
+ if($action){
+ if(strlen($_SERVER["REQUEST_URI"]) > 1){ // for the sub-pages
+
+ $this->cacheFilePath = preg_replace("/\/*\?.+/", "", $this->cacheFilePath);
+ $this->cacheFilePath = $this->cacheFilePath."/";
+
+ if(!defined('WPFC_CACHE_QUERYSTRING')){
+ define('WPFC_CACHE_QUERYSTRING', true);
+ }
+ }
+ }
+ }
+
+ }
+
+ public function set_cdn(){
+ $cdn_values = get_option("WpFastestCacheCDN");
+ if($cdn_values){
+ $std_obj = json_decode($cdn_values);
+ $arr = array();
+
+ if(is_array($std_obj)){
+ $arr = $std_obj;
+ }else{
+ array_push($arr, $std_obj);
+ }
+
+ foreach ($arr as $key => &$std) {
+ $std->originurl = trim($std->originurl);
+ $std->originurl = trim($std->originurl, "/");
+ $std->originurl = preg_replace("/http(s?)\:\/\/(www\.)?/i", "", $std->originurl);
+
+ $std->cdnurl = trim($std->cdnurl);
+ $std->cdnurl = trim($std->cdnurl, "/");
+
+ if(!preg_match("/https\:\/\//", $std->cdnurl)){
+ $std->cdnurl = "//".preg_replace("/http(s?)\:\/\/(www\.)?/i", "", $std->cdnurl);
+ }
+ }
+
+ $this->cdn = $arr;
+ }
+ }
+
+ public function checkShortCode($content){
+ if(preg_match("/\[wpfcNOT\]/", $content)){
+ if(!is_home() || !is_archive()){
+ $this->blockCache = true;
+ }
+ $content = str_replace("[wpfcNOT]", "", $content);
+ }
+ return $content;
+ }
+
+ public function createCache(){
+ if(isset($this->options->wpFastestCacheStatus)){
+
+ // to exclude static pdf files
+ if(preg_match("/\.pdf$/i", $_SERVER["REQUEST_URI"])){
+ return 0;
+ }
+
+ // to check logged-in user
+ if(isset($this->options->wpFastestCacheLoggedInUser) && $this->options->wpFastestCacheLoggedInUser == "on"){
+ foreach ((array)$_COOKIE as $cookie_key => $cookie_value){
+ if(preg_match("/wordpress_logged_in/i", $cookie_key)){
+ ob_start(array($this, "cdn_rewrite"));
+
+ return 0;
+ }
+ }
+ }
+
+ // to exclude admin users
+ if($this->is_user_admin()){
+ return 0;
+ }
+
+ // to check comment author
+ foreach ((array)$_COOKIE as $cookie_key => $cookie_value){
+ if(preg_match("/comment_author_/i", $cookie_key)){
+ ob_start(array($this, "cdn_rewrite"));
+
+ return 0;
+ }
+ }
+
+ if(isset($_COOKIE) && isset($_COOKIE['safirmobilswitcher'])){
+ ob_start(array($this, "cdn_rewrite"));
+
+ return 0;
+ }
+
+ if(isset($_COOKIE) && isset($_COOKIE["wptouch-pro-view"])){
+ if($this->is_wptouch_smartphone()){
+ if($_COOKIE["wptouch-pro-view"] == "desktop"){
+ ob_start(array($this, "cdn_rewrite"));
+
+ return 0;
+ }
+ }
+ }
+
+ if(preg_match("/\?/", $_SERVER["REQUEST_URI"]) && !preg_match("/\/\?fdx\_switcher\=true/", $_SERVER["REQUEST_URI"])){ // for WP Mobile Edition
+ if(preg_match("/\?amp(\=1)?/i", $_SERVER["REQUEST_URI"])){
+ //
+ }else if(defined('WPFC_CACHE_QUERYSTRING') && WPFC_CACHE_QUERYSTRING){
+ //
+ }else if(isset($_GET["wc-api"]) && $_GET["wc-api"]){
+ //
+ }else{
+ ob_start(array($this, "cdn_rewrite"));
+
+ return 0;
+ }
+ }
+
+ if(preg_match("/(".$this->get_excluded_useragent().")/", $_SERVER['HTTP_USER_AGENT'])){
+ return 0;
+ }
+
+ if(isset($_SERVER['REQUEST_URI']) && preg_match("/(\/){2}$/", $_SERVER['REQUEST_URI'])){
+ return 0;
+ }
+
+ // to check permalink if it does not end with slash
+ if(isset($_SERVER['REQUEST_URI']) && preg_match("/[^\/]+\/$/", $_SERVER['REQUEST_URI'])){
+ if(!preg_match("/\/$/", get_option('permalink_structure'))){
+ return 0;
+ }
+ }
+
+ if(isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == "POST"){
+ return 0;
+ }
+
+ if(preg_match("/^https/i", get_option("home")) && !is_ssl()){
+ //Must be secure connection
+ return 0;
+ }
+
+ if(!preg_match("/^https/i", get_option("home")) && is_ssl()){
+ //must be normal connection
+ if(!$this->isPluginActive('really-simple-ssl/rlrsssl-really-simple-ssl.php')){
+ if(!$this->isPluginActive('really-simple-ssl-pro/really-simple-ssl-pro.php')){
+ if(!$this->isPluginActive('really-simple-ssl-on-specific-pages/really-simple-ssl-on-specific-pages.php')){
+ if(!$this->isPluginActive('ssl-insecure-content-fixer/ssl-insecure-content-fixer.php')){
+ if(!$this->isPluginActive('https-redirection/https-redirection.php')){
+ if(!$this->isPluginActive('better-wp-security/better-wp-security.php')){
+ return 0;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if(isset($_SERVER["DOCUMENT_ROOT"]) && preg_match("/bitnami/", $_SERVER["DOCUMENT_ROOT"])){
+ // to disable cache for the IP based urls on the bitnami servers
+ // /opt/bitnami/apps/wordpress/htdocs
+ if(preg_match("/(?:[0-9]{1,3}\.){3}[0-9]{1,3}/", get_option("home"))){
+ return 0;
+ }
+ }
+
+ if(preg_match("/www\./i", get_option("home")) && !preg_match("/www\./i", $_SERVER['HTTP_HOST'])){
+ return 0;
+ }
+
+ if(!preg_match("/www\./i", get_option("home")) && preg_match("/www\./i", $_SERVER['HTTP_HOST'])){
+ return 0;
+ }
+
+ if($this->exclude_page()){
+ ob_start(array($this, "cdn_rewrite"));
+
+ //echo ""."\n";
+ return 0;
+ }
+
+ // http://mobiledetect.net/ does not contain the following user-agents
+ if(preg_match("/Nokia309|Casper_VIA/i", $_SERVER['HTTP_USER_AGENT'])){
+ return 0;
+ }
+
+ if(preg_match("/Empty\sUser\sAgent/i", $_SERVER['HTTP_USER_AGENT'])){ // not to show the cache for command line
+ return 0;
+ }
+
+
+ //to show cache version via php if htaccess rewrite rule does not work
+ if(!$this->preload_user_agent && $this->cacheFilePath && (@file_exists($this->cacheFilePath."index.html") || @file_exists($this->cacheFilePath."index.json") || @file_exists($this->cacheFilePath."index.xml"))){
+
+ $via_php = "";
+ if(@file_exists($this->cacheFilePath."index.json")){
+ $file_extension = "json";
+
+ header('Content-type: application/json');
+ }else if(@file_exists($this->cacheFilePath."index.xml")){
+ $file_extension = "xml";
+
+ header('Content-type: text/xml');
+ }else{
+ $file_extension = "html";
+ $via_php = "";
+ }
+
+ if($content = @file_get_contents($this->cacheFilePath."index.".$file_extension)){
+
+ if($file_extension == "html"){
+ header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($this->cacheFilePath."index.".$file_extension)).' GMT', true, 200);
+ }
+
+
+ if(defined('WPFC_REMOVE_VIA_FOOTER_COMMENT') && WPFC_REMOVE_VIA_FOOTER_COMMENT){
+ $via_php = "";
+ }
+
+ $content = $content.$via_php;
+
+ die($content);
+ }
+ }else{
+ if($this->isMobile()){
+ if(class_exists("WpFcMobileCache") && isset($this->options->wpFastestCacheMobileTheme)){
+ if(isset($this->options->wpFastestCacheMobileTheme_themename) && $this->options->wpFastestCacheMobileTheme_themename){
+ $create_cache = true;
+ }else if($this->isPluginActive('wptouch/wptouch.php') || $this->isPluginActive('wptouch-pro/wptouch-pro.php')){
+ //to check that user-agent exists in wp-touch's list or not
+ if($this->is_wptouch_smartphone()){
+ $create_cache = true;
+ }else{
+ $create_cache = false;
+ }
+ }else{
+ if((preg_match('/iPhone/', $_SERVER['HTTP_USER_AGENT']) && preg_match('/Mobile/', $_SERVER['HTTP_USER_AGENT'])) || (preg_match('/Android/', $_SERVER['HTTP_USER_AGENT']) && preg_match('/Mobile/', $_SERVER['HTTP_USER_AGENT']))){
+ $create_cache = true;
+ }else{
+ $create_cache = false;
+ }
+ }
+ }else if(!isset($this->options->wpFastestCacheMobile) && !isset($this->options->wpFastestCacheMobileTheme)){
+ $create_cache = true;
+ }else{
+ $create_cache = false;
+ }
+ }else{
+ $create_cache = true;
+ }
+
+ if($create_cache){
+ $this->startTime = microtime(true);
+
+
+ add_action('wp', array($this, "detect_current_page_type"));
+ add_action('get_footer', array($this, "detect_current_page_type"));
+ add_action('get_footer', array($this, "wp_print_scripts_action"));
+
+ // to exclude current page hook
+ add_action("wpfc_exclude_current_page", array($this, 'exclude_current_page'), 10, 0);
+
+ ob_start(array($this, "callback"));
+ }
+ }
+ }
+ }
+
+ public function is_user_admin(){
+ global $wpdb;
+
+ foreach ((array)$_COOKIE as $cookie_key => $cookie_value){
+ if(preg_match("/wordpress_logged_in/i", $cookie_key)){
+ $username = preg_replace("/^([^\|]+)\|.+/", "$1", $cookie_value);
+ break;
+ }
+ }
+
+ if(isset($username) && $username){
+ $username = esc_sql($username);
+
+ $res = $wpdb->get_var("SELECT `$wpdb->users`.`ID`, `$wpdb->users`.`user_login`, `$wpdb->usermeta`.`meta_key`, `$wpdb->usermeta`.`meta_value`
+ FROM `$wpdb->users`
+ INNER JOIN `$wpdb->usermeta`
+ ON `$wpdb->users`.`user_login` = \"$username\" AND
+ `$wpdb->usermeta`.`meta_key` LIKE \"%_user_level\" AND
+ `$wpdb->usermeta`.`meta_value` = \"10\" AND
+ `$wpdb->users`.`ID` = `$wpdb->usermeta`.user_id ;"
+ );
+
+ return $res;
+ }
+
+ return false;
+ }
+
+ public function exclude_current_page($some = true){
+ $via = debug_backtrace();
+
+ if(isset($via) && is_array($via)){
+ foreach ($via as $key => $value){
+ if($value["function"] == "wpfc_exclude_current_page"){
+
+ if(defined('WPFC_DEBUG') && (WPFC_DEBUG === true)){
+ if(preg_match("/wp-content\/themes/", $value["file"])){
+ $this->exclude_current_page_text = "";
+ }else if(preg_match("/wp-content\/plugins/", $value["file"])){
+ $this->exclude_current_page_text = "";
+ }
+ }else{
+ $this->exclude_current_page_text = "";
+ }
+
+ break;
+ }
+ }
+ }
+ }
+
+ public function wp_print_scripts_action(){
+ echo "";
+ }
+
+ public function ignored($buffer){
+ $list = array(
+ "\/wp\-comments\-post\.php",
+ "\/wp\-login\.php",
+ "\/robots\.txt",
+ "\/wp\-cron\.php",
+ "\/wp\-content",
+ "\/wp\-admin",
+ "\/wp\-includes",
+ "\/index\.php",
+ "\/xmlrpc\.php",
+ "\/wp\-api\/",
+ "leaflet\-geojson\.php",
+ "\/clientarea\.php"
+ );
+ if($this->isPluginActive('woocommerce/woocommerce.php')){
+ if($this->current_page_type != "homepage"){
+ global $post;
+
+ if(isset($post->ID) && $post->ID){
+ if(function_exists("wc_get_page_id")){
+ $woocommerce_ids = array();
+
+ //wc_get_page_id('product')
+ //wc_get_page_id('product-category')
+
+ array_push($woocommerce_ids, wc_get_page_id('cart'), wc_get_page_id('checkout'), wc_get_page_id('receipt'), wc_get_page_id('confirmation'), wc_get_page_id('myaccount'));
+
+ if (in_array($post->ID, $woocommerce_ids)) {
+ return true;
+ }
+ }
+ }
+
+ //"\/product"
+ //"\/product-category"
+
+ array_push($list, "\/cart\/?$", "\/checkout", "\/receipt", "\/confirmation", "\/wc-api\/");
+ }
+ }
+
+ if($this->isPluginActive('wp-easycart/wpeasycart.php')){
+ array_push($list, "\/cart");
+ }
+
+ if($this->isPluginActive('easy-digital-downloads/easy-digital-downloads.php')){
+ array_push($list, "\/cart", "\/checkout");
+ }
+
+ if(preg_match("/".implode("|", $list)."/i", $_SERVER["REQUEST_URI"])){
+ return true;
+ }
+
+ return false;
+ }
+
+ public function exclude_page($buffer = false){
+ $preg_match_rule = "";
+ //$request_url = urldecode(trim($_SERVER["REQUEST_URI"], "/"));
+ $request_url = urldecode($_SERVER["REQUEST_URI"]);
+
+ if($this->exclude_rules){
+
+ foreach((array)$this->exclude_rules as $key => $value){
+ $value->type = isset($value->type) ? $value->type : "page";
+
+ if($value->prefix == "yandexclickid"){
+ if(preg_match("/y(ad|s)?clid\=/i", $request_url)){
+ // yclid
+ // yadclid
+ // ysclid
+
+ return true;
+ }
+ }else if($value->prefix == "googleanalytics"){
+ if(preg_match("/utm_(source|medium|campaign|content|term)/i", $request_url)){
+ return true;
+ }
+ }else if(isset($value->prefix) && $value->prefix && ($value->type == "page")){
+ $value->content = trim($value->content);
+ //$value->content = trim($value->content, "/");
+
+ if($buffer && preg_match("/^(homepage|category|tag|post|page|archive|attachment)$/", $value->prefix)){
+ if(preg_match('/<\!--WPFC_PAGE_TYPE_'.$value->prefix.'-->/i', $buffer)){
+ return true;
+ }
+ }else if($value->prefix == "exact"){
+ $request_url = trim($request_url, "/");
+ $value->content = trim($value->content, "/");
+
+ if(strtolower($value->content) == strtolower($request_url)){
+ return true;
+ }
+ }else if($value->prefix == "regex"){
+ if(preg_match("/".$value->content."/i", $request_url)){
+ return true;
+ }
+ }else{
+ if($value->prefix == "startwith"){
+ $request_url = ltrim($request_url, "/");
+ $value->content = ltrim($value->content, "/");
+
+ $preg_match_rule = "^".preg_quote($value->content, "/");
+ }else if($value->prefix == "contain"){
+ $preg_match_rule = preg_quote($value->content, "/");
+ }
+
+ if($preg_match_rule){
+ if(preg_match("/".$preg_match_rule."/i", $request_url)){
+ return true;
+ }
+ }
+ }
+ }else if($value->type == "useragent"){
+ if(preg_match("/".preg_quote($value->content, "/")."/i", $_SERVER['HTTP_USER_AGENT'])){
+ return true;
+ }
+ }else if($value->type == "cookie"){
+ if(isset($_SERVER['HTTP_COOKIE'])){
+ if(preg_match("/".preg_quote($value->content, "/")."/i", $_SERVER['HTTP_COOKIE'])){
+ return true;
+ }
+ }
+ }
+ }
+
+ }
+ return false;
+ }
+
+ public function is_json(){
+ return $this->current_page_content_type == "json" ? true : false;
+
+ // if(isset($_SERVER["HTTP_ACCEPT"]) && preg_match("/json/i", $_SERVER["HTTP_ACCEPT"])){
+ // return true;
+ // }
+
+ // if(preg_match("/^\/wp-json/", $_SERVER["REQUEST_URI"])){
+ // return true;
+ // }
+
+ // if(preg_match("/^\s*\{\s*[\"\']/i", $buffer)){
+ // return true;
+ // }
+
+ // if(preg_match("/^\s*\[\s*\{\s*[\"\']/i", $buffer)){
+ // return true;
+ // }
+
+ // return false;
+ }
+
+ public function is_xml(){
+ return $this->current_page_content_type == "xml" ? true : false;
+
+ // if(preg_match("/^\s*\<\?xml/i", $buffer)){
+ // return true;
+ // }
+ // return false;
+ }
+
+ public function is_html(){
+ return $this->current_page_content_type == "html" ? true : false;
+ }
+
+ public function set_current_page_type($buffer){
+ preg_match('/<\!--WPFC_PAGE_TYPE_([a-z]+)-->/i', $buffer, $out);
+
+ $this->current_page_type = isset($out[1]) ? $out[1] : false;
+ }
+
+ public function set_current_page_content_type($buffer){
+ $content_type = false;
+ if(function_exists("headers_list")){
+ $headers = headers_list();
+ foreach($headers as $header){
+ if(preg_match("/Content-Type\:/i", $header)){
+ $content_type = preg_replace("/Content-Type\:\s(.+)/i", "$1", $header);
+ }
+ }
+ }
+
+ if(preg_match("/xml/i", $content_type)){
+ $this->current_page_content_type = "xml";
+ }else if(preg_match("/json/i", $content_type)){
+ $this->current_page_content_type = "json";
+ }else{
+ $this->current_page_content_type = "html";
+ }
+ }
+
+ public function last_error($buffer = false){
+ if(function_exists("http_response_code") && (http_response_code() === 404)){
+ return true;
+ }
+
+ if(is_404()){
+ return true;
+ }
+
+ //to exclude "There has been a critical error on this website" page
+ if(preg_match("/\s*
/i", $buffer)){
+ return true;
+ }
+ }
+
+ public function callback($buffer){
+ $this->set_current_page_type($buffer);
+ $this->set_current_page_content_type($buffer);
+
+ $buffer = $this->checkShortCode($buffer);
+
+ // for Wordfence: not to cache 503 pages
+ if(defined('DONOTCACHEPAGE') && $this->isPluginActive('wordfence/wordfence.php')){
+ if(function_exists("http_response_code") && http_response_code() == 503){
+ return $buffer."";
+ }
+ }
+
+ // Prevent caching of 403 Forbidden error pages.
+ // This is particularly important for compatibility with the following security plugins:
+ // 1. iThemes Security
+ // 2. Defender Security
+ if(defined('DONOTCACHEPAGE')){
+ if(function_exists("http_response_code") && http_response_code() == 403){
+ return $buffer."";
+ }
+ }
+
+ // for Divi Theme
+ if(defined('DONOTCACHEPAGE') && (get_template() == "Divi")){
+ if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
+ // /?wc-ajax=dgwt_wcas_ajax_search&s=keyword&l=en
+ return $buffer;
+ }
+
+ return $buffer."";
+ }
+
+
+ if($this->exclude_page($buffer)){
+ $buffer = preg_replace('/<\!--WPFC_PAGE_TYPE_[a-z]+-->/i', '', $buffer);
+
+ $buffer = $this->cdn_rewrite($buffer);
+
+ return $buffer;
+ }
+
+ $buffer = preg_replace('/<\!--WPFC_PAGE_TYPE_[a-z]+-->/i', '', $buffer);
+
+
+ if($this->is_html()){
+ $tmp_buffer = (string) apply_filters('wpfc_buffer_callback_filter', $buffer, "html", $this->cacheFilePath);
+
+ if(!$tmp_buffer){
+ return $buffer;
+ }else{
+ $buffer = $tmp_buffer;
+ }
+ }
+
+
+ if($this->exclude_current_page_text){
+ return $buffer.$this->exclude_current_page_text;
+ }else if($this->is_json() && (!defined('WPFC_CACHE_JSON') || (defined('WPFC_CACHE_JSON') && WPFC_CACHE_JSON !== true))){
+ return $buffer;
+ }else if(preg_match("/Mediapartners-Google|Google\sWireless\sTranscoder/i", $_SERVER['HTTP_USER_AGENT'])){
+ return $buffer;
+ }else if (is_user_logged_in() || $this->isCommenter()){
+ return $buffer;
+ }else if($this->isPasswordProtected($buffer)){
+ return $buffer."";
+ }else if($this->isWpLogin($buffer)){
+ return $buffer."";
+ }else if($this->hasContactForm7WithCaptcha($buffer)){
+ return $buffer."";
+ }else if($this->last_error($buffer)){
+ return $buffer;
+ }else if($this->ignored($buffer)){
+ return $buffer;
+ }else if($this->blockCache === true){
+ return $buffer."";
+ }else if(isset($_GET["preview"])){
+ return $buffer."";
+ }else if($this->checkHtml($buffer)){
+ if(preg_match("/^.*$/s", $buffer)){
+ // Check if the buffer has only one line (no line breaks)
+ return $buffer;
+ }else{
+ return $buffer."";
+ }
+ }else if((function_exists("http_response_code")) && (http_response_code() == 301 || http_response_code() == 302)){
+ return $buffer;
+ }else if(!$this->cacheFilePath){
+ return $buffer."";
+ }else{
+ $content = $buffer;
+
+ if(isset($this->options->wpFastestCacheDelayJS) && method_exists("WpFastestCachePowerfulHtml", "render_blocking")){
+ if(file_exists(WPFC_WP_PLUGIN_DIR."/wp-fastest-cache-premium/pro/library/delay-js.php")){
+ if(!$this->is_amp($content)){
+ include_once WPFC_WP_PLUGIN_DIR."/wp-fastest-cache-premium/pro/library/delay-js.php";
+ $delay = new WpFastestCacheDelayJS($content);
+ $content = $delay->action();
+ }
+ }
+ }
+
+ if(isset($this->options->wpFastestCacheRenderBlocking) && method_exists("WpFastestCachePowerfulHtml", "render_blocking")){
+ if(class_exists("WpFastestCachePowerfulHtml")){
+ if(!$this->is_amp($content)){
+ $powerful_html = new WpFastestCachePowerfulHtml();
+
+ if(isset($this->options->wpFastestCacheRenderBlockingCss)){
+ $content = $powerful_html->render_blocking($content, true);
+ }else{
+ $content = $powerful_html->render_blocking($content);
+ }
+ }
+ }
+ }
+
+ if(isset($this->options->wpFastestCacheCombineCss)){
+ require_once "css-utilities.php";
+ $css = new CssUtilities($this, $content);
+ $content = $css->combineCss();
+ unset($css);
+ }else if(isset($this->options->wpFastestCacheMinifyCss)){
+ require_once "css-utilities.php";
+ $css = new CssUtilities($this, $content);
+ $content = $css->minifyCss();
+ unset($css);
+ }
+
+ if(isset($this->options->wpFastestCacheCombineJs) || isset($this->options->wpFastestCacheMinifyJs) || isset($this->options->wpFastestCacheCombineJsPowerFul)){
+ require_once "js-utilities.php";
+ }
+
+ if(isset($this->options->wpFastestCacheCombineJs)){
+
+ $head_new = $this->get_header($content);
+
+ if($head_new){
+ if(isset($this->options->wpFastestCacheMinifyJs) && $this->options->wpFastestCacheMinifyJs){
+ $js = new JsUtilities($this, $head_new, true);
+ }else{
+ $js = new JsUtilities($this, $head_new);
+ }
+
+ $tmp_head = $js->combine_js();
+
+ $content = str_replace($head_new, $tmp_head, $content);
+
+ unset($r);
+ unset($js);
+ unset($tmp_head);
+ unset($head_new);
+ }
+ }
+
+ if(class_exists("WpFastestCachePowerfulHtml")){
+ if(!isset($powerful_html)){
+ $powerful_html = new WpFastestCachePowerfulHtml();
+ }
+
+ $powerful_html->set_html($content);
+
+ if(isset($this->options->wpFastestCacheCombineJsPowerFul) && method_exists("WpFastestCachePowerfulHtml", "combine_js_in_footer")){
+ if(isset($this->options->wpFastestCacheMinifyJs) && $this->options->wpFastestCacheMinifyJs){
+ $content = $powerful_html->combine_js_in_footer($this, true);
+ }else{
+ $content = $powerful_html->combine_js_in_footer($this);
+ }
+ }
+
+ if(isset($this->options->wpFastestCacheRemoveComments)){
+ $content = $powerful_html->remove_head_comments();
+ }
+
+ if(isset($this->options->wpFastestCacheMinifyHtmlPowerFul)){
+ $content = $powerful_html->minify_html();
+ }
+
+ if(isset($this->options->wpFastestCacheMinifyJs) && method_exists("WpFastestCachePowerfulHtml", "minify_js_in_body")){
+ $content = $powerful_html->minify_js_in_body($this, $this->exclude_rules);
+ }
+ }
+
+ if($this->err){
+ return $buffer."";
+ }else{
+ $content = $this->cacheDate($content);
+ $content = $this->minify($content);
+ $content = str_replace("", "", $content);
+
+
+ if(isset($this->options->wpFastestCacheLazyLoad) && class_exists("WpFastestCachePowerfulHtml")){
+ $execute_lazy_load = true;
+
+ // to disable Lazy Load if the page is amp
+ if($this->is_amp($content)){
+ $execute_lazy_load = false;
+ }
+
+ // to disable for Ajax Load More on the pages
+ if($this->isPluginActive('ajax-load-more/ajax-load-more.php') && preg_match("/\/page\/\d+\//", $_SERVER["REQUEST_URI"])){
+ $execute_lazy_load = false;
+ }
+
+ if($execute_lazy_load){
+ if(!class_exists("WpFastestCacheLazyLoad")){
+ include_once $this->get_premium_path("lazy-load.php");
+ }
+
+ $content = $powerful_html->lazy_load($content);
+
+ if(method_exists("WpFastestCacheLazyLoad",'get_js_source_new')){
+ $lazy_load_js = WpFastestCacheLazyLoad::get_js_source_new();
+ }else if(method_exists("WpFastestCacheLazyLoad",'get_js_source')){
+ $lazy_load_js = WpFastestCacheLazyLoad::get_js_source();
+ }
+
+ $content = preg_replace("/\s*<\/head\s*>/i", $lazy_load_js."", $content, 1);
+ }
+ }
+
+ $content = $this->cdn_rewrite($content);
+
+ $content = $this->fix_pre_tag($content, $buffer);
+
+ if(preg_match("/
]+href\s*\=\s*[\'\"][^\"\']+\.\.[\"\'][^\>]+>/", $content)){
+ /*
+ to check that resources have been successfully optimized
+
+ */
+ return $buffer."";
+ }
+
+ if($this->cacheFilePath){
+ if($this->is_html()){
+
+ $tmp_content = (string) apply_filters('wpfc_buffer_callback_filter', $content, "cache", $this->cacheFilePath);
+
+ if(!$tmp_content){
+ return $content;
+ }else{
+ $content = $tmp_content;
+ }
+
+ $this->createFolder($this->cacheFilePath, $content);
+ do_action('wpfc_is_cacheable_action');
+ }else if($this->is_xml()){
+ if(preg_match("/
<\/link>/", $buffer)){
+ if(preg_match("/\/feed$/", $_SERVER["REQUEST_URI"])){
+ return $buffer.time();
+ }
+ }
+
+ $this->createFolder($this->cacheFilePath, $buffer, "xml");
+ do_action('wpfc_is_cacheable_action');
+
+ return $buffer;
+ }else if($this->is_json()){
+ $this->createFolder($this->cacheFilePath, $buffer, "json");
+ do_action('wpfc_is_cacheable_action');
+
+ return $buffer;
+ }
+ }
+
+ return $content."";
+ }
+ }
+ }
+
+
+ public function find_tags($data, $start_string, $end_string){
+
+ $list = array();
+ $start_index = false;
+ $end_index = false;
+
+ for($i = 0; $i < strlen( $data ); $i++) {
+ if(substr($data, $i, strlen($start_string)) == $start_string){
+ $start_index = $i;
+ }
+
+ if($start_index && $i > $start_index){
+ if(substr($data, $i, strlen($end_string)) == $end_string){
+ $end_index = $i + strlen($end_string)-1;
+ $text = substr($data, $start_index, ($end_index-$start_index + 1));
+
+
+ array_push($list, array("start" => $start_index, "end" => $end_index, "text" => $text));
+
+
+ $start_index = false;
+ $end_index = false;
+ }
+ }
+ }
+
+ return $list;
+ }
+
+ public function fix_pre_tag($content, $buffer){
+
+ // Check if buffer contains any
tag
+ if(!preg_match("/]*>/i", $buffer)){
+ return $content;
+ }
+
+ // Extract blocks from buffer
+ $pre_buffer = $this->find_tags($buffer, "");
+
+ // Extract blocks from content
+ $pre_content = $this->find_tags($content, "");
+
+ // If either side has no blocks, do nothing
+ if(empty($pre_buffer) || empty($pre_content)){
+ return $content;
+ }
+
+ // Reverse the order to avoid index shifting during replacement
+ $pre_content = array_reverse($pre_content, true);
+
+ foreach ($pre_content as $key => $value){
+ if(isset($pre_buffer[$key])){
+
+ // New block that will replace the old one
+ $replace_text = $pre_buffer[$key]["text"];
+
+ // Replace the original block in the content with the buffer's block
+ $content = substr_replace(
+ $content,
+ $replace_text,
+ $value["start"],
+ ($value["end"] - $value["start"] + 1)
+ );
+ }
+ }
+
+ return $content;
+ }
+
+
+
+ public function cdn_rewrite($content){
+ if($this->cdn){
+ $content = preg_replace_callback("/(srcset|src|href|data-vc-parallax-image|data-bg|data-bg-webp|data-fullurl|data-mobileurl|data-img-url|data-cvpsrc|data-cvpset|data-thumb|data-bg-url|data-large_image|data-lazyload|data-lazy|data-source-url|data-srcsmall|data-srclarge|data-srcfull|data-slide-img|data-lazy-original)\s{0,2}\=\s{0,2}[\'\"]([^\'\"]+)[\'\"]/i", array($this, 'cdn_replace_urls'), $content);
+
+ //url()
+ $content = preg_replace_callback("/(url)\(([^\)\>]+)\)/i", array($this, 'cdn_replace_urls'), $content);
+
+ //{"concatemoji":"http:\/\/your_url.com\/wp-includes\/js\/wp-emoji-release.min.js?ver=4.7"}
+ $content = preg_replace_callback("/\{\"concatemoji\"\:\"[^\"]+\"\}/i", array($this, 'cdn_replace_urls'), $content);
+
+ //
+ $content = preg_replace_callback("/[\"\']([^\'\"]+)[\"\']\s*\:\s*[\"\']https?\:\\\\\/\\\\\/[^\"\']+[\"\']/i", array($this, 'cdn_replace_urls'), $content);
+
+ //
+ $content = preg_replace_callback("/(jsFileLocation)\s*\:[\"\']([^\"\']+)[\"\']/i", array($this, 'cdn_replace_urls'), $content);
+
+ //