<!-- #include file="include/onlogin.asp" -->
<!-- #include file="include/csk3000_page_cute.asp" -->
<!-- #include file="include/conn.asp" -->
<%tit="<a href=""?action=add&mb=mb"">开通网吧IP</a>－<a href='?action=mb'>网吧IP管理</a>－－－<a href=?action=add>增加封锁IP</a>－<a href='?'>封锁IP管理</a>  "

response.write header(22,tit)

titt="IP管理"
response.write admin_bar(titt,1,"99%")

call main()
sub main()
dim userip,ips,GetIp1,GetIp2,data
if request("userip")<>"" then
userip=request("userip")
ips=Split(userIP,".")
GetIp1=ips(0)&"."&ips(1)&"."&ips(2)&".1"
GetIp2=ips(0)&"."&ips(1)&"."&ips(2)&".255"
else 
userip=""
GetIp1=""
GetIp2=""
end if
if request("action")="add" then
%>
<table width="95%" border="0" cellspacing="1" cellpadding="3"  align=center class="tableBorder">
<%
dim sip,str1,str2,str3,str4,num_1,num_2,mbname
if request.querystring("reaction")="save" then
	sip=cstr(request.form("ip1"))
	'dot=instr(ip,".")-1
	'response.write dot
	str1=left(sip,cint(instr(sip,".")-1))
	sip=mid(sip,cint(instr(sip,"."))+1)
	str2=left(sip,cint(instr(sip,"."))-1)
	sip=mid(sip,cint(instr(sip,"."))+1)
	str3=left(sip,cint(instr(sip,"."))-1)
	str4=mid(sip,cint(instr(sip,"."))+1)
	num_1=cint(str1)*256*256*256+cint(str2)*256*256+cint(str3)*256+cint(str4)-1
	
	mbname=cstr(request.form("mbname"))
	data=cstr(request.form("data"))
	sip=cstr(request.form("ip2"))
	str1=left(sip,instr(sip,".")-1)
	sip=mid(sip,instr(sip,".")+1)
	str2=left(sip,instr(sip,".")-1)
	sip=mid(sip,instr(sip,".")+1)
	str3=left(sip,instr(sip,".")-1)
	str4=mid(sip,instr(sip,".")+1)
	num_2=cint(str1)*256*256*256+cint(str2)*256*256+cint(str3)*256+cint(str4)-1
	'response.write num_1 &","& num_2
	'response.end

	set rs = server.CreateObject ("adodb.recordset")
	sql="select * from LockIP"
	rs.open sql,conn,1,3
	rs.addnew
	rs("ip1")=num_1
	rs("why")=trim(request.form("why"))
	rs("ip2")=num_2
	rs("sip1")=request.form("ip1")
	rs("sip2")=request.form("ip2")
	rs("mbname")=mbname
	rs("time")=now()+data
	rs.update
	rs.close
	set rs=nothing
	conn.close
	set conn=nothing
%>
<tr>
<td width="100%" class=forumrow bgcolor="#99CCFF">
<span style="font-size: 9pt">添加成功！</td>
</tr>
<%
elseif request("mb")="mb" then
%><table width="95%" border="0" cellspacing="1" cellpadding="3"  align=center class="tableBorder">
<tr> 
<th width="100%" colspan=2 bgcolor="#33CCFF"><span style="font-size: 9pt">
<font color="#FFFFFF">网吧IP开通管理－－添加</font></th>
</tr>

<form action="?action=add&reaction=save" method="post">
<tr>
<td width="20%" class=forumrow bgcolor="#99CCFF"><span style="font-size: 9pt">网吧名称</span></td>
<td width="80%" class=forumrow bgcolor="#99CCFF"><span style="font-size: 9pt">
<input type="text" name="mbname" size="30" value="<%=mbname%>"></span></td>
</tr>
<tr>
<td width="20%" class=forumrow bgcolor="#99CCFF"><span style="font-size: 9pt">起始I&nbsp;P</span></td>
<td width="80%" class=forumrow bgcolor="#99CCFF"><span style="font-size: 9pt"><input type="text" name="ip1" size="30" value="<%=GetIp1%>">&nbsp;如202.96.0.0</span></td>
</tr>
<tr>
<td width="20%" class=forumrow bgcolor="#99CCFF"><span style="font-size: 9pt">结尾I&nbsp;P</span></td>
<td width="80%" class=forumrow bgcolor="#99CCFF"><span style="font-size: 9pt"><input type="text" name="ip2" size="30" value="<%=GetIp2%>">&nbsp;如202.96.0.255</span></td>
</tr>
<tr>
<td width="20%" class=forumrow bgcolor="#99CCFF">到期时间</td>
<td width="80%" class=forumrow bgcolor="#99CCFF"><span style="font-size: 9pt">
<select size="1" name="data">
<option value="30">一个月</option>
<option value="60">三个月</option>
<option>半年</option>
<option value="365">一年</option>
<option value="800">二年</option>
<option value="9999">无限制</option>
</select></span></td>
</tr>
<tr>
<td width="20%" class=forumrow bgcolor="#99CCFF">说明</td>
<td width="80%" class=forumrow bgcolor="#99CCFF">
<span style="font-size: 9pt">
<textarea rows="3" name="why" cols="28">没有说明</textarea></span></td>
</tr>
<tr>
<td width="20%" class=forumrow bgcolor="#99CCFF"></td>
<td width="80%" class=forumrow bgcolor="#99CCFF">
<span style="font-size: 9pt">
<input type="submit" name="Submit" value="提 交">
</td>
</tr>
</form>
<%else%>
<form action="?action=add&reaction=save" method="post">
<tr>
<th width="100%" colspan=2 bgcolor="#33CCFF"><span style="font-size: 9pt">
<font color="#FFFFFF">IP限制管理－－添加</font></th>
</tr>
<tr>
<td width="20%" class=forumrow bgcolor="#99CCFF"><span style="font-size: 9pt">起始I&nbsp;P</span></td>
<td width="80%" class=forumrow bgcolor="#99CCFF"><span style="font-size: 9pt"><input type="text" name="ip1" size="30" value="<%=GetIp1%>">&nbsp;如202.96.0.0</span></td>
</tr>
<tr>
<td width="20%" class=forumrow bgcolor="#99CCFF"><span style="font-size: 9pt">结尾I&nbsp;P</span></td>
<td width="80%" class=forumrow bgcolor="#99CCFF"><span style="font-size: 9pt"><input type="text" name="ip2" size="30" value="<%=GetIp2%>">&nbsp;如202.96.0.255</span></td>
</tr>
<tr>
<td width="20%" class=forumrow bgcolor="#99CCFF">到期时间</td>
<td width="80%" class=forumrow bgcolor="#99CCFF"><span style="font-size: 9pt">
<select size="1" name="data">
<option value="1">一天</option>
<option value="30">一个月</option>
<option>半年</option>
<option value="365">一年</option>
<option value="800">二年</option>
<option value="9999">无限制</option>
</select></span></td>
</tr>
<tr>
<td width="20%" class=forumrow bgcolor="#99CCFF"><span style="font-size: 9pt">原&nbsp;&nbsp;&nbsp; 因</span></td>
<td width="80%" class=forumrow bgcolor="#99CCFF">
<span style="font-size: 9pt">
<textarea rows="3" name="why" cols="28">没有原因</textarea></span></td>
</tr>
<tr>
<td width="20%" class=forumrow bgcolor="#99CCFF"></td>
<td width="80%" class=forumrow bgcolor="#99CCFF">
<span style="font-size: 9pt">
<input type="submit" name="Submit" value="提 交">
</td>
</tr>
</form><%end if
elseif request("action")="delip" then
	conn.execute("delete from lockip where id in ("&request.form("delid")&")")
	response.write "删除成功！"
else
%> </span>
<FORM METHOD=POST ACTION="?action=delip">
</table>
<div align="center">
  <center>
<table width="785" border="0" cellspacing="0" cellpadding="3" class="tableBorder" style="border-collapse: collapse" bordercolor="#111111">
<tr> 
<th width="100%" colspan=8 bgcolor="#0000FF">
<p align="left">
<span style="font-size: 9pt"><font color="#FFFFFF">
－－－－<a href="?action=mb"><font color="#FFFFFF">开通网吧IP管理</font></a>－－－－－－<a href="?"><font color="#FFFFFF">已封IP管理</font></a>－－－－&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF0000">红色</font><font color="#FFFFFF">表
示到期&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font> </span></th>
</tr>
<tr> 
<th width="100%" colspan=8 bgcolor="#0000FF">
<p align="right">
<span style="font-size: 9pt"><font color="#FFFFFF">
&nbsp; </font><input type=submit name=submit value="删除"><input type=checkbox value="on" name="chkall" onclick="CheckAll(this.form)"></span></th>
</tr>
<tr>
<td width="5%" align="center" class="forumHeaderBackgroundAlternate" bgcolor="#33CCFF"><B>
<span style="font-size: 9pt">ID</span></B></td>
<%if request("action")="mb" then%><td width="15%" align="center" class="forumHeaderBackgroundAlternate" bgcolor="#33CCFF">网吧名称</td><%end if%>
<td width="15%" align="center" class="forumHeaderBackgroundAlternate" bgcolor="#33CCFF"><B>
<span style="font-size: 9pt">起始IP</span></B></td>
<td width="15%" align="center" class="forumHeaderBackgroundAlternate" bgcolor="#33CCFF"><B>
<span style="font-size: 9pt">结尾IP</span></B></td>
<td width="15%" align="center" class="forumHeaderBackgroundAlternate" bgcolor="#33CCFF">
<b>原因说明</b></td>
<td width="15%" align="center" class="forumHeaderBackgroundAlternate" bgcolor="#33CCFF">
<b>時間</b></td>
<td width="15%" align="center" class="forumHeaderBackgroundAlternate" bgcolor="#33CCFF">
<b>到期</b></td>
<td width="5%" align="center" class="forumHeaderBackgroundAlternate" bgcolor="#33CCFF"><B>
<span style="font-size: 9pt">操作</span></B></td>
</tr>
<%
	dim currentpage,page_count,Pcount
	dim totalrec,endpage
	currentPage=request("page")
	if currentpage="" then
		currentpage=1
	else
		currentpage=clng(currentpage)
		if err then
			currentpage=1
			err.clear
		end if
	end if
	
if request("action")="mb" then
	sql="select * from LockIP where mbname<>'' order by id desc"
else
	sql="select * from LockIP where mbname='' order by id desc"
end if
	Set rs= Server.CreateObject("ADODB.Recordset")
	rs.open sql,conn,1,3
	if rs.eof and rs.bof then
%> </span>
<tr> 
<td width="5%" colspan=8 class=forumrow bgcolor="#99CCFF">
<span style="font-size: 9pt">还没有任何IP限制数据。</td>
</tr>
<%
	else
		rs.PageSize = 1500
		rs.AbsolutePage=currentpage
		page_count=0
		totalrec=rs.recordcount
		while (not rs.eof) and (not page_count = 1500)

dim coler
if now()=>rs("time") then
coler="red"
else
coler="#99CCFF"
end if%>
 </span>
<tr>
<td width="5%" align="center" class=forumrow bgcolor="<%=coler%>"><%=rs("id")%></td>
<%if request("action")="mb" then%><td width="15%" align="center" class=forumrow bgcolor="<%=coler%>"><%=rs("mbname")%></td><%end if%>
<td width="15%" align="center" class=forumrow bgcolor="<%=coler%>"><%=rs("sip1")%></td>
<td width="15%" align="center" class=forumrow bgcolor="<%=coler%>"><%=rs("sip2")%></td>
<td width="15%" align="center" class=forumrow bgcolor="<%=coler%>"><%=rs("why")%></td>
<td width="15%" align="center" class=forumrow bgcolor="<%=coler%>"><%=rs("tim")%></td>
<td width="15%" align="center" class=forumrow bgcolor="<%=coler%>"><%=rs("time")%></td>
<td width="5%" align="center" class=forumrow bgcolor="<%=coler%>">
<span style="font-size: 9pt"><input type=checkbox name="delid" value="<%=cstr(rs("ID"))%>"></span></td>
</tr>
<%
		page_count = page_count + 1
		rs.movenext
		wend
%><span style="font-size: 9pt"> </span>
<tr>
  <td colspan=8 class=forumrow align=center bgcolor="#99CCFF" width="846" height="18">
  <span style="font-size: 9pt">分页：
<%Pcount=rs.PageCount
	if currentpage > 4 then
	response.write "<a href=""?page=1"">[1]</a> ..."
	end if
	if Pcount>currentpage+3 then
	endpage=currentpage+3
	else
	endpage=Pcount
	end if
	for i=currentpage-3 to endpage
	if not i<1 then
		if i = clng(currentpage) then
        response.write " <font color=red>["&i&"]</font>"
		else
        response.write " <a href=""?page="&i&""">["&i&"]</a>"
		end if
	end if
	next
	if currentpage+3 < Pcount then 
	response.write "... <a href=""?page="&Pcount&""">["&Pcount&"]</a>"
	end if
%> </span>
</td>
</tr>
<%
	end if
	rs.close
	set rs=nothing
	conn.close
	set conn=nothing
%><span style="font-size: 9pt"> </span>
</FORM><%response.write admin_bar(titt,2,"99%")
response.write ender()%>
</table>
  </center>
</div>
<%
end if
end sub
%>
<script language="JavaScript">
<!--
function CheckAll(form)  {
  for (var i=0;i<form.elements.length;i++)    {
    var e = form.elements[i];
    if (e.name != 'chkall')       e.checked = form.chkall.checked; 
   }
  }
//-->
</script>