From bd8a6c7bec32bb06cd314bf777958b29bcb214b4 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 20 Jul 2011 15:21:11 +0200 Subject: [PATCH] Fixed missing namespaces. Once again PHP proofed that changes made to the language are never tested, the method silently fails instead of returning any error message! --- .../files/lib/util/HeaderUtil.class.php | 188 +++++++++--------- 1 file changed, 94 insertions(+), 94 deletions(-) diff --git a/wcfsetup/install/files/lib/util/HeaderUtil.class.php b/wcfsetup/install/files/lib/util/HeaderUtil.class.php index 09518ff3e6..192296bc2c 100644 --- a/wcfsetup/install/files/lib/util/HeaderUtil.class.php +++ b/wcfsetup/install/files/lib/util/HeaderUtil.class.php @@ -1,95 +1,95 @@ - - * @package com.woltlab.wcf - * @subpackage util - * @category Community Framework - */ -class HeaderUtil { - /** - * alias to php setcookie() function - */ - public static function setCookie($name, $value = '', $expire = 0) { - @header('Set-Cookie: '.rawurlencode(COOKIE_PREFIX.$name).'='.rawurlencode($value).($expire ? '; expires='.gmdate('D, d-M-Y H:i:s', $expire).' GMT' : '').(COOKIE_PATH ? '; path='.COOKIE_PATH : '').(COOKIE_DOMAIN ? '; domain='.COOKIE_DOMAIN : '').((isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443') ? '; secure' : '').'; HttpOnly', false); - } - - /** - * Sends the headers of a page. - */ - public static function sendHeaders() { - // send content type - @header('Content-Type: text/html; charset=UTF-8'); - - // send no cache headers - if (HTTP_ENABLE_NO_CACHE_HEADERS && !WCF::getSession()->spiderID) { - self::sendNoCacheHeaders(); - } - - // enable gzip compression - if (HTTP_ENABLE_GZIP && HTTP_GZIP_LEVEL > 0 && HTTP_GZIP_LEVEL < 10 && !defined('HTTP_DISABLE_GZIP')) { - self::compressOutput(); - } - } - - /** - * Sends no cache headers. - */ - public static function sendNoCacheHeaders() { - @header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); - @header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - @header('Cache-Control: no-cache, must-revalidate'); - @header('Pragma: no-cache'); - } - - /** - * Enables the gzip compression of the page output. - */ - public static function compressOutput() { - if (function_exists('gzcompress') && !@ini_get('zlib.output_compression') && !@ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) { - if (strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip')) { - @header('Content-Encoding: x-gzip'); - } - else { - @header('Content-Encoding: gzip'); - } - ob_start(array('HeaderUtil', 'getCompressedOutput')); - } - } - - /** - * Outputs the compressed page content. - */ - public static function getCompressedOutput($output) { - $size = strlen($output); - $crc = crc32($output); - - $newOutput = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff"; - $newOutput .= substr(gzcompress($output, HTTP_GZIP_LEVEL), 2, -4); - unset($output); - $newOutput .= pack('V', $crc); - $newOutput .= pack('V', $size); - - return $newOutput; - } - - /** - * Redirects the user agent. - * - * @param string $location - * @param boolean $prependDir - * @param boolean $sendStatusCode - */ - public static function redirect($location, $prependDir = true, $sendStatusCode = false) { - if ($prependDir) $location = FileUtil::addTrailingSlash(FileUtil::unifyDirSeperator(dirname(WCF::getSession()->requestURI))) . $location; - //if ($sendStatusCode) @header('HTTP/1.0 301 Moved Permanently'); - if ($sendStatusCode) @header('HTTP/1.1 307 Temporary Redirect'); - header('Location: '.$location); - } + + * @package com.woltlab.wcf + * @subpackage util + * @category Community Framework + */ +class HeaderUtil { + /** + * alias to php setcookie() function + */ + public static function setCookie($name, $value = '', $expire = 0) { + @header('Set-Cookie: '.rawurlencode(COOKIE_PREFIX.$name).'='.rawurlencode($value).($expire ? '; expires='.gmdate('D, d-M-Y H:i:s', $expire).' GMT' : '').(COOKIE_PATH ? '; path='.COOKIE_PATH : '').(COOKIE_DOMAIN ? '; domain='.COOKIE_DOMAIN : '').((isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443') ? '; secure' : '').'; HttpOnly', false); + } + + /** + * Sends the headers of a page. + */ + public static function sendHeaders() { + // send content type + @header('Content-Type: text/html; charset=UTF-8'); + + // send no cache headers + if (HTTP_ENABLE_NO_CACHE_HEADERS && !WCF::getSession()->spiderID) { + self::sendNoCacheHeaders(); + } + + // enable gzip compression + if (HTTP_ENABLE_GZIP && HTTP_GZIP_LEVEL > 0 && HTTP_GZIP_LEVEL < 10 && !defined('HTTP_DISABLE_GZIP')) { + self::compressOutput(); + } + } + + /** + * Sends no cache headers. + */ + public static function sendNoCacheHeaders() { + @header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); + @header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); + @header('Cache-Control: no-cache, must-revalidate'); + @header('Pragma: no-cache'); + } + + /** + * Enables the gzip compression of the page output. + */ + public static function compressOutput() { + if (function_exists('gzcompress') && !@ini_get('zlib.output_compression') && !@ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) { + if (strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip')) { + @header('Content-Encoding: x-gzip'); + } + else { + @header('Content-Encoding: gzip'); + } + ob_start(array('wcf\util\HeaderUtil', 'getCompressedOutput')); + } + } + + /** + * Outputs the compressed page content. + */ + public static function getCompressedOutput($output) { + $size = strlen($output); + $crc = crc32($output); + + $newOutput = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff"; + $newOutput .= substr(gzcompress($output, HTTP_GZIP_LEVEL), 2, -4); + unset($output); + $newOutput .= pack('V', $crc); + $newOutput .= pack('V', $size); + + return $newOutput; + } + + /** + * Redirects the user agent. + * + * @param string $location + * @param boolean $prependDir + * @param boolean $sendStatusCode + */ + public static function redirect($location, $prependDir = true, $sendStatusCode = false) { + if ($prependDir) $location = FileUtil::addTrailingSlash(FileUtil::unifyDirSeperator(dirname(WCF::getSession()->requestURI))) . $location; + //if ($sendStatusCode) @header('HTTP/1.0 301 Moved Permanently'); + if ($sendStatusCode) @header('HTTP/1.1 307 Temporary Redirect'); + header('Location: '.$location); + } } -- 2.20.1