02-01-2010, 03:38 AM
|
#4 (permalink)
|
|
The Wanderer
Join Date: Dec 2009
Posts: 17
Thanks: 2
|
Not the cleanest
But this should work:
PHP Code:
<html>
<head>
<title>Dir Test</title>
<style type="text/css">
li {
color:green;
}
li.empty{
color:red;
}
</style>
</head>
<body>
<?PHP
function hasFolders($dir){
$hasFolders = false;
$files = glob("$dir/*", GLOB_ONLYDIR);
if(!empty($files))
{
$hasFolders = true;
}
return $hasFolders;
}
function globDir($dir)
{
$files = glob("$dir/*", GLOB_ONLYDIR);
if(!empty($files))
{
echo "<ul>\n";
foreach($files as $file)
{
echo "<li ". (( hasFolders($file) ) ? "" : "class=\"empty\"") ."><b>" . basename($file)."</b>\n";
globDir($file);
echo "</li>\n";
}
echo "</ul>\n";
}
}
$baseDir = "Photos";
globDir($baseDir);
?>
</body>
</html>
As you see, its not dealing with icons, just changing colors, but that is easy enough to change with css.
Also, it is not checking for files existing, only directories, but you should be able to figure that out if you need it. If not, let me know 
|
|
|
|