• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 318
  • Last Modified:

PHP script to generate file index when "IndexIgnore *" set on directory

When a host sets either

IndexIgnore *
or
Options -Indexes


Is there a PHP script that can generate a list of all the files in the current directory and output them as "clickable" links?

0
paradoxloss
Asked:
paradoxloss
1 Solution
 
BILJAXCommented:
// open this directory
      $myDirectory = opendir(".");

      // get each entry
      while($entryName = readdir($myDirectory))
      {
            $dirArray[] = $entryName;
      }
      // close directory
      closedir($myDirectory);


//      count elements in array
$indexCount      = count($dirArray);
Print ("$indexCount files<br>\n");
// sort 'em
sort($dirArray);
// print 'em
print("<TABLE border=1 cellpadding=5 cellspacing=0 class=whitelinks>\n");
print("<TR><TH>Filename</TH><th>Filetype</th><th>filesize</th></TR>\n");

for($index=0; $index< $indexCount; $index++)
      {
      print("<TR><TD><a href=\"$dirArray[$index]\">$dirArray[$index]</a></td>");
      print("<td>");
      print(filetype($dirArray[$index]));
      print("</td>");
      print("<td>");
      print(filesize($dirArray[$index]));
      print("</td>");
      print("</TR>\n");
      }
      print("</TABLE>\n");


tada!



AC
0
 
paradoxlossAuthor Commented:
thanks!
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now