Photos: WP-3D Scientists and Crew\n";
$dirArr = array();
$ind = 0;
$photopath = "$albumName/formatted";
$displayThumb=1; //flag for whether to show thumbnails or larger photos
$d = opendir($photopath) or die($php_errormsg); //get array of all photos in directory
while(false !==($f = readdir($d))) {
if ((stristr($photopath.$f, '.jpg')) && (!preg_match('/^._/', $f))) { //all files containing .jpg and not starting in "._"
$dirArr[$ind] = $f;
$ind+=1;
}
}
closedir($d);
sort($dirArr); //sort array by file name
$maxNum = count($dirArr); // number of photos in directory
if (array_key_exists('num', $_GET)) { //use this if user clicks on link under image (next or previous). Get corresponding large photo.
$photoNum = trim($_GET['num']); //get the value passed in by the "GET" method
if (!is_numeric($photoNum)) {
$photoNum = 0;
}
$photoName = $dirArr[$photoNum]; //get the name of the photo from knowing the array position
$displayThumb=0; //don't display thumbnail
getPhoto($photoNum, $photoName, $maxNum, $albumName); //call the function which displays the photo.
} else {
if ($displayThumb==1) { //do display the thumbnails
echo "
";
} //if displayThumb=1
} // if array_key_exists
?>