Skip to content

Instantly share code, notes, and snippets.

@lrstanley
Created December 13, 2013 13:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lrstanley/7944324 to your computer and use it in GitHub Desktop.
Save lrstanley/7944324 to your computer and use it in GitHub Desktop.
Media based file indexer. (I.e, if you have a directory full of .png, .txt, or .doc, etc) this will cleanly list them (and remove the index.php from the list of files)
<!doctype html>
<html>
<head>
<title>File index</title>
<meta name="viewport" content="width=device-width">
<!--<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">-->
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootswatch/3.0.2/cosmo/bootstrap.min.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script type="text/javascript" src="https://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h1 class="text-center">File indexer</h1>
<table class="table table-bordered table-hover table-condensed text-center" style="margin-top:50px;margin-left:auto;margin-right:auto;width:900px;">
<thead>
<tr>
<th>Filesize (In bytes)</th>
<th>Filename</th>
</tr>
</thead>
<tbody>
<?php
$target = getcwd();
$weeds = array(".", "..");
$directories = array_diff(scandir($target), $weeds);
foreach($directories as $value) {
//if(if_dir($target.$value))
if (strpos($value,"php") == false) {
echo "<tr>";
echo " <td>".filesize($value)."B</td>";
echo " <td><a href=\"".$value."\">".$value."</a></td>";
echo "</tr>\n";
}
}
?>
</tbody>
</table>
</div>
<footer>
<div style="padding-top:20px;padding-bottom:20px;" class="text-center">Website Copyright &copy; <a href="http://liamstanley.net/license">Liam Stanley 2013</a></div>
</footer>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment