<!-- #include file=../../inc/BBSsetup.asp -->
<!-- #include file=../../inc/Board_Popfun.asp -->
<!-- #include file=../inc/bbsmanage_Fun.asp -->
<%
DEF_BBS_HomeUrl = "../../"
Dim GBL_ID
initDatabase
GBL_CHK_TempStr = ""
GBL_ID = checkSupervisorPass

SiteHead(DEF_SiteNameString & " - 管理员")
UserTopicTopInfo
DisplayUserNavigate("屏蔽ＩＰ地址管理")%>
<br><br><%
If GBL_CHK_Flag=1 Then
	LoginAccuessFul
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 LoginAccuessFul

	Dim Rs,SQL,NewNum
	Set rs = Server.CreateObject("ADODB.Recordset")

	GBL_CHK_TempStr=""
	Dim UpDownPageFlag
	UpDownPageFlag = Request("UpDownPageFlag")

	Dim Start,recordCount,key
	recordCount=0
	
	Dim SQLendString

	Start = Left(Trim(Request("Start")),14)
	Start = start
	If isNumeric(Start)=0 or Start="" Then Start=999999999
	Start = cCur(Start)
	If Start = 0 Then Start=999999999

	Dim SQLCountString,whereFlag

	Rem 下面的代码使目前暂不提供城市分类双重查询
	
	SQLCountString = SQLendString
	If UpDownPageFlag = "1" and Start>0 then
		If whereFlag = 1 Then
			SQLendString = SQLendString & " and ID>" & Start
		Else
			SQLendString = SQLendString & " where ID>" & Start
			whereFlag = 1
		End If
	Else
		If whereFlag = 1 Then
			SQLendString = SQLendString & " and ID<" & Start
		Else
			SQLendString = SQLendString & " where ID<" & Start
			whereFlag = 1
		End If
	end If

	If UpDownPageFlag = "1" then
		SQLendString = SQLendString & " Order by ID ASC"
	Else
		SQLendString = SQLendString & " Order by ID DESC"
	End If
	
	Dim MaxRecordID,MinRecordID
	MaxRecordID = 0

	SQL = "select Max(id) from LeadBBS_ForbidIP " & SQLCountString
	Set Rs = Con.ExeCute(SQL)
	GBL_DBNum = GBL_DBNum + 1
	
	If not Rs.Eof Then
		If Rs(0) <> "" Then
			MaxRecordID = cCur(Rs(0))
		Else
			MaxRecordID = 0
		End If
	End If
	Rs.Close
	Set Rs = Nothing
	
	SQL = "select Min(id) from LeadBBS_ForbidIP " & SQLCountString
	Set Rs = Con.ExeCute(SQL)
	GBL_DBNum = GBL_DBNum + 1

	If not Rs.Eof Then
		If Rs(0) <> "" Then
			MinRecordID = cCur(Rs(0))
		else
			MinRecordID = 0
		end If
	End If
	Rs.Close
	Set Rs = Nothing

	Dim FirstID,LastID	
	SQL = "select count(*) from LeadBBS_ForbidIP " & SQLCountString
	Set Rs = Con.ExeCute(SQL)
	GBL_DBNum = GBL_DBNum + 1
	if rs.eof then
		recordCount=0
	else
		recordCount=rs(0)
		if recordCount="" or isNull(recordCount) or len(recordCount)<1 Then recordCount=0
	End If
	Rs.Close

	SQL = "select TOP "&DEF_MaxListNum&" ID,IPStart,IPEnd,IPNumber,ExpiresTime,WhyString from LeadBBS_ForbidIP " & SQLendString
	Set Rs = Con.ExeCute(SQL)
	GBL_DBNum = GBL_DBNum + 1
	Dim Num
	Dim GetData
	If Not rs.Eof Then
		GetData = Rs.GetRows(-1)
		Num = Ubound(GetData,2)
	Else
		Num = -1
	End If
	Rs.close
	Set Rs = Nothing
	
	Dim i,N
	If Num>=0 Then
		i=1
	
		Dim MinN,MaxN,StepValue
		SQL = ubound(getdata,2)
		If UpDownPageFlag = "1" then
			MinN = SQL
			MaxN = 0
			StepValue = -1
		Else
			MinN = 0
			MaxN = SQL
			StepValue = 1
		End If
		
		LastID = cCur(GetData(0,MaxN))
		FirstID = cCur(GetData(0,MinN))
	
		Dim EndwriteQueryString,PageSplictString
		EndwriteQueryString = "?test=ttt"
	
		PageSplictString = PageSplictString & "<table cellspacing=0 cellpadding=0><tr><td colspan=4>&nbsp;"
		If FirstID >= MaxRecordID Then
			PageSplictString = PageSplictString & "<font color=999999 class=GrayFont>首页</font> " & VbCrLf
			PageSplictString = PageSplictString & " <font color=999999 class=GrayFont>上页</font> " & VbCrLf
		else
			PageSplictString = PageSplictString & "<a href=IPManage.asp" & EndwriteQueryString & "&Start=0>首页</a> " & VbCrLf
			PageSplictString = PageSplictString & " <a href=IPManage.asp" & EndwriteQueryString & "&Start=" & FirstID & "&UpDownPageFlag=1>上页</a> " & VbCrLf
		end if
	
		if LastID<MaxRecordID and LastID<>0 then
		else
		end if
	
		If LastID <= MinRecordID Then
			PageSplictString = PageSplictString & " <font color=999999 class=GrayFont>下页</font> " & VbCrLf
			PageSplictString = PageSplictString & " <font color=999999 class=GrayFont>尾页</font> " & VbCrLf
		else
			PageSplictString = PageSplictString & " <a href=IPManage.asp" & EndwriteQueryString & "&Start=" & LastID & ">下页</a> " & VbCrLf
			PageSplictString = PageSplictString & " <a href=IPManage.asp" & EndwriteQueryString & "&Start=1&UpDownPageFlag=1>尾页</a> " & VbCrLf
		end if
		
		PageSplictString = PageSplictString & "&nbsp;共<b>" & recordCount & "</b>条记录"
		If (recordCount mod DEF_MaxListNum)=0 Then
			PageSplictString = PageSplictString & " 计<b>" & clng(recordCount/DEF_MaxListNum) & "</b>页"
		Else
			If recordCount>=DEF_MaxListNum Then
				SQL = fix(recordCount/DEF_MaxListNum)
				If (recordCount mod DEF_MaxListNum) <> 0 Then SQL = SQL + 1
				PageSplictString = PageSplictString & " 计<b>" & SQL & "</b>页"
			Else
				PageSplictString = PageSplictString & " 计<b>1</b>页"
			End If
		End If
		PageSplictString = PageSplictString & " 每页<b>" & DEF_MaxListNum & "</b>条"
		PageSplictString = PageSplictString & "</td></tr></table>"
	
	End If

	%>
	<table cellspacing=0 cellpadding=0 width=100% border=0 height=5>
	<tr> 
		<td colspan="2" height="0"><img src="../images/BLANK.GIF" width="1" height="2"></td>
	</tr>
	</table>

	<script language=javascript>
		function kill(killID)
		{
			window.open('DeleteIP.asp?kasdie=3&KillID='+killID,'','width=450,height=37,scrollbars=auto,status=no');
		}
	</script>
	<%Response.Write "<b>共<font color=ff0000 class=RedFont>" & recordCount & "</font>个屏蔽项目</b>"%> <a href=NewForbidIP.asp>点击这里添加屏蔽ＩＰ地址</a>
	<table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="<%=DEF_BBS_LightColor%>" class=TBBG1>
	<tbody> 
	<tr height="19" bgcolor="<%=DEF_BBS_TableHeadColor%>" class=TBfour>
		<td><img src=img/blank.gif width=1 height=3><br>编目</td>
		<td ><img src=img/blank.gif width=1 height=3><br>ＩＰ范围</td>
		<td><img src=img/blank.gif width=1 height=3><br>数量</td>
		<td width=25><img src=img/blank.gif width=1 height=3><br>解除</td>
		<td><img src=img/blank.gif width=1 height=3><br>说明</td>
	</tr>
	<%
	If Num = -1 Then
		response.write "<tr bgcolor=" & DEF_BBS_LightestColor & " class=TBfour><td colspan=6 height=30>&nbsp; 没有任何屏蔽ＩＰ地址，<a href=NewForbidIP.asp>点击这里添加新屏蔽ＩＰ地址</a>。</td></tr>"
	end if

	Dim TempN

	if Num <> -1 then
		i=1
		LastID = GetData(0,ubound(getdata,2))
		for n= MinN to MaxN Step StepValue
			Response.Write "<tr height=19 bgcolor=" & DEF_BBS_LightestColor & " class=TBBG9><td width=30>" & GetData(0,n) & "</td>"
			Response.Write "<td width=200>" & RestoreIPAddress(GetData(1,n)) & " - "
			Response.Write RestoreIPAddress(GetData(2,n)) & "</td>"
			Response.Write "<td width=30>" & GetData(3,n) & "</td>"
			Response.Write "<td width=25><a href='javascript:kill(" & GetData(0,n) & ");'>解除</a></td>"
			Response.Write "<td>"
			If GetData(5,n) <> "" Then Response.Write htmlencode(GetData(5,n)) & "<br>"
			If cCur(GetData(4,n)) > 0 Then
				Response.Write "<font color=gray class=GrayFont>自解除时间：" & RestoreTime(GetData(4,n))
			Else
				Response.Write "<font color=gray class=GrayFont>此IP永久屏蔽，不能自动解除"
			End If
			Response.Write "</font></td>"
			Response.Write "</tr>" & VbCrLf
			i=i+1
		next
	End If
	If PageSplictString<>"" Then Response.Write "<tr bgcolor=" & DEF_BBS_TableHeadColor & " class=TBfour><td colspan=6>" & PageSplictString & "</td></tr>"
	%>
	</table>
	<br><%

End Function

Function RestoreIPAddress(NIP)

	NIP = Right("000000000000" & cStr(NIP),12)
	RestoreIPAddress = Left(NIP,3) & "." & Mid(NIP,4,3) & "." & Mid(NIP,7,3) & "." & Mid(NIP,10,3)

End Function%>