Skip to content

Instantly share code, notes, and snippets.

@flyingfisch
Last active August 29, 2015 13:58
Show Gist options
  • Save flyingfisch/9946401 to your computer and use it in GitHub Desktop.
Save flyingfisch/9946401 to your computer and use it in GitHub Desktop.
An index for directories
<!DOCTYPE HTML>
<html>
<head>
<title>Index</title>
</head>
<body>
<style>
html {
background: #CDE5E5;
color: #1B2638;
}
a {
color: #00728E;
}
a:hover {
color: #0DA3CB;
}
div {
width: 90%;
background: #fff;
margin: 0 auto;
border-radius: 5px;
padding: 10px;
line-height: 150%;
}
</style>
<div>
<h1>Contents of <?PHP
$array = explode($_SERVER['SERVER_NAME'] . dirname(__FILE__),$url); $count = count($array);
echo basename(__DIR__); ?></h1>
<hr color="#ccc" />
<b><a href="../">Go up one directory</a></b><br /><br />
<h2>Folders</h2>
<?PHP
$handle = opendir(dirname(realpath(__FILE__)));
while($fn = readdir($handle)) {
if ($fn != '.' && $fn != '..') {
if (!is_file($fn)) {
echo '<a href="' . $fn . '">' . $fn . '</a><br />';
}
}
}
?>
<h2>Files</h2>
<?PHP
$handle = opendir(dirname(realpath(__FILE__)));
while($fn = readdir($handle)) {
if ($fn != '.' && $fn != '..' && $fn != 'index.php') {
if (is_file($fn)) {
echo '<a href="' . $fn . '">' . $fn . '</a><br />';
}
}
}
?>
<hr color="#ccc" />
Powered by Apache, server owned by <a href="http://toppagedesign.com/">Top Page Design</a>.<br />
<i>Server 1</i>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment