当前位置:首页 > ASP教程 > 应用技巧

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

<%
'******************************
'函数: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
%>
【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!