-
Notifications
You must be signed in to change notification settings - Fork 6
/
tool-load-dir.php
94 lines (91 loc) · 1.95 KB
/
tool-load-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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
include_once dirname(__FILE__)."/functions.php";
include_once dirname(__FILE__)."/auth.php";
include dirname(__FILE__)."/conf.php";
if($cfg->authentification_needed && !$userlogin)
{
exit();
}
$rooturl = $cfg->rootdir;
$seldir = kh_filter_input(INPUT_GET, 'dir', FILTER_SANITIZE_STRING);
$dir2 = path_decode(kh_filter_input(INPUT_GET, 'seldir'), $cfg->rootdir);
if(!is_dir($dir2)){
$dir2 = path_decode('', $cfg->rootdir);
}
$arrdir = array();
if(file_exists($dir2))
{
if ($handle = opendir($dir2))
{
$i=0;
while (false !== ($ufile = readdir($handle)))
{
$fn = "$dir2/$ufile";
if($ufile == "." || $ufile == ".." )
{
continue;
}
try
{
$filetype = filetype($fn);
unset($obj);
if($filetype == "dir")
{
$obj['path'] = path_encode($fn, $cfg->rootdir);
$obj['location'] = path_encode(dirname($fn), $cfg->rootdir);
$obj['name'] = basename($fn);
$arrdir[] = $obj;
}
}
catch(Exception $e)
{
try
{
unset($obj);
if(is_dir($fn))
{
$obj['path'] = path_encode($fn, $cfg->rootdir);
$obj['location'] = path_encode(dirname($fn), $cfg->rootdir);
$obj['name'] = basename($fn);
$arrdir[] = $obj;
}
}
catch(Exception $e)
{
}
}
}
}
}
$_order = array();
foreach ($arrdir as &$row){
$_order[] = &$row['name'];
}
array_multisort($_order, SORT_ASC, SORT_STRING, $arrdir);
if(count($arrdir))
{
?>
<ul>
<?php
foreach($arrdir as $k=>$val)
{
?>
<li class="row-data-dir dir-control" data-file-name="<?php echo $val['name'];?>" data-file-location="<?php echo $val['location'];?>" data-file-path="<?php echo str_replace("'", "\'", $val['path']);?>"><a href="javascript:;" onClick="return openDir('<?php echo str_replace("'", "\'", $val['path']);?>')"><?php echo $val['name'];?></a>
<?php
if($val['location']){
if(stripos($seldir, $val['path']) !== false)
{
// recursive
// list dir tree
echo builddirtree($seldir);
}
}
?>
</li>
<?php
}
?>
</ul>
<?php
}
?>