手机
当前位置:查字典教程网 >编程开发 >ASP教程 >做了CDN加速的ASP网站获取用户真实IP程序
做了CDN加速的ASP网站获取用户真实IP程序
摘要:复制代码代码如下:functioncheckip(checkstring)'用正则判断IP是否合法dimre1setre1=newRegEx...

复制代码 代码如下:

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

【做了CDN加速的ASP网站获取用户真实IP程序】相关文章:

如何使用ASP设置指定站点CPU最大使用程度

ASP如何获取客户端真实IP地址

经典的分页完整程序+注释

如何将ASP生成的内容写入响应流中

用通ASP直接获取用户真实IP地址

ASP小偷(远程数据获取)程序的入门教程

asp获取用户真实IP地址的方法

带数据库的ASP用户名密码登录验证代码

如何通过ASP管理NT帐号

如何在ASP.NET应用程序中初始化

精品推荐
分类导航