lockIP.asp
上传用户:qyswxdl
上传日期:2013-06-01
资源大小:1373k
文件大小:7k
源码类别:

家庭/个人应用

开发平台:

ASP/ASPX

  1. <!--#include file="../checkpost.asp"-->
  2. <!--#include file="articleconn.asp"-->
  3. <!--#include file="security.asp"-->
  4. <%if session("flag")>1 then
  5.     response.write "<br><p align=center>您的操作权限不够!</p>"
  6.     response.end
  7. end if
  8. %>
  9. <HTML><HEAD><TITLE>后台管理 </TITLE>
  10. <META http-equiv=Content-Type content="text/html; charset=gb2312">
  11. <LINK href="inc/Admin_STYLE.CSS" type=text/css rel=stylesheet>
  12. <style type="text/css">
  13. <!--
  14. .样式3 {font-size: 9pt}
  15. -->
  16. </style>
  17. </HEAD>
  18. <BODY leftMargin=0 topMargin=0 marginwidth="0" marginheight="0">
  19. <!--#include file="top1.asp"-->
  20. <table width="100%" border="0" cellspacing="0" cellpadding="2">
  21.   <tr>
  22.     <td>&nbsp;</td>
  23.   </tr>
  24. </table>
  25. <%  const MaxPerPage=25
  26.       if zcn="" or zcv="" then response.end
  27.       if session("admin")="" then
  28.       response.redirect"login.asp"
  29.       response.end
  30.       end if
  31. dim userip,ips,GetIp1,GetIp2
  32. if request("userip")<>"" then
  33. userip=request("userip")
  34. ips=Split(userIP,".")
  35. GetIp1=ips(0)&"."&ips(1)&"."&ips(2)&".1"
  36. GetIp2=ips(0)&"."&ips(1)&"."&ips(2)&".255"
  37. else 
  38. userip=""
  39. GetIp1=""
  40. GetIp2=""
  41. end if
  42. if request("action")="add" then
  43. %>
  44. <table width="100%" border="0" cellspacing="1" cellpadding="3"  align=center class="border">
  45.   <tr> 
  46.     <th width="100%" colspan=2 bgcolor="#429AEF"><span class="样式3"><font color="#FFFFFF">访问IP限制管理—添加 </font>      </span> </th>
  47.   </tr>
  48.  <%
  49. dim sip,str1,str2,str3,str4,num_1,num_2
  50. if request.querystring("reaction")="save" then
  51. sip=cstr(request.form("ip1"))
  52. 'dot=instr(ip,".")-1
  53. 'response.write dot
  54. str1=left(sip,cint(instr(sip,".")-1))
  55. sip=mid(sip,cint(instr(sip,"."))+1)
  56. str2=left(sip,cint(instr(sip,"."))-1)
  57. sip=mid(sip,cint(instr(sip,"."))+1)
  58. str3=left(sip,cint(instr(sip,"."))-1)
  59. str4=mid(sip,cint(instr(sip,"."))+1)
  60. num_1=cint(str1)*256*256*256+cint(str2)*256*256+cint(str3)*256+cint(str4)-1
  61. sip=cstr(request.form("ip2"))
  62. str1=left(sip,instr(sip,".")-1)
  63. sip=mid(sip,instr(sip,".")+1)
  64. str2=left(sip,instr(sip,".")-1)
  65. sip=mid(sip,instr(sip,".")+1)
  66. str3=left(sip,instr(sip,".")-1)
  67. str4=mid(sip,instr(sip,".")+1)
  68. num_2=cint(str1)*256*256*256+cint(str2)*256*256+cint(str3)*256+cint(str4)-1
  69. 'response.write num_1 &","& num_2
  70. 'response.end
  71. conn.execute("insert into lockip (ip1,ip2,sip1,sip2) values ('"&num_1&"','"&num_2&"','"&request.form("ip1")&"','"&request.form("ip2")&"')")
  72. 'set rs = server.CreateObject ("adodb.recordset")
  73. 'sql="select * from LockIP"
  74. 'rs.open sql,conn,1,3
  75. 'rs.addnew
  76. 'rs("ip1")=num_1
  77. 'rs("ip2")=num_2
  78. 'rs("sip1")=request.form("ip1")
  79. 'rs("sip2")=request.form("ip2")
  80. 'rs.updat
  81. 'rs.closee
  82. %>
  83.   <tr> 
  84.     <td width="100%" colspan=2 class=tdbg><div align="center"><font color="#FF0000">添加成功!<a href=lockip.asp>返回</a></font></div></td>
  85.   </tr>
  86. </table>
  87. <span class="b1"><%else%></span>
  88. <table width="100%" border="0" cellpadding="3" cellspacing="1" class="border">
  89.   <form action="LockIP.asp?action=add&reaction=save" method="post">
  90.     <tr> 
  91.       <td width="20%" class=tdbg><div align="center">起始I&nbsp;P:</div></td>
  92.       <td width="80%" class=tdbg>   
  93.         <span class="tdbg2">
  94.         <input type="text" name="ip1" size="30" value="<%=GetIp1%>">
  95.         </span>        &nbsp;如210..41.240.1</td>
  96.     </tr>
  97.     <tr> 
  98.       <td width="20%" height="23" class=tdbg> 
  99.         <div align="center">结尾I&nbsp;P:</div></td>
  100.       <td width="80%" class=tdbg>   
  101.         <span class="tdbg2">
  102.         <input type="text" name="ip2" size="30" value="<%=GetIp2%>">
  103.         </span>        &nbsp;如210..41.240.255</td>
  104.     </tr>
  105.     <tr> 
  106.       <td width="20%" class=tdbg></td>
  107.       <td width="80%" class=tdbg> <div align="left">   
  108.           <input type="submit" name="Submit" value="提 交">
  109.         </div></td>
  110.     </tr>
  111.   </form>
  112. </table>
  113. <%
  114. end if
  115. elseif request("action")="delip" then
  116. conn.execute("delete from LockIP where id in ("&request.form("delid")&")")
  117. response.write "删除成功!"
  118. response.redirect "lockip.asp"
  119. response.end
  120. else
  121. %>
  122. <table width="100%" border="0" cellspacing="1" cellpadding="3"  align=center class="border">
  123.   <FORM name="myform" METHOD=POST ACTION="?action=delip">
  124.     <tr background="IMAGES/topBar_bg.gif"> 
  125.       <th height="21" colspan=4 class="title"><span class="样式3">访问IP限制管理—管理 <a href=lockip.asp?action=add> 
  126.         <font color="#FF0000">添加限制的IP地址</font></a> </span></th>
  127.     </tr>
  128.     <tr class="tdbg2"> 
  129.       <td width="11%" height="20" align="center" bgcolor="#429AEF"><B><font color="#FFFFFF">ID号</font></B></td>
  130.       <td width="27%" align="center" bgcolor="#429AEF"><B><font color="#FFFFFF">起始IP</font></B></td>
  131.       <td width="22%" align="center" bgcolor="#429AEF"><B><font color="#FFFFFF">结尾IP</font></B></td>
  132.       <td width="40%" align="center" bgcolor="#429AEF"><B><font color="#FFFFFF">选择/全选</font></B> 
  133.         <font color="#FFFFFF"> 
  134.         <input type=checkbox value="on" name="chkall" onclick="CheckAll(this.form)">
  135.         </font></td>
  136.     </tr>
  137.      <%
  138. dim currentpage,page_count,Pcount
  139. dim totalrec,endpage
  140. currentPage=request("page")
  141. if currentpage="" or not int(currentpage) then
  142. currentpage=1
  143. else
  144. currentpage=clng(currentpage)
  145. if err then
  146. currentpage=1
  147. err.clear
  148. end if
  149. end if
  150. sql="select id,sip1,sip2 from LockIP order by id desc"
  151. Set rs= Server.CreateObject("ADODB.Recordset")
  152. rs.open sql,conn,1,1
  153. if rs.eof and rs.bof then
  154. %>
  155.     <tr class="tdbg"> 
  156.       <td colspan=4 ><div align="center">还没有任何允许访问限制IP数据!</div></td>
  157.     </tr>
  158.              <%
  159. else
  160. rs.PageSize = MaxPerPage
  161. rs.AbsolutePage=currentpage
  162. page_count=0
  163. totalrec=rs.recordcount
  164. while (not rs.eof) and (not page_count = MaxPerPage)
  165. %>
  166.     <tr class="tdbg" > 
  167.       <td width="11%" height="20" align="center"><%=rs("id")%></td>
  168.       <td width="27%" align="center"><%=rs("sip1")%></td>
  169.       <td width="22%" align="center" ><%=rs("sip2")%></td>
  170.       <td width="40%" align="center"> 
  171.         <input type=checkbox name="delid" value="<%=cstr(rs("ID"))%>"></td>
  172.     </tr>
  173.     <%
  174. page_count = page_count + 1
  175. rs.movenext
  176. wend
  177. %>
  178.     <tr class="tdbg"> 
  179.       <td colspan=3 align=center>分页: 
  180.       <%Pcount=rs.PageCount
  181. if currentpage > 4 then
  182. response.write "<a href=""?page=1"">[1]</a> ..."
  183. end if
  184. if Pcount>currentpage+3 then
  185. endpage=currentpage+3
  186. else
  187. endpage=Pcount
  188. end if
  189. for i=currentpage-3 to endpage
  190. if not i<1 then
  191. if i = clng(currentpage) then
  192.         response.write " <font color=red>["&i&"]</font>"
  193. else
  194.         response.write " <a href=""?page="&i&""">["&i&"]</a>"
  195. end if
  196. end if
  197. next
  198. if currentpage+3 < Pcount then 
  199. response.write "... <a href=""?page="&Pcount&""">["&Pcount&"]</a>"
  200. end if
  201. %>      </td>
  202.       <td align=center> <input type=submit name=submit value="删除"> </td>
  203.     </tr>
  204.     <%
  205. end if
  206. rs.close
  207. set rs=nothing
  208. %>
  209.   </FORM>
  210. </table>
  211. <span class="b1"><%
  212. end if
  213. %></span>
  214. <script language="JavaScript">
  215. <!--
  216. function CheckAll(form)  {
  217.   for (var i=0;i<form.elements.length;i++)    {
  218.     var e = form.elements[i];
  219.     if (e.name != 'chkall')       e.checked = form.chkall.checked; 
  220.    }
  221.   }
  222. //-->
  223.       </script>
  224. <br>
  225. </BODY></HTML>