Skip to content

Instantly share code, notes, and snippets.

@tjumyk
Created March 4, 2018 13:52
Show Gist options
  • Save tjumyk/468a65cea9b405dbcc88940564908481 to your computer and use it in GitHub Desktop.
Save tjumyk/468a65cea9b405dbcc88940564908481 to your computer and use it in GitHub Desktop.
Simple file index for apache
<?php $title="File Index";?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
<title><?=$title?></title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<style>
html,body,.vertical-center{
width: 100%;
height: 100%;
}
.vertical-center{
display: table;
}
.vertical-center>.inner{
display: table-cell;
vertical-align: middle;
}
</style>
</head>
<body>
<div class="vertical-center">
<div class="inner">
<div class="container">
<div class="row">
<h1 class="text-center"><?=$title?></h1>
</div>
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
<?php
$files = array_diff(scandir("."), array('.', '..', 'index.html', 'index.php'));
foreach ($files as $file) {
if(is_dir($file))
echo "<a href=\"$file/\" class=\"btn btn-default btn-block\">$file</a>";
else
echo "<a href=\"$file\" class=\"btn btn-default btn-block\">$file</a>";
}
?>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment