Use this command in zsh to enable auto indexing:
for d in **/*(/); do ln "$PWD/index.php" "$d"; done
Run:
php -S 127.0.0.0 4747
And then check http://127.0.0.1:4747
Use this command in zsh to enable auto indexing:
for d in **/*(/); do ln "$PWD/index.php" "$d"; done
Run:
php -S 127.0.0.0 4747
And then check http://127.0.0.1:4747
<?php | |
# originated from http://stackoverflow.com/questions/14946964/ddg#14947054 | |
# vim: ts=4 sw=4 sts=4 et sta ai si | |
$dir = substr(__DIR__,strlen($_SERVER['DOCUMENT_ROOT'])) ?: '/'; | |
$g = array_diff(glob("*"), [basename(__FILE__)]); | |
usort($g,function($a,$b) { | |
if(is_dir($a) == is_dir($b)) | |
return strnatcasecmp($a,$b); | |
else | |
return is_dir($a) ? -1 : 1; | |
}); | |
?> | |
<h2>Index of <code><?= $dir ?></code></h2> | |
<?php if (empty($g)): ?> | |
<p>No files/directories in this directory</p> | |
<p><a href="..">back</a></p> | |
<?php else: ?> | |
<ul> | |
<li><?= implode("</li><li>",array_map(function($a) {$a=$a.(is_dir($a)?'/':''); return "<a href='$a'>$a</a>";},$g)) ?></li> | |
<?php if ($dir!='/'): ?><li><a href="..">------- back -------</a></li><?php endif ?> | |
</ul> | |
<?php endif; ?> |