test33.php to HTML

index

USE AT OWN RISK

Generated: Tue Jul 31 15:22:16 2007 from test33.php 2005/08/08 2.9 KB bytes.

<html>
<head>
<title>test33.php</title>
</head>
<body background="cldsg.jpg">

<h1 align="center">test33.php</h1>

<p>Full Directory List</p>
<?php 

function getDirList ($dirName, $dep) { 
 $d = dir($dirName); 
 $head = "-";
 for($i = 0; $i < $dep; $i++) {
 $head = $head."-";
 }
 while($entry = $d->read()) { 
 $locpath = $dirName."/".$entry;
 if ($entry != "." && $entry != "..") { 
 if (is_dir($locpath)) { 
 getDirList($locpath, ($dep + 1)); 
 } else { 
 echo $head." ".$locpath."<br>\n"; 
 } 
 } 
 } 
 $d->close(); 
} 

 // getDirList(".",0); 

?>

<p>Another File List, in date order</p>

<?php 

$dirpath = getcwd() . "/";
print "cwd: $dirpath";
$dir = opendir($dirpath);
$files = array();
while ($file = readdir($dir)) {
 $localpath = $dirpath.$file;
 
 if (is_file($localpath)) {
 $key = filemtime($localpath).md5($file);
 $files[$key] = $file;
 }
}
ksort($files);
foreach ($files as $file) {
 // echo "$file<br>";
} 

?>

<p>And a callback method</p>

<p>You are using 
<?php
global $HTTP_USER_AGENT;
print "[$HTTP_USER_AGENT]";
?>
<BR>
and coming from
<?php
global $REMOTE_ADDR;
print "[$REMOTE_ADDR]";
?>
</p>

<p align="center">
<!-- <a href="&lt?php echo $this->SELF; ?&gt?dir=net2ftp">net2ftp</a> or -->
<a href="<?php echo $PHP_SELF; ?>?dir=net2ftp">net2ftp</a> or 
<a href="<?php echo $PHP_SELF; ?>?dir=.">Clear</a>
</p>

<?php

if (isset($_REQUEST["dir"])) {
$directory = $_REQUEST["dir"]; // lets fetch the variable: REQUEST works for both, POST and GET methods
} else {
$directory = 'none';
}
echo "Got dir=".$directory."<br>";
if (substr($directory, 0, 1) == "/")
 $directory = "";
$directory = str_replace ("./", "", $directory);
$directory = str_replace (".", "", $directory);

echo "After=".$directory."<br>";

if ($directory != @$null) { // lets check if the variable "dir" has something in it, otherwise lets just print out the empty document
 if ($dir = @opendir($directory)) { // changed "./" to the directory variable
 echo ("Listing contents of <b>$directory</b><br><br>\n"); // i just added this thing
 while (($file = readdir($dir)) !== false) {
 if ($file != "." && $file != "..") {
 $location = "$directory/$file";
 $type = filetype($location);
 $size = filesize($location);
 if (is_dir($location) == true) {
 echo ("$type - <a href=\"dir.php?dir=$location\">$file</a><br>\n");
 }
 else {
 echo ("$type - <a href=\"$location\">$file</a> - $size Bytes<br>\n");
 }
 }
 }
 closedir($dir);
 }
}

?>
 


<p>
End of test33.php
</p>

</body>
</html>
 

index

Valid HTML 4.01 Transitional