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.
48 lines
1.6 KiB
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 INET_ATON(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(' ',$level) . '<a href="locationview.php?location_id=' . $row->location_id . '">' . $row->location_name . '</a></td><td> </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");
|
|
?>
|