Ecco uno script utile in PHP per mostrare l’elenco di una cartella del proprio server, qui sotto il codice della pagina (da creare e salvare a piacimento, ad esempio index.php):
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN” “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>
<html>
<head>
<title>Elenco files</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=ISO-8859-1″>
<style type=’text/css’>
body {
font-family: verdana;
background-color: #000;
color: #FFF;
}
a {
color: #FFFF00;
text-decoration: none;
}
.red {
color: #FF0000;
}
.green {
color: #00CC00;
}
.yellow {
color: #FFFF00;
}
a:hover {
color: #FFF0C4;
text-decoration: underline;
}
td {
border: 1px solid #FFF;
vertical-align: middle;
padding: 2px;
}
table {
table-layout: fixed;
}
</style>
</head>
<body>
<div align=center’>
<?php
if ($handle = opendir(’.')) //il punto indica la directory attuale
{
while (false !== ($file = readdir($handle)))
{
$fileList[] = trim($file);
}
sort ($fileList);
reset ($fileList); //si riporta in cima all’array
echo “<table>”;
while (list ($key, $val) = each ($fileList))
{
//non mostro i link di cartella ed eventualmente questa pagina (index.php)
if ($val != ‘.’ AND $val != ‘..’ AND $val != ‘index.php’)
{
echo ‘<tr><td><span class=\’yellow\’><a href=\”.$val.’\'>’.$val.’</a></span></td><td><span class=\’red\’>’.filesize($val).’ KB</span></td><td><span class=\’green\’>’.date(”F d Y H:i:s”, filectime($val)).’</span></td></tr>’;
}
}
closedir($handle);
echo “</table>”;
}
?>
<small>©<a href=”http://www.studioinformatico.net” target=”_blank”>Studio Informatico</a> – Powered by <a href=”http://www.globula.it” target=”_blank”>Globula</a></small>
</div>
</body>
</html>







