Skip to content

Instantly share code, notes, and snippets.

@janbiasi

janbiasi/index.php

Created Jan 13, 2016
Embed
What would you like to do?
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