function folderScan($dir) { global $raw; disp("Scanning Folder: {$dir}", 5); # Define image extensions in lower case. $imgExt = array('jpg', 'jpeg', 'png', 'gif', 'bmp', 'tif', 'tiff'); if ($raw) { $imgExt = array_merge($imgExt, array('dng', 'cr2')); } # Add trailing slash to directory if it doesn't exist already. $dir = substr($dir, -1) == "/" ? $dir : $dir . "/"; # Create arrays $result['directories'] = array(); $result['images'] = array(); # If the scan fails. if (!($files = @scandir($dir))) { disp("Failed scanning {$dir}", 2); } # If there were files found. if (count($files) > 0) { foreach ($files as $file) { # Skip all Unix hidden images & directories if (substr($file, 0, 1) == ".") { continue; } # If the 'file' is a directory. if (is_dir($dir . $file)) { $result['directories'][] = $dir . $file; } # If the 'file' is an image file. if (is_file($dir . $file) && hasExt($file, $imgExt)) { $result['images'][] = $dir . $file; } } } return $result; }
function print_gallery_movies($movies) { global $baseURL, $dir; if (count($movies) > 0) { echo "<!-- Begin Movies-->\n"; ?> <script type="text/javascript"> function movie_player(movie,width,height) { var movie=window.open(movie,'','scrollbars=no,menubar=no,height='+height+',width='+width+',resizable=no,toolbar=no,location=no,status=no'); return false; } </script> <?php echo "<div id='movies'>\n"; echo "\t<h3>Movies</h3>\n"; echo "\t<ul>\n"; foreach ($movies as $movie) { if (hasExt($movie, array("mpg", "avi"))) { echo "\t\t<li><a target='_new' href=\"" . rrawurlencode($baseURL . $dir . $movie) . "\">"; echo "{$movie}</a> (" . getFileSize($scriptBase . $dir . $movie) . ")"; echo "</li>\n"; } if (hasExt($movie, "mov")) { echo "\t<li>\n"; echo "\t\t"; print_movie($movie, "qt_player"); echo "</li>\n"; } if (hasExt($movie, array("flv", "f4v", "mp4", "mp3"))) { echo "\t<li>\n"; echo "\t\t"; print_movie($movie, "swf_player"); echo "</li>\n"; } } echo "\t</ul>\n"; echo "</div>\n"; echo "<!-- End Movies-->\n\n"; } }