IP Reg is a IPAM tool to keep track of assets, nodes (IP addresses, MAC addresses, DNS aliases) within different subnets, over different locations or even VLAN's. Written in PHP, used with a MySQL-database to have a unique insight in your local network.
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
ipreg/location.php

48 lines
1.6 KiB

<?php
include("header.php");
function display_subnet ($location_id) {
$subnet = '';
$result = mysql_query("SELECT s.subnet_id, s.subnet_address, s.subnet_mask FROM subnet s INNER JOIN subnetlocation sl ON s.subnet_id=sl.subnet_id WHERE sl.location_id='$location_id' ORDER BY subnet_address");
while ($row = mysql_fetch_object($result)) {
$subnet .= '<a href="subnetview.php?subnet_id='. $row->subnet_id . '">' . $row->subnet_address . '/' . $row->subnet_mask . '</a><br>';
}
return $subnet;
}
// displaysubnet link (or not)
if (isset($_GET['displaysubnet'])) {
$displaysubnetlink = '<a href="location.php">(hide subnets)</a>';
} else {
$displaysubnetlink = '<a href="location.php?displaysubnet">(display subnets)</a>';
}
// "menu"
function display_children($parent, $level) {
$result = mysql_query("SELECT location_id, location_name FROM location WHERE parent='$parent' ORDER BY location_name");
while ($row = mysql_fetch_object($result)) {
if (isset($_GET['displaysubnet'])) {
$displaysubnet = display_subnet($row->location_id);
} else {
$displaysubnet = '';
}
echo '<tr><td>' . str_repeat('&nbsp;&nbsp;&nbsp;',$level) . '<a href="locationview.php?location_id=' . $row->location_id . '">' . $row->location_name . '</a></td><td>&nbsp;</td><td>' . $displaysubnet . '</td></tr>';
display_children($row->location_id, $level+1);
}
}
?>
<table border="0">
<tr>
<td>
<b>Location:</b> <?php echo $displaysubnetlink; ?>
</td>
</tr>
<?php display_children('',0); ?>
</table>
<?php
include("footer.php");
?>