Por ser GNU.
Veja.
<?php
// Sistema para Listar Diretórios e Arquivos
// GNU Public License - 2004-11-07 | 07/11/2004
//
http://www.gnu.org/p...hy/free-sw.html // Klaus Roberto de Paiva - klausphp@gmail.com
// Defina aqui o diretório a ser listado!
// Use definição relativa não absoluta!
// Certo: "../Pasta"
// Errado: "
http://www.meusite.com.br/Pasta" // Não coloque / no final da pasta!
define ("Diretorio", "..");
?>
<style type="text/css">
body {
font: 10pt verdana;
}
a:link, a:visited {
color: #000000;
text-decoration: none;
}
a:hover, a:active {
font-weight: bold;
}
</style>
<script language="javascript" type="text/javascript">
function expandirContrair (qual) {
var pasta = document.getElementById(qual);
if (pasta.style.display == "none") {
pasta.style.display = "";
}
else {
pasta.style.display = "none";
}
}
</script>
<?php
function exibeEstrutura ($pasta, $acima, $caminho, $nivel = 0) {
$arquivos = null;
$id = md5 (microtime());
$mostrar = ($nivel == 0) ? "" : " style=\"display: none;\"";
echo "";
if (!is_dir ($pasta)) :
echo "$pasta não é uma pasta válida e/ou acessível!";
endif;
chdir ($pasta);
$eval = dir ("./");
$atual = getcwd();
echo str_repeat (" ", ($nivel * 5));
echo "<a href=\"java script:expandirContrair ('$id');\"><img src=\"pastas.gif\" border=\"0\" alt=\"\" width=\"17\" height=\"14\" align=\"absmiddle\" /> ";
echo ($nivel == 0) ? $atual : $pasta;
echo "</a><br /><div id=\"$id\"$mostrar>\n\n\n";
while (($itens = $eval->read()) !== false) :
if (($itens == ".") or ($itens == "..")) :
continue;
endif;
if (is_dir ($itens)) :
exibeEstrutura ($itens, $atual, $caminho . "/" . $itens, ($nivel + 1));
else :
$arquivos .= str_repeat (" ", (($nivel + 1) * 5));
$extra = ($nivel != 0) ? $pasta . "/" : "";
$arquivos .= "$itens <a href=\"$caminho/$itens\"><img src=\"visualizar.gif\" border=\"0\" alt=\"\" title=\"Visualizar este arquivo!\" width=\"14\" height=\"14\" align=\"absmiddle\" /></a> <a href=\"apagar.php?source=" . base64_encode ($caminho . "/" . $itens) . "\"><img src=\"apagar.gif\" border=\"0\" alt=\"\" title=\"Apagar este arquivo!\" width=\"14\" height=\"14\" align=\"absmiddle\" /></a><br />\n";
endif;
endwhile;
chdir ($acima);
echo $arquivos;
echo "</div>\n\n";
}
exibeEstrutura (Diretorio, Diretorio, Diretorio);
?>