Anyway, that disclaimer out of the way... sometimes I use the default Apache directory viewer, but other times I want more fine grained control over its appearance or what files get included. This PHP code seems to work pretty well for me. (The escaping might be a little wonky, but just replacing single quotes worked while urlencode() did not.)
<style>
body{
font-size:30px;
}
a{
padding-bottom:10px;
display:block;
text-decoration:none;
}
</style>
<?php
$path = ".";
$blacklist = array("index.php");
// get everything except hidden files
$files = preg_grep('/^([^.])/', scandir($path));
foreach ($files as $file) {
if (!in_array($file, $blacklist)) {
$url = str_replace("'","'",$file);
echo "<a href='$url'>$file</a>\n";
}
}
?>
No comments:
Post a Comment