Re: DirListing

"Thomas E. Horner" <[email protected]>
Newsgroups gmane.network.mathopd
Message-ID <[email protected]>
here it is!

short howto:
  copy the script to a place that is not viewable from www
  make sure the mathopd-user has rights to read it
  create an index.php with the following content:
     <? include('/path/to/dirlisting.php'); ?>
  that's it!

regards,
   thomas



Hello,

Where is the script with directory browsing?
That sounds like a nice feature.

-Mike

-- 
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net
dirlisting.php (text/html, 2.5 KB)
<? $currdir = dirname($PHP_SELF); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><HTML><HEAD><TITLE>Index of <? echo $currdir; ?></TITLE></HEAD><BODY><H1>Index of <? echo $currdir; ?></H1><PRE><IMG SRC="http://www.apache.org/icons/blank.gif" ALT="     "> <A HREF="#">Name</A>                    <A HREF="#">Last modified</A>              <A HREF="#">Size</A><HR><?

$realdir=dirname($PATH_TRANSLATED);
$dir_handle = opendir($realdir);

while ($listelem = readdir($dir_handle))
{
  if (is_dir($listelem)) {
    if ($listelem == ".")
    {
      //current dir, nothing 2 do
    }
    elseif ($listelem == "..")
    {
      //parent dir
      $elemtime = filemtime($realdir."/".$listelem);

      echo "<IMG SRC=\"http://www.apache.org/icons/folder.gif\" ALT=\"[DIR]\"> <A HREF=\"$listelem\">Parent Directory</A>        ".date("Y-m-d H:i:s",$elemtime)."        -  <br>";
    }
    else
    {
      //standard dir
      $elemtime = filemtime($realdir."/".$listelem);

      echo "<IMG SRC=\"http://www.apache.org/icons/folder.gif\" ALT=\"[DIR]\"> <A HREF=\"$listelem\">";
      printf("%.22s",$listelem);
      echo "</A>";
      $len = (22-strlen($listelem));
      $len += 2;
      if($len<2)$len=2;
      printf("%".$len."s","");
      echo date("Y-m-d H:i:s",$elemtime)."        -  <br>";
    }
  }
  else
  {
     if($listelem == basename($PATH_TRANSLATED))
     {
     }
     elseif($listelem == ".htaccess")
     {
     }
     else
     {
       $elemtime = filemtime($realdir."/".$listelem);

       $file_size = filesize($realdir."/".$listelem);
       if($file_size=="") $file_size="0";
			
       if ($file_size >= 1048576)
         $file_size = round($file_size / 1048576 * 100) / 100 . " MB";
       elseif ($file_size >= 1024)
         $file_size = round($file_size / 1024 * 100) / 100 ." KB";
       else
         $file_size = $file_size . " B"; 
  	
       echo "<IMG SRC=\"http://www.apache.org/icons/unknown.gif\" ALT=\"[ X ]\"> <A HREF=\"$listelem\">";
       printf("%.22s",$listelem);
       echo "</A>";
       $len = (22-strlen($listelem));
       $len += 2;
       if($len<2)$len=2;
       printf("%".$len."s","");
       echo date("Y-m-d H:i:s",$elemtime)."        $file_size  <br>";
     }
  }
}
?>
</PRE><HR><TABLE BORDER="0" WIDTH="100%"><TR><TD><ADDRESS><? echo $SERVER_SOFTWARE; ?> at <? echo $SERVER_NAME; ?> on Port <? echo $SERVER_PORT; ?></ADDRESS></TD><TD ALIGN="right"><A HREF="http://www.highspeed-at.net" TARGET="_blank"><ADDRESS>HighSpeed-AT.NET</ADDRESS></A></TD></TR></TABLE></BODY></HTML>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.