<?php
  ##########################################
## Àâòîð: Ãîâíî êîäûðü -=ØÀÕÒÅÐ=-           #  
## Ñàéò: http://masteram.us ICQ  : 46-92-90 #
### Âåðñèÿ 4.0 Ëèöåíçèîííàÿ                 #
## Äàííàÿ âåðñèÿ ñêðèïòà ÿâëÿëàñü ÏËÀÒÍÎÉ,  #
## âû ÍÅ ÈÌÅËÈ ÏÐÀÂÀ ðàñïðîñòðÿíÿòü äàííûé  #
## ñêðèïò èëè êàêèå-ëèáî ÷àñòè åãî êîäà...  #
## À ÒÅÏÅÐÜ ÑÂÑÅÌ ÍÀ ÝÒÎ ÏÎÕÓÉ!!!)))        #
  #########################################
require'config.php';

$w = intval($_GET['w']);
$h = intval($_GET['h']);
$foto = intval($_GET['foto']);

$f = $db->sql_fetchrow($db->sql_query("Select * from foto_add where id = '".$foto."'"));


$img = 'files/album/album_'.$f['album'].'_'.$f['id'].$f['format'].'';

$array=explode(".", $img);
$type=$array[1];

$name = $img;

function resizeimage($name, $type, $w, $h)
{
$ratio=$w/$h;
$size_image=getimagesize($name);
$src_ratio=$size_image[0]/$size_image[1];
if($ratio<$src_ratio)
$h=$w/$src_ratio;
else $w=$h*$src_ratio;
$destroy=imagecreatetruecolor($w, $h);

if(strtolower($type)=="jpg") $src_image=imagecreatefromjpeg($name);
elseif(strtolower($type)=="gif") $src_image=imagecreatefromgif($name);
else $src_image=imagecreatefrompng($name);

if(!@imagecopyresampled($destroy, $src_image, 0, 0, 0, 0, $w, $h, $size_image[0], $size_image[1])) return false;

if(strtolower($type)=="jpg")
{
header("Content-type: image/jpeg");
imagejpeg($destroy);
}
if(strtolower($type)=="gif")
{
header("Content-type: image/gif");
imagegif($destroy);
}
 if(strtolower($type)=="png")
{
header("Content-type: image/png");
imagepng($destroy);
}
 if(strtolower($type)=="jpeg")
{
header("Content-type: image/jpeg");
imagepng($destroy);
}
 if(strtolower($type)=="bmp")
{
header("Content-type: image/bmp");
imagepng($destroy);
}
imagedestroy($destroy);
imagedestroy($src_image);
return TRUE;

}

resizeimage($img, $type, $w, $h);

?>