note 73007 deleted from function.filemtime by philip
| From: | philip@php.net | Date: | Wed, 07 Feb 2007 05:00:19 +0000 |
| Subject: | note 73007 deleted from function.filemtime by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-123019@lists.php.net to get a copy of this message | ||
Note Submitter: Allen Panclape
Reason: bad code
----
Here is a script that fakes directory indexing for people who's hosting doesn't allow
normal indexing. This script uses date() and filemtime() to mimic the indexing "last
modified" date.
<?php
$pathinfo=pathinfo($_SERVER["PHP_SELF"]);
$dir=$pathinfo['dirname'];
print "<h1>Index Of $dir</h1><br />
<table width='100%' cellspacing='0' style='font-size: 12px; font-family:
Verdana; '>
<tr><td width='200'><b>Filename</b></td>
<td width='300'><b>Last Modified</b></td>
<td width='50'><b>Size</b></td>
<td> </td></tr>
<tr><td colspan='5'><hr></td></tr>";
$dir_handle=opendir("./");
while(false!=($file=readdir($dir_handle)))
{
$fileinfo=pathinfo($file);
$lastmod=date("d-M-Y G:i", filemtime($file));
$filesize=filesize($file);
print "<tr><td><a href='$file'>$file</a></td>
<td>$lastmod</td>";
if($filesize>1000000000)
$filesize=($filesize/1000000000)." GB";
elseif($filesize>1000000 && $filesize<1000000000)
$filesize=($filesize/1000000)." MB";
elseif($filesize>1000 && $filesize<1000000)
$filesize=($filesize/1000)." KB";
elseif($filesize>0 && $filesize<1000)
$filesize=$filesize." B";
if($fileinfo['extension']=="")
$filesize=" - ";
print "
<td>$filesize </td><td> </td></tr>";
}
closedir($dir_handle);
print "<tr><td
colspan='5'><hr></td></tr></table>";
?>