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.
104 lines
3.3 KiB
104 lines
3.3 KiB
<?php
|
|
include("header.php");
|
|
|
|
// get id
|
|
$location_id = $_GET['location_id'];
|
|
|
|
// set template
|
|
$tp = new Template("tpl/locationview.tpl");
|
|
|
|
// set language variables
|
|
$tp->setvars($lang);
|
|
|
|
// create breadcrumb arrays
|
|
$parents = array();
|
|
$location_names = array();
|
|
$crumbs = array();
|
|
|
|
// get location information and insert to the arrays
|
|
$result = mysql_query("SELECT location_id, location_name, parent FROM location") or die(mysql_error());
|
|
while ($row = mysql_fetch_object($result)) {
|
|
$location_names[$row->location_id] = $row->location_name;
|
|
$parents[$row->location_id] = $row->parent;
|
|
}
|
|
|
|
// function to build array with parents
|
|
function parent($location_id) {
|
|
// use names index
|
|
global $parents;
|
|
global $crumbs;
|
|
global $location_names;
|
|
|
|
// fill array with this value
|
|
$crumbs[$location_id] = $location_id;
|
|
if (($parents[$location_id])>0) {
|
|
// still not on top, so do it again
|
|
parent($parents[$location_id]);
|
|
}
|
|
|
|
// return the array
|
|
return $location_id;
|
|
}
|
|
|
|
// build parents
|
|
parent($location_id);
|
|
|
|
// loop array in reverse order and send to template
|
|
foreach (array_reverse($crumbs) as $key=>$val) {
|
|
$tp->set("location_id", $val);
|
|
$tp->set("location_name", $location_names[$val]);
|
|
if (($key>0) ? $tp->set("seperator", ". ") : $tp->set("seperator", ""));
|
|
$tp->parse("locationcrumbrow");
|
|
}
|
|
$tp->parse("locationcrumb");
|
|
|
|
// get location info
|
|
$result = mysql_query("SELECT location_name, location_info FROM location WHERE location_id='$location_id'");
|
|
$row=mysql_fetch_object($result);
|
|
$tp->set("location_info", nl2br($row->location_info));
|
|
|
|
// search subnets for this location
|
|
$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'") or die(mysql_error());
|
|
for ($i=0;$row=mysql_fetch_object($result);$i++) {
|
|
$tp->set("subnet_id", $row->subnet_id);
|
|
$tp->set("subnet_address", $row->subnet_address);
|
|
$tp->set("subnet_mask", $row->subnet_mask);
|
|
$tp->parse("subnetrow");
|
|
}
|
|
if (($i>0) ? $tp->parse("subnet") : $tp->hide("subnet"));
|
|
|
|
// search sub-locations for this location
|
|
$result = mysql_query("SELECT location_id, location_name FROM location WHERE parent='$location_id' ORDER BY location_name") or die(mysql_error());
|
|
for ($i=0;$row=mysql_fetch_object($result);$i++) {
|
|
$tp->set("sublocation_id", $row->location_id);
|
|
$tp->set("sublocation_name", $row->location_name);
|
|
$tp->parse("sublocationrow");
|
|
}
|
|
if (($i>0) ? $tp->parse("sublocation") : $tp->hide("sublocation"));
|
|
|
|
// display options
|
|
if($_SESSION['suser_level'] >= $config_userlevel_assignlocationtosubnet) {
|
|
$tp->set("location_id", $location_id);
|
|
$tp->parse("assignlocationtosubnet");
|
|
} else {
|
|
$tp->hide("assignlocationtosubnet");
|
|
}
|
|
if($_SESSION['suser_level'] >= $config_userlevel_locationedit) {
|
|
$tp->set("location_id", $location_id);
|
|
$tp->parse("locationedit");
|
|
} else {
|
|
$tp->hide("locationedit");
|
|
}
|
|
if($_SESSION['suser_level'] >= $config_userlevel_locationdel) {
|
|
$tp->set("location_id", $location_id);
|
|
$tp->parse("locationdel");
|
|
} else {
|
|
$tp->hide("locationdel");
|
|
}
|
|
|
|
// output
|
|
$tp->parse();
|
|
$tp->spit();
|
|
|
|
include("footer.php");
|
|
?>
|