|
\n";
echo " | http://".$_SERVER['SERVER_NAME'];
echo "$prefix/";
echo " |  | \n";
function get_extension($name) {
$array = explode(".", $name);
$retval = strtolower(array_pop($array));
return $retval;
}
// Recursion! And away we go...
// Set some globals and clean up a bit...
// What a pig...
function list_dir($chdir) {
global $root, $prefix, $showsize, $display, $excludedir, $excludefile;
unset($sdirs);
unset($sfiles);
chdir($chdir);
$self = basename($_SERVER['PHP_SELF']);
// Open the current directory
$handle = opendir('.');
// Read directory. If the item is a directory, place it in $sdirs.
// If it's a filetype we want, put it in $sfiles */
while ($file = readdir($handle))
{
if(is_dir($file) && $file != "." && $file != ".." && !in_array($file, $excludedir))
{ $sdirs[] = $file; }
elseif(is_file($file) && $file != "$self" && array_key_exists(get_extension($file), $display)
&& !in_array($file, $excludefile))
{ $sfiles[] = $file; }
}
// Count the slashes to determine how deep we're in the directory.
// Add lines to make it pretty.
$dir = getcwd();
$dir1 = str_replace($root, "", $dir."/");
$count = substr_count($dir1, "/") + substr_count($dir1, "\\");
// Display directory names and recursively list them.
if(is_array($sdirs)) {
sort($sdirs);
reset($sdirs);
for($y=0; $y";
for($z=1; $z<=$count; $z++)
{ echo " "; }
if(is_array($sfiles))
{ echo " "; }
else
{ echo " "; }
echo " $sdirs[$y]";
list_dir($dir."/".$sdirs[$y]);
}
}
chdir($chdir);
// Run through the array of files and show them.
if(is_array($sfiles)) {
sort($sfiles);
reset($sfiles);
$sizeof = sizeof($sfiles);
// What file types shall we display?
for($y=0; $y<$sizeof; $y++) {
echo " | ";
for($z=1; $z<=$count; $z++)
{ echo " "; }
if($y == ($sizeof -1))
{ echo " "; }
else
{ echo " "; }
echo " ";
echo "$sfiles[$y]";
if($showsize) {
$fsize = @filesize($sfiles[$y])/1024;
printf(" (%.2f kB)", $fsize);
}
echo " | ";
}
echo "";
for($z=1; $z<=$count; $z++)
{ echo " "; }
echo " | \n";
}
}
list_dir($root);
echo " \n";
// How long did that take?
$ftime = gettimeofday();
$time = round(($ftime[sec] + $ftime[usec] / 1000000) - ($stime[sec] + $stime[usec] / 1000000), 5);
echo "This page was generated in $time seconds. \n";
?>
|