mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[ticket/11997] Remove obsolete failover_flag in function redirect()
This flag is no longer needed as the failover is no longer needed. PHPBB3-11997
This commit is contained in:
parent
27ae58713b
commit
68db335468
1 changed files with 42 additions and 47 deletions
|
@ -2647,8 +2647,6 @@ function redirect($url, $return = false, $disable_cd_check = false)
|
||||||
{
|
{
|
||||||
global $db, $cache, $config, $user, $phpbb_root_path, $phpbb_filesystem, $phpbb_path_helper;
|
global $db, $cache, $config, $user, $phpbb_root_path, $phpbb_filesystem, $phpbb_path_helper;
|
||||||
|
|
||||||
$failover_flag = false;
|
|
||||||
|
|
||||||
if (empty($user->lang))
|
if (empty($user->lang))
|
||||||
{
|
{
|
||||||
$user->add_lang('common');
|
$user->add_lang('common');
|
||||||
|
@ -2698,56 +2696,53 @@ function redirect($url, $return = false, $disable_cd_check = false)
|
||||||
// Relative uri
|
// Relative uri
|
||||||
$pathinfo = pathinfo($url);
|
$pathinfo = pathinfo($url);
|
||||||
|
|
||||||
if (!$failover_flag)
|
// Is the uri pointing to the current directory?
|
||||||
|
if ($pathinfo['dirname'] == '.')
|
||||||
{
|
{
|
||||||
// Is the uri pointing to the current directory?
|
$url = str_replace('./', '', $url);
|
||||||
if ($pathinfo['dirname'] == '.')
|
|
||||||
|
// Strip / from the beginning
|
||||||
|
if ($url && substr($url, 0, 1) == '/')
|
||||||
{
|
{
|
||||||
$url = str_replace('./', '', $url);
|
$url = substr($url, 1);
|
||||||
|
|
||||||
// Strip / from the beginning
|
|
||||||
if ($url && substr($url, 0, 1) == '/')
|
|
||||||
{
|
|
||||||
$url = substr($url, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
$url = generate_board_url() . '/' . $url;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
$url = generate_board_url() . '/' . $url;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Used ./ before, but $phpbb_root_path is working better with urls within another root path
|
||||||
|
$root_dirs = explode('/', str_replace('\\', '/', phpbb_realpath($phpbb_root_path)));
|
||||||
|
$page_dirs = explode('/', str_replace('\\', '/', phpbb_realpath($pathinfo['dirname'])));
|
||||||
|
$intersection = array_intersect_assoc($root_dirs, $page_dirs);
|
||||||
|
|
||||||
|
$root_dirs = array_diff_assoc($root_dirs, $intersection);
|
||||||
|
$page_dirs = array_diff_assoc($page_dirs, $intersection);
|
||||||
|
|
||||||
|
$dir = str_repeat('../', sizeof($root_dirs)) . implode('/', $page_dirs);
|
||||||
|
|
||||||
|
// Strip / from the end
|
||||||
|
if ($dir && substr($dir, -1, 1) == '/')
|
||||||
{
|
{
|
||||||
// Used ./ before, but $phpbb_root_path is working better with urls within another root path
|
$dir = substr($dir, 0, -1);
|
||||||
$root_dirs = explode('/', str_replace('\\', '/', phpbb_realpath($phpbb_root_path)));
|
|
||||||
$page_dirs = explode('/', str_replace('\\', '/', phpbb_realpath($pathinfo['dirname'])));
|
|
||||||
$intersection = array_intersect_assoc($root_dirs, $page_dirs);
|
|
||||||
|
|
||||||
$root_dirs = array_diff_assoc($root_dirs, $intersection);
|
|
||||||
$page_dirs = array_diff_assoc($page_dirs, $intersection);
|
|
||||||
|
|
||||||
$dir = str_repeat('../', sizeof($root_dirs)) . implode('/', $page_dirs);
|
|
||||||
|
|
||||||
// Strip / from the end
|
|
||||||
if ($dir && substr($dir, -1, 1) == '/')
|
|
||||||
{
|
|
||||||
$dir = substr($dir, 0, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Strip / from the beginning
|
|
||||||
if ($dir && substr($dir, 0, 1) == '/')
|
|
||||||
{
|
|
||||||
$dir = substr($dir, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
$url = str_replace($pathinfo['dirname'] . '/', '', $url);
|
|
||||||
|
|
||||||
// Strip / from the beginning
|
|
||||||
if (substr($url, 0, 1) == '/')
|
|
||||||
{
|
|
||||||
$url = substr($url, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
$url = (!empty($dir) ? $dir . '/' : '') . $url;
|
|
||||||
$url = generate_board_url() . '/' . $url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Strip / from the beginning
|
||||||
|
if ($dir && substr($dir, 0, 1) == '/')
|
||||||
|
{
|
||||||
|
$dir = substr($dir, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = str_replace($pathinfo['dirname'] . '/', '', $url);
|
||||||
|
|
||||||
|
// Strip / from the beginning
|
||||||
|
if (substr($url, 0, 1) == '/')
|
||||||
|
{
|
||||||
|
$url = substr($url, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = (!empty($dir) ? $dir . '/' : '') . $url;
|
||||||
|
$url = generate_board_url() . '/' . $url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue