john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

index file listing 2007

<html>
<noads>
<?php

$d = dir( getcwd() );
echo "Handle: " . $d->handle . ", Path (not necessarily accurate): " . $d->path . "\n<br>";
echo "<title>" . $d->path . "/</title>";

$dh = opendir( getcwd() );

while (false !== ($file = readdir($dh)))
{
    if( $file != "." && $file != ".." ) //don't test the root directories
    {
        if( is_file($file) )
        {   $filelist[] = $file;    }
        else
        {   $dirlist[] = $file;     }
    }
}

echo "\n" . getcwd() . " contains " . sizeof($filelist) . " files and " .
    sizeof($dirlist) . " directories\n<br>\n";

echo "<table>\n";                       //a table for our dir/file names & sizes

if( $dirlist[0] != NULL )               //maybe there are no directories
{
    sort($dirlist);
    foreach ($dirlist as $value)
    {
        echo "<tr>";
        echo "<td><a href=\"" . $value . "\">" . $value . "</a></td>";
        echo "<td>&nbsp;</td>";
        echo "<td>" . date("dMy H:s T", filemtime($value)) . "</td>";
        echo "</tr>\n";
    }
}

sort($filelist);
foreach ($filelist as $value)
{
    echo "<tr>";
    echo "<td><a href=\"" . $value . "\">" . $value . "</a></td>";
    echo "<td>&nbsp;</td>";
    echo "<td>" . filesize($value) . " bytes</td>";
    echo "<td>&nbsp;</td>";
    echo "<td>" . date("dMy H:s T", filemtime($value)) . "</td>";
    echo "</tr>\n";
}
echo "</table>";

closedir($dh);
$d->close();
echo "\n";
?>
</html>

  • « index file listing 2009
  • css dropdown menu ie fix »

Published

Feb 6, 2010

Category

web

~134 words

Tags

  • 2007 7
  • file 92
  • index 8
  • listing 9
  • web 56