summaryrefslogtreecommitdiffstats
path: root/usr/local/www/bandwidth_by_ip.php
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2015-04-19 12:23:44 +0545
committerPhil Davis <phil.davis@inf.org>2015-04-19 12:23:44 +0545
commit45b4ffc68fed9e831da10de3b7d2de0c47496d1a (patch)
treeb197e9e651ea5df4f28d33bda408ae8002c38034 /usr/local/www/bandwidth_by_ip.php
parentabaa7feb680dc6f6f9bc79577075c45b3786a061 (diff)
downloadpfsense-45b4ffc68fed9e831da10de3b7d2de0c47496d1a.zip
pfsense-45b4ffc68fed9e831da10de3b7d2de0c47496d1a.tar.gz
Code style usr-local-www back-end
files that do stuff in mostly in the background.
Diffstat (limited to 'usr/local/www/bandwidth_by_ip.php')
-rwxr-xr-xusr/local/www/bandwidth_by_ip.php39
1 files changed, 21 insertions, 18 deletions
diff --git a/usr/local/www/bandwidth_by_ip.php b/usr/local/www/bandwidth_by_ip.php
index 74697e6..c9e8e93 100755
--- a/usr/local/www/bandwidth_by_ip.php
+++ b/usr/local/www/bandwidth_by_ip.php
@@ -1,5 +1,5 @@
<?php
-/*
+/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*
@@ -33,8 +33,9 @@ $intsubnet = gen_subnet($intip, $netmask) . "/$netmask";
// see if they want local, remote or all IPs returned
$filter = $_GET['filter'];
-if ($filter == "")
+if ($filter == "") {
$filter = "local";
+}
if ($filter == "local") {
$ratesubnet = "-c " . $intsubnet;
@@ -47,18 +48,19 @@ if ($filter == "local") {
//get the sort method
$sort = $_GET['sort'];
-if ($sort == "out")
- {$sort_method = "-T";}
-else
- {$sort_method = "-R";}
+if ($sort == "out") {
+ $sort_method = "-T";
+} else {
+ $sort_method = "-R";
+}
// get the desired format for displaying the host name or IP
$hostipformat = $_GET['hostipformat'];
$iplookup = array();
// If hostname display is requested and the DNS forwarder does not already have DHCP static names registered,
// then load the DHCP static mappings into an array keyed by IP address.
-if (($hostipformat != "") && ((!isset($config['dnsmasq']['enable']) || !isset($config['dnsmasq']['regdhcpstatic']))
- || (!isset($config['unbound']['enable']) || !isset($config['unbound']['regdhcpstatic'])))) {
+if (($hostipformat != "") && ((!isset($config['dnsmasq']['enable']) || !isset($config['dnsmasq']['regdhcpstatic'])) ||
+ (!isset($config['unbound']['enable']) || !isset($config['unbound']['regdhcpstatic'])))) {
if (is_array($config['dhcpd'])) {
foreach ($config['dhcpd'] as $ifdata) {
if (is_array($ifdata['staticmap'])) {
@@ -75,14 +77,14 @@ if (($hostipformat != "") && ((!isset($config['dnsmasq']['enable']) || !isset($c
$_grb = exec("/usr/local/bin/rate -i {$real_interface} -nlq 1 -Aba 20 {$sort_method} {$ratesubnet} | tr \"|\" \" \" | awk '{ printf \"%s:%s:%s:%s:%s\\n\", $1, $2, $4, $6, $8 }'", $listedIPs);
$someinfo = false;
-for ($x=2; $x<12; $x++){
+for ($x=2; $x<12; $x++) {
- $bandwidthinfo = $listedIPs[$x];
+ $bandwidthinfo = $listedIPs[$x];
- // echo $bandwidthinfo;
- $emptyinfocounter = 1;
- if ($bandwidthinfo != "") {
- $infoarray = explode (":",$bandwidthinfo);
+ // echo $bandwidthinfo;
+ $emptyinfocounter = 1;
+ if ($bandwidthinfo != "") {
+ $infoarray = explode (":",$bandwidthinfo);
if (($filter == "all") ||
(($filter == "local") && (ip_in_subnet($infoarray[0], $intsubnet))) ||
(($filter == "remote") && (!ip_in_subnet($infoarray[0], $intsubnet)))) {
@@ -93,8 +95,9 @@ for ($x=2; $x<12; $x++){
$addrdata = gethostbyaddr($infoarray[0]);
if ($addrdata == $infoarray[0]) {
// gethostbyaddr() gave us back the IP address, so try the static mapping array
- if ($iplookup[$infoarray[0]] != "")
+ if ($iplookup[$infoarray[0]] != "") {
$addrdata = $iplookup[$infoarray[0]];
+ }
} else {
if ($hostipformat == "hostname") {
// Only pass back the first part of the name, not the FQDN.
@@ -115,7 +118,7 @@ unset($bandwidthinfo, $_grb);
unset($listedIPs);
//no bandwidth usage found
-if ($someinfo == false)
- echo gettext("no info");
-
+if ($someinfo == false) {
+ echo gettext("no info");
+}
?>
OpenPOWER on IntegriCloud