php3 fix and format cleanup in get_referer()

This commit is contained in:
Miles Lott 2001-11-12 14:26:16 +00:00
parent 5b962ced87
commit fb0f64e6d0

View File

@ -248,12 +248,18 @@
return $headers; return $headers;
} }
function get_referer($vars=array('sort','order','query','start','filter','cat_id')) function get_referer($vars)
{ {
if(!$vars)
{
$vars=array('sort','order','query','start','filter','cat_id');
}
global $HTTP_REFERER,$referer; global $HTTP_REFERER,$referer;
if (!$referer) if (!$referer)
{
$referer = $HTTP_REFERER; $referer = $HTTP_REFERER;
}
$url = parse_url(str_replace($GLOBALS['phpgw_info']['server']['webserver_url'],'',$referer)); $url = parse_url(str_replace($GLOBALS['phpgw_info']['server']['webserver_url'],'',$referer));
@ -266,8 +272,10 @@
{ {
$args = array(); $args = array();
if ($url['query']) if ($url['query'])
{
$args[] = $url['query']; $args[] = $url['query'];
} }
}
$query_arr = array( ); $query_arr = array( );
while (list($null,$arg) = each($args)) while (list($null,$arg) = each($args))
{ {
@ -279,15 +287,19 @@
{ {
global $$var; // merge in HTTP_{POST|GET}_VARS global $$var; // merge in HTTP_{POST|GET}_VARS
if (isset($$var)) if (isset($$var))
{
$query_arr[$var] = $$var; $query_arr[$var] = $$var;
} }
}
$qstr = ''; $qstr = '';
reset ($query_arr); reset ($query_arr);
while (list($var,$val) = each($query_arr)) while (list($var,$val) = each($query_arr))
{ {
if ($val && !($val == 'none' && $var == 'filter')) if ($val && !($val == 'none' && $var == 'filter'))
{
$qstr .= ($qstr ? '&' : '?')."$var=$val"; $qstr .= ($qstr ? '&' : '?')."$var=$val";
} }
}
//echo "<p>qstr='$qstr'</p>\n"; //echo "<p>qstr='$qstr'</p>\n";
return $url['path'] . $qstr; return $url['path'] . $qstr;
} }