mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[ticket/17201] Split off logic into function and add tests
PHPBB3-17201
This commit is contained in:
@@ -1814,6 +1814,30 @@ function redirect($url, $return = false, $disable_cd_check = false)
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the install redirect path for phpBB.
|
||||
*
|
||||
* @param string $phpbb_root_path The root path of the phpBB installation.
|
||||
* @param string $phpEx The file extension of php files, e.g., "php".
|
||||
* @return string The install redirect path.
|
||||
*/
|
||||
function phpbb_get_install_redirect(string $phpbb_root_path, string $phpEx): string
|
||||
{
|
||||
$script_name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
|
||||
if (!$script_name)
|
||||
{
|
||||
$script_name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF');
|
||||
}
|
||||
|
||||
$script_name = substr($script_name, -1) === '/' ? $script_name . '.' : $script_name;
|
||||
|
||||
// $phpbb_root_path accounts for redirects from e.g. /adm
|
||||
$script_path = trim(dirname($script_name)) . '/' . $phpbb_root_path . 'install/app.' . $phpEx;
|
||||
// Replace any number of consecutive backslashes and/or slashes with a single slash
|
||||
// (could happen on some proxy setups and/or Windows servers)
|
||||
return preg_replace('#[\\\\/]{2,}#', '/', $script_path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-Apply session id after page reloads
|
||||
*/
|
||||
|
Reference in New Issue
Block a user