projects
/
bizou.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2dda0f2
)
Did some vars renaming to clarify
author
Marc MAURICE
<dooblempub@positon.org>
Thu, 30 Dec 2010 18:10:44 +0000
(19:10 +0100)
committer
Marc MAURICE
<dooblempub@positon.org>
Thu, 30 Dec 2010 18:10:44 +0000
(19:10 +0100)
plugins/viewer/view.php
patch
|
blob
|
history
diff --git
a/plugins/viewer/view.php
b/plugins/viewer/view.php
index
56fcf11
..
6cac4b0
100644
(file)
--- a/
plugins/viewer/view.php
+++ b/
plugins/viewer/view.php
@@
-17,24
+17,24
@@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-require '../../config.php';
+$bizouRootFromHere = '../..';
+require "$bizouRootFromHere/config.php";
-$simplePath = $_SERVER["PATH_INFO"];
-if ($simplePath == '/') $simplePath = '';
+$simpleImagePath = $_SERVER["PATH_INFO"];
+if ($simpleImagePath == '/') $simpleImagePath = '';
// extra security check to avoid /photos/index/../.. like urls, maybe useless but..
// extra security check to avoid /photos/index/../.. like urls, maybe useless but..
-if (strpos($simplePath, '..') !== false) die(".. found in url");
+if (strpos($simpleImagePath, '..') !== false) die(".. found in url");
-if (! is_file('../../'.IMAGES_DIR.$simplePath)) {
+
+if (! is_file("$bizouRootFromHere/".IMAGES_DIR.$simpleImagePath)) {
header("HTTP/1.1 404 Not Found");
die("File Not Found");
}
header("HTTP/1.1 404 Not Found");
die("File Not Found");
}
-$scriptPath = $_SERVER["SCRIPT_NAME"];
-
// get all images in an array
$images = array();
// get all images in an array
$images = array();
-$files = scandir('../../'.IMAGES_DIR.dirname($simplePath));
+$files = scandir("$bizouRootFromHere/".IMAGES_DIR.dirname($simpleImagePath));
foreach ($files as $file) {
$ext = strtolower(substr($file, -4));
if ($ext == ".jpg" or $ext == ".png")
foreach ($files as $file) {
$ext = strtolower(substr($file, -4));
if ($ext == ".jpg" or $ext == ".png")
@@
-42,7
+42,7
@@
foreach ($files as $file) {
}
// find the image position
}
// find the image position
-$pos = array_search(basename($simplePath), $images);
+$pos = array_search(basename($simpleImagePath), $images);
if ($pos === false) die("Image not found");
// get prev and next images
if ($pos === false) die("Image not found");
// get prev and next images
@@
-53,20
+53,25
@@
if ($pos > 0)
if ($pos < sizeof($images)-1)
$nextImage = $images[$pos+1];
if ($pos < sizeof($images)-1)
$nextImage = $images[$pos+1];
+$scriptUrl = $_SERVER["SCRIPT_NAME"];
+$bizouRootUrl = dirname(dirname(dirname($scriptUrl)));
+// scriptUrl = /path/to/bizou/plugins/viewer/view.php
+// bizouRootUrl = /path/to/bizou
+
// template variables
// template variables
-$imageUrl = dirname($scriptPath)."/../../".IMAGES_DIR.$simplePath;
+$imageUrl = "$bizouRootUrl/".IMAGES_DIR.$simpleImagePath;
if ($nextImage === '') {
$nextImageUrl = '';
$nextPageUrl = '';
} else {
if ($nextImage === '') {
$nextImageUrl = '';
$nextPageUrl = '';
} else {
- $nextImageUrl = dirname($scriptPath)."/".IMAGES_DIR.dirname($simplePath)."/$nextImage";
+ $nextImageUrl = "$bizouRootUrl/".IMAGES_DIR.dirname($simpleImagePath)."/$nextImage";
$nextPageUrl = dirname($_SERVER["REQUEST_URI"])."/$nextImage";
}
if ($prevImage === '') $prevPageUrl = '';
else $prevPageUrl = dirname($_SERVER["REQUEST_URI"])."/$prevImage";
$nextPageUrl = dirname($_SERVER["REQUEST_URI"])."/$nextImage";
}
if ($prevImage === '') $prevPageUrl = '';
else $prevPageUrl = dirname($_SERVER["REQUEST_URI"])."/$prevImage";
-$directoryUrl = dirname($scriptPath)."/../../index.php".dirname($simplePath);
+$directoryUrl = "$bizouRootUrl/index.php".dirname($simpleImagePath);
header('Content-Type: text/html; charset=utf-8');
header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + 3600));
header('Content-Type: text/html; charset=utf-8');
header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + 3600));