本文整理汇总了PHP中apache_response_headers函数的典型用法代码示例。如果您正苦于以下问题:PHP apache_response_headers函数的具体用法?PHP apache_response_headers怎么用?PHP apache_response_headers使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了apache_response_headers函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wfOutputHandler
/**
* Standard output handler for use with ob_start
*
* @param $s string
*
* @return string
*/
function wfOutputHandler($s)
{
global $wgDisableOutputCompression, $wgValidateAllHtml;
$s = wfMangleFlashPolicy($s);
if ($wgValidateAllHtml) {
$headers = apache_response_headers();
$isHTML = true;
foreach ($headers as $name => $value) {
if (strtolower($name) == 'content-type' && strpos($value, 'text/html') === false && strpos($value, 'application/xhtml+xml') === false) {
$isHTML = false;
break;
}
}
if ($isHTML) {
$s = wfHtmlValidationHandler($s);
}
}
if (!$wgDisableOutputCompression && !ini_get('zlib.output_compression')) {
if (!defined('MW_NO_OUTPUT_COMPRESSION')) {
$s = wfGzipHandler($s);
}
if (!ini_get('output_handler')) {
wfDoContentLength(strlen($s));
}
}
return $s;
}
示例2: debugRequest
/**
* Remember that this is not sanitized and should be commented out of your code when done using
*/
function debugRequest()
{
echo "Echoing for debug:<br>";
echo "You should see 'DONE' line at the end if all is successful<br>";
function show($arr, $label = "")
{
echo "{$label}<br>";
echo "<pre>";
var_dump($arr);
echo "</pre>";
echo "<br>";
}
// === Section 1
show($_GET, "GET");
show($_POST, "POST");
show($_COOKIE, "COOKIE");
show($_SERVER, "SERVER");
show(getallheaders(), "Request headers");
show(apache_response_headers(), "Response headers: apache_response_headers (array)");
// Section 1 ===
if (isset($_COOKIE["thetestcookie"])) {
echo "thetestcookie:" . $_COOKIE["thetestcookie"] . "<br>";
} else {
echo "thetestcookie: cookie is not set<br>";
}
echo "<br><br>Usage notes:<br>";
$readme = "";
$readme .= "- You can set a cookie called 'thetestcookie'";
echo $readme;
echo "<br>DONE<br>";
}
示例3: prepareData
/**
* Captures data about the current environment, before a notification
* @return array
* @access private
*/
function prepareData()
{
global $HTTP_RAW_POST_DATA;
$Data = array('timestamp' => time(), 'gmt' => gmdate("D, d M Y H:i:s", time()) . " GMT", 'requestInfo' => $this->requestInfo, 'responseInfo' => $this->responseInfo, 'SERVER' => $_SERVER, 'GET' => $_GET, 'POST' => $_POST, 'RAWPOST' => $HTTP_RAW_POST_DATA);
if (function_exists('apache_request_headers')) {
$Data['requestHeaders'] = apache_request_headers();
$Data['responseHeaders'] = apache_response_headers();
}
return $Data;
}
示例4: getHeaders
protected static function getHeaders()
{
if (function_exists('apache_response_headers')) {
return apache_response_headers();
} else {
$headers = array();
foreach (headers_list() as $header) {
$sp = strpos($header, ':');
$headers[substr($header, 0, $sp)] = substr($header, $sp);
}
return $headers;
}
}
示例5: store
function store()
{
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
$cache = "";
foreach (apache_response_headers() as $key => $value) {
if ('set-cookie' != strtolower($key)) {
$cache .= $key . ': ' . $value . "\r\n";
}
}
$cache .= "\r\n";
$cache .= ob_get_flush();
file_put_contents($this->_filename, $cache);
}
示例6: wp_cache_get_response_headers
function wp_cache_get_response_headers()
{
if (function_exists('apache_response_headers')) {
$headers = apache_response_headers();
} else {
if (function_exists('headers_list')) {
$headers = array();
foreach (headers_list() as $hdr) {
list($header_name, $header_value) = explode(': ', $hdr, 2);
$headers[$header_name] = $header_value;
}
} else {
$headers = null;
}
}
return $headers;
}
开发者ID:ryan-allen,项目名称:w1000-super-total-mega-shark-cache-on-a-boat-on-a-plane,代码行数:17,代码来源:wp-cache-phase2.php
示例7: execute
public function execute()
{
$back = 'Request headers:<ul>' . PHP_EOL;
foreach (apache_request_headers() as $key => $v) {
$back .= sprintf('<li>%s: %s</li>' . PHP_EOL, htmlspecialchars($key), htmlspecialchars($v));
}
$back .= '</ul><br/><br/><ul>Response Headers:<ul>' . PHP_EOL;
foreach (apache_response_headers() as $key => $v) {
$back .= sprintf('<li>%s: %s</li>' . PHP_EOL, htmlspecialchars($key), htmlspecialchars($v));
}
$back .= '</ul>' . PHP_EOL;
if (GWF_User::getStaticOrGuest()->isAdmin()) {
$back .= '<br/><br/>$_SERVER variables:<ul>';
foreach ($_SERVER as $key => $v) {
$back .= sprintf('<li>%s: %s</li>' . PHP_EOL, htmlspecialchars($key), htmlspecialchars($v));
}
$back .= '</ul>';
}
return $back;
}
示例8: handleOnShutdown
public static function handleOnShutdown()
{
$request = self::_getRequest();
if (!$request->three_o_four_buffering_started) {
return;
}
$response = ob_get_clean();
if (http_response_code() != 200) {
ob_end_flush();
return;
}
$contentLength = strlen($response);
$etag = null;
if (isset($request->three_o_four_cache_response) && $request->three_o_four_cache_response == true) {
$key = self::_generateCacheKey($request);
$microtime = microtime();
//$etag = md5($key . $microtime);
$etag = self::_hash($response);
$cacheData = array('changed' => $microtime, 'etag' => $etag, 'contentLength' => $contentLength, 'content' => $response, 'headers' => apache_response_headers(), 'params' => array());
if (isset($request->three_o_four_cache_opts['store_params'])) {
foreach ($request->three_o_four_cache_opts['store_params'] as $k) {
if (isset($request->url_params[$k])) {
$cacheData['params'][$k] = $request->url_params[$k];
}
}
}
// Optimization for pages
cache_set($key, $cacheData);
cache_save();
} else {
if (isset($request->three_o_four_emit_etag) && $request->three_o_four_emit_etag == true) {
$etag = self::_hash($response);
}
}
self::_sendResponse($response, $contentLength, $etag);
}
示例9: headers
/**
* Show HTTP headers
* @return JBDump
*/
public static function headers()
{
if (!self::isDebug()) {
return false;
}
if (function_exists('apache_request_headers')) {
$data = array('Request' => apache_request_headers(), 'Response' => apache_response_headers(), 'List' => headers_list());
} else {
$data = array('List' => headers_list());
}
if (headers_sent($filename, $linenum)) {
$data['Sent'] = 'Headers already sent in ' . self::i()->_getRalativePath($filename) . ':' . $linenum;
} else {
$data['Sent'] = false;
}
return self::i()->dump($data, '! headers !');
}
示例10: ob
function ob($output)
{
if ($this->cancel !== false) {
return $output;
}
// PHP5 and objects disappearing before output buffers?
wp_cache_init();
// Remember, $wp_object_cache was clobbered in wp-settings.php so we have to repeat this.
$this->configure_groups();
// Do not batcache blank pages (usually they are HTTP redirects)
$output = trim($output);
if (empty($output)) {
return;
}
// Construct and save the batcache
$cache = array('output' => $output, 'time' => time(), 'timer' => $this->timer_stop(false, 3), 'status_header' => $this->status_header, 'version' => $this->url_version);
if (function_exists('apache_response_headers')) {
$cache['headers'] = apache_response_headers();
if (!empty($this->uncached_headers)) {
foreach ($cache['headers'] as $header => $value) {
if (in_array(strtolower($header), $this->uncached_headers)) {
unset($cache['headers'][$header]);
}
}
}
}
wp_cache_set($this->key, $cache, $this->group, $this->max_age + $this->seconds + 30);
// Unlock regeneration
wp_cache_delete("{$this->url_key}_genlock", $this->group);
if ($this->cache_control) {
header('Last-Modified: ' . date('r', $cache['time']), true);
header("Cache-Control: max-age={$this->max_age}, must-revalidate", false);
}
if (!empty($this->headers)) {
foreach ($this->headers as $k => $v) {
if (is_array($v)) {
header("{$v[0]}: {$v[1]}", false);
} else {
header("{$k}: {$v}", true);
}
}
}
// Add some debug info just before </head>
if ($this->debug) {
$tag = "<!--\n\tgenerated in " . $cache['timer'] . " seconds\n\t" . strlen(serialize($cache)) . " bytes batcached for " . $this->max_age . " seconds\n-->\n";
if (false !== ($tag_position = strpos($output, '</head>'))) {
$tag = "<!--\n\tgenerated in " . $cache['timer'] . " seconds\n\t" . strlen(serialize($cache)) . " bytes batcached for " . $this->max_age . " seconds\n-->\n";
$output = substr($output, 0, $tag_position) . $tag . substr($output, $tag_position);
}
}
// Pass output to next ob handler
return $output;
}
示例11: misc_proxy
function misc_proxy($url, $translate_func, $flags)
{
// $res_keys = $http_response_header; // deprecated
$res = apache_response_headers();
$res_keys = array_keys($res);
$req = apache_request_headers();
$req_keys = array_keys($req);
if (($fp = fopen($url, "rb")) == false) {
return -1;
}
$p = "";
$i_max = sizeof($res_keys);
/*
for ($i = 1; $i < $i_max; $i++)
{
if (!strncasecmp ($res[$res_keys[$i]], "Content-Type: ", 14))
{
if ($res[$res_keys[$i]] == "Content-Type: audio/mpeg" ||
$res[$res_keys[$i]] == "Content-Type: application/octet-stream")
$p .= "Content-Disposition: attachment; filename=".$file;
}
else
$p .= $res[$res_keys[$i]];
$p .= $res_keys[$i];
}
header ($p);
*/
if ($flags & PROXY_SHOW_HEADER) {
$p = "<!--\n";
$j_max = sizeof($req_keys);
for ($j = 0; $j < $j_max; $j++) {
$p .= $req_keys[$j] . ": " . $req[$req_keys[$j]] . "\n";
}
$p .= "\n\n\n\n";
for ($i = 0; $i < $i_max; $i++) {
$p .= $res_keys[$i] . ": " . $res[$res_keys[$i]] . "\n";
}
$p .= "\n//-->";
echo $p;
}
if ($translate_func || $flags & PROXY_PASS_FORMS || $flags & PROXY_PASS_LINKS) {
while ($p = fgets($fp)) {
echo $translate_func($p);
}
} else {
fpassthru($fp);
}
fclose($fp);
return 0;
}
示例12: __tcSqlLogDump
function __tcSqlLogDump()
{
global $__tcSqlLog, $__tcPageEndTime;
global $service, $memcache;
static $sLogPumped = false;
if (!empty($sLogPumped)) {
return;
}
$sLogPumped = true;
__tcSqlLogPoint('shutdown');
$headers = array();
if (function_exists('apache_response_headers') || function_exists('headers_list')) {
if (function_exists('apache_response_headers')) {
flush();
$headers = apache_response_headers();
} else {
$headers = headers_list();
}
}
$commentBlosk = false;
foreach ($headers as $row) {
if (strpos($row, '/xml') !== false || strpos($row, '+xml') !== false) {
/* To check text/xml, application/xml and application/xml+blah, application/blah+xml... types */
$commentBlosk = true;
break;
}
if (strpos($row, 'text/javascript') !== false) {
return;
}
}
if ($commentBlosk == true) {
echo '<!--';
}
if (!$commentBlosk) {
print <<<EOS
<style type='text/css'>
/*<![CDATA[*/
\t.debugTable
\t{
\t\tbackground-color: #fff;
\t\tborder-left: 1px solid #999;
\t\tborder-top: 1px solid #999;
\t\tborder-collapse: collapse;
\t\tmargin-bottom: 20px;
\t}
\t.debugTable *
\t{
\t\tborder: none;
\t\tmargin: 0;
\t\tpadding: 0;
\t}
\t.debugTable td, .debugTable th
\t{
\t\tborder-bottom: 1px solid #999;
\t\tborder-right: 1px solid #999;
\t\tcolor: #000;
\t\tfont-family: Arial, Tahoma, Verdana, sans-serif;
\t\tfont-size: 12px;
\t\tpadding: 3px 5px;
\t}
\t.debugTable th
\t{
\t\tbackground-color: #dedede;
\t\ttext-align: center;
\t}
\ttr.debugSQLLine .rows
\t{
\t\ttext-align: center;
\t}
\ttr.debugSQLLine .error
\t{
\t\ttext-align: left;
\t}
\ttr.debugSQLLine .elapsed, tr.debugSQLLine .elapsedSum
\t{
\t\ttext-align: right;
\t}
\ttr.debugSQLLine .backtrace
\t{
\t\tfont-family: Courier, 'Courier new', monospace;
\t\tfont-size: 11px;
\t\tletter-spacing: -1px;
\t}
\ttr.debugCached *, tr.debugSystem *
\t{
\t\tcolor: #888888 !important;
\t}
\t/* warning */
\ttr.debugWarning *
\t{
\t\tbackground-color: #fefff1;
//.........这里部分代码省略.........
示例13: _onShutdownKtai
function _onShutdownKtai()
{
if (!$this->HypKTaiRender->vars['ua']['allowCookie']) {
$url = '';
$arh = FALSE;
if (function_exists('apache_response_headers')) {
$arh = apache_response_headers();
if (is_array($arh)) {
foreach (array('Location', 'location', 'LOCATION') as $key) {
if (isset($arh[$key])) {
$url = trim($arh[$key]);
break;
}
}
}
}
if ($arh === FALSE && function_exists('headers_list')) {
foreach (headers_list() as $header) {
if (preg_match('/^Location:(.+)$/is', $header, $match)) {
$url = trim($match[1]);
break;
}
}
}
if ($url) {
$nosession = strpos($url, session_name() . '=') === FALSE;
$url = $this->HypKTaiRender->getRealUrl($url);
$url = $this->HypKTaiRender->addSID($url, XOOPS_URL);
if (!headers_sent()) {
$this->_locationRedirect($url, false);
} else {
if ($this->HypKTaiRender->vars['ua']['uid'] && $nosession) {
$file = XOOPS_ROOT_PATH . '/cache/' . md5($this->HypKTaiRender->vars['ua']['uid'] . XOOPS_DB_PASS) . '.redirect';
$fp = fopen($file, 'w');
fwrite($fp, $url);
fclose($fp);
}
}
}
}
}
示例14: onRestInPeace
/**
* Analyze the response header and set "cacheablity" flag
*
* @return bool true (hook handler
*/
public static function onRestInPeace()
{
if (function_exists('apache_response_headers')) {
$isCacheable = self::isCacheable(apache_response_headers());
if (is_bool($isCacheable)) {
self::setAttribute('cacheable', $isCacheable);
}
}
return true;
}
示例15: wp_cache_ob_end
function wp_cache_ob_end()
{
global $cache_path, $cache_max_time, $file_expired, $file_prefix, $meta_file, $new_cache;
global $meta_object, $known_headers;
/* Preparing... with PHP5 is straightforward, use headers_list() */
if (function_exists('apache_response_headers')) {
$response = apache_response_headers();
$meta_object->headers = array();
foreach ($known_headers as $key) {
if (isset($response[$key])) {
array_push($meta_object->headers, "{$key}: " . $response[$key]);
}
}
/* Not use because it gives problems with some
* PHP installations
if (!$response{'Content-Length'}) {
// WP does not set content size
$content_size = ob_get_length();
@header("Content-Length: $content_size");
array_push($meta_object->headers, "Content-Length: $content_size");
}
*/
if (!$response['Last-Modified']) {
$value = gmdate('D, d M Y H:i:s') . ' GMT';
/* Dont send this the first time */
/* @header('Last-Modified: ' . $value); */
array_push($meta_object->headers, "Last-Modified: {$value}");
}
if (!$response['Content-Type']) {
$value = "text/html; charset=\"" . get_settings('blog_charset') . "\"";
@header("Content-Type: {$value}");
array_push($meta_object->headers, "Content-Type: {$value}");
}
}
ob_end_clean();
if ($new_cache) {
$serial = serialize($meta_object);
wp_cache_writers_entry();
$fr = fopen($cache_path . $meta_file, 'w');
fputs($fr, $serial);
fclose($fr);
wp_cache_writers_exit();
}
if ($file_expired == false) {
return;
}
// we delete expired files
flush();
//Ensure we send data to the client
wp_cache_phase2_clean_expired($file_prefix);
}