Rev 787 Rev 788
1 <?php 1 <?php
2 header("Content-type: image/jpeg"); 2 header("Content-type: image/jpeg");
3   3  
4 function file_type($file){ 4 function file_type($file){
5 $path_chunks = explode("/", $file); 5 $path_chunks = explode("/", $file);
6 $thefile = $path_chunks[count($path_chunks) - 1]; 6 $thefile = $path_chunks[count($path_chunks) - 1];
7 $dotpos = strrpos($thefile, "."); 7 $dotpos = strrpos($thefile, ".");
8 return strtolower(substr($thefile, $dotpos + 1)); 8 return strtolower(substr($thefile, $dotpos + 1));
9 } 9 }
10   10  
11 $path = "/var/www/Modules/".$HTTP_GET_VARS["pth"]."/"; 11 $path = "/var/www/Modules/".$HTTP_GET_VARS["pth"]."/";
12 $filename = $HTTP_GET_VARS["fname"]."_Small.jpg"; 12 $filename = $HTTP_GET_VARS["fname"]."_Small.jpg";
13 // $thumbnail = thumbnail_name($filename); 13 // $thumbnail = thumbnail_name($filename);
14 $extension = file_type($filename); 14 $extension = file_type($filename);
15 $remove_thumb = false; 15 $remove_thumb = false;
16   16  
17   17  
18 if(in_array($extension, array('png', 'gif', 'jpg', 'jpeg'))){ 18 if(in_array($extension, array('png', 'gif', 'jpg', 'jpeg'))){
19 if(!$img_size = getimagesize($path.$filename)){ 19 if(!$img_size = getimagesize($path.$filename)){
20 $remove_thumb = true; 20 $remove_thumb = true;
21 } 21 }
22 if($extension == 'gif'){ 22 if($extension == 'gif'){
23 if(!$image = imagecreatefromgif($path.$filename)){ 23 if(!$image = imagecreatefromgif($path.$filename)){
24 $remove_thumb = true; 24 $remove_thumb = true;
25 } 25 }
26 }elseif($extension == 'png'){ 26 }elseif($extension == 'png'){
27 if(!$image = imagecreatefrompng($path.$filename)){ 27 if(!$image = imagecreatefrompng($path.$filename)){
28 $remove_thumb = true; 28 $remove_thumb = true;
29 } 29 }
30 }elseif($extension == 'jpg' || $extension == 'jpeg'){ 30 }elseif($extension == 'jpg' || $extension == 'jpeg'){
31 if(!$image = imagecreatefromjpeg($path.$filename)){ 31 if(!$image = imagecreatefromjpeg($path.$filename)){
32 $remove_thumb = true; 32 $remove_thumb = true;
33 } 33 }
34 } 34 }
-   35 $img_height = $img_size['1'];
-   36 $img_width = $img_size['0'];
35 if($remove_thumb == false){ 37 if($remove_thumb == false){
36   38  
37 $black = ImageColorAllocate($image, 0, 0, 0); 39 $black = ImageColorAllocate($image, 0, 0, 0);
38 ImageString ($image, 3, $thumb_width-80, $thumb_height-15, "www.mlab.cz", $black); 40 ImageString ($image, 3, $img_width-80, $img_height-15, "www.mlab.cz", $black);
39 imagejpeg($image); 41 imagejpeg($image);
40   42  
41 } 43 }
42 }else{ 44 }else{
43 $remove_thumb = true; 45 $remove_thumb = true;
44 } 46 }
45   47  
46   48  
47   49  
48 ?> 50 ?>