diff options
| -rw-r--r-- | includes/php_53_compatibility.php | 13 | ||||
| -rw-r--r-- | library/WT/Filter.php | 45 |
2 files changed, 35 insertions, 23 deletions
diff --git a/includes/php_53_compatibility.php b/includes/php_53_compatibility.php index b4abc6ebea..0cb5bce134 100644 --- a/includes/php_53_compatibility.php +++ b/includes/php_53_compatibility.php @@ -65,6 +65,8 @@ if (!defined('PASSWORD_BCRYPT') && crypt("password", $hash) !== $hash) { * @return int|null */ function http_response_code($code = null) { + static $http_response_code = 200; + if ($code !== null) { switch ($code) { case 100: @@ -179,15 +181,12 @@ function http_response_code($code = null) { $text = 'HTTP Version not supported'; break; default: - exit('Unknown http status code "' . htmlentities($code) . '"'); - break; + throw new DomainException; } - $protocol = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0'); + $http_response_code = $code; + $protocol = WT_Filter::server('SERVER_PROTOCOL', null, 'HTTP/1.0'); header($protocol . ' ' . $code . ' ' . $text); - $GLOBALS['http_response_code'] = $code; - } else { - $code = (isset($GLOBALS['http_response_code']) ? $GLOBALS['http_response_code'] : 200); } - return $code; + return $http_response_code; } diff --git a/library/WT/Filter.php b/library/WT/Filter.php index 50214161ff..ce28556ea1 100644 --- a/library/WT/Filter.php +++ b/library/WT/Filter.php @@ -172,7 +172,7 @@ class WT_Filter { } /** - * Validate INPUT requests + * Validate INPUT parameters * * @param string $source * @param string $variable @@ -201,7 +201,7 @@ class WT_Filter { FILTER_CALLBACK, array( 'options' => function($x) { - return !function_exists('mb_convert_encoding') || mb_check_encoding($x, 'UTF-8') ? $x : false; + return mb_check_encoding($x, 'UTF-8') ? $x : false; }, ) ); @@ -210,7 +210,7 @@ class WT_Filter { } /** - * Validate array INPUT requests + * Validate array INPUT parameters * * @param string $source * @param string $variable @@ -255,7 +255,7 @@ class WT_Filter { } /** - * Validate GET requests + * Validate GET parameters * * @param string $variable * @param string|null $regexp @@ -268,7 +268,7 @@ class WT_Filter { } /** - * Validate array GET requests + * Validate array GET parameters * * @param string $variable * @param string|null $regexp @@ -281,7 +281,7 @@ class WT_Filter { } /** - * Validate boolean GET requests + * Validate boolean GET parameters * * @param string $variable * @@ -292,7 +292,7 @@ class WT_Filter { } /** - * Validate integer GET requests + * Validate integer GET parameters * * @param string $variable * @param integer $min @@ -306,7 +306,7 @@ class WT_Filter { } /** - * Validate email GET requests + * Validate email GET parameters * * @param string $variable * @param string|null $default @@ -318,7 +318,7 @@ class WT_Filter { } /** - * Validate URL GET requests + * Validate URL GET parameters * * @param string $variable * @param string|null $default @@ -330,7 +330,7 @@ class WT_Filter { } /** - * Validate POST requests + * Validate POST parameters * * @param string $variable * @param string|null $regexp @@ -343,7 +343,7 @@ class WT_Filter { } /** - * Validate array POST requests + * Validate array POST parameters * * @param string $variable * @param string|null $regexp @@ -356,7 +356,7 @@ class WT_Filter { } /** - * Validate boolean POST requests + * Validate boolean POST parameters * * @param string $variable * @@ -367,7 +367,7 @@ class WT_Filter { } /** - * Validate integer POST requests + * Validate integer POST parameters * * @param string $variable * @param integer $min @@ -381,7 +381,7 @@ class WT_Filter { } /** - * Validate email POST requests + * Validate email POST parameters * * @param string $variable * @param string|null $default @@ -393,7 +393,7 @@ class WT_Filter { } /** - * Validate URL GET requests + * Validate URL GET parameters * * @param string $variable * @param string|null $default @@ -405,7 +405,7 @@ class WT_Filter { } /** - * Validate COOKIE requests + * Validate COOKIE parameters * * @param string $variable * @param string|null $regexp @@ -418,6 +418,19 @@ class WT_Filter { } /** + * Validate SERVER parameters + * + * @param string $variable + * @param string|null $regexp + * @param string|null $default + * + * @return null|string + */ + public static function server($variable, $regexp = null, $default = null) { + return self::input(INPUT_SERVER, $variable, $regexp, $default); + } + + /** * Cross-Site Request Forgery tokens - ensure that the user is submitting * a form that was generated by the current session. * |
