当前位置: 移动技术网 > IT编程>开发语言>Asp > 做了CDN加速的ASP网站获取用户真实IP程序

做了CDN加速的ASP网站获取用户真实IP程序

2017年12月08日  | 移动技术网IT编程  | 我要评论
复制代码 代码如下:

function checkip(checkstring)'用正则判断ip是否合法
dim re1
set re1=new regexp
re1.pattern="^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$"
re1.global=false
re1.ignorecase=false
checkip=re1.test(checkstring)
set re1=nothing
end function

复制代码 代码如下:

function get_cli_ip()'取真实ip函数,先 http_client_ip 再 http_x_forwarded_for 再 remote_addr
dim client_ip
if checkip(request.servervariables("http_client_ip"))=true then
get_cli_ip = checkip(request.servervariables("http_client_ip"))
else
myarray = split(request.servervariables("http_x_forwarded_for"),",")
if ubound(myarray)>=0 then
client_ip = trim(myarray(0))
if checkip(client_ip)=true then
get_cli_ip = client_ip
exit function
end if
end if
get_cli_ip = request.servervariables("remote_addr")
end if
end function

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网