/*******THE SCRIPT************************************/
// Start out with an image count of zero
$count = 0;
// Open the directory of photos
$handle = opendir($photoDir);
while ($file = readdir($handle)) {
// If $file isn't a directory...
if (!is_dir($file)) {
// Set $imageSize
$imageSize = getimagesize($photoDir . "/" . $file);
// If it's an image...
if ($imageSize[3] != "") {
// Stuff its name into an array...
$imageName[$count] = $file;
// And increment the number of images
$count++;
}
}
}
// Close the directory of photos
closedir($handle);
// Get ?image=whatever to see what image the visitor tried to access
if (array_key_exists('image', $_GET)) {
$imageChoice = $_GET['image'];
} else $imageChoice = "";
// If there is at least one photo in the gallery
if (sizeof($imageName) != 0) {
// The default stuff--no particular image has been accessed
if ($imageChoice == "" || !is_numeric($imageChoice)) {
// Start a new div layer
echo " \n";
// Go through the entire array of images...
for ($i=0; $i
\n";
echo "
\n";
echo " \n";
}
// Close the div layer
echo " \n";
// If the visitor tried to access some particular image...
} else if ($imageChoice != "") {
if ($imageChoice > $count) $imageChoice = $count-1;
else if ($imageChoice < 0) $imageChoice = 0;
// Set some variables that are easier to work with
$currentImageSize = getimagesize($photoDir . "/" . $imageName[$imageChoice]);
$width = $currentImageSize[0];
$height = $currentImageSize[1];
$areaWidth = $firstImageWidth + $previousImageWidth + $width + $nextImageWidth + $lastImageWidth + (4 * $spaceBetween) - (2 * $padding);
if (($navChoice == "image" || $navChoice == "both") && sizeof($imageName) > 1) {
// Start a new div layer
echo " \n\n";
// Start a new div layer
echo " \n";
// If we're not at the beginning of the photos...
if ($imageChoice != 0)
// Get a link to the previous full-size image
echo "
\n";
echo "
\n";
echo " \n";
// Close the div layer
echo "
\n\n";
}
// Start a new div
echo " \n";
// Display the current image
echo "

\n";
// Close the div layer
echo "
\n\n";
if (($navChoice == "image" || $navChoice == "both") && sizeof($imageName) > 1) {
// Start a new div layer
echo " \n";
// If we're not at the end of the photos...
if ($imageChoice != (sizeof($imageName)-1))
// Get a link to the next full-size image
echo "
\n";
echo "
\n";
echo " \n";
// Close the div layer
echo "
\n\n";
// Start a new div layer
echo " \n\n";
}
// Start a new div layer
echo " \n";
if (($navChoice == "text" || $navChoice == "both") && sizeof($imageName) > 1) {
// First image link
echo "
" . $firstLinkText . "\n";
// Previous image link
echo "
0) echo ($imageChoice-1);
else echo ($count-1);
echo "\" title=\"Previous\">" . $previousLinkText . "\n";
}
// The information about the photo
switch ($photoNumStyle) {
case 1: echo " Photo #" . ($imageChoice+1) . " of " . $count . "\n"; break;
case 2: echo " " . ($imageChoice+1) . "/" . $count . "\n"; break;
case 3: echo " Photo " . ($imageChoice+1) . "/" . $count . "\n"; break;
default: echo " Photo #" . ($imageChoice+1) . "/" . $count . "\n";
}
if (($navChoice == "text" || $navChoice == "both") && sizeof($imageName) > 1) {
// Next image link
echo "
" . $nextLinkText . "\n";
// Last image link
echo "
" . $lastLinkText . "\n";
}
// Close the div layer
echo "
\n\n";
if (sizeof($imageName) > 1) {
// Start a new div layer
echo " \n";
// Go through all the images in our array of images
for ($i=0; $i
\n";
echo "
\n";
echo " \n";
}
}
// Close the div layer
echo " \n";
}
}
// Otherwise, if there are no photos in the gallery...
} else echo "No photos in gallery.
\n";
?>