<%
Dim LimitBoardStringData,LimitBoardStringDataNum
Rem 1.所有人,2.只针对非版主,3.只针对非版主,4.只针对非版主,5.只针对非版主,6,所有人,7.所有人,8.仅对版主,9.开放论坛-针对未登录用户,10．所有人,11.所有人,12.分类版面,13.此版面帖子发出需要认证,14.特殊帖子包括回复帖与购买帖
LimitBoardStringData = Array("只有登录用户才能访问","只对认证会员开放","禁止发表新主题","不允许修改论坛帖子","不允许删除论坛帖子","禁止回复帖子","只对论坛版主以上开放","不允许转移帖子","开放论坛","仅允许版主发表主题","仅允许版主回复帖子","作为分类论坛","发帖需要审核才能显示","允许发表特殊帖子")
LimitBoardStringDataNum = Ubound(LimitBoardStringData,1)

Dim LimitUserStringData,LimitUserStringDataNum
Rem 1.所有人,2.所有人,3.所有人,4.所有人,版主同时限制修改自己版面,5.仅对版主,6.只针对版主有效,7.所有人,8.是否是论坛版主,9.是否允许版主转移帖子到其它论坛,10.是否是总版主,11.仅为版主总版主,12.仅针对总版主,13所有人,14.是否区版主
LimitUserStringData = Array("非正式会员","认证会员","禁止发言和发送短消息","禁止修改个人资料和帖子内容","禁止删除帖子","禁止精华帖子","所有发言屏蔽","论坛版主","禁止转移帖子","总版主","删除上传附件","特殊权限","仅接收好友短消息","区版主")
LimitUserStringDataNum = Ubound(LimitUserStringData,1)
Dim GBL_BoardMasterFlag
GBL_BoardMasterFlag = 0

Sub CheckisBoardMaster

	'If GBL_CheckPassDoneFlag = 0 Then CheckPass
	'6-分类版主
	If CheckSupervisorUserName = 1 Then
		GBL_BoardMasterFlag = 9 '管理员
	ElseIf GetBinarybit(GBL_CHK_UserLimit,10) = 1 Then
		GBL_BoardMasterFlag = 7 '总版主
	ElseIf GetBinarybit(GBL_CHK_UserLimit,14) = 1 Then
		If GBL_Board_MasterList = "?LeadBBS?" or inStr("," & GBL_Board_AssortMaster & ",","," & GBL_CHK_User & ",") > 0 Then
			GBL_BoardMasterFlag = 6 '本区版主
		Else
			If GetBinarybit(GBL_CHK_UserLimit,8) = 1 and (GBL_Board_MasterList = "?LeadBBS?" or inStr("," & GBL_Board_MasterList & ",","," & GBL_CHK_User & ",") > 0) Then
				GBL_BoardMasterFlag = 5 '本版版主
			Else
				GBL_BoardMasterFlag = 4 '版主
			End If
		End If
	ElseIf GetBinarybit(GBL_CHK_UserLimit,8) = 1 Then
		If GBL_Board_MasterList = "?LeadBBS?" or inStr("," & GBL_Board_MasterList & ",","," & GBL_CHK_User & ",") > 0 Then
			GBL_BoardMasterFlag = 5 '本版版主
		Else
			GBL_BoardMasterFlag = 4 '版主
		End If
	Else
		GBL_BoardMasterFlag = 0 '非版主
	End If

End Sub

Function CheckBoardReAnnounceLimit

	If GetBinarybit(GBL_Board_BoardLimit,12) = 1 Then
		GBL_CHK_TempStr = "此版面属于分类论坛，不允许此操作。" & VbCrLf
		CheckBoardReAnnounceLimit = 0
	ElseIf GetBinarybit(GBL_Board_BoardLimit,6) = 1 Then
		GBL_CHK_TempStr = "此版面" & LimitBoardStringData(5) & "。" & VbCrLf
		CheckBoardReAnnounceLimit = 0
	ElseIf GetBinarybit(GBL_Board_BoardLimit,11) = 1 and GBL_BoardMasterFlag = 0 Then
		GBL_CHK_TempStr = "此版面" & LimitBoardStringData(10) & "。" & VbCrLf
		CheckBoardReAnnounceLimit = 0
	End If
	CheckBoardReAnnounceLimit = 1

End Function

Function CheckBoardAnnounceLimit

	If GetBinarybit(GBL_Board_BoardLimit,12) = 1 Then
		GBL_CHK_TempStr = "此版面属于分类论坛，不允许此操作。" & VbCrLf
		CheckBoardAnnounceLimit = 0
	ElseIf GetBinarybit(GBL_Board_BoardLimit,3) = 1 Then
		GBL_CHK_TempStr = "此版面" & LimitBoardStringData(2) & "。" & VbCrLf
		CheckBoardAnnounceLimit = 0
	ElseIf GetBinarybit(GBL_Board_BoardLimit,10) = 1 and GBL_BoardMasterFlag = 0 Then
		GBL_CHK_TempStr = "此版面" & LimitBoardStringData(9) & "。" & VbCrLf
		CheckBoardAnnounceLimit = 0
	End If
	CheckBoardAnnounceLimit = 1

End Function

Function CheckUserAnnounceLimit

	If GetBinarybit(GBL_CHK_UserLimit,7) = 1 Then
		GBL_CHK_TempStr = "您处于" & LimitUserStringData(2) & "中，不必尝试这些操作。" & VbCrLf
		CheckUserAnnounceLimit = 0
		Exit Function
	End If
	If GetBinarybit(GBL_CHK_UserLimit,1) = 1 Then
		GBL_CHK_TempStr = "您目前处于" & LimitUserStringData(0) & "状态，请先<a href=" & DEF_BBS_HomeUrl & "User/UserTurnOn.asp>激活</a>或等待管理人员审核。" & VbCrLf
		CheckUserAnnounceLimit = 0
		Exit Function
	End If
	If GetBinarybit(GBL_CHK_UserLimit,3) = 1 Then
		GBL_CHK_TempStr = "您已经被" & LimitUserStringData(2) & "，投票等操作。" & VbCrLf
		CheckUserAnnounceLimit = 0
		Exit Function
	End If
	CheckUserAnnounceLimit = 1

End Function

Function CheckBoardModifyLimit

	If GetBinarybit(GBL_Board_BoardLimit,4) = 1 Then
		GBL_CHK_TempStr = "此版面" & LimitBoardStringData(3) & "。" & VbCrLf
		CheckBoardModifyLimit = 0
		Exit Function
	End If
	CheckBoardModifyLimit = 1

End Function

Function CheckUserModifyLimit

	If GetBinarybit(GBL_CHK_UserLimit,4) = 1 Then
		GBL_CHK_TempStr = "您已经被" & LimitUserStringData(3) & "。" & VbCrLf
		CheckUserModifyLimit = 0
		Exit Function
	End If
	CheckUserModifyLimit = 1

End Function


Function GetBinaryString(Number)
	
	Dim Temp1,Temp2,TempN
	Temp2 = Number
	Temp1 = ""
	For TempN = BinaryDataNum+1 to 1 step -1
		If Temp2 >= BinaryData(TempN-1) Then
			Temp1 = Temp1 & "1"
			Temp2 = Temp2 - BinaryData(TempN-1)
		Else
			Temp1 = Temp1 & "0"
		End If
	Next
	GetBinaryString = Temp1

End Function

Function SetBinarybit(Number,bit,value)

	Dim Temp
	Temp = GetBinarybit(Number,bit)

	If Temp = value Then
		SetBinarybit = Number
	ElseIf Temp = 1 and  value = 0 Then
		SetBinarybit = Number - BinaryData(Bit-1)
	ElseIf Temp = 0 and  value = 1 Then
		SetBinarybit = Number + BinaryData(Bit-1)
	End If

End Function

Sub CheckAccessLimit_TimeLimit

	If GBL_Board_ID < 1 Then Exit Sub
	If (GBL_Board_StartTime <> "000000" or GBL_Board_EndTime <> "000000")  Then
		Dim T1,t2,t3
		t1 = int(Mid(GBL_Board_StartTime,1,2))
		t2 = int(Mid(GBL_Board_EndTime,1,2))
		If t1 <> 0 or t2 <> 0 Then
			t3 = hour(DEF_Now)
			If t2 >= t1 Then
				if t3 >= t1 and t3 <=t2 Then
					GBL_CHK_TempStr = "此版面每天 " & t1 & ":00 到 " & t2 & ":59  限时关闭,现在时间" & DEF_Now & "。" & VbCrLf
					Exit Sub
				End If
			Else
				If (t3 >= t1 and t3 <=23) or (t3 >=0 and t3 <=t2) Then
					GBL_CHK_TempStr = "此版面每天 " & t1 & ":00 到 次日" & t2 & ":59  限时关闭,现在时间" & DEF_Now & "。" & VbCrLf
					Exit Sub
				End If
			End If
		End If
		t1 = int(Mid(GBL_Board_StartTime,3,2))
		t2 = int(Mid(GBL_Board_EndTime,3,2))
		If t1 <> 0 or t2 <> 0 Then
			t3 = weekday(date,2)
			If t2 >= t1 Then
				if t3 >= t1 and t3 <=t2 Then
					GBL_CHK_TempStr = "此版面每周 " & t1 & " - " & t2 & " 关闭中,今天是星期" & t3  & "。" & VbCrLf
					Exit Sub
				End If
			Else
				If (t3 >= t1 and t3 <=7) or (t3 >=1 and t3 <=t2) Then
					GBL_CHK_TempStr = "此版面每周" & t1 & "到周日，周一到周" & t2 & " 关闭中,今天是星期" & t3  & "。" & VbCrLf
					Exit Sub
				End If
			End If
		End If
		t1 = int(Mid(GBL_Board_StartTime,5,2))
		t2 = int(Mid(GBL_Board_EndTime,5,2))
		If t1 <> 0 or t2 <> 0 Then
			t3 = day(date)
			If t2 >= t1 Then
				if t3 >= t1 and t3 <=t2 Then
					GBL_CHK_TempStr = "此版面每月 " & t1 & "号 - " & t2 & "号 关闭中,今天是" & t3  & "号。" & VbCrLf
					Exit Sub
				End If
			Else
				If (t3 >= t1 and t3 <=31) or (t3 >=1 and t3 <=t2) Then
					GBL_CHK_TempStr = "此版面每月 " & t1 & "号到月底，一号到" & t2 & "号 关闭中,今天是" & t3  & "号。" & VbCrLf
					Exit Sub
				End If
			End If
		End If
	End If

End Sub
	

Sub CheckAccessLimit

	Dim Temp
	If GBL_Board_ID < 1 Then Exit Sub
	
	If GBL_Board_OtherLimit > 0 Then
		If GBL_Board_OtherLimit < 100 Then
			Temp = 0
		Else
			Temp = cCur(Left(GBL_Board_OtherLimit,Len(GBL_Board_OtherLimit)-2))
		End If
		Select Case CCur(Right(GBL_Board_OtherLimit,2))
			Case 1: If GBL_CHK_Points < Temp Then GBL_CHK_TempStr = "你的" & DEF_PointsName & "值不足，访问此版面需要" & Temp & DEF_PointsName & "。" & VbCrLf
			Case 2: If (GBL_CHK_OnlineTime/60) < Temp Then GBL_CHK_TempStr = "你的经验值不足，访问此版面需要" & Temp & "经验值。" & VbCrLf
			Case 3: If GBL_CHK_CharmPoint < Temp Then GBL_CHK_TempStr = "你的魅力值不足，访问此版面需要" & Temp & "魅力值。" & VbCrLf
			Case 4: If GBL_CHK_CachetValue < Temp Then GBL_CHK_TempStr = "你的威望值不足，访问此版面需要" & Temp & "威望值。" & VbCrLf
		End Select
		If GBL_CHK_TempStr <> "" Then Exit Sub
	End If

	If GetBinarybit(GBL_Board_BoardLimit,7) = 1 Then
		If GBL_BoardMasterFlag < 4 or GBL_UserID < 1 Then
			GBL_CHK_TempStr = "此版面" & LimitBoardStringData(6) & "。" & VbCrLf
			Exit Sub
		End If
	End If

	If GBL_CHK_GuestFlag = 1 and GetBinarybit(GBL_Board_BoardLimit,1) = 1 and GBL_CHK_Flag = 0 Then
		GBL_CHK_TempStr = "此版面" & LimitBoardStringData(0) & "，请先<a href=" & DEF_BBS_HomeUrl & "User/Login.asp?u=" & urlencode(Request.Servervariables("SCRIPT_NAME") & "?" & Request.QueryString) & ">登录</a>或<a href=" & DEF_BBS_HomeUrl & "User/UserJoin.asp>注册</a>新用户。" & VbCrLf
		Exit Sub
	End If

	If GetBinarybit(GBL_Board_BoardLimit,2) = 1 Then
		If GetBinarybit(GBL_CHK_UserLimit,2) = 0 or GBL_UserID < 1 Then
			GBL_CHK_TempStr = "此版面" & LimitBoardStringData(1) & "。" & VbCrLf
			Exit Sub
		End If
	End If

	If GBL_UserID > 0 and CheckSupervisorUserName = 1 Then Exit Sub
	If GBL_CHK_TempStr <> "" Then Exit Sub
	If GBL_Board_HiddenFlag = 2 Then
		GBL_CHK_TempStr = GBL_CHK_TempStr & "此版面已经关闭,禁止浏览。" & VbCrLf
		Exit Sub
	End If

	If GBL_Board_ForumPass <> "" Then
		If GBL_UserID < 1 Then
			GBL_CHK_TempStr = GBL_CHK_TempStr & "<p><font color=ff0000><b>请先以用户身份登录!</b></font>" & VbCrLf
			Exit sub
		End If

		If GBL_CHK_LastWriteTime < DEF_WriteEventSpace Then
			GBL_CHK_TempStr = "<b><font color=Red Class=RedFont>您的操作太频，请稍候再试!</font></b>" & VbCrLf
			Exit sub
		End If
		If GBL_Board_ForumPass <> Request.Cookies(DEF_MasterCookies & "_" & GBL_UserID)("Board_" & GBL_board_ID) Then
			GBL_CHK_TempStr = GBL_CHK_TempStr & " " & VbCrLf
			%>
		<br>
		<table width="<%=DEF_BBS_ScreenWidth%>" border="0" cellspacing="0" cellpadding="0" align="center">
		<tr>
			<td>
			<%
			Dim ForumPass
			If Request("submitflag") <> "" Then
				ForumPass = Request.Form("ForumPass")
				Dim NumCheck
				NumCheck = CheckRndNumber
				If ForumPass = GBL_Board_ForumPass and NumCheck = 1 Then
					Response.Cookies(DEF_MasterCookies & "_" & GBL_UserID)("Board_" & GBL_board_ID) = ForumPass
					Response.Cookies(DEF_MasterCookies & "_" & GBL_UserID).Expires = Date + 365
					Response.Write "<b><font color=008800>登录成功</font></b>"
					Response.Write "<br><br>-- 返回 <a href=http://"&Request.ServerVariables("SERVER_NAME")&Request.ServerVariables("URL") & "?" & Request.QueryString & ">" & htmlencode(Request.ServerVariables("SERVER_NAME")&Request.ServerVariables("URL")) & "</a>" & VbCrLf
				Else
					If NumCheck = 0 Then
						Response.Write "<b><font color=ff0000>验证码填写错误!</font></b><br>" & VbCrLf
					Else
						Response.Write "<b><font color=ff0000>您的密码错误!</font></b><br>" & VbCrLf
					End If
					Con.ExeCute("Update LeadBBS_User Set LastWriteTime=" & GetTimeValue(DEF_Now) & " where ID=" & GBL_UserID)
					GBL_DBNum = GBL_DBNum + 1
					DisplayPassWordLoginForm
				End If
			Else
				Response.Write "<b>此论坛为加密论坛,请输入正确的登录密码.</b><br>" & VbCrLf
				DisplayPassWordLoginForm
			End If
			%></td>
		</tr>
		</table><%
			Exit Sub
		End If
	End If

End Sub

Function CheckRndNumber

	If DEF_EnableAttestNumber = 0 Then
		CheckRndNumber = 1
		Exit Function
	End If

	Dim RndNumber
	Dim Rs
	RndNumber = Left(Session(DEF_MasterCookies & "RndNum") & "",4)
	If RndNumber = "" or isNumeric(RndNumber) = 0 Then
		'RndNumber = 0
		Randomize
		RndNumber = Fix(Rnd*9999)+1
		Session(DEF_MasterCookies & "RndNum") = RndNumber
	End If
	RndNumber = cCur(RndNumber)
	If RndNumber = 0 Then
		RndNumber = 9999999
	End If
	
	Dim ForumNumber
	ForumNumber = Left(Request.Form("ForumNumber"),4)
	If isNumeric(ForumNumber) = False Then ForumNumber = 0
	ForumNumber = Fix(cCur(ForumNumber))
	If RndNumber = ForumNumber and RndNumber > 0 Then
		CheckRndNumber = 1
	Else
		CheckRndNumber = 0
	End If
	Randomize
	Session(DEF_MasterCookies & "RndNum") = Fix(Rnd*9999)+1

End Function

Sub DisplayPassWordLoginForm

	Dim Temp
	Temp = Request.ServerVariables("URL")
	Temp = StrReverse(Temp)
	Temp = Replace(Temp,"\","/")
	if Instr(Temp,"/") > 0 Then Temp = Left(Temp,Instr(Temp,"/")-1)
	Temp = StrReverse(Temp)
	%>
	<p>
	<form action=<%=Temp%>?<%=Request.QueryString%> method="post">
		密　码: <input name=ForumPass type=password maxlength=20 size=20 value="<%=htmlencode(Request("ForumPass"))%>" class=fminpt><br><%If DEF_EnableAttestNumber > 0 Then%>
		验证码: <input name=ForumNumber maxlength=20 size=20 value="<%=htmlencode(Request("RndNumber"))%>" class=fminpt><br>
		<img src=<%=DEF_BBS_HomeUrl%>images/null.gif height=3 width=2><br>
		请在验证码框输入<img src=<%=DEF_BBS_HomeUrl%>User/number.asp?n=<%=timer%> align=absmiddle width=32 height=12><%End If%> [<a href=<%=DEF_BBS_HomeUrl%>User/help/help.asp#code>说明</a>]<p>
		<input name=submitflag type=hidden value="ddddls-+++">
		<input type=submit value="登录" class=fmbtn> <input type=reset value="取消" class=fmbtn>
	</form>
		注意：如果提交后验证码显示数字始终是0000，请在线一段时间后再重试。
	<%

End Sub%>