-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
44 lines (35 loc) · 956 Bytes
/
index.php
File metadata and controls
44 lines (35 loc) · 956 Bytes
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
<?php
$path = getenv('PATH');
$path_arr = explode(PATH_SEPARATOR, $path);
// print_r($path_arr);
$path_arr = array_unique(trim_path_array($path_arr));
/* Ignore some paths */
$ignore = json_decode(file_get_contents('ignore.json'), true);
$arr = array();
foreach($path_arr as $line) {
if(!in_array($line, $ignore['ignore'])) {
$arr[] = $line;
}
}
$path_arr = $arr;
//file_put_contents('ignore.json', json_encode(array('ignore' => $path_arr) ));
$command_arr = array();
foreach($path_arr as $path) {
$files = glob($path . DIRECTORY_SEPARATOR . '{*.exe,*.bat,*.cmd,*.sh,*.php}', GLOB_BRACE);
$command_arr = array_merge($command_arr, $files);
}
print_r($command_arr);
print_r($path_arr);
function trim_path_array($arr) {
if (!is_array($arr)) {
return $arr;
}
while (list($key, $value) = each($arr)) {
if (is_array($value)) {
$arr[$key] = trim_path_array($value);
} else {
$arr[$key] = rtrim($value, '\\/ ');
}
}
return $arr;
}