当前位置: 移动技术网 > IT编程>开发语言>Asp > asp 取得用户真实IP,对代理地址仍然有效的函数

asp 取得用户真实IP,对代理地址仍然有效的函数

2017年12月12日  | 移动技术网IT编程  | 我要评论
<%
'******************************
'函数:getusertrueip()
'参数:无
'作者:阿里西西
'日期:2007/7/13
'描述:取得用户真实ip,对代理地址仍然有效;返回值:文本类型的ip地址
'示例:<%=getusertrueip()%>
'******************************
function getusertrueip()
   dim stripaddr
   if request.servervariables("http_x_forwarded_for") = "" or instr(request.servervariables("http_x_forwarded_for"), "unknown") > 0 then 
      stripaddr = request.servervariables("remote_addr") 
   elseif instr(request.servervariables("http_x_forwarded_for"), ",") > 0 then 
      stripaddr = mid(request.servervariables("http_x_forwarded_for"), 1, instr(request.servervariables("http_x_forwarded_for"), ",")-1) 
   elseif instr(request.servervariables("http_x_forwarded_for"), ";") > 0 then 
      stripaddr = mid(request.servervariables("http_x_forwarded_for"), 1, instr(request.servervariables("http_x_forwarded_for"), ";")-1) 
   else 
      stripaddr = request.servervariables("http_x_forwarded_for") 
   end if 
   getusertrueip = trim(mid(stripaddr, 1, 30)) 
end function
%>

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

相关文章:

验证码:
移动技术网