国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 阳新县| 天柱县| 林芝县| 马公市| 柘城县| 获嘉县| 永州市| 台南市| 石楼县| 于田县| 珲春市| 涞源县| 夹江县| 米林县| 林周县| 金沙县| 措美县| 白朗县| 桐柏县| 罗源县| 诸城市| 怀宁县| 和林格尔县| 周口市| 吉林省| 阳高县| 高安市| 汽车| 尤溪县| 江孜县| 若羌县| 定远县| 黄山市| 江山市| 阳春市| 宝兴县| 尚志市| 镇康县| 南汇区| 彝良县| 固安县|