diff options
| author | Cesar G <prototech91@gmail.com> | 2013-11-11 15:45:02 -0800 |
|---|---|---|
| committer | Cesar G <prototech91@gmail.com> | 2014-04-22 15:21:02 -0700 |
| commit | e1c6b40ee82a79a58276d8e85de9c3593a6f3703 (patch) | |
| tree | 32227ce17f23938fd77123ac4d828dce31a66623 /phpBB/includes/functions.php | |
| parent | ef4202d8590cdf3d88049329fe02864881369906 (diff) | |
| download | forums-e1c6b40ee82a79a58276d8e85de9c3593a6f3703.tar forums-e1c6b40ee82a79a58276d8e85de9c3593a6f3703.tar.gz forums-e1c6b40ee82a79a58276d8e85de9c3593a6f3703.tar.bz2 forums-e1c6b40ee82a79a58276d8e85de9c3593a6f3703.tar.xz forums-e1c6b40ee82a79a58276d8e85de9c3593a6f3703.zip | |
[ticket/11508] Move the stripping param code to separate function as well.
PHPBB3-11508
Diffstat (limited to 'phpBB/includes/functions.php')
| -rw-r--r-- | phpBB/includes/functions.php | 56 |
1 files changed, 37 insertions, 19 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index aa09b90b35..71716ae6b3 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2368,28 +2368,13 @@ function build_url($strip_vars = false) // Append SID $redirect = append_sid($page, false, false); - $basic_parts = phpbb_get_url_parts($redirect, '&'); - $params = $basic_parts['params']; - // Strip vars... if ($strip_vars !== false) { - if (!is_array($strip_vars)) - { - $strip_vars = array($strip_vars); - } - - // Strip the vars off - foreach ($strip_vars as $strip) - { - if (isset($params[$strip])) - { - unset($params[$strip]); - } - } + $redirect = phpbb_strip_url_params($redirect, $strip_vars, '&'); } - return $basic_parts['base'] . (($params) ? '?' . phpbb_glue_url_params($params) : ''); + return $redirect; } /** @@ -2450,14 +2435,47 @@ function phpbb_glue_url_params($params) { } /** +* Strip parameters from an already built URL. +* +* @param string $url URL to strip parameters from +* @param array|string $strip Parameters to strip. +* @param string $separator Parameter separator. Defaults to & +* @return string Returns the new URL. +*/ +function phpbb_strip_url_params($url, $strip, $separator = '&') { + $url_parts = phpbb_get_url_parts($url, $separator); + $params = $url_parts['params']; + + if (!is_array($strip)) + { + $strip = array($strip); + } + + if (!empty($params)) + { + // Strip the parameters off + foreach ($strip as $param) + { + if (isset($params[$param])) + { + unset($params[$param]); + } + } + } + + return $url_parts['base'] . (($params) ? '?' . phpbb_glue_url_params($params) : ''); +} + +/** * Append parameters to an already built URL. * * @param string $url URL to append parameters to * @param array $new_params Parameters to add in the form of array(name => value) +* @param string $separator Parameter separator. Defaults to & * @return string Returns the new URL. */ -function phpbb_append_url_params($url, $new_params) { - $url_parts = phpbb_get_url_parts($url); +function phpbb_append_url_params($url, $new_params, $separator = '&') { + $url_parts = phpbb_get_url_parts($url, $separator); $params = array_merge($url_parts['params'], $new_params); // Move the sid to the end if it's set |
