From ab6738c74344b572d25e325dcd669fa813a7a1e5 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sun, 2 Dec 2007 02:43:42 +0000 Subject: Use correct pfSenseHeader() function. --- etc/inc/functions.inc | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/etc/inc/functions.inc b/etc/inc/functions.inc index 2d6338a..fbd1b99 100644 --- a/etc/inc/functions.inc +++ b/etc/inc/functions.inc @@ -39,8 +39,32 @@ if(!function_exists("gettext")) { } if(!function_exists("pfSenseHeader")) { - function pfSenseHeader($location) { - header("Location: $location"); + /****f* pfsense-utils/pfSenseHeader + * NAME + * pfSenseHeader + * INPUTS + * none + * RESULT + * Javascript header change or browser Location: + ******/ + function pfSenseHeader($text) { + global $_SERVER; + if (isAjax()) { + if ($_SERVER['HTTPS'] == "on") + $protocol = "https"; + else + $protocol = "http"; + + $port = ":{$_SERVER['SERVER_PORT']}"; + if ($_SERVER['SERVER_PORT'] == "80" && $protocol == "http") + $port = ""; + if ($_SERVER['SERVER_PORT'] == "443" && $protocol == "https") + $port = ""; + $complete_url = "{$protocol}://{$_SERVER['SERVER_NAME']}{$port}/{$text}"; + echo "\ndocument.location.href = '{$complete_url}';\n"; + } else { + Header("Location: $text"); + } } } /* END compatibility goo with HEAD */ -- cgit v1.1