<?
require ("global.php");

if($action1){ 

//如果文件上传，进行处理
eval("dooutput(\"".gettemplate("header")."\");");

//set_time_limit(60); 
// 以确保较大文件上传 

$path1 = dirname($PATH_TRANSLATED); 

$path1=$path1."/upload/";//输出上传路径; 

for($i=1;$i<4;$i++) 

{ 
	$temp1="file".$i; 
	$temptype1=$temp."_type";
	$filetype=$$temptype1;
	$temp2="file".$i."_name"; 
	$source=$$temp1; 
	$source_name=$$temp2; 
	if(($source <> "none")&&($source <> "")) 

	{ 

	$dest = $path1.$source_name; 

	if(!copy($source,$dest))
		{ 

		break; 

		}

	$imagesize = getimagesize($dest); 

switch($imagesize[2]) 

{ 
	case 0: 
		echo "<br>对不起，只能上传GIF和JPG文件！！<br>"; 
		unlink($dest); 
		exit; 
	case 1: 
		echo "<br> GIF文件： <br>"; 
		echo "$dest has a width of $imagesize[0]<br>"; 
		echo "$dest has a height of $imagesize[1]<br>"; 
		$newname = $path1; 
		$nname=$i.time() . ".gif"; 
		$newname .=$nname;

		if(copy($dest,$newname))
		{ 
			echo "<br> GIF文件写入成功 !!!<br>"; 
			//写入文本文件
			$title="t".$i; 
			$title1=$$title; 

			writetofile();

//写入完成
unlink ($dest); 
		}else { 
			echo "<br> GIF Rename Unsuccessful"; 
			} 
	
	break; 

	case 2: 
		echo "<br> Image is a JPG <br>"; 
		echo "$dest has a width of $imagesize[0]<br>"; 
		echo "$dest has a height of $imagesize[1]<br>"; 
		$newname = $path1; 
		$nname=$i.time() . ".jpg"; 
		$newname .=$nname;

		if(copy($dest,$newname))
		{ 
			echo "<br> JPG文件写入成功！！！<br>"; 


//写入文本文件
			//print"写入成功!!!<br>"; 
			
			$title="t".$i; 
			$title1=$$title; 
			writetofile();

//写入完成


unlink ($dest); 

		}else { 
			echo "<br> JPG Rename Unsuccessful"; 
			} 
	
	break; 

	case 3: 
		echo "<br> Image is a PNG <br>"; 
		echo "$dest has a width of $imagesize[0]<br>"; 
		echo "$dest has a height of $imagesize[1]<br>"; 
		$newname = $path1; 
		$nname=$i.time() . ".png"; 
		$newname .=$nname;
		if(copy($dest,$newname))
		{ 
			echo "<br> PNG文件写入成功!!!<"; 


//写入文本文件
			$title="t".$i; 
			$title1=$$title; 
			writetofile();

//写入完成


	unlink ($dest); 
		}else { 
			echo "<br> PNG Rename Unsuccessful"; 
			} 

	break; 
} //end switch
unlink($source); 

}//end if source=none 
?> 
<? 
} //end for 
?> 
<br><a href="index.php">返回</a> 
</font></p> 
<? 
eval("dooutput(\"".gettemplate("footer")."\");");

} 
else { 
eval("dooutput(\"".gettemplate("add")."\");");
} 

?> 
