public function createFolder($cachFilePath, $buffer, $extension = "html", $prefix = "") { $create = false; if ($buffer && strlen($buffer) > 100 && $extension == "html") { $create = true; } if (($extension == "css" || $extension == "js") && $buffer && strlen($buffer) > 5) { $create = true; $buffer = trim($buffer); if ($extension == "js") { if (substr($buffer, -1) != ";") { $buffer .= ";"; } } } $cachFilePath = urldecode($cachFilePath); if ($create) { if (!is_user_logged_in() && !$this->isCommenter()) { if (!is_dir($cachFilePath)) { if (is_writable($this->getWpContentDir()) || is_dir($this->getWpContentDir() . "/cache") && is_writable($this->getWpContentDir() . "/cache")) { if (@mkdir($cachFilePath, 0755, true)) { file_put_contents($cachFilePath . "/" . $prefix . "index." . $extension, $buffer); if (class_exists("WpFastestCacheStatics")) { if (preg_match("/wpfc\\-mobile\\-cache/", $cachFilePath)) { $extension = "mobile"; } $cache_statics = new WpFastestCacheStatics($extension, strlen($buffer)); $cache_statics->update_db(); } } else { } } else { } } else { if (file_exists($cachFilePath . "/" . $prefix . "index." . $extension)) { } else { file_put_contents($cachFilePath . "/" . $prefix . "index." . $extension, $buffer); if (class_exists("WpFastestCacheStatics")) { if (preg_match("/wpfc\\-mobile\\-cache/", $cachFilePath)) { $extension = "mobile"; } $cache_statics = new WpFastestCacheStatics($extension, strlen($buffer)); $cache_statics->update_db(); } } } } } elseif ($extension == "html") { $this->err = "Buffer is empty so the cache cannot be created"; } }
public function createFolder($cachFilePath, $buffer, $extension = "html", $prefix = "", $gzip = false) { $create = false; if ($buffer && strlen($buffer) > 100 && $extension == "html") { if (!preg_match("/^\\<\\!\\-\\-\\sMobile\\:\\sWP\\sFastest\\sCache/i", $buffer)) { if (!preg_match("/^\\<\\!\\-\\-\\sWP\\sFastest\\sCache/i", $buffer)) { $create = true; } } } if (($extension == "css" || $extension == "js") && $buffer && strlen($buffer) > 5) { $create = true; $buffer = trim($buffer); if ($extension == "js") { if (substr($buffer, -1) != ";") { $buffer .= ";"; } } } $cachFilePath = urldecode($cachFilePath); if ($create) { if (!is_user_logged_in() && !$this->isCommenter()) { if (!is_dir($cachFilePath)) { if (is_writable($this->getWpContentDir()) || is_dir($this->getWpContentDir() . "/cache") && is_writable($this->getWpContentDir() . "/cache")) { if (@mkdir($cachFilePath, 0755, true)) { file_put_contents($cachFilePath . "/" . $prefix . "index." . $extension, $buffer); if (defined("WPFC_GZIP_FOR_COMBINED_FILES") && WPFC_GZIP_FOR_COMBINED_FILES) { if ($gzip) { if (in_array($extension, array("css", "js"))) { $zp = gzopen($cachFilePath . "/" . $prefix . "index." . $extension . ".gz", "w9"); gzwrite($zp, $buffer); gzclose($zp); } } } if (class_exists("WpFastestCacheStatics")) { if (!preg_match("/After\\sCache\\sTimeout/i", $_SERVER['HTTP_USER_AGENT'])) { if (preg_match("/wpfc\\-mobile\\-cache/", $cachFilePath)) { $extension = "mobile"; } $cache_statics = new WpFastestCacheStatics($extension, strlen($buffer)); $cache_statics->update_db(); } } } else { } } else { } } else { if (file_exists($cachFilePath . "/" . $prefix . "index." . $extension)) { } else { file_put_contents($cachFilePath . "/" . $prefix . "index." . $extension, $buffer); if (class_exists("WpFastestCacheStatics")) { if (!preg_match("/After\\sCache\\sTimeout/i", $_SERVER['HTTP_USER_AGENT'])) { if (preg_match("/wpfc\\-mobile\\-cache/", $cachFilePath)) { $extension = "mobile"; } $cache_statics = new WpFastestCacheStatics($extension, strlen($buffer)); $cache_statics->update_db(); } } } } } } elseif ($extension == "html") { $this->err = "Buffer is empty so the cache cannot be created"; } }