Can anyone tell me what's wrong with this code? It should display all folders within the main folder and it should be recursive.
function list_files ($root,$path_ext = "",$check_ext = "",$new_path_ext = "") {
$username = $GLOBALS["username"];
$dh = opendir("../users/$username");
while(false !== ($entry=readdir($dh))) {
if($entry != "." && $entry != ".." && is_dir($root.$path_ext.$new_path_ext."/".$entry)) {
$prev_path_ext = $new_path_ext;
if ($root == "../users/$username") {
echo "<span style='width: 10px;'></span><input type='radio' name='file' value='$root$new_path_ext/$entry'><img src='images/folder.jpg'><span style='width: 5px;'></span>$entry/<br>\n";
} else {
echo "<span style='width: ".(10 * $GLOBALS['level'])."px;'></span><input type='radio' name='file' value='$root$new_path_ext/$entry'><img src='images/folder.jpg'><span style='width: 5px;'></span>$entry/<br>\n";
}
$new_path_ext .= $entry;
$GLOBALS["level"] += 1;
list_files ($root."/".$new_path_ext, "", "", "");
} elseif($entry != "." && $entry != ".." && eregi("($check_ext)",$entry) && !is_dir($root.$path_ext.$new_path_ext."/".$entry)) {
if ($root != "../users/$username") {
echo "<span style='width: ".(10 * $GLOBALS['level'])."px;'></span><input type='radio' name='file' value='$root$new_path_ext/$entry'><img src='images/file.jpg'><span style='width: 10px'></span>$entry<br>\n";
} else {
echo "<span style='width: 10px;'></span><input type='radio' name='file' value='$root$new_path_ext/$entry'><img src='images/file.jpg'><span style='width: 10px'></span>$entry<br>\n";
}
}
}
closedir($dh);
}