. For more information, visit http://sourceforge.net/projects/ipreg, or contact me at wietsew@users.sourceforge.net *****************************************************************************/ // start page // includes include("includes.php"); // get id $location_id = sanitize($_GET['location_id']); // start output include("header.php"); // set template $tp = new Template("tpl/locationview.tpl", $config_yapter_error); // set language variables $tp->setvars($lang); // start locationcrumb // get locations // build query $query = "SELECT location.location_id AS location_id, location.location_name AS location_name, location.location_parent AS location_parent FROM location"; // run query $locations = $db->db_select($query); // count results $location_counter = count($locations); // counter to tpl $tp->set("location_counter", $location_counter); // any loactions? if ($location_counter>0) { // get objects foreach($locations AS $location) { // create arrays $location_names[$location['location_id']] = $location['location_name']; $parents[$location['location_id']] = $location['location_parent']; } } // build parents array // function to build array with parents for this location 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); // to tpl // loop in reverse order foreach (array_reverse($crumbs) as $key=>$val) { // send vars to template $tp->set("location_id", $val); $tp->set("location_name", $location_names[$val]); // include seperator? if (($key>0) ? $tp->set("seperator", ". ") : $tp->set("seperator", "")); // parse block $tp->parse("locationcrumb_row"); } // parse block $tp->parse("locationcrumb_table"); // setup location // build query $query = "SELECT location.location_info AS location_info FROM location WHERE location.location_id=" . $location_id; // run query $location = $db->db_select($query); // send to tpl $tp->set("location_id", $location_id); $tp->set("location_info", nl2br($location[0]['location_info'])); // setup sublocations // build query $query = "SELECT location.location_id AS sublocation_id, location.location_name AS sublocation_name FROM location WHERE location.location_parent=" . $location_id . " ORDER BY location.location_name"; // run query $sublocations = $db->db_select($query); // count results $sublocation_counter = count($sublocations); // counter to tpl $tp->set("sublocation_counter", $sublocation_counter); // any nodes? if ($sublocation_counter>0) { // get objects foreach($sublocations AS $sublocation) { // send to tpl $tp->set("sublocation_id", $sublocation['sublocation_id']); $tp->set("sublocation_name", $sublocation['sublocation_name']); // parse row $tp->parse("sublocation_row"); } // parse block $tp->parse("sublocation_table"); } else { // hide block $tp->hide("sublocation_table"); } // setup subnets // build query $query = "SELECT subnet.subnet_id AS subnet_id, subnet.subnet_address AS subnet_address, subnet.subnet_mask AS subnet_mask FROM subnet, subnetlocation WHERE subnetlocation.location_id=" . $location_id . " AND subnetlocation.subnet_id=subnet.subnet_id ORDER BY INET_ATON(subnet.subnet_address)"; // run query $subnets = $db->db_select($query); // count results $subnet_counter = count($subnets); // counter to tpl $tp->set("subnet_counter", $subnet_counter); // any nodes? if ($subnet_counter>0) { // get objects foreach($subnets AS $subnet) { // send to tpl $tp->set("subnet_id", $subnet['subnet_id']); $tp->set("subnet_address", $subnet['subnet_address']); $tp->set("subnet_mask", $subnet['subnet_mask']); // parse row $tp->parse("subnet_row"); } // parse block $tp->parse("subnet_table"); } else { // hide block $tp->hide("subnet_table"); } // end page // output $tp->parse(); $tp->spit(); // footer include("footer.php"); ?>