-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubnetSummary.php
90 lines (77 loc) · 3.63 KB
/
subnetSummary.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2006 Michael Earls |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| - phpIP - http://www.phpip.net/ |
+-------------------------------------------------------------------------+
*/
ob_start();
// include the layout file
include 'layout.php';
login_check();
// Use the myheader function from layout.php
myheader("Subnet Summary");
// get count of netaddress for for loop
$NetCount_sql = mysql_query("SELECT COUNT(*) AS NetCount FROM `net_ips` WHERE `view` = '1'");
while($row = mysql_fetch_array($NetCount_sql)) {
$NetCount = $row[NetCount];
}
// need to subtract 1 from total
$NetCount = ($NetCount - 1);
// loop net_ips for netaddress
$NetListView = mysql_query("SELECT `netaddress`, `NetCidr` FROM `net_ips` WHERE `view` = '1'");
while($row = mysql_fetch_array($NetListView)) {
$iprangeEx = explode('.', $row[netaddress]);
// grab total number of address based on prefixes (netaddress)
$NetTotal_sql = mysql_query("SELECT COUNT(*) AS NetTotal FROM `addresses` WHERE `ip`
LIKE '%$iprangeEx[0].$iprangeEx[1].$iprangeEx[2].%' AND `NetID` = '$row[NetCidr]'");
// grab used number of address based on prefixes (netaddress)
$NetUsed_sql = mysql_query("SELECT COUNT(*) AS Used FROM `addresses` WHERE `ip`
LIKE '%$iprangeEx[0].$iprangeEx[1].$iprangeEx[2].%' AND `NetID` = '$row[NetCidr]' AND `client` IS NOT NULL");
while($row = mysql_fetch_array($NetTotal_sql)) {
$TotalValue[] = $row[NetTotal];
}
while($row = mysql_fetch_array($NetUsed_sql)) {
$NetUsed[] = $row[Used];
}
}
?>
<table class="listTable" style="width:100%" cellpadding="0" cellspacing="0">
<tr class="listCell">
<TD class="listCell" colspan="3">PREFIX SUMMARY</TD>
</tr>
<tr class="listHeadRow">
<TD class="listCell">PREFIX</TD>
<TD class="listCell"> </TD>
<TD class="listCell">USED/TOTAL</TD>
</tr>
<?php
$NetDisplay_sql = mysql_query("SELECT `netaddress` FROM `net_ips` WHERE `view` = '1'");
for ($i = 0; $i <= $NetCount; $i++) {
$row = mysql_fetch_array($NetDisplay_sql);
if ($RowClass == "listRow2") { $RowClass = "listRow1";
}
else
{ $RowClass = "listRow2";
}
echo "<TR class=\"$RowClass\">";
echo "<TD class=\"listCell\"><b>$row[netaddress]</b></TD>";
echo "<TD class=\"listCell\" width=\"256\"><img src='i/4.gif' height='10' width='$NetUsed[$i]'></TD>";
echo "<TD class=\"listCell\">$NetUsed[$i]/$TotalValue[$i]</TD>";
echo "</TR>";
}
echo "</TABLE>";
// Use the footer function from layout.php
footer();
?>