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