Файл: vkolhoze.com/img.php
Строк: 58
<?php
if(isset($_GET['id']))$id = intval($_GET['id']); else $id=1;
if(!isset($_GET['ava'])){
include_once 'inc/start_sess.php';
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '$id'"));
//$ank_conf=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_setting` WHERE `id_user` = '$id'"));
// исходное изображение
$img="images/gd_image/back.jpg";
// imagecreatetruecolor - создаёт новое изображение true color
//$image=imagecreatetruecolor($wmW, $wmH);
$image=imagecreatefromjpeg($img);
$size=getimagesize($img);
if($ank['soiler']>0){
$wm=imagecreatefromjpeg('images/gd_image/soil.jpg');
$wmW=imagesx($wm);
$wmH=imagesy($wm);
$cx=$size[0]-$wmW-300;
$cy=$size[1]-$wmH-24;
imagecopyresampled ($image, $wm, $cx, $cy, 0, 0, $wmW, $wmH, $wmW, $wmH);}
if($ank['irregate']>0){
$wm=imagecreatefrompng('images/gd_image/water.png');
$wmW=imagesx($wm);
$wmH=imagesy($wm);
$cx=$size[0]-$wmW-134;
$cy=$size[1]-$wmH-123;
imagecopyresampled ($image, $wm, $cx, $cy, 0, 0, $wmW, $wmH, $wmW, $wmH);}
if($ank['hydropinics_time']>time()){
$wm=imagecreatefromjpeg('images/gd_image/hidra.jpg');
$wmW=imagesx($wm);
$wmH=imagesy($wm);
$cx=$size[0]-$wmW-303;
$cy=$size[1]-$wmH-185;
imagecopyresampled ($image, $wm, $cx, $cy, 0, 0, $wmW, $wmH, $wmW, $wmH);}
if($ank['scarecrow_time']>time()){
$wm=imagecreatefromjpeg('images/gd_image/scarecrow.jpg');
$wmW=imagesx($wm);
$wmH=imagesy($wm);
$cx=$size[0]-$wmW-77;
$cy=$size[1]-$wmH-516;
imagecopyresampled ($image, $wm, $cx, $cy, 0, 0, $wmW, $wmH, $wmW, $wmH);}
if($ank['dog_time']>time()){
$wm=imagecreatefrompng('images/gd_image/dog.png');
$wmW=imagesx($wm);
$wmH=imagesy($wm);
$cx=$size[0]-$wmW-137;
$cy=$size[1]-$wmH-527;
imagecopyresampled ($image, $wm, $cx, $cy, 0, 0, $wmW, $wmH, $wmW, $wmH);}
if($ank['cultivator']>0){
$wm=imagecreatefromjpeg('images/gd_image/cultivate.jpg');
$wmW=imagesx($wm);
$wmH=imagesy($wm);
$cx=$size[0]-$wmW;
$cy=$size[1]-$wmH-223;
imagecopyresampled ($image, $wm, $cx, $cy, 0, 0, $wmW, $wmH, $wmW, $wmH);}
if($ank['seeder']>0){
$wm=imagecreatefrompng('images/gd_image/seat.png');
$wmW=imagesx($wm);
$wmH=imagesy($wm);
$cx=$size[0]-$wmW;
$cy=$size[1]-$wmH-360;
imagecopyresampled ($image, $wm, $cx, $cy, 0, 0, $wmW, $wmH, $wmW, $wmH);}
if($ank['flowerbed']>0){
$wm=imagecreatefromjpeg('images/gd_image/flower.jpg');
$wmW=imagesx($wm);
$wmH=imagesy($wm);
$cx=$size[0]-$wmW-201;
$cy=$size[1]-$wmH-447;
imagecopyresampled ($image, $wm, $cx, $cy, 0, 0, $wmW, $wmH, $wmW, $wmH);}
if($ank['harvester']>0){
$wm=imagecreatefromjpeg('images/gd_image/harvest.jpg');
$wmW=imagesx($wm);
$wmH=imagesy($wm);
$cx=$size[0]-$wmW-307;
$cy=$size[1]-$wmH-324;
imagecopyresampled ($image, $wm, $cx, $cy, 0, 0, $wmW, $wmH, $wmW, $wmH);}
if($ank['arena_rating']>=1000){
$wm=imagecreatefrompng('images/gd_image/arena.png');
$wmW=imagesx($wm);
$wmH=imagesy($wm);
$cx=$size[0]-$wmW-191;
$cy=$size[1]-$wmH-261;
imagecopyresampled ($image, $wm, $cx, $cy, 0, 0, $wmW, $wmH, $wmW, $wmH);}
if($ank['conveyor']>0){
$wm=imagecreatefrompng('images/gd_image/conveyor.png');
$wmW=imagesx($wm);
$wmH=imagesy($wm);
$cx=$size[0]-$wmW;
$cy=$size[1]-$wmH-19;
imagecopyresampled ($image, $wm, $cx, $cy, 0, 0, $wmW, $wmH, $wmW, $wmH);}
if($ank['fooder']>0){
$wm=imagecreatefrompng('images/gd_image/fooder.png');
$wmW=imagesx($wm);
$wmH=imagesy($wm);
$cx=$size[0]-$wmW-36;
$cy=$size[1]-$wmH-77;
imagecopyresampled ($image, $wm, $cx, $cy, 0, 0, $wmW, $wmH, $wmW, $wmH);}
if(isset($_GET['prev'])){
$images = imagecreatetruecolor(120, 160);
imagecopyresampled ($images,$image, 0,0,0,0, 120,160,$size[0], $size[1]);}
/*** imagejpeg - создаёт JPEG-файл filename из изображения image
* третий параметр - качество нового изображение
* параметр является необязательным и имеет диапазон значений
* от 0 (наихудшее качество, наименьший файл)
* до 100 (наилучшее качество, наибольший файл)
* По умолчанию используется значение по умолчанию IJG quality (около 75)
*/
header("Content-type: image/jpeg");
if(isset($_GET['prev']))imageJpeg($images,null,95); else imageJpeg($image,null,95);
// imagedestroy - освобождает память
imagedestroy($image);
if(isset($_GET['prev']))imagedestroy($images);
if(isset($wm))imagedestroy($wm);
// на всякий случай
unset($image,$img);
if(isset($_GET['prev']))unset($images);
}else{
$url='images/avatars/'.$id.'.png';
$form = getimagesize(''.$url.'');
if($form['mime']=='image/jpeg')$wm=imagecreatefromjpeg(''.$url.'');
if($form['mime']=='image/png')$wm=imagecreatefrompng(''.$url.'');
if($form['mime']=='image/gif')$wm=imagecreatefromgif(''.$url.'');
if($form['mime']=='image/bmp')$wm=imagecreatefromwbmp(''.$url.'');
$x=$form[0];
$y=$form[1];
if(empty($x)){print_r($form);}else{
if($x>$y){$koef=round($x/230,3);$ysize = round($y/$koef);$xsize = 230;}else{$koef=round($y/230,3);$xsize = round($x/$koef);$ysize = 230;}
$images = imagecreatetruecolor($xsize, $ysize);
imagecopyresampled ($images,$wm, 0,0,0,0, $xsize,$ysize,$x, $y);
header("Content-type: image/jpeg");
imageJpeg($images,null,95);}
imagedestroy($images);
imagedestroy($wm);
unset($images,$wm);
}
?>