View file premiym_zone/img.php

File size: 1.32Kb
<?php
header("Content-type:image/jpeg");

$pic = urldecode(htmlspecialchars(str_replace("../", "", "$_GET[img]")));
list($width, $height) = getimagesize($pic);

if(!empty($_GET['prev']))
 {
  $qual = "20";
 }
else
 {
  $qual = "80";
 }

if(empty($_GET['wid']) && empty($_GET['hei']))
 {
  $W = intval("50");
  $H = $height / ($width / $W);
 }
elseif(empty($_GET['wid']))
 {
  $H = intval("$_GET[hei]");
  $W = $width / ($height / $H);
 }
elseif(empty($_GET['hei']))
 {
  $W = intval("$_GET[wid]");
  $H = $height / ($width / $W);
 }
 
if(!empty($_POST['wid']) && !empty($_POST['hei']))
 {
  $W = intval("$_POST[wid]");
  $H = intval("$_POST[hei]");
  if($W < $H)
   {
    $H = $height / ($width / $W);
   }
  if($W > $H)
   {
    $W = $width / ($height / $H);
   }
 }

$pic = str_replace("./", "", "$pic");
if(substr($pic,0,1)!=".")
 {
  if(ereg("\.gif$", $pic)) 
   {
    $old = imageCreateFromGif("$pic");
   }
  if(ereg("\.jpg$|\.jpeg$|\.jpe$", $pic))
   {
    $old = imageCreateFromJpeg("$pic");
   }
  if(ereg("\.png$", $pic))
   {
    $old = imageCreateFromPNG("$pic");
   }
   {
    $w = imageSX($old);
    $h = imageSY($old);
    $new = imageCreateTrueColor($W, $H);
    imageCopyResized($new, $old, 0, 0, 0, 0, $W, $H, $w, $h);
    imageJPEG($new,"","$qual");
   }
 }
?>