I had this problem at work that I completely forgot about. I left one of our production servers directory listings available to all who viewed it, which is a complete no-no. So I wrote this small script that you can name whatever you want and place it in any directory and it will link all your scripts. That way you can directly link to the script and get the same view of a file system without showing all your files and folders if you are missing an index page
PHP Code:
<?php
$dirlisting = directory_display();
sort($dirlisting);
foreach ($dirlisting as $file)
{
if (filetype($file) == 'dir')
{
echo "<tr>\n<td><img src=\"./images/folder.png\" /></td>\n</tr>\n";
}
else
{
echo "<tr>\n<td><img src=\"./images/file-generic.png\" /></td>\n</tr>\n";
}
echo "<tr>\n<td>\n<a href=\"$file\">$file</a></td>\n</tr>\n<br />";
}
function directory_display()
{
$directory = opendir(".");
//while ($file = readdir($directory))
while (false !== ($file = readdir($directory)))
{
if ($file != "." && $file != "..")
{
$dirlisting[] = $file;
}
}
closedir($directory);
return $dirlisting;
}
?>
The two images for the folders are attached to place in an "/image" folder
Bookmarks