* Copyright (c) 2004-2005 Jonathan Watt . * All rights reserved. * * originally part of m0n0wall (http://m0n0.ch/wall) * Copyright (c) 2003-2004 Manuel Kasper . * 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. * * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgment: * "This product includes software developed by the pfSense Project * for use in the pfSense® software distribution. (http://www.pfsense.org/). * * 4. The names "pfSense" and "pfSense Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * coreteam@pfsense.org. * * 5. Products derived from this software may not be called "pfSense" * nor may "pfSense" appear in their names without prior written * permission of the Electric Sheep Fencing, LLC. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * * "This product includes software developed by the pfSense Project * for use in the pfSense software distribution (http://www.pfsense.org/). * * THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY * EXPRESSED 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 pfSense PROJECT OR * ITS CONTRIBUTORS 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. */ /* TODOs */ //re-use on Status > traffic graphs //figure out why there is a missing datapoint at the start //name things/variables better //apply css change to Status > Monitoring //show interface name and latest in/out in upper left //add stacked overall graph? //also show pie graph of lastest precentages of total? (split 50/50 on width) //make this an option? $nocsrf = true; require_once("guiconfig.inc"); require_once("pfsense-utils.inc"); require_once("ipsec.inc"); require_once("functions.inc"); $ifdescrs = get_configured_interface_with_descr(); if (ipsec_enabled()) { $ifdescrs['enc0'] = "IPsec"; } //there are no traffic graph widget defaults in config yet. so set them, but don't write the config if (!is_array($config["widgets"]["trafficgraphs"])) { $config["widgets"]["trafficgraphs"] = array(); $config["widgets"]["trafficgraphs"]["refreshinterval"] = 1; $config["widgets"]["trafficgraphs"]["invert"] = "true"; $config["widgets"]["trafficgraphs"]["size"] = 1; $config["widgets"]["trafficgraphs"]["shown"] = array(); $config["widgets"]["trafficgraphs"]["shown"]["item"] = array(); foreach($ifdescrs as $ifname => $ifdescr) { $ifinfo = get_interface_info($ifname); if ($ifinfo['status'] != "down") { $config["widgets"]["trafficgraphs"]["shown"]["item"][] = $ifname; } } //TODO silently write to config? (use a config message about saving defaults) } if(!isset($config["widgets"]["trafficgraphs"]["size"])) { $config["widgets"]["trafficgraphs"]["size"] = 1; } if(!isset($config["widgets"]["trafficgraphs"]["invert"])) { $config["widgets"]["trafficgraphs"]["invert"] = "true"; } $a_config = &$config["widgets"]["trafficgraphs"]; // save new default config options that have been submitted if ($_POST) { //TODO validate data and throw error $a_config["shown"]["item"] = $_POST["traffic-graph-interfaces"]; // TODO check if between 1 and 10 if (isset($_POST["traffic-graph-interval"]) && is_numericint($_POST["traffic-graph-interval"])) { $a_config["refreshinterval"] = $_POST["traffic-graph-interval"]; } else { die('{ "error" : "Refresh Interval is not a valid number between 1 and 10." }'); } if($_POST["traffic-graph-invert"] === "true" || $_POST["traffic-graph-invert"] === "false") { $a_config["invert"] = $_POST["traffic-graph-invert"]; } else { die('{ "error" : "Invert is not a boolean of true or false." }'); } //TODO validate data and throw error $a_config["size"] = $_POST["traffic-graph-size"]; write_config(gettext("Updated traffic graph settings via dashboard.")); header('Content-Type: application/json'); die('{ "success" : "The changes have been applied successfully." }'); } $refreshinterval = $a_config["refreshinterval"]; $ifsarray = []; foreach ($a_config["shown"]["item"] as $ifname) { $ifinfo = get_interface_info($ifname); if ($ifinfo['status'] != "down") { $ifsarray[] = $ifname; } else { //TODO throw error? } } $allifs = implode("|", $ifsarray); ?> '; echo ' '; echo ''; } ?>