-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
59 lines (55 loc) · 1.49 KB
/
functions.php
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
<?php
/**
* Celestial Body.
*
* @link <https://github.com/Celestial-Body/Betelgeuse> Github repository.
* @license <https://github.com/Celestial-Body/Betelgeuse/blob/master/LICENSE> GPL-3.0 License.
*/
if (!function_exists('depth')) {
function depth($input)
{
if (!canVarLoop($input)) {
return (int) "0";
}
$arrayiter = new RecursiveArrayIterator($input);
$iteriter = new RecursiveIteratorIterator($arrayiter);
foreach ($iteriter as $value) {
$d = $iteriter->getDepth() + 1;
$result[] = "$d";
}
return (int) max($result);
}
}
if (!function_exists('canVarLoop')) {
function canVarLoop($input)
{
return (bool) (is_array($input) || $input instanceof Traversable) ? true : false;
}
}
if (!function_exists('isArrayMulti')) {
function isArrayMulti($array)
{
foreach ($array as $val) {
if (is_array($val)) {
return (bool) true;
}
}
return (bool) false;
}
}
if (!function_exists('checkdnsrr')) {
function checkdnsrr($arg, $record = 'MX')
{
if (!empty($arg) && !empty($record)) {
$record = escapeshellarg($record);
$arg = escapeshellarg($arg);
exec("nslookup -type=$record $host", $res);
foreach ($res as $val) {
if (stristr($val, $host)) {
return true;
}
}
}
return false;
}
}