Skip to content

Instantly share code, notes, and snippets.

@ivuorinen
Created November 26, 2010 09:24
Show Gist options
  • Save ivuorinen/716451 to your computer and use it in GitHub Desktop.
Save ivuorinen/716451 to your computer and use it in GitHub Desktop.
directory insides as cute listing
<?php
/**
* directory insides as cute listing
*/
$me = __FILE__;
$dir = dirname($me);
$files = scandir($dir);
$req = $_SERVER['SERVER_NAME'].($_SERVER['REQUEST_URI']);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title><?php echo $req; ?></title>
<style type="text/css" media="screen">
body { background: #e3e3e3; color: #333; font: 14px/120% "Lucida Grande", Verdana, sans-serif; margin: 50px; }
div#r { width: 800px; margin: 0 auto; border: 10px solid #dbdbdb; background: #fff; padding: 10px 20px; }
table { width: 100%; }
table tr:nth-child(even) { background: #e9e9e9; }
th { text-align: left; }
a { color: #333; text-decoration: none; border-bottom: 1px solid #900; }
a:hover { color: #900; }
small { text-align: center; display: block; }
</style>
</head>
<body>
<div id="r">
<h1><?php echo $req; ?></h1>
<table border="0" cellspacing="0" cellpadding="5">
<tr>
<th>Tiedosto</th>
<th width="150">Muokattu</th>
<th width="100">Koko</th>
</tr>
<?php
foreach( $files as $file ):
if(
is_file($file)
&& is_readable($file)
&& $file[0] != "."
&& $file != "index.php"
):
$edit = filemtime($file);
$size = filesize($file)/1024;
if( floor($size) > 1024 ) {
$size = round($size/1024, 2)."Mt";
} else {
$size = round($size, 2)."kt";
}
?>
<tr>
<td><a href="<?php echo $file; ?>"><?php echo $file; ?></a></td>
<td><?php echo date("Y-m-d H:i", $edit); ?></td>
<td><?php echo $size; ?></td>
</tr>
<?php endif; endforeach; ?>
</table>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment