0) { $path = substr($path, 0, $count); } // Remove any query string $pathname = $path; // copy of path for display $pathname = substr($pathname, strlen($root)+1); // trim to root $pathname = str_replace("/", "*", $pathname); // swap UNIX to BBC format $pathname = str_replace(".", "/", $pathname); // '.' <-> '/' $pathname = str_replace("*", ".", $pathname); // Page title echo '
'; echo "\n"; // Breadcrumb header: $pathcount = substr_count($pathname, ".")+1; // number of path components echo ' MDFS::'; $count = $pathcount; // step through path components while ($count > 1) { $count = $count -1; // dec. number of path components echo ''; echo substr($pathname, 0, strpos($pathname, ".")); // path component echo '.'; $pathname = substr($pathname, strpos($pathname, ".")+1); // step to next path component } echo ''; echo $pathname; echo ''; echo "\n"; echo ' | '; echo "\n"; echo 'Search'; echo "\n"; echo ' |
'; echo "\n";
// Read sorted directory contents
$dir = opendir($path); // create a handle for the directory
while (false !== ($file = readdir($dir))) { // read directory entries
$files[] = $file;
}
closedir($dir); // close directory handle
sort($files, SORT_STRING | SORT_FLAG_CASE); // sort filenames ignoring case
// Catalogue of directory entries
$count = 0; // current column
foreach ($files as $file) {
// if $file isn't this directory or its parent, display it as a link
if ($file != '.' && $file != '..' && $file != 'index.php') {
echo " "; // link
echo $file; echo ""; // filename
if (strlen($file)<16) {
echo str_repeat(" ", 16-strlen($file)); // padding to access string
}
if (is_dir($path . "/" . $file)) {
echo "DL/ \n"; // directory access string
} else {
echo "wr/R \n"; // file access string
}
$count = $count+1; // inc. column count
if ($count > $colmax) {
echo "
\n"; // newline
$count = 0;
}
}
}
// Footer
echo '