Make use of Yapter Template Engine

This commit is contained in:
2023-02-13 09:31:40 +01:00
parent 7322231d3e
commit 8d00ee5e1b
100 changed files with 4804 additions and 2666 deletions

View File

@@ -13,17 +13,26 @@
// rebuild mac address
function write_mac($mac) {
// check for invalid mac
if (strlen($mac)!=12) {
// if the MAC is empty, or for whatever reason incorrect, just return
return $mac;
} else {
} else {
// length is good, continue
$mac1 = substr($mac, 0, 2);
$mac2 = substr($mac, 2, 2);
$mac3 = substr($mac, 4, 2);
$mac4 = substr($mac, 6, 2);
$mac5 = substr($mac, 8, 2);
$mac6 = substr($mac, 10, 2);
$mac = $mac1 . '-' . $mac2 . '-' . $mac3 . '-' . $mac4 . '-' . $mac5 . '-' . $mac6;
// check session for preference (if 0, do nothing), if changed: update useredit.php too!
if ($_SESSION['suser_mac']==1) {
$mac = $mac1 . '-' . $mac2 . '-' . $mac3 . '-' . $mac4 . '-' . $mac5 . '-' . $mac6;
} else if ($_SESSION['suser_mac']==2) {
$mac = $mac1 . ':' . $mac2 . ':' . $mac3 . ':' . $mac4 . ':' . $mac5 . ':' . $mac6;
} else if ($_SESSION['suser_mac']==3) {
$mac = $mac1 . $mac2 . $mac3 . '-' . $mac4 . $mac5 . $mac6;
}
return $mac;
}
@@ -31,39 +40,7 @@
// redirect page
function header_location($location) {
return header("location: " . $location);
header("location: " . $location);
exit;
}
// get location name and that of its parents and return with links to the locations
function location_name($location_id, $seperator) {
// create an array
$location_name = array();
// get location name(s)
$result = mysql_query("SELECT location_name, parent FROM location WHERE location_id='$location_id'");
while ($row = mysql_fetch_object($result)) {
// put this parent before any children
array_unshift($location_name, $row->location_name);
// repeat
location_name($row->parent, '.');
}
// count total no. of found locations
$location_count = count($location_name);
// display location for every array value
for ($i = 0; $i < $location_count; $i++ ) {
echo '<a href="locationview.php?location_id=' . $location_id . '">' . $location_name[$i] . '</a>' . $seperator;
}
}
// calculate page for pagination (pagination is used in subnetview.php)
function page($ip) {
$iprange = explode('.', $ip);
$iprange3 = $iprange[2];
return $iprange3;
}
?>