0) { print("

Sub-albums:

\n"); print("\n"); } if (is_dir("$dir/thm") && is_dir("$dir/img")) { if ($subalbums) print("

Photos

\n"); print ("
\n"); $images=getImages($album); foreach ($images as $img) { $albumE=urlencode($album); $fileE=urlencode($img); $name=formName($img); $thumb=htmlspecialchars("$dir/thm/$img"); print("
\n"); print(" \n"); print(" \"$name\"\n"); print(" \n"); print(" \n"); print("
\n"); } print("
\n"); } if ($album != "") { $upAlbum=getParentAlbum($album); print("
Up...
\n"); } foot(); } function displayImage($album, $file) { $dir=getDir($album); $path="$dir/img/$file"; $albumE=urlencode($album); $images = getImages($album); $i = array_search($file, $images); if ($i > 0) { $headlink['previous']['title'] = "Previous"; $prevE = urlencode($images[$i-1]); $headlink['previous']['href'] = "album.php?album=$albumE&file=$prevE"; } if ($i+1 < count($images)) { $headlink['next']['title'] = "Next"; $nextE = urlencode($images[$i+1]); $headlink['next']['href'] = "album.php?album=$albumE&file=$nextE"; } $headlink['contents']['title'] = "Contents"; $headlink['contents']['href'] = "album.php?album=$albumE"; $headlink['up']['title'] = "Up"; $headlink['up']['href'] = "album.php?album=$albumE"; $title=formName($file); $sideBarName=formName(preg_replace("'/.*$'", "", $album)); include_once("base.php"); print("
\n"); print(" \"$title\"\n"); print("
\n"); print("
\n"); print("
Up...
\n"); if (isset($prevE)) print(" \"Previous\"\n"); if (isset($nextE)) print(" \"Next\"\n"); print("
\n"); print("\n"); print("\n"); } function getParentAlbum($album) { if (strpos($album, "/") != false) return preg_replace("'/.*?$'","", $album); else return ""; } function getDir($album) { if ($album == "") return "photos"; else return "photos/" . $album; } function formName($file) { $reducedName = preg_replace("'\..*?$'i", "", $file); $dontCapitalise = array("and", "or", "e", "non"); $words = explode("_", $reducedName); for ($i=0; $i 1) sort($images); return $images; } function getSubalbums($album) { $dir=getDir($album); $handle = opendir($dir); while(false != ($file = readdir($handle))) { if (! is_dir("$dir/$file") || $file == "." || $file == ".." || $file == "thm" || $file == "img") continue; $subalbums[]=$file; } if (count($subalbums) > 1) sort($subalbums); return $subalbums; } function foot() { print("
All Images Copyright © Rivera family.
\n"); print(" Album generated in Python and presented via PHP.
\n"); print("\n"); print("\n"); } function album() { if (isset($_REQUEST['album'])) $album = $_REQUEST['album']; else die("No Album!"); if (isset($_REQUEST['file'])) { $file = $_REQUEST['file']; if (strpos($name, "/") != false || ! is_file(getDir($album) . "/img/$file")) die("Bad File!"); } if (substr($album, 0, 1) == "/" || (strlen($album) > 1 && substr($album, -1) == "/") || strpos($album, "/..") != false || strpos($album, "../") != false || ! is_dir(getDir($album))) die("Bad Album!"); if (isset($file)) displayImage($album, $file); else thumbnails($album); } ?>