Просмотр файла imgprev.php

Размер файла: 1.27Kb
  1. <?php
  2. error_reporting(0);
  3. include 'connect.php';
  4. include 'functions.php';
  5. include 'config.php';
  6. $p=@$_GET['p'];
  7. $p=valid_number($p);
  8. $res=mysql_query("SELECT *
  9. FROM `category`
  10. WHERE `id`='$p'
  11. LIMIT 1");
  12. $arr = mysql_fetch_assoc($res);
  13. $dec=urldecode($arr['array']);
  14. $dec=unserialize($dec);
  15. $f=$_GET['f'];
  16. $f=valid_number($f);
  17. $img=$dec[$f];
  18. $info=getimagesize($img);
  19. $w_or=$info[0];
  20. $h_or=$info[1];
  21. $type=$info['mime'];
  22. $im1='';
  23. if ($type=='image/jpeg')
  24. $im1=ImageCreateFromJpeg($img);
  25. if ($type=='image/gif')
  26. $im1=ImageCreateFromGif($img);
  27. if ($type=='image/png')
  28. $im1=ImageCreateFromPng($img);
  29. if (!$im1)
  30. die('');
  31. if (!isset($_GET['w'])){$w=1;}
  32. else {$w=@$_GET['w'];}
  33. if (!preg_match('/^[\d]+$/iu', $w)){$w=1;}
  34. else {$w=@$_GET['w'];}
  35. if ($w>640){$w=1;}
  36. if (!isset($_GET['h'])){$h=1;}
  37. else {$h=@$_GET['h'];}
  38. if (!preg_match('/^[\d]+$/iu', $h)){$h=1;}
  39. else {$h=@$_GET['h'];}
  40. if ($h>480){$h=1;}
  41. $im2=imagecreatetruecolor($w,$h);
  42. imagecopyresampled($im2,$im1,0,0,0,0,$w,$h,$w_or,$h_or);
  43. if ($type=='image/jpeg')
  44. {header('Content-type:image/jpeg');
  45. ImageJpeg($im2);}
  46. elseif ($type=='image/gif')
  47. {header('Content-type:image/gif');
  48. ImageGif($im2);}
  49. elseif ($type=='image/png')
  50. {header('Content-type:image/png');
  51. ImagePng($im2);}
  52. else die('');
  53. ?>