/*
USAGE:
------------
copy this file in your root download directory and
it will show all files and directories.
if you don't want to show a directory,
the first character of the name should be "-".
test (visible)
-test (invisible)
*/
/* Displays formated file size */
function getfilesize($size) {
if ($size != 0) {
if ($size>=1099511627776) {
$size = round($size / 1024 / 1024 / 1024 / 1024, 2);
$suff = "TB";
} elseif ($size>=1073741824) {
$size = round($size / 1024 / 1024 / 1024, 2);
$suff = "GB";
} elseif ($size>=1048576) {
$size = round($size / 1024 / 1024, 2);
$suff = "MB";
} elseif ($size>=1024) {
$size = round($size / 1024, 2);
$suff = "KB";
} elseif ($size<1024) {
$size = round($size / 1024, 2);
$suff = "Byte";
}
} else {
$suff = "Byte";
}
if ($size == 1) $size = $size." ".$suff;
else $size = $size." ".$suff."s";
return $size;
}
function show_all_files($dirname = '.') {
//$dirname = ".";
$dirs = explode('/',$dirname);
$cur_dir = array_pop($dirs);
if ($cur_dir=='.') $cur_dir = 'Home';
if (count($dirs)>0) {
$dirLink = '';
foreach ($dirs as $dir) {
if (strlen($dirLink)>0) $dirLink .= '/';
$dirLink .= $dir;
if ($dir == '.') $dir = 'Home';
echo "".$dir."
";
}
echo "
";
}
if ( $filedir = opendir($dirname) ) {
$i = 1;
while ( ($file = readdir($filedir)) ) {
if ( $file!="index.php" && !is_dir($dirname."/".$file) ) {
$files[$file] = filemtime($dirname.'/'.$file);
$i++;
}
if (is_dir($dirname."/".$file) && $file!="." && $file!=".." && substr($file, 0, 1)!='-') {
$direct[$file] = $file;
}
}
closedir($filedir);
@asort($direct);
@asort($files);
echo "Directory: ".$cur_dir."
";
if ($direct)
for ($i=1, @reset($direct) ; $i<=count($direct) ; $i++, next($direct)) {
$dir = key($direct);
echo "".$dir."
";
}
if ($files)
for ($i=1, @reset($files) ; $i<=count($files) ; $i++, next($files)) {
$file = key($files);
echo "$i: $file (".getfilesize(filesize($dirname.'/'.$file)).")
";
}
}
else echo "Couldn't load the files.";
}
$_REQUEST['dir'] = strlen($_REQUEST['dir'])==0 ? '.' : $_REQUEST['dir'];
?>