用asp脚本实现限制IP访问
程序员文章站
2022-06-19 23:53:48
cookies跨不了域很麻烦,有了这个脚本就方便多了. <% ip=request.servervariables("remote_addr") set f...
cookies跨不了域很麻烦,有了这个脚本就方便多了.
<%
ip=request.servervariables("remote_addr")
set fso=createobject("scripting.filesystemobject")
set files=fso.opentextfile(server.mappath("./ip.txt"),1,false)
data=files.readall
files.close
set fso=nothing
if instrrev(data, ip, -1, 0) = 0 then
set fso=createobject("scripting.filesystemobject")
set file=fso.opentextfile(server.mappath("./ip.txt"),8,true)
file.writeline ip
file.close
set fso=nothing
response.write "此ip今天第一次访问该页面"
response.end
else
response.write "此ip以前访问过了"
response.end
end if
%>
<%
ip=request.servervariables("remote_addr")
set fso=createobject("scripting.filesystemobject")
set files=fso.opentextfile(server.mappath("./ip.txt"),1,false)
data=files.readall
files.close
set fso=nothing
if instrrev(data, ip, -1, 0) = 0 then
set fso=createobject("scripting.filesystemobject")
set file=fso.opentextfile(server.mappath("./ip.txt"),8,true)
file.writeline ip
file.close
set fso=nothing
response.write "此ip今天第一次访问该页面"
response.end
else
response.write "此ip以前访问过了"
response.end
end if
%>