// php code to handle the gallery error_reporting(E_ALL); // find out what image we want. $this_position = (isset($_GET['p'])) ? ereg_replace('[^0-9]','',$_GET['p']) : 0; // set the allowed format types: $allowed = array('gif','jpg','png'); // set the image directory $dirsource = 'slideshow/'; // Open the gallery directory and see what's in there! $dir = opendir($dirsource); while($file = readdir($dir)) { $extension = substr($file,-3); if (in_array(strtolower($extension),$allowed)) { $fileList[] = $file; } } // make sure someone isn't passing in bogus numbers. if (!isset($fileList[$this_position])) { trigger_error("No such file: $this_position",E_USER_WARNING); $this_position = 0; } $imageAddress = $dirsource . $fileList[$this_position]; $nextImage = $this_position + 1; $previousImage = $this_position -1; $lastImage = count($fileList) - 1; // wrap at the boundaries if ($previousImage < 0) $previousImage = $lastImage; if ($nextImage > $lastImage) $nextImage = 0; $pImgLink = $_SERVER['PHP_SELF'] . '?p=' . $previousImage; $nImgLink = $_SERVER['PHP_SELF'] . '?p=' . $nextImage; ?>