3 /***************************************************************************
5 * phpfspot, presents your F-Spot photo collection in Web browsers.
7 * Copyright (c) by Andreas Unterkircher
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 ***************************************************************************/
25 require_once "phpfspot.class.php";
33 * PHPFSPOT_IMG class constructor
35 public function __construct()
37 $this->parent = new PHPFSPOT;
38 $this->db = $this->parent->db;
43 * PHPFSPOT_IMG class destructor
45 public function __destruct()
51 * sends the specified image to the browser
53 * this function will send the specified image to
54 * the client - in the specified width. it also try's
55 * to create on-the-fly missing thumbnails via PHPFSPOT
56 * gen_thumbs function.
58 public function show($idx, $width = 0)
61 $idx = $this->parent->get_random_photo();
63 $details = $this->parent->get_photo_details($idx);
66 $this->parent->showTextImage("The image (". $idx .") you requested is unknown");
70 /* no width specified - show photo in its original size */
72 $fullpath = $this->parent->translate_path($this->parent->parse_uri($details['uri'], 'fullpath'));
76 /* if no entry for this photo is yet in the database, create thumb */
77 if(!$this->parent->getMD5($idx)) {
78 $this->parent->gen_thumb($idx);
80 $fullpath = $this->parent->get_thumb_path($width, $idx);
81 /* if the thumb file does not exist, create it */
82 if(!file_exists($fullpath)) {
83 $this->parent->gen_thumb($idx);
87 if(!file_exists($fullpath)) {
88 $this->parent->showTextImage("File ". basename($fullpath) ." does not exist");
91 if(!is_readable($fullpath)) {
92 $this->parent->showTextImage("File ". basename($fullpath) ." is not readable. Check the permissions");
96 $tmp = getimagesize($fullpath);
99 if(!$this->parent->checkifImageSupported($mime)) {
100 $this->parent->showTextImage("Unsupported Image Type");
104 Header("Content-Type: ". $mime);
105 Header("Content-Length: ". filesize($fullpath));
106 Header("Content-Transfer-Encoding: binary\n");
107 Header("Content-Disposition: inline; filename=\"". $this->parent->parse_uri($details['uri'], 'filename') ."\"");
108 Header("Content-Description: ". $this->parent->parse_uri($details['uri'], 'filename'));
109 Header("Accept-Ranges: bytes");
110 Header("Connection: close");
111 Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
112 Header("Cache-Control: no-cache");
113 Header("Pragma: no-cache");
115 $file = fopen($fullpath, "rb");
123 if(isset($_GET['idx']) && (is_numeric($_GET['idx']) || $_GET['idx'] == 'rand')) {
125 $img = new PHPFSPOT_IMG;
127 if(isset($_GET['width']) && is_numeric($_GET['width']))
128 $img->show($_GET['idx'], $_GET['width']);
130 $img->show($_GET['idx']);