<?php
    // gallery.php
   
    switch ($action):
    case "g_default":
     
    // settings window
    drawMainTop();
     
     
     
    drawMainBottom();
    // decide which directories to apply processing to
    drawMainTop();
     
    $dirname = "/home/brian/public_html/images/digital";
    $processQueue = listDirsInDir($dirname);
     
    foreach($processQueue as $i)
    {
        print "$i<br>";
         
    }
     
    drawMainBottom();
    break;
    endswitch;
     
       
     
     
     
    //////////////////////
    // function library //
    //////////////////////
     
     
     
     
    function createQueue($dirname)
    {
         
         
        if ($dirname[strlen($dirname)-1] != '/')
            $dirname .= '/';
         
        $handle = opendir($dirname);
        while ($file = readdir($handle))
        {
            //print $file;
            if ($file == '.' || $file == '..')
                continue;
            if (is_dir($dirname.$file))
            {
                $result_string[] = createQueue($dirname.$file);
            }
            else
            {
                //TODO: Come up with a better way to filter pictures
                //in que for previously thumbnailed copys of pictures
                //and also for other non-picture files that shouldn't be
                //being parsed by the system.  Basically only put the original,
                //to-be processed pictures in the queue.
                if (!stristr($dirname.$file, "-md.jpg") && !stristr($dirname.$file, "-sm.jpg") && !stristr($dirname.$file, "-tm.jpg") && stristr($dirname.$file, ".jpg"))
                {
                    $result_string[] = $dirname.$file;
                }
                 
            }
             
        }
        closedir($handle);
        return $result_string;
    }
     
     
    function createDirQueue($dirname)
    {
        if ($dirname[strlen($dirname)-1] != '/')
            $dirname .= '/';
         
        $handle = opendir($dirname);
        while ($file = readdir($handle))
        {
            //print $file;
            if ($file == '.' || $file == '..')
                continue;
            if (is_dir($dirname.$file))
            {
                $result_string[] = $dirname.$file;
                $result_string[] = createDirQueue($dirname.$file);
            }
             
             
        }
        closedir($handle);
        return $result_string;
    }
     
    function listDirsInDir($dirname)
    {
        if ($dirname[strlen($dirname)-1] != '/')
            $dirname .= '/';
         
        $handle = opendir($dirname);
        while ($file = readdir($handle))
        {
            //print $file;
            if ($file == '.' || $file == '..')
                continue;
            if (is_dir($dirname.$file))
            {
                $result_string[] = $dirname.$file;
            }
             
             
        }
        closedir($handle);
        return $result_string;
    }
     
     
?>
