3 Bizou - a (french) KISS php image gallery
4 Copyright (C) 2010 Marc MAURICE
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 define('IMAGES_DIR', 'images');
22 $shortPath = $_SERVER["PATH_INFO"];
23 if ($shortPath == '/') $shortPath = '';
24 // extra security check to avoid /photos/index/../.. like urls, maybe useless but..
25 if (strpos($shortPath, '..') !== false) die(".. found in url");
27 $scriptPath = $_SERVER["SCRIPT_NAME"];
29 // get all images in an array
32 $files = scandir(IMAGES_DIR.dirname($shortPath));
33 foreach ($files as $file) {
34 $ext = strtolower(substr($file, -4));
35 if ($ext == ".jpg" or $ext == ".png")
39 // find the image position
40 $pos = array_search(basename($shortPath), $images);
41 if ($pos === false) die("Image not found");
43 // get prev and next images
47 $prevImage = $images[$pos-1];
48 if ($pos < sizeof($images)-1)
49 $nextImage = $images[$pos+1];
52 $imageUrl = dirname($scriptPath)."/".IMAGES_DIR.$shortPath;
54 if ($nextImage === '') {
58 $nextImageUrl = dirname($scriptPath)."/".IMAGES_DIR.dirname($shortPath)."/$nextImage";
59 $nextPageUrl = dirname($_SERVER["REQUEST_URI"])."/$nextImage";
61 if ($prevImage === '') $prevPageUrl = '';
62 else $prevPageUrl = dirname($_SERVER["REQUEST_URI"])."/$prevImage";
64 $directoryUrl = dirname($_SERVER["SCRIPT_NAME"])."/index.php".dirname($shortPath);
66 header('Content-Type: text/html; charset=utf-8');
67 header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + 3600));
71 <style type="text/css">
87 text-decoration: none;
89 #next, #previous, #up {
114 <?php if ($nextImageUrl !== '') { ?>
115 <link rel="prefetch" href="<?php echo $nextImageUrl ?>" />
116 <link rel="prefetch" href="<?php echo $nextPageUrl ?>" />
122 <a href="<?php echo $imageUrl ?>"><img src="<?php echo $imageUrl ?>" id="theimage" /></a>
125 <a href="<?php echo $directoryUrl ?>" title="Back to directory">^</a>
128 <?php if ($nextPageUrl !== '') { ?>
130 <a href="<?php echo $nextPageUrl ?>" title="Next image">></a>
134 <?php if ($prevPageUrl !== '') { ?>
136 <a href="<?php echo $prevPageUrl ?>" title="Previous image"><</a>