<?php
error_reporting(7);
define('R_P', dirname(dirname(__FILE__)));
if(empty($_COOKIE['admin_auth'])) exit();
$editName = urldecode($_GET['src']);
$info = parse_url($editName);
if(empty($info['host']) || strpos($editName, '..') !== false) exit();
$exp = 3600;
header("Content-Type: image/jpeg");
header("Expires: " .gmdate ("D, d M Y H:i:s", time() + $exp). " GMT");
header("Cache-Control: max-age={$exp}");
header("Pragma: Public");
$index = strpos($editName, "/attachment/");
if($index === false) exit();
$filename = R_P .'/'. substr($editName,  $index+1);
$out_w = intval($_GET['width']);
$out_h = intval($_GET['height']);
if($out_w > 300 || $out_w < 16) $out_w = 48;
if($out_h > 300 || $out_h < 16) $out_h = 48;
require_once(R_P . "/include/class.resizeimage.php");
$resize = new resizeimage($filename);
$rs = $resize->init();
if($rs != 0){
	header("location:images/blank.gif");
	exit();
}
$resize->run($out_w, $out_h, 1, '', 60);
$resize->close();
?>