作家
登录

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

作者: 来源:www.28hudong.com 2013-03-30 08:17:46 阅读 我要评论

复制代码 代码如下: 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

  推荐阅读

  asp中常用的字符串安全处理函数集合(过滤特殊字符等)

复制代码 代码如下:'===================================== '转换内容,防止意外 '===================================== Function Content_Encode(ByVal t0) IF IsNull(t0) Or Len(t0)=0 Then Content_Encode=">>>详细阅读


本文标题:做了CDN加速的ASP网站获取用户真实IP程序

地址:http://www.17bianji.com/kaifa2/ASP/31906.html

关键词: 探索发现

乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

网友点评
自媒体专栏

评论

热度

精彩导读
栏目ID=71的表不存在(操作类型=0)