X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=phpfspot.git;a=blobdiff_plain;f=phpfspot_img.php;h=ce3731b3fe92522a855efff12618b31c1793444c;hp=bd811e85ce2d26e6738ed3dec1e9206065631a29;hb=8de7a22ceac0fab9eb984854758608d7aeb079d3;hpb=6e2d319e3b4fb0aac55413bbcc121669a19e3720 diff --git a/phpfspot_img.php b/phpfspot_img.php index bd811e8..ce3731b 100644 --- a/phpfspot_img.php +++ b/phpfspot_img.php @@ -28,6 +28,9 @@ class PHPFSPOT_IMG { var $db; var $parent; + /** + * PHPFSPOT_IMG class constructor + */ public function __construct() { $this->parent = new PHPFSPOT; @@ -35,17 +38,31 @@ class PHPFSPOT_IMG { } // __construct() + /** + * PHPFSPOT_IMG class destructor + */ public function __destruct() { } // __desctruct() + /** + * sends the specified image to the browser + * + * this function will send the specified image to + * the client - in the specified width. it also try's + * to create on-the-fly missing thumbnails via PHPFSPOT + * gen_thumbs function. + */ public function show($idx, $width = 0) { + if($idx == 'rand') + $idx = $this->parent->get_random_photo(); + $details = $this->parent->get_photo_details($idx); if(!$details) { - $this->parent->showTextImage("The image you requested is unknown"); + $this->parent->showTextImage("The image (". $idx .") you requested is unknown"); return; } @@ -59,7 +76,7 @@ class PHPFSPOT_IMG { if(!$this->parent->getMD5($idx)) { $this->parent->gen_thumb($idx); } - $fullpath = $this->parent->cfg->base_path ."/thumbs/". $width ."_". $this->parent->getMD5($idx); + $fullpath = $this->parent->get_thumb_path($width, $idx); /* if the thumb file does not exist, create it */ if(!file_exists($fullpath)) { $this->parent->gen_thumb($idx); @@ -89,7 +106,10 @@ class PHPFSPOT_IMG { Header("Content-Disposition: inline; filename=\"". $details['name'] ."\""); Header("Accept-Ranges: bytes"); Header("Connection: close"); - + Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); + Header("Cache-Control: no-cache"); + Header("Pragma: no-cache"); + $file = fopen($fullpath, "rb"); fpassthru($file); @fclose($file); @@ -98,7 +118,7 @@ class PHPFSPOT_IMG { } -if(isset($_GET['idx']) && is_numeric($_GET['idx'])) { +if(isset($_GET['idx']) && (is_numeric($_GET['idx']) || $_GET['idx'] == 'rand')) { $img = new PHPFSPOT_IMG;