From 988b7c1bc5a4e0bd99993f6834648a7664427496 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 9 Nov 2005 12:45:48 +0000 Subject: [PATCH] new method common::get_referer(), to get an eGW conformat referer from $_SERVER['HTTP_REFERER'], suitable for direct use in the link function --- phpgwapi/inc/class.common.inc.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/phpgwapi/inc/class.common.inc.php b/phpgwapi/inc/class.common.inc.php index 60401dd625..da15ce9bff 100644 --- a/phpgwapi/inc/class.common.inc.php +++ b/phpgwapi/inc/class.common.inc.php @@ -2085,6 +2085,28 @@ return (int)$id; } + /** + * gets an eGW conformat referer from $_SERVER['HTTP_REFERER'], suitable for direct use in the link function + * + * @param string $default='' default to use if referer is not set by webserver or not determinable + * @return string + */ + function get_referer($default='') + { + $referer = $_SERVER['HTTP_REFERER']; + + $parts = explode($GLOBALS['egw_info']['server']['webserver_url'],$referer); + + $referer = array_pop($parts); + if (count($parts) > 1) // eg. URL contains http://egroupware.domain.com/egroupware/... and webserver_url='/egroupware' + { + $referer = array_pop($parts) . $GLOBALS['egw_info']['server']['webserver_url'] . $referer; + } + if (empty($referer)) $referer = $default; + + return $referer; + } + // some depricated functions for the migration function phpgw_exit($call_footer = False) {