summaryrefslogtreecommitdiffstats
path: root/phpfspot_img.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpfspot_img.php')
-rw-r--r--phpfspot_img.php35
1 files changed, 26 insertions, 9 deletions
diff --git a/phpfspot_img.php b/phpfspot_img.php
index 3599b2b..5ef76b4 100644
--- a/phpfspot_img.php
+++ b/phpfspot_img.php
@@ -64,13 +64,17 @@ class PHPFSPOT_IMG {
* @param integer $idx
* @param integer $width
*/
- public function showImg($idx, $width = 0)
+ public function showImg($idx, $width = 0, $version = NULL)
{
if($idx == 'rand')
$idx = $this->parent->get_random_photo();
- $details = $this->parent->get_photo_details($idx);
-
+ /* display the lastest available version, if a wrong version has been requested */
+ if(!isset($version) || !$this->parent->is_valid_version($idx, $version))
+ $version = $this->parent->get_latest_version($idx);
+
+ $details = $this->parent->get_photo_details($idx, $version);
+
if(!$details) {
$this->parent->showTextImage("The image (". $idx .") you requested is unknown");
return;
@@ -82,11 +86,15 @@ class PHPFSPOT_IMG {
}
/* show thumbnail */
else {
- /* if no entry for this photo is yet in the database, create thumb */
+
+ /* check for an entry if we already handled this photo before. If not,
+ create a thumbnail for it.
+ */
if(!$this->parent->getMD5($idx)) {
$this->parent->gen_thumb($idx);
}
- $fullpath = $this->parent->get_thumb_path($width, $idx);
+ /* get the full filesystem path to the thumbnail */
+ $fullpath = $this->parent->get_thumb_path($width, $idx, $version);
/* if the thumb file does not exist, create it */
if(!file_exists($fullpath)) {
$this->parent->gen_thumb($idx);
@@ -150,7 +158,10 @@ class PHPFSPOT_IMG {
if(!$this->parent->getMD5($idx)) {
$this->parent->gen_thumb($idx);
}
- $fullpath = $this->parent->get_thumb_path($width, $idx);
+
+ $version = $this->parent­>get_latest_version($idx);
+
+ $fullpath = $this->parent->get_thumb_path($width, $idx, $version);
/* if the thumb file does not exist, create it */
if(!file_exists($fullpath)) {
$this->parent->gen_thumb($idx);
@@ -196,9 +207,16 @@ if(isset($_GET['idx']) && (is_numeric($_GET['idx']) || $_GET['idx'] == 'rand'))
$img = new PHPFSPOT_IMG;
if(isset($_GET['width']) && is_numeric($_GET['width']))
- $img->showImg($_GET['idx'], $_GET['width']);
+ $width = $_GET['width'];
+ else
+ $width = NULL;
+
+ if(isset($_GET['version']) && is_numeric($_GET['version']))
+ $version = $_GET['version'];
else
- $img->showImg($_GET['idx']);
+ $version = NULL;
+
+ $img->showImg($_GET['idx'], $width, $version);
exit(0);
}
@@ -212,5 +230,4 @@ if(isset($_GET['tagidx']) && is_numeric($_GET['tagidx'])) {
}
-
?>