<?
if (isset($user) && isset($_FILES['file_f']) && ereg('\.', $_FILES['file_f']['name']))
{
$file=esc(stripcslashes(htmlspecialchars($_FILES['file_f']['name'])));
$name=eregi_replace('\.[^\.]*$', NULL, $file); // имя файла без расширения
$ras=strtolower(eregi_replace('^.*\.', NULL, $file));
$tmp_name=$_FILES['file_f']['tmp_name'];
$size=filesize($_FILES['file_f']['tmp_name']);
$type=$_FILES['file_f']['type'];
if ($imgc=@imagecreatefromstring(file_get_contents($_FILES['file_f']['tmp_name'])))
{
if (!isset($err)){
$file_id=$passgen;
//copy($_FILES['file_f']['tmp_name'], H.'blog/files/'.$file_id.'.frf');
$img_x=imagesx($imgc);
$img_y=imagesy($imgc);
if ($img_x==$img_y)
{
$dstW=128; // ширина
$dstH=128; // высота
}
elseif ($img_x>$img_y)
{
$prop=$img_x/$img_y;
$dstW=128;
$dstH=ceil($dstW/$prop);
}
else
{
$prop=$img_y/$img_x;
$dstH=128;
$dstW=ceil($dstH/$prop);
}
$screen=imagecreatetruecolor($dstW, $dstH);
imagecopyresampled($screen, $imgc, 0, 0, 0, 0, $dstW, $dstH, $img_x, $img_y);
//imagedestroy($imgc);
$screen=img_copyright($screen); // наложение копирайта
imagejpeg($screen,H."sys/stena/$file_id.jpg",90);
@chmod(H."sys/stena/$file_id.jpg",0777);
imagedestroy($screen);
imagedestroy($imgc);
msg("Картинка успешно добавлена");
}
}
else
{
$err='Выбранный Вами формат изображения не поддерживается';
}
}
?>