View Single Post
Old 02-01-2010, 03:38 AM   #4 (permalink)
andformore
The Wanderer
 
andformore's Avatar
 
Join Date: Dec 2009
Posts: 17
Thanks: 2
andformore is on a distinguished road
Default 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
__________________
Something interesting... If you visit one of my sites today, you'll probably double my unique visitors for the day! Shameless Plugs:
My Blog My Octopus Game My Flash Card Website
andformore is offline  
Reply With Quote