<?php
require './image.class.php';
$server = $_GET['server'];
$width = (int)$_GET['width'];
$height = (int)$_GET['height'];
$cut = (int)$_GET['cut'];
$ext = $_GET['ext'];
$file_path = '';
$file_path .= $server;
$ym = $_GET['ym'];
$dh = $_GET['dh'];
$name = $_GET['name'];
$file_path .= '/'.$ym.'/'.$dh.'/'.$name;
$original = $file_path.$ext;
if (!empty($width)){
	$file_path .= '_'.$width;
}
if (!empty($height)){
	$file_path .= '_'.$height;
}
if (!empty($cut)){
	$file_path .= '_'.$cut;
}
$file_path .= $ext;
$image_types = array('.gif','.png','.jpg','.jpeg','.bmp');
if (in_array($ext, $image_types)){
	if (!empty($width) || !empty($height) || !empty($cut)){
		if (!file_exists($file_path)){//文件不存在
			if (file_exists($original)){
				//生成缩略图
				$image = new image($original);
				$image = $image->thumb($file_path,$width,$height,$cut);
			}
		}
	}
}
header('HTTP/1.1 301 Moved Permanently'); 
header('Location: /'.$file_path.'?v=1.0'); 
exit();