new photo index icon
[phpfspot.git] / phpfspot_img.php
1 <?php
2
3 require_once "phpfspot_db.php";
4 require_once "phpfspot.class.php";
5
6 class PHPFSPOT_IMG {
7    
8    var $db;
9    var $parent;
10
11    public function __construct()
12    {
13       $this->parent = new PHPFSPOT;
14       $this->db = $this->parent->db;
15
16    } // __construct()
17
18    public function __destruct()
19    {
20
21    } // __desctruct()
22
23    public function show($idx, $width = "")
24    {
25       $this->parent->gen_thumbs($idx);
26
27       $details = $this->parent->get_photo_details($idx);
28
29       if($width == "")
30          $fullpath = $this->parent->translate_path($details['directory_path'])  ."/". $details['name'];
31       else
32          $fullpath = $this->parent->translate_path($details['directory_path'])  ."/thumbs/". $width ."_". $details['name'];
33
34
35       $tmp = getimagesize($fullpath);
36       $mime = $tmp['mime'];
37
38       Header("Content-Type: ". $mime);
39       Header("Content-Length: ". filesize($fullpath));
40       Header("Content-Transfer-Encoding: binary\n");              
41       $user_agent = strtolower ($_SERVER["HTTP_USER_AGENT"]);     
42       Header("Content-Disposition: inline; filename=\"". $details['name'] ."\"");
43       Header("Accept-Ranges: bytes");                             
44       Header("Connection: close");                                
45    
46       $file = fopen($fullpath, "rb");
47       fpassthru($file);
48       @fclose($file);
49
50    } // show()
51
52 }
53
54 if(isset($_GET['idx']) && is_numeric($_GET['idx'])) {
55
56    if(isset($_GET['width']) && is_numeric($_GET['width'])) 
57       $width = $_GET['width'];
58    else
59       $width = "";
60
61    $img = new PHPFSPOT_IMG;
62    $img->show($_GET['idx'], $width);
63 }
64
65 ?>