Project

General

Profile

« Previous | Next » 

Revision 45b4ffc6

Added by Phil Davis about 10 years ago

Code style usr-local-www back-end

files that do stuff in mostly in the background.

View differences:

usr/local/www/bandwidth_by_ip.php
1 1
<?php
2
/* 
2
/*
3 3
 * To change this template, choose Tools | Templates
4 4
 * and open the template in the editor.
5 5
 *
......
33 33
// see if they want local, remote or all IPs returned
34 34
$filter = $_GET['filter'];
35 35

  
36
if ($filter == "")
36
if ($filter == "") {
37 37
	$filter = "local";
38
}
38 39

  
39 40
if ($filter == "local") {
40 41
	$ratesubnet = "-c " . $intsubnet;
......
47 48

  
48 49
//get the sort method
49 50
$sort = $_GET['sort'];
50
if ($sort == "out") 
51
	{$sort_method = "-T";}
52
else
53
	{$sort_method = "-R";}
51
if ($sort == "out") {
52
	$sort_method = "-T";
53
} else {
54
	$sort_method = "-R";
55
}
54 56

  
55 57
// get the desired format for displaying the host name or IP
56 58
$hostipformat = $_GET['hostipformat'];
57 59
$iplookup = array();
58 60
// If hostname display is requested and the DNS forwarder does not already have DHCP static names registered,
59 61
// then load the DHCP static mappings into an array keyed by IP address.
60
if (($hostipformat != "") && ((!isset($config['dnsmasq']['enable']) || !isset($config['dnsmasq']['regdhcpstatic']))
61
	|| (!isset($config['unbound']['enable']) || !isset($config['unbound']['regdhcpstatic'])))) {
62
if (($hostipformat != "") && ((!isset($config['dnsmasq']['enable']) || !isset($config['dnsmasq']['regdhcpstatic'])) ||
63
    (!isset($config['unbound']['enable']) || !isset($config['unbound']['regdhcpstatic'])))) {
62 64
	if (is_array($config['dhcpd'])) {
63 65
		foreach ($config['dhcpd'] as $ifdata) {
64 66
			if (is_array($ifdata['staticmap'])) {
......
75 77
$_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);
76 78

  
77 79
$someinfo = false;
78
for ($x=2; $x<12; $x++){
80
for ($x=2; $x<12; $x++) {
79 81

  
80
    $bandwidthinfo = $listedIPs[$x];
82
	$bandwidthinfo = $listedIPs[$x];
81 83

  
82
   // echo $bandwidthinfo;
83
    $emptyinfocounter = 1;
84
    if ($bandwidthinfo != "") {
85
        $infoarray = explode (":",$bandwidthinfo);
84
	// echo $bandwidthinfo;
85
	$emptyinfocounter = 1;
86
	if ($bandwidthinfo != "") {
87
		$infoarray = explode (":",$bandwidthinfo);
86 88
		if (($filter == "all") ||
87 89
		    (($filter == "local") && (ip_in_subnet($infoarray[0], $intsubnet))) ||
88 90
		    (($filter == "remote") && (!ip_in_subnet($infoarray[0], $intsubnet)))) {
......
93 95
				$addrdata = gethostbyaddr($infoarray[0]);
94 96
				if ($addrdata == $infoarray[0]) {
95 97
					// gethostbyaddr() gave us back the IP address, so try the static mapping array
96
					if ($iplookup[$infoarray[0]] != "")
98
					if ($iplookup[$infoarray[0]] != "") {
97 99
						$addrdata = $iplookup[$infoarray[0]];
100
					}
98 101
				} else {
99 102
					if ($hostipformat == "hostname") {
100 103
						// Only pass back the first part of the name, not the FQDN.
......
115 118
unset($listedIPs);
116 119

  
117 120
//no bandwidth usage found
118
if ($someinfo == false)
119
    echo gettext("no info");
120

  
121
if ($someinfo == false) {
122
	echo gettext("no info");
123
}
121 124
?>

Also available in: Unified diff