PHP Effective Directory Listing

Effective Directory Listing

<?
// The CODE below must be in .htaccess

//CODE: <FilesMatch "^index$"> 
//CODE:   ForceType application/x-httpd-php 
//CODE: </FilesMatch>

//END

$a = $_SERVER['REQUEST_URI'];
$b = $_SERVER['SCRIPT_NAME'];

$c = eregi_replace("$b/", "", $a);

if (is_dir($c)) {
  $handle = opendir($c);
  while($file = readdir($handle)) if ($file != "." && $file != "..") echo "$file<BR>";
}
?>