Просмотр файла zagrcent/imgload.php

Размер файла: 1.49Kb
<?php
include('func.php');
include('nast.php');
include('db.php');
$time=time();
$neww=intval($_GET['x']);
$newh=intval($_GET['y']);
$file=mysql_escape_string($file);
$dirname=dirname($file);
$basename=basename($file);
while($file[0]=='/')
$sd=substr($file,1,strlen($file));
$result=mysql_query("SELECT * from `file` WHERE `sd`='$dirname' and `file`='$basename'");
if(
(in_array(r($file), $imagef)) and (!in_array(r($file,1), $progf) and !in_array(r($file,1), $temaf) and !in_array(r($file,1), $videof)) and !strstr($dirname,"..") and file_exists($file))
	{
if(!mysql_num_rows($result))
{
mysql_query("INSERT into `file` VALUES(0,'$dirname','$basename','1','".time()."','".filectime($file)."')");}
else
{
$fileinfo=mysql_fetch_array($result);
mysql_query("UPDATE `file` SET `rat`=`rat`+1,`ldate`='$time' WHERE `id`='$fileinfo[id]'");
}
list($sx,$sy, $type,)=@getimagesize($file);
$sxy=round($sx/$sy,3);
$swh=round($neww/$newh,3);
if($sxy<$swh)
$neww=intval($newh*$sxy);
else
$newh=intval($neww/$sxy);
//print "$sxy $swh";
//print "$neww $newh $sx $sy";
if ($type==1) {$funci="imagecreatefromgif";} //$funco="imagegif";}
if ($type==2) {$funci="imagecreatefromjpeg";} //$funco="imagejpeg";}
if ($type==3) {$funci="imagecreatefrompng";} //$funco="imagepng";}
if($type)
{
$im1 = @$funci($file);
$im2=@imagecreatetruecolor($neww,$newh); 
@imagecopyresized($im2, $im1, 0,0,0,0,$neww,$newh, @imagesx($im1), @imagesy($im1));

@header("Content-type: image/gif");@imagegif($im2);

}}



?>