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

Размер файла: 1.49Kb
  1. <?php
  2. include('func.php');
  3. include('nast.php');
  4. include('db.php');
  5. $time=time();
  6. $neww=intval($_GET['x']);
  7. $newh=intval($_GET['y']);
  8. $file=mysql_escape_string($file);
  9. $dirname=dirname($file);
  10. $basename=basename($file);
  11. while($file[0]=='/')
  12. $sd=substr($file,1,strlen($file));
  13. $result=mysql_query("SELECT * from `file` WHERE `sd`='$dirname' and `file`='$basename'");
  14. if(
  15. (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))
  16. {
  17. if(!mysql_num_rows($result))
  18. {
  19. mysql_query("INSERT into `file` VALUES(0,'$dirname','$basename','1','".time()."','".filectime($file)."')");}
  20. else
  21. {
  22. $fileinfo=mysql_fetch_array($result);
  23. mysql_query("UPDATE `file` SET `rat`=`rat`+1,`ldate`='$time' WHERE `id`='$fileinfo[id]'");
  24. }
  25. list($sx,$sy, $type,)=@getimagesize($file);
  26. $sxy=round($sx/$sy,3);
  27. $swh=round($neww/$newh,3);
  28. if($sxy<$swh)
  29. $neww=intval($newh*$sxy);
  30. else
  31. $newh=intval($neww/$sxy);
  32. //print "$sxy $swh";
  33. //print "$neww $newh $sx $sy";
  34. if ($type==1) {$funci="imagecreatefromgif";} //$funco="imagegif";}
  35. if ($type==2) {$funci="imagecreatefromjpeg";} //$funco="imagejpeg";}
  36. if ($type==3) {$funci="imagecreatefrompng";} //$funco="imagepng";}
  37. if($type)
  38. {
  39. $im1 = @$funci($file);
  40. $im2=@imagecreatetruecolor($neww,$newh);
  41. @imagecopyresized($im2, $im1, 0,0,0,0,$neww,$newh, @imagesx($im1), @imagesy($im1));
  42.  
  43. @header("Content-type: image/gif");@imagegif($im2);
  44.  
  45. }}
  46.  
  47.  
  48.  
  49. ?>