mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
using another approach
git-svn-id: file:///svn/phpbb/trunk@5905 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
215693d897
commit
8b88ffe996
1 changed files with 18 additions and 4 deletions
|
@ -1239,20 +1239,34 @@ function build_url($strip_vars = false)
|
|||
$redirect = (($user->page['page_dir']) ? $user->page['page_dir'] . '/' : '') . $user->page['page_name'] . $SID . (($user->page['query_string']) ? "&{$user->page['query_string']}" : '');
|
||||
|
||||
// Strip vars...
|
||||
if ($strip_vars !== false)
|
||||
if ($strip_vars !== false && strpos($redirect, '?') !== false)
|
||||
{
|
||||
if (!is_array($strip_vars))
|
||||
{
|
||||
$strip_vars = array($strip_vars);
|
||||
}
|
||||
|
||||
foreach ($strip_vars as $var)
|
||||
$query = $_query = array();
|
||||
parse_str(substr($redirect, strpos($redirect, '?') + 1), $query);
|
||||
$redirect = substr($redirect, 0, strpos($redirect, '?'));
|
||||
|
||||
// Strip the vars off
|
||||
foreach ($strip_vars as $strip)
|
||||
{
|
||||
if (strpos($redirect, $var) !== false)
|
||||
if (isset($query[$strip]))
|
||||
{
|
||||
$redirect = preg_replace('#^(.*?)&?' . preg_quote($var, '#') . '=.*(&?)(.*?)$#', '\1\3', $redirect);
|
||||
unset($query[$strip]);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
foreach ($query as $key => $value)
|
||||
{
|
||||
$_query[] = $key . '=' . $value;
|
||||
}
|
||||
$query = implode('&', $_query);
|
||||
|
||||
$redirect .= ($query) ? '?' . $query : '';
|
||||
}
|
||||
|
||||
return $phpbb_root_path . str_replace('&', '&', $redirect);
|
||||
|
|
Loading…
Add table
Reference in a new issue