3 $quickPath = isset($_SERVER["PATH_INFO"])?$_SERVER["PATH_INFO"]:"";
4 $scriptPath = $_SERVER["SCRIPT_NAME"];
6 $quickDir = dirname($quickPath);
7 $realDir = "images$quickDir";
9 // get all images in an array
12 $files = scandir($realDir);
13 foreach ($files as $file) {
14 $ext = strtolower(substr($file, -4));
15 if ($ext == ".jpg" or $ext == ".png")
19 // find the image position
20 $pos = array_search(basename($quickPath), $images);
21 if ($pos === false) die("Image not found");
23 // get prev and next images
27 $prevImage = $images[$pos-1];
28 if ($pos < sizeof($images))
29 $nextImage = $images[$pos+1];
31 $imageUrl = dirname($scriptPath)."/images$quickPath";
33 if ($nextImage === '') {
37 $nextImageUrl = dirname($scriptPath)."/images".dirname($quickPath)."/$nextImage";
38 $nextPageUrl = dirname($_SERVER["REQUEST_URI"])."/$nextImage";
40 if ($prevImage === '') $prevPageUrl = '';
41 else $prevPageUrl = dirname($_SERVER["REQUEST_URI"])."/$prevImage";
43 $directoryUrl = dirname($_SERVER["SCRIPT_NAME"])."/index".dirname($quickPath);
45 header('Content-Type: text/html; charset=utf-8');
46 header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + 3600));
50 <style type="text/css">
66 text-decoration: none;
68 #next, #previous, #up {
93 <?php if ($nextImageUrl !== '') { ?>
94 <link rel="prefetch" href="<?php echo $nextImageUrl ?>" />
95 <link rel="prefetch" href="<?php echo $nextPageUrl ?>" />
101 <a href="<?php echo $imageUrl ?>"><img src="<?php echo $imageUrl ?>" id="theimage" /></a>
104 <a href="<?php echo $directoryUrl ?>" title="Back to directory">^</a>
107 <?php if ($nextPageUrl !== '') { ?>
109 <a href="<?php echo $nextPageUrl ?>" title="Next image">></a>
113 <?php if ($prevPageUrl !== '') { ?>
115 <a href="<?php echo $nextPageUrl ?>" title="Previous image"><</a>