本文整理汇总了PHP中wp_cache_get_cookies_values函数 的典型用法代码示例。如果您正苦于以下问题:PHP wp_cache_get_cookies_values函数的具体用法?PHP wp_cache_get_cookies_values怎么用?PHP wp_cache_get_cookies_values使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_cache_get_cookies_values函数 的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: wp_super_cache_init
function wp_super_cache_init()
{
global $wp_cache_key, $key, $blogcacheid, $wp_cache_request_uri, $file_prefix, $blog_cache_dir, $meta_file, $cache_file, $cache_filename, $wp_super_cache_debug, $meta_pathname, $wp_cache_gzip_encoding, $meta;
$wp_cache_key = do_cacheaction('wp_cache_key', $_SERVER['HTTP_HOST'] . preg_replace('/#.*$/', '', str_replace('/index.php', '/', $wp_cache_request_uri)) . $wp_cache_gzip_encoding . wp_cache_get_cookies_values());
$key = $blogcacheid . md5($wp_cache_key);
$wp_cache_key = $blogcacheid . $wp_cache_key;
$cache_filename = $file_prefix . $key . '.html';
$meta_file = $file_prefix . $key . '.meta';
$cache_file = realpath($blog_cache_dir . $cache_filename);
$meta_pathname = realpath($blog_cache_dir . 'meta/' . $meta_file);
return compact('key', 'cache_filename', 'meta_file', 'cache_file', 'meta_pathname');
}
开发者ID:jeremylightsmith, 项目名称:blog, 代码行数:12, 代码来源:wp-cache-phase1.php
示例2: wp_cache_get_ob
function wp_cache_get_ob(&$buffer)
{
global $cache_path, $cache_filename, $meta_file, $wp_start_time, $supercachedir;
global $new_cache, $wp_cache_meta, $file_expired, $blog_id, $cache_compression;
global $wp_cache_gzip_encoding, $super_cache_enabled, $cached_direct_pages;
global $wp_cache_404, $gzsize, $supercacheonly, $wp_cache_gzip_first, $wp_cache_gmt_offset;
global $blog_cache_dir, $wp_cache_request_uri, $wp_supercache_cache_list;
$new_cache = true;
$wp_cache_meta = '';
/* Mode paranoic, check for closing tags
* we avoid caching incomplete files */
if ($buffer == '') {
$new_cache = false;
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("Buffer is blank. Output buffer may have been corrupted by another plugin or this is a redirected URL. Look for text 'ob_start' in the files of your plugins directory.", 2);
$buffer .= "\n<!-- Page not cached by WP Super Cache. Blank Page. Check output buffer usage by plugins. -->\n";
}
}
if ($wp_cache_404 && false == apply_filters('wpsupercache_404', false)) {
$new_cache = false;
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("404 file not found not cached", 2);
$buffer .= "\n<!-- Page not cached by WP Super Cache. 404. -->\n";
}
}
if (!preg_match('/(<\\/html>|<\\/rss>|<\\/feed>)/i', $buffer)) {
$new_cache = false;
if (false === strpos($_SERVER['REQUEST_URI'], 'robots.txt')) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("No closing html tag. Not caching.", 2);
$buffer .= "\n<!-- Page not cached by WP Super Cache. No closing HTML tag. Check your theme. -->\n";
}
} else {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("robots.txt detected. Not caching.", 2);
}
}
}
if (!$new_cache) {
return $buffer;
}
$duration = wp_cache_microtime_diff($wp_start_time, microtime());
$duration = sprintf("%0.3f", $duration);
$buffer .= "\n<!-- Dynamic page generated in {$duration} seconds. -->\n";
if (!wp_cache_writers_entry()) {
$buffer .= "\n<!-- Page not cached by WP Super Cache. Could not get mutex lock. -->\n";
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("Could not get mutex lock. Not caching.", 1);
}
return $buffer;
}
$dir = get_current_url_supercache_dir();
$supercachedir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $_SERVER["HTTP_HOST"]);
if (!empty($_GET) || is_feed() || $super_cache_enabled == true && is_dir(substr($supercachedir, 0, -1) . '.disabled')) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("Supercache disabled: GET or feed detected or disabled by config.", 2);
}
$super_cache_enabled = false;
}
$tmp_wpcache_filename = $cache_path . uniqid(mt_rand(), true) . '.tmp';
// Don't create wp-cache files for anon users
$supercacheonly = false;
if ($super_cache_enabled && wp_cache_get_cookies_values() == '') {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("Anonymous user detected. Only creating Supercache file.", 3);
}
$supercacheonly = true;
}
if (!$supercacheonly) {
if (!@file_exists($blog_cache_dir . $cache_filename) || @file_exists($blog_cache_dir . $cache_filename) && time() - @filemtime($blog_cache_dir . $cache_filename) > 5) {
$fr = @fopen($tmp_wpcache_filename, 'w');
if (!$fr) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("Error. Supercache could not write to " . str_replace(ABSPATH, '', $cache_path) . $cache_filename, 1);
}
$buffer .= "<!-- File not cached! Super Cache Couldn't write to: " . str_replace(ABSPATH, '', $cache_path) . $cache_filename . " -->\n";
return $buffer;
}
}
}
if ($super_cache_enabled) {
$user_info = wp_cache_get_cookies_values();
$do_cache = apply_filters('do_createsupercache', $user_info);
if ($user_info == '' || $do_cache === true) {
if (@is_dir($dir) == false) {
@wp_mkdir_p($dir);
}
$cache_fname = "{$dir}index.html";
$tmp_cache_filename = $dir . uniqid(mt_rand(), true) . '.tmp';
if (!@file_exists($cache_fname) || @file_exists($cache_fname) && time() - @filemtime($cache_fname) > 5) {
$fr2 = @fopen($tmp_cache_filename, 'w');
if (!$fr2) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("Error. Supercache could not write to " . str_replace(ABSPATH, '', $tmp_cache_filename), 1);
}
$buffer .= "<!-- File not cached! Super Cache Couldn't write to: " . str_replace(ABSPATH, '', $tmp_cache_filename) . " -->\n";
@fclose($fr);
@unlink($tmp_wpcache_filename);
return $buffer;
} elseif ($cache_compression) {
//.........这里部分代码省略.........
开发者ID:jeremylightsmith, 项目名称:blog, 代码行数:101, 代码来源:wp-cache-phase2.php
示例3: wp_cache_get_ob
function wp_cache_get_ob(&$buffer)
{
global $cache_path, $cache_filename, $meta_file, $wp_start_time, $supercachedir;
global $new_cache, $wp_cache_meta, $file_expired, $blog_id, $cache_compression;
global $wp_cache_gzip_encoding, $super_cache_enabled, $cached_direct_pages;
global $wp_cache_404, $gzsize, $supercacheonly, $wp_cache_gzip_first, $wp_cache_gmt_offset;
global $blog_cache_dir;
$new_cache = true;
$wp_cache_meta = '';
/* Mode paranoic, check for closing tags
* we avoid caching incomplete files */
if ($wp_cache_404) {
$new_cache = false;
$buffer .= "\n<!-- Page not cached by WP Super Cache. 404. -->\n";
}
if (!preg_match('/(<\\/html>|<\\/rss>|<\\/feed>)/i', $buffer)) {
$new_cache = false;
if (false === strpos($_SERVER['REQUEST_URI'], 'robots.txt')) {
$buffer .= "\n<!-- Page not cached by WP Super Cache. No closing HTML tag. Check your theme. -->\n";
}
}
if (!$new_cache) {
return $buffer;
}
$duration = wp_cache_microtime_diff($wp_start_time, microtime());
$duration = sprintf("%0.3f", $duration);
$buffer .= "\n<!-- Dynamic page generated in {$duration} seconds. -->\n";
if (!wp_cache_writers_entry()) {
$buffer .= "\n<!-- Page not cached by WP Super Cache. Could not get mutex lock. -->\n";
return $buffer;
}
$mtime = @filemtime($blog_cache_dir . $cache_filename);
/* Return if:
the file didn't exist before but it does exist now (another connection created)
OR
the file was expired and its mtime is less than 5 seconds
*/
if (!(!$file_expired && $mtime || $mtime && $file_expired && time() - $mtime < 5)) {
$dir = get_current_url_supercache_dir();
$supercachedir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $_SERVER["HTTP_HOST"]);
if (!empty($_GET) || is_feed() || $super_cache_enabled == true && is_dir(substr($supercachedir, 0, -1) . '.disabled')) {
$super_cache_enabled = false;
}
$tmp_wpcache_filename = $cache_path . uniqid(mt_rand(), true) . '.tmp';
// Don't create wp-cache files for anon users
$supercacheonly = false;
if ($super_cache_enabled && wp_cache_get_cookies_values() == '') {
$supercacheonly = true;
}
if (!$supercacheonly) {
$fr = @fopen($tmp_wpcache_filename, 'w');
if (!$fr) {
$buffer .= "<!-- File not cached! Super Cache Couldn't write to: " . str_replace(ABSPATH, '', $cache_path) . $cache_filename . " -->\n";
return $buffer;
}
}
if ($super_cache_enabled) {
$user_info = wp_cache_get_cookies_values();
$do_cache = apply_filters('do_createsupercache', $user_info);
if ($user_info == '' || $do_cache === true) {
if (@is_dir($dir) == false) {
@wp_mkdir_p($dir);
}
$cache_fname = "{$dir}index.html";
$tmp_cache_filename = $dir . uniqid(mt_rand(), true) . '.tmp';
$fr2 = @fopen($tmp_cache_filename, 'w');
if (!$fr2) {
$buffer .= "<!-- File not cached! Super Cache Couldn't write to: " . str_replace(ABSPATH, '', $tmp_cache_filename) . " -->\n";
@fclose($fr);
@nlink($tmp_wpcache_filename);
return $buffer;
}
if ($cache_compression) {
$gz = @fopen($tmp_cache_filename . ".gz", 'w');
if (!$gz) {
$buffer .= "<!-- File not cached! Super Cache Couldn't write to: " . str_replace(ABSPATH, '', $tmp_cache_filename) . ".gz -->\n";
@close($fr);
@nlink($tmp_wpcache_filename);
@close($fr2);
@nlink($tmp_cache_filename);
return $buffer;
}
}
}
}
if (preg_match('/<!--mclude|<!--mfunc/', $buffer)) {
//Dynamic content
$store = preg_replace('|<!--mclude (.*?)-->(.*?)<!--/mclude-->|is', "<!--mclude-->\n<?php include_once('" . ABSPATH . "\$1'); ?>\n<!--/mclude-->", $buffer);
$store = preg_replace('|<!--mfunc (.*?)-->(.*?)<!--/mfunc-->|is', "<!--mfunc-->\n<?php \$1 ;?>\n<!--/mfunc-->", $store);
$store = apply_filters('wpsupercache_buffer', $store);
$wp_cache_meta['dynamic'] = true;
/* Clean function calls in tag */
$buffer = preg_replace('|<!--mclude (.*?)-->|is', '<!--mclude-->', $buffer);
$buffer = preg_replace('|<!--mfunc (.*?)-->|is', '<!--mfunc-->', $buffer);
if ($fr) {
fputs($fr, $store);
}
if ($fr2) {
fputs($fr2, $store . '<!-- super cache -->');
}
//.........这里部分代码省略.........
开发者ID:emoksha, 项目名称:freefairelections, 代码行数:101, 代码来源:wp-cache-phase2.php
示例4: wp_cache_serve_cache_file
function wp_cache_serve_cache_file()
{
global $key, $blogcacheid, $wp_cache_request_uri, $file_prefix, $blog_cache_dir, $meta_file, $cache_file, $cache_filename, $wp_super_cache_debug, $meta_pathname, $wp_cache_gzip_encoding, $meta;
global $wp_cache_object_cache, $cache_compression, $wp_cache_slash_check, $wp_supercache_304, $wp_cache_home_path, $wp_cache_no_cache_for_get;
global $wp_cache_disable_utf8, $wp_cache_mfunc_enabled;
extract(wp_super_cache_init());
if (wp_cache_user_agent_is_rejected()) {
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("No wp-cache file served as user agent rejected.", 5);
}
return false;
}
if ($wp_cache_no_cache_for_get && false == empty($_GET)) {
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("Non empty GET request. Caching disabled on settings page. " . print_r($_GET, 1), 1);
}
return false;
}
if ($wp_cache_object_cache && wp_cache_get_cookies_values() == '') {
if (!empty($_GET)) {
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("Non empty GET request. Not serving request from object cache. " . print_r($_GET, 1), 1);
}
return false;
}
$oc_key = get_oc_key();
$meta_filename = $oc_key . ".meta";
if (gzip_accepted()) {
$oc_key .= ".gz";
$meta_filename .= ".gz";
}
$cache = wp_cache_get($oc_key, 'supercache');
$meta = unserialize(wp_cache_get($meta_filename, 'supercache'));
if (is_array($meta) == false) {
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("Meta array from object cache corrupt. Ignoring cache.", 1);
}
return true;
}
} elseif (file_exists($cache_file)) {
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("wp-cache file exists: {$cache_file}", 5);
}
if (!($meta = unserialize(@file_get_contents($meta_pathname)))) {
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("couldn't load wp-cache meta file", 5);
}
return true;
}
if (is_array($meta) == false) {
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("meta array corrupt, deleting {$meta_pathname} and {$cache_file}", 1);
}
@unlink($meta_pathname);
@unlink($cache_file);
return true;
}
} else {
// last chance, check if a supercache file exists. Just in case .htaccess rules don't work on this host
$filename = supercache_filename();
$file = get_current_url_supercache_dir() . $filename;
if (false == file_exists($file)) {
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("No Super Cache file found for current URL: {$file}");
}
return false;
} elseif (false == empty($_GET)) {
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("GET array not empty. Cannot serve a supercache file. " . print_r($_GET, 1));
}
return false;
} elseif (wp_cache_get_cookies_values() != '') {
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("Cookies found. Cannot serve a supercache file. " . wp_cache_get_cookies_values());
}
return false;
}
if (isset($wp_cache_mfunc_enabled) == false) {
$wp_cache_mfunc_enabled = 0;
}
if (false == isset($wp_cache_home_path)) {
$wp_cache_home_path = '/';
}
// make sure ending slashes are ok
if ($wp_cache_request_uri == $wp_cache_home_path || $wp_cache_slash_check && substr($wp_cache_request_uri, -1) == '/' || $wp_cache_slash_check == 0 && substr($wp_cache_request_uri, -1) != '/') {
if ($wp_cache_mfunc_enabled == 0) {
// get data from file
if ($wp_cache_gzip_encoding) {
if (file_exists($file . '.gz')) {
$cachefiledata = file_get_contents($file . '.gz');
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("Fetched gzip static page data from supercache file using PHP. File: {$file}.gz");
}
} else {
$cachefiledata = gzencode(file_get_contents($file), 6, FORCE_GZIP);
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("Fetched static page data from supercache file using PHP and gzipped it. File: {$file}");
}
}
} else {
//.........这里部分代码省略.........
开发者ID:JuiceCrawl, 项目名称:juicecrawldev, 代码行数:101, 代码来源:wp-cache-phase1.php
示例5: wp_cache_get_ob
function wp_cache_get_ob(&$buffer)
{
global $wpsc_settings;
global $cache_enabled, $cache_path, $cache_filename, $meta_file, $wp_start_time, $supercachedir;
global $new_cache, $wp_cache_meta, $file_expired, $blog_id, $cache_compression;
global $wp_cache_gzip_encoding, $super_cache_enabled, $cached_direct_pages;
global $wp_cache_404, $gzsize, $supercacheonly;
global $blog_cache_dir, $wp_cache_request_uri, $wp_supercache_cache_list;
global $wp_cache_not_logged_in, $wp_cache_object_cache, $cache_max_time;
global $wp_cache_is_home, $wp_cache_front_page_checks;
$new_cache = true;
$wp_cache_meta = '';
/* Mode paranoic, check for closing tags
* we avoid caching incomplete files */
if ($buffer == '') {
$new_cache = false;
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("Buffer is blank. Output buffer may have been corrupted by another plugin or this is a redirected URL. Look for text 'ob_start' in the files of your plugins directory.", 2);
$buffer .= "\n<!-- Page not cached by WP Super Cache. Blank Page. Check output buffer usage by plugins. -->\n";
}
}
if ($wp_cache_404 && false == apply_filters('wpsupercache_404', false)) {
$new_cache = false;
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("404 file not found not cached", 2);
$buffer .= "\n<!-- Page not cached by WP Super Cache. 404. -->\n";
}
}
if (!preg_match('/(<\\/html>|<\\/rss>|<\\/feed>|<\\/urlset)/i', $buffer)) {
$new_cache = false;
if (false === strpos($_SERVER['REQUEST_URI'], 'robots.txt')) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("No closing html tag. Not caching.", 2);
$buffer .= "\n<!-- Page not cached by WP Super Cache. No closing HTML tag. Check your theme. -->\n";
}
} else {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("robots.txt detected. Not caching.", 2);
}
}
}
if (!$new_cache) {
return $buffer;
}
$duration = wp_cache_microtime_diff($wp_start_time, microtime());
$duration = sprintf("%0.3f", $duration);
$buffer .= "\n<!-- Dynamic page generated in {$duration} seconds. -->\n";
if (!wp_cache_writers_entry()) {
$buffer .= "\n<!-- Page not cached by WP Super Cache. Could not get mutex lock. -->\n";
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("Could not get mutex lock. Not caching.", 1);
}
return $buffer;
}
if ($wp_cache_not_logged_in && is_feed()) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("Feed detected. Writing legacy cache files.", 5);
}
$wp_cache_not_logged_in = false;
}
$home_url = parse_url(trailingslashit(get_bloginfo('url')));
$dir = get_current_url_supercache_dir();
$supercachedir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $home_url['host']);
if (!empty($_GET) || is_feed() || $super_cache_enabled == true && is_dir(substr($supercachedir, 0, -1) . '.disabled')) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("Supercache disabled: GET or feed detected or disabled by config.", 2);
}
$super_cache_enabled = false;
}
$tmp_wpcache_filename = $cache_path . uniqid(mt_rand(), true) . '.tmp';
$supercacheonly = false;
if ($super_cache_enabled) {
if (wp_cache_get_cookies_values() == '') {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("Anonymous user detected. Only creating Supercache file.", 3);
}
$supercacheonly = true;
}
}
$cache_error = '';
if ($wp_cache_not_logged_in && wp_cache_get_cookies_values() != '') {
$super_cache_enabled = false;
$cache_enabled = false;
$cache_error = 'Not caching requests by known users. (See Advanced Settings page)';
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug('Not caching for known user.', 5);
}
}
if ($wp_cache_object_cache) {
// half on mode when using the object cache
if (wp_cache_get_cookies_values() != '') {
$cache_enabled = false;
$cache_error = 'Known User and using object. Only anonymous users cached.';
}
$super_cache_enabled = false;
$supercacheonly = false;
wp_cache_init();
// PHP5 destroys objects during shutdown
}
if (!$cache_enabled) {
//.........这里部分代码省略.........
开发者ID:rubyerme, 项目名称:rubyerme.github.com, 代码行数:101, 代码来源:wp-cache-phase2.php
示例6: md5
<?php
if (!@(include ABSPATH . 'wp-content/wp-cache-config.php')) {
return;
}
$mutex_filename = 'wp_cache_mutex.lock';
$new_cache = false;
// Don't change variables behind this point
if (!$cache_enabled || $_SERVER["REQUEST_METHOD"] == 'POST') {
return;
}
$file_expired = false;
$cache_filename = '';
$meta_file = '';
$key = md5(preg_replace('/#.*$/', '', $_SERVER['REQUEST_URI']) . wp_cache_get_cookies_values());
$cache_filename = $file_prefix . $key . '.html';
$meta_file = $file_prefix . $key . '.meta';
$cache_file = $cache_path . $cache_filename;
$meta_pathname = $cache_path . $meta_file;
$wp_start_time = microtime();
if ($mtime = @filemtime($meta_pathname)) {
if ($mtime + $cache_max_time > time()) {
$meta = new CacheMeta();
if (!($meta = unserialize(@file_get_contents($meta_pathname)))) {
return;
}
foreach ($meta->headers as $header) {
header($header);
}
$log = "<!-- Cached page served by WP-Cache -->\n";
if (!($content_size = @filesize($cache_file)) > 0 || $mtime < @filemtime($cache_file)) {
开发者ID:sajidsan, 项目名称:sajidsan.github.io, 代码行数:31, 代码来源:wp-cache-phase1.php
示例7: wp_cache_serve_cache_file
function wp_cache_serve_cache_file()
{
global $key, $blogcacheid, $wp_cache_request_uri, $file_prefix, $blog_cache_dir, $meta_file, $cache_file, $cache_filename, $wp_super_cache_debug, $meta_pathname, $wp_cache_gzip_encoding, $meta;
global $wp_cache_object_cache, $cache_compression, $wp_cache_slash_check, $wp_supercache_304;
extract(wp_super_cache_init());
if (wp_cache_user_agent_is_rejected()) {
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("No wp-cache file served as user agent rejected.", 5);
}
return false;
}
if ($wp_cache_object_cache && wp_cache_get_cookies_values() == '') {
if (!empty($_GET)) {
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("Non empty GET request. Not serving request from object cache", 1);
}
return false;
}
$oc_key = get_oc_key();
$meta_filename = $oc_key . ".meta";
if (gzip_accepted()) {
$oc_key .= ".gz";
$meta_filename .= ".gz";
}
$cache = wp_cache_get($oc_key, 'supercache');
$meta = unserialize(wp_cache_get($meta_filename, 'supercache'));
if (is_array($meta) == false) {
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("Meta array from object cache corrupt. Ignoring cache.", 1);
}
return true;
}
} elseif (file_exists($cache_file)) {
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("wp-cache file exists: {$cache_file}", 5);
}
if (!($meta = unserialize(@file_get_contents($meta_pathname)))) {
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("couldn't load wp-cache meta file", 5);
}
return true;
}
if (is_array($meta) == false) {
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("meta array corrupt, deleting {$meta_pathname} and {$cache_file}", 1);
}
@unlink($meta_pathname);
@unlink($cache_file);
return true;
}
} else {
// last chance, check if a supercache file exists. Just in case .htaccess rules don't work on this host
$file = get_current_url_supercache_dir() . "index.html";
$phpfile = get_current_url_supercache_dir() . "index.html.php";
$serving_supercache = false;
if (file_exists($file)) {
$serving_supercache = 'html';
} elseif (file_exists($phpfile)) {
$serving_supercache = 'php';
}
if (($wp_cache_request_uri == '/' || $wp_cache_slash_check && substr($wp_cache_request_uri, -1) == '/' || $wp_cache_slash_check == 0 && substr($wp_cache_request_uri, -1) != '/') && (wp_cache_get_cookies_values() == '' && empty($_GET) && $serving_supercache)) {
header("Content-type: text/html; charset=UTF-8");
// UTF-8 hard coded is bad but we don't know what it is this early in the process
header("Vary: Accept-Encoding, Cookie");
header("Cache-Control: max-age=300, must-revalidate");
header("WP-Super-Cache: Served supercache file from PHP");
if (file_exists($file . '.gz') && $wp_cache_gzip_encoding) {
$file = $file . '.gz';
header('Content-Encoding: ' . $wp_cache_gzip_encoding);
header('Content-Length: ' . filesize($file));
} elseif ($serving_supercache == 'html' && $wp_supercache_304) {
header('Content-Length: ' . filesize($file));
}
if ($serving_supercache == 'html' && $wp_supercache_304) {
if (function_exists('apache_request_headers')) {
$request = apache_request_headers();
$remote_mod_time = $request['If-Modified-Since'];
} else {
$remote_mod_time = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
}
$local_mod_time = gmdate("D, d M Y H:i:s", filemtime($file)) . ' GMT';
if ($remote_mod_time == $local_mod_time) {
header("HTTP/1.0 304 Not Modified");
exit;
}
header('Last-Modified: ' . $local_mod_time);
}
if ($serving_supercache == 'html') {
readfile($file);
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("Served page from supercache file using PHP.", 5);
}
exit;
} elseif ($serving_supercache == 'php') {
$cachefiledata = file_get_contents($phpfile);
if ($cache_compression and $wp_cache_gzip_encoding) {
ob_start("ob_gzhandler");
eval('?>' . $cachefiledata . '<?php ');
echo "\n<!-- Compression = gzip -->\n";
ob_end_flush();
//.........这里部分代码省略.........
开发者ID:howardlei82, 项目名称:IGSM-Website, 代码行数:101, 代码来源:wp-cache-phase1.php
示例8: gzip_accepted
function gzip_accepted()
{
if (ini_get('zlib.output_compression')) {
// don't compress WP-Cache data files when PHP is already doing it
return false;
}
if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') === false) {
return false;
}
return 'gzip';
}
if ($cache_compression) {
$wp_cache_gzip_encoding = gzip_accepted();
}
add_cacheaction('wp_cache_key', 'wp_cache_check_mobile');
$key = $blogcacheid . md5(do_cacheaction('wp_cache_key', $_SERVER['HTTP_HOST'] . preg_replace('/#.*$/', '', str_replace('/index.php', '/', $_SERVER['REQUEST_URI'])) . $wp_cache_gzip_encoding . wp_cache_get_cookies_values()));
if (false == @is_dir($blog_cache_dir)) {
@mkdir($cache_path . "blogs");
@mkdir($blog_cache_dir);
}
if (false == @is_dir($blog_cache_dir . 'meta')) {
@mkdir($blog_cache_dir . 'meta');
}
$cache_filename = $file_prefix . $key . '.html';
$meta_file = $file_prefix . $key . '.meta';
$cache_file = realpath($blog_cache_dir . $cache_filename);
$meta_pathname = realpath($blog_cache_dir . 'meta/' . $meta_file);
$wp_start_time = microtime();
if (file_exists($cache_file) && ($mtime = @filemtime($meta_pathname))) {
if ($mtime + $cache_max_time > time()) {
if (!($meta = unserialize(@file_get_contents($meta_pathname)))) {
开发者ID:enlamp, 项目名称:enlamp.cn, 代码行数:31, 代码来源:wp-cache-phase1.php
示例9: wp_cache_get_ob
function wp_cache_get_ob(&$buffer)
{
global $cache_enabled, $cache_path, $cache_filename, $meta_file, $wp_start_time, $supercachedir;
global $new_cache, $wp_cache_meta, $file_expired, $blog_id, $cache_compression;
global $wp_cache_gzip_encoding, $super_cache_enabled, $cached_direct_pages;
global $wp_cache_404, $gzsize, $supercacheonly;
global $blog_cache_dir, $wp_cache_request_uri, $wp_supercache_cache_list;
global $wp_cache_not_logged_in, $wp_cache_object_cache, $cache_max_time;
global $wp_cache_is_home, $wp_cache_front_page_checks, $wp_cache_mfunc_enabled;
if (isset($wp_cache_mfunc_enabled) == false) {
$wp_cache_mfunc_enabled = 0;
}
$new_cache = true;
$wp_cache_meta = '';
/* Mode paranoic, check for closing tags
* we avoid caching incomplete files */
if ($buffer == '') {
$new_cache = false;
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("Buffer is blank. Output buffer may have been corrupted by another plugin or this is a redirected URL. Look for text 'ob_start' in the files of your plugins directory.", 2);
wp_cache_add_to_buffer($buffer, "Page not cached by WP Super Cache. Blank Page. Check output buffer usage by plugins.");
}
}
if ($wp_cache_404 && false == apply_filters('wpsupercache_404', false)) {
$new_cache = false;
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("404 file not found not cached", 2);
wp_cache_add_to_buffer($buffer, "Page not cached by WP Super Cache. 404.");
}
}
if (!preg_match(apply_filters('wp_cache_eof_tags', '/(<\\/html>|<\\/rss>|<\\/feed>|<\\/urlset|<\\?xml)/i'), $buffer)) {
$new_cache = false;
if (false === strpos($_SERVER['REQUEST_URI'], 'robots.txt')) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("No closing html tag. Not caching.", 2);
wp_cache_add_to_buffer($buffer, "Page not cached by WP Super Cache. No closing HTML tag. Check your theme.");
}
} else {
wp_cache_debug("robots.txt detected. Not caching.", 2);
}
}
if (!$new_cache) {
return wp_cache_maybe_dynamic($buffer);
}
$duration = wp_cache_microtime_diff($wp_start_time, microtime());
$duration = sprintf("%0.3f", $duration);
wp_cache_add_to_buffer($buffer, "Dynamic page generated in {$duration} seconds.");
if (!wp_cache_writers_entry()) {
wp_cache_add_to_buffer($buffer, "Page not cached by WP Super Cache. Could not get mutex lock.");
wp_cache_debug("Could not get mutex lock. Not caching.", 1);
return wp_cache_maybe_dynamic($buffer);
}
if ($wp_cache_not_logged_in && is_feed()) {
wp_cache_debug("Feed detected. Writing legacy cache files.", 5);
$wp_cache_not_logged_in = false;
}
$home_url = parse_url(trailingslashit(get_bloginfo('url')));
$dir = get_current_url_supercache_dir();
$supercachedir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $home_url['host']);
if (!empty($_GET) || is_feed() || $super_cache_enabled == true && is_dir(substr($supercachedir, 0, -1) . '.disabled')) {
wp_cache_debug("Supercache disabled: GET or feed detected or disabled by config.", 2);
$super_cache_enabled = false;
}
$tmp_wpcache_filename = $cache_path . uniqid(mt_rand(), true) . '.tmp';
$supercacheonly = false;
if ($super_cache_enabled) {
if (wp_cache_get_cookies_values() == '' && empty($_GET)) {
wp_cache_debug("Anonymous user detected. Only creating Supercache file.", 3);
$supercacheonly = true;
}
}
$cache_error = '';
if ($wp_cache_not_logged_in && wp_cache_get_cookies_values() != '') {
$super_cache_enabled = false;
$cache_enabled = false;
$cache_error = 'Not caching requests by known users. (See Advanced Settings page)';
wp_cache_debug('Not caching for known user.', 5);
}
if ($wp_cache_object_cache) {
// half on mode when using the object cache
if (wp_cache_get_cookies_values() != '') {
$cache_enabled = false;
$cache_error = 'Known User and using object. Only anonymous users cached.';
}
$super_cache_enabled = false;
$supercacheonly = false;
wp_cache_init();
// PHP5 destroys objects during shutdown
}
if (!$cache_enabled) {
wp_cache_debug('Cache is not enabled. Sending buffer to browser.', 5);
wp_cache_writers_exit();
wp_cache_add_to_buffer($buffer, "Page not cached by WP Super Cache. Check your settings page. {$cache_error}");
if ($wp_cache_mfunc_enabled == 1) {
global $wp_super_cache_late_init;
if (false == isset($wp_super_cache_late_init) || isset($wp_super_cache_late_init) && $wp_super_cache_late_init == 0) {
wp_cache_add_to_buffer($buffer, 'Super Cache dynamic page detected but $wp_super_cache_late_init not set. See the readme.txt for further details.');
}
}
return wp_cache_maybe_dynamic($buffer);
//.........这里部分代码省略.........
开发者ID:KurtMakesWeb, 项目名称:CandG, 代码行数:101, 代码来源:wp-cache-phase2.php
示例10: wp_cache_serve_cache_file
function wp_cache_serve_cache_file()
{
global $key, $blogcacheid, $wp_cache_request_uri, $file_prefix, $blog_cache_dir, $meta_file, $cache_file, $cache_filename, $wp_super_cache_debug, $meta_pathname, $wp_cache_gzip_encoding, $meta;
global $wp_cache_object_cache, $cache_compression, $wp_cache_slash_check;
extract(wp_super_cache_init());
if (wp_cache_user_agent_is_rejected()) {
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("No wp-cache file served as user agent rejected.", 5);
}
return false;
}
if ($wp_cache_object_cache && wp_cache_get_cookies_values() == '') {
if (!empty($_GET)) {
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("Non empty GET request. Not serving request from object cache", 1);
}
return false;
}
$oc_key = get_oc_key();
$meta_filename = $oc_key . ".meta";
if (gzip_accepted()) {
$oc_key .= ".gz";
$meta_filename .= ".gz";
}
$cache = wp_cache_get($oc_key, 'supercache');
$meta = unserialize(wp_cache_get($meta_filename, 'supercache'));
if (is_array($meta) == false) {
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("Meta array from object cache corrupt. Ignoring cache.", 1);
}
return true;
}
} elseif (file_exists($cache_file)) {
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("wp-cache file exists: {$cache_file}", 5);
}
if (!($meta = unserialize(@file_get_contents($meta_pathname)))) {
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("couldn't load wp-cache meta file", 5);
}
return true;
}
if (is_array($meta) == false) {
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("meta array corrupt, deleting {$meta_pathname} and {$cache_file}", 1);
}
@unlink($meta_pathname);
@unlink($cache_file);
return true;
}
} else {
// last chance, check if a supercache file exists. Just in case .htaccess rules don't work on this host
$file = get_current_url_supercache_dir() . "index.html";
if (($wp_cache_request_uri == '/' || $wp_cache_slash_check && substr($wp_cache_request_uri, -1) == '/' || $wp_cache_slash_check == 0 && substr($wp_cache_request_uri, -1) != '/') && (wp_cache_get_cookies_values() == '' && empty($_GET) && file_exists($file))) {
header("Content-type: text/html; charset=UTF-8");
// UTF-8 hard coded is bad but we don't know what it is this early in the process
header("Vary: Accept-Encoding, Cookie");
header("Cache-Control: max-age=300, must-revalidate");
header("WP-Cache: Served supercache file from PHP");
readfile($file);
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("Served page from supercache file. Mod rewrite rules may be broken or missing.", 5);
}
die;
} else {
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("No wp-cache file exists. Must generate a new one.", 5);
}
return false;
}
}
$cache_file = do_cacheaction('wp_cache_served_cache_file', $cache_file);
// Sometimes the gzip headers are lost. Make sure html returned isn't compressed!
if ($cache_compression && $wp_cache_gzip_encoding && !in_array('Content-Encoding: ' . $wp_cache_gzip_encoding, $meta['headers'])) {
$ungzip = true;
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("GZIP headers not found. Force uncompressed output.", 1);
}
} else {
$ungzip = false;
}
foreach ($meta['headers'] as $t => $header) {
// godaddy fix, via http://blog.gneu.org/2008/05/wp-supercache-on-godaddy/ and http://www.littleredrails.com/blog/2007/09/08/using-wp-cache-on-godaddy-500-error/
if (strpos($header, 'Last-Modified:') === false) {
header($header);
}
}
header('WP-Super-Cache: WP-Cache');
if ($wp_cache_object_cache) {
if ($cache) {
if ($ungzip) {
$uncompressed = gzuncompress($cache);
if ($uncompressed) {
if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
wp_cache_debug("Uncompressed gzipped cache file from object cache", 1);
}
$cache = $uncompressed;
unset($uncompressed);
}
}
//.........这里部分代码省略.........
开发者ID:hoonio, 项目名称:wordpress, 代码行数:101, 代码来源:wp-cache-phase1.php
示例11: wp_cache_ob_callback
function wp_cache_ob_callback($buffer)
{
global $cache_path, $cache_filename, $meta_file, $wp_start_time, $supercachedir;
global $new_cache, $wp_cache_meta_object, $file_expired, $blog_id, $cache_compression;
global $wp_cache_gzip_encoding, $super_cache_enabled, $cached_direct_pages;
global $wp_cache_404, $gzsize;
$new_cache = true;
/* Mode paranoic, check for closing tags
* we avoid caching incomplete files */
if ($wp_cache_404) {
$new_cache = false;
$buffer .= "\n<!-- Page not cached by WP Super Cache. 404. -->\n";
}
if (!preg_match('/(<\\/html>|<\\/rss>|<\\/feed>)/i', $buffer)) {
$new_cache = false;
$buffer .= "\n<!-- Page not cached by WP Super Cache. No closing HTML tag. Check your theme. -->\n";
}
if (!$new_cache) {
return $buffer;
}
$duration = wp_cache_microtime_diff($wp_start_time, microtime());
$duration = sprintf("%0.3f", $duration);
$buffer .= "\n<!-- Dynamic Page Served (once) in {$duration} seconds -->\n";
if (!wp_cache_writers_entry()) {
$buffer .= "\n<!-- Page not cached by WP Super Cache. Could not get mutex lock. -->\n";
return $buffer;
}
$mtime = @filemtime($cache_path . $cache_filename);
/* Return if:
the file didn't exist before but it does exist now (another connection created)
OR
the file was expired and its mtime is less than 5 seconds
*/
if (!(!$file_expired && $mtime || $mtime && $file_expired && time() - $mtime < 5)) {
$dir = get_current_url_supercache_dir();
$supercachedir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $_SERVER["HTTP_HOST"]);
if (!empty($_GET) || is_feed() || $super_cache_enabled == true && is_dir(substr($supercachedir, 0, -1) . '.disabled')) {
$super_cache_enabled = false;
}
$tmp_wpcache_filename = tempnam($cache_path, "wp-cache");
$fr = @fopen($tmp_wpcache_filename, 'w');
if (!$fr) {
$buffer .= "<!-- File not cached! Super Cache Couldn't write to: " . str_replace(ABSPATH, '', $cache_path) . $cache_filename . " -->\n";
return $buffer;
}
if ($super_cache_enabled) {
if (@is_dir($dir) == false) {
@wp_mkdir_p($dir);
}
$user_info = wp_cache_get_cookies_values();
$do_cache = apply_filters('do_createsupercache', $user_info);
if ($user_info == '' || $do_cache === true) {
$cache_fname = "{$dir}index.html";
$tmp_cache_filename = tempnam($dir, "wpsupercache");
$fr2 = @fopen($tmp_cache_filename, 'w');
if ($cache_compression) {
$gz = @fopen($tmp_cache_filename . ".gz", 'w');
}
}
}
if (preg_match('/<!--mclude|<!--mfunc/', $buffer)) {
//Dynamic content
$store = preg_replace('|<!--mclude (.*?)-->(.*?)<!--/mclude-->|is', "<!--mclude-->\n<?php include_once('" . ABSPATH . "\$1'); ?>\n<!--/mclude-->", $buffer);
$store = preg_replace('|<!--mfunc (.*?)-->(.*?)<!--/mfunc-->|is', "<!--mfunc-->\n<?php \$1 ;?>\n<!--/mfunc-->", $store);
$store = apply_filters('wpsupercache_buffer', $store);
$wp_cache_meta_object->dynamic = true;
/* Clean function calls in tag */
$buffer = preg_replace('|<!--mclude (.*?)-->|is', '<!--mclude-->', $buffer);
$buffer = preg_replace('|<!--mfunc (.*?)-->|is', '<!--mfunc-->', $buffer);
fputs($fr, $store);
if ($fr2) {
fputs($fr2, $store . '<!-- super cache -->');
}
if ($gz) {
fputs($gz, gzencode($store . '<!-- super cache gz -->', 1, FORCE_GZIP));
}
} else {
$buffer = apply_filters('wpsupercache_buffer', $buffer);
$log = "<!-- Cached page served by WP-Super-Cache -->\n";
if ($gz || $wp_cache_gzip_encoding) {
$gzdata = gzencode($buffer . $log . "<!-- Compression = gzip -->", 3, FORCE_GZIP);
$gzsize = strlen($gzdata);
}
if ($wp_cache_gzip_encoding) {
array_push($wp_cache_meta_object->headers, 'Content-Encoding: ' . $wp_cache_gzip_encoding);
array_push($wp_cache_meta_object->headers, 'Vary: Accept-Encoding, Cookie');
array_push($wp_cache_meta_object->headers, 'Content-Length: ' . strlen($gzdata));
// Return uncompressed data & store compressed for later use
fputs($fr, $gzdata);
} else {
// no compression
array_push($wp_cache_meta_object->headers, 'Vary: Cookie');
fputs($fr, $buffer . $log);
}
if ($fr2) {
fputs($fr2, $buffer . '<!-- super cache -->');
}
if ($gz) {
fwrite($gz, $gzdata);
}
//.........这里部分代码省略.........
开发者ID:alx, 项目名称:barceloneta, 代码行数:101, 代码来源:wp-cache-phase2.php
The seminars (aka Seminar Manager) extension through 4.1.3 for TYPO3 allows SQL
阅读:618| 2022-07-29
librespeed/speedtest: Self-hosted Speedtest for HTML5 and more. Easy setup, exam
阅读:1218| 2022-08-30
avehtari/BDA_m_demos: Bayesian Data Analysis demos for Matlab/Octave
阅读:1133| 2022-08-17
女人怀孕后,为了有一个健康聪明的宝宝,经历各种体检、筛查。其实这些体检和筛查中的
阅读:944| 2022-11-06
medfreeman/markdown-it-toc-and-anchor: markdown-it plugin to add a toc and ancho
阅读:1340| 2022-08-18
微信小程序 app.json 详细介绍
阅读:566| 2022-07-18
A memory corruption in Hex Rays Ida Pro v6.6 allows attackers to cause a Denial
阅读:513| 2022-07-08
sydney0zq/covid-19-detection: The implementation of A Weakly-supervised Framewor
阅读:485| 2022-08-16
cpnota/autonomous-learning-library: A PyTorch library for building deep reinforc
阅读:527| 2022-08-15
离中国最远的国家是阿根廷。从太平洋直线计算,即往东线走,北京到阿根廷的布宜诺斯艾
阅读:641| 2022-11-06
请发表评论