From 8f09dd01eda55afc154d67d50fc492ab1814b0eb Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Sun, 17 Jan 2016 11:31:05 +0100 Subject: [PATCH] shortcuts: merge remainder into fbegin.inc --- src/www/fbegin.inc | 43 +++++++++++++++++------- src/www/shortcuts.inc | 77 ------------------------------------------- 2 files changed, 32 insertions(+), 88 deletions(-) delete mode 100644 src/www/shortcuts.inc diff --git a/src/www/fbegin.inc b/src/www/fbegin.inc index 78f30928f..1d3c3f744 100644 --- a/src/www/fbegin.inc +++ b/src/www/fbegin.inc @@ -1,8 +1,9 @@ + Copyright (C) 2014-2015 Deciso B.V. + Copyright (C) 2012 Jim Pingle + Copyright (C) 2007-2008 Scott Ullrich Copyright (C) 2005-2006 Colin Smith All rights reserved. @@ -28,13 +29,33 @@ POSSIBILITY OF SUCH DAMAGE. */ -require_once("shortcuts.inc"); +function find_service_by_shortcut($name) +{ + $shortcuts = array(); + + $shortcuts['dhcp'] = 'dhcpd'; + $shortcuts['forwarder'] = 'dnsmasq'; + $shortcuts['gateways'] = 'apinger'; + $shortcuts['ipsec'] = 'ipsec'; + $shortcuts['ntp'] = 'ntpd'; + $shortcuts['openvpn'] = 'openvpn'; + $shortcuts['relayd'] = 'relayd'; + $shortcuts['resolver'] = 'unbound'; + $shortcuts['snmp'] = 'bsnmpd'; + $shortcuts['squid'] = 'squid'; + $shortcuts['upnp'] = 'miniupnpd'; -function find_service_by_name($name) { $services = get_services(); - foreach ($services as $service) - if ($service["name"] == $name) - return $service; + + foreach ($shortcuts as $shortcut => $realname) { + if ($shortcut == $name) { + foreach ($services as $service) + if ($service['name'] == $realname) { + return $service; + } + } + } + return array(); } @@ -194,15 +215,15 @@ if($need_alert_display == true) { - All rights reserved. - - 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. - - 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. -*/ - -$shortcuts = array(); - -function get_shortcut_by_service_name($servicename) -{ - global $shortcuts; - - foreach ($shortcuts as $name => $shortcut) { - if (!empty($shortcut['service']) && ($shortcut['service'] == $servicename)) { - return $name; - } - } - - return null; -} - -$shortcuts['upnp'] = array(); -$shortcuts['upnp']['service'] = "miniupnpd"; - -$shortcuts['relayd'] = array(); -$shortcuts['relayd']['service'] = "relayd"; - -$shortcuts['dhcp'] = array(); -$shortcuts['dhcp']['service'] = "dhcpd"; - -$shortcuts['ipsec'] = array(); -$shortcuts['ipsec']['service'] = "ipsec"; - -$shortcuts['openvpn'] = array(); -$shortcuts['openvpn']['service'] = "openvpn"; - -$shortcuts['forwarder'] = array(); -$shortcuts['forwarder']['service'] = 'dnsmasq'; - -$shortcuts['resolver'] = array(); -$shortcuts['resolver']['service'] = 'unbound'; - -$shortcuts['ntp'] = array(); -$shortcuts['ntp']['service'] = 'ntpd'; - -$shortcuts['gateways'] = array(); -$shortcuts['gateways']['service'] = "apinger"; - -$shortcuts['snmp'] = array(); -$shortcuts['snmp']['service'] = "bsnmpd"; - -$shortcuts['squid'] = array(); -$shortcuts['squid']['service'] = "squid";