Rev 786 | Rev 787 | ||
---|---|---|---|
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 | if($remove_thumb == false){ |
35 | if($remove_thumb == false){ |
36 | |
36 | |
37 | $black = ImageColorAllocate($thumb, 0, 0, 0); |
37 | $black = ImageColorAllocate($image, 0, 0, 0); |
38 | ImageString ($thumb, 3, $thumb_width-80, $thumb_height-15, "www.mlab.cz", $black); |
38 | ImageString ($image, 3, $thumb_width-80, $thumb_height-15, "www.mlab.cz", $black); |
39 | imagejpeg($image); |
39 | imagejpeg($image); |
40 | |
40 | |
41 | } |
41 | } |
42 | }else{ |
42 | }else{ |
43 | $remove_thumb = true; |
43 | $remove_thumb = true; |
44 | } |
44 | } |
45 | |
45 | |
46 | |
46 | |
47 | |
47 | |
48 | ?> |
48 | ?> |