Файл: www/gp/file.php
Строк: 12
<?php
include '../config.php';
if(isset($_GET['fid'])){
$fid=intval($_GET['fid']);
$r=mysql_fetch_array(mysql_query("SELECT * FROM `group_file` WHERE `id`='$fid'"));
$url='files/'.$r['id_gp'].'/'.$r['file'];
$width=70;
$height=70;}
if(isset($_GET['lid'])){
$lid=intval($_GET['lid']);
$r1=mysql_fetch_array(mysql_query("SELECT * FROM `group_file` WHERE `id`='$lid'"));
$url='files/'.$r1['id_gp'].'/'.$r1['file'];
$width=300;
$height=300;}
$info=getimagesize($url);
$w_or=$info[0];
$h_or=$info[1];
$im1=ImageCreateFromJpeg($url);
if($w_or>$h_or) $k=$w_or/$width; else $k=$h_or/$height;
$w=round($w_or/$k);
$h=round($h_or/$k);
$im2=imagecreatetruecolor($w, $h);
imagecopyresampled($im2, $im1, 0, 0, 0, 0, $w, $h, $w_or, $h_or);
header('Content-type: image/jpeg');
ImageJpeg($im2);
imagedestroy($im2);
?>