<?php
#####################################
#  Coded in Pirate Technologies(C)  #
#  ///////////////////////////////  #
# ICQ: 854141                       #
# http://phpme.ru                   #
# http://angelcorpse.free-lance.ru  #
#####################################
require '../system/start.php';
require '../system/functions.php';
error_reporting(0);
header('Content-type: image/jpeg');
$setup['prev_size'] = 80;
$size = int($_GET['wh']);

if(!isset($size) or empty($size) or $size > 3 and $size < 1)
{
	$W = 100; // ширина
	$H = 100;  // высота
}
if(isset($size) and $size == 1)
{
	$W = 128; // ширина
	$H = 128;  // высота
}
if(isset($size) and $size == 2)
{
	$W = 176; // ширина
	$H = 220;  // высота
}
if(isset($size) and $size == 3)
{
	$W = 240; // ширина
	$H = 320;  // высота
}
$id = abs(intval($_GET['id']));

$file_info = mysql_fetch_row(mysql_query("SELECT TRIM(`logo`) FROM `community` WHERE `id` = ".$id." LIMIT 1"));
$path ='files/';
$pic = urldecode(htmlspecialchars($path.$file_info[0]));

if(substr($pic,0,1) != '.'){

if(preg_match('/\.gif$/i', $pic)){$old = imageCreateFromGif($pic);}
elseif(preg_match('/\.jpg$|\.jpeg$|\.jpe$/i', $pic)){$old = imageCreateFromJpeg($pic);}
elseif(preg_match('/\.png$/i', $pic)){$old = imageCreateFromPNG($pic);}
{
$wn = imageSX($old);
$hn = imageSY($old);
$prew = 1;
if(!$W and !$H)
{
$prew = 0;
$size = explode('*',$setup['prev_size']);
$W = round(intval($size[0])); // ширина картинки
$H = round(intval($size[1])); // высота картинки
}
$new = imageCreateTrueColor($W, $H);
imageCopyResampled($new, $old, 0, 0, 0, 0, $W, $H, $wn, $hn);

imageJpeg($new,null,100);
}
}
?>