Fixed a bug when bizou was operating at the top root of a site
Thanks to pilau who detected it
This commit is contained in:
parent
276926efe8
commit
451e14b16e
3 changed files with 17 additions and 14 deletions
20
index.php
20
index.php
|
@ -19,6 +19,13 @@
|
||||||
|
|
||||||
require 'config.php';
|
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
|
// load plugins
|
||||||
$plugins = array();
|
$plugins = array();
|
||||||
if (is_dir("plugins")) {
|
if (is_dir("plugins")) {
|
||||||
|
@ -37,7 +44,7 @@ function plugins_include($phpFile)
|
||||||
if (! function_exists('getImageLink')) {
|
if (! function_exists('getImageLink')) {
|
||||||
function getImageLink($imageSimplePath)
|
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);
|
imagedestroy($newImg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return dirname($_SERVER["SCRIPT_NAME"])."/".$newImgFile;
|
return $GLOBALS['rootUrl'].$newImgFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAlbumPreview($dir)
|
function getAlbumPreview($dir)
|
||||||
|
@ -100,11 +107,6 @@ function getAlbumPreview($dir)
|
||||||
return '';
|
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/toto/titi, path_info == /toto/titi
|
||||||
// if url == http://localhost/photos/index.php, path_info is not set
|
// if url == http://localhost/photos/index.php, path_info is not set
|
||||||
// if url == http://localhost/photos/, 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") {
|
if ($ext == ".jpg" or $ext == ".png") {
|
||||||
$imageFiles[] = array( "name" => $file, "url" => getPreview("$realDir/$file"), "link" => getImageLink("$simplePath/$file") );
|
$imageFiles[] = array( "name" => $file, "url" => getPreview("$realDir/$file"), "link" => getImageLink("$simplePath/$file") );
|
||||||
} else {
|
} else {
|
||||||
$otherFiles[] = array( "name" => $file, "link" => "$rootUrl/$realDir/$file" );
|
$otherFiles[] = array( "name" => $file, "link" => "$rootUrl$realDir/$file" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,7 +207,7 @@ a {
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<?php foreach ($plugins as $p) if (is_file("plugins/$p/style.css")) { ?>
|
<?php foreach ($plugins as $p) if (is_file("plugins/$p/style.css")) { ?>
|
||||||
<link rel="stylesheet" type="text/css" href="<?php echo "$rootUrl/plugins/$p/style.css" ?>" />
|
<link rel="stylesheet" type="text/css" href="<?php echo $rootUrl."plugins/$p/style.css" ?>" />
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
function getImageLink($imageSimplePath)
|
function getImageLink($imageSimplePath)
|
||||||
{
|
{
|
||||||
return dirname($_SERVER["SCRIPT_NAME"])."/plugins/viewer/view.php$imageSimplePath";
|
return $GLOBALS['rootUrl']."plugins/viewer/view.php$imageSimplePath";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -55,23 +55,24 @@ if ($pos < sizeof($images)-1)
|
||||||
|
|
||||||
$scriptUrl = $_SERVER["SCRIPT_NAME"];
|
$scriptUrl = $_SERVER["SCRIPT_NAME"];
|
||||||
$bizouRootUrl = dirname(dirname(dirname($scriptUrl)));
|
$bizouRootUrl = dirname(dirname(dirname($scriptUrl)));
|
||||||
|
if (substr($bizouRootUrl, -1) !== '/') $bizouRootUrl.='/'; // add a trailing / to rootUrl
|
||||||
// scriptUrl = /path/to/bizou/plugins/viewer/view.php
|
// scriptUrl = /path/to/bizou/plugins/viewer/view.php
|
||||||
// bizouRootUrl = /path/to/bizou
|
// bizouRootUrl = /path/to/bizou/
|
||||||
|
|
||||||
// template variables
|
// template variables
|
||||||
$imageUrl = "$bizouRootUrl/".IMAGES_DIR.$simpleImagePath;
|
$imageUrl = $bizouRootUrl.IMAGES_DIR.$simpleImagePath;
|
||||||
|
|
||||||
if ($nextImage === '') {
|
if ($nextImage === '') {
|
||||||
$nextImageUrl = '';
|
$nextImageUrl = '';
|
||||||
$nextPageUrl = '';
|
$nextPageUrl = '';
|
||||||
} else {
|
} else {
|
||||||
$nextImageUrl = "$bizouRootUrl/".IMAGES_DIR.dirname($simpleImagePath)."/$nextImage";
|
$nextImageUrl = $bizouRootUrl.IMAGES_DIR.dirname($simpleImagePath)."/$nextImage";
|
||||||
$nextPageUrl = dirname($_SERVER["REQUEST_URI"])."/$nextImage";
|
$nextPageUrl = dirname($_SERVER["REQUEST_URI"])."/$nextImage";
|
||||||
}
|
}
|
||||||
if ($prevImage === '') $prevPageUrl = '';
|
if ($prevImage === '') $prevPageUrl = '';
|
||||||
else $prevPageUrl = dirname($_SERVER["REQUEST_URI"])."/$prevImage";
|
else $prevPageUrl = dirname($_SERVER["REQUEST_URI"])."/$prevImage";
|
||||||
|
|
||||||
$directoryUrl = "$bizouRootUrl/index.php".dirname($simpleImagePath);
|
$directoryUrl = $bizouRootUrl."index.php".dirname($simpleImagePath);
|
||||||
|
|
||||||
$firefox = strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false;
|
$firefox = strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue