$urlPath = dirname($_SERVER['SCRIPT_NAME']);
$here = dirname($_SERVER['SCRIPT_FILENAME']);
//print($here . "
");
$d = dir($here);
//echo "Handle: ".$d->handle."
\n";
//echo "Path: ".$d->path."
\n";
$dirs = array();
$files = array();
while (false !== ($entry = $d->read())) {
//print($entry . "
\n");
if ( (strcmp(substr($entry, 0, 1), ".") != 0)
&& (strcmp(substr($entry, 0, 6), "index.") != 0)
&& (strcmp(substr($entry, 0, 6), "index_") != 0)
&& (strcmp($entry, "README.TXT") != 0)
&& (strcmp($entry, "stairs") != 0)
&& (strcmp($entry, "sync.sh") != 0)
&& (strcmp($entry, "favicon.ico") != 0)
) {
if (is_file($entry))
array_push($files, $entry);
else if (is_dir($entry))
array_push($dirs, $entry);
}
}
$favicon = "";
if (file_exists("favicon.ico"))
$favicon = "favicon.ico";
else if (file_exists("../favicon.ico"))
$favicon = "../favicon.ico";
else if (file_exists("../../favicon.ico"))
$favicon = "../../favicon.ico";
if (strlen($favicon) > 0)
print("\n\n");
$d->close();
usort($dirs, "strcasecmp");
usort($files, "strcasecmp");
//ksort($dirs, SORT_STRING);
//ksort($files, SORT_STRING);
$descriptions = getDescriptions(".htaccess");
function getDescriptions($filename) {
GLOBAL $dirs, $files;
$result = array();
if (file_exists($filename)) {
$handle = fopen($filename, "r");
while (!feof($handle)) {
$line = fgets($handle);
if (strcmp(substr($line, 0, 14), "AddDescription") == 0) {
$line = substr($line, 16);
$pos = strpos($line, '"');
$desc = trim(substr($line, 0, $pos));
$file = trim(substr($line, $pos + 1));
//print($file . " -> " . $desc . "
\n");
$result[$file] = $desc;
}
}
}
for ($i=0; $i
\n";
$dashes .= "
\n";
$inverseDashes = "" . $inverseDashes . "";
$dashes = "" . $dashes . "";
$columnCutoff = 18;
for ($i=0; $i
<-- Parent Directory
reset($dirs);
while (list($pos, $name) = each($dirs)) {
//for ($i=0; $i < sizeof($dirs); $i++) {
// $name = $dirs[$i];
// $description = $descriptinos[$dirs[$i]];
$description = $descriptions[$name];
if (strlen($name) > $columnCutoff)
$name = substr($name, 0, $columnCutoff);
print("");
print($name);
print("");
printSpaces($columnCutoff - strlen($name) + 1);
print($description);
print("
\n");
}
if ( (sizeof($dirs) > 0) && (sizeof($files) > 0))
print $dashes;
reset($files);
while (list($pos, $name) = each($files)) {
//for ($i=0; $i < sizeof($files); $i++) {
// $name = $files[$i];
// $description = $descriptions[$files[$i]];
$description = $descriptions[$name];
if (!in_array($name, $files))
continue;
if (strlen($name) > $columnCutoff)
$name = substr($name, 0, $columnCutoff);
print("");
print($name);
print("");
printSpaces($columnCutoff - strlen($name) + 1);
printPadded(round(filesize($name) / 1000) . "K", 5);
print(" ");
if (strpos($description, "[No Description]") === 0)
$description = "[No Description]";
print($description);
print("
\n");
}
print $inverseDashes;
//search();
?>
printReadme() ?>