/**
  * Our own implementation of the glob function for those sites which run a version
  * of php lower than 4.3. For more information on the function glob:
  * http://www.php.net/manual/en/function.glob.php
  *
  * Returns an array with all the files and subdirs that match the given shell expression.
  * @param folder Where to start searching.
  * @param pattern A shell expression including wildcards '*' and '?' defining which
  * files will match and which will not.
  * @return An array with the matching files and false if error.
  */
 function myGlob($folder = ".", $pattern = "*")
 {
     // Note that !== did not exist until 4.0.0-RC2
     // what if the temp folder is deleted?  or $folder is not exist? then will raise
     // ugly error or warning message. so first check if $folder readable
     if (!file_exists($folder)) {
         return array();
     }
     if ($handle = opendir($folder)) {
         $files = array();
         while (false !== ($file = readdir($handle))) {
             if ($file != "." && $file != "..") {
                 // ignore '.' and '..'
                 if (Glob::fnmatch($pattern, $file)) {
                     if ($folder[strlen($folder) - 1] != "/") {
                         $filePath = $folder . "/" . $file;
                     } else {
                         $filePath = $folder . $file;
                     }
                     array_push($files, $filePath);
                 }
             }
         }
         closedir($handle);
     } else {
         return array();
     }
     return $files;
 }