fixed wrong referer if url contains webserver_url more then once, eg. "http://egroupware.org/egroupware/index.php" and "/egroupware"

This commit is contained in:
Ralf Becker 2006-04-05 14:55:57 +00:00
parent 2d77b83245
commit a9988cc72a

View File

@ -2045,21 +2045,21 @@
* gets an eGW conformat referer from $_SERVER['HTTP_REFERER'], suitable for direct use in the link function * 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 * @param string $default='' default to use if referer is not set by webserver or not determinable
* @param string $referer='' referer string to use, default ('') use $_SERVER['HTTP_REFERER']
* @return string * @return string
*/ */
function get_referer($default='') function get_referer($default='',$referer='')
{ {
$referer = $_SERVER['HTTP_REFERER']; if (!$referer) $referer = $_SERVER['HTTP_REFERER'];
$webserver_url = $GLOBALS['egw_info']['server']['webserver_url']; $webserver_url = $GLOBALS['egw_info']['server']['webserver_url'];
if (empty($webserver_url) || $webserver_url == '/') // fix for eGW installed in the docroot if (empty($webserver_url) || $webserver_url{0} == '/') // url is just a path
{ {
$referer = preg_replace('/^https?:\/\/[^\/]+/','',$referer); // removing the domain part $referer = preg_replace('/^https?:\/\/[^\/]+/','',$referer); // removing the domain part
} }
else if (strlen($webserver_url) > 1)
{ {
$parts = explode($webserver_url,$referer); list(,$referer) = explode($webserver_url,$referer,2);
$referer = array_pop($parts);
} }
$referer = str_replace('/etemplate/process_exec.php','/index.php',$referer); $referer = str_replace('/etemplate/process_exec.php','/index.php',$referer);