From 3d93e25ba06cd7200a24dde31a288bfb876aaf09 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Mon, 18 Jan 2016 09:20:17 +0100 Subject: [PATCH] services: remove indirect mapping and fix remaining services --- src/www/diag_logs_gateways.php | 3 ++ src/www/diag_logs_ntpd.php | 2 +- src/www/fbegin.inc | 31 +++---------------- src/www/load_balancer_pool_edit.php | 2 +- src/www/services_ntpd.php | 2 +- src/www/services_ntpd_gps.php | 2 +- src/www/services_ntpd_pps.php | 4 +-- src/www/services_snmp.php | 2 +- src/www/services_upnp.php | 2 +- src/www/status_gateway_groups.php | 3 ++ src/www/status_gateways.php | 2 ++ src/www/status_ntpd.php | 2 +- src/www/status_upnp.php | 2 +- src/www/system_gateway_groups.php | 3 ++ src/www/system_gateway_groups_edit.php | 3 ++ src/www/system_gateways.php | 42 ++++++++++++++------------ src/www/system_gateways_edit.php | 2 ++ 17 files changed, 53 insertions(+), 56 deletions(-) diff --git a/src/www/diag_logs_gateways.php b/src/www/diag_logs_gateways.php index ea4deecbe..566a72f99 100644 --- a/src/www/diag_logs_gateways.php +++ b/src/www/diag_logs_gateways.php @@ -3,4 +3,7 @@ $logfile = '/var/log/gateways.log'; $logclog = true; +require_once 'services.inc'; +$shortcut_section = 'apinger'; + require_once 'diag_logs_template.inc'; diff --git a/src/www/diag_logs_ntpd.php b/src/www/diag_logs_ntpd.php index 382246fd5..e036836ac 100644 --- a/src/www/diag_logs_ntpd.php +++ b/src/www/diag_logs_ntpd.php @@ -4,6 +4,6 @@ $logfile = '/var/log/ntpd.log'; $logclog = true; require_once 'services.inc'; -$shortcut_section = 'ntp'; +$shortcut_section = 'ntpd'; require_once 'diag_logs_template.inc'; diff --git a/src/www/fbegin.inc b/src/www/fbegin.inc index 8ef1f3ea8..9d47efb1a 100644 --- a/src/www/fbegin.inc +++ b/src/www/fbegin.inc @@ -29,39 +29,18 @@ POSSIBILITY OF SUCH DAMAGE. */ -function find_service_by_shortcut($names) +function find_service_by_name($names) { - $shortcuts = array(); - if (!is_array($names)) { $names = array($names); } - $shortcuts['dhcpd'] = 'dhcpd'; - $shortcuts['dhcrelay'] = 'dhcrelay'; - $shortcuts['dhcrelay6'] = 'dhcrelay6'; - $shortcuts['dnsmasq'] = 'dnsmasq'; - $shortcuts['unbound'] = 'unbound'; - - /* WIP unify mapping so "shortcuts" are no longer needed */ - $shortcuts['gateways'] = 'apinger'; - $shortcuts['ipsec'] = 'ipsec'; - $shortcuts['ntp'] = 'ntpd'; - $shortcuts['openvpn'] = 'openvpn'; - $shortcuts['relayd'] = 'relayd'; - $shortcuts['snmp'] = 'bsnmpd'; - $shortcuts['squid'] = 'squid'; - $shortcuts['upnp'] = 'miniupnpd'; - $services = get_services(); - foreach ($shortcuts as $shortcut => $realname) { + foreach ($services as $service) { foreach ($names as $name) { - if ($shortcut == $name) { - foreach ($services as $service) - if ($service['name'] == $realname) { - return $service; - } + if ($service['name'] == $name) { + return $service; } } } @@ -232,7 +211,7 @@ if($need_alert_display == true) { $ssvc = find_service_by_openvpn_vpnid($vpnid); break; default: - $ssvc = find_service_by_shortcut($shortcut_section); + $ssvc = find_service_by_name($shortcut_section); break; } if (!empty($ssvc)) { diff --git a/src/www/load_balancer_pool_edit.php b/src/www/load_balancer_pool_edit.php index deed1f1a3..45567c9b5 100644 --- a/src/www/load_balancer_pool_edit.php +++ b/src/www/load_balancer_pool_edit.php @@ -146,7 +146,7 @@ if ($_POST) { } } -$shortcut_section = "relayd"; +$shortcut_section = 'relayd'; include("head.inc"); diff --git a/src/www/services_ntpd.php b/src/www/services_ntpd.php index 2da72e0fa..9155572fa 100644 --- a/src/www/services_ntpd.php +++ b/src/www/services_ntpd.php @@ -157,7 +157,7 @@ if (empty($pconfig['interface'])) { $pconfig['interface'] = explode(",", $pconfig['interface']); } -$shortcut_section = 'ntp'; +$shortcut_section = 'ntpd'; include("head.inc"); diff --git a/src/www/services_ntpd_gps.php b/src/www/services_ntpd_gps.php index a043b64e1..2dce1b237 100644 --- a/src/www/services_ntpd_gps.php +++ b/src/www/services_ntpd_gps.php @@ -130,7 +130,7 @@ if ($_POST) { } $pconfig = &$config['ntpd']['gps']; -$shortcut_section = "ntp"; +$shortcut_section = 'ntpd'; $closehead = false; include("head.inc"); diff --git a/src/www/services_ntpd_pps.php b/src/www/services_ntpd_pps.php index cb2415824..530773a84 100644 --- a/src/www/services_ntpd_pps.php +++ b/src/www/services_ntpd_pps.php @@ -87,9 +87,9 @@ if ($_POST) { $retval = system_ntp_configure(); $savemsg = get_std_save_message(); } -$pconfig = &$config['ntpd']['pps']; -$shortcut_section = "ntp"; +$pconfig = &$config['ntpd']['pps']; +$shortcut_section = 'ntpd'; include("head.inc"); diff --git a/src/www/services_snmp.php b/src/www/services_snmp.php index 36a58d903..d0ead8e8f 100644 --- a/src/www/services_snmp.php +++ b/src/www/services_snmp.php @@ -152,7 +152,7 @@ if ($_POST) { } } -$shortcut_section = "snmp"; +$shortcut_section = 'bsnmpd'; $closehead = false; include("head.inc"); diff --git a/src/www/services_upnp.php b/src/www/services_upnp.php index 557f7f69c..faa9ac547 100644 --- a/src/www/services_upnp.php +++ b/src/www/services_upnp.php @@ -29,7 +29,7 @@ ini_set('max_execution_time', '0'); -$shortcut_section = "upnp"; +$shortcut_section = 'miniupnpd'; require_once("guiconfig.inc"); require_once("services.inc"); diff --git a/src/www/status_gateway_groups.php b/src/www/status_gateway_groups.php index 987f614de..984684699 100644 --- a/src/www/status_gateway_groups.php +++ b/src/www/status_gateway_groups.php @@ -28,6 +28,7 @@ */ require_once("guiconfig.inc"); +require_once("services.inc"); // request report data if (!isset($config['gateways']['gateway_group']) || !is_array($config['gateways']['gateway_group'])) { @@ -41,6 +42,8 @@ $a_gateways = return_gateways_array(); legacy_html_escape_form_data($a_gateways); legacy_html_escape_form_data($a_gateway_groups); +$shortcut_section = 'apinger'; + include("head.inc"); ?> diff --git a/src/www/status_gateways.php b/src/www/status_gateways.php index 75f46fde5..64f4b8906 100644 --- a/src/www/status_gateways.php +++ b/src/www/status_gateways.php @@ -35,6 +35,8 @@ $a_gateways = return_gateways_array(); $gateways_status = return_gateways_status(true); legacy_html_escape_form_data($a_gateways); +$shortcut_section = 'apinger'; + include("head.inc"); ?> diff --git a/src/www/status_ntpd.php b/src/www/status_ntpd.php index b09e0fffe..eea8b2b7a 100644 --- a/src/www/status_ntpd.php +++ b/src/www/status_ntpd.php @@ -145,7 +145,7 @@ if (isset($config['ntpd']['gps']['type']) && ($config['ntpd']['gps']['type'] == } } -$shortcut_section = "ntp"; +$shortcut_section = 'ntpd'; include("head.inc"); diff --git a/src/www/status_upnp.php b/src/www/status_upnp.php index 647ce639f..9c3770e91 100644 --- a/src/www/status_upnp.php +++ b/src/www/status_upnp.php @@ -44,7 +44,7 @@ exec("/sbin/pfctl -aminiupnpd -sn", $rdr_entries, $pf_ret); $now = time(); $year = date("Y"); -$shortcut_section = "upnp"; +$shortcut_section = 'miniupnpd'; include("head.inc"); diff --git a/src/www/system_gateway_groups.php b/src/www/system_gateway_groups.php index 3ea536bea..5049d5b60 100644 --- a/src/www/system_gateway_groups.php +++ b/src/www/system_gateway_groups.php @@ -31,6 +31,7 @@ require_once("guiconfig.inc"); require_once("interfaces.inc"); require_once("openvpn.inc"); require_once("system.inc"); +require_once("services.inc"); require_once("pfsense-utils.inc"); require_once("rrd.inc"); @@ -112,6 +113,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { legacy_html_escape_form_data($a_gateway_groups); +$shortcut_section = 'apinger'; + include("head.inc"); $main_buttons = array( diff --git a/src/www/system_gateway_groups_edit.php b/src/www/system_gateway_groups_edit.php index 7af0b36af..e6e3ea3e5 100644 --- a/src/www/system_gateway_groups_edit.php +++ b/src/www/system_gateway_groups_edit.php @@ -29,6 +29,7 @@ require_once("guiconfig.inc"); require_once("vpn.inc"); +require_once("services.inc"); require_once("interfaces.inc"); if (!is_array($config['gateways'])) { @@ -143,6 +144,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { legacy_html_escape_form_data($a_gateways); legacy_html_escape_form_data($pconfig); +$shortcut_section = 'apinger'; + include("head.inc"); ?> diff --git a/src/www/system_gateways.php b/src/www/system_gateways.php index 4ff45c293..dd4cb8405 100644 --- a/src/www/system_gateways.php +++ b/src/www/system_gateways.php @@ -1,30 +1,30 @@ . - All rights reserved. + Copyright (C) 2014-2015 Deciso B.V. + Copyright (C) 2010 Seth Mos . + All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. */ require_once("guiconfig.inc"); @@ -205,6 +205,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { legacy_html_escape_form_data($a_gateways); +$shortcut_section = 'apinger'; + include("head.inc"); $main_buttons = array( diff --git a/src/www/system_gateways_edit.php b/src/www/system_gateways_edit.php index 5183d68a0..1623b6aa3 100644 --- a/src/www/system_gateways_edit.php +++ b/src/www/system_gateways_edit.php @@ -477,6 +477,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { legacy_html_escape_form_data($a_gateways); legacy_html_escape_form_data($pconfig); +$shortcut_section = 'apinger'; + include("head.inc"); ?>