forked from mkucej/i-librarian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjqueryFileTree.php
30 lines (25 loc) · 902 Bytes
/
jqueryFileTree.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
<?php
/*
* No directory browsing is allowed in hosted version.
*/
if ($hosted === true) {
exit;
}
$_POST['dir'] = urldecode($_POST['dir']);
$_POST['dir'] = str_replace("\\", "/", $_POST['dir']);
if (file_exists($_POST['dir']) && is_readable($_POST['dir'])) {
$files = scandir($_POST['dir']);
if (count($files) > 2) { /* The 2 accounts for . and .. */
echo '<ul class="jqueryFileTree" style="display: none">';
// All dirs
foreach ($files as $file) {
if ($file != '.' && $file != '..' && is_dir($_POST['dir'] . $file) && $file[0] != '.') {
echo '<li class="directory collapsed"><a href="#" rel="'
. htmlentities($_POST['dir'] . $file) . '/"><span class="fa fa-folder" style="padding-top: 2px"></span> '
. htmlentities($file) . '</a></li>';
}
}
echo "</ul>";
}
}
?>