<!--#include file=../conn.asp-->
<!--#include file="inc/const.asp" -->
<!--#include file="../Dv_Plus/Avatar/Plus_Avatar_Const.asp" -->
<%
Head()
Server.ScriptTimeout=9999999
Dim Avatar_Setting
If Not Dvbbs.Master Or InStr("," & Session("Flag") & ",", ",38,") = 0 Then
	ErrMsg = ErrMsg & "<BR><li>本页面为管理员专用，请<a href=../admin_login.asp target=_top>登录</a>后进入。<br><li>您没有管理本页面的权限。"
	Call Dvbbs_Error()
Else
	If Request("action")="save" Then
		Call SaveConst()
	ElseIf Request("action")="cleanbg" Then
		Call CleanBg()
	ElseIf Request("action")="import" Then
		Call ImportItems()
	Else
		Call Consted()
	End If
	Footer()
End If

Sub Consted()
	Dim AvatarRs
	
	Set AvatarRs = Dvbbs.Plus_Execute("Select * From Dv_Plus_Avatar_Config")
	Avatar_Setting = Split(AvatarRs("Avatar_Setting"), ",")
%>
	<br>
	<script language="javascript">
	function ValidateServer() {
		var ServerURL = document.getElementById("ServerURL").value;
		if(ServerURL == "") {
			alert("请首先指定正确的远程服务器地址！");
			return false;
		}
		ServerURL = "../Plus_Avatar_Photo.asp?action=xml&testurl=" + ServerURL;
		
		var xslDoc = CreateXmlDocument();
		if (!xslDoc){ throw new Error('你的电脑不支持XML，无法验证远程服务器！');return false; }
		xslDoc.async = false;
		xslDoc.validateOnParse = false;
		xslDoc.load(ServerURL);
		function CreateXmlDocument() {
			if(document.implementation && document.implementation.createDocument) {
				var doc = document.implementation.createDocument("", "", null);
				if(doc.readyState == null) {
					doc.readyState = 1;
					doc.addEventListener("load", function () {
						doc.readyState = 4;
						if(typeof doc.onreadystatechange == "function")
							doc.onreadystatechange();
					}, false);
				}
				return doc;
			} else if (window.ActiveXObject) {
				var prefix = ["MSXML3","MSXML2","MSXML","Microsoft"];
				for (var i=0;i<prefix.length;i++) {
					try {
						var doc = new ActiveXObject(prefix[i] + ".DOMDocument");
						if (doc) {
							return doc;
						}		
					} catch (e) {}
				}
			}
			return null;
		};
		if (xslDoc.parseError){
			if (xslDoc.parseError.errorCode!=0){
				alert(xslDoc.parseError.reason);
				return false;
			}
		}
		var nodeList=xslDoc.documentElement.getElementsByTagName("AvatarInfo");
		if (nodeList!=null) {
			if (nodeList[0].getAttribute("AllowRemoteCreatePhoto") == '-1') {
				alert("指定的不是一个远程服务器！")
				return false;
			} else if (nodeList[0].getAttribute("AllowRemoteCreatePhoto") == '1') {
				document.getElementById("IsAllow").checked = true;
				document.getElementById("NormalPrice").value = nodeList[0].getAttribute("NormalRemoteCreatePrice");
				document.getElementById("VIPPrice").value = nodeList[0].getAttribute("VIPRemoteCreatePrice");
			} else {
				document.getElementById("IsAllow").checked = false;
				document.getElementById("NormalPrice").value = "";
				document.getElementById("VIPPrice").value = "";
			}
		} else {
			alert("指定的不是一个远程服务器！")
			return false;
		}
		if(document.getElementById("IsAllow").checked)
			alert("指定的服务器是一个正常的远程服务器，此时开启了远程生成照片服务！")
		else
			alert("指定的服务器是一个正常的远程服务器，但是此时关闭了远程生成照片服务！")
		return true;
	}
	</script>
	<table width="95%" border="0" cellspacing="1" cellpadding="3"  align=center class="tableBorder">
		<tr><th height="25" colspan="5" align=left> &nbsp;功能设置导航</th></tr>
		<tr> 
		<td width="100%" class=Forumrow colspan=5 height=25>
		[<a href="#setting1">基本设置</a>]
		[<a href="#setting2">清除过期物品设置</a>]
		[<a href="#setting3">手续费管理</a>]
		[<a href="#setting4">翻新管理</a>]
		[<a href="#setting5">照相管理</a>]
		[<a href="#setting6">大赛管理</a>]
		[<a href="#setting7">商品管理</a>]
		</td>
		</tr>
		<form action="Plus_Avatar_Index.asp?action=save" method="post">
		<tr><th height="25" colspan="2" id=tabletitlelink align=left> &nbsp;<a name="setting1"></a>基本设置[<a href="#top">顶部</a>]</th></tr>
		<tr height=25 valign=middle>
			<td width="50%" class=forumrowhighlight align=right>购物袋的存放商品的个数：</td>
			<td width="50%" class=forumrow><input type=text name="Avatar_Setting(0)" value="<%=Avatar_Setting(0)%>" size=30 maxlength=5> 个</td>
		</tr>
		<tr height=25 valign=middle>
			<td class=forumrowhighlight align=right>个人收藏最多保存的商品个数：</td>
			<td class=forumrow><input type=text name="Avatar_Setting(1)" value="<%=Avatar_Setting(1)%>" size=30 maxlength=5> 个</td>
		</tr>
		<tr height=25 valign=middle>
			<td class=forumrowhighlight align=right>小图示每页显示商品的个数<br>(必须为偶数)：</td>
			<td class=forumrow><input type=text name="Avatar_Setting(2)" value="<%=Avatar_Setting(2)%>" size=30 maxlength=2> 个</td>
		</tr>
		<tr height=25 valign=middle>
			<td class=forumrowhighlight align=right>大图示每页显示商品的个数<br>(必须为偶数)：</td>
			<td class=forumrow><input type=text name="Avatar_Setting(3)" value="<%=Avatar_Setting(3)%>" size=30 maxlength=2> 个</td>
		</tr>
		<tr height=25 valign=middle>
			<td class=forumrowhighlight align=right>超大图示每页显示商品的个数<br>(必须为偶数)：</td>
			<td class=forumrow><input type=text name="Avatar_Setting(44)" value="<%=Avatar_Setting(44)%>" size=30 maxlength=2> 个</td>
		</tr>
		<tr height=25 valign=middle>
			<td class=forumrowhighlight align=right>是否允许显示不雅形象<br>(即上衣和裤裙是否必须齐备)：</td>
			<td class=forumrow><INPUT type=radio name="Avatar_Setting(4)" value="0"<%If Avatar_Setting(4) = 0 Then%> checked<%End If%>> 禁止&nbsp;&nbsp;<INPUT type=radio name="Avatar_Setting(4)" value="1"<%If Avatar_Setting(4) = 1 Then%> checked<%End If%>> 允许</td>
		</tr>
		<tr height=25 valign=middle>
			<td class=forumrowhighlight align=right>是否允许使用头像：</td>
			<td class=forumrow><INPUT type=radio name="Avatar_Setting(36)" value="0"<%If Avatar_Setting(36) = 0 Then%> checked<%End If%>> 禁止&nbsp;&nbsp;<INPUT type=radio name="Avatar_Setting(36)" value="1"<%If Avatar_Setting(36) = 1 Then%> checked<%End If%>> 允许</td>
		</tr>
		<tr><th height="25" colspan="2" id=tabletitlelink align=left> &nbsp;<a name="setting2"></a>清除过期物品设置[<a href="#top">顶部</a>]</th></tr>
		<tr height=25 valign=middle>
			<td width="50%" class=forumrowhighlight align=right>自动清除过期多少天的商品：</td>
			<td width="50%" class=forumrow><input type=text name="Avatar_Setting(5)" value="<%=Avatar_Setting(5)%>" size=30 maxlength=5> 天</td>
		</tr>
		<tr height=25 valign=middle>
			<td class=forumrowhighlight align=right>提前多少天发短消息提醒：</td>
			<td class=forumrow><input type=text name="Avatar_Setting(6)" value="<%=Avatar_Setting(6)%>" size=30 maxlength=5> 天</td>
		</tr>
		<tr><th height="25" colspan="2" id=tabletitlelink align=left> &nbsp;<a name="setting3"></a>手续费管理[<a href="#top">顶部</a>]</th></tr>
		<tr height=25 valign=middle>
			<td align=right width="50%" class=forumrowhighlight>赠送商品的手续费<br>(成交价格的百分比)：</td>
			<td align=left width="50%" class=forumrow><INPUT type=text name="Avatar_Setting(7)" size="20" value="<%=Avatar_Setting(7)%>" maxlength=3> %</td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>出售商品的手续费<br>(成交价格的百分比)：</td>
			<td align=left class=forumrow><INPUT type=text name="Avatar_Setting(8)" size="20" value="<%=Avatar_Setting(8)%>" maxlength=3> %</td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>出售商品的最低价<br>(享受价格的百分比)：</td>
			<td align=left class=forumrow><INPUT type=text name="Avatar_Setting(9)" size="20" value="<%=Avatar_Setting(9)%>"> %</td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>低价商品的标准<br>(低于此价格的商品记为低价商品)：</td>
			<td align=left class=forumrow><INPUT type=text name="Avatar_Setting(10)" size="20" value="<%=Avatar_Setting(10)%>" maxlength=5> 元</td>
		</tr>
		<tr><th height="25" colspan="2" id=tabletitlelink align=left> &nbsp;<a name="setting4"></a>翻新管理[<a href="#top">顶部</a>]</th></tr>
		<tr height=25 valign=middle>
			<td align=right width="50%" class=forumrowhighlight>增加一天有效期的费用<br>(享受价格/有效期的百分比)：</td>
			<td align=left width="50%" class=forumrow><INPUT type=text name="Avatar_Setting(11)" size="20" value="<%=Avatar_Setting(11)%>" maxlength=3> %</td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>增加至永远有效的费用<br>(享受价格的倍数)：</td>
			<td align=left class=forumrow><INPUT type=text name="Avatar_Setting(12)" size="20" value="<%=Avatar_Setting(12)%>" maxlength=3> 倍</td>
		</tr>
		<tr><th height="25" colspan="2" id=tabletitlelink align=left> &nbsp;<a name="setting5"></a>照相管理[<a href="#top">顶部</a>]</th></tr>
		<tr height=25 valign=middle>
			<td align=right width="50%" class=forumrowhighlight>普通会员照相的价格：</td>
			<td align=left width="50%" class=forumrow><INPUT type=text name="Avatar_Setting(13)" size="20" value="<%=Avatar_Setting(13)%>" maxlength=5> 元/人</td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>VIP会员照相的价格：</td>
			<td align=left class=forumrow><INPUT type=text name="Avatar_Setting(14)" size="20" value="<%=Avatar_Setting(14)%>" maxlength=5> 元/人</td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>照相请求的有效时间：</td>
			<td align=left class=forumrow><INPUT type=text name="Avatar_Setting(15)" size="20" value="<%=Avatar_Setting(15)%>" maxlength=3> 天</td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>完成照片的默认状态：</td>
			<td align=left class=forumrow><INPUT type=radio name="Avatar_Setting(16)" value="0"<%If Avatar_Setting(16) = 0 Then%> checked<%End If%>> 保密&nbsp;&nbsp;<INPUT type=radio name="Avatar_Setting(16)" value="1"<%If Avatar_Setting(16) = 1 Then%> checked<%End If%>> 公开</td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>最大允许合影的人数：</td>
			<td align=left class=forumrow><INPUT type=text name="Avatar_Setting(17)" size="20" value="<%=Avatar_Setting(17)%>" maxlength=2> 人</td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>最大允许上传背景的大小：</td>
			<td align=left class=forumrow><INPUT type=text name="Avatar_Setting(18)" size="20" value="<%=Avatar_Setting(18)%>" maxlength=3> K</td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>普通会员上传背景的价格：</td>
			<td align=left class=forumrow><INPUT type=text name="Avatar_Setting(19)" size="20" value="<%=Avatar_Setting(19)%>" maxlength=5> 元/K</td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>VIP会员上传背景的价格：</td>
			<td align=left class=forumrow><INPUT type=text name="Avatar_Setting(20)" size="20" value="<%=Avatar_Setting(20)%>" maxlength=5> 元/K</td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>照相中可以使用的饰物类别<br>(以|分隔)：</td>
			<td align=left class=forumrow><INPUT type=text name="Avatar_Setting(21)" size="20" value="<%=Avatar_Setting(21)%>"></td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>用于保存照片的目录：</td>
			<td align=left class=forumrow><INPUT type=text name="Avatar_Setting(22)" size="20" value="<%=Avatar_Setting(22)%>"></td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>生成照片的方式：</td>
			<td align=left class=forumrow><INPUT type=radio name="Avatar_Setting(40)" value="0"<%If Avatar_Setting(40) = 0 Then%> checked<%End If%>> 本机&nbsp;&nbsp;<INPUT type=radio name="Avatar_Setting(40)" value="1"<%If Avatar_Setting(40) = 1 Then%> checked<%End If%>> 远程</td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>远程生成照片的服务器地址：<br>(必须使用远程生成照片方式才有效)</td>
			<td align=left class=forumrow><INPUT type=text id="ServerURL" name="Avatar_Setting(41)" size="20" value="<%=Avatar_Setting(41)%>"></td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight><input type=button value="验证远程服务器" onclick="ValidateServer()"></td>
			<td align=left class=forumrow>是否开启远程服务<INPUT type=checkbox id="IsAllow" value="yes" disabled=true><br>普通会员的生成价格<input type=textbox id="NormalPrice" value="" disabled=true><br>VIP 会员的生成价格<input type=textbox id="VIPPrice" value="" disabled=true></td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>远程生成照片的用户名：<br>(必须使用远程生成照片方式才有效)</td>
			<td align=left class=forumrow><INPUT type=text name="Avatar_Setting(42)" size="20" value="<%=Avatar_Setting(42)%>"></td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>远程生成照片的密码：<br>(必须使用远程生成照片方式才有效)</td>
			<td align=left class=forumrow><INPUT type=password name="Avatar_Setting(43)" size="20" value="<%=Avatar_Setting(43)%>"></td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>确认远程生成照片的密码：<br>(必须与远程生成照片的密码相同)</td>
			<td align=left class=forumrow><INPUT type=password name="Avatar_Setting(43)" size="20" value="<%=Avatar_Setting(43)%>"></td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>是否开启远程照片生成服务<br>(必须使用本地生成照片方式才有效)：</td>
			<td align=left class=forumrow><INPUT type=radio name="Avatar_Setting(37)" value="0"<%If Avatar_Setting(37) = 0 Then%> checked<%End If%>> 关闭&nbsp;&nbsp;<INPUT type=radio name="Avatar_Setting(37)" value="1"<%If Avatar_Setting(37) = 1 Then%> checked<%End If%>> 开启</td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>普通会员远程生成照片的价格<br>(-1表示不对此类会员开通)：</td>
			<td align=left class=forumrow><INPUT type=text name="Avatar_Setting(38)" size="20" value="<%=Avatar_Setting(38)%>" maxlength=5> 元/张</td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>VIP会员远程生成照片的价格<br>(-1表示不对此类会员开通)：</td>
			<td align=left class=forumrow><INPUT type=text name="Avatar_Setting(39)" size="20" value="<%=Avatar_Setting(39)%>" maxlength=5> 元/张</td>
		</tr>
		<tr><th height="25" colspan="2" id=tabletitlelink align=left> &nbsp;<a name="setting6"></a>大赛管理(下个版本提供)[<a href="#top">顶部</a>]</th></tr>
		<tr height=25 valign=middle>
			<td align=right width="50%" class=forumrowhighlight>大赛举办周期：</td>
			<td align=left width="50%" class=forumrow><INPUT type=text name="Avatar_Setting(23)" size="20" value="<%=Avatar_Setting(23)%>" maxlength=3> 天</td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>最少的参赛者数：</td>
			<td align=left class=forumrow><INPUT type=text name="Avatar_Setting(24)" size="20" value="<%=Avatar_Setting(24)%>" maxlength=5> 位</td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>每位参赛者最多的作品数：</td>
			<td align=left class=forumrow><INPUT type=text name="Avatar_Setting(25)" size="20" value="<%=Avatar_Setting(25)%>" maxlength=5> 个</td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>每位评选者最多的选票数：</td>
			<td align=left class=forumrow><INPUT type=text name="Avatar_Setting(26)" size="20" value="<%=Avatar_Setting(26)%>" maxlength=5> 张</td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>评选者每张选票获得金钱：</td>
			<td align=left class=forumrow><INPUT type=text name="Avatar_Setting(27)" size="20" value="<%=Avatar_Setting(27)%>" maxlength=5> 元</td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>获奖者的最少得票数：</td>
			<td align=left class=forumrow><INPUT type=text name="Avatar_Setting(28)" size="20" value="<%=Avatar_Setting(28)%>" maxlength=5> 张</td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>团体赛第一名获得奖金：</td>
			<td align=left class=forumrow><INPUT type=text name="Avatar_Setting(29)" size="20" value="<%=Avatar_Setting(29)%>" maxlength=5> 元</td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>团体赛第二名获得奖金：</td>
			<td align=left class=forumrow><INPUT type=text name="Avatar_Setting(30)" size="20" value="<%=Avatar_Setting(30)%>" maxlength=5> 元</td> </tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>团体赛第三名获得奖金：</td>
			<td align=left class=forumrow><INPUT type=text name="Avatar_Setting(31)" size="20" value="<%=Avatar_Setting(31)%>" maxlength=5> 元</td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>个人赛第一名获得奖金：</td>
			<td align=left class=forumrow><INPUT type=text name="Avatar_Setting(32)" size="20" value="<%=Avatar_Setting(32)%>" maxlength=5> 元</td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>个人赛第二名获得奖金：</td>
			<td align=left class=forumrow><INPUT type=text name="Avatar_Setting(33)" size="20" value="<%=Avatar_Setting(33)%>" maxlength=5> 元</td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>个人赛第三名获得奖金：</td>
			<td align=left class=forumrow><INPUT type=text name="Avatar_Setting(34)" size="20" value="<%=Avatar_Setting(34)%>" maxlength=5> 元</td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>全部猜中结果的评选者获得奖金：</td>
			<td align=left class=forumrow><INPUT type=text name="Avatar_Setting(35)" size="20" value="<%=Avatar_Setting(35)%>" maxlength=5> 元</td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>下届比赛开始时间：</td>
			<td align=left class=forumrow><INPUT type=text name="NextMatchDate" size="20" value="<%=AvatarRs("NextMatchDate")%>" maxlength=10></td>
		</tr>
		<tr height=25 valign=middle>
			<td align=right class=forumrowhighlight>下届比赛的届数：</td>
			<td align=left class=forumrow><INPUT type=text name="NextMatchSeqNo" size="20" value="<%=AvatarRs("NextMatchSeqNo")%>" maxlength=5></td>
		</tr>
		<tr height=25 valign=middle>
			<td align=center colspan=2 class=forumrowhighlight><INPUT type="submit" name="submit" value=" 修  改 "></td>
		</tr>
		</form>
		<tr><th height="25" colspan="2" id=tabletitlelink align=left> &nbsp;<a name="setting7"></a>商品管理[<a href="#top">顶部</a>]</th></tr>
		<tr height=50 valign=middle>
			<td width="35%" class=forumrowhighlight><b>添加形象商品</b><br>请输入您想导入的商品数据库文件名，数据库必须上传到论坛的管理目录中</td>
			<form method="post" action="Plus_Avatar_Index.asp?action=import">
			<td width="65%" class=forumrow>例如NewAvatar<%=Right("00" & Month(Now()), 2) & Right("00" & Day(Now()), 2) & ".mdb"%><br><INPUT type=text name="NewAvatarDB" size="40">&nbsp; <INPUT type="submit" name="submit" value=" 导  入 "></td>
			</form>
		</tr>
		<tr height=40 valign=middle>
			<td class=forumrowhighlight><b>已有商品管理</b></td>
			<form method="get" action="Plus_Avatar_Items.asp">
			<td class=forumrow><INPUT type="submit" name="submit" value=" 管理形象商品 "></td>
			</form>
		</tr>
		<tr height=40 valign=middle>
			<td class=forumrowhighlight><b>商品分类管理</b></td>
			<form method="get" action="Plus_Avatar_Type.asp">
			<td class=forumrow><INPUT type="submit" name="submit" value=" 管理形象商品分类 "></td>
			</form>
		</tr>
		<tr height=40 valign=middle>
			<td class=forumrowhighlight><b>背景管理</b></td>
			<form method="post" action="Plus_Avatar_Index.asp?action=cleanbg">
			<td class=forumrow><INPUT type="submit" name="submit" value=" 清理无用的照片背景 "></td>
			</form>
		</tr>
	</table>
	<br>
	<%AvatarRs.Close
End Sub

Sub SaveConst()
	Dim iAvatar_Setting,iSetting, i, PasswordSplit

	If Trim(Request.Form("NextMatchSeqNo")) = "" Or Not IsInteger(Trim(Request.Form("NextMatchSeqNo"))) Then
		Errmsg = ErrMsg & "<BR><li>下届比赛的届数必须是整数。"
		Dvbbs_Error()
		Exit Sub
	End If
	If Trim(Request.Form("NextMatchDate")) = "" Or Not IsDate(Trim(Request.Form("NextMatchDate"))) Then
		Errmsg = ErrMsg & "<BR><li>下届比赛的开始时间必须是日期。"
		Dvbbs_Error()
		Exit Sub
	End If
	For i = 0 To 50
		If i <> 21 And i <> 22 And i <> 37 And i <> 38 And i <> 39 And i <> 41 And i <> 42 And i <> 43 And i < 45 Then
			If Trim(Request.Form("Avatar_Setting(" & i & ")")) = "" Or Not IsInteger(Trim(Request.Form("Avatar_Setting(" & i & ")"))) Then
				Errmsg = ErrMsg & "<BR><li>设置的数据有误，必须是整数。"
				Dvbbs_Error()
				Exit Sub
			End If
		ElseIf i = 38 Or i = 39 Then
			If Trim(Request.Form("Avatar_Setting(" & i & ")")) = "" Or Not IsNumeric(Trim(Request.Form("Avatar_Setting(" & i & ")"))) Then
				Errmsg = ErrMsg & "<BR><li>设置的数据有误，必须是数值。"
				Dvbbs_Error()
				Exit Sub
			End If
		ElseIf i = 37 And Trim(Request.Form("Avatar_Setting(40)")) = "1" Then
			If Trim(Request.Form("Avatar_Setting(" & i & ")")) = "1" Then
				Errmsg = ErrMsg & "<BR><li>使用远程生成照片方式不得再开启远程服务。"
				Dvbbs_Error()
				Exit Sub
			End If
		ElseIf i = 41 And Trim(Request.Form("Avatar_Setting(40)")) = "1" Then
			If Trim(Request.Form("Avatar_Setting(" & i & ")")) = "" Then
				Errmsg = ErrMsg & "<BR><li>必须指定远程服务器的地址。"
				Dvbbs_Error()
				Exit Sub
			End If
		ElseIf i = 42 And Trim(Request.Form("Avatar_Setting(40)")) = "1" Then
			If Trim(Request.Form("Avatar_Setting(" & i & ")")) = "" Then
				Errmsg = ErrMsg & "<BR><li>必须指定远程用户的用户名。"
				Dvbbs_Error()
				Exit Sub
			End If
		ElseIf i = 43 And Trim(Request.Form("Avatar_Setting(40)")) = "1" Then
			If Trim(Request.Form("Avatar_Setting(" & i & ")")) = "" Or Not InStr(Trim(Request.Form("Avatar_Setting(" & i & ")")), ",") > 0 Then
				Errmsg = ErrMsg & "<BR><li>必须指定远程用户的密码和确认密码。"
				Dvbbs_Error()
				Exit Sub
			End If
			PasswordSplit = Split(Trim(Request.Form("Avatar_Setting(" & i & ")")), ",")
			If Trim(PasswordSplit(0)) = "" Then
				Errmsg = ErrMsg & "<BR><li>远程用户的密码不可为空。"
				Dvbbs_Error()
				Exit Sub
			End If
			If Trim(PasswordSplit(0)) <> Trim(PasswordSplit(1)) Then
				Errmsg = ErrMsg & "<BR><li>指定的远程用户密码和确认密码必须一致。"
				Dvbbs_Error()
				Exit Sub
			End If
		End If
		If Trim(Request.Form("Avatar_Setting(" & i & ")")) = "" Then
			If i <> 21 And i <> 22 And i <> 41 And i <> 42 And i <> 43 Then
				iSetting = 0
			Else
				iSetting = ""
			End If
		Else
			iSetting = Replace(Trim(Request.Form("Avatar_Setting(" & i & ")")), ",", "")
			If i = 22 Then
				If iSetting <> "" And Right(iSetting, 1) <> "/" Then iSetting = iSetting & "/"
			ElseIf i = 41 Then
				If iSetting <> "" And Right(iSetting, 1) <> "/" Then iSetting = iSetting & "/"
				If iSetting <> "" And LCase(Left(iSetting, 7)) <> "http://" Then iSetting = "http://" & iSetting
			ElseIf i = 43 And Trim(Request.Form("Avatar_Setting(40)")) = "1" Then
				iSetting = Trim(PasswordSplit(0))
			End If
		End If
		If i = 0 Then
			iAvatar_Setting = iSetting
		Else
			iAvatar_Setting = iAvatar_Setting & "," & iSetting
		End If
	Next
	Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_Config Set Avatar_Setting='" & iAvatar_Setting & "', NextMatchDate='" & Request.Form("NextMatchDate") & "',NextMatchSeqNo=" & Request.Form("NextMatchSeqNo"))
	Call MakeAvatarXML()
	Dv_Suc("设置成功。<a href=Plus_Avatar_Index.asp>返回形象系统管理</a>")
End Sub

Sub ImportItems()
	Dim NewDB, NewConn
	Dim ItemAddCount, ItemSkipCount, ItemUpdCount
	Dim MaxID, MinID, n, i, Delta
	Dim NewRs, OldRs, SubTypeRs
	
	NewDB = Trim(Request.Form("NewAvatarDB"))
	If NewDB = "" Then
		ErrMsg = ErrMsg & "<Br><li>请填写导入的数据库名"
		Dvbbs_Error()
		Exit Sub
	End If
	Set NewConn = Server.CreateObject("ADODB.Connection")
	Set NewRs = Server.CreateObject("ADODB.Recordset")
	Set OldRs = Server.CreateObject("ADODB.Recordset")
	On Error Resume Next
	NewConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(NewDB)
	If Err <> 0 Then
		Err.Clear
		On Error Goto 0
		ErrMsg = ErrMsg & "<Br><li>指定的数据库不存在或者无法打开"
		Set NewConn = Nothing
		Dvbbs_Error()
		Exit Sub
	End If
	If Trim(Request.Form("beginid")) = "" Or Trim(Request.Form("endid")) = "" Then
		NewRs.Open "Select * From Dv_Plus_Avatar_Items", NewConn, 1, 1
	ElseIf Trim(Request.Form("beginid")) <> "" Then
		If Not IsNumeric(Request.Form("beginid")) Then
			On Error Goto 0
			ErrMsg = ErrMsg & "<Br><li>错误的开始参数！"
			Dvbbs_Error()
			Exit Sub
		End If
		If not IsNumeric(Request.Form("endid")) Then
			On Error Goto 0
			ErrMsg = ErrMsg & "<Br><li>错误的结束参数！"
			Dvbbs_Error()
			Exit Sub
		End If
		If CLng(Request.Form("beginid")) > CLng(Request.Form("endid")) Then
			On Error Goto 0
			ErrMsg = ErrMsg & "开始ID应该比结束ID小！"
			Dvbbs_Error()
			Exit Sub
		End If
		NewRs.Open "Select * From Dv_Plus_Avatar_Items Where ID>=" & Request.Form("beginid") & " And ID<=" & Request.Form("endid"), NewConn, 1, 1
	End If
	If Err <> 0 Then
		Err.Clear
		On Error Goto 0
		ErrMsg = ErrMsg & "<Br><li>指定的数据库不是形象数据库"
		Set NewRs = Nothing
		NewConn.Close
		Set NewConn = Nothing
		Dvbbs_Error()
		Exit Sub
	End If
	On Error Goto 0
	If NewRs.EOF Then
		ErrMsg = ErrMsg & "<Br><li>没有可供导入的形象商品"
		NewRs.Close
		Set NewRs = Nothing
		NewConn.Close
		Set NewConn = Nothing
		Dv_Suc("没有可供导入的形象商品！<a href=Plus_Avatar_Index.asp>返回形象系统管理</a>")
		Exit Sub
	End If
	Delta = 100
	n = NewRs.RecordCount
	If Trim(Request.Form("beginid")) <> "" And Trim(Request.Form("endid")) <> "" Then
		ItemAddCount = 0
		ItemSkipCount = 0
		ItemUpdCount = 0
		Delta = Clng(Request.Form("endid")) - CLng(Request.Form("beginid")) + 1
		i = 0
%>
<BR>
<table cellpadding="0" cellspacing="0" border="0" width="95%" class="tableBorder" align=center>
<tr><td colspan=2 class=forumrow>
下面开始更新形象商品，预计本次共有<%=n%>个商品需要处理
<table width="400" border="0" cellspacing="1" cellpadding="1">
<tr> 
	<td bgcolor="#000000">
		<table width="400" border="0" cellspacing="0" cellpadding="1">
		<tr> 
		<td bgcolor="#ffffff" height="9"><img src="../skins/default/bar/bar3.gif" width="0" height="16" id="img2" name="img2" align="absmiddle"></td>
		</tr>
		</table>
	</td>
</tr>
</table>
<span id="txt2" name="txt2" style="font-size:9pt">0</span><span style="font-size:9pt">%</span></td>
</tr>
</table>
<%
		Do While Not NewRs.Eof
			i = i + 1
			Response.Write "<script>img2.width=" & Fix((i / n) * 400) & ";" & VbCrLf
			Response.Write "txt2.innerHTML=""正在处理商品【" & Replace(NewRs("Name"), """", "") & "】，" & FormatNumber(i / n * 100, 4, -1) & """;" & VbCrLf
			Response.Write "img2.title=""" & Replace(NewRs("Name"), """", "") & "(" & i & ")"";</script>" & VbCrLf
			Response.Flush
			If Cint(Dvbbs.Forum_Setting(92))=1 Then
				If Not IsObject(Plus_Conn) Then Plus_ConnectionDatabase
				OldRs.Open "Select Top 1 * From Dv_Plus_Avatar_Items Where ID=" & NewRs("ID"), Plus_Conn, 1, 3
			Else
				If Not IsObject(Conn) Then ConnectionDatabase
				OldRs.Open "Select Top 1 * From Dv_Plus_Avatar_Items Where ID=" & NewRs("ID"), Conn, 1, 3
			End If
			If OldRs.Eof Then
				Set SubTypeRs = Dvbbs.Plus_Execute("Select Top 1 * From Dv_Plus_Avatar_SubType Where MyType=" & NewRs("Type"))
				OldRs.AddNew
				OldRs("ID") = NewRs("ID")
				OldRs("Name") = Replace(NewRs("Name"), """", "")
				OldRs("Sex") = NewRs("Sex")
				OldRs("Type") = NewRs("Type")
				OldRs("Content") = NewRs("Content")
				OldRs("Class") = NewRs("Class")
				If SubTypeRs.Eof Then
					OldRs("Price1") = NewRs("Price1")
					OldRs("Price2") = NewRs("Price2")
					OldRs("Period") = NewRs("Period")
					OldRs("Quantity") = NewRs("Quantity")
					OldRs("Flag") = NewRs("Flag")
					OldRs("Vip") = NewRs("Vip")
				Else
					OldRs("Price1") = SubTypeRs("DefPrice1")
					OldRs("Price2") = SubTypeRs("DefPrice2")
					OldRs("Period") = SubTypeRs("DefPeriod")
					OldRs("Quantity") = SubTypeRs("DefQuantity")
					OldRs("Flag") = SubTypeRs("DefFlag")
					OldRs("Vip") = SubTypeRs("DefVip")
				End If
				OldRs.Update
				ItemAddCount = ItemAddCount + 1
			Else
				If OldRs("Name") <> Replace(NewRs("Name"), """", "") Or OldRs("Sex") <> NewRs("Sex") Or OldRs("Type") <> NewRs("Type") Or OldRs("Content") <> NewRs("Content") Or OldRs("Class") <> NewRs("Class") Then
					OldRs("Name") = Replace(NewRs("Name"), """", "")
					OldRs("Sex") = NewRs("Sex")
					OldRs("Type") = NewRs("Type")
					OldRs("Content") = NewRs("Content")
					OldRs("Class") = NewRs("Class")
					OldRs.Update
					ItemUpdCount = ItemUpdCount + 1
				Else
					ItemSkipCount = ItemSkipCount + 1
				End If
			End If
			OldRs.Close
			NewRs.MoveNext
		Loop
		NewRs.Close
		NewRs.Open "Select * From Dv_Plus_Avatar_Items Where ID>=" & (CLng(Request.Form("endid")) + 1), NewConn, 1, 1
		n = NewRs.RecordCount
		Response.Write "<script>img2.width=400;txt2.innerHTML=""100"";</script>"
	%>
		<br>
		<table cellpadding="0" cellspacing="0" border="0" width="95%" class="tableBorder" align=center>
		<tr><td colspan=2 align=center class=forumrow>数据导入成功(导入<%=ItemAddCount%>个新商品，更新<%=ItemUpdCount%>个旧商品，跳过<%=ItemSkipCount%>个已有商品)！</td></tr>
		</table>
	<%
		MinID = CLng(Request.Form("endid")) + 1
	Else
		MinID = NewConn.Execute("Select Min(ID) From Dv_Plus_Avatar_Items")(0)
	End If
	NewRs.Close
	MaxID = NewConn.Execute("Select Max(ID) From Dv_Plus_Avatar_Items")(0)
	If Not IsNull(MaxID) And MaxID >= MinID Then
%>
<BR>
<table cellpadding="0" cellspacing="0" border="0" width="95%" class="tableBorder" align=center>
<tr><td colspan=2 class=forumrow>请选择更新范围，预计还有<%=n%>个商品需要处理</td></tr>
<FORM METHOD=POST ACTION="?action=import">
<tr>
<td width="20%" class="forumrow">开始商品ID</td>
<td width="80%" class="forumrow"><input type=hidden name="beginID" value="<%=MinID%>"><input type=text value="<%=MinID%>" size=10 disabled>&nbsp;商品ID，可以填写您想从哪一个ID号开始导入</td>
</tr>
<tr>
<td width="20%" class="forumrow">结束商品ID</td>
<td width="80%" class="forumrow"><input type=text name="endID" value="<%
		If n <= 100 Then
			Response.Write MaxID
		ElseIf MaxID > MinID + Delta - 1 Then
			Response.Write MinID + Delta - 1
		Else
			Response.Write MaxID
		End If
%>" size=10>&nbsp;将导入开始到结束ID之间的形象商品，之间的数值最好不要选择过大</td>
</tr>
<tr>
<td width="20%" class="forumrow"></td>
<td width="80%" class="forumrow"><INPUT type=hidden name="NewAvatarDB" value="<%=NewDB%>"><input type="submit" name="Submit" value="开始导入"></td>
</tr>
</form>
</table>
<%
	Else%>
		<br>
		<table cellpadding="0" cellspacing="0" border="0" width="95%" class="tableBorder" align=center>
		<tr><td colspan=2 align=center class=forumrow><a href=Plus_Avatar_Index.asp>返回形象系统管理</a></td></tr>
		</table>
<%
	End If
	Set OldRs = Nothing
	Set NewRs = Nothing
	NewConn.Close
	Set NewConn = Nothing
End Sub

Sub CleanBg()
	Dim objFSO, UploadFolder, UploadFiles, UpFile
	Dim i, n, NeedDelete
	Dim PhotoPath,  UpFileName
	
	PhotoPath = AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").Attributes.getNamedItem("PhotoPath").text
	If Left(PhotoPath, 1) <> "/" Then PhotoPath = "../" & PhotoPath
	If Right(PhotoPath, 1) <> "/" Then PhotoPath = PhotoPath & "/"
	Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
	Set UploadFolder = objFSO.GetFolder(Server.MapPath(PhotoPath))
	Set UploadFiles = UploadFolder.Files
	i = 0
	n = 0
%>
<BR>
<table cellpadding="0" cellspacing="0" border="0" width="95%" class="tableBorder" align=center>
<tr><td colspan=2 class=forumrow>
下面开始删除无用的背景，预计本次共有<%=UploadFiles.Count%>个文件需要处理
<table width="400" border="0" cellspacing="1" cellpadding="1">
<tr> 
	<td bgcolor="#000000">
		<table width="400" border="0" cellspacing="0" cellpadding="1">
		<tr> 
		<td bgcolor="#ffffff" height="9"><img src="../skins/default/bar/bar3.gif" width="0" height="16" id="img2" name="img2" align="absmiddle"></td>
		</tr>
		</table>
	</td>
</tr>
</table>
<span id="txt2" name="txt2" style="font-size:9pt">0</span><span style="font-size:9pt">%</span></td>
</tr>
</table>
<%	For Each UpFile In UploadFiles
		UpFileName = PhotoPath & UpFile.Name
		i = i + 1
		Response.Write "<script>img2.width=" & Fix((i / UploadFiles.Count) * 400) & ";" & VbCrLf
		Response.Write "txt2.innerHTML=""正在处理文件" & UpFile.Name & "，" & FormatNumber(i / UploadFiles.Count * 100, 4, -1) & """;" & VbCrLf
		Response.Write "img2.title=""" & UpFile.Name & "(" & i & ")"";</script>" & VbCrLf
		Response.Flush
		NeedDelete = False
		If Not InStr(UpFile.Name, "_") > 0 Then
			NeedDelete = True
		ElseIf LCase(Left(UpFile.Name, 6)) <> "photo_" And LCase(Left(UpFile.Name, 7)) <> "avatar_" Then
			If Dvbbs.Plus_Execute("select ID From Dv_Plus_Avatar_Photo Where UploadFile='" & UpFile.Name & "'").Eof Then
				NeedDelete = True
			End If
		End If
		If NeedDelete Then
			n = n + 1
			objFSO.DeleteFile(Server.MapPath(UpFileName))
			Response.Write "文件 " & UpFileName & " 已被删除！<br>"
			Response.Flush
		End If
	Next
	Response.Write "<script>img2.width=400;txt2.innerHTML=""100"";</script>"
	Set UploadFolder = Nothing
	Set UploadFiles = Nothing
	Set objFSO = Nothing
	Dv_Suc("成功地删除了　" & n & "　个无用背景文件。<a href=Plus_Avatar_Index.asp>返回形象系统管理</a>")
End Sub%>
