View file imgprev.php

File size: 1.27Kb
<?php
error_reporting(0);
include 'connect.php';
include 'functions.php';
include 'config.php';
$p=@$_GET['p'];
$p=valid_number($p);
$res=mysql_query("SELECT * 
FROM `category`
WHERE `id`='$p'
LIMIT 1");
$arr = mysql_fetch_assoc($res);
$dec=urldecode($arr['array']);
$dec=unserialize($dec);
$f=$_GET['f'];
$f=valid_number($f);
$img=$dec[$f];
$info=getimagesize($img);
$w_or=$info[0];
$h_or=$info[1];
$type=$info['mime'];
$im1='';
if ($type=='image/jpeg') 
$im1=ImageCreateFromJpeg($img);
if ($type=='image/gif') 
$im1=ImageCreateFromGif($img);
if ($type=='image/png') 
$im1=ImageCreateFromPng($img);
if (!$im1)
die('');
if (!isset($_GET['w'])){$w=1;}
else {$w=@$_GET['w'];}
if (!preg_match('/^[\d]+$/iu', $w)){$w=1;}
else {$w=@$_GET['w'];}
if ($w>640){$w=1;}
if (!isset($_GET['h'])){$h=1;}
else {$h=@$_GET['h'];}
if (!preg_match('/^[\d]+$/iu', $h)){$h=1;}
else {$h=@$_GET['h'];}
if ($h>480){$h=1;}
$im2=imagecreatetruecolor($w,$h);
imagecopyresampled($im2,$im1,0,0,0,0,$w,$h,$w_or,$h_or);
if ($type=='image/jpeg')
{header('Content-type:image/jpeg');
ImageJpeg($im2);}
elseif ($type=='image/gif')
{header('Content-type:image/gif');
ImageGif($im2);}
elseif ($type=='image/png')
{header('Content-type:image/png');
ImagePng($im2);}
else die('');
?>