diff options
Diffstat (limited to 'phpBB/common.php')
| -rw-r--r-- | phpBB/common.php | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/phpBB/common.php b/phpBB/common.php index ea05515075..0630d48934 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -111,7 +111,33 @@ require($phpbb_root_path . 'config.' . $phpEx); if (!defined('PHPBB_INSTALLED')) { - header('Location: install/index.' . $phpEx); + // Redirect the user to the installer + // We have to generate a full HTTP/1.1 header here since we can't guarantee to have any of the information + // available as used by the redirect function + $server_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'); + $server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT'); + $secure = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 1 : 0; + + $script_name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF'); + if (!$script_name) + { + $script_name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI'); + } + + // Replace backslashes and doubled slashes (could happen on some proxy setups) + $script_name = str_replace(array('\\', '//'), '/', $script_name); + $script_path = trim(dirname($script_name)); + $script_path = rtrim($script_patch, '/'); + + $url = (($secure) ? 'https://' : 'http://') . $server_name; + + if ($server_port && (($secure && $server_port <> 443) || (!$secure && $server_port <> 80))) + { + $url .= ':' . $server_port; + } + + $url .= $script_path . '/install/index.' . $phpEx; + header('Location: ' . $url); exit; } |
