当前位置: 首页>>代码示例>>PHP>>正文


PHP wp_cache_user_agent_is_rejected函数代码示例

本文整理汇总了PHP中wp_cache_user_agent_is_rejected函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_cache_user_agent_is_rejected函数的具体用法?PHP wp_cache_user_agent_is_rejected怎么用?PHP wp_cache_user_agent_is_rejected使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wp_cache_user_agent_is_rejected函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: wp_cache_phase2

/** Diable here because PHP4.3 does not make the global
 Serious bug?

$mutex_filename = 'wp_cache_mutex.lock';
$new_cache = false;
*/
function wp_cache_phase2()
{
    global $cache_filename, $cache_acceptable_files;
    wp_cache_mutex_init();
    if (function_exists('add_action')) {
        // Post ID is received
        add_action('publish_post', 'wp_cache_post_change', 0);
        add_action('edit_post', 'wp_cache_post_change', 0);
        add_action('delete_post', 'wp_cache_post_change', 0);
        add_action('publish_phone', 'wp_cache_post_change', 0);
        // Coment ID is received
        add_action('trackback_post', 'wp_cache_get_postid_from_comment', 0);
        add_action('pingback_post', 'wp_cache_get_postid_from_comment', 0);
        add_action('comment_post', 'wp_cache_get_postid_from_comment', 0);
        add_action('edit_comment', 'wp_cache_get_postid_from_comment', 0);
        add_action('wp_set_comment_status', 'wp_cache_get_postid_from_comment', 0);
        // No post_id is available
        add_action('delete_comment', 'wp_cache_no_postid', 0);
        add_action('switch_theme', 'wp_cache_no_postid', 0);
    }
    //$script = basename($_SERVER['SCRIPT_NAME']);
    if ($_SERVER["REQUEST_METHOD"] == 'POST' || get_settings('gzipcompression')) {
        return;
    }
    $script = basename($_SERVER['PHP_SELF']);
    if (!in_array($script, $cache_acceptable_files) && wp_cache_is_rejected($_SERVER["REQUEST_URI"])) {
        return;
    }
    if (wp_cache_user_agent_is_rejected()) {
        return;
    }
    ob_start('wp_cache_ob_callback');
    register_shutdown_function('wp_cache_ob_end');
}
开发者ID:sajidsan,项目名称:sajidsan.github.io,代码行数:40,代码来源:wp-cache-phase2.php

示例2: wp_cache_phase2

/** Diable here because PHP4.3 does not make the global
 Serious bug?

$mutex_filename = 'wp_cache_mutex.lock';
$new_cache = false;
*/
function wp_cache_phase2()
{
    global $cache_filename, $cache_acceptable_files, $wp_cache_meta_object;
    wp_cache_mutex_init();
    if (function_exists('add_action')) {
        // Post ID is received
        add_action('publish_post', 'wp_cache_post_change', 0);
        add_action('edit_post', 'wp_cache_post_change', 0);
        add_action('delete_post', 'wp_cache_post_change', 0);
        add_action('publish_phone', 'wp_cache_post_change', 0);
        // Coment ID is received
        add_action('trackback_post', 'wp_cache_get_postid_from_comment', 0);
        add_action('pingback_post', 'wp_cache_get_postid_from_comment', 0);
        add_action('comment_post', 'wp_cache_get_postid_from_comment', 0);
        add_action('edit_comment', 'wp_cache_get_postid_from_comment', 0);
        add_action('wp_set_comment_status', 'wp_cache_get_postid_from_comment', 0);
        // No post_id is available
        add_action('delete_comment', 'wp_cache_no_postid', 0);
        add_action('switch_theme', 'wp_cache_no_postid', 0);
    }
    //$script = basename($_SERVER['SCRIPT_NAME']);
    if ($_SERVER["REQUEST_METHOD"] == 'POST' || get_settings('gzipcompression')) {
        return;
    }
    $script = basename($_SERVER['PHP_SELF']);
    if (!in_array($script, $cache_acceptable_files) && wp_cache_is_rejected($_SERVER["REQUEST_URI"])) {
        return;
    }
    if (wp_cache_user_agent_is_rejected()) {
        return;
    }
    if (is_user_logged_in()) {
        return;
    }
    // don't cache pages of logged in users, that is lame.
    foreach ($_COOKIE as $key => $val) {
        if (strstr($key, 'comment_author')) {
            return;
            // don't perform caching of pages that commenters see, that is lame
        }
    }
    $wp_cache_meta_object = new CacheMeta();
    ob_start('wp_cache_ob_callback');
    register_shutdown_function('wp_cache_shutdown_callback');
}
开发者ID:ryan-allen,项目名称:w1000-super-total-mega-shark-cache-on-a-boat-on-a-plane,代码行数:51,代码来源:wp-cache-phase2.php

示例3: wp_cache_phase2

function wp_cache_phase2()
{
    global $cache_filename, $cache_acceptable_files, $wp_cache_gzip_encoding, $super_cache_enabled, $cache_rebuild_files, $wp_cache_gmt_offset, $wp_cache_blog_charset, $wp_cache_last_gc;
    global $cache_max_time, $wp_cache_not_logged_in, $wp_cache_request_uri, $super_cache_enabled;
    if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
        wp_cache_debug('In WP Cache Phase 2', 5);
    }
    $wp_cache_gmt_offset = get_option('gmt_offset');
    // caching for later use when wpdb is gone. http://wordpress.org/support/topic/224349
    $wp_cache_blog_charset = get_option('blog_charset');
    wp_cache_mutex_init();
    if (function_exists('add_action') && (!defined('WPLOCKDOWN') || defined('WPLOCKDOWN') && constant('WPLOCKDOWN') == '0')) {
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug('Setting up WordPress actions', 5);
        }
        // Post ID is received
        add_action('publish_post', 'wp_cache_post_edit', 0);
        add_action('edit_post', 'wp_cache_post_change', 0);
        // leaving a comment called edit_post
        add_action('delete_post', 'wp_cache_post_edit', 0);
        add_action('publish_phone', 'wp_cache_post_edit', 0);
        // Coment ID is received
        add_action('trackback_post', 'wp_cache_get_postid_from_comment', 99);
        add_action('pingback_post', 'wp_cache_get_postid_from_comment', 99);
        add_action('comment_post', 'wp_cache_get_postid_from_comment', 99);
        add_action('edit_comment', 'wp_cache_get_postid_from_comment', 99);
        add_action('wp_set_comment_status', 'wp_cache_get_postid_from_comment', 99, 2);
        // No post_id is available
        add_action('switch_theme', 'wp_cache_no_postid', 99);
        add_action('edit_user_profile_update', 'wp_cache_no_postid', 99);
        add_action('wp_cache_gc', 'wp_cache_gc_cron');
        do_cacheaction('add_cacheaction');
    }
    if (is_admin()) {
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug('Not caching wp-admin requests.', 5);
        }
        return false;
    }
    if ($_SERVER["REQUEST_METHOD"] == 'POST' || !empty($_POST) || get_option('gzipcompression')) {
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug('Not caching POST request.', 5);
        }
        return false;
    }
    if (isset($_GET['preview'])) {
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug('Not caching preview post.', 2);
        }
        return false;
    }
    if (!empty($_GET)) {
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug('Supercache caching disabled. Non empty GET request.', 5);
        }
        $super_cache_enabled = false;
    }
    if ($wp_cache_not_logged_in && is_user_logged_in() && !is_feed() && !is_admin()) {
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug('not caching for logged in user', 5);
            register_shutdown_function('wpcache_logged_in_message');
        }
        return false;
    }
    $script = basename($_SERVER['PHP_SELF']);
    if (!in_array($script, $cache_acceptable_files) && wp_cache_is_rejected($wp_cache_request_uri)) {
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug('URI rejected. Not Caching', 2);
        }
        return false;
    }
    if (wp_cache_user_agent_is_rejected()) {
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug("USER AGENT ({$_SERVER['HTTP_USER_AGENT']}) rejected. Not Caching", 4);
        }
        return;
    }
    if ($wp_cache_gzip_encoding) {
        header('Vary: Accept-Encoding, Cookie');
    } else {
        header('Vary: Cookie');
    }
    ob_start('wp_cache_ob_callback');
    if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
        wp_cache_debug('Created output buffer', 4);
    }
    // restore old supercache file temporarily
    if ($super_cache_enabled && $cache_rebuild_files) {
        $user_info = wp_cache_get_cookies_values();
        $do_cache = apply_filters('do_createsupercache', $user_info);
        if ($user_info == '' || $do_cache === true) {
            $dir = get_current_url_supercache_dir();
            $files_to_check = array($dir . 'index.html', $dir . 'index.html.gz');
            foreach ($files_to_check as $cache_file) {
                if (!@file_exists($cache_file . '.needs-rebuild')) {
                    continue;
                }
                $mtime = @filemtime($cache_file . '.needs-rebuild');
                if ($mtime && time() - $mtime < 30) {
                    if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
//.........这里部分代码省略.........
开发者ID:jeremylightsmith,项目名称:blog,代码行数:101,代码来源:wp-cache-phase2.php

示例4: wp_cache_phase2

function wp_cache_phase2()
{
    global $cache_filename, $cache_acceptable_files, $wp_cache_gzip_encoding, $super_cache_enabled, $cache_rebuild_files, $wp_cache_gmt_offset, $wp_cache_blog_charset, $wp_cache_last_gc;
    global $cache_max_time;
    $wp_cache_gmt_offset = get_option('gmt_offset');
    // caching for later use when wpdb is gone. http://wordpress.org/support/topic/224349
    $wp_cache_blog_charset = get_option('blog_charset');
    wp_cache_mutex_init();
    if (function_exists('add_action') && (!defined('WPLOCKDOWN') || defined('WPLOCKDOWN') && constant('WPLOCKDOWN') == '0')) {
        // Post ID is received
        add_action('publish_post', 'wp_cache_post_edit', 0);
        add_action('edit_post', 'wp_cache_post_change', 0);
        // leaving a comment called edit_post
        add_action('delete_post', 'wp_cache_post_edit', 0);
        add_action('publish_phone', 'wp_cache_post_edit', 0);
        // Coment ID is received
        add_action('trackback_post', 'wp_cache_get_postid_from_comment', 99);
        add_action('pingback_post', 'wp_cache_get_postid_from_comment', 99);
        add_action('comment_post', 'wp_cache_get_postid_from_comment', 99);
        add_action('edit_comment', 'wp_cache_get_postid_from_comment', 99);
        add_action('wp_set_comment_status', 'wp_cache_get_postid_from_comment', 99);
        // No post_id is available
        add_action('delete_comment', 'wp_cache_no_postid', 99);
        add_action('switch_theme', 'wp_cache_no_postid', 99);
        add_action('wp_cache_gc', 'wp_cache_gc_cron');
        do_cacheaction('add_cacheaction');
    }
    if ($_SERVER["REQUEST_METHOD"] == 'POST' || get_option('gzipcompression')) {
        return;
    }
    $script = basename($_SERVER['PHP_SELF']);
    if (!in_array($script, $cache_acceptable_files) && wp_cache_is_rejected($_SERVER["REQUEST_URI"])) {
        return;
    }
    if (wp_cache_user_agent_is_rejected()) {
        return;
    }
    if ($wp_cache_gzip_encoding) {
        header('Vary: Accept-Encoding, Cookie');
    } else {
        header('Vary: Cookie');
    }
    ob_start('wp_cache_ob_callback');
    // restore old supercache file temporarily
    if ($super_cache_enabled && $cache_rebuild_files) {
        $user_info = wp_cache_get_cookies_values();
        $do_cache = apply_filters('do_createsupercache', $user_info);
        if ($user_info == '' || $do_cache === true) {
            $dir = get_current_url_supercache_dir();
            $files_to_check = array($dir . 'index.html', $dir . 'index.html.gz');
            foreach ($files_to_check as $cache_file) {
                if (!@file_exists($cache_file . '.needs-rebuild')) {
                    continue;
                }
                $mtime = @filemtime($cache_file . '.needs-rebuild');
                if ($mtime && time() - $mtime < 30) {
                    @rename($cache_file . '.needs-rebuild', $cache_file);
                }
                // cleanup old files or if rename fails
                if (@file_exists($cache_file . '.needs-rebuild')) {
                    @unlink($cache_file . '.needs-rebuild');
                }
            }
        }
    }
    if (!isset($cache_max_time)) {
        $cache_max_time = 600;
    }
    $last_gc = get_option("wpsupercache_gc_time");
    if (!$last_gc) {
        update_option('wpsupercache_gc_time', time());
    }
    $next_gc = $cache_max_time < 1800 ? $cache_max_time : 600;
    if ($last_gc < time() - $next_gc) {
        update_option('wpsupercache_gc_time', time());
        global $wp_cache_shutdown_gc;
        if (!isset($wp_cache_shutdown_gc) || $wp_cache_shutdown_gc == 0) {
            if (!wp_next_scheduled('wp_cache_gc')) {
                wp_schedule_single_event(time() + 10, 'wp_cache_gc');
            }
        } else {
            global $time_to_gc_cache;
            $time_to_gc_cache = 1;
            // tell the "shutdown gc" to run!
        }
    }
}
开发者ID:emoksha,项目名称:freefairelections,代码行数:87,代码来源:wp-cache-phase2.php

示例5: 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

示例6: wp_cache_phase2

function wp_cache_phase2()
{
    global $wpsc_settings;
    global $cache_filename, $cache_acceptable_files, $wp_cache_gzip_encoding, $super_cache_enabled, $cache_rebuild_files, $wp_cache_last_gc;
    global $cache_max_time, $wp_cache_request_uri, $super_cache_enabled, $wp_cache_object_cache, $cache_time_interval;
    global $cache_enabled, $wp_cache_gmt_offset, $wp_cache_blog_charset, $cache_schedule_type, $cache_scheduled_time, $cache_schedule_interval;
    if ($cache_enabled == false) {
        return false;
    }
    if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
        wp_cache_debug('In WP Cache Phase 2', 5);
    }
    $wp_cache_gmt_offset = get_option('gmt_offset');
    // caching for later use when wpdb is gone. http://wordpress.org/support/topic/224349
    $wp_cache_blog_charset = get_option('blog_charset');
    wp_cache_mutex_init();
    if (function_exists('add_action') && (!defined('WPLOCKDOWN') || defined('WPLOCKDOWN') && constant('WPLOCKDOWN') == '0')) {
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug('Setting up WordPress actions', 5);
        }
        // Post ID is received
        add_action('publish_post', 'wp_cache_post_edit', 0);
        add_action('edit_post', 'wp_cache_post_change', 0);
        // leaving a comment called edit_post
        add_action('delete_post', 'wp_cache_post_edit', 0);
        add_action('publish_phone', 'wp_cache_post_edit', 0);
        // Coment ID is received
        add_action('trackback_post', 'wp_cache_get_postid_from_comment', 99);
        add_action('pingback_post', 'wp_cache_get_postid_from_comment', 99);
        add_action('comment_post', 'wp_cache_get_postid_from_comment', 99);
        add_action('edit_comment', 'wp_cache_get_postid_from_comment', 99);
        add_action('wp_set_comment_status', 'wp_cache_get_postid_from_comment', 99, 2);
        // No post_id is available
        add_action('switch_theme', 'wp_cache_no_postid', 99);
        add_action('edit_user_profile_update', 'wp_cache_no_postid', 99);
        add_action('wp_update_nav_menu', 'wp_cache_clear_cache');
        add_action('wp_cache_gc', 'wp_cache_gc_cron');
        add_filter('supercache_filename_str', 'wp_cache_check_mobile');
        do_cacheaction('add_cacheaction');
    }
    if (is_admin()) {
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug('Not caching wp-admin requests.', 5);
        }
        return false;
    }
    if ($_SERVER["REQUEST_METHOD"] == 'POST' || !empty($_POST) || get_option('gzipcompression')) {
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug('Not caching POST request.', 5);
        }
        return false;
    }
    if ($wp_cache_object_cache && !empty($_GET)) {
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug('Not caching GET request while object cache storage enabled.', 5);
        }
        return false;
    }
    if (isset($_GET['preview'])) {
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug('Not caching preview post.', 2);
        }
        return false;
    }
    if (!empty($_GET)) {
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug('Supercache caching disabled. Only using wp-cache. Non empty GET request.', 5);
        }
        $super_cache_enabled = false;
    }
    $script = basename($_SERVER['PHP_SELF']);
    if (!in_array($script, $cache_acceptable_files) && wp_cache_is_rejected($wp_cache_request_uri)) {
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug('URI rejected. Not Caching', 2);
        }
        return false;
    }
    if (wp_cache_user_agent_is_rejected()) {
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug("USER AGENT ({$_SERVER['HTTP_USER_AGENT']}) rejected. Not Caching", 4);
        }
        return;
    }
    if ($wp_cache_gzip_encoding) {
        header('Vary: Accept-Encoding, Cookie');
    } else {
        header('Vary: Cookie');
    }
    ob_start('wp_cache_ob_callback');
    if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
        wp_cache_debug('Created output buffer', 4);
    }
    // restore old supercache file temporarily
    if ($super_cache_enabled && $cache_rebuild_files) {
        $user_info = wp_cache_get_cookies_values();
        $do_cache = apply_filters('do_createsupercache', $user_info);
        if ($user_info == '' || $do_cache === true) {
            wpcache_do_rebuild(get_current_url_supercache_dir());
        }
    }
//.........这里部分代码省略.........
开发者ID:rubyerme,项目名称:rubyerme.github.com,代码行数:101,代码来源:wp-cache-phase2.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: wp_cache_ob_callback

function wp_cache_ob_callback($buffer)
{
    global $wp_cache_pages, $wp_query, $wp_super_cache_query, $cache_acceptable_files, $wp_cache_no_cache_for_get, $wp_cache_object_cache, $wp_cache_request_uri;
    $buffer = apply_filters('wp_cache_ob_callback_filter', $buffer);
    $script = basename($_SERVER['PHP_SELF']);
    // All the things that can stop a page being cached
    $cache_this_page = true;
    if (defined('DONOTCACHEPAGE')) {
        wp_cache_debug('DONOTCACHEPAGE defined. Caching disabled.', 2);
        $cache_this_page = false;
    } elseif ($wp_cache_no_cache_for_get && false == empty($_GET) && false == defined('DOING_CRON')) {
        wp_cache_debug("Non empty GET request. Caching disabled on settings page. " . serialize($_GET), 1);
        $cache_this_page = false;
    } elseif ($_SERVER["REQUEST_METHOD"] == 'POST' || !empty($_POST) || get_option('gzipcompression')) {
        wp_cache_debug('Not caching POST request.', 5);
        $cache_this_page = false;
    } elseif ($wp_cache_object_cache && !empty($_GET)) {
        wp_cache_debug('Not caching GET request while object cache storage enabled.', 5);
        $cache_this_page = false;
    } elseif (isset($_GET['preview'])) {
        wp_cache_debug('Not caching preview post.', 2);
        $cache_this_page = false;
    } elseif (!in_array($script, $cache_acceptable_files) && wp_cache_is_rejected($wp_cache_request_uri)) {
        wp_cache_debug('URI rejected. Not Caching', 2);
        $cache_this_page = false;
    } elseif (wp_cache_user_agent_is_rejected()) {
        wp_cache_debug("USER AGENT ({$_SERVER['HTTP_USER_AGENT']}) rejected. Not Caching", 4);
        $cache_this_page = false;
    } elseif (isset($wp_cache_pages['single']) && $wp_cache_pages['single'] == 1 && isset($wp_super_cache_query['is_single'])) {
        wp_cache_debug('Not caching single post.', 2);
        $cache_this_page = false;
    } elseif (isset($wp_cache_pages['pages']) && $wp_cache_pages['pages'] == 1 && isset($wp_super_cache_query['is_page'])) {
        wp_cache_debug('Not caching single page.', 2);
        $cache_this_page = false;
    } elseif (isset($wp_cache_pages['archives']) && $wp_cache_pages['archives'] == 1 && isset($wp_super_cache_query['is_archive'])) {
        wp_cache_debug('Not caching archive page.', 2);
        $cache_this_page = false;
    } elseif (isset($wp_cache_pages['tag']) && $wp_cache_pages['tag'] == 1 && isset($wp_super_cache_query['is_tag'])) {
        wp_cache_debug('Not caching tag page.', 2);
        $cache_this_page = false;
    } elseif (isset($wp_cache_pages['category']) && $wp_cache_pages['category'] == 1 && isset($wp_super_cache_query['is_category'])) {
        wp_cache_debug('Not caching category page.', 2);
        $cache_this_page = false;
    } elseif (isset($wp_cache_pages['frontpage']) && $wp_cache_pages['frontpage'] == 1 && isset($wp_super_cache_query['is_front_page'])) {
        wp_cache_debug('Not caching front page.', 2);
        $cache_this_page = false;
    } elseif (isset($wp_cache_pages['home']) && $wp_cache_pages['home'] == 1 && isset($wp_super_cache_query['is_home'])) {
        wp_cache_debug('Not caching home page.', 2);
        $cache_this_page = false;
    } elseif (isset($wp_cache_pages['search']) && $wp_cache_pages['search'] == 1 && isset($wp_super_cache_query['is_search'])) {
        wp_cache_debug('Not caching search page.', 2);
        $cache_this_page = false;
    } elseif (isset($wp_cache_pages['author']) && $wp_cache_pages['author'] == 1 && isset($wp_super_cache_query['is_author'])) {
        wp_cache_debug('Not caching author page.', 2);
        $cache_this_page = false;
    } elseif (isset($wp_cache_pages['feed']) && $wp_cache_pages['feed'] == 1 && isset($wp_super_cache_query['is_feed'])) {
        wp_cache_debug('Not caching feed.', 2);
        $cache_this_page = false;
    }
    if (!isset($wp_query)) {
        wp_cache_debug('wp_cache_ob_callback: WARNING! $query not defined but the plugin has worked around that problem.', 4);
    }
    if ($cache_this_page) {
        wp_cache_debug('Output buffer callback', 4);
        $buffer = wp_cache_get_ob($buffer);
        wp_cache_shutdown_callback();
        return $buffer;
    } else {
        return wp_cache_maybe_dynamic($buffer);
    }
}
开发者ID:KurtMakesWeb,项目名称:CandG,代码行数:71,代码来源:wp-cache-phase2.php

示例9: 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

示例10: wp_cache_phase2

function wp_cache_phase2()
{
    global $cache_filename, $cache_acceptable_files, $wp_cache_meta_object, $wp_cache_gzip_encoding, $super_cache_enabled, $cache_rebuild_files;
    wp_cache_mutex_init();
    if (function_exists('add_action') && (!defined('WPLOCKDOWN') || defined('WPLOCKDOWN') && constant('WPLOCKDOWN') == '0')) {
        // Post ID is received
        add_action('publish_post', 'wp_cache_post_edit', 0);
        add_action('edit_post', 'wp_cache_post_change', 0);
        // leaving a comment called edit_post
        add_action('delete_post', 'wp_cache_post_edit', 0);
        add_action('publish_phone', 'wp_cache_post_edit', 0);
        // Coment ID is received
        add_action('trackback_post', 'wp_cache_get_postid_from_comment', 0);
        add_action('pingback_post', 'wp_cache_get_postid_from_comment', 0);
        add_action('comment_post', 'wp_cache_get_postid_from_comment', 0);
        add_action('edit_comment', 'wp_cache_get_postid_from_comment', 0);
        add_action('wp_set_comment_status', 'wp_cache_get_postid_from_comment', 0);
        // No post_id is available
        add_action('delete_comment', 'wp_cache_no_postid', 0);
        add_action('switch_theme', 'wp_cache_no_postid', 0);
        add_action('wp_cache_gc', 'wp_cache_gc_cron');
        do_cacheaction('add_cacheaction');
    }
    if ($_SERVER["REQUEST_METHOD"] == 'POST' || get_option('gzipcompression')) {
        return;
    }
    $script = basename($_SERVER['PHP_SELF']);
    if (!in_array($script, $cache_acceptable_files) && wp_cache_is_rejected($_SERVER["REQUEST_URI"])) {
        return;
    }
    if (wp_cache_user_agent_is_rejected()) {
        return;
    }
    if (!is_object($wp_cache_meta_object)) {
        $wp_cache_meta_object = new CacheMeta();
    }
    if ($wp_cache_gzip_encoding) {
        header('Vary: Accept-Encoding, Cookie');
    } else {
        header('Vary: Cookie');
    }
    ob_start('wp_cache_ob_callback');
    // restore old supercache file temporarily
    if ($super_cache_enabled && $cache_rebuild_files) {
        $user_info = wp_cache_get_cookies_values();
        $do_cache = apply_filters('do_createsupercache', $user_info);
        if ($user_info == '' || $do_cache === true) {
            $dir = get_current_url_supercache_dir();
            $files_to_check = array($dir . 'index.html', $dir . 'index.html.gz');
            foreach ($files_to_check as $cache_file) {
                if (!file_exists($cache_file . '.needs-rebuild')) {
                    continue;
                }
                $mtime = @filemtime($cache_file . '.needs-rebuild');
                if ($mtime && time() - $mtime < 30) {
                    @rename($cache_file . '.needs-rebuild', $cache_file);
                }
                // cleanup old files or if rename fails
                if (@file_exists($cache_file . '.needs-rebuild')) {
                    @unlink($cache_file . '.needs-rebuild');
                }
            }
        }
    }
    register_shutdown_function('wp_cache_shutdown_callback');
}
开发者ID:alx,项目名称:barceloneta,代码行数:66,代码来源:wp-cache-phase2.php

示例11: 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;
    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 (file_exists($cache_file)) {
        if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
            wp_cache_debug("wp-cache file exists", 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;
        }
        $cache_file = do_cacheaction('wp_cache_served_cache_file', $cache_file);
        // Sometimes the gzip headers are lost. If this is a gzip capable client, send those headers.
        if ($wp_cache_gzip_encoding && !in_array('Content-Encoding: ' . $wp_cache_gzip_encoding, $meta['headers'])) {
            $meta['headers']['Content-Encoding'] = 'Content-Encoding: ' . $wp_cache_gzip_encoding;
            $meta['headers']['Vary'] = 'Vary: Accept-Encoding, Cookie';
            if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
                wp_cache_debug("added gzip headers before serving.", 1);
            }
        }
        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 ($meta['dynamic']) {
            if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
                wp_cache_debug("Serving wp-cache dynamic file", 5);
            }
            include $cache_file;
        } else {
            if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
                wp_cache_debug("Serving wp-cache static file", 5);
            }
            readfile($cache_file);
        }
        if (isset($wp_super_cache_debug) && $wp_super_cache_debug) {
            wp_cache_debug("exit request", 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);
        }
    }
}
开发者ID:jeremylightsmith,项目名称:blog,代码行数:65,代码来源:wp-cache-phase1.php


注:本文中的wp_cache_user_agent_is_rejected函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。