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


PHP get_cache_file函数代码示例

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


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

示例1: get_category_dropdown

        $old_session_mode = $site_sess->mode;
        $site_sess->mode = 'get';
        // Set $cat_id to 0 to ensure that no category is selected
        $category_dropdown_selfjump = get_category_dropdown(0, 1);
        $site_sess->mode = $old_session_mode;
        save_cache_file($cache_id, $category_dropdown_selfjump);
    }
}
$site_template->register_vars("category_dropdown_selfjump", $category_dropdown_selfjump);
unset($category_dropdown_selfjump);
// -------------------------------------
if (!$cache_enable) {
    $category_dropdown_form = $site_template->parse_template("category_dropdown_form");
} else {
    $cache_id = create_cache_id('data.dropdown_form', array($user_info[$user_table_fields['user_id']], $config['template_dir'], $config['language_dir']));
    if (!($category_dropdown_form = get_cache_file($cache_id))) {
        // Always append session id if cache is enabled
        $old_session_mode = $site_sess->mode;
        $site_sess->mode = 'get';
        $category_dropdown_form = $site_template->parse_template("category_dropdown_form");
        $site_sess->mode = $old_session_mode;
        save_cache_file($cache_id, $category_dropdown_form);
    }
}
$site_template->register_vars("category_dropdown_form", $category_dropdown_form);
unset($category_dropdown_form);
//-----------------------------------------------------
//--- Random Image ------------------------------------
//-----------------------------------------------------
$random_image = defined("SHOW_RANDOM_IMAGE") && SHOW_RANDOM_IMAGE == 0 ? "" : get_random_image();
$site_template->register_vars("random_image", $random_image);
开发者ID:4images,项目名称:4images,代码行数:31,代码来源:page_header.php

示例2: show_cache_file

/**
 *
 */
function show_cache_file($mime_type)
{
    $cache_file = DIRECTORY_CACHE . '/' . get_cache_file();
    if (file_exists($cache_file)) {
        $gmdate_mod = gmdate("D, d M Y H:i:s", filemtime($cache_file));
        if (!strstr($gmdate_mod, "GMT")) {
            $gmdate_mod .= " GMT";
        }
        if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"])) {
            // check for updates
            $if_modified_since = preg_replace("/;.*\$/", "", $_SERVER["HTTP_IF_MODIFIED_SINCE"]);
            if ($if_modified_since == $gmdate_mod) {
                header("HTTP/1.1 304 Not Modified");
                die;
            }
        }
        clearstatcache();
        $fileSize = filesize($cache_file);
        // send headers then display image
        header('Content-Type: ' . $mime_type);
        header('Accept-Ranges: bytes');
        header('Last-Modified: ' . $gmdate_mod);
        header('Content-Length: ' . $fileSize);
        header('Cache-Control: max-age=9999, must-revalidate');
        header('Expires: ' . $gmdate_mod);
        readfile($cache_file);
        die;
    }
}
开发者ID:OvayoMonti,项目名称:showofhands,代码行数:32,代码来源:timthumb.php

示例3: show_cache_file

/**
 *
 * @param <type> $mime_type
 * @return <type> 
 */
function show_cache_file($mime_type)
{
    // use browser cache if available to speed up page load
    if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
        if (strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) < strtotime('now')) {
            header('HTTP/1.1 304 Not Modified');
            die;
        }
    }
    $cache_file = get_cache_file($mime_type);
    if (file_exists($cache_file)) {
        // change the modified headers
        $gmdate_expires = gmdate('D, d M Y H:i:s', strtotime('now +10 days')) . ' GMT';
        $gmdate_modified = gmdate('D, d M Y H:i:s') . ' GMT';
        // send content headers then display image
        header('Content-Type: ' . $mime_type);
        header('Accept-Ranges: bytes');
        header('Last-Modified: ' . $gmdate_modified);
        header('Content-Length: ' . filesize($cache_file));
        header('Cache-Control: max-age=' . CACHE_MAX_AGE . ', must-revalidate');
        header('Expires: ' . $gmdate_expires);
        if (!@readfile($cache_file)) {
            $content = file_get_contents($cache_file);
            if ($content != FALSE) {
                echo $content;
            } else {
                display_error('cache file could not be loaded');
            }
        }
        die;
    }
    return FALSE;
}
开发者ID:BrunoDuarte,项目名称:WS_PHP_ADMIN,代码行数:38,代码来源:tim.php

示例4: str_replace

        global $script_url;
        $url = $script_url . '/' . $url;
    }
    return str_replace('./', '', $url);
}
function get_rss_enclosure($file_name, $image_type, $cat_id)
{
    if (!get_file_path($file_name, $image_type, $cat_id, 0, 0)) {
        return array();
    }
    $file = get_file_path($file_name, $image_type, $cat_id, 0, 1);
    $url = get_file_url($file_name, $image_type, $cat_id);
    return array('url' => $url, 'length' => @filesize($file), 'type' => get_mime_content_type($file));
}
$cache_id = create_cache_id('page.rss', array($user_info[$user_table_fields['user_id']], $action, $image_id, $cat_id, $num_items));
if (!$cache_page_rss || !($content = get_cache_file($cache_id))) {
    $old_session_mode = $site_sess->mode;
    $site_sess->mode = 'cookie';
    ob_start();
    $rss_title = format_rss_text($config['site_name']);
    $rss_link = $site_sess->url($script_url);
    $rss_desc = format_rss_text($config['site_name']);
    $rss_lang = "";
    $rss_image = array();
    $rss_ttl = $cache_page_rss ? $cache_lifetime : 0;
    $rss_cat = array();
    $rss_items = array();
    switch ($action) {
        case 'comments':
            if (!$image_id) {
                exit;
开发者ID:4images,项目名称:4images,代码行数:31,代码来源:rss.php

示例5: get_cache_expiration

 function get_cache_expiration($uri_string)
 {
     $cache_path = get_cache_file($uri_string);
     if (!@file_exists($cache_path)) {
         return FALSE;
     }
     if (!($fp = @fopen($cache_path, FOPEN_READ))) {
         return FALSE;
     }
     flock($fp, LOCK_SH);
     $time_str = '';
     while (($char = fgetc($fp)) !== FALSE) {
         if ($char === 'T') {
             break;
         }
         $time_str .= $char;
     }
     flock($fp, LOCK_UN);
     fclose($fp);
     if (ctype_digit($time_str)) {
         return (int) $time_str;
     } else {
         return FALSE;
     }
 }
开发者ID:aslijiasheng,项目名称:ciFramework,代码行数:25,代码来源:cache_helper.php

示例6: show_cache_file

/**
 * 
 */
function show_cache_file($cache_dir) {

	$cache_file = $cache_dir . '/' . get_cache_file();

	if (file_exists($cache_file)) {
    	
		$gmdate_mod = gmdate("D, d M Y H:i:s", filemtime($cache_file));
		
		if(! strstr($gmdate_mod, "GMT")) {
			$gmdate_mod .= " GMT";
		}
		
		if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"])) {
		
			// check for updates
			$if_modified_since = preg_replace("/;.*$/", "", $_SERVER["HTTP_IF_MODIFIED_SINCE"]);
			
			if ($if_modified_since == $gmdate_mod) {
				header("HTTP/1.1 304 Not Modified");
				exit;
			}

		}
		
		$fileSize = filesize($cache_file);
		
		// send headers then display image
		header("Content-Type: image/png");
		header("Accept-Ranges: bytes");
		header("Last-Modified: " . $gmdate_mod);
		header("Content-Length: " . $fileSize);
		header("Cache-Control: max-age=9999, must-revalidate");
		header("Expires: " . $gmdate_mod);
		
		readfile($cache_file);
		
		exit;

	}
	
}
开发者ID:nebirhos,项目名称:cargopress,代码行数:44,代码来源:timthumb.php

示例7: define

 *                                                                        *
 *************************************************************************/
$templates_used = 'categories,category_bit,thumbnail_bit';
$main_template = 'categories';
define('GET_CACHES', 1);
define('ROOT_PATH', './');
define('MAIN_SCRIPT', __FILE__);
include ROOT_PATH . 'global.php';
require ROOT_PATH . 'includes/sessions.php';
$user_access = get_permission();
include ROOT_PATH . 'includes/page_header.php';
if (!$cat_id || !isset($cat_cache[$cat_id]) || !check_permission("auth_viewcat", $cat_id)) {
    redirect("index.php");
}
$cache_id = create_cache_id('page.categories', array($user_info[$user_table_fields['user_id']], $cat_id, $page, $perpage, isset($user_info['lightbox_image_ids']) ? substr(md5($user_info['lightbox_image_ids']), 0, 8) : 0, $config['template_dir'], $config['language_dir']));
if (!$cache_page_categories || !($content = get_cache_file($cache_id))) {
    // Always append session id if cache is enabled
    if ($cache_page_categories) {
        $old_session_mode = $site_sess->mode;
        $site_sess->mode = 'get';
    }
    ob_start();
    //-----------------------------------------------------
    //--- SEO variables -----------------------------------
    //-----------------------------------------------------
    $site_template->register_vars(array('prepend_head_title' => $cat_cache[$cat_id]['cat_name'] . " - "));
    //-----------------------------------------------------
    //--- Show Categories ---------------------------------
    //-----------------------------------------------------
    if (!check_permission("auth_upload", $cat_id)) {
        $upload_url = "";
开发者ID:abhinay100,项目名称:fourimages_app,代码行数:31,代码来源:categories.php

示例8: show_cache_file

/**
 *
 * @param <type> $mime_type 
 */
function show_cache_file($mime_type)
{
    $cache_file = get_cache_file($mime_type);
    if (file_exists($cache_file)) {
        // use browser cache if available to speed up page load
        if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
            if (strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) < strtotime('now')) {
                header('HTTP/1.1 304 Not Modified');
                die;
            }
        }
        clearstatcache();
        $fileSize = filesize($cache_file);
        // change the modified headers
        $gmdate_expires = gmdate("D, d M Y H:i:s", time() + 315360000) . ' GMT';
        $gmdate_modified = gmdate('D, d M Y H:i:s') . ' GMT';
        // send content headers then display image
        header('Content-Type: ' . $mime_type);
        header('Accept-Ranges: bytes');
        header('Last-Modified: ' . $gmdate_modified);
        header('Content-Length: ' . $fileSize);
        header('Cache-Control: max-age=315360000, public');
        header('Expires: ' . $gmdate_expires);
        if (!@readfile($cache_file)) {
            $content = file_get_contents($cache_file);
            if ($content != FALSE) {
                echo $content;
            } else {
                display_error('cache file could not be loaded');
            }
        }
        // we've shown the image so stop processing
        die;
    }
}
开发者ID:netwolf103,项目名称:dvpoo,代码行数:39,代码来源:timthumb.php

示例9: has_cache_for

function has_cache_for($anime_name)
{
    $file = get_cache_file($anime_name);
    return file_exists($file) && filemtime($file) - time() < CACHE_REFRESH_TIME;
}
开发者ID:Vazkii,项目名称:TenoriTaiga,代码行数:5,代码来源:index.php

示例10: amr_cache_url

function amr_cache_url($url, $cache = ICAL_EVENTS_CACHE_TTL)
{
    global $amr_lastcache;
    global $amr_globaltz;
    global $amr_options;
    $text = '';
    // if any args are sent then all must be sent - use wp defaults more or less
    // so better to use filters
    add_filter('http_request_timeout', 'amr_set_http_timeout');
    //add_filter( 'http_request_redirection_count', 'amr_' );
    //'httpversion' => apply_filters( 'http_request_version', '1.0' ),  //or 1.1
    /*
    	curl_setopt($c, CURLOPT_RETURNTRANSFER, true);  // just says to return rather than echo
    	curl_setopt($c, CURLOPT_USERAGENT, 'PHP/'.PHP_VERSION);
    	curl_setopt($c, CURLOPT_ENCODING, '');
    	if( strstr( $resource, 'https' ) !== FALSE ) {
    		curl_setopt($c, CURLOPT_SSLVERSION, 3);
    		curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
    		curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 2);
    	}
    	curl_setopt($c, CURLOPT_COOKIESESSION, true);
    	curl_setopt($c, CURLOPT_HEADER, true);
    	if( !ini_get('safe_mode') ){
    		curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
    	}
    */
    //		If (ICAL_EVENTS_DEBUG) echo '<hr />url before decode: '.$url.'<br />';
    $url = html_entity_decode($url);
    //		If (ICAL_EVENTS_DEBUG) echo '<br />url decoded: '.$url.'<hr />';
    $cachedfile = get_cache_file($url);
    if (file_exists($cachedfile)) {
        $c = filemtime($cachedfile);
        if ($c) {
            $amr_lastcache = amr_newDateTime(strftime('%c', $c));
        } else {
            $amr_lastcache = '';
        }
    } else {
        $c = false;
        $amr_lastcache = amr_newDateTime(strftime('%c', 0));
    }
    // must we refresh ?
    if (isset($_REQUEST['nocache']) or isset($_REQUEST['refresh']) or !file_exists($cachedfile) or time() - $c >= $cache * 60 * 60) {
        if (ICAL_EVENTS_DEBUG) {
            echo '<br>Get ical file remotely, it is time to refresh or it is not cached: <br />';
        }
        amrical_mem_debug('We are going to refresh next');
        //$url = urlencode($u);  - do NOT encode - that gives an invalid URL response
        $check = wp_remote_get($url);
        // if use args, must set all - rather use filters and let wp do its thing
        if (is_wp_error($check) or isset($check['response']['code']) and !($check['response']['code'] == 200) or isset($check[0]) and preg_match('#404#', $check[0])) {
            /* is this bit still meaningful or needed ? */
            if (ICAL_EVENTS_DEBUG) {
                echo '<hr /><b>Http request failed </b><br /> Dumping response: ';
                var_dump($check);
            }
            if (is_wp_error($check)) {
                $text = '<br />' . $check->get_error_message() . '</br>';
            } else {
                $text = '';
            }
            $data = false;
        } elseif (!stristr($check['headers']['content-type'], 'text/calendar')) {
            if (amr_check_start_of_file($data = $check['body'])) {
                // well wrong content type, but has the content!! - bad calendar provider
                $data = $check['body'];
                if (current_user_can('manage_options')) {
                    echo '<br />This message is only shown to the administrator, and only when we refresh the file.';
                    echo '<br />The ics url given is issuing an incorrect content type of text/html.' . ' It should be text/calendar. ' . ' Luckily we persevere and check if the content looks like an ics file.' . 'Please inform the provider of the url. ' . 'Their urls may not be recognised by browsers as ics files. <br />';
                }
            } else {
                if (ICAL_EVENTS_DEBUG) {
                    echo '<br />The url given is not returning a calendar file';
                    echo '<br />The response was ';
                    var_dump($check['response']);
                    echo '<br />The content type is ' . $check['headers']['content-type'];
                    echo '<br />The content type of an ics file should be text/calendar. <br />';
                }
                $data = false;
            }
        } else {
            $data = $check['body'];
        }
        // from the http request
        if (!amr_check_start_of_file($data)) {
            $text .= '&nbsp;' . sprintf(__('Error getting calendar file with htpp or curl %s', 'amr-ical-events-list'), $url);
            if (file_exists($cachedfile)) {
                // Try use cached file if it exists
                if (is_object($amr_lastcache)) {
                    $text .= '&nbsp;...' . sprintf(__('Using File last cached at %s', 'amr-ical-events-list'), $amr_lastcache->format('D c'));
                } else {
                    $text .= '&nbsp;...' . __('File last cached time not available', 'amr-ical-events-list');
                }
                echo '<a class="error" href="#" title="' . __('Warning: Events may be out of date. ', 'amr-ical-events-list') . $text . '">!</a>';
                return $cachedfile;
                //return file not data
            } else {
                echo '<a class="error" href="#" title="' . __('No cached ical file for events', 'amr-ical-events-list') . $text . '">!</a>';
                return false;
            }
//.........这里部分代码省略.........
开发者ID:greg3560,项目名称:plailly,代码行数:101,代码来源:amr-import-ical.php

示例11: str_replace

        $template = "";
    } else {
        $main_template = $template;
    }
} else {
    $template = "";
}
include ROOT_PATH . 'includes/page_header.php';
if (!empty($template)) {
    $clickstream = "<a href=\"" . $site_sess->url(ROOT_PATH . "index.php") . "\">" . $lang['home'] . "</a>" . $config['category_separator'] . str_replace("_", " ", ucfirst($template));
    $site_template->register_vars("clickstream", $clickstream);
    $site_template->print_template($site_template->parse_template($main_template));
    include ROOT_PATH . 'includes/page_footer.php';
}
$cache_id = create_cache_id('page.index', array($user_info[$user_table_fields['user_id']], isset($user_info['lightbox_image_ids']) ? substr(md5($user_info['lightbox_image_ids']), 0, 8) : 0, $config['template_dir'], $config['language_dir']));
if (!$cache_page_index || !($content = get_cache_file($cache_id))) {
    // Always append session id if cache is enabled
    if ($cache_page_index) {
        $old_session_mode = $site_sess->mode;
        $site_sess->mode = 'get';
    }
    ob_start();
    //-----------------------------------------------------
    //--- Show Categories ---------------------------------
    //-----------------------------------------------------
    $categories = get_categories(0);
    if (!$categories) {
        $categories = $lang['no_categories'];
    }
    $site_template->register_vars("categories", $categories);
    unset($categories);
开发者ID:abhinay100,项目名称:fourimages_app,代码行数:31,代码来源:index.php


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