index.phps
<html lang="ru">
<head>
<title>File keeper</title>
<style type="text/css">
td, body { font-family: Tahoma; font-size: 12px }
a { text-decoration: none; color: black }
a:hover { text-decoration: underline }
small { font-family: Arial;font-size: 10px }
</style>
</head>
<body bgcolor="white" color="black">
<br /><br />
<table width="100%" cellpadding="4" cellspacing="0" border="0">
<tr><td width="16"></td><td width="40">Name</td>
<td width="40" align="right">Size</td><td>Description</td></tr>
<tr><td colspan="4"><hr noshade="yes" /></td></tr>
<?
$folders = $files = $descr = array();
if (file_exists('descript.ion') && $fp = fopen ('descript.ion', 'rb'))
{
flock ($fp,LOCK_SH);
while (!feof($fp))
{
list($fname, $str) = preg_split('/\s+/', fgets($fp, 1024), 2);
$descr[$fname] = $str;
}
fclose($fp);
}
foreach (array('./') as $f)
{
$d = opendir ($f);
while (($name = readdir($d)) !== FALSE)
if (isset($descr[$name]))
{
if (is_dir($f.$name))
$folders[] = $f.$name; else $files[] = $f.$name;
}
closedir($d);
}
sort($folders);
sort($files);
foreach ($folders as $n) S_out($n, TRUE);
foreach ($files as $n) S_out($n, FALSE);
function S_out($name, $isfolder)
{
global $descr;
if ($isfolder)
{
$bg = '#FFEF8A';
$pict = 'folder';
$size = '-';
}
else
{
$bg = '#D1E8F8';
$pict = 'file';
$size = filesize($name);
}
$bname = basename($name);
echo <<<HTML
<tr>
<td width="16"><a href="$name"><img src="/files/$pict.gif" width="16" height="16" alt="-" border="0" style="background-color:$bg" /></a></td>
<td width="40"><a href="$name">$bname</a></td>
<td width="40" align="right">$size</td>
<td><small>{$descr[$bname]}</small></td>
</tr>
HTML;
}
?>
<tr><td colspan="4"><hr noshade="yes" />
</td></tr>
</table>
</body>
</html>