0,0 → 1,51 |
<?php |
/*Hlavièky*/ |
header("Content-type: image/jpeg"); |
|
function file_type($file){ |
$path_chunks = explode("/", $file); |
$thefile = $path_chunks[count($path_chunks) - 1]; |
$dotpos = strrpos($thefile, "."); |
return strtolower(substr($thefile, $dotpos + 1)); |
} |
/*Absolutní cesta k obrázku ($HTTP_GET_VARS["pth"]=parametr pth v adrese stránky)*/ |
$path = "/var/www/Modules/".$HTTP_GET_VARS["pth"]."/"; |
/*Jméno obrázku + suffix*/ |
$filename = $HTTP_GET_VARS["fname"]."_Small.jpg"; |
$extension = file_type($filename); |
$remove_thumb = false; |
|
/*Naètení obrázku*/ |
if(in_array($extension, array('png', 'gif', 'jpg', 'jpeg'))){ |
if(!$img_size = getimagesize($path.$filename)){ |
$remove_thumb = true; |
} |
if($extension == 'gif'){ |
if(!$image = imagecreatefromgif($path.$filename)){ |
$remove_thumb = true; |
} |
}elseif($extension == 'png'){ |
if(!$image = imagecreatefrompng($path.$filename)){ |
$remove_thumb = true; |
} |
}elseif($extension == 'jpg' || $extension == 'jpeg'){ |
if(!$image = imagecreatefromjpeg($path.$filename)){ |
$remove_thumb = true; |
} |
} |
/*Naètení velikosti obrázku*/ |
$img_height = $img_size['1']; |
$img_width = $img_size['0']; |
if($remove_thumb == false){ |
/*Pokud se nemá v rohu obrázku zobrazovat text 'www.mlab.cz' zakomentovat následující 2 øádky*/ |
$black = ImageColorAllocate($image, 0, 0, 0); |
ImageString ($image, 3, $img_width-80, $img_height-15, "www.mlab.cz", $black); |
/*Zobraz obrázek!!!*/ |
imagejpeg($image); |
|
} |
}else{ |
$remove_thumb = true; |
} |
|
?> |