国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

asp實現(xiàn)限制一個ip只能訪問一次的方法

2024-05-04 11:10:10
字體:
供稿:網(wǎng)友

這篇文章主要介紹了asp實現(xiàn)限制一個ip只能訪問一次的方法,感興趣的小伙伴們可以參考一下

限制一個ip只能訪問一次,現(xiàn)在將asp代碼分享給大家:

 

 
  1. <%  
  2. '/////////////////////////////////////////////////////  
  3. '// //  
  4. '//作用:一個IP地址只允許訪問本頁一次 //  
  5. '//引用:<!-- #include file="Check_Ip.asp" --> //  
  6. '// //  
  7. '/////////////////////////////////////////////////////  
  8.  
  9. 'Response.Charset = 936 '設(shè)置輸出編碼為簡體中文  
  10. 'Response.Buffer = false '關(guān)閉緩沖區(qū)  
  11.  
  12. Dim Fso,ts,IpList,Cfs  
  13.  
  14. '設(shè)置Cookies函數(shù)  
  15. Function SetCookie()  
  16. Response.Cookies("IsBrow") = "Brow" 
  17. Response.Cookies("IsBrow").Expires = Date+365  
  18. End Function  
  19.  
  20. '記錄IP地址函數(shù)  
  21. Function WriteIp(FileName, IpAddress)  
  22. Set Fso = Server.CreateObject("Scripting.FileSystemObject")  
  23. Set ts = Fso.OpenTextFile(Server.MapPath(FileName),8,true)  
  24. ts.WriteLine IpAddress  
  25. ts.Close  
  26. Set ts = Nothing  
  27. Set Fso = Nothing  
  28. End Function  
  29.  
  30. '讀取IP地址函數(shù)  
  31. Function ReadIpList(FileName)  
  32. Set Fso = Server.CreateObject("Scripting.FileSystemObject")  
  33. If Not Fso.FileExists(Server.MapPath(FileName)) Then  
  34. CreateFile("Iplist.txt")  
  35. Exit Function  
  36. End If  
  37.  
  38. Set ts = Fso.OpenTextFile(Server.MapPath(FileName))  
  39. Iplist = ts.ReadAll  
  40. ts.Close  
  41. Set ts = Nothing  
  42. Set Fso = Nothing  
  43. ReadIpList = Iplist  
  44. End Function  
  45.  
  46. '創(chuàng)建文件函數(shù)  
  47. Function CreateFile(FileName)  
  48. Set Fso = Server.CreateObject("Scripting.FileSystemObject")  
  49. Set Cfs = Fso.CreateTextFile(Server.MapPath(FileName))  
  50. Cfs.Close  
  51. Set Cfs = Nothing  
  52. Set Fso = Nothing  
  53. End Function  
  54.  
  55. '關(guān)閉當(dāng)前IE窗口函數(shù)(注:IE6下通過,其他瀏覽器未測試)  
  56. Function CloseWindow()  
  57. 'Response.Write "<script>window.location='javascript:window.opener=null;window.close();'</script>"  
  58. Response.Redirect "http://www.baidu.com" 
  59. End Function  
  60.  
  61. Ip = Request.ServerVariables("REMOTE_ADDR") '獲取瀏覽者IP地址  
  62.  
  63. Cookie = Request.Cookies("IsBrow") '獲取當(dāng)前Cookies  
  64. 'Response.Write Cookie  
  65.  
  66. If Request.ServerVariables("HTTP_X_FORWARDED_FOR") <> "" Then  
  67. Response.Write "本站不允許使用代理訪問" 
  68. Response.End()  
  69. Else  
  70. If Cookie = "Brow" Then  
  71. CloseWindow()  
  72. Else  
  73. If Instr(ReadIpList("Iplist.txt"),Ip) <> 0 Then  
  74. CloseWindow()  
  75. Else  
  76. WriteIp "Iplist.txt" , Ip  
  77. End If  
  78. SetCookie()  
  79. End If  
  80. End If  
  81. %> 

以上就是分享給大家的asp實現(xiàn)代碼,希望對大家的學(xué)習(xí)有所幫助。


注:相關(guān)教程知識閱讀請移步到ASP教程頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 静宁县| 宝应县| 防城港市| 邳州市| 陆丰市| 温宿县| 基隆市| 深州市| 札达县| 奉化市| 蓬溪县| 合作市| 磴口县| 沈阳市| 柳河县| 枣阳市| 黔西县| 西昌市| 茶陵县| 通许县| 北票市| 八宿县| 米泉市| 郓城县| 噶尔县| 深州市| 阳新县| 朔州市| 日照市| 竹溪县| 柳州市| 靖边县| 张北县| 赣榆县| 登封市| 馆陶县| 万宁市| 萨迦县| 麦盖提县| 阳春市| 璧山县|