aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorIgor Wiedler <igor@wiedler.ch>2012-11-17 01:15:50 +0100
committerIgor Wiedler <igor@wiedler.ch>2012-11-17 01:15:50 +0100
commit5fad4006e102ddec8afe17a1315971fed3d29376 (patch)
tree208466fb707e8ae38b172f54c143dd1cfad61031 /phpBB
parent65dde648cab316fd0f0715f13d57ef45452398a3 (diff)
downloadforums-5fad4006e102ddec8afe17a1315971fed3d29376.tar
forums-5fad4006e102ddec8afe17a1315971fed3d29376.tar.gz
forums-5fad4006e102ddec8afe17a1315971fed3d29376.tar.bz2
forums-5fad4006e102ddec8afe17a1315971fed3d29376.tar.xz
forums-5fad4006e102ddec8afe17a1315971fed3d29376.zip
[ticket/11212] Do not rely on $request in send_status_line()
PHPBB3-11212
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/includes/functions.php35
1 files changed, 25 insertions, 10 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 3a5b100515..dd82c9dc46 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -2858,8 +2858,6 @@ function meta_refresh($time, $url, $disable_cd_check = false)
*/
function send_status_line($code, $message)
{
- global $request;
-
if (substr(strtolower(@php_sapi_name()), 0, 3) === 'cgi')
{
// in theory, we shouldn't need that due to php doing it. Reality offers a differing opinion, though
@@ -2867,18 +2865,35 @@ function send_status_line($code, $message)
}
else
{
- if ($request->server('SERVER_PROTOCOL'))
- {
- $version = $request->server('SERVER_PROTOCOL');
- }
- else
- {
- $version = 'HTTP/1.0';
- }
+ $version = get_http_version();
header("$version $code $message", true, $code);
}
}
+/**
+* Returns the HTTP version used in the current request.
+*
+* Handles the case of being called before `$request` is present,
+* In which case it falls back to the $_SERVER superglobal.
+*
+* @return string HTTP version
+*/
+function get_http_version()
+{
+ global $request;
+
+ if ($request && $request->server('SERVER_PROTOCOL'))
+ {
+ return $request->server('SERVER_PROTOCOL');
+ }
+ else if (isset($_SERVER['SERVER_PROTOCOL']))
+ {
+ return $_SERVER['SERVER_PROTOCOL'];
+ }
+
+ return 'HTTP/1.0';
+}
+
//Form validation