909 |
miho |
1 |
<?php |
|
|
2 |
/*Hlavièky*/ |
|
|
3 |
header("Content-type: image/jpeg"); |
|
|
4 |
|
|
|
5 |
function file_type($file){ |
|
|
6 |
$path_chunks = explode("/", $file); |
|
|
7 |
$thefile = $path_chunks[count($path_chunks) - 1]; |
|
|
8 |
$dotpos = strrpos($thefile, "."); |
|
|
9 |
return strtolower(substr($thefile, $dotpos + 1)); |
|
|
10 |
} |
|
|
11 |
/*Absolutní cesta k obrázku ($HTTP_GET_VARS["pth"]=parametr pth v adrese stránky)*/ |
|
|
12 |
$path = "/var/www/Modules/".$HTTP_GET_VARS["pth"]."/"; |
|
|
13 |
/*Jméno obrázku + suffix*/ |
|
|
14 |
$filename = $HTTP_GET_VARS["fname"]."_Small.jpg"; |
|
|
15 |
$extension = file_type($filename); |
|
|
16 |
$remove_thumb = false; |
|
|
17 |
|
|
|
18 |
/*Naètení obrázku*/ |
|
|
19 |
if(in_array($extension, array('png', 'gif', 'jpg', 'jpeg'))){ |
|
|
20 |
if(!$img_size = getimagesize($path.$filename)){ |
|
|
21 |
$remove_thumb = true; |
|
|
22 |
} |
|
|
23 |
if($extension == 'gif'){ |
|
|
24 |
if(!$image = imagecreatefromgif($path.$filename)){ |
|
|
25 |
$remove_thumb = true; |
|
|
26 |
} |
|
|
27 |
}elseif($extension == 'png'){ |
|
|
28 |
if(!$image = imagecreatefrompng($path.$filename)){ |
|
|
29 |
$remove_thumb = true; |
|
|
30 |
} |
|
|
31 |
}elseif($extension == 'jpg' || $extension == 'jpeg'){ |
|
|
32 |
if(!$image = imagecreatefromjpeg($path.$filename)){ |
|
|
33 |
$remove_thumb = true; |
|
|
34 |
} |
|
|
35 |
} |
|
|
36 |
/*Naètení velikosti obrázku*/ |
|
|
37 |
$img_height = $img_size['1']; |
|
|
38 |
$img_width = $img_size['0']; |
|
|
39 |
if($remove_thumb == false){ |
|
|
40 |
/*Pokud se nemá v rohu obrázku zobrazovat text 'www.mlab.cz' zakomentovat následující 2 øádky*/ |
|
|
41 |
$black = ImageColorAllocate($image, 0, 0, 0); |
|
|
42 |
ImageString ($image, 3, $img_width-80, $img_height-15, "www.mlab.cz", $black); |
|
|
43 |
/*Zobraz obrázek!!!*/ |
|
|
44 |
imagejpeg($image); |
|
|
45 |
|
|
|
46 |
} |
|
|
47 |
}else{ |
|
|
48 |
$remove_thumb = true; |
|
|
49 |
} |
|
|
50 |
|
|
|
51 |
?> |