<?
session_start(); 
?>
<?php echo "<?xml version=\"1.0\" encoding=\"utf-8\"?".">"; ?>

<?
	ob_clean();
	require_once('../../../../ru/update/2.55/ls_admin/inc/conn.php');
	require_once('../../../../ru/update/2.55/ls_admin/inc/constant.php');
	require_once('../../../../ru/update/2.55/ls_admin/inc/ls_syscode.php');

	$opendb=new mydb();
	require_once('../../../../ru/update/2.55/ls_admin/inc/char_set.php');

	$wt_sql="select * from ls_watermark where ID=1";
	$wt_query=$opendb->query($wt_sql);
	$wt_rows=mysql_fetch_assoc($wt_query);
	$submit2=$_POST['submit2'];
	$selectpic=$_POST['selectpic'];
	$testfile=$_POST['testfile'];
	$checkstring="checked";		//default string
	if($_GET['desPic'])
	{$desPic=urldecode($_GET['desPic']);}  // flash this page then get desPic
	
	$test_sql="select * from ls_products where productID is not null and productName is not null and productPic is not null and enable=1 limit 0,15 ";
	//$test_sql="select * from ls_products";
	$test_query=$opendb->query($test_sql);
	$select_rows2=mysql_num_rows($test_query); //总数
	if($select_rows2!=0)
	{
	$test_rows=mysql_fetch_assoc($test_query);
	$testfilefolder="../".getproductfolder($test_rows['productID'])."/".$BigFoldersProducts."/";
	if($testfile=="")
	{
		$testfile=$testfilefolder.$test_rows['productPic'];
	}
	if($submit2=="测试水印")
	{
		$wtString=$_POST['wtString'];
		$wtFont=$_POST['wtFont'];
		$wtSize=$_POST['wtSize'];
		$wtColor=$_POST['wtColor'];
		$wtPosition=$_POST['wtPosition'];
		$allPic=$_POST['allPic'];
		$wtType=$_POST['wtType'];
		$srcPic=$testfile;
		$picFile=$_FILES['picFile']['tmp_name'];
		$localpicFile=$_POST['localpicFile'];

		list($srcwidth, $srcheight, $srctype, $srcattr) = getimagesize($testfile);//获取文件类型
	  	if($srctype==1)
		{
 		  	$desPic="images/testwtk.gif";
		}
		if($srctype==2)
		{ 
 		  	$desPic="images/testwtk.jpg";
 	 	}
		if($srctype==3)
 	  	{
 		  	$desPic="images/testwtk.png";
		}

		addWatermark($srcPic,$desPic,$wtString,$wtFont,$wtSize,$wtColor,$wtPosition,$wtType,$picFile);
		
		echo " 测试水印已生成： ".$desPic." <a href='watermarkstr.php?desPic=".urlencode($desPic)."'> 请刷新本页查看</a>";
		
	}else{
		$wtString=$wt_rows['wtString'];
		$wtFont=$wt_rows['wtFont'];
		$wtSize=$wt_rows['wtSize'];
		$wtColor=$wt_rows['wtColor'];
		$wtPosition=$wt_rows['wtPosition'];
		$date=$wt_rows['date'];
		$wtImage=$wt_rows['wtImage']; 
		if($wtString==NULL&&$wtImage!=NULL)
		{$wtType="pic";}

	}
	} //	if($select_rows2!=0)
	else
	{
		echo " 没有产品，请添加。"; 
	}
	
	if($wtType=="pic")
	{$checkpic="checked";}
	else
	{$checkstring="checked";}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../../../../ru/update/2.55/ls_admin/css/admin.css" rel="stylesheet" type="text/css">
<title>无标题文档</title></head>

<body>
<p>&nbsp;</p>
<table width="96%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#6396d6">
  <tr>
	<td height="18" background="../../../../ru/update/2.55/ls_admin/images/admin_bg.gif"><div align="center"><strong><font color="#ffffff">设置水印属性并生成</font></strong></div></td>
  </tr>
  <tr>
	<td height="213" valign="top" bgcolor="#dee7ff"><br />
		<table border="0" width="90%" align="center">
		  <tr>
			<td>&nbsp;</td>
		  </tr>
		</table>
		<form name="watermark" id="watermark" action="../../../../ru/update/2.55/ls_admin/watermark.php" method="post" enctype="multipart/form-data" >
		  <table width="90%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF">
			<tr align="center" bgcolor="#B9DAFF">
			  <td height="77" colspan="3" >
			  <? if($desPic!="") 
			  {	  echo  "<img src=\"".$desPic."\" name=\"testpic\"  border=\"0\" style='margin:15;' />" ;}
			  else
			  {   echo  "<img src=\"".$testfile."\" name=\"testpic\"  border=\"0\" style='margin:15;'  />";} 
			  ?>			  </td>
			</tr>
			<tr bgcolor="#B9DAFF">
			  <td height="53" colspan="3"><div align="center">
				<input type="hidden" name="testfile" id="hiddenField4" value="<? echo $testfile ?>"/>
				<select name="selectpic" id="select"  onchange="javascript:document.testpic.src=watermark.selectpic.value;watermark.testfile.value=watermark.selectpic.value;">
				  <? while($test_rows=mysql_fetch_assoc($test_query))
			  {
			  		$testfilefolder="../".getproductfolder($test_rows['productID'])."/".$BigFoldersProducts."/";
				   echo " <option value=\"".$testfilefolder.$test_rows['productPic']."\">".$test_rows['productName']."</option>\n";
			   }
			  ?>  
				</select>
				
				可以选择一个图片进行水印生成测试 
				<input name="submit2" type="submit" value="测试水印" onclick="javascript:watermark.action='watermarkstr.php';"/>
			  </div></td>
			</tr>
			<tr bgcolor="#B9DAFF">
			  <td height="83" colspan="3" style='padding-left:20px;'><span style="padding-left:3.0em;"><img src="../../../../ru/update/2.55/ls_admin/images/picture.gif" name="pic"  border="0" id="pic" style="float:left;" /></span></td>
			</tr>
			<tr bgcolor="#B9DAFF">
			  
			<td height="28" style='padding-left:20px;'><input name="radio3" type="radio" id="radio8" onclick="javascript:document.watermark.wtType.value='pic';document.watermark.picFile.enabled;" value="radio3" <?=$checkpic?> />
			  水印图片: 
			  <input type="file" name="picFile" id="fileField" onblur="document.pic.src=watermark.picFile.value;document.watermark.localpicFile.value=watermark.picFile.value;" value="<? echo $localpicFile ?>"/ ></td>
			  <td colspan="2" style='padding-left:20px;'><input name="wtType" type="hidden" id="hiddenField3" value="string" />
			  <input type="hidden" name="localpicFile" id="localpicFile" /></td>
			</tr>
			<tr bgcolor="#B9DAFF">
			  <td width="51%" height="28" style='padding-left:20px;'>
				<input name="radio3" type="radio" id="radio7" value="radio3" onclick="javascript:document.watermark.wtType.value='string';" <?=$checkstring?>/>
				水印文字:
				<input type="text" name="wtString" value="<? echo $wtString; ?>"/></td>
			  
			<td colspan="2" style='padding-left:20px;'>颜色值:
<input type="text" name="wtColor" value="<? echo $wtColor; ?>"/></td>
			</tr>
			<tr bgcolor="#B9DAFF">
			  
			<td height="28" style='padding-left:20px;'>字体:&nbsp;
<input type="text" name="wtFont" value="<? echo $wtFont; ?>" /></td>
			  
			<td colspan="2" style='padding-left:20px;'>大小:&nbsp;
<input type="text" name="wtSize" value="<? echo $wtSize;?>" /></td>
			</tr>
			<tr bgcolor="#B9DAFF">
			  
			<td height="28" style='padding-left:20px;'>位置:&nbsp;
<input name="position" type="radio" id="radio4" value="1" checked="checked" onclick="javascript:document.watermark.wtPosition.value=1;"/>
				偏下
				<input type="radio" name="position" id="radio5" value="2" onclick="javascript:document.watermark.wtPosition.value=2;"/>
				居中
				<input type="radio" name="position" id="radio6" value="3" onclick="javascript:document.watermark.wtPosition.value=3;"/>
				偏上
				<input type="hidden" name="wtPosition" id="hiddenField2" value="1" /></td>
			  
			<td colspan="2" style='padding-left:20px;'>上次日期:&nbsp; 
			  <input type="text" name="size" value="<? echo $wt_rows['date']; ?>" /></td>
			</tr>
			<tr bgcolor="#B9DAFF">
			  <td height="34" colspan="3" style='padding-left:20px;'>
				<div align="center">
				  <input name="all" type="radio" id="radio2" value="1" checked="checked" onclick="javascript:document.watermark.allPic.value=0;"/>
				新增图片
				<input name="all" type="radio" id="radio" value="1" onclick="javascript:document.watermark.allPic.value=1;"/>
			  全部图片</div></td>
			</tr>
			<tr bgcolor="#B9DAFF">
			  <td height="93" colspan="3" style='padding-left:20px;'><div align="center"><br />
				<input name="submit" type="submit" id="submit3" value="生成水印" />
  <input type="hidden" name="allPic" id="hiddenField" value="0" />
  <br />
			  </div>
				<br />
				注：“全部图片”指重新全部生成一遍水印；“新增图片”是指只生成上次日期以后新增图片的水印生成			  </td>
			</tr>
		  </table>
		<br />
		<table width="90%" border="0" align="center">
		  <tr>
			<td><div align="center">
				<input name="submit3" type="submit" id="submit" value="清除全部水印"  onclick="javascript:document.watermark.clearallWatermark.value=1;"/>
				<input type="hidden" name="clearallWatermark" id="clearallWatermark" value="0" />
			  </div></td>
		  </tr>
		</table>
		<br />
		  <br />
	  </form></td>
  </tr>
</table>
<p>&nbsp;</p>
</body>
</html>
