|
|
|
@ -42,16 +42,8 @@ $subnet = $sth->fetch(PDO::FETCH_OBJ); |
|
|
|
|
|
|
|
|
|
$smarty->assign("subnet", $subnet); |
|
|
|
|
|
|
|
|
|
// set needed variables |
|
|
|
|
$subnet_address = $subnet->address; |
|
|
|
|
$subnet_mask = $subnet->mask; |
|
|
|
|
$subnet_dhcpstart = $subnet->dhcp_start; |
|
|
|
|
$subnet_dhcpend = $subnet->dhcp_end; |
|
|
|
|
$subnet_proto_vers = $subnet->protocol_version; |
|
|
|
|
$subnet_ntp_server = $subnet->ntp_server; |
|
|
|
|
|
|
|
|
|
// set counters |
|
|
|
|
$host_counter = pow(2,(32-$subnet_mask)); |
|
|
|
|
$host_counter = pow(2, (32-$subnet->mask)); |
|
|
|
|
$node_counter = $subnet->node_counter; |
|
|
|
|
$subnet_usedpercentage = round((($node_counter/($host_counter-2))*100), 1); |
|
|
|
|
|
|
|
|
@ -74,7 +66,7 @@ $iprange4 = $iprange[3]; |
|
|
|
|
$subnetdata = array(); |
|
|
|
|
|
|
|
|
|
// determine range (Class A/B/C) |
|
|
|
|
if ($subnet_mask >= 24) { |
|
|
|
|
if ($subnet->mask >= 24) { |
|
|
|
|
// Class C |
|
|
|
|
// fill subnet-array with addresses we want to see |
|
|
|
|
for($i=0; $i<$host_counter; $i++) { |
|
|
|
@ -105,15 +97,16 @@ if ($subnet_mask >= 24) { |
|
|
|
|
|
|
|
|
|
// set displayed nodes |
|
|
|
|
$nodes_displayed = $host_counter; |
|
|
|
|
} else if ($subnet_mask>=16) { |
|
|
|
|
|
|
|
|
|
} else if ($subnet->mask >= 16) { |
|
|
|
|
// Class B |
|
|
|
|
// which part do we want to see? |
|
|
|
|
if((empty($page)) ? $page=$subnet_address : $page=$page); |
|
|
|
|
if ((empty($page)) ? $page = $subnet->address : $page = $page); |
|
|
|
|
$page = explode('.', $page); |
|
|
|
|
$page2 = $page[2]; |
|
|
|
|
|
|
|
|
|
// fill subnet-array with addresses we want to see |
|
|
|
|
for($i=0;$i<256;$i++) { |
|
|
|
|
for($i=0; $i<256; $i++) { |
|
|
|
|
// build ip |
|
|
|
|
$ip = $iprange1 . '.' . $iprange2 . '.' . $page2 . '.' . $i; |
|
|
|
|
|
|
|
|
@ -129,13 +122,13 @@ if ($subnet_mask >= 24) { |
|
|
|
|
$smarty->assign("iprange2", $iprange2); |
|
|
|
|
|
|
|
|
|
// loop addresses in range3 |
|
|
|
|
for($i=$iprange3;$i<(pow(2,(32-$subnet_mask))/256);$i++) { |
|
|
|
|
for ($i=$iprange3; $i<(pow(2,(32-$subnet->mask))/256); $i++) { |
|
|
|
|
// send to tpl |
|
|
|
|
$smarty->assign("iprange3", $i); |
|
|
|
|
$smarty->assign("iprange4", 0); |
|
|
|
|
|
|
|
|
|
// set select box |
|
|
|
|
if($i==$page2) { |
|
|
|
|
if ($i == $page2) { |
|
|
|
|
$smarty->assign("row_selected", "selected"); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
@ -159,7 +152,7 @@ if ($subnet_mask >= 24) { |
|
|
|
|
} else { |
|
|
|
|
// Class A |
|
|
|
|
// which part do we want to see? |
|
|
|
|
if ((empty($page)) ? $page = $subnet_address : $page = $page); |
|
|
|
|
if ((empty($page)) ? $page = $subnet->address : $page = $page); |
|
|
|
|
$page = explode('.', $page); |
|
|
|
|
$page2 = $page[1]; |
|
|
|
|
$page3 = $page[2]; |
|
|
|
@ -181,7 +174,7 @@ if ($subnet_mask >= 24) { |
|
|
|
|
$smarty->assign("iprange2", $iprange2); |
|
|
|
|
|
|
|
|
|
// loop addresses in range 2 |
|
|
|
|
for ($i=$iprange2; $i<(pow(2,(24-$subnet_mask))/256); $i++) { |
|
|
|
|
for ($i=$iprange2; $i<(pow(2,(24-$subnet->mask))/256); $i++) { |
|
|
|
|
// send to tpl |
|
|
|
|
$smarty->assign("iprange1", $iprange1); |
|
|
|
|
$smarty->assign("iprange2", $i); |
|
|
|
@ -196,12 +189,10 @@ if ($subnet_mask >= 24) { |
|
|
|
|
$smarty->assign("row1_selected", ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// parse block |
|
|
|
|
$tp->parse("two_select_row1"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// loop addresses in range 3 |
|
|
|
|
for($i=0; $i<256; $i++) { |
|
|
|
|
for ($i=0; $i<256; $i++) { |
|
|
|
|
// send to tpl |
|
|
|
|
$smarty->assign("iprange1", $iprange1); |
|
|
|
|
$smarty->assign("iprange2", $page2); |
|
|
|
@ -216,8 +207,6 @@ if ($subnet_mask >= 24) { |
|
|
|
|
$smarty->assign("row2_selected", ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// parse block |
|
|
|
|
$tp->parse("two_select_row2"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$smarty->assign("subnetmask1", 255); |
|
|
|
@ -235,43 +224,36 @@ if ($subnet_mask >= 24) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// get nodes for this subnetview and implement the values into the array |
|
|
|
|
$sql = "SELECT |
|
|
|
|
asset.asset_name, |
|
|
|
|
assetclassgroup.assetclassgroup_color, |
|
|
|
|
node.node_id, |
|
|
|
|
node.node_ip |
|
|
|
|
FROM |
|
|
|
|
asset, |
|
|
|
|
assetclass, |
|
|
|
|
assetclassgroup, |
|
|
|
|
node |
|
|
|
|
$sql = "SELECT a.asset_name, g.assetclassgroup_color, n.node_id, n.node_ip |
|
|
|
|
FROM |
|
|
|
|
asset AS a, |
|
|
|
|
assetclass AS c, |
|
|
|
|
assetclassgroup AS g, |
|
|
|
|
node AS n |
|
|
|
|
WHERE |
|
|
|
|
node.node_ip IN ('".implode("','",array_keys($subnetdata))."') |
|
|
|
|
AND node.subnet_id=? |
|
|
|
|
AND asset.asset_id=node.asset_id |
|
|
|
|
AND assetclass.assetclass_id=asset.assetclass_id |
|
|
|
|
AND assetclassgroup.assetclassgroup_id=assetclass.assetclassgroup_id"; |
|
|
|
|
n.node_ip IN ('".implode("','",array_keys($subnetdata))."') |
|
|
|
|
AND n.subnet_id=? |
|
|
|
|
AND a.asset_id=n.asset_id |
|
|
|
|
AND c.assetclass_id=a.assetclass_id |
|
|
|
|
AND g.assetclassgroup_id=c.assetclassgroup_id"; |
|
|
|
|
|
|
|
|
|
$sth = $dbh->prepare($sql); |
|
|
|
|
$sth->execute([$subnet_id]); |
|
|
|
|
$smarty->assign("locations", $sth->fetchAll()); |
|
|
|
|
|
|
|
|
|
$nodes = $sth->fetchAll(); |
|
|
|
|
$smarty->assign("nodes", $nodes); |
|
|
|
|
|
|
|
|
|
$node_counter = count($nodes); |
|
|
|
|
if ($node_counter > 0) { |
|
|
|
|
// get objects |
|
|
|
|
if (count($nodes) > 0) { |
|
|
|
|
foreach ($nodes AS $node) { |
|
|
|
|
// add node-values to ip in subnet-array |
|
|
|
|
$subnetdata[$node['node_ip']] = $node; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// replace ip's in subnet-array (if necessary) |
|
|
|
|
// check for subnet address |
|
|
|
|
if (array_key_exists($subnet_address, $subnet)) { |
|
|
|
|
if (array_key_exists($subnet->address, $subnet)) { |
|
|
|
|
// replace |
|
|
|
|
$subnetdata[$subnet_address] = array("subnet_address"); |
|
|
|
|
$subnetdata[$subnet->address] = array("subnet_address"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// check for broadcast address |
|
|
|
@ -281,9 +263,9 @@ if (array_key_exists($broadcast_address, $subnet)) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$dhcpstart = 0; |
|
|
|
|
if ($subnet_dhcpstart && $subnet_dhcpend) { |
|
|
|
|
$dhcpstart = ip2long($subnet_dhcpstart); |
|
|
|
|
$dhcpend = ip2long($subnet_dhcpend); |
|
|
|
|
if ($subnet->dhcp_start && $subnet->dhcp_end) { |
|
|
|
|
$dhcpstart = ip2long($subnet->dhcp_start); |
|
|
|
|
$dhcpend = ip2long($subnet->dhcp_end); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// loop subnet-array and send to template |
|
|
|
@ -300,7 +282,7 @@ foreach ($subnetdata AS $node_ip => $node) { |
|
|
|
|
if ($dhcpstart > 0) { |
|
|
|
|
$ipval = ip2long($node_ip); |
|
|
|
|
if (($ipval >= $dhcpstart) and ($ipval <= $dhcpend)) { |
|
|
|
|
$subnet[$node_ip]["dynamic"] = true; |
|
|
|
|
$subnetdata[$node_ip]["dynamic"] = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|