search for all files in sub-dirs (http://de3.php.net/manual/de/function.opendir.php#83990)
function createFileIndex( $start = '.')
{
//catch error
if(! is_dir($start))
return false;
//initalize stuff
echo "
";
$dirs = array( $start);
echo "| NAME
|
| SIZE
|
| TYPE
|
| DATE CREATED
|
";
//search iterative
while( NULL !== ($dir = array_pop( $dirs)))
{
$dh = opendir($dir);
while( $file = readdir($dh) )
{
//skip current directory and php-files
if( $file == '.' || $file == '..' || substr($file,-3)=="php")
continue;
$path = $dir . '/' . $file;
//if path is an directory => write into array, else write the files attributes into the table
if( is_dir($path) )
$dirs[] = $path;
else
{
//get file infos
$ftime = gmdate("d.M.y",filemtime($path))
. " "
. gmdate("H:i:s",filemtime($path));
$fsize = round(filesize($path) * .0009765625);
$ftype = strtolower(substr(strrchr($file,'.'),1));
//to table
$output = "
| $file
|
| $fsize KB |
| $ftype |
| $ftime |
";
echo $output;
}
}
closedir($dh);
}
echo "
";
}
createFileIndex();
?>