Skip to content

Instantly share code, notes, and snippets.

@erikccoder
Created December 11, 2014 04:55
Show Gist options
  • Save erikccoder/dccd57181d0facaa2e63 to your computer and use it in GitHub Desktop.
Save erikccoder/dccd57181d0facaa2e63 to your computer and use it in GitHub Desktop.
<?php
function pc_validate($user,$pass) {
/* replace with appropriate username and password checking,
such as checking a database */
$users = array('430' => '');
if (isset($users[$user]) && ($users[$user] == $pass)) {
return true;
} else {
return false;
}
}
if (! pc_validate($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']))
{
header('WWW-Authenticate: Basic realm="430"');
header('HTTP/1.0 401 Unauthorized');
echo "You need to enter a valid username and password.";
exit;
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<style>
/* tables */
table.tablesorter {
font-family:arial;
background-color: #CDCDCD;
margin:10px 0pt 15px;
font-size: 8pt;
width: 100%;
text-align: left;
}
table.tablesorter thead tr th, table.tablesorter tfoot tr th {
background-color: #e6EEEE;
border: 1px solid #FFF;
font-size: 8pt;
padding: 4px;
}
table.tablesorter thead tr .header {
background-image: url("http://tablesorter.com/themes/blue/bg.gif");
background-repeat: no-repeat;
background-position: center right;
cursor: pointer;
}
table.tablesorter tbody td {
color: #3D3D3D;
padding: 4px;
background-color: #FFF;
vertical-align: top;
}
table.tablesorter tbody tr.odd td {
background-color:#F0F0F6;
}
table.tablesorter thead tr .headerSortUp {
background-image: url("http://tablesorter.com/themes/blue/asc.gif");
}
table.tablesorter thead tr .headerSortDown {
background-image: url("http://tablesorter.com/themes/blue/desc.gif");
}
table.tablesorter thead tr .headerSortDown, table.tablesorter thead tr .headerSortUp {
background-color: #8dbdd8;
}
</style>
<body>
<table id="myTable" class="tablesorter">
<thead>
<tr>
<th>Name</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<?php
$dir = "./";
$dh = opendir($dir);
while (false !== ($filename = readdir($dh)))
{
$files[] = $filename;
}
foreach ($files as $value)
{
if(strlen($value)>2 && strcmp($value, "index.php")!= 0)
{
echo "<tr>";
echo "<td>";
echo "<a href=\"$value\">$value (". round(filesize($value) /(1048576), 2) . "MB)</a>";
echo "</td>";
echo "<td>";
echo date ("Ymd_His", filemtime($value));
echo "</td>";
echo "</tr>";
}
}
?>
</tbody>
</table>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//tablesorter.com/__jquery.tablesorter.min.js"></script>
<script>
$(document).ready(function()
{
$("#myTable").tablesorter({
// sort on the first column and third column, order asc
sortList: [[1,1]]
});
}
);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment