From c7092ee1b331a1642e5310ff2331437c7f4ee2ce Mon Sep 17 00:00:00 2001 From: thisgun Date: Thu, 26 Nov 2020 18:34:40 +0900 Subject: [PATCH] =?UTF-8?q?=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=EA=B0=80?= =?UTF-8?q?=20=EB=B0=B0=EC=97=B4=EC=9D=BC=20=EA=B2=BD=EC=9A=B0=20get=5Fpar?= =?UTF-8?q?ams=5Fmerge=5Furl=20=ED=95=A8=EC=88=98=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/common.lib.php | 53 +++++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/lib/common.lib.php b/lib/common.lib.php index 29ce6d4b6..82f5207b3 100644 --- a/lib/common.lib.php +++ b/lib/common.lib.php @@ -3353,6 +3353,11 @@ function clean_query_string($query, $amp=true) $q = array(); foreach($out as $key=>$val) { + if(($key && is_array($key)) || ($val && is_array($val))){ + $q[$key] = $val; + continue; + } + $key = strip_tags(trim($key)); $val = trim($val); @@ -3426,33 +3431,41 @@ function clean_query_string($query, $amp=true) return $str; } -function get_params_merge_url($params){ - $p = @parse_url(G5_URL); - $href = $p['scheme'].'://'.$p['host']; - if(isset($p['port']) && $p['port']) - $href .= ':'.$p['port']; - - if( $tmp = explode('?', $_SERVER['REQUEST_URI']) ){ - if( isset($tmp[0]) && $tmp[0] ) +function get_params_merge_url($params, $url=''){ + $str_url = $url ? $url : G5_URL; + $p = @parse_url($str_url); + $href = (isset($p['scheme']) ? "{$p['scheme']}://" : '') + . (isset($p['user']) ? $p['user'] + . (isset($p['pass']) ? ":{$p['pass']}" : '').'@' : '') + . (isset($p['host']) ? $p['host'] : '') + . ((isset($p['path']) && $url) ? $p['path'] : '') + . ((isset($p['port']) && $p['port']) ? ":{$p['port']}" : ''); + + $ori_params = ''; + if( $url ){ + $ori_params = !empty($p['query']) ? $p['query'] : ''; + } else if( $tmp = explode('?', $_SERVER['REQUEST_URI']) ){ + if( isset($tmp[0]) && $tmp[0] ) { $href .= $tmp[0]; - } - $q = array(); - if($_SERVER['QUERY_STRING']) { - foreach($_GET as $key=>$val) { - $key = strip_tags($key); - $val = strip_tags($val); - - if($key && $val) - $q[$key] = $val; + $ori_params = $tmp[1]; + } + if( $freg = strstr($ori_params, '#') ) { + $p['fragment'] = preg_replace('/^#/', '', $freg); } } - - if( is_array($params) ){ + + $q = array(); + if( $ori_params ){ + parse_str( $ori_params, $q ); + } + + if( is_array($params) && $params ){ $q = array_merge($q, $params); } $query = http_build_query($q, '', '&'); - $href .= '?'.$query; + $qc = (strpos( $href, '?' ) !== false) ? '&' : '?'; + $href .= $qc.$query.(isset($p['fragment']) ? "#{$p['fragment']}" : ''); return $href; }