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