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/>.
22 // global variables, globals should remain contant
23 $scriptUrl = $_SERVER["SCRIPT_NAME"];
24 $rootUrl = dirname($scriptUrl);
25 if (substr($rootUrl, -1) !== '/') $rootUrl.='/'; // add a trailing / to rootUrl
26 // $scriptUrl = "/path/to/bizou/index.php"
27 // $rootUrl = "/path/to/bizou/"
29 require 'functions.php';
32 // if url == http://localhost/photos/index.php/toto/titi, path_info == /toto/titi
33 // if url == http://localhost/photos/index.php, path_info is not set
34 // if url == http://localhost/photos/, path_info is not set
35 // if path_info is not set, we are at top level, so we redirect to /photos/index.php/
36 if (! isset($_SERVER["PATH_INFO"])) {
37 header("Location: $scriptUrl/");
41 // simplePath is the simple path to the directory
42 // extract /path/to/dir/ from /index.php/path/to/dir/
43 $simplePath = getPathInfo();
45 # realDir is the directory in filesystem
46 # seen from current script directory
47 $realDir = IMAGES_DIR.$simplePath;
49 if (! is_dir($realDir)) {
50 header("HTTP/1.1 404 Not Found");
51 die("Directory Not Found");
55 $imageFiles = array();
56 $otherFiles = array();
58 foreach (scandir($realDir) as $file) if ($file[0] != '.')
60 if (is_dir("$realDir/$file"))
62 $folders[] = array( "name" => $file, "file" => "$realDir/$file", "link" => "$scriptUrl$simplePath/$file" );
66 $ext = strtolower(substr($file, -4));
67 if ($ext == ".jpg" or $ext == ".png") {
68 $imageFiles[] = array( "name" => $file, "file" => "$realDir/$file", "link" => getImageLink("$simplePath/$file") );
70 $otherFiles[] = array( "name" => $file, "link" => "$rootUrl$realDir/$file" );
75 if (dirname($simplePath) !== '')
76 $parentLink = $scriptUrl.dirname($simplePath);
80 plugins_include("before_tpl.php");
82 ///// template starts here /////
83 header('Content-Type: text/html; charset=utf-8');
84 header('Cache-Control: max-age=3600');
86 require 'template.php';