- 資訊首頁(yè) > 開(kāi)發(fā)技術(shù) > web開(kāi)發(fā) > ASP >
- asp實(shí)現限制一個(gè)ip只能訪(fǎng)問(wèn)一次的方法
限制一個(gè)ip只能訪(fǎng)問(wèn)一次,現在將asp代碼分享給大家:
<% '///////////////////////////////////////////////////// '// // '//作用:一個(gè)IP地址只允許訪(fǎng)問(wèn)本頁(yè)一次 // '//引用:<!-- #include file="Check_Ip.asp" --> // '// // '///////////////////////////////////////////////////// 'Response.Charset = 936 '設置輸出編碼為簡(jiǎn)體中文 'Response.Buffer = false '關(guān)閉緩沖區 Dim Fso,ts,IpList,Cfs '設置Cookies函數 Function SetCookie() Response.Cookies("IsBrow") = "Brow" Response.Cookies("IsBrow").Expires = Date+365 End Function '記錄IP地址函數 Function WriteIp(FileName, IpAddress) Set Fso = Server.CreateObject("Scripting.FileSystemObject") Set ts = Fso.OpenTextFile(Server.MapPath(FileName),8,true) ts.WriteLine IpAddress ts.Close Set ts = Nothing Set Fso = Nothing End Function '讀取IP地址函數 Function ReadIpList(FileName) Set Fso = Server.CreateObject("Scripting.FileSystemObject") If Not Fso.FileExists(Server.MapPath(FileName)) Then CreateFile("Iplist.txt") Exit Function End If Set ts = Fso.OpenTextFile(Server.MapPath(FileName)) Iplist = ts.ReadAll ts.Close Set ts = Nothing Set Fso = Nothing ReadIpList = Iplist End Function '創(chuàng )建文件函數 Function CreateFile(FileName) Set Fso = Server.CreateObject("Scripting.FileSystemObject") Set Cfs = Fso.CreateTextFile(Server.MapPath(FileName)) Cfs.Close Set Cfs = Nothing Set Fso = Nothing End Function '關(guān)閉當前IE窗口函數(注:IE6下通過(guò),其他瀏覽器未測試) Function CloseWindow() 'Response.Write "<script>window.location='javascript:window.opener=null;window.close();'</script>" Response.Redirect "http://www.baidu.com" End Function Ip = Request.ServerVariables("REMOTE_ADDR") '獲取瀏覽者IP地址 Cookie = Request.Cookies("IsBrow") '獲取當前Cookies 'Response.Write Cookie If Request.ServerVariables("HTTP_X_FORWARDED_FOR") <> "" Then Response.Write "本站不允許使用代理訪(fǎng)問(wèn)" Response.End() Else If Cookie = "Brow" Then CloseWindow() Else If Instr(ReadIpList("Iplist.txt"),Ip) <> 0 Then CloseWindow() Else WriteIp "Iplist.txt" , Ip End If SetCookie() End If End If %>
以上就是分享給大家的asp實(shí)現代碼,希望對大家的學(xué)習有所幫助。
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自本網(wǎng)站內容采集于網(wǎng)絡(luò )互聯(lián)網(wǎng)轉載等其它媒體和分享為主,內容觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如侵犯了原作者的版權,請告知一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容,聯(lián)系我們QQ:712375056,同時(shí)歡迎投稿傳遞力量。
Copyright ? 2009-2022 56dr.com. All Rights Reserved. 特網(wǎng)科技 特網(wǎng)云 版權所有 特網(wǎng)科技 粵ICP備16109289號
域名注冊服務(wù)機構:阿里云計算有限公司(萬(wàn)網(wǎng)) 域名服務(wù)機構:煙臺帝思普網(wǎng)絡(luò )科技有限公司(DNSPod) CDN服務(wù):阿里云計算有限公司 百度云 中國互聯(lián)網(wǎng)舉報中心 增值電信業(yè)務(wù)經(jīng)營(yíng)許可證B2
建議您使用Chrome、Firefox、Edge、IE10及以上版本和360等主流瀏覽器瀏覽本網(wǎng)站