本文整理匯總了PHP中http::etag方法的典型用法代碼示例。如果您正苦於以下問題:PHP http::etag方法的具體用法?PHP http::etag怎麽用?PHP http::etag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類http
的用法示例。
在下文中一共展示了http::etag方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: serveDocument
protected static function serveDocument($tpl, $content_type = 'text/html', $http_cache = true, $http_etag = true)
{
$_ctx =& $GLOBALS['_ctx'];
$core =& $GLOBALS['core'];
if ($_ctx->nb_entry_per_page === null) {
$_ctx->nb_entry_per_page = $core->blog->settings->nb_post_per_page;
}
$tpl_file = $core->tpl->getFilePath($tpl);
if (!$tpl_file) {
throw new Exception('Unable to find template');
}
if ($http_cache) {
$GLOBALS['mod_files'][] = $tpl_file;
http::cache($GLOBALS['mod_files'], $GLOBALS['mod_ts']);
}
$result = new ArrayObject();
header('Content-Type: ' . $content_type . '; charset=UTF-8');
$_ctx->current_tpl = $tpl;
$result['content'] = $core->tpl->getData($tpl);
$result['content_type'] = $content_type;
$result['tpl'] = $tpl;
$result['blogupddt'] = $core->blog->upddt;
# --BEHAVIOR-- urlHandlerServeDocument
$core->callBehavior('urlHandlerServeDocument', $result);
if ($http_cache && $http_etag) {
http::etag($result['content'], http::getSelfURI());
}
echo $result['content'];
}
示例2: serveDocument
protected static function serveDocument($tpl, $content_type = 'text/html', $http_cache = true, $http_etag = true)
{
$_ctx =& $GLOBALS['_ctx'];
$core =& $GLOBALS['core'];
if ($_ctx->nb_entry_per_page === null) {
$_ctx->nb_entry_per_page = $core->blog->settings->system->nb_post_per_page;
}
if ($_ctx->nb_entry_first_page === null) {
$_ctx->nb_entry_first_page = $_ctx->nb_entry_per_page;
}
$tpl_file = $core->tpl->getFilePath($tpl);
if (!$tpl_file) {
throw new Exception('Unable to find template ');
}
$result = new ArrayObject();
$_ctx->current_tpl = $tpl;
$_ctx->content_type = $content_type;
$_ctx->http_cache = $http_cache;
$_ctx->http_etag = $http_etag;
$core->callBehavior('urlHandlerBeforeGetData', $_ctx);
if ($_ctx->http_cache) {
$GLOBALS['mod_files'][] = $tpl_file;
http::cache($GLOBALS['mod_files'], $GLOBALS['mod_ts']);
}
header('Content-Type: ' . $_ctx->content_type . '; charset=UTF-8');
if ($core->blog->settings->system->prevents_clickjacking) {
if ($_ctx->exists('xframeoption')) {
$url = parse_url($_ctx->xframeoption);
header(sprintf('X-Frame-Options: %s', is_array($url) ? "ALLOW-FROM " . $url['scheme'] . '://' . $url['host'] : 'SAMEORIGIN'));
} else {
// Prevents Clickjacking as far as possible
header('X-Frame-Options: SAMEORIGIN');
// FF 3.6.9+ Chrome 4.1+ IE 8+ Safari 4+ Opera 10.5+
}
}
$result['content'] = $core->tpl->getData($_ctx->current_tpl);
$result['content_type'] = $_ctx->content_type;
$result['tpl'] = $_ctx->current_tpl;
$result['blogupddt'] = $core->blog->upddt;
# --BEHAVIOR-- urlHandlerServeDocument
$core->callBehavior('urlHandlerServeDocument', $result);
if ($_ctx->http_cache && $_ctx->http_etag) {
http::etag($result['content'], http::getSelfURI());
}
echo $result['content'];
}