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.
112 lines
3.8 KiB
112 lines
3.8 KiB
<?php
|
|
/*****************************************************************************
|
|
IP Reg, a PHP/MySQL IPAM tool
|
|
Copyright (C) 2008 Wietse Warendorff
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
For more information, visit http://sourceforge.net/projects/ipreg,
|
|
or contact me at wietsew@users.sourceforge.net
|
|
*****************************************************************************/
|
|
|
|
// includes
|
|
include("includes.php");
|
|
|
|
// get id
|
|
$location_id = $_GET['location_id'];
|
|
|
|
// check authorisation
|
|
$auth = auth("location", $config_auth_locationview, $location_id);
|
|
|
|
// start output
|
|
include("header.php");
|
|
|
|
// 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"));
|
|
|
|
// output
|
|
$tp->parse();
|
|
$tp->spit();
|
|
|
|
include("footer.php");
|
|
?>
|