From 280e9a290dff26c6f4ef48e66b4d24e839166fad Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Tue, 15 Oct 2013 18:51:36 +0000 Subject: [PATCH] central function to get calling URL --- lam/lib/account.inc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lam/lib/account.inc b/lam/lib/account.inc index c90daa5d..1773b120 100644 --- a/lam/lib/account.inc +++ b/lam/lib/account.inc @@ -1136,4 +1136,26 @@ function getExtendedLDAPErrorMessage($server) { return _('LDAP error, server says:') . ' ' . $ldapMsg; } +/** + * Returns the URL under which the page was loaded. + * This includes any GET parameters set. + * + * @return String URL + */ +function getCallingURL() { + $url = null; + if (!empty($_SERVER['HTTP_REFERER'])) { + $url = $_SERVER['HTTP_REFERER']; + } + else { + $proto = 'http://'; + if (!empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] != 'off')) { + $proto = 'https://'; + } + $url = $proto . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + } + logNewMessage(LOG_DEBUG, 'Calling URL detected as ' . $url); + return $url; +} + ?>