/*
PHP Directory display
Copyright (C) 2002 Richard Clark (rclark@exorsus.net)
See the GNU General Public License included with this software
for more details. If none is included you have NO LICENSE to
operate this software and should contact the author immediately.
*/
function format_size($size) {
if ($size<1024) { return $size."b"; }
if ($size<(1024*1024)) { return sprintf("%dk",$size/1024); }
return sprintf("%.1fM",$size/(1024*1024));
}
function get_dir_listing() {
$listing = array();
$dh = opendir(getcwd());
while ($file = readdir($dh)) {
array_push($listing, $file);
}
closedir($dh);
sort($listing);
return $listing;
}
?>
foreach (get_dir_listing() as $file) {
$name = preg_replace("/\s/","%20",$file);
$name = preg_replace("/'/","%27",$name);
$time = date("M d H:i",filemtime($file));
if ($file == ".") continue;
if ($file == "index.php") continue;
if ($file == ".htaccess") continue;
if ($file == "..") $name = "Parent Directory";
if (is_dir($file))
printf("%-60.60s %s %6.6s\n",$file,"$name/",$time,"-");
else
printf("%-60.60s %s %6.6s\n", $name,$file,$time,format_size(filesize($file)));
}
?>