Exemplo n.º 1
0
 public function __construct()
 {
     $optimize_image_ajax_requests = array("wpfc_revert_image_ajax_request", "wpfc_statics_ajax_request", "wpfc_optimize_image_ajax_request", "wpfc_update_image_list_ajax_request");
     add_action('wp_ajax_wpfc_save_timeout_pages', array($this, 'wpfc_save_timeout_pages_callback'));
     add_action('wp_ajax_wpfc_save_exclude_pages', array($this, 'wpfc_save_exclude_pages_callback'));
     add_action('wp_ajax_wpfc_cdn_options_ajax_request', array($this, 'wpfc_cdn_options_ajax_request_callback'));
     add_action('wp_ajax_wpfc_remove_cdn_integration_ajax_request', array($this, 'wpfc_remove_cdn_integration_ajax_request_callback'));
     add_action('wp_ajax_wpfc_save_cdn_integration_ajax_request', array($this, 'wpfc_save_cdn_integration_ajax_request_callback'));
     add_action('wp_ajax_wpfc_cdn_template_ajax_request', array($this, 'wpfc_cdn_template_ajax_request_callback'));
     add_action('wp_ajax_wpfc_check_url_ajax_request', array($this, 'wpfc_check_url_ajax_request_callback'));
     add_action('wp_ajax_wpfc_cache_statics_get', array($this, 'wpfc_cache_statics_get_callback'));
     add_action('wp_ajax_wpfc_update_premium', array($this, 'wpfc_update_premium_callback'));
     add_action('rate_post', array($this, 'wp_postratings_clear_fastest_cache'), 10, 2);
     if (isset($_POST) && isset($_POST["action"]) && $_POST["action"] == "vc_get_vc_grid_data") {
         if (isset($_POST["vc_post_id"]) && $_POST["vc_post_id"]) {
             if (isset($_POST["_vcnonce"]) && $_POST["_vcnonce"]) {
                 include_once ABSPATH . "wp-includes/pluggable.php";
                 if (!wp_verify_nonce($_POST["_vcnonce"], "vc-nonce-vc-public-nonce")) {
                     $uri = get_page_uri($_POST["vc_post_id"]);
                     $path = $this->getWpContentDir() . "/cache/all/" . $uri;
                     $mobile_path = $this->getWpContentDir() . "/cache/wpfc-mobile-cache/" . $uri;
                     if (is_dir($path)) {
                         $this->rm_folder_recursively($path);
                     }
                     if (is_dir($mobile_path)) {
                         $this->rm_folder_recursively($mobile_path);
                     }
                     if (get_option('page_on_front') == $_POST["vc_post_id"]) {
                         @unlink($this->getWpContentDir() . "/cache/all/index.html");
                         @unlink($this->getWpContentDir() . "/cache/wpfc-mobile-cache/index.html");
                     }
                     echo '<script>location.reload();</script>';
                 }
             }
         }
     } else {
         if (isset($_GET) && isset($_GET["action"]) && in_array($_GET["action"], $optimize_image_ajax_requests)) {
             if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                 include_once $this->get_premium_path("image.php");
                 $img = new WpFastestCacheImageOptimisation();
                 $img->hook();
             }
         } else {
             $this->setCustomInterval();
             $this->options = $this->getOptions();
             add_action('transition_post_status', array($this, 'on_all_status_transitions'), 10, 3);
             $this->commentHooks();
             $this->checkCronTime();
             register_deactivation_hook(__FILE__, array('WpFastestCache', 'deactivate'));
             if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                 include_once $this->get_premium_path("mobile-cache.php");
             }
             if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                 include_once $this->get_premium_path("powerful-html.php");
             }
             if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                 if (file_exists(WPFC_WP_PLUGIN_DIR . "/wp-fastest-cache-premium/pro/library/statics.php")) {
                     include_once $this->get_premium_path("statics.php");
                 }
             }
             if (is_admin()) {
                 //for wp-panel
                 $this->setRegularCron();
                 if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                     include_once $this->get_premium_path("image.php");
                 }
                 if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                     include_once $this->get_premium_path("logs.php");
                 }
                 add_action('wp_ajax_wpfc_cdn_template_ajax_request', array($this, 'wpfc_cdn_template_ajax_request_callback'));
                 add_action('plugins_loaded', array($this, 'wpfc_load_plugin_textdomain'));
                 $this->admin();
             } else {
                 if (preg_match("/wpfc-minified\\/([^\\/]+)\\/([^\\/]+)/", $this->current_url(), $path)) {
                     if ($sources = @scandir(WPFC_WP_CONTENT_DIR . "/cache/wpfc-minified/" . $path[1], 1)) {
                         if (isset($sources[0])) {
                             // $exist_url = str_replace($path[2], $sources[0], $this->current_url());
                             // header('Location: ' . $exist_url, true, 301);
                             // exit;
                             if (preg_match("/\\.css/", $this->current_url())) {
                                 header('Content-type: text/css');
                             } else {
                                 if (preg_match("/\\.js/", $this->current_url())) {
                                     header('Content-type: text/js');
                                 }
                             }
                             echo file_get_contents(WPFC_WP_CONTENT_DIR . "/cache/wpfc-minified/" . $path[1] . "/" . $sources[0]);
                             exit;
                         }
                     }
                 } else {
                     //for cache
                     $this->cache();
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
 public function __construct()
 {
     $optimize_image_ajax_requests = array("wpfc_revert_image_ajax_request", "wpfc_statics_ajax_request", "wpfc_optimize_image_ajax_request", "wpfc_update_image_list_ajax_request");
     if (isset($_GET) && isset($_GET["action"]) && $_GET["action"] == "wpfc_cache_statics_get") {
         if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
             if (file_exists(WPFC_WP_PLUGIN_DIR . "/wp-fastest-cache-premium/pro/library/statics.php")) {
                 include_once $this->get_premium_path("statics.php");
                 $cache_statics = new WpFastestCacheStatics();
                 $res = $cache_statics->get();
                 echo json_encode($res);
                 exit;
             }
         }
     } else {
         if (isset($_GET) && isset($_GET["action"]) && $_GET["action"] == "wpfc_download_premium") {
             $res = array();
             $response = wp_remote_get("http://api.wpfastestcache.net/premium/download/" . str_replace(array("http://", "www."), "", $_SERVER["HTTP_HOST"]) . "/" . get_option("WpFc_api_key"), array('timeout' => 10));
             if (!$response || is_wp_error($response)) {
                 $res = array("success" => false, "error_message" => $response->get_error_message());
             } else {
                 if (wp_remote_retrieve_response_code($response) == 200) {
                     $wpfc_premium_download_link = wp_remote_retrieve_body($response);
                     if ($wpfc_premium_download_link) {
                         $response_download = wp_remote_get($wpfc_premium_download_link);
                         if (!$response_download || is_wp_error($response_download)) {
                             $res = array("success" => false, "error_message" => $response_download->get_error_message());
                         } else {
                             if (wp_remote_retrieve_response_code($response_download) == 200) {
                                 if (!($wpfc_zip_data = wp_remote_retrieve_body($response_download))) {
                                     $res = array("success" => false, "error_message" => ".zip file is empty");
                                 }
                             } else {
                                 $res = array("success" => false, "error_message" => "Download Source is unavailable");
                             }
                         }
                         if ($wpfc_zip_data) {
                             $wpfc_zip_dest_path = WPFC_WP_PLUGIN_DIR . "/wp-fastest-cache-premium.zip";
                             if (@file_put_contents($wpfc_zip_dest_path, $wpfc_zip_data)) {
                                 include_once ABSPATH . "wp-admin/includes/file.php";
                                 include_once ABSPATH . "wp-admin/includes/plugin.php";
                                 if (function_exists("unzip_file")) {
                                     $this->rm_folder_recursively(WPFC_WP_PLUGIN_DIR . "/wp-fastest-cache-premium");
                                     WP_Filesystem();
                                     $unzipfile = unzip_file($wpfc_zip_dest_path, WPFC_WP_PLUGIN_DIR . "/");
                                     if ($unzipfile) {
                                         $result = activate_plugin('wp-fastest-cache-premium/wpFastestCachePremium.php');
                                         if (is_wp_error($result)) {
                                             $res = array("success" => false, "error_message" => "Error occured while the plugin was activated", "error_code" => 1);
                                         } else {
                                             $res = array("success" => true);
                                             $this->deleteCache(true);
                                         }
                                     } else {
                                         $res = array("success" => false, "error_message" => 'Error occured while the file was unzipped', "error_code" => 2);
                                     }
                                 } else {
                                     $res = array("success" => false, "error_message" => "unzip_file() is not found", "error_code" => 3);
                                 }
                             } else {
                                 $res = array("success" => false, "error_message" => "/wp-content/plugins/ is not writable", "error_code" => 4);
                             }
                         } else {
                             $res = array("success" => false, "error_message" => "Error: Service is unavailable. Try later...");
                         }
                     } else {
                         $res = array("success" => false, "error_message" => "Error: Link is empty");
                     }
                 } else {
                     $res = array("success" => false, "error_message" => "Error: Try later...");
                 }
             }
             echo json_encode($res);
             exit;
         } else {
             if (isset($_GET) && isset($_GET["action"]) && in_array($_GET["action"], $optimize_image_ajax_requests)) {
                 if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                     include_once $this->get_premium_path("image.php");
                     $img = new WpFastestCacheImageOptimisation();
                     $img->hook();
                 }
             } else {
                 $this->setCustomInterval();
                 $this->options = $this->getOptions();
                 add_action('transition_post_status', array($this, 'on_all_status_transitions'), 10, 3);
                 $this->commentHooks();
                 $this->checkCronTime();
                 register_deactivation_hook(__FILE__, array('WpFastestCache', 'deactivate'));
                 if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                     include_once $this->get_premium_path("mobile-cache.php");
                 }
                 if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                     include_once $this->get_premium_path("powerful-html.php");
                 }
                 if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                     if (file_exists(WPFC_WP_PLUGIN_DIR . "/wp-fastest-cache-premium/pro/library/statics.php")) {
                         include_once $this->get_premium_path("statics.php");
                     }
                 }
                 if (is_admin()) {
                     //for wp-panel
                     $this->setRegularCron();
                     if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                         include_once $this->get_premium_path("image.php");
                     }
                     if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                         include_once $this->get_premium_path("logs.php");
                     }
                     $this->admin();
                 } else {
                     //for cache
                     $this->cache();
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
 public function __construct()
 {
     $optimize_image_ajax_requests = array("wpfc_revert_image_ajax_request", "wpfc_statics_ajax_request", "wpfc_optimize_image_ajax_request", "wpfc_update_image_list_ajax_request");
     add_action('wp_ajax_wpfc_save_timeout_pages', array($this, 'wpfc_save_timeout_pages_callback'));
     add_action('wp_ajax_wpfc_save_exclude_pages', array($this, 'wpfc_save_exclude_pages_callback'));
     add_action('wp_ajax_wpfc_cdn_options_ajax_request', array($this, 'wpfc_cdn_options_ajax_request_callback'));
     add_action('wp_ajax_wpfc_remove_cdn_integration_ajax_request', array($this, 'wpfc_remove_cdn_integration_ajax_request_callback'));
     add_action('wp_ajax_wpfc_save_cdn_integration_ajax_request', array($this, 'wpfc_save_cdn_integration_ajax_request_callback'));
     add_action('wp_ajax_wpfc_cdn_template_ajax_request', array($this, 'wpfc_cdn_template_ajax_request_callback'));
     add_action('wp_ajax_wpfc_check_url_ajax_request', array($this, 'wpfc_check_url_ajax_request_callback'));
     add_action('wp_ajax_wpfc_cache_statics_get', array($this, 'wpfc_cache_statics_get_callback'));
     add_action('wp_ajax_wpfc_update_premium', array($this, 'wpfc_update_premium_callback'));
     add_action('rate_post', array($this, 'wp_postratings_clear_fastest_cache'), 10, 2);
     if (is_dir($this->getWpContentDir() . "/cache/tmpWpfc")) {
         $this->rm_folder_recursively($this->getWpContentDir() . "/cache/tmpWpfc");
     }
     if (isset($_POST) && isset($_POST["action"]) && $_POST["action"] == "wpestate_ajax_agent_contact_form") {
         if (isset($_POST["nonce"]) && $_POST["nonce"]) {
             //for WpResidence theme contact form
             include_once ABSPATH . "wp-includes/pluggable.php";
             foreach ($_POST as $key => &$value) {
                 if (preg_match("/nonce/", $key)) {
                     $value = wp_create_nonce('ajax-property-contact');
                 }
             }
         }
     } else {
         if (isset($_POST) && isset($_POST["action"]) && $_POST["action"] == "vc_get_vc_grid_data") {
             if (isset($_POST["vc_post_id"]) && $_POST["vc_post_id"]) {
                 if (isset($_POST["_vcnonce"]) && $_POST["_vcnonce"]) {
                     //for Visual Composer Grid-View
                     include_once ABSPATH . "wp-includes/pluggable.php";
                     foreach ($_POST as $key => &$value) {
                         if (preg_match("/_vcnonce/", $key)) {
                             $value = wp_create_nonce('vc-nonce-vc-public-nonce');
                         }
                     }
                 }
             }
         } else {
             if (isset($_POST) && isset($_POST["action"]) && $_POST["action"] == "polls") {
                 //for WP-Polls
                 include_once ABSPATH . "wp-includes/pluggable.php";
                 foreach ($_POST as $key => &$value) {
                     if (preg_match("/poll_\\d+_nonce/", $key)) {
                         $value = wp_create_nonce('poll_' . $_POST["poll_id"] . '-nonce');
                     }
                 }
             } else {
                 if (isset($_POST) && isset($_POST["action"]) && $_POST["action"] == "wpfc_wppolls_ajax_request") {
                     //for WP-Polls
                     require_once "inc/wp-polls.php";
                     $wp_polls = new WpPollsForWpFc();
                     $wp_polls->hook();
                 } else {
                     if (isset($_GET) && isset($_GET["action"]) && in_array($_GET["action"], $optimize_image_ajax_requests)) {
                         if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                             include_once $this->get_premium_path("image.php");
                             $img = new WpFastestCacheImageOptimisation();
                             $img->hook();
                         }
                     } else {
                         if (isset($_GET) && isset($_GET["action"]) && $_GET["action"] == "wpfastestcache") {
                             if (isset($_GET) && isset($_GET["type"]) && $_GET["type"] == "preload") {
                                 // /?action=wpfastestcache&type=preload
                                 $this->create_preload_cache();
                             }
                             exit;
                         } else {
                             $this->setCustomInterval();
                             $this->options = $this->getOptions();
                             add_action('transition_post_status', array($this, 'on_all_status_transitions'), 10, 3);
                             $this->commentHooks();
                             $this->checkCronTime();
                             register_deactivation_hook(__FILE__, array('WpFastestCache', 'deactivate'));
                             register_uninstall_hook(__FILE__, array('WpFastestCache', 'uninstall'));
                             if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                                 include_once $this->get_premium_path("mobile-cache.php");
                             }
                             if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                                 include_once $this->get_premium_path("powerful-html.php");
                             }
                             if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                                 if (file_exists(WPFC_WP_PLUGIN_DIR . "/wp-fastest-cache-premium/pro/library/statics.php")) {
                                     include_once $this->get_premium_path("statics.php");
                                 }
                             }
                             if (is_admin()) {
                                 // to avoid loading menu and optionPage() twice
                                 if (!class_exists("WpFastestCacheAdmin")) {
                                     //for wp-panel
                                     if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                                         include_once $this->get_premium_path("image.php");
                                     }
                                     if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                                         include_once $this->get_premium_path("logs.php");
                                     }
                                     add_action('wp_ajax_wpfc_cdn_template_ajax_request', array($this, 'wpfc_cdn_template_ajax_request_callback'));
                                     add_action('plugins_loaded', array($this, 'wpfc_load_plugin_textdomain'));
                                     $this->admin();
                                 }
                             } else {
                                 if (preg_match("/wpfc-minified\\/([^\\/]+)\\/([^\\/]+)/", $this->current_url(), $path)) {
                                     if ($sources = @scandir(WPFC_WP_CONTENT_DIR . "/cache/wpfc-minified/" . $path[1], 1)) {
                                         if (isset($sources[0])) {
                                             // $exist_url = str_replace($path[2], $sources[0], $this->current_url());
                                             // header('Location: ' . $exist_url, true, 301);
                                             // exit;
                                             if (preg_match("/\\.css/", $this->current_url())) {
                                                 header('Content-type: text/css');
                                             } else {
                                                 if (preg_match("/\\.js/", $this->current_url())) {
                                                     header('Content-type: text/js');
                                                 }
                                             }
                                             echo file_get_contents(WPFC_WP_CONTENT_DIR . "/cache/wpfc-minified/" . $path[1] . "/" . $sources[0]);
                                             exit;
                                         }
                                     }
                                 } else {
                                     //for cache
                                     $this->cache();
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
 public function __construct()
 {
     $optimize_image_ajax_requests = array("wpfc_revert_image_ajax_request", "wpfc_statics_ajax_request", "wpfc_optimize_image_ajax_request", "wpfc_update_image_list_ajax_request");
     if (isset($_GET) && isset($_GET["action"]) && $_GET["action"] == "wpfc_cdn_options_ajax_request") {
         $cdn_values = get_option("WpFastestCacheCDN");
         if ($cdn_values) {
             echo $cdn_values;
         } else {
             echo json_encode(array("success" => false));
         }
         exit;
     } else {
         if (isset($_POST) && isset($_POST["action"]) && $_POST["action"] == "wpfc_remove_cdn_integration_ajax_request") {
             delete_option("WpFastestCacheCDN");
             echo json_encode(array("success" => true));
             exit;
         } else {
             if (isset($_POST) && isset($_POST["action"]) && $_POST["action"] == "wpfc_save_cdn_integration_ajax_request") {
                 $values = json_encode($_POST["values"]);
                 if (get_option("WpFastestCacheCDN")) {
                     update_option("WpFastestCacheCDN", $values);
                 } else {
                     add_option("WpFastestCacheCDN", $values, null, "yes");
                 }
                 echo json_encode(array("success" => true));
                 exit;
             } else {
                 if (isset($_GET) && isset($_GET["action"]) && $_GET["action"] == "wpfc_check_url_ajax_request") {
                     $_GET["url"] = strip_tags($_GET["url"]);
                     $_GET["url"] = str_replace(array("'", '"'), "", $_GET["url"]);
                     if (!preg_match("/^http/", $_GET["url"])) {
                         $_GET["url"] = "http://" . $_GET["url"];
                     }
                     $response = wp_remote_get($_GET["url"], array('timeout' => 10));
                     if (!$response || is_wp_error($response)) {
                         $res = array("success" => false, "error_message" => $response->get_error_message());
                     } else {
                         $response_code = wp_remote_retrieve_response_code($response);
                         if ($response_code == 200) {
                             $res = array("success" => true);
                         } else {
                             $res = array("success" => false, "error_message" => $response->get_error_message());
                         }
                     }
                     echo json_encode($res);
                     exit;
                 } else {
                     if (isset($_GET) && isset($_GET["action"]) && $_GET["action"] == "wpfc_cache_statics_get") {
                         if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                             if (file_exists(WPFC_WP_PLUGIN_DIR . "/wp-fastest-cache-premium/pro/library/statics.php")) {
                                 include_once $this->get_premium_path("statics.php");
                                 $cache_statics = new WpFastestCacheStatics();
                                 $res = $cache_statics->get();
                                 echo json_encode($res);
                                 exit;
                             }
                         }
                     } else {
                         if (isset($_GET) && isset($_GET["action"]) && $_GET["action"] == "wpfc_update_premium") {
                             if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                                 if (!file_exists(WPFC_WP_PLUGIN_DIR . "/wp-fastest-cache-premium/pro/library/update.php")) {
                                     $res = array("success" => false, "error_message" => "update.php is not exist");
                                 } else {
                                     include_once $this->get_premium_path("update.php");
                                     if (!class_exists("WpFastestCacheUpdate")) {
                                         $res = array("success" => false, "error_message" => "WpFastestCacheUpdate is not exist");
                                     } else {
                                         $wpfc_premium = new WpFastestCacheUpdate();
                                         $content = $wpfc_premium->download_premium();
                                         if ($content["success"]) {
                                             $wpfc_zip_data = $content["content"];
                                             $wpfc_zip_dest_path = WPFC_WP_PLUGIN_DIR . "/wp-fastest-cache-premium.zip";
                                             if (@file_put_contents($wpfc_zip_dest_path, $wpfc_zip_data)) {
                                                 include_once ABSPATH . "wp-admin/includes/file.php";
                                                 include_once ABSPATH . "wp-admin/includes/plugin.php";
                                                 if (function_exists("unzip_file")) {
                                                     $this->rm_folder_recursively(WPFC_WP_PLUGIN_DIR . "/wp-fastest-cache-premium");
                                                     if (!function_exists('gzopen')) {
                                                         $res = array("success" => false, "error_message" => "Missing zlib extension");
                                                     } else {
                                                         WP_Filesystem();
                                                         $unzipfile = unzip_file($wpfc_zip_dest_path, WPFC_WP_PLUGIN_DIR . "/");
                                                         if ($unzipfile) {
                                                             $result = activate_plugin('wp-fastest-cache-premium/wpFastestCachePremium.php');
                                                             if (is_wp_error($result)) {
                                                                 $res = array("success" => false, "error_message" => "Error occured while the plugin was activated");
                                                             } else {
                                                                 $res = array("success" => true);
                                                                 $this->deleteCache(true);
                                                             }
                                                         } else {
                                                             $res = array("success" => false, "error_message" => 'Error occured while the file was unzipped');
                                                         }
                                                     }
                                                 } else {
                                                     $res = array("success" => false, "error_message" => "unzip_file() is not found");
                                                 }
                                             } else {
                                                 $res = array("success" => false, "error_message" => "/wp-content/plugins/ is not writable");
                                             }
                                         } else {
                                             $res = array("success" => false, "error_message" => $content["error_message"]);
                                         }
                                     }
                                 }
                             } else {
                                 $res = array("success" => false, "error_message" => "Premium is not active");
                             }
                             echo json_encode($res);
                             exit;
                         } else {
                             if (isset($_GET) && isset($_GET["action"]) && in_array($_GET["action"], $optimize_image_ajax_requests)) {
                                 if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                                     include_once $this->get_premium_path("image.php");
                                     $img = new WpFastestCacheImageOptimisation();
                                     $img->hook();
                                 }
                             } else {
                                 $this->setCustomInterval();
                                 $this->options = $this->getOptions();
                                 add_action('transition_post_status', array($this, 'on_all_status_transitions'), 10, 3);
                                 $this->commentHooks();
                                 $this->checkCronTime();
                                 register_deactivation_hook(__FILE__, array('WpFastestCache', 'deactivate'));
                                 if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                                     include_once $this->get_premium_path("mobile-cache.php");
                                 }
                                 if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                                     include_once $this->get_premium_path("powerful-html.php");
                                 }
                                 if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                                     if (file_exists(WPFC_WP_PLUGIN_DIR . "/wp-fastest-cache-premium/pro/library/statics.php")) {
                                         include_once $this->get_premium_path("statics.php");
                                     }
                                 }
                                 if (is_admin()) {
                                     //for wp-panel
                                     $this->setRegularCron();
                                     if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                                         include_once $this->get_premium_path("image.php");
                                     }
                                     if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                                         include_once $this->get_premium_path("logs.php");
                                     }
                                     $this->admin();
                                 } else {
                                     //for cache
                                     $this->cache();
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 public function __construct()
 {
     $optimize_image_ajax_requests = array("wpfc_revert_image_ajax_request", "wpfc_statics_ajax_request", "wpfc_optimize_image_ajax_request", "wpfc_update_image_list_ajax_request");
     add_action('wp_ajax_wpfc_save_timeout_pages', array($this, 'wpfc_save_timeout_pages_callback'));
     add_action('wp_ajax_wpfc_save_exclude_pages', array($this, 'wpfc_save_exclude_pages_callback'));
     add_action('wp_ajax_wpfc_cdn_options_ajax_request', array($this, 'wpfc_cdn_options_ajax_request_callback'));
     add_action('wp_ajax_wpfc_remove_cdn_integration_ajax_request', array($this, 'wpfc_remove_cdn_integration_ajax_request_callback'));
     add_action('wp_ajax_wpfc_save_cdn_integration_ajax_request', array($this, 'wpfc_save_cdn_integration_ajax_request_callback'));
     add_action('wp_ajax_wpfc_cdn_template_ajax_request', array($this, 'wpfc_cdn_template_ajax_request_callback'));
     add_action('wp_ajax_wpfc_check_url_ajax_request', array($this, 'wpfc_check_url_ajax_request_callback'));
     add_action('wp_ajax_wpfc_cache_statics_get', array($this, 'wpfc_cache_statics_get_callback'));
     add_action('wp_ajax_wpfc_update_premium', array($this, 'wpfc_update_premium_callback'));
     add_action('rate_post', array($this, 'wp_postratings_clear_fastest_cache'), 10, 2);
     if (is_dir($this->getWpContentDir() . "/cache/tmpWpfc")) {
         $this->rm_folder_recursively($this->getWpContentDir() . "/cache/tmpWpfc");
     }
     if (isset($_POST) && isset($_POST["action"]) && $_POST["action"] == "vc_get_vc_grid_data") {
         if (isset($_POST["vc_post_id"]) && $_POST["vc_post_id"]) {
             if (isset($_POST["_vcnonce"]) && $_POST["_vcnonce"]) {
                 $this->setCustomInterval();
                 $schedules_rules = array();
                 $exist_cronjob = false;
                 $wpfc_timeout_number = 0;
                 $crons = _get_cron_array();
                 foreach ((array) $crons as $cron_key => $cron_value) {
                     foreach ((array) $cron_value as $hook => $events) {
                         if (preg_match("/^wp\\_fastest\\_cache(.*)/", $hook, $id)) {
                             if (!$id[1] || preg_match("/^\\_(\\d+)\$/", $id[1])) {
                                 $wpfc_timeout_number++;
                                 foreach ((array) $events as $event_key => $event) {
                                     $schedules = wp_get_schedules();
                                     if (isset($event["args"]) && isset($event["args"][0])) {
                                         if ($event["args"][0] == '{"prefix":"all","content":"all"}') {
                                             if ($schedules[$event["schedule"]]["interval"] <= 86400) {
                                                 $exist_cronjob = true;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 if (!$exist_cronjob) {
                     $args = array("prefix" => "all", "content" => "all");
                     wp_schedule_event(time(), "onceaday", "wp_fastest_cache_" . $wpfc_timeout_number, array(json_encode($args)));
                 }
             }
         }
     } else {
         if (isset($_POST) && isset($_POST["action"]) && $_POST["action"] == "wpfc_wppolls_ajax_request") {
             //for WP-Polls
             require_once "inc/wp-polls.php";
             $wp_polls = new WpPollsForWpFc();
             $wp_polls->hook();
         } else {
             if (isset($_GET) && isset($_GET["action"]) && in_array($_GET["action"], $optimize_image_ajax_requests)) {
                 if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                     include_once $this->get_premium_path("image.php");
                     $img = new WpFastestCacheImageOptimisation();
                     $img->hook();
                 }
             } else {
                 $this->setCustomInterval();
                 $this->options = $this->getOptions();
                 add_action('transition_post_status', array($this, 'on_all_status_transitions'), 10, 3);
                 $this->commentHooks();
                 $this->checkCronTime();
                 register_deactivation_hook(__FILE__, array('WpFastestCache', 'deactivate'));
                 if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                     include_once $this->get_premium_path("mobile-cache.php");
                 }
                 if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                     include_once $this->get_premium_path("powerful-html.php");
                 }
                 if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                     if (file_exists(WPFC_WP_PLUGIN_DIR . "/wp-fastest-cache-premium/pro/library/statics.php")) {
                         include_once $this->get_premium_path("statics.php");
                     }
                 }
                 if (is_admin()) {
                     //for wp-panel
                     if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                         include_once $this->get_premium_path("image.php");
                     }
                     if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                         include_once $this->get_premium_path("logs.php");
                     }
                     add_action('wp_ajax_wpfc_cdn_template_ajax_request', array($this, 'wpfc_cdn_template_ajax_request_callback'));
                     add_action('plugins_loaded', array($this, 'wpfc_load_plugin_textdomain'));
                     $this->admin();
                 } else {
                     if (preg_match("/wpfc-minified\\/([^\\/]+)\\/([^\\/]+)/", $this->current_url(), $path)) {
                         if ($sources = @scandir(WPFC_WP_CONTENT_DIR . "/cache/wpfc-minified/" . $path[1], 1)) {
                             if (isset($sources[0])) {
                                 // $exist_url = str_replace($path[2], $sources[0], $this->current_url());
                                 // header('Location: ' . $exist_url, true, 301);
                                 // exit;
                                 if (preg_match("/\\.css/", $this->current_url())) {
                                     header('Content-type: text/css');
                                 } else {
                                     if (preg_match("/\\.js/", $this->current_url())) {
                                         header('Content-type: text/js');
                                     }
                                 }
                                 echo file_get_contents(WPFC_WP_CONTENT_DIR . "/cache/wpfc-minified/" . $path[1] . "/" . $sources[0]);
                                 exit;
                             }
                         }
                     } else {
                         //for cache
                         $this->cache();
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 6
0
 public function __construct()
 {
     $optimize_image_ajax_requests = array("wpfc_revert_image_ajax_request", "wpfc_statics_ajax_request", "wpfc_optimize_image_ajax_request", "wpfc_update_image_list_ajax_request");
     add_action('wp_ajax_wpfc_save_timeout_pages', array($this, 'wpfc_save_timeout_pages_callback'));
     add_action('wp_ajax_wpfc_save_exclude_pages', array($this, 'wpfc_save_exclude_pages_callback'));
     add_action('wp_ajax_wpfc_cdn_options_ajax_request', array($this, 'wpfc_cdn_options_ajax_request_callback'));
     add_action('wp_ajax_wpfc_remove_cdn_integration_ajax_request', array($this, 'wpfc_remove_cdn_integration_ajax_request_callback'));
     add_action('wp_ajax_wpfc_save_cdn_integration_ajax_request', array($this, 'wpfc_save_cdn_integration_ajax_request_callback'));
     add_action('wp_ajax_wpfc_cdn_template_ajax_request', array($this, 'wpfc_cdn_template_ajax_request_callback'));
     add_action('wp_ajax_wpfc_check_url_ajax_request', array($this, 'wpfc_check_url_ajax_request_callback'));
     add_action('wp_ajax_wpfc_cache_statics_get', array($this, 'wpfc_cache_statics_get_callback'));
     add_action('wp_ajax_wpfc_update_premium', array($this, 'wpfc_update_premium_callback'));
     add_action('rate_post', array($this, 'wp_postratings_clear_fastest_cache'), 10, 2);
     if (isset($_GET) && isset($_GET["action"]) && in_array($_GET["action"], $optimize_image_ajax_requests)) {
         if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
             include_once $this->get_premium_path("image.php");
             $img = new WpFastestCacheImageOptimisation();
             $img->hook();
         }
     } else {
         $this->setCustomInterval();
         $this->options = $this->getOptions();
         add_action('transition_post_status', array($this, 'on_all_status_transitions'), 10, 3);
         $this->commentHooks();
         $this->checkCronTime();
         register_deactivation_hook(__FILE__, array('WpFastestCache', 'deactivate'));
         if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
             include_once $this->get_premium_path("mobile-cache.php");
         }
         if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
             include_once $this->get_premium_path("powerful-html.php");
         }
         if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
             if (file_exists(WPFC_WP_PLUGIN_DIR . "/wp-fastest-cache-premium/pro/library/statics.php")) {
                 include_once $this->get_premium_path("statics.php");
             }
         }
         if (is_admin()) {
             //for wp-panel
             $this->setRegularCron();
             if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                 include_once $this->get_premium_path("image.php");
             }
             if ($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")) {
                 include_once $this->get_premium_path("logs.php");
             }
             $this->admin();
         } else {
             if (preg_match("/wpfc-minified\\/([^\\/]+)\\/([^\\/]+)/", $this->current_url(), $path)) {
                 if ($sources = @scandir(WPFC_WP_CONTENT_DIR . "/cache/wpfc-minified/" . $path[1], 1)) {
                     if (isset($sources[0])) {
                         // $exist_url = str_replace($path[2], $sources[0], $this->current_url());
                         // header('Location: ' . $exist_url, true, 301);
                         // exit;
                         if (preg_match("/\\.css/", $path[1])) {
                             header('Content-type: text/css');
                         } else {
                             if (preg_match("/\\.js/", $path[1])) {
                                 header('Content-type: text/js');
                             }
                         }
                         echo file_get_contents(WPFC_WP_CONTENT_DIR . "/cache/wpfc-minified/" . $path[1] . "/" . $sources[0]);
                         exit;
                     }
                 }
             } else {
                 //for cache
                 $this->cache();
             }
         }
     }
 }