<!-- #include file=../../inc/BBSsetup.asp -->
<!-- #include file=../../inc/User_setup.asp -->
<!-- #include file=../../inc/Bank_setup.asp -->
<!-- #include file=../../inc/Board_popfun.asp -->
<!-- #include file=../inc/bbsmanage_Fun.asp -->
<%
DEF_BBS_HomeUrl = "../../"
Const MaxLinkNum = 100
Dim GBL_ID
initDatabase
GBL_CHK_TempStr = ""
GBL_ID = checkSupervisorPass

Redim Form_DEF_UserSavePoints(DEF_UserLevelNum)
Dim Form_DEF_UserPoints_Day, Form_DEF_UserPoints_Tax, Form_DEF_UserPoints_Move, Form_DEF_UserPoints_VIP_m, Form_DEF_BK_SET_Open, Form_DEF_BK_SET_Default, Form_DEF_BK_SET_Move, Form_DEF_BK_SET_WriteLog, Form_DEF_BK_SET_Massage, Form_DEF_BK_SET_Limit_Total, Form_DEF_BK_SET_OpenAt, Form_DEF_BK_SET_CloseAt, Form_DEF_BK_LogPath, Form_DEF_BK_CloseInfo
Dim XmlFlag, XML, XmlCount

GetDefaultValue

SiteHead(DEF_SiteNameString & " - 管理员")
UserTopicTopInfo
DisplayUserNavigate("LeadBBS Bank 0.5 参数设置")
If GBL_CHK_Flag=1 Then
	SiteLink
Else%>
	<table width=96%>
	<tr>
	<td>
	<%
	If Request("submitflag")="" Then
		Response.Write "<br><b>请先登录</b>"
	Else
		Response.Write "<br><p align=left><font color=ff0000 class=RedFont><b>" & GBL_CHK_TempStr & "</b></font>"
	End If
	DisplayLoginForm
	Response.Write "</p>"%>
	</td>
	</tr>
	</table>
<%End If
UserTopicBottomInfo
closeDataBase
SiteBottom
If GBL_ShowBottomSure = 1 Then Response.Write GBL_SiteBottomString

Function SiteLink
	
	%>
	<form name="pollform3sdx" method="post" action="BankSetup.asp">
	<input type="hidden" name="SubmitFlag" value=yes>
	<p>
		<font color=8888888 class=GrayFont>如果在设置后发现网站不能正常运行，请将LeadBBS Bank 0.5 安装包中
		原始的 Bank_Setup.asp 覆盖回去</font>
	</p>
	<%If Request("SubmitFlag") <> "" Then
		CheckLinkValue
	End If%>
	<b><font color=ff0000 class=RedFont><%=GBL_CHK_TempStr%></font></b>
	<p>
	<%
	If Request("SubmitFlag") <> "" Then
		If GBL_CHK_TempStr <> "" Then
			DisplayDatabaseLink
		Else
			MakeDataBaseLinkFile
			Exit Function
		End If
	Else
		If Request("CleanLog") = "Ef89ae442d" Then
			If XmlFlag And DEF_BK_SET_WriteLog Then
				Set Xml = Server.CreateObject("MSXML2.DOMDocument.3.0")
				Xml.LoadXml("<?xml version=""1.0"" encoding=""utf-8""?><actions />")
				Xml.Save(Server.MapPath(Replace(Replace(DEF_BBS_HomeUrl & DEF_BK_LogPath, "/", "\"), "\\", "\")))
			End If
			Response.Redirect "BankSetup.asp"
		End If
		DisplayDatabaseLink
	End If
	%>
	<br>
	<input type=submit name=提交 value=提交 class=fmbtn>
	<input type=reset name=取消 value=取消 class=fmbtn>
	</form>
	<%

End Function

Function CheckLinkValue

	GetFormValue
	
End Function

Function DisplayDatabaseLink

	Dim N
		%>
		<table border=0 cellpadding=5 cellspacing=1 width="100%" bgcolor="<%=DEF_BBS_LightColor%>" class=TBBG1>
		<tr bgcolor=<%=DEF_BBS_LightestColor%> class=TBBG9>
			<td>存款定义</td>
			<td>
				<table border=0 cellpadding=1 cellspacing=0>
				<tr>
					<td>&nbsp;级别</td>
					<td>&nbsp;级别称号</td>
					<td>&nbsp;存款极限</td>
				</tr><%
			For n = 0 to DEF_UserLevelNum
				%>
				<tr>
					<td>&nbsp;<%=Right(" " & N,2)%>级</td>
					<td>&nbsp;<%=DEF_UserLevelString(n)%></td>
					<td>&nbsp;<input class=fminpt type="text" name="Form_DEF_UserSavePoints<%=N%>" maxlength="14" size="10" value="<%=htmlencode(Form_DEF_UserSavePoints(n))%>"></td>
				</tr>
				<%
			Next
			%>
				</table>
				&nbsp;<font color=gray class=grayfont>发表文章指的是曾经发表过的文章(包括删除数量)</font><br>
				&nbsp;<font color=gray class=grayfont>存款极限指的是在社区银行中每次最大的存款数量</font></td>
		</tr>
		<tr bgcolor=<%=DEF_BBS_LightestColor%> class=TBBG9>
			<td>日利率</td>
			<td><input type=text class=fminpt name=Form_DEF_UserPoints_Day maxlength="4" size="10" value="<%=htmlencode(Form_DEF_UserPoints_Day)%>"> %<font color=gray class=grayfont> 最大100 最小0</font></td>
		</tr>
		<tr bgcolor=<%=DEF_BBS_LightestColor%> class=TBBG9>
			<td>利息税率</td>
			<td><input type=text class=fminpt name=Form_DEF_UserPoints_Tax maxlength="4" size="10" value="<%=htmlencode(Form_DEF_UserPoints_Tax)%>"> %<font color=gray class=grayfont> 最大100 最小0</font></td>
		</tr>
		<tr bgcolor=<%=DEF_BBS_LightestColor%> class=TBBG9>
			<td>转帐的税率</td>
			<td><input type=text class=fminpt name=Form_DEF_UserPoints_Move maxlength="4" size="10" value="<%=htmlencode(Form_DEF_UserPoints_Move)%>"> %<font color=gray class=grayfont> 最大100 最小0</font></td>
		</tr>
		<tr bgcolor=<%=DEF_BBS_LightestColor%> class=TBBG9>
			<td>VIP用户存款极限倍率</td>
			<td><input type=text class=fminpt name=Form_DEF_UserPoints_VIP_m maxlength="4" size="10" value="<%=htmlencode(Form_DEF_UserPoints_VIP_m)%>"></td>
		</tr>
		<tr bgcolor=<%=DEF_BBS_LightestColor%> class=TBBG9>
			<td>银行开门时间</td>
			<td><input type=text class=fminpt name=Form_DEF_BK_SET_OpenAt maxlength="2" size="2" value="<%=htmlencode(Form_DEF_BK_SET_OpenAt)%>">:00</td>
		</tr>
		<tr bgcolor=<%=DEF_BBS_LightestColor%> class=TBBG9>
			<td>银行关门时间</td>
			<td><input type=text class=fminpt name=Form_DEF_BK_SET_CloseAt  maxlength="2" size="2" value="<%=htmlencode(Form_DEF_BK_SET_CloseAt)%>">:00</td>	
		</tr>
		<tr bgcolor=<%=DEF_BBS_LightestColor%> class=TBBG9>
			<td>其他设置</td>
			<td>
			<input type=checkbox class=fmchkbox name=Form_DEF_BK_SET_Open value=1 onclick=Form_DEF_BK_CloseInfoDiv.style.display=(this.checked)?'none':'block' <%if Form_DEF_BK_SET_Open then Response.Write "checked"%>> <font color=gray class=grayfont>设置开启银行</font><br>
			<table id="Form_DEF_BK_CloseInfoDiv" name="Form_DEF_BK_CloseInfoDiv" cellpadding="1" cellspacing="2" border="0" width="100%" <%if Form_DEF_BK_SET_Open then response.write "style=display:none"%>>
				<tr>
					<td>
					<textarea rows="5" name="Form_DEF_BK_CloseInfo" cols="40" class="fmtxtra"><%If Form_DEF_BK_CloseInfo <> "" Then Response.Write VbCrLf & htmlencode(Form_DEF_BK_CloseInfo)%></textarea><br>
					<font color="gray" class="grayfont">银行关闭时显示的消息，可使用 HTML</font></td>
				</tr>
			</table>
			<input type=checkbox class=fmchkbox name=Form_DEF_BK_SET_Default value=1 <%if Form_DEF_BK_SET_Default then Response.Write "checked"%>> <font color=gray class=grayfont>设置允许存款取款</font><br>
			<input type=checkbox class=fmchkbox name=Form_DEF_BK_SET_Move value=1 <%if Form_DEF_BK_SET_Move then Response.Write "checked"%>> <font color=gray class=grayfont>设置允许转帐</font><br>
			<input type=checkbox class=fmchkbox name=Form_DEF_BK_SET_Limit_Total value=1 <%if Form_DEF_BK_SET_Limit_Total then Response.Write "checked"%>> <font color=gray class=grayfont>设置单次存款最大值为用户的账户中的最大极限(非每次存款数)</font><br>
			<input type=checkbox class=fmchkbox name=Form_DEF_BK_SET_WriteLog value=1 
			<%If Form_DEF_BK_SET_WriteLog and XmlFlag then
				Response.Write "checked"
			End If
			If XMLFlag = 0 then
				Response.Write "disabled"
			End If
			If XMLFlag Then Response.Write " onclick=Form_DEF_BK_LogPathDiv.style.display=(this.checked)?'block':'none'"
			%>> <font color=gray class=grayfont>设置开启银行操作记录(不建议开启)<%If XMLFlag = 0 Then Response.Write " 对不起，您的服务器不支持 XMLDOM"%></font><br>
			<%If XMLFlag Then%>
			<table id="Form_DEF_BK_LogPathDiv" name="Form_DEF_BK_LogPathDiv" cellpadding="1" cellspacing="2" border="0" width="100%" <%if Form_DEF_BK_SET_WriteLog = 0 then response.write "style=display:none"%>>
				<tr>
					<td>
					<input type="text" class="fminpt" name="Form_DEF_BK_LogPath" maxlength="255" size="20" value="<%=htmlencode(Form_DEF_BK_LogPath)%>"><br />
					<font color="gray" class="grayfont">日志文件地址，相对于论坛根目录</font><br />
					当前共有 <%=XmlCount%> 条记录<br>
					操作：[<a href="<%=DEF_BBS_HomeUrl & DEF_BK_LogPath%>">下载</a>] [<a href="BankSetup.asp?CleanLog=Ef89ae442d">清除</a>] [<a href="BankLog.asp">查看</a>]
					</td>
				</tr>
			</table>
			<%End If%>
			<input type=checkbox class=fmchkbox name=Form_DEF_BK_SET_Massage value=1 <%if Form_DEF_BK_SET_Massage then Response.Write "checked"%>> <font color=gray class=grayfont>设置允许使用自定义转帐信息</font></td>
		</tr>
		</table>
		<%

End Function

Function GetDefaultValue

	Dim N
	
	Form_DEF_UserPoints_Day = DEF_UserPoints_Day * 100
	Form_DEF_UserPoints_Tax = (1 - DEF_UserPoints_Tax) * 100
	Form_DEF_UserPoints_Move = (1 - DEF_UserPoints_Move) * 100
	Form_DEF_UserPoints_VIP_m = DEF_UserPoints_VIP_m
	Form_DEF_BK_SET_Open = DEF_BK_SET_Open
	Form_DEF_BK_SET_Default = DEF_BK_SET_Default
	Form_DEF_BK_SET_Move = DEF_BK_SET_Move
	Form_DEF_BK_SET_WriteLog = DEF_BK_SET_WriteLog
	Form_DEF_BK_SET_Massage = DEF_BK_SET_Massage
	Form_DEF_BK_SET_Limit_Total = DEF_BK_SET_Limit_Total
	Form_DEF_BK_SET_OpenAt = DEF_BK_SET_OpenAt
	Form_DEF_BK_SET_CloseAt = DEF_BK_SET_CloseAt + 1
	Form_DEF_BK_LogPath = DEF_BK_LogPath
	Form_DEF_BK_CloseInfo = DEF_BK_CloseInfo
	
	For n = 0 to DEF_UserLevelNum
		Form_DEF_UserSavePoints(n) = DEF_UserSavePoints(n)
	Next
		
	CheckXML
	
End Function

Function CheckXML
	
	'On Error Resume Next
	XMLFlag = 1
	Set Xml = Server.CreateObject("MSXML2.DOMDocument.3.0")
	If Err <> 0 Then
		Err.Clear
		XmlFlag = 0
	Else
		Xml.Load(Server.MapPath(Replace(Replace(DEF_BBS_HomeUrl & DEF_BK_LogPath, "/", "\"), "\\", "\")))
		If Xml.parseError <> 0 And DEF_BK_SET_WriteLog Then
			Xml.LoadXml("<?xml version=""1.0"" encoding=""utf-8""?><actions />")
			Xml.Save(Server.MapPath(Replace(Replace(DEF_BBS_HomeUrl & DEF_BK_LogPath, "/", "\"), "\\", "\")))
		End If
		XmlCount = Xml.SelectNodes("//actions/a").length
	End If
	Set Xml = Nothing
	
End Function

Function GetFormValue

	Dim N
	Form_DEF_UserPoints_Day = Left(Request("Form_DEF_UserPoints_Day"),6)
	Form_DEF_UserPoints_Tax = Left(Request("Form_DEF_UserPoints_Tax"),6)
	Form_DEF_UserPoints_Move = Left(Request("Form_DEF_UserPoints_Move"),6)
	Form_DEF_UserPoints_VIP_m = Left(Request("Form_DEF_UserPoints_VIP_m"),14)
	Form_DEF_BK_SET_Open = Left(Request("Form_DEF_BK_SET_Open"),1)
	Form_DEF_BK_SET_Default = Left(Request("Form_DEF_BK_SET_Default"),1)
	Form_DEF_BK_SET_Move = Left(Request("Form_DEF_BK_SET_Move"),1)
	Form_DEF_BK_SET_WriteLog = Left(Request("Form_DEF_BK_SET_WriteLog"),1)
	Form_DEF_BK_SET_Massage = Left(Request("Form_DEF_BK_SET_Massage"),1)
	Form_DEF_BK_SET_Limit_Total = Left(Request("Form_DEF_BK_SET_Limit_Total"),1)
	Form_DEF_BK_SET_OpenAt = Left(Request("Form_DEF_BK_SET_OpenAt"),2)
	Form_DEF_BK_SET_CloseAt = Left(Request("Form_DEF_BK_SET_CloseAt"),2)
	Form_DEF_BK_LogPath = Request("Form_DEF_BK_LogPath")
	Form_DEF_BK_CloseInfo = Request("Form_DEF_BK_CloseInfo")
		
	For n = 0 to DEF_UserLevelNum
		If isNumeric(Form_DEF_UserSavePoints(n)) = 0 Then
			GBL_CHK_TempStr = "第" & N & "等级存款极限必须为数字<br>" & VbCrLf
			Exit Function
		End If
	Next
	
	If Not isNumeric(Form_DEF_BK_SET_OpenAt) or inStr(Form_DEF_BK_SET_OpenAt,".") or inStr(Form_DEF_BK_SET_OpenAt,"-") > 0 Then GBL_CHK_TempStr = "银行开放时间要求必须为正整数<br>" & VbCrLf : Exit Function
	Form_DEF_BK_SET_OpenAt = cInt(Form_DEF_BK_SET_OpenAt)
	If Form_DEF_BK_SET_OpenAt < 0 or Form_DEF_BK_SET_OpenAt > 24 Then GBL_CHK_TempStr = "银行开放时间要求必须大于或等于0，并且小于或等于24<br>" & VbCrLf : Exit Function
	
	If Not isNumeric(Form_DEF_BK_SET_OpenAt) or inStr(Form_DEF_BK_SET_OpenAt,".") or inStr(Form_DEF_BK_SET_OpenAt,"-") > 0 Then GBL_CHK_TempStr = "银行关闭时间要求必须为正整数<br>" & VbCrLf : Exit Function
	Form_DEF_BK_SET_OpenAt = cInt(Form_DEF_BK_SET_OpenAt)
	If Form_DEF_BK_SET_OpenAt < 0 or Form_DEF_BK_SET_OpenAt > 24 Then GBL_CHK_TempStr = "银行关闭时间要求必须大于或等于0，并且小于或等于24<br>" & VbCrLf : Exit Function

	If Not isNumeric(Form_DEF_UserPoints_Day) Then GBL_CHK_TempStr = "社区银行利率必须为数字<br>" & VbCrLf : Exit Function
	Form_DEF_UserPoints_Day = cDbl(Form_DEF_UserPoints_Day)
	If Form_DEF_UserPoints_Day < 0 or Form_DEF_UserPoints_Day > 100 Then GBL_CHK_TempStr = "银行设置利率必须是小于或等于100，并且大于或等于0的数字<br>" & VbCrLf : Exit Function

	If Not isNumeric(Form_DEF_UserPoints_Move) Then GBL_CHK_TempStr = "社区银行转帐手续费必须为数字<br>" & VbCrLf : Exit Function
	Form_DEF_UserPoints_Move = cDbl(Form_DEF_UserPoints_Move)
	If Form_DEF_UserPoints_Move < 0 or Form_DEF_UserPoints_Move > 100 Then GBL_CHK_TempStr = "银行设置转帐手续费必须是小于或等于100，并且大于或等于0的数字<br>" & VbCrLf : Exit Function
	
	If Not isNumeric(Form_DEF_UserPoints_VIP_m) Then GBL_CHK_TempStr = "社区银行VIP存款极限倍率必须为数字<br>" & VbCrLf : Exit Function
	Form_DEF_UserPoints_VIP_m = cDbl(Form_DEF_UserPoints_VIP_m)
	If Form_DEF_UserPoints_VIP_m < 0 or Form_DEF_UserPoints_VIP_m > 100 Then GBL_CHK_TempStr = "银行设置VIP存款极限倍率必须是小于或等于100，并且大于或等于0的数字<br>" & VbCrLf : Exit Function
	
	If Form_DEF_BK_SET_Open <> "1" Then Form_DEF_BK_SET_Open = 0
	If Form_DEF_BK_SET_Default <> "1" Then Form_DEF_BK_SET_Default = 0
	If Form_DEF_BK_SET_Move <> "1" Then Form_DEF_BK_SET_Move = 0
	If Form_DEF_BK_SET_WriteLog <> "1" Then Form_DEF_BK_SET_WriteLog = 0
	If Form_DEF_BK_SET_Massage <> "1" Then Form_DEF_BK_SET_Massage = 0
	If Form_DEF_BK_SET_Limit_Total <> "1" Then Form_DEF_BK_SET_Limit_Total = 0
	If Form_DEF_BK_SET_WriteLog = "1" and inStr(Form_DEF_BK_LogPath,"""") Then GBL_CHK_TempStr = "银行日志地址不能包含有引号<br>" & VbCrLfE
	
End Function

Function MakeDataBaseLinkFile

	Dim TempStr,N
	TempStr = ""
	TempStr = TempStr & chr(60) & "%" & VbCrLf

	TempStr = TempStr & "Dim DEF_UserSavePoints" & VbCrLf	
	TempStr = TempStr & "DEF_UserSavePoints = Array("
	For n = 0 to DEF_UserLevelNum
		If n = 0 Then
			TempStr = TempStr & Form_DEF_UserSavePoints(n)
		Else
			TempStr = TempStr & "," & Form_DEF_UserSavePoints(n)
		End If
	Next
	TempStr = TempStr & ")" & VbCrLf
	TempStr = TempStr & "Const DEF_UserPoints_Day = " & Form_DEF_UserPoints_Day / 100 & VbCrLf
	TempStr = TempStr & "Const DEF_UserPoints_Tax = " & 1 - (Form_DEF_UserPoints_Tax / 100) & VbCrLf
	TempStr = TempStr & "Const DEF_UserPoints_Move = " & 1 - (Form_DEF_UserPoints_Move / 100) & VbCrLf
	TempStr = TempStr & "Const DEF_UserPoints_VIP_m = " & Form_DEF_UserPoints_VIP_m & VbCrLf
	TempStr = TempStr & "Const DEF_BK_SET_Open = " & Form_DEF_BK_SET_Open & VbCrLf
	TempStr = TempStr & "Const DEF_BK_SET_Default = " & Form_DEF_BK_SET_Default & VbCrLf
	TempStr = TempStr & "Const DEF_BK_SET_Move = " & Form_DEF_BK_SET_Move & VbCrLf
	TempStr = TempStr & "Const DEF_BK_SET_WriteLog = " & Form_DEF_BK_SET_WriteLog & VbCrLf
	TempStr = TempStr & "Const DEF_BK_SET_Massage = " & Form_DEF_BK_SET_Massage & VbCrLf
	TempStr = TempStr & "Const DEF_BK_SET_Limit_Total = " & Form_DEF_BK_SET_Limit_Total & VbCrLf
	TempStr = TempStr & "Const DEF_BK_SET_OpenAt = " & Form_DEF_BK_SET_OpenAt & VbCrLf
	TempStr = TempStr & "Const DEF_BK_SET_CloseAt = " & (Form_DEF_BK_SET_CloseAt - 1) & VbCrLf
	TempStr = TempStr & "Const DEF_BK_LogPath = """ & Form_DEF_BK_LogPath & """" & VbCrLf
	TempStr = TempStr & "Const DEF_BK_CloseInfo = """ & htmlencode(Form_DEF_BK_CloseInfo) & """" & VbCrLf
	
	TempStr = TempStr & "%" & chr(62) & VbCrLf

	ADODB_SaveToFile TempStr,"../../inc/Bank_Setup.ASP"
	If GBL_CHK_TempStr = "" Then
		Response.Write "<br><font color=Green class=GreenFont>2.成功完成设置！</font>"
	Else
		%><%=GBL_CHK_TempStr%><br>服务器不支持在线写入文件功能，请使用FTP等功能，将<font color=Red Class=RedFont>inc/Bank_Setup.ASP</font>文件替换成框中内容(注意备份)<p>
		<textarea name="fileContent" cols="80" rows="30" class=fmtxtra><%=Server.htmlencode(TempStr)%></textarea><%
		GBL_CHK_TempStr = ""
	End If
	
End Function
%>