您正在使用 IPV4 [18.117.81.240] 访问本站,您本次已经查看了 1 页
用户名: 密 码: 验证码:     用QQ登录本站
首页 软件 编程 笑话 知识 公告 台风 日历 计算器
悟空收录网       [公益]保护绿色环境,构建和谐社会      

【腾讯云】 爆款2核2G3M云服务器首年 61元,叠加红包再享折上折      
[公益] 地球是我家,绿化靠大家      
2024年 劳动节 012
2024年 端午节 052
2025年 元 旦 257
2025年 春 节 285
 
您现在的位置:首页 >> ASP/ASP.net >> 内容
本类新增
本类热门
asp实现限制一个ip只能访问一次的方法
内容摘要: %'/////////////////////////////////////////////////////'// //'//作用:一个IP地址只允许访问本页一次 //'//引用:!-- #include file='Check_Ip.asp' -- //'// //'///////////////////////////////////////////......

<%

'/////////////////////////////////////////////////////

'// //

'//作用:一个IP地址只允许访问本页一次 //

'//引用:<!-- #include file="Check_Ip.asp" --> //

'// //

'/////////////////////////////////////////////////////


'Response.Charset = 936 '设置输出编码为简体中文

'Response.Buffer = false '关闭缓冲区


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


'创建文件函数

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


'关闭当前IE窗口函数(注:IE6下通过,其他浏览器未测试)

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 "本站不允许使用代理访问"

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中if语句、select 、while循环的使用方法

 

下一篇:xmlhttp读取文件

发布日期:2021/6/15
手机扫二维码直达本页
发布时间:12:34:56
点  击:3
录  入:齐天大圣
相关文章
Baidu
YiJiaCMS 7.3.8 build231228(MSSQL) 闽ICP备05000814号-1
本空间由腾讯云(轻量应用服务器)提供,Cloudflare提供加速防护
运行时间载入中.....