ASP取得客户端IP地址函数

作者:网络 来源:佚名 更新时间:2009-02-14 00:57:17 点击:

最大的网站源码资源下载站,

asp取得访问者真实ip地址函数

 private function getip()
  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)
   actforip = 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)
   actforip = request.servervariables("remote_addr")
  else
   stripaddr = request.servervariables("http_x_forwarded_for")
   actforip = request.servervariables("remote_addr")
  end if
  getip = replace(trim(mid(stripaddr, 1, 30)), "'", "")
 end function

调用方法: <%=getip()%>