You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
229 lines
6.6 KiB
229 lines
6.6 KiB
2 years ago
|
<?php
|
||
|
include("header.php");
|
||
|
|
||
|
// get page
|
||
|
if(isset($_GET['page'])) {
|
||
|
$page = $_GET['page'];
|
||
|
} else {
|
||
|
$page = 0;
|
||
|
}
|
||
|
?>
|
||
|
|
||
|
<script language="javascript">
|
||
|
function linkTo(optVal){
|
||
|
if(optVal=="")
|
||
|
return false;
|
||
|
window.location='subnetview.php?subnet_id='+optVal;
|
||
|
}
|
||
|
</script>
|
||
|
<script type="text/javascript">
|
||
|
function change(id,newtext) {
|
||
|
document.getElementById(id).innerHTML=newtext
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<?php
|
||
|
// get all info
|
||
|
$result = mysql_query("SELECT subnet_address, subnet_mask, vlan_id, subnet_info FROM subnet WHERE subnet_id='$subnet_id'");
|
||
|
while ($row = mysql_fetch_object($result)) {
|
||
|
$subnet_address = $row->subnet_address;
|
||
|
$subnet_mask = $row->subnet_mask;
|
||
|
$vlan_id = $row->vlan_id;
|
||
|
$subnet_info = $row->subnet_info;
|
||
|
}
|
||
|
|
||
|
// determine current range
|
||
|
$iprange = explode('.', $subnet_address);
|
||
|
$iprange1 = $iprange[0];
|
||
|
$iprange2 = $iprange[1];
|
||
|
$iprange3 = $iprange[2];
|
||
|
$iprange4 = $iprange[3];
|
||
|
|
||
|
// calculate no. of hosts
|
||
|
$hostcount = pow(2,(32-$subnet_mask));
|
||
|
|
||
|
// is there a need for pagination?
|
||
|
if ($hostcount>256) {
|
||
|
$maxdisplayedip = 256;
|
||
|
|
||
|
// calculate broadcast address and create pagination
|
||
|
if ($hostcount>65536) {
|
||
|
// class A subnet
|
||
|
echo 'Class A subnets (>65536 nodes) are not supported';
|
||
|
exit;
|
||
|
} else {
|
||
|
// class B subnet
|
||
|
$broadcast_address = $iprange1 . '.' . $iprange2 . '.' . ($hostcount/256-1) . '.255';
|
||
|
|
||
|
$pagination = 'Page: <select name="pagination" onchange="linkTo(this.options[this.selectedIndex].value);">';
|
||
|
for ($i=0;$i<($hostcount/256);$i++) {
|
||
|
if ($i==$page) {
|
||
|
$selected = ' selected';
|
||
|
} else {
|
||
|
$selected = '';
|
||
|
}
|
||
|
$pagination .= '<option value="' . $subnet_id . '&page=' . $i . '"' . $selected . '>' . $iprange1 . '.' . $iprange2 . '.' . ($i) . '.0</option>';
|
||
|
}
|
||
|
$pagination .= '</select>';
|
||
|
}
|
||
|
} else {
|
||
|
// // class C subnet so no pagination needed, set static variables
|
||
|
$pagination = ' ';
|
||
|
$page = 0;
|
||
|
$maxdisplayedip = $hostcount;
|
||
|
$broadcast_address = $iprange1 . '.' . $iprange2 . '.' . $iprange3 . '.' . ($iprange4+$hostcount-1);
|
||
|
}
|
||
|
?>
|
||
|
|
||
|
<table border="0">
|
||
|
<tr>
|
||
|
<td colspan="32">
|
||
|
<b>Subnet: </b><?php echo $subnet_address . '/'. $subnet_mask; ?>
|
||
|
</td>
|
||
|
<td colspan="32" align="right">
|
||
|
<?php echo $pagination; ?>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<?php
|
||
|
echo '<tr>';
|
||
|
|
||
|
for ($i=1;$i<=$maxdisplayedip;$i++) {
|
||
|
// build current ip
|
||
|
$ip = $iprange1 . '.' . $iprange2 . '.' . ($iprange3+$page) . '.' . ($i+$iprange4-1);
|
||
|
|
||
|
// disable subnet_address and broadcast_address
|
||
|
if ($ip==$subnet_address) {
|
||
|
echo '<td><img src="images/cross.jpg" onMouseOver="change(\'remotetext\',\'' . $ip . ' (Subnet address)\')" onMouseOut="change(\'remotetext\',\' \')"></td>';
|
||
|
} else if ($ip==$broadcast_address) {
|
||
|
echo '<td><img src="images/cross.jpg" onMouseOver="change(\'remotetext\',\'' . $ip . ' (Broadcast address)\')" onMouseOut="change(\'remotetext\',\' \')"></td>';
|
||
|
} else {
|
||
|
// check for current ip address
|
||
|
$result = mysql_query("SELECT a.asset_name, acg.color, n.node_id FROM asset a, assetclass ac, assetclassgroup acg, node n WHERE n.ip='$ip' AND a.asset_id=n.asset_id AND ac.assetclass_id=a.assetclass_id AND acg.assetclassgroup_id=ac.assetclassgroup_id");
|
||
|
if (mysql_num_rows($result)==0) {
|
||
|
// ip not in use
|
||
|
echo '<td><a href="assigniptonode.php?ip='. $ip . '&subnet_id=' . $subnet_id . '"><img src="images/grey.jpg" border="0" onMouseOver="change(\'remotetext\',\'' . $ip . '\')" onMouseOut="change(\'remotetext\',\' \')"></a></td>';
|
||
|
} else {
|
||
|
// ip in use
|
||
|
while ($row = mysql_fetch_object($result)) {
|
||
|
$node_id = $row->node_id;
|
||
|
echo '<td><a href="nodeview.php?node_id=' . $node_id . '"><img src="images/' . $row->color . '.jpg" border="0" onMouseOver="change(\'remotetext\',\'' . $ip . ' ' . $row->asset_name . '\')" onMouseOut="change(\'remotetext\',\' \')"></a></td>';
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ($i%64==0) {
|
||
|
echo '</tr><tr>';
|
||
|
}
|
||
|
}
|
||
|
?>
|
||
|
<tr>
|
||
|
<td colspan="64">
|
||
|
<a id="remotetext"> </a>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<table border="0">
|
||
|
<tr>
|
||
|
<td>
|
||
|
<table border="0">
|
||
|
<tr>
|
||
|
<td>
|
||
|
<b>VLAN(s):</b>
|
||
|
</td>
|
||
|
<td>
|
||
|
|
||
|
<?php
|
||
|
// search vlan(s) for this subnet
|
||
|
$result = mysql_query("SELECT vlan_id, vlan_number, vlan_name FROM vlan WHERE vlan_id='$vlan_id'");
|
||
|
while ($row = mysql_fetch_object($result)) {
|
||
|
echo '<a href="vlanview.php?vlan_id=' . $row->vlan_id . '">' . $row->vlan_name . ' ('. $row->vlan_number . ')</a>';
|
||
|
}
|
||
|
?>
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>
|
||
|
<b>Location(s):</b>
|
||
|
</td>
|
||
|
<td>
|
||
|
|
||
|
<?php
|
||
|
// search location(s) for this subnet
|
||
|
$result = mysql_query("SELECT l.location_id FROM location l INNER JOIN subnetlocation sl ON l.location_id=sl.location_id WHERE sl.subnet_id='$subnet_id'");
|
||
|
while ($row = mysql_fetch_object($result)) {
|
||
|
echo location_name($row->location_id, '') . '<br>';
|
||
|
}
|
||
|
?>
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>
|
||
|
<b>Subnet info:</b>
|
||
|
</td>
|
||
|
<td>
|
||
|
<?php echo nl2br($subnet_info); ?>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</td>
|
||
|
<td width="100">
|
||
|
|
||
|
</td>
|
||
|
<td>
|
||
|
<table border="0">
|
||
|
<tr>
|
||
|
<td>
|
||
|
<img src="images/grey.jpg"> Unassigned
|
||
|
</td>
|
||
|
</tr>
|
||
|
</tr>
|
||
|
<?php
|
||
|
// display assetclass(es)
|
||
|
$result = mysql_query("SELECT assetclassgroup_id, assetclassgroup_name, color FROM assetclassgroup ORDER BY assetclassgroup_id");
|
||
|
while ($row = mysql_fetch_object($result)) {
|
||
|
echo '<tr><td><img src="images/' . $row->color . '.jpg"> <a href="assetclassgroupview.php?assetclassgroup_id=' . $row->assetclassgroup_id . '">' . $row->assetclassgroup_name . '</a></td></tr>';
|
||
|
}
|
||
|
?>
|
||
|
</table>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<p>
|
||
|
|
||
|
<?php
|
||
|
// display only if admin
|
||
|
if($_SESSION['suser_level'] >= 2) {
|
||
|
?>
|
||
|
|
||
|
<table border="0">
|
||
|
<tr>
|
||
|
<td>
|
||
|
<img src="images/arrow.gif" border="0"><a href="subnetedit.php?subnet_id=<?php echo $subnet_id; ?>">Modify subnet</a>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>
|
||
|
<img src="images/arrow.gif" border="0"><a href="assignsubnettolocation.php?subnet_id=<?php echo $subnet_id; ?>">Assign location</a>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<?php
|
||
|
// end display only if admin
|
||
|
}
|
||
|
?>
|
||
|
|
||
|
<tr>
|
||
|
<td>
|
||
|
<img src="images/arrow.gif" border="0"><a href="nodelist.php?subnet_id=<?php echo $subnet_id; ?>">View assigned IP addresses in subnet</a>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<?php
|
||
|
include("footer.php");
|
||
|
?>
|