<!DOCTYPE html>
<html>
    <head>
        <title>Index of</title>
    </head>
    <body>
      <?php
        //https://stackoverflow.com/questions/14946964/php-built-in-server-any-way-to-configure-it-to-show-files-of-directory
        $dir = substr( dirname(__FILE__), strrpos(dirname(__FILE__), 'public_html') );
        echo "<h2>Index of ".$dir."</h2>";
        echo "<hr/>";
        $g = glob("".$dir."\*");
        usort($g, function($a, $b) {
            if (is_dir($a) == is_dir($b))
                return strnatcasecmp($a, $b);
            else
                return is_dir($a) ? -1 : 1; });
        echo '<a href="/..">Parent directory</a><br>';
        echo implode("<br>", array_map(function($a){$b = substr($a, 1+strrpos($a, "\\"));
                                                    if (is_dir($a)) $b = $b."/";
                                                    return '<a href="'.$b.'">'.$b.'</a>';},
                                       $g));
        echo "<hr/>";
        echo "<address>index.php</address>";
        ?>
    </body>
</html>
