-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlistdir.php
30 lines (28 loc) · 858 Bytes
/
listdir.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
function debug( $chaine ) {
echo "<b>Debug:</b> " . htmlentities($chaine) . "<br />\n";
}
$req_uri = $_SERVER['SCRIPT_NAME'];
$req_path = $_REQUEST['dir'];
//if ($req_path[strlen($req_path)-1] != "/") {
// $req_path .= "/";
//}
$cur_path = dirname($_SERVER['SCRIPT_FILENAME']);
$abs_path = realpath($cur_path . "/" . $req_path);
// debug("req_path=".$req_path);
// debug("cur_path=".$cur_path);
// debug("abs_path=".$abs_path);
$files = " ";
if ($handle = opendir($abs_path)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$ext = substr(strrchr($file, "."), 1);
//if ($ext == "wav" || $ext == "mp3") {
$files .= '"'.$file.'",';
//}
}
}
closedir($handle);
}
echo('({"Files":["(aucun)",'.substr($files,0,-1).']})');
?>