用asp脚本实现限制IP访问

编程学习 2021-07-05 10:58www.dzhlxh.cn编程入门
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
%> 

Copyright © 2016-2025 www.dzhlxh.cn 金源码 版权所有 Power by

网站模板下载|网络推广|微博营销|seo优化|视频营销|网络营销|微信营销|网站建设|织梦模板|小程序模板