<!--#include file="conn.asp"-->
<!--#include file="Admin_Chkpass.asp"-->
<SCRIPT language=javascript>
function checkip() 
{
var sIPAddress =document.form1.lockip.value
var exp=/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/; 
var reg = sIPAddress.match(exp); 
if(reg==null) 
	{ 
		alert("你输入的是一个非法的IP地址段！\nIP段为：:xxx.xxx.xxx.xxx（xxx为0-255)！"); 
	return false;
	
	} 
return true;

} 



</script>
<%
dim action
Action=trim(request("Action"))

select case Action
	case "saveconfig" 
		call saveconfig()
	case "addconfig" 
		call addconfig()
	case "showconfig"
		call showconfig()
	case "modiconfig"
		call modiconfig()
end select

	
%>
<html>
<head>
<title>IP屏蔽管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="Admin_STYLE.CSS" rel="stylesheet" type="text/css">
</head>
<%
sub showconfig()
dim rs
set rs=conn.execute("select * from lockip")
%>
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0" class="bgcolor">
<br>
<form method="POST" action="Admin_iplock.asp" id="form1" name="form1">
  <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" Class="border">
    <tr class="topbg"> 
      <td width="100" height="25" ><div align="center">ID</div></td>
      <td width="200" ><div align="center">IP段</div></td>
      <td width="418" ><div align="center">选择</div></td>
    </tr>
    
       <% 
while not rs.eof	  
%> 
            <tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'"> 
             <td width="100"><div align="center"><%= rs("id") %>&nbsp;</div></td>
            <td width="200"><div align="center"><%= rs("lockip") %></div></td>
            <td width="418">
                <div align="center">
                  <input type="checkbox" name=<%="checkbox"&rs("id")%> value=<%=rs("id")%>>
                </div></td>
          </tr>
        
        <%
rs.movenext
wend
%>
    
    <tr> 
      <td height="40" colspan="3" align="center" class="tdbg"> 
        <div align="center">
          <input name="Action" type="hidden" id="Action" value="modiconfig">
          <input name="cmdSave" type="submit" id="cmdSave" value="删除 " >
          </div></td>
    </tr>
  </table>


</form>


<%
	set rs=nothing
	call closeconn
end sub

sub saveconfig()
	dim rs,sql
	set rs=server.CreateObject("adodb.recordset")
	sql="select * from lockip"
	rs.open sql,conn,1,3
	rs.addnew
	rs("lockip")=trim(request("lockip"))
	rs.update
	rs.close
	set rs=nothing
	call PutApplicationValue()
	call closeconn
	response.Redirect "admin_iplock.asp?action=showconfig"
end sub

sub modiconfig()
	dim rs,sql
	set rs=server.CreateObject("adodb.recordset")
	sql="select id from lockip"
	rs.open sql,conn,1,3
	while not rs.eof
		if rs("id")=clng(request("checkbox"&rs("id"))) then
			rs.delete
			rs.update
		end if
			rs.movenext
	wend 
	rs.close
	set rs=nothing
	call PutApplicationValue()
	call closeconn
	response.Redirect "admin_iplock.asp?action=showconfig"
end sub

sub addconfig()
%>
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0" class="bgcolor">
<form method="POST" action="Admin_iplock.asp" id="form1" name="form1" onSubmit="return checkip()">
<br>
  <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" Class="border">
    <tr> 
      <td height="22" colspan="2" class="topbg"> <strong>添加屏蔽IP段：</strong></td>
    </tr>
    <tr> 
      <td width="11%" height="25" class="tdbg"> <div align="right">IP:</div></td>
      <td width="89%" height="25" class="tdbg"><input name="lockip" type="text" id="lockip" size="25" maxlength="25">
      限制IP的书写方式如202.152.12.1,就限制了202.152.12.1这个IP的访问。      </td>
    </tr>
    <tr> 
      <td height="40" colspan="2" class="tdbg"><p align="center" class="tdbg"><input name="Action" type="hidden" id="Action" value="saveconfig"> 
        <input name="cmdSave" type="submit" id="cmdSave" value=" 添加IP "  > 
      </p> </td>
    </tr>
  </table>

</form>
</body>
</html>
<%
end sub

%>