Commit 8f09dd01 authored by Franco Fichtner's avatar Franco Fichtner

shortcuts: merge remainder into fbegin.inc

parent 7743289a
<?php
/*
Copyright (C) 2014 Deciso B.V.
Copyright (C) 2008 Scott Ullrich <sullrich@gmail.com>
Copyright (C) 2014-2015 Deciso B.V.
Copyright (C) 2012 Jim Pingle
Copyright (C) 2007-2008 Scott Ullrich <sullrich@gmail.com>
Copyright (C) 2005-2006 Colin Smith <ethethlay@gmail.com>
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) {
<?php
if (isset($shortcut_section) && !empty($shortcuts[$shortcut_section]['service'])) {
if (isset($shortcut_section)) {
$ssvc = array();
switch ($shortcut_section) {
case "openvpn":
case 'openvpn':
$ssvc = find_service_by_openvpn_vpnid($vpnid);
break;
default:
$ssvc = find_service_by_name($shortcuts[$shortcut_section]['service']);
$ssvc = find_service_by_shortcut($shortcut_section);
break;
}
if (!empty($ssvc)) {
echo get_service_status_icon($ssvc, false);
......
<?php
/*
Copyright (C) 2014-2015 Deciso B.V.
Copyright (C) 2012 Jim Pingle
Copyright (C) 2007, 2008 Scott Ullrich <sullrich@gmail.com>
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";
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