Skip to content

Instantly share code, notes, and snippets.

@janbiasi
Created January 13, 2016 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janbiasi/768bf1b5d7ec85828537 to your computer and use it in GitHub Desktop.
Save janbiasi/768bf1b5d7ec85828537 to your computer and use it in GitHub Desktop.
Tired of the default XAMPP/MAMP Index? Try this one and get a beautiful directory listing in your server root!
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Index of <?= $_SERVER['SERVER_NAME'] ?></title>
<style type="text/css">
html, body { margin: 0; padding: 0; }
body { font-family: 'Helvetica Neue', Arial, sans-serif; padding: 20px; }
a { text-decoration: none; color: #4BB7DB; }
a:hover { text-decoration: underline; }
h1 { margin: 0 0 10px 0; }
p { font-size: 10px; margin: 2px 0; }
p strong { display: inline-block; min-width: 70px; }
p:first-child { margin-top: 5px; }
ul { list-style: disc; list-style-type: disc; }
li { font-size: 16px; line-height: 23px;}
</style>
</head>
<body>
<header>
<h1>Documents on <?= $_SERVER['SERVER_NAME'] ?> (<?= $_SERVER['SERVER_ADDR'] ?>)</h1>
<div class="server-info-container">
<p>
<strong>Request</strong> <?= $_SERVER['REQUEST_METHOD'] ?> <?= $_SERVER['SERVER_PROTOCOL'] ?> @<?= $_SERVER['REQUEST_TIME'] ?>
</p>
<p>
<strong>Accepting</strong> <?= $_SERVER['HTTP_ACCEPT'] ?>
</p>
<p>
<strong>Software</strong> <?= $_SERVER['SERVER_SOFTWARE'] ?>
</p>
<p>
<strong>User Agent</strong> <?= $_SERVER['HTTP_USER_AGENT'] ?>
</p>
</div>
</header>
<main>
<ul>
<?php
$open_target = '_blank';
if($handle = opendir('.')) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
?>
<li title="Open <?= $entry ?>">
<a href="<?= $entry ?>" target="<?= $open_target ?>">
<?= $entry ?>
</a>
</li>
<?php
}
}
closedir($handle);
}
?>
</ul>
</main>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment