fixes in varables names...
This commit is contained in:
parent
924290855d
commit
a4fb65e857
1 changed files with 12 additions and 10 deletions
22
view.php
22
view.php
|
@ -1,15 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$quickPath = isset($_SERVER["PATH_INFO"])?$_SERVER["PATH_INFO"]:"";
|
$shortPath = $_SERVER["PATH_INFO"];
|
||||||
$scriptPath = $_SERVER["SCRIPT_NAME"];
|
if ($shortPath == '/') $shortPath = '';
|
||||||
|
// extra security check to avoid /photos/index/../.. like urls, maybe useless but..
|
||||||
|
if (strpos($shortPath, '..') !== false) die(".. found in url");
|
||||||
|
|
||||||
$quickDir = dirname($quickPath);
|
$scriptPath = $_SERVER["SCRIPT_NAME"];
|
||||||
$realDir = "images$quickDir";
|
|
||||||
|
|
||||||
// get all images in an array
|
// get all images in an array
|
||||||
$images = array();
|
$images = array();
|
||||||
|
|
||||||
$files = scandir($realDir);
|
$files = scandir("images".dirname($shortPath));
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
$ext = strtolower(substr($file, -4));
|
$ext = strtolower(substr($file, -4));
|
||||||
if ($ext == ".jpg" or $ext == ".png")
|
if ($ext == ".jpg" or $ext == ".png")
|
||||||
|
@ -17,7 +18,7 @@ foreach ($files as $file) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// find the image position
|
// find the image position
|
||||||
$pos = array_search(basename($quickPath), $images);
|
$pos = array_search(basename($shortPath), $images);
|
||||||
if ($pos === false) die("Image not found");
|
if ($pos === false) die("Image not found");
|
||||||
|
|
||||||
// get prev and next images
|
// get prev and next images
|
||||||
|
@ -28,19 +29,20 @@ if ($pos > 0)
|
||||||
if ($pos < sizeof($images))
|
if ($pos < sizeof($images))
|
||||||
$nextImage = $images[$pos+1];
|
$nextImage = $images[$pos+1];
|
||||||
|
|
||||||
$imageUrl = dirname($scriptPath)."/images$quickPath";
|
// template variables
|
||||||
|
$imageUrl = dirname($scriptPath)."/images$shortPath";
|
||||||
|
|
||||||
if ($nextImage === '') {
|
if ($nextImage === '') {
|
||||||
$nextImageUrl = '';
|
$nextImageUrl = '';
|
||||||
$nextPageUrl = '';
|
$nextPageUrl = '';
|
||||||
} else {
|
} else {
|
||||||
$nextImageUrl = dirname($scriptPath)."/images".dirname($quickPath)."/$nextImage";
|
$nextImageUrl = dirname($scriptPath)."/images".dirname($shortPath)."/$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 = dirname($_SERVER["SCRIPT_NAME"])."/index".dirname($quickPath);
|
$directoryUrl = dirname($_SERVER["SCRIPT_NAME"])."/index".dirname($shortPath);
|
||||||
|
|
||||||
header('Content-Type: text/html; charset=utf-8');
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + 3600));
|
header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + 3600));
|
||||||
|
@ -112,7 +114,7 @@ img {
|
||||||
|
|
||||||
<?php if ($prevPageUrl !== '') { ?>
|
<?php if ($prevPageUrl !== '') { ?>
|
||||||
<div id="previous">
|
<div id="previous">
|
||||||
<a href="<?php echo $nextPageUrl ?>" title="Previous image"><</a>
|
<a href="<?php echo $prevPageUrl ?>" title="Previous image"><</a>
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue