<?php
/*
转移水印图片和small水印图片
用在 watermark.php watermarkstr.php
*/

	$temppic=$_FILES['picFile']['tmp_name'];
	//$picFile=$_FILES['picFile']['tmp_name']==''?$wt_rows['wtImage']:$_FILES['picFile']['tmp_name'];
	if(file_exists($temppic) ) //水印复制
	{
		list($wtmwidth, $wtmheight, $wtmtype, $wtmattr)  = getimagesize($temppic);//获取文件类型
		switch($wtmtype)
		{
			//waterMarkPic 在constant中定义
			case 1:   $extname = ".gif";break;  
			case 2:   $extname = ".jpg";break;
			case 3:   $extname = ".png";break;
			default: return("水印图片文件类型错误，只能是.gif,.jpg.png");
		}

		$waterMarkFile=$waterMarkPic.$extname; //$waterMarkPic in constant
		$smallWTPic=$waterMarkPicSmall.$extname;
		copy($temppic,$waterMarkFile);
		//$smallWTPic="images/watermarksmall.png";
		$picwh=getimagewh($temppic);
		$smallTWPicW=$SmallPicW/$BigPicW*$picwh[0];
		$smallTWPicH=$SmallPicW/$BigPicW*$picwh[1];
		ImageResize($temppic,$smallTWPicW,$smallTWPicH,$smallWTPic);  // ls_admin/images 在生成水印小图
		
		$picFile=$waterMarkFile;
	}
	else
	{
		if($wt_rows['wtImage']!='')	
		{
			$picFile=$wt_rows['wtImage'];
			$smallWTPic	=$waterMarkPicSmall.".".substr($picFile,-3);
			$waterMarkFile=$picFile;
		}
	}
?>