X-Git-Url: http://positon.org/gitweb/?p=bizou.git;a=blobdiff_plain;f=index.php;h=828b06c11db67a653530226622ac969c9760b043;hp=9653b31651314b6b9d97283d3b0c85bb1ac60a2a;hb=451e14b16e96be106ada7c474f9cb17621ca25d3;hpb=276926efe8ed6b3a3522a9d2458ec1b384aabc81 diff --git a/index.php b/index.php index 9653b31..828b06c 100644 --- a/index.php +++ b/index.php @@ -19,6 +19,13 @@ require 'config.php'; +// global variables, globals should remain contant +$scriptUrl = $_SERVER["SCRIPT_NAME"]; +$rootUrl = dirname($scriptUrl); +if (substr($rootUrl, -1) !== '/') $rootUrl.='/'; // add a trailing / to rootUrl +// $scriptUrl = "/path/to/bizou/index.php" +// $rootUrl = "/path/to/bizou/" + // load plugins $plugins = array(); if (is_dir("plugins")) { @@ -37,7 +44,7 @@ function plugins_include($phpFile) if (! function_exists('getImageLink')) { function getImageLink($imageSimplePath) { - return dirname($_SERVER["SCRIPT_NAME"]).'/'.IMAGES_DIR.$imageSimplePath; + return $GLOBALS['rootUrl'].IMAGES_DIR.$imageSimplePath; } } @@ -86,7 +93,7 @@ function getPreview($imgFile, $maxSize = THUMB_SIZE) imagedestroy($newImg); } - return dirname($_SERVER["SCRIPT_NAME"])."/".$newImgFile; + return $GLOBALS['rootUrl'].$newImgFile; } function getAlbumPreview($dir) @@ -100,11 +107,6 @@ function getAlbumPreview($dir) return ''; } -$scriptUrl = $_SERVER["SCRIPT_NAME"]; -$rootUrl = dirname($scriptUrl); -// $scriptUrl = "/path/to/bizou/index.php" -// $rootUrl = "/path/to/bizou" - // if url == http://localhost/photos/index.php/toto/titi, path_info == /toto/titi // if url == http://localhost/photos/index.php, path_info is not set // if url == http://localhost/photos/, path_info is not set @@ -146,7 +148,7 @@ foreach (scandir($realDir) as $file) if ($file != '.' and $file != '..') if ($ext == ".jpg" or $ext == ".png") { $imageFiles[] = array( "name" => $file, "url" => getPreview("$realDir/$file"), "link" => getImageLink("$simplePath/$file") ); } else { - $otherFiles[] = array( "name" => $file, "link" => "$rootUrl/$realDir/$file" ); + $otherFiles[] = array( "name" => $file, "link" => "$rootUrl$realDir/$file" ); } } } @@ -205,7 +207,7 @@ a { } - " /> + " />