File Directory Php

< Main PHP FILE (dirlist.php3) >

$url_address = "http://130.113.48.245";
$local_address = "d:/Server";
$relative_address = str_replace( '%20', ' ', $QUERY_STRING );
$listing_title = "In responce to: $local_address/$relative_address";
require "darklib.inc";
heather($listing_title);
record_user();
$fp = opendir("$local_address/$relative_address");
while ($file = readdir($fp))
if (filetype($local_address . "/" . $relative_address.$file) == file) {
$Ufiles[] = $file;
$Lfiles[] = strtolower($file);
} else {
$Ufolders[] = $file;
$Lfolders[] = strtolower($file);
}
closedir($fp);
sort($Lfolders);
for ($i=0; $i<=count($Lfolders)-1; $i++) {
for ($j=0; $j<=count($Lfolders)-1; $j++) {
if (strcmp($Lfolders[$i], strtolower($Ufolders[$j])) == 0) {
$folders[] = $Ufolders[$j];
}
}
}
for ($i=0; $i<=count($folders)-1; $i++)
$item[] = $folders[$i];
if (count($Lfiles) > 0) {
sort($Lfiles);
for ($i=0; $i<=count($Lfiles)-1; $i++) {
for ($j=0; $j<=count($Lfiles)-1; $j++) {
if (strcmp($Lfiles[$i], strtolower($Ufiles[$j])) == 0) {
$files[] = $Ufiles[$j];
}
}
}
for ($i=0; $i<=count($files)-1; $i++)
$item[] = $files[$i];
}
for ($i=0; $i<=count($item)-1; $i++) {
if (strcmp($item[$i], "..") != 0 && strcmp($item[$i], ".") != 0) {
if (filetype($local_address."/".$relative_address.$item[$i]) == file) {
$filesize = number_format(filesize($local_address."/".$relative_address.$item
[$i])/1024)." kb";
echo "";
$icon_file = iconcalc($item[$i]);
echo "src=/Icons/$icon_file height=17 width=16 border=0>";
echo "$item[$i]
";
echo "$filesize";
echo "File";
} else {
$filesize = "Directory";
echo "";
echo "
[$i]/\">";
echo "[$i]/\">$item[$i]";
echo "";
echo "Folder";
}
}
}
echo "";
echo "
";
echo "
";
echo "
";
echo "";
?>

< END OF Main PHP FILE (dirlist.php3) >
< THE INCLUDE FILE (darklib.inc) >
FUNCTION record_user($Referer_IP,$User_IP)
{
$pathname = "d:/server/test/logs/";
$filename = sprintf("%s%s", $pathname, "referer.txt");
$fp=fopen($filename,"r+");
if ($fp == 0) {
print "Error opening file";
}
while (!feof($fp)) {
fgetc($fp);
}
fputs($fp,"User $User_IP was sent here by $Referer_IP \n");
fclose($fp);
}
FUNCTION heather($listing_title)
{
print "";
print "bgcolor=\"#000000\" text=\"#6595FF\">";
print "
Directory Index
";
print "
$listing_title
";
print "
[Refresh]";
print "

";
print "";
print " ";
print " ";
}
FUNCTION iconcalc($file_name)
{
$temp = explode(".", $file_name);
if ($temp[count($temp)-1] == "txt" || $temp[count($temp)-1] == "diz" || $temp[count
($temp)-1] == "me" || $temp[count($temp)-1] == "nfo") {
return "txtBLK.gif";
} else if ($temp[count($temp)-1] == "gif" || $temp[count($temp)-1] == "jpg" || $temp
[count($temp)-1] == "jpeg" || $temp[count($temp)-1] == "bmp" || $temp[count($temp)-1]
== "tif"){
return "picBLK.gif";
} else if ($temp[count($temp)-1] == "ace" || $temp[count($temp)-1] == "zip" || $temp
[count($temp)-1] == "rar"){
return "aceBLK.gif";
} else if ($temp[count($temp)-1] == "mp3" || $temp[count($temp)-1] == "wav" || $temp
[count($temp)-1] == "mp2"){
return "mp3BLK.gif";
} else if ($temp[count($temp)-1] == "doc" || $temp[count($temp)-1] == "xls") {
return "docBLK.gif";
} else {
return "unknown.gif";
}
}
?>
< END OF INCLUDE FILE (darklib.inc) >
File Namewidth=\"50\">SizeType
width=16>[Go Back]