|
|
|
@ -7,51 +7,49 @@ Copyright (C) 2011-2023 Thomas Hooge |
|
|
|
|
SPDX-License-Identifier: GPL-3.0-or-later |
|
|
|
|
*****************************************************************************/ |
|
|
|
|
|
|
|
|
|
// strip mac address to 12 char string |
|
|
|
|
function strip_mac($mac) { |
|
|
|
|
function strip_mac($mac, $caps=true) { |
|
|
|
|
// strip mac address to 12 char string |
|
|
|
|
// strip chars we don't need |
|
|
|
|
$mac = preg_replace("|[^a-fA-F0-9]|", "", $mac); |
|
|
|
|
|
|
|
|
|
// capitalize (just because it looks better eh) |
|
|
|
|
$mac = strtoupper($mac); |
|
|
|
|
|
|
|
|
|
// and return |
|
|
|
|
return ($mac); |
|
|
|
|
$mac = preg_replace('/[^a-fA-F0-9]/', '', $mac); |
|
|
|
|
if ($caps) { |
|
|
|
|
$mac = strtoupper($mac); |
|
|
|
|
} else { |
|
|
|
|
$mac = strtolower($mac); |
|
|
|
|
} |
|
|
|
|
return $mac; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// rebuild mac address |
|
|
|
|
function write_mac($mac) { |
|
|
|
|
// check string length |
|
|
|
|
if (strlen($mac)!=12) { |
|
|
|
|
function write_mac($mac, $user_mac='xx:xx:xx:xx:xx:xx') { |
|
|
|
|
// rebuild mac address using user supplied format |
|
|
|
|
|
|
|
|
|
if (strlen($mac) != 12) { |
|
|
|
|
// if the MAC is empty, or for whatever reason incorrect, just return |
|
|
|
|
return $mac; |
|
|
|
|
} else { |
|
|
|
|
// count to 12... |
|
|
|
|
for ($i=0; $i<12; $i++) { |
|
|
|
|
// ... and strip mac to pieces |
|
|
|
|
${"mac".$i} = $mac{$i}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// get user preference |
|
|
|
|
$user_mac = $_SESSION['suser_mac']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// count to 12 again... |
|
|
|
|
for($i=0; $i<12; $i++) { |
|
|
|
|
// ... and replace user preference with pieces |
|
|
|
|
$user_mac = preg_replace("/x/", ${"mac".$i}, $user_mac, 1); |
|
|
|
|
} |
|
|
|
|
// check format of user mac: count upper or lower char |
|
|
|
|
$chars = count_chars($user_mac, 1); |
|
|
|
|
if (array_key_exists(88, $chars) and $chars[88] == 12) { |
|
|
|
|
$pattern = '/X/'; |
|
|
|
|
$mac = strtoupper($mac); |
|
|
|
|
} elseif (array_key_exists(120, $chars) and $chars[120] == 12) { |
|
|
|
|
$pattern = '/x/'; |
|
|
|
|
$mac = strtolower($mac); |
|
|
|
|
} else { |
|
|
|
|
// invalid format |
|
|
|
|
return $mac; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// and return |
|
|
|
|
return $user_mac; |
|
|
|
|
for($i=0; $i<12; $i++) { |
|
|
|
|
$user_mac = preg_replace($pattern, $mac[$i], $user_mac, 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $user_mac; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// redirect page |
|
|
|
|
function header_location($location) { |
|
|
|
|
// send header |
|
|
|
|
header("location: " . $location); |
|
|
|
|
|
|
|
|
|
// exit to be sure |
|
|
|
|
// redirect page |
|
|
|
|
header('location:' . $location); |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -78,14 +76,6 @@ function sanitize($input) { |
|
|
|
|
return $input; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function mysql_nullstring($input) { |
|
|
|
|
if (isset($input)) { |
|
|
|
|
return $input; |
|
|
|
|
} else { |
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function lang_getfrombrowser ($allowed_languages, $default_language, $lang_variable = null, $strict_mode = true) { |
|
|
|
|
if ($lang_variable === null) { |
|
|
|
|
$lang_variable = $_SERVER['HTTP_ACCEPT_LANGUAGE']; |
|
|
|
@ -138,7 +128,6 @@ function print_tree_rec($tree, $level) { |
|
|
|
|
return $output; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//function print_tree($params, &$smarty) { |
|
|
|
|
function print_tree($params, Smarty_Internal_Template $template) { |
|
|
|
|
if (empty($params['level'])) { |
|
|
|
|
$level = 0; |
|
|
|
@ -152,12 +141,9 @@ function print_tree($params, Smarty_Internal_Template $template) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function msgout(array $parameters, Smarty_Internal_Template $smarty) |
|
|
|
|
{ |
|
|
|
|
function msgout(array $parameters, Smarty_Internal_Template $smarty) { |
|
|
|
|
// This is just a quick hack around missing {php} in Smarty3 |
|
|
|
|
$GLOBALS['g_error']->PrintOut(); |
|
|
|
|
$GLOBALS['g_warning']->PrintOut(); |
|
|
|
|
$GLOBALS['g_message']->PrintOut(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
?> |
|
|
|
|