Fixed missing namespaces.
authorAlexander Ebert <ebert@woltlab.com>
Wed, 20 Jul 2011 13:21:11 +0000 (15:21 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 20 Jul 2011 13:21:11 +0000 (15:21 +0200)
Once again PHP proofed that changes made to the language are never tested, the method silently fails instead of returning any error message!

wcfsetup/install/files/lib/util/HeaderUtil.class.php

index 09518ff3e62d0439feeb8b7e4da4ccb579ed10be..192296bc2c5855fd97ecc9d18141fbe04ce6a35d 100644 (file)
@@ -1,95 +1,95 @@
-<?php\r
-namespace wcf\util;\r
-use wcf\system\WCF;\r
-\r
-/**\r
- * Contains header-related functions.\r
- * \r
- * @author     Marcel Werk\r
- * @copyright  2001-2009 WoltLab GmbH\r
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\r
- * @package    com.woltlab.wcf\r
- * @subpackage util\r
- * @category   Community Framework\r
- */\r
-class HeaderUtil {\r
-       /**\r
-        * alias to php setcookie() function\r
-        */\r
-       public static function setCookie($name, $value = '', $expire = 0) {\r
-               @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);\r
-       }\r
-       \r
-       /**\r
-        * Sends the headers of a page.\r
-        */\r
-       public static function sendHeaders() {\r
-               // send content type\r
-               @header('Content-Type: text/html; charset=UTF-8');\r
-               \r
-               // send no cache headers\r
-               if (HTTP_ENABLE_NO_CACHE_HEADERS && !WCF::getSession()->spiderID) {\r
-                       self::sendNoCacheHeaders();\r
-               }\r
-               \r
-               // enable gzip compression\r
-               if (HTTP_ENABLE_GZIP && HTTP_GZIP_LEVEL > 0 && HTTP_GZIP_LEVEL < 10 && !defined('HTTP_DISABLE_GZIP')) {\r
-                       self::compressOutput();\r
-               }\r
-       }\r
-       \r
-       /**\r
-        * Sends no cache headers.\r
-        */\r
-       public static function sendNoCacheHeaders() {\r
-               @header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); \r
-               @header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');\r
-               @header('Cache-Control: no-cache, must-revalidate');\r
-               @header('Pragma: no-cache');\r
-       }\r
-       \r
-       /**\r
-        * Enables the gzip compression of the page output.\r
-        */\r
-       public static function compressOutput() {\r
-               if (function_exists('gzcompress') && !@ini_get('zlib.output_compression') && !@ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {\r
-                       if (strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip')) {\r
-                               @header('Content-Encoding: x-gzip');\r
-                       }\r
-                       else {\r
-                               @header('Content-Encoding: gzip');\r
-                       }\r
-                       ob_start(array('HeaderUtil', 'getCompressedOutput'));\r
-               }\r
-       }\r
-       \r
-       /**\r
-        * Outputs the compressed page content.\r
-        */\r
-       public static function getCompressedOutput($output) {\r
-               $size = strlen($output);\r
-               $crc = crc32($output);\r
-\r
-               $newOutput = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff";\r
-               $newOutput .= substr(gzcompress($output, HTTP_GZIP_LEVEL), 2, -4);\r
-               unset($output);\r
-               $newOutput .= pack('V', $crc);\r
-               $newOutput .= pack('V', $size);\r
-               \r
-               return $newOutput;\r
-       }\r
-       \r
-       /**\r
-        * Redirects the user agent.\r
-        *\r
-        * @param       string          $location\r
-        * @param       boolean         $prependDir\r
-        * @param       boolean         $sendStatusCode\r
-        */\r
-       public static function redirect($location, $prependDir = true, $sendStatusCode = false) {\r
-               if ($prependDir) $location = FileUtil::addTrailingSlash(FileUtil::unifyDirSeperator(dirname(WCF::getSession()->requestURI))) . $location;\r
-               //if ($sendStatusCode) @header('HTTP/1.0 301 Moved Permanently');\r
-               if ($sendStatusCode) @header('HTTP/1.1 307 Temporary Redirect');\r
-               header('Location: '.$location);\r
-       }\r
+<?php
+namespace wcf\util;
+use wcf\system\WCF;
+
+/**
+ * Contains header-related functions.
+ * 
+ * @author     Marcel Werk
+ * @copyright  2001-2009 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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);
+       }
 }