當前位置: 首頁>>代碼示例>>PHP>>正文


PHP http::cache_max_age方法代碼示例

本文整理匯總了PHP中http::cache_max_age方法的典型用法代碼示例。如果您正苦於以下問題:PHP http::cache_max_age方法的具體用法?PHP http::cache_max_age怎麽用?PHP http::cache_max_age使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在http的用法示例。


在下文中一共展示了http::cache_max_age方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: array

    http::head(404, 'Not Found');
    exit;
}
$allow_types = array('png', 'jpg', 'jpeg', 'gif', 'css', 'js', 'swf');
$pf = path::clean($_GET['pf']);
$paths = array_reverse(explode(PATH_SEPARATOR, DC_PLUGINS_ROOT));
# Adding admin/res folder here to load some stuff
$paths[] = dirname(__FILE__) . '/swf';
foreach ($paths as $m) {
    $PF = path::real($m . '/' . $pf);
    if ($PF !== false) {
        break;
    }
}
unset($paths);
if ($PF === false || !is_file($PF) || !is_readable($PF)) {
    header('Content-Type: text/plain');
    http::head(404, 'Not Found');
    exit;
}
if (!in_array(files::getExtension($PF), $allow_types)) {
    header('Content-Type: text/plain');
    http::head(404, 'Not Found');
    exit;
}
http::$cache_max_age = 7200;
http::cache(array_merge(array($PF), get_included_files()));
header('Content-Type: ' . files::getMimeType($PF));
header('Content-Length: ' . filesize($PF));
readfile($PF);
exit;
開發者ID:HackerMajor,項目名稱:root,代碼行數:31,代碼來源:load_plugin_file.php

示例2: dirname

$pf = path::clean($_GET['pf']);
$paths = array_reverse(explode(PATH_SEPARATOR, DC_PLUGINS_ROOT));
# Adding some folders here to load some stuff
$paths[] = dirname(__FILE__) . '/swf';
$paths[] = dirname(__FILE__) . '/js';
$paths[] = dirname(__FILE__) . '/css';
foreach ($paths as $m) {
    $PF = path::real($m . '/' . $pf);
    if ($PF !== false) {
        break;
    }
}
unset($paths);
if ($PF === false || !is_file($PF) || !is_readable($PF)) {
    header('Content-Type: text/plain');
    http::head(404, 'Not Found');
    exit;
}
if (!in_array(files::getExtension($PF), $allow_types)) {
    header('Content-Type: text/plain');
    http::head(404, 'Not Found');
    exit;
}
http::$cache_max_age = 7 * 24 * 60 * 60;
// One week cache for plugin's files served by ?pf=… is better than old 2 hours
http::cache(array_merge(array($PF), get_included_files()));
header('Content-Type: ' . files::getMimeType($PF));
// Content-length is not mandatory and must be the exact size of content transfered AFTER possible compression (gzip, deflate, …)
//header('Content-Length: '.filesize($PF));
readfile($PF);
exit;
開發者ID:nikrou,項目名稱:dotclear,代碼行數:31,代碼來源:load_plugin_file.php


注:本文中的http::cache_max_age方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。