// Check inputs from web/flash
if (!isset($_GET['dir'])) {
$dir = opendir(".");
} else {
$dir = opendir($_GET['dir']);
}
if (!isset($_GET['ext'])) {
$ext = 'png';
} else {
$ext = $_GET['ext'];
}
// get each entry
while($entryName = readdir($dir)) {
$dirArray[] = $entryName;
}
// close directory
closedir($dir);
// count elements in array
$indexCount = count($dirArray);
// Print ("$indexCount files
\n");
// sort 'em
sort($dirArray);
/*
// print 'em
print("
\n");
print("Filename | Filetype | Filesize |
\n");
// loop through the array of files and print them all
for($index=0; $index < $indexCount; $index++) {
if (substr("$dirArray[$index]", 0, 1) != "."){ // don't list hidden files
$info = pathinfo($dirArray[$index]);
if ($info['extension'] == $ext) {
print("$dirArray[$index] | ");
print("");
// show the extension
print($info['extension']);
print(" | ");
print("");
print(filesize($dirArray[$index]));
print(" | ");
print("
\n");
}
}
}
*/
$filestring = '';
for($index=0; $index < $indexCount; $index++) {
if (substr("$dirArray[$index]", 0, 1) != "."){ // don't list hidden files
$info = pathinfo($dirArray[$index]);
if ($info['extension'] == $ext) {
if ($filestring == '') {
$filestring = $dirArray[$index];
} else {
$filestring = $filestring . ',' . $dirArray[$index];
}
}
}
}
print "fileList=".$filestring;
return "fileList=".$filestring;
?>