-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathfunctions.php
More file actions
64 lines (60 loc) · 1.51 KB
/
Copy pathfunctions.php
File metadata and controls
64 lines (60 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
function hextostr($hex)
{
$str = '';
for ($i = 0; $i < strlen($hex) - 1; $i += 2)
{
if ($hex[$i] . $hex[$i+1] != '00') $str .= chr(hexdec($hex[$i] . $hex[$i+1]));
}
return $str;
}
function strtohex($str)
{
$hex = '';
for ($i = 0; $i < strlen($str); $i++)
{
$hex .= dechex(ord($str[$i]));
}
return $hex;
}
function stripstr($str)
{
$str = str_ireplace('Hex: ', '', $str);
$str = str_ireplace(' ', '', $str);
$str = str_ireplace('"', '', $str);
$str = str_ireplace(chr(10), '', $str);
$str = str_ireplace(chr(13), '', $str);
$str = substr($str, 0, 8);
return $str;
}
function keyscut($arr)
{
$new_arr = array();
reset($arr);
for ($i = 0; $i < count($arr); $i++)
{
$val = $arr[key($arr)];
$key = key($arr);
$key = substr(strrchr($key, '.'), 1);
$new_arr[$key] = $val;
next($arr);
}
return $new_arr;
}
function keyscutvlanmac($arr)
{
$new_arr = array();
reset($arr);
for ($i = 0; $i < count($arr); $i++)
{
$val = $arr[key($arr)];
$key = key($arr);
$arrkey = explode('.', $key);
$arrkey = array_reverse($arrkey);
$key = $arrkey[6] . '.' . $arrkey[5] . '.' . $arrkey[4] . '.' . $arrkey[3] . '.' . $arrkey[2] . '.' . $arrkey[1] . '.' . $arrkey[0];
$new_arr[$key] = $val;
next($arr);
}
return $new_arr;
}
?>