加入收藏 | 设为首页 | 会员中心 | 我要投稿 银川站长网 (https://www.0951zz.com/)- 云通信、基础存储、云上网络、机器学习、视觉智能!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

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

发布时间:2023-07-01 13:32:29 所属栏目:Asp教程 来源:
导读:做了CDN加速的ASP网站取得用户真实IP程序:代码如下:function checkip(checkstring)'用正则判断IP是否合法dim re1set re1=new RegExpre1.pattern="^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$"re1.global=fa

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

代码如下:

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

(编辑:银川站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章