"; $dir = $_GET['dir']; $picid=$_GET['picid']; if (!isset($dir) && !isset($picid)) { print "

Gallery

"; print "
You can also download all original pics as a zip file (542MB!!)

"; } function file_type($file) { $path_chunks = explode("/", $file); $thefile = $path_chunks[count($path_chunks) - 1]; $dotpos = strrpos($thefile, "."); return strtolower(substr($thefile, $dotpos + 1)); } $file_types = array('jpeg', 'jpg'); $file_count = 0; $subpath = "gallery/"; $thumbpath = "thumbs"; $path = "pics/" . $subpath . $dir . "/"; # read gallery dir for next/prev $p = opendir("pics/" . $subpath); while (false !== ($dirname = readdir($p))) { $dirs[] = $dirname; } rsort($dirs); foreach ($dirs as $directory) { $extension = file_type($directory); if($directory != '.' && $directory != '..' && array_search($extension, $file_types) !== true) { $diritems[] = $directory; $maxdirs++; } } $maxdirs = $maxdirs-1; $tpath = $path . $thumbpath; if (isset($dir)) { $parentdir = array_search($dir,$diritems); if ($parentdir > 0) $prev=$parentdir-1; if ($parentdir < $maxdirs) $next=$parentdir+1; $p = opendir($path); while (false !== ($filename = readdir($p))) { $files[] = $filename; } sort($files); if (!isset($picid)) { print "
"; print ($parentdir>0) ? "prev\n " : "prev\n "; print " | Gallery index\n | "; print ($parentdir < $maxdirs) ? " next\n" : " next\n"; print "\n \n"; $pics = 5; $cols = $pics; $picid = 0; foreach ($files as $file) { $extension = file_type($file); if($file != '.' && $file != '..' && array_search($extension, $file_types) !== false) { $size = getimagesize($tpath . "/" . $file); $file_count++; print"\n"; $picid++; $cols++; print ($cols % $pics == 0) ? "\n" : ""; } } if($file_count == 0) { echo "No file match your file types\n"; } print "


\n"; print"
\n"; } else { $maxfiles=0; foreach ($files as $file) { $extension = file_type($file); if($file != '.' && $file != '..' && array_search($extension, $file_types) !== false) { $maxfiles++; $pics[] = $file; } } $maxfiles = $maxfiles-1; if ($picid > 0) $prev=$picid-1; if ($picid < $maxfiles) $next=$picid+1; $size=getimagesize($path . $pics[$picid]); print "
\n"; print "Gallery index
\n"; print ($picid>0) ? "prev\n " : "prev\n "; print "| index\n |"; print ($picid < $maxfiles) ? " next\n" : " next\n"; print "

"; print ($picid>0) ? "prev\n " : "prev\n "; print "| index\n |"; print ($picid < $maxfiles) ? " next\n" : " next\n"; print "
\n \n"; } } else { # generate minipics view print "
\n"; $path = "pics/" . $subpath; if (count($diritems) != "0") { foreach ($diritems as $dir) { print $dir . "
\n \n \n"; if ($dir != "" && $dir != '..' && $dir != '.') { $file_count=0; unset($files); $path = "pics/gallery/" . $dir . "/minipics"; $file_types = array('jpeg', 'jpg', 'JPG'); if (is_dir($path)) { $p = opendir($path); while (false !== ($filename = readdir($p))) { $files[] = $filename; } sort($files); foreach ($files as $file) { $extension = file_type($file); if($file != '.' && $file != '..' && array_search($extension, $file_types) !== false) { $file_count++; if ($file_count<=8) { $size = getimagesize($path . "/" . $file); print "\n"; } } } } if ($file_count == 0) { print "\n"; } if ($file_count>0) { print ""; } } print "\n
"; print "  
\n Gallery available, but no Pics in it!\n
" . $file_count . " Pics
\n
\n "; } } else { print "No Gallery available! \n"; } } ?>