当前位置: 首页>>代码示例>>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;未经允许,请勿转载。