aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGraham Eames <grahamje@users.sourceforge.net>2006-07-07 20:47:25 +0000
committerGraham Eames <grahamje@users.sourceforge.net>2006-07-07 20:47:25 +0000
commit63dbf43693bd4f63682da1d55533bd34ff3f0d46 (patch)
tree63eb39562c650186ab1871143843c82946de356c
parent97cd5b1c3de8ce063ffbbfed17c36fd6b31f9761 (diff)
downloadforums-63dbf43693bd4f63682da1d55533bd34ff3f0d46.tar
forums-63dbf43693bd4f63682da1d55533bd34ff3f0d46.tar.gz
forums-63dbf43693bd4f63682da1d55533bd34ff3f0d46.tar.bz2
forums-63dbf43693bd4f63682da1d55533bd34ff3f0d46.tar.xz
forums-63dbf43693bd4f63682da1d55533bd34ff3f0d46.zip
Change redirection logic to match the RFC better in those cases before redirect() is available to us
git-svn-id: file:///svn/phpbb/trunk@6154 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r--phpBB/common.php28
-rwxr-xr-xphpBB/install/index.php33
-rwxr-xr-xphpBB/install/install_install.php12
3 files changed, 64 insertions, 9 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;
}
diff --git a/phpBB/install/index.php b/phpBB/install/index.php
index 51ab82ba3c..d22545a56a 100755
--- a/phpBB/install/index.php
+++ b/phpBB/install/index.php
@@ -373,6 +373,39 @@ class module
}
/**
+ * Generate an HTTP/1.1 header to redirect the user to another page
+ * This is used during the installation when we do not have a database available to call the normal redirect function
+ * @param string $page The page to redirect to relative to the installer root path
+ */
+ function redirect($page)
+ {
+ $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));
+
+ $url = (($secure) ? 'https://' : 'http://') . $server_name;
+
+ if ($server_port && (($secure && $server_port <> 443) || (!$secure && $server_port <> 80)))
+ {
+ $url .= ':' . $server_port;
+ }
+
+ $url .= $script_path . '/' . $page;
+ header('Location: ' . $url);
+ exit;
+ }
+
+ /**
* Generate the navigation tabs
*/
function generate_navigation()
diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php
index 780301d547..9e0a3cc002 100755
--- a/phpBB/install/install_install.php
+++ b/phpBB/install/install_install.php
@@ -537,8 +537,7 @@ class install_install extends module
{
// Someone's been silly and tried calling this page direct
// So we send them back to the start to do it again properly
- header('Location: index.' . $phpEx . '?mode=install');
- exit;
+ $this->p_master->redirect("index?mode=install");
}
$s_hidden_fields = ($img_imagick) ? '<input type="hidden" name="img_imagick" value="' . addslashes($img_imagick) . '" />' : '';
@@ -696,8 +695,7 @@ class install_install extends module
{
// Someone's been silly and tried calling this page direct
// So we send them back to the start to do it again properly
- header('Location: index.' . $phpEx . '?mode=install');
- exit;
+ $this->p_master->redirect("index?mode=install");
}
$s_hidden_fields = ($img_imagick) ? '<input type="hidden" name="img_imagick" value="' . addslashes($img_imagick) . '" />' : '';
@@ -841,8 +839,7 @@ class install_install extends module
{
// Someone's been silly and tried calling this page direct
// So we send them back to the start to do it again properly
- header('Location: index.' . $phpEx . '?mode=install');
- exit;
+ $this->p_master->redirect("index?mode=install");
}
$s_hidden_fields = ($img_imagick) ? '<input type="hidden" name="img_imagick" value="' . addslashes($img_imagick) . '" />' : '';
@@ -925,8 +922,7 @@ class install_install extends module
{
// Someone's been silly and tried calling this page direct
// So we send them back to the start to do it again properly
- header('Location: index.' . $phpEx . '?mode=install');
- exit;
+ $this->p_master->redirect("index?mode=install");
}
$cookie_domain = ($server_name != '') ? $server_name : (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME');