3 require_once "phpfspot.class.php";
10 public function __construct()
12 $this->parent = new PHPFSPOT;
13 $this->db = $this->parent->db;
17 public function __destruct()
22 public function show($idx, $width = 0)
24 $details = $this->parent->get_photo_details($idx);
27 $this->parent->showTextImage("The image you requested is unknown");
31 /* no width specified - show photo in its original size */
33 $fullpath = $this->parent->translate_path($details['directory_path']) ."/". $details['name'];
37 /* if no entry for this photo is yet in the database, create thumb */
38 if(!$this->parent->getMD5($idx)) {
39 $this->parent->gen_thumb($idx);
41 $fullpath = $this->parent->cfg->base_path ."/thumbs/". $width ."_". $this->parent->getMD5($idx);
42 /* if the thumb file does not exist, create it */
43 if(!file_exists($fullpath)) {
44 $this->parent->gen_thumb($idx);
48 if(!file_exists($fullpath)) {
49 $this->parent->showTextImage("File ". basename($fullpath) ." does not exist");
52 if(!is_readable($fullpath)) {
53 $this->parent->showTextImage("File ". basename($fullpath) ." is not readable. Check the permissions");
57 $tmp = getimagesize($fullpath);
60 if(!$this->parent->checkifImageSupported($mime)) {
61 $this->parent->showTextImage("Unsupported Image Type");
65 Header("Content-Type: ". $mime);
66 Header("Content-Length: ". filesize($fullpath));
67 Header("Content-Transfer-Encoding: binary\n");
68 Header("Content-Disposition: inline; filename=\"". $details['name'] ."\"");
69 Header("Accept-Ranges: bytes");
70 Header("Connection: close");
72 $file = fopen($fullpath, "rb");
80 if(isset($_GET['idx']) && is_numeric($_GET['idx'])) {
82 $img = new PHPFSPOT_IMG;
84 if(isset($_GET['width']) && is_numeric($_GET['width']))
85 $img->show($_GET['idx'], $_GET['width']);
87 $img->show($_GET['idx']);