forked from LafeLabs/trashbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dir.php
47 lines (40 loc) · 1.2 KB
/
dir.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
<?php
// list files and or directories in a directory
if(isset($_GET["filename"])){
$filename = $_GET["filename"];//
$files = scandir(getcwd()."/".$filename);
}
else{
$files = scandir(getcwd());
}
if(isset($_GET["type"])){
if($_GET["type"] == "dir"){
$dirs = [];
foreach($files as $value){
if($value[0] != "." && is_dir($value) && $value != "php" && $value != "jscode" && $value != "data" && $value != "html" && $value != "symbols" && $value != "fonts" && $value != "icons" && $value != "iconsymbols" && $value != "uploadimages" && $value != "symbol" && $value != "symbolfeed" && $value != "maps" && $value != "scrolls"){
array_push($dirs,$value);
}
}
echo json_encode($dirs);
}
else{
$ending = $_GET["type"];
$namelist = [];
foreach($files as $value){
if(substr($value,-strlen($ending)) == $ending){
array_push($namelist,$value);
}
}
echo json_encode($namelist);
}
}
else{
$dirs = [];
foreach($files as $value){
if($value[0] != "."){
array_push($dirs,$value);
}
}
echo json_encode($dirs);
}
?>