. * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ ##|+PRIV ##|*IDENT=page-status-trafficgraph ##|*NAME=Status: Traffic Graph ##|*DESCR=Allow access to the 'Status: Traffic Graph' page. ##|*MATCH=status_graph.php* ##|*MATCH=bandwidth_by_ip.php* ##|*MATCH=graph.php* ##|*MATCH=ifstats.php* ##|-PRIV require_once("guiconfig.inc"); require_once("ipsec.inc"); // Get configured interface list $ifdescrs = get_configured_interface_with_descr(); if (ipsec_enabled()) { $ifdescrs['enc0'] = gettext("IPsec"); } foreach (array('server', 'client') as $mode) { if (is_array($config['openvpn']["openvpn-{$mode}"])) { foreach ($config['openvpn']["openvpn-{$mode}"] as $id => $setting) { if (!isset($setting['disable'])) { $ifdescrs['ovpn' . substr($mode, 0, 1) . $setting['vpnid']] = gettext("OpenVPN") . " " . $mode . ": ".htmlspecialchars($setting['description']); } } } } if ($_REQUEST['if']) { $curif = $_REQUEST['if']; $found = false; foreach ($ifdescrs as $descr => $ifdescr) { if ($descr == $curif) { $found = true; break; } } if ($found === false) { header("Location: status_graph.php"); exit; } } else { if (empty($ifdescrs["wan"])) { /* Handle the case when WAN has been disabled. Use the first key in ifdescrs. */ reset($ifdescrs); $curif = key($ifdescrs); } else { $curif = "wan"; } } if ($_REQUEST['sort']) { $cursort = $_REQUEST['sort']; } else { $cursort = ""; } if ($_REQUEST['filter']) { $curfilter = $_REQUEST['filter']; } else { $curfilter = ""; } if ($_REQUEST['hostipformat']) { $curhostipformat = $_REQUEST['hostipformat']; } else { $curhostipformat = ""; } if ($_REQUEST['backgroundupdate']) { $curbackgroundupdate = $_REQUEST['backgroundupdate']; } else { $curbackgroundupdate = ""; } function iflist() { global $ifdescrs; $iflist = array(); foreach ($ifdescrs as $ifn => $ifd) { $iflist[$ifn] = $ifd; } return($iflist); } $pgtitle = array(gettext("Status"), gettext("Traffic Graph")); include("head.inc"); $form = new Form(false); $form->addClass('auto-submit'); $section = new Form_Section('Graph Settings'); $group = new Form_Group(''); $group->add(new Form_Select( 'if', null, $curif, iflist() ))->setHelp('Interface'); $group->add(new Form_Select( 'sort', null, $cursort, array ( 'in' => gettext('Bandwidth In'), 'out' => gettext('Bandwidth Out') ) ))->setHelp('Sort by'); $group->add(new Form_Select( 'filter', null, $curfilter, array ( 'local' => gettext('Local'), 'remote'=> gettext('Remote'), 'all' => gettext('All') ) ))->setHelp('Filter'); $group->add(new Form_Select( 'hostipformat', null, $curhostipformat, array ( '' => gettext('IP Address'), 'hostname' => gettext('Host Name'), 'descr' => gettext('Description'), 'fqdn' => gettext('FQDN') ) ))->setHelp('Display'); $group->add(new Form_Select( 'backgroundupdate', null, $curbackgroundupdate, array ( 'false' => gettext('Clear graphs when not visible.'), 'true' => gettext('Keep graphs updated on inactive tab. (increases cpu usage)'), ) ))->setHelp('Background updates'); $section->add($group); $form->add($section); print $form; $realif = get_real_interface($curif); ?>