From 92d692a3349b0fb9b8e16d31085dc0a5e2ac9190 Mon Sep 17 00:00:00 2001 From: mistic100 Date: Thu, 10 Oct 2013 10:53:59 +0000 Subject: make get_query_string_diff compatible with arrays and use build-in functions git-svn-id: http://piwigo.org/svn/trunk@24833 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions.inc.php | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'include/functions.inc.php') diff --git a/include/functions.inc.php b/include/functions.inc.php index ac20b73bb..be6c57114 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -763,25 +763,18 @@ function get_query_string_diff($rejects=array(), $escape=true) return ''; } - $query_string = ''; + parse_str($_SERVER['QUERY_STRING'], $vars); - $str = $_SERVER['QUERY_STRING']; - parse_str($str, $vars); - - $is_first = true; - foreach ($vars as $key => $value) - { - if (!in_array($key, $rejects)) - { - $query_string.= $is_first ? '?' : ($escape ? '&' : '&' ); - $is_first = false; - $query_string.= $key.'='.$value; - } - } - - return $query_string; + $vars = array_diff_key($vars, array_flip($rejects)); + + return '?' . http_build_query($vars, '', $escape ? '&' : '&'); } +/** + * returns true if the url is absolute (begins with http) + * @param string $url + * @returns boolean + */ function url_is_remote($url) { if ( strncmp($url, 'http://', 7)==0 -- cgit v1.2.3