Commit 4d336198 authored by Franco Fichtner's avatar Franco Fichtner

src: s/pfSenseHeader/redirectHeader/g plus cleanups

parent dc757d07
......@@ -53,7 +53,7 @@ if (!isAllowedPage($_SERVER['REQUEST_URI'])) {
$page = str_replace('*', '', $allowedpages[0]);
$_SESSION['Post_Login'] = true;
require_once("functions.inc");
pfSenseHeader("/{$page}");
redirectHeader("/{$page}");
$username = empty($_SESSION["Username"]) ? "(system)" : $_SESSION['Username'];
if (!empty($_SERVER['REMOTE_ADDR'])) {
......@@ -77,7 +77,7 @@ if (!isAllowedPage($_SERVER['REQUEST_URI'])) {
if (!$_SESSION['Post_Login']) {
$_SESSION['Post_Login'] = true;
require_once("functions.inc");
pfSenseHeader($_SERVER['REQUEST_URI']);
redirectHeader($_SERVER['REQUEST_URI']);
exit;
}
......
......@@ -28,112 +28,98 @@
*/
/* BEGIN compatibility goo with HEAD */
if(!function_exists("gettext")) {
function gettext($text) {
return $text;
}
if (!function_exists('gettext')) {
function gettext($text)
{
return $text;
}
if(!function_exists("pfSenseHeader")) {
/****f* functions/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 */
/*fetch menu notices function*/
if(!function_exists("get_menu_messages")) {
function get_menu_messages(){
global $g,$config;
if (are_notices_pending()) {
$notices = get_notices();
$requests=array();
## Get Query Arguments from URL ###
foreach ($_REQUEST as $key => $value) {
if ($key != "PHPSESSID")
$requests[] = $key.'='.$value;
}
if(is_array($requests))
$request_string = implode("&", $requests);
if(is_array($notices)) {
$notice_msgs = "<ul class=\"dropdown-menu\" role=\"menu\">";
function redirectHeader($text)
{
global $_SERVER;
$notice_msgs .= "<li><a href=\"#\" onclick=\"notice_action('acknowledge','all');\" >".gettext("Acknowledge All Notices")."</a></li><li class=\"divider\"></li>";
if (isAjax()) {
if ($_SERVER['HTTPS'] == 'on') {
$protocol = 'https';
} else {
$protocol = 'http';
}
foreach ($notices as $key => $value) {
$date = date("m-d-y H:i:s", $key);
$noticemsg = ($value['notice'] != "" ? $value['notice'] : $value['id']);
$noticemsg = preg_replace("/(\"|\'|\n|<.?\w+>)/i","",$noticemsg);
if ((strlen($noticemsg)* 8) > $domtt_width)
$domtt_width=(strlen($noticemsg) *8);
if ((strlen($noticemsg)* 8) > 900)
$domtt_width= 900;
$alert_action ="onclick=\"notice_action('acknowledge','{$key}'); jQuery(this).parent().parent().remove();\"";
$notice_msgs .= "<li><a href=\"#\" {$alert_link} {$alert_action}>{$date} [ ".htmlspecialchars($noticemsg)."]</a></li>";
}
$notice_msgs .="</ul>";
$port = '';
if (
!($_SERVER['SERVER_PORT'] == '80' && $protocol == 'http') &&
!($_SERVER['SERVER_PORT'] == '443' && $protocol == 'https')
) {
$port = ":{$_SERVER['SERVER_PORT']}";
}
$menu_messages = '';
echo "\ndocument.location.href = '{$protocol}://{$_SERVER['SERVER_NAME']}{$port}/{$text}';\n";
} else {
header("Location: $text");
}
}
if(count($notices)==1)
$msg= sprintf("%1$02d",count($notices))." ".gettext("unread notice");
else
$msg= sprintf("%1$02d",count($notices))." ".gettext("unread notices");
function get_menu_messages()
{
global $config;
$menu_messages.="<a href=\"/\" class=\"dropdown-toggle \" data-toggle=\"dropdown\" role=\"button\" aria-expanded=\"false\"><span class=\"text-primary\">{$msg}&nbsp;</span><span class=\"caret text-primary\"></span></a>{$notice_msgs}\n";
if (are_notices_pending()) {
$notices = get_notices();
$requests = array();
}
## Get Query Arguments from URL ###
foreach ($_REQUEST as $key => $value) {
if ($key != "PHPSESSID") {
$requests[] = $key.'='.$value;
}
else {
$menu_messages='';
$menu_messages.= "<a href=\"#\">".$config['system']['hostname'] . "." . $config['system']['domain']."</a>";
$menu_messages.='';
}
return ($menu_messages);
}
}
if(!function_exists("dom_title")) {
function dom_title($title_msg,$width=NULL){
$width=preg_replace("/\D+/","",$width);
if (!empty($width)){
$width=",'width',$width";
if (is_array($requests)) {
$request_string = implode("&", $requests);
}
if (is_array($notices)) {
$notice_msgs = "<ul class=\"dropdown-menu\" role=\"menu\">";
$notice_msgs .= "<li><a href=\"#\" onclick=\"notice_action('acknowledge','all');\" >".gettext("Acknowledge All Notices")."</a></li><li class=\"divider\"></li>";
foreach ($notices as $key => $value) {
$date = date("m-d-y H:i:s", $key);
$noticemsg = ($value['notice'] != "" ? $value['notice'] : $value['id']);
$noticemsg = preg_replace("/(\"|\'|\n|<.?\w+>)/i","",$noticemsg);
if ((strlen($noticemsg)* 8) > $domtt_width) {
$domtt_width=(strlen($noticemsg) *8);
}
if ((strlen($noticemsg)* 8) > 900) {
$domtt_width= 900;
}
$alert_action ="onclick=\"notice_action('acknowledge','{$key}'); jQuery(this).parent().parent().remove();\"";
$notice_msgs .= "<li><a href=\"#\" {$alert_link} {$alert_action}>{$date} [ ".htmlspecialchars($noticemsg)."]</a></li>";
}
if (!empty($title_msg)){
$title_msg=preg_replace("/\s+/"," ",$title_msg);
$title_msg=preg_replace("/'/","\'",$title_msg);
return "onmouseout=\"this.style.color = ''; domTT_mouseout(this, event);\" onmouseover=\"domTT_activate(this, event, 'content', '{$title_msg}', 'trail', true, 'delay', 250, 'fade', 'both', 'fadeMax', 93, 'styleClass', 'niceTitle' $width);\"";
$notice_msgs .="</ul>";
$menu_messages = '';
if (count($notices) == 1) {
$msg= sprintf("%1$02d",count($notices))." ".gettext("unread notice");
} else {
$msg= sprintf("%1$02d",count($notices))." ".gettext("unread notices");
}
$menu_messages.="<a href=\"/\" class=\"dropdown-toggle \" data-toggle=\"dropdown\" role=\"button\" aria-expanded=\"false\"><span class=\"text-primary\">{$msg}&nbsp;</span><span class=\"caret text-primary\"></span></a>{$notice_msgs}\n";
}
} else {
$menu_messages='';
$menu_messages.= "<a href=\"#\">".$config['system']['hostname'] . "." . $config['system']['domain']."</a>";
$menu_messages.='';
}
return ($menu_messages);
}
/* include all configuration functions */
require_once("interfaces.inc");
require_once("gwlb.inc");
......
......@@ -141,7 +141,7 @@ if($_POST['aliasimport'] <> "") {
if (write_config())
mark_subsystem_dirty('aliases');
pfSenseHeader("firewall_aliases.php");
redirectHeader("firewall_aliases.php");
exit;
}
......
......@@ -50,7 +50,7 @@ function get_pkg_interfaces_select_source($include_localhost=false) {
}
/* dummy stubs needed by some code that was MFC'd */
function pfSenseHeader($location) { header("Location: " . $location); }
function redirectHeader($location) { header("Location: " . $location); }
function gentitle_pkg($pgname) {
global $pfSense_config;
......@@ -241,11 +241,11 @@ if ($_POST) {
exec($pkg['restart_command'] . ">/dev/null 2&>1");
if($pkg['aftersaveredirect'] <> "") {
pfSenseHeader($pkg['aftersaveredirect']);
redirectHeader($pkg['aftersaveredirect']);
} elseif(!$pkg['adddeleteeditpagefields']) {
pfSenseHeader("pkg_edit.php?xml={$xml}&amp;id=0");
redirectHeader("pkg_edit.php?xml={$xml}&amp;id=0");
} elseif(!$pkg['preoutput']) {
pfSenseHeader("pkg.php?xml=" . $xml);
redirectHeader("pkg.php?xml=" . $xml);
}
exit;
} else {
......
......@@ -46,7 +46,7 @@ if (isset($_POST['act']))
if ($act == "del") {
if (!$a_acls[$id]) {
pfSenseHeader("services_unbound_acls.php");
redirectHeader("services_unbound_acls.php");
exit;
}
......@@ -122,7 +122,7 @@ if ($_POST) {
mark_subsystem_dirty("unbound");
write_config();
pfSenseHeader("/services_unbound_acls.php");
redirectHeader("/services_unbound_acls.php");
exit;
}
......
......@@ -127,7 +127,7 @@ if ($_POST) {
unset($config['system']['disablebeep']);
write_config();
pfSenseHeader("system_advanced_notifications.php");
redirectHeader("system_advanced_notifications.php");
return;
}
......
......@@ -65,7 +65,7 @@ if ($act == "del") {
unset($a_tunable[$id]);
write_config();
mark_subsystem_dirty('sysctl');
pfSenseHeader("system_advanced_sysctl.php");
redirectHeader("system_advanced_sysctl.php");
exit;
}
}
......@@ -105,7 +105,7 @@ if ($_POST) {
write_config();
pfSenseHeader("system_advanced_sysctl.php");
redirectHeader("system_advanced_sysctl.php");
exit;
}
}
......
......@@ -56,7 +56,7 @@ if ($_POST['act'])
if ($act == "del") {
if (!$a_server[$_GET['id']]) {
pfSenseHeader("system_authservers.php");
redirectHeader("system_authservers.php");
exit;
}
......@@ -293,7 +293,7 @@ if ($_POST) {
write_config();
pfSenseHeader("system_authservers.php");
redirectHeader("system_authservers.php");
}
}
......
......@@ -67,7 +67,7 @@ if ($_POST['act'])
if ($act == "del") {
if (!isset($a_ca[$id])) {
pfSenseHeader("system_camanager.php");
redirectHeader("system_camanager.php");
exit;
}
......@@ -85,13 +85,13 @@ if ($act == "del") {
unset($a_ca[$id]);
write_config();
$savemsg = sprintf(gettext("Certificate Authority %s and its CRLs (if any) successfully deleted"), $name) . "<br />";
pfSenseHeader("system_camanager.php");
redirectHeader("system_camanager.php");
exit;
}
if ($act == "edit") {
if (!$a_ca[$id]) {
pfSenseHeader("system_camanager.php");
redirectHeader("system_camanager.php");
exit;
}
$pconfig['descr'] = $a_ca[$id]['descr'];
......@@ -113,7 +113,7 @@ if ($act == "new") {
if ($act == "exp") {
if (!$a_ca[$id]) {
pfSenseHeader("system_camanager.php");
redirectHeader("system_camanager.php");
exit;
}
......@@ -131,7 +131,7 @@ if ($act == "exp") {
if ($act == "expkey") {
if (!$a_ca[$id]) {
pfSenseHeader("system_camanager.php");
redirectHeader("system_camanager.php");
exit;
}
......@@ -287,7 +287,7 @@ if ($_POST) {
if (!$input_errors)
write_config();
// pfSenseHeader("system_camanager.php");
// redirectHeader("system_camanager.php");
}
}
......
......@@ -82,7 +82,7 @@ if ($_POST['act'])
if ($act == "del") {
if (!isset($a_cert[$id])) {
pfSenseHeader("system_certmanager.php");
redirectHeader("system_certmanager.php");
exit;
}
......@@ -90,7 +90,7 @@ if ($act == "del") {
unset($a_cert[$id]);
write_config();
$savemsg = sprintf(gettext("Certificate %s successfully deleted"), $name) . "<br />";
pfSenseHeader("system_certmanager.php");
redirectHeader("system_certmanager.php");
exit;
}
......@@ -106,7 +106,7 @@ if ($act == "new") {
if ($act == "exp") {
if (!$a_cert[$id]) {
pfSenseHeader("system_certmanager.php");
redirectHeader("system_certmanager.php");
exit;
}
......@@ -124,7 +124,7 @@ if ($act == "exp") {
if ($act == "key") {
if (!$a_cert[$id]) {
pfSenseHeader("system_certmanager.php");
redirectHeader("system_certmanager.php");
exit;
}
......@@ -141,7 +141,7 @@ if ($act == "key") {
if ($act == "p12") {
if (!$a_cert[$id]) {
pfSenseHeader("system_certmanager.php");
redirectHeader("system_certmanager.php");
exit;
}
......@@ -170,7 +170,7 @@ if ($act == "p12") {
if ($act == "csr") {
if (!$a_cert[$id]) {
pfSenseHeader("system_certmanager.php");
redirectHeader("system_certmanager.php");
exit;
}
......@@ -445,7 +445,7 @@ if ($_POST) {
write_config();
pfSenseHeader("system_certmanager.php");
redirectHeader("system_certmanager.php");
}
}
}
......
......@@ -71,7 +71,7 @@ if (!empty($id))
// If we were given an invalid crlref in the id, no sense in continuing as it would only cause errors.
if (!$thiscrl && (($act != "") && ($act != "new"))) {
pfSenseHeader("system_crlmanager.php");
redirectHeader("system_crlmanager.php");
$act="";
$savemsg = gettext("Invalid CRL reference.");
}
......@@ -115,7 +115,7 @@ if ($act == "addcert") {
$pconfig = $_POST;
if (!$pconfig['crlref'] || !$pconfig['certref']) {
pfSenseHeader("system_crlmanager.php");
redirectHeader("system_crlmanager.php");
exit;
}
......@@ -139,7 +139,7 @@ if ($act == "addcert") {
cert_revoke($cert, $crl, $reason);
openvpn_refresh_crls();
write_config("Revoked cert {$cert['descr']} in CRL {$crl['descr']}.");
pfSenseHeader("system_crlmanager.php");
redirectHeader("system_crlmanager.php");
exit;
}
}
......@@ -147,7 +147,7 @@ if ($act == "addcert") {
if ($act == "delcert") {
if (!is_array($thiscrl['cert'])) {
pfSenseHeader("system_crlmanager.php");
redirectHeader("system_crlmanager.php");
exit;
}
$found = false;
......@@ -158,7 +158,7 @@ if ($act == "delcert") {
}
}
if (!$found) {
pfSenseHeader("system_crlmanager.php");
redirectHeader("system_crlmanager.php");
exit;
}
$name = $thiscert['descr'];
......@@ -231,7 +231,7 @@ if ($_POST) {
write_config("Saved CRL {$crl['descr']}");
openvpn_refresh_crls();
pfSenseHeader("system_crlmanager.php");
redirectHeader("system_crlmanager.php");
}
}
......
......@@ -46,7 +46,7 @@ $act = (isset($_POST['act']) ? $_POST['act'] : '');
if ($act == "delgroup") {
if (!isset($id) || !isset($_POST['groupname']) || !isset($a_group[$id]) || ($_POST['groupname'] != $a_group[$id]['name'])) {
pfSenseHeader("system_groupmanager.php");
redirectHeader("system_groupmanager.php");
exit;
}
......@@ -61,7 +61,7 @@ if ($act == "delgroup") {
if ($act == "delpriv") {
if (!isset($id) || !isset($a_group[$id])) {
pfSenseHeader("system_groupmanager.php");
redirectHeader("system_groupmanager.php");
exit;
}
......
......@@ -51,7 +51,7 @@ if (isset($_POST['groupid']) && is_numericint($_POST['groupid']))
$a_group = & $config['system']['group'][$groupid];
if (!is_array($a_group)) {
pfSenseHeader("system_groupmanager.php?id={$groupid}");
redirectHeader("system_groupmanager.php?id={$groupid}");
exit;
}
......@@ -98,7 +98,7 @@ if ($_POST) {
$retval = write_config();
$savemsg = get_std_save_message($retval);
pfSenseHeader("system_groupmanager.php?act=edit&amp;id={$groupid}");
redirectHeader("system_groupmanager.php?act=edit&amp;id={$groupid}");
exit;
}
}
......
......@@ -65,7 +65,7 @@ if (isset($id) && $a_user[$id]) {
if ($_POST['act'] == "deluser") {
if (!isset($_POST['username']) || !isset($a_user[$id]) || ($_POST['username'] != $a_user[$id]['name'])) {
pfSenseHeader("system_usermanager.php");
redirectHeader("system_usermanager.php");
exit;
}
......@@ -79,7 +79,7 @@ if ($_POST['act'] == "deluser") {
else if ($_POST['act'] == "delpriv") {
if (!$a_user[$id]) {
pfSenseHeader("system_usermanager.php");
redirectHeader("system_usermanager.php");
exit;
}
......@@ -94,7 +94,7 @@ else if ($_POST['act'] == "delpriv") {
else if ($_POST['act'] == "expcert") {
if (!$a_user[$id]) {
pfSenseHeader("system_usermanager.php");
redirectHeader("system_usermanager.php");
exit;
}
......@@ -113,7 +113,7 @@ else if ($_POST['act'] == "expcert") {
else if ($_POST['act'] == "expckey") {
if (!$a_user[$id]) {
pfSenseHeader("system_usermanager.php");
redirectHeader("system_usermanager.php");
exit;
}
......@@ -132,7 +132,7 @@ else if ($_POST['act'] == "expckey") {
else if ($_POST['act'] == "delcert") {
if (!$a_user[$id]) {
pfSenseHeader("system_usermanager.php");
redirectHeader("system_usermanager.php");
exit;
}
......@@ -322,7 +322,7 @@ if ($_POST['save']) {
local_user_set($userent);
write_config();
pfSenseHeader("system_usermanager.php");
redirectHeader("system_usermanager.php");
}
}
......
......@@ -40,7 +40,7 @@ if (isset($_POST['userid']) && is_numericint($_POST['userid']))
$userid = $_POST['userid'];
if (!isset($config['system']['user'][$userid]) && !is_array($config['system']['user'][$userid])) {
pfSenseHeader("system_usermanager.php");
redirectHeader("system_usermanager.php");
exit;
}
......
......@@ -59,7 +59,7 @@ if ($_GET['act'] == "del") {
unset($a_secret[$_GET['id']]);
write_config();
mark_subsystem_dirty('l2tpusers');
pfSenseHeader("vpn_l2tp_users.php");
redirectHeader("vpn_l2tp_users.php");
exit;
}
}
......
......@@ -128,7 +128,7 @@ if ($_POST) {
$retval = vpn_l2tp_configure();
pfSenseHeader("vpn_l2tp_users.php");
redirectHeader("vpn_l2tp_users.php");
exit;
}
......
......@@ -69,7 +69,7 @@ else
if ($_GET['act'] == "del") {
if (!isset($a_client[$id])) {
pfSenseHeader("vpn_openvpn_client.php");
redirectHeader("vpn_openvpn_client.php");
exit;
}
if (!empty($a_client[$id]))
......
......@@ -49,7 +49,7 @@ if (isset($_POST['act']))
if ($_GET['act'] == "del") {
if (!$a_csc[$id]) {
pfSenseHeader("vpn_openvpn_csc.php");
redirectHeader("vpn_openvpn_csc.php");
exit;
}
......
......@@ -120,11 +120,11 @@ if (!empty($act)) {
$usrid = $_GET['usrid'];
$crtid = $_GET['crtid'];
if ($srvid === false) {
pfSenseHeader("vpn_openvpn_export.php");
redirectHeader("vpn_openvpn_export.php");
exit;
} else if (($config['openvpn']['openvpn-server'][$srvid]['mode'] != "server_user") &&
(($usrid === false) || ($crtid === false))) {
pfSenseHeader("vpn_openvpn_export.php");
redirectHeader("vpn_openvpn_export.php");
exit;
}
......
......@@ -75,7 +75,7 @@ $error = false;
if(($act == "skconf") || ($act == "skzipconf")) {
$srvid = $_GET['srvid'];
if (($srvid === false) || ($config['openvpn']['openvpn-server'][$srvid]['mode'] != "p2p_shared_key")) {
pfSenseHeader("vpn_openvpn_export.php");
redirectHeader("vpn_openvpn_export.php");
exit;
}
......
......@@ -70,7 +70,7 @@ else
if ($_GET['act'] == "del") {
if (!isset($a_server[$id])) {
pfSenseHeader("vpn_openvpn_server.php");
redirectHeader("vpn_openvpn_server.php");
exit;
}
if (!empty($a_server[$id]))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment