tag) $hSub = 90; // Height of subfolder thumbs $rewrite = 1; // Use mod_rewrite /***** No further user set options below here. *****/ /* TODO: script execution clock */ /* $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $begintime = $time; */ // TODO: the following must also be the same in image_resize.php //$cache_thumbs = 1; // Set to 1 to store thumbs in _di-cache directory in root folder $cache_dir = '_di-cache'; // Name of cache directory if you so choose /* setup the script */ $rootdir = stripslashes(dirname($_SERVER['SCRIPT_NAME'])); $rootlink = htmlentities($rootdir, ENT_QUOTES).'/'; // If not specified, use top folder for gallery name if(!$rootname){ $rootname = explode('/', $rootdir); $rootname = htmlentities(end($rootname), ENT_QUOTES); } if ($_GET[d]) { $d = stripslashes(urldecode($_GET['d'])); // remove escape characters $d .= '/'; // put trailing slash after its converted to a string $current_dir .= $d; $replace = array ("_", "/", "\\"); $with = array (" ", " - ", ""); $title = htmlentities(str_replace($replace, $with, $_GET[d]), ENT_QUOTES); } else $title = 'Home'; if($_GET[v]) $title .= ' - '.htmlentities(str_replace("_", " ", eregi_replace('((\.jpg)|(\.gif)|(\.png))', '', $_GET[v])), ENT_QUOTES); if($rewrite) { if($_GET[d]) $d_string = escape(stripslashes(urldecode($_GET['d']))).'/'; } else { $d_string = '?d='; // for use in passing to URL strings $d_val = stripslashes(escape($_GET['d'])); } if($pg = $_GET['pg']) { $start_from = (($pg-1)*$limit); if($rewrite) $pg_delim = 'page'.$pg.'/'; else $pg_delim = '&pg='.$pg; } else $img = 0; if($rewrite) { $pg_string = 'page'; $pg_term = '/'; } else $pg_string = '&pg='; if($rewrite) $v_string = 'view/'; else $v_string = '&v='; if(ereg("\.\.", $_GET['d'])) // important to prevent browsing upper directories header ("Location: ?"); // additional paramaters for

(thumbnails) - based on whether name or dimensions is displayed $pwidth = $w+12; $pheight = $h+12; if($ititle) $pheight +=10; // increase height of thumbnail

element if($isize || $idim) // if displaying dimensions or size of image, increase height of thumbnail

element. $pheight +=10; /*** Get list of folders ***/ $folder_list = count_folders(); $num_folders = count($folder_list); /*** Get list of Images ***/ $img_list = array(); if ($dir = opendir("./$current_dir")) { while ($file = readdir($dir)) { if ((eregi('((.jpg)|(.gif)|(.png))', $file)) && ($file != $icon)) // Don't add the icon to the list $img_list[] = $file; } closedir($dir); } asort($img_list); // sort alpha $num_images = count($img_list); // total number of images in folder $whole_img_list = $img_list; // save it before we chunk it $paginated = array_chunk($whole_img_list, $limit); if ($pg) $img_list = $paginated[($pg-1)]; $num_remain = $num_images-$start_from; // total remaining thumbs in the array (current directory) ?> <?= $rootname.' - '.$title; ?>

Find out more about Lazy Gallery!

- ($num_folders Folders)" ?> - ($num_images Images)" ?>

Current DIR = '.$_GET[d]); sort($folder_list); return $folder_list; } /*** Folder Navigation ***/ function list_folders($dir) { global $show_folders, $rewrite, $rootlink, $rootname, $d_string, $d_val, $folder_list, $sub_thumbs, $icon, $cache_dir, $wSub, $hSub; if ($show_folders) { echo "
\n"; echo "\n"; echo "
\n\n"; } /* TODO: list of all files one level deep */ /* echo '
sub_img_list (list of folder with first image)
';
print_r($sub_img_list);
echo '
'; */ } /*** Preview Image ***/ function previewPic() { global $rootlink, $d; if ($_GET[v]) { $v = stripslashes($_GET[v]); $iname = eregi_replace('((\.jpg)|(\.gif)|(\.png))', '', $v); $iname = str_replace('_', ' ', $iname); echo "\n\n"; } } /*** random image ***/ function randomPic() { global $rootlink, $d, $d_string, $d_val, $v_string, $whole_img_list, $pg_string, $preview, $random_pic; // array of images. this function must be declared after it. if ($random_pic && $whole_img_list) { $rand_key = array_rand($whole_img_list); $myRandImg = stripslashes($whole_img_list[$rand_key]); echo "\n\n"; } } /*** Page Navigation ***/ function pagenav() // Writes the number of thumbs, remaining pages, next and prev links { global $rootlink, $pg, $pg_string, $pg_term, $start_from, $d_string, $d_val, $limit, $num_images, $num_remain; //TODO: if there are greater than 10 pages, chunk the page array with first and end links. if (($num_images > 0) && ($num_images > $limit)) // do not show page navigation if no images, or less than limit { $page = 0; if(!$pg) $pg = 1; echo "
\n
    \n"; if($start_from > 0) echo "
  • \n"; else echo "
  • "; while($page*$limit < $num_images) { $page ++; unset($cur); if($page == $pg) { $cur = ' class="current"'; } echo "".$page."\n"; } if($num_remain > $limit) echo "
  • \n"; else echo "
  • \n"; echo "
\n
\n"; } } /*** Get image file size ***/ function getfilesize($size) // gets file size for each image { $units = array(' B', ' KB', ' MB', ' GB', ' TB'); for ($i = 0; $size > 1024; $i++) { $size /= 1024; } return round($size, 2).$units[$i]; } //**************************** END FUNCTIONS ***************************** list_folders($current_dir); // write out the directory navigation (folder list) pagenav(); // page links at top of gallery /*** Create Thumbnails and Gallery ***/ echo "
\n"; $img = $start_from; foreach ($img_list as $pic) { $fp = $current_dir.$pic; if($img < $start_from+$limit) { $i_size = getfilesize(filesize($fp)); $i_area = getimagesize($fp); $i_width = $i_area[0]; $i_height = $i_area[1]; //$i_mtime = date("d F Y ", filemtime($fp)); //// TODO possible future expansion for file sort based on date $iname = eregi_replace('((\.jpg)|(\.gif)|(\.png))', '', $pic); $iname = str_replace('_', ' ', $iname); echo "

\n"; if (!$preview) // just link right to the image echo ' '; else // image previewed inside gallery echo ' '; // TODO: possible use the key of whole_img_list instead of sending image name in URL if ($cache_thumbs) { $myPic = $d.$pic; $thumbnailFile = $cache_dir."/".str_replace("/", "_~_", $myPic); //$thumbnailFile = $cache_dir."/".basename($pic); } //TODO: cached thumbnail integration ////if(file_exists($thumbnailFile)) //// echo ''.$pic.''; //// if thumbnail is in cache, do not recreate it. //// will need modification to check if dimensions are correct ////else echo " ".htmlentities($pic, ENT_QUOTES).""; if($ititle) echo "
".htmlentities($iname, ENT_QUOTES).""; if ($idate) echo " - ".date("F d", filemtime($current_dir.$pic)).""; echo "
\n
"; if($idim) echo "$i_width x $i_height"; if($idim && $isize) echo " - "; if ($isize) echo "[$i_size]"; echo "

\n\n"; $img++; } } echo "
\n"; pagenav(); // page links at bottom of gallery /* $time = microtime(); $time = explode(" ", $time); $time = $time[1] + $time[0]; $endtime = $time; $totaltime = ($endtime - $begintime); */ ?>