Har lavet lidt opdateringer på koden og bland andet proppet lidt HTML og CSS ind, samt gjort den valid.
Til dem der kan bruge det:
<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"
http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Directory Tree</title>
</head>
<body>
<?php
$dir = "files/";
$dh = opendir($dir);
echo "<h2>Directory: ".$dir."</h2>";
echo "<span style=\"padding-left: 15px;\"><u>Filer:</u></span><br>";
$dirnavn = "files/";
$dirh = opendir($dirnavn);
while($udskriv_fil = readdir($dirh)) {
if ($udskriv_fil != "." && $udskriv_fil != "..") {
if (is_file($dirnavn.$udskriv_fil)) {
echo "<span style=\"padding-left: 25px;\"> - ".$udskriv_fil."</span><br>";
}
}
}
echo "<br>";
echo "<span style=\"padding-left: 15px;\"><u>Mapper:</u></span>";
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"padding-top: 0px; padding-left: 0px; padding-right: 10px; padding-bottom: 0px;\">";
while (gettype( $file = readdir($dh)) != boolean) {
if ($file != "." && $file != "..") {
if (is_dir("$dir/$file")) {
if (!isset($number)) {
$_SESSION[numb] = "1";
$number = $_SESSION[numb];
}
echo "<tr>";
echo "<td><span style=\"padding-left: 25px;\"> - <a href='#link".$number."' onClick=\"document.getElementById('link".$number."').style.visibility='visible'\">".$file."</a></span></td>";
echo "<td>";
echo "<span id='link".$number."' style=\"visibility: hidden;\">";
$sti = "files/$file/";
$dirhandle = opendir($sti);
echo "<select size=\"1\">";
while($content = readdir($dirhandle)) {
if ($content != "." && $content != "..") {
if (is_file($sti.$content)) {
echo "<option>".$content."</option>";
}
}
}
echo "</select>";
echo "</span>";
echo "</td>";
echo "</tr>";
$number = $number+1;
}
}
}
echo "</table>";
closedir($dh);
?>
</body>
</html>