当前位置:首页 > ASP教程 > 应用技巧

用asp脚本实现限制IP访问

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
%> 

【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!