rendered paste body<?php
$ooo = "";
function GiveOut($nsstring)
{
$ooo .= $nsstring;
}
function PrintOutput()
{
echo gzcompress($ooo,9);
}
if($argc != 2)
{
echo "Usage: listdir.php /directory/to/list\n\n\n";
exit;
}else{
$dir = $argv[1];
$dir = $dir . "<^:^:^>";
if(strpos($dir,"/<^:^:^>"))
{
$dir = str_replace("/<^:^:^>","",$dir);
}else{
$dir = str_replace("<^:^:^>","",$dir);
}
GiveOut("\n\n&*c" . "Listing Directory: " . $dir . "\n\n");
if ($handle = opendir($dir)) {
echo $dir . "\n\n\n\n";
GiveOut("&*cDirectory handle: $handle\n");
GiveOut("&*cFiles:\n");
GiveOut("&*cd" . $dir);
/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if(is_dir($dir . "/" . $file))
{
GiveOut("&*d" . $file . "<path>" . $dir . "/" . $file . "\n");
}else{
GiveOut("&*f" . $file . "<path>" . $dir . "/" . $file ."\n");
}
}
}
closedir($handle);
}
GiveOut("\n\n&*c" . "End of Directory Listing for " . $dir);
echo $ooo;
exit;
}
?>