日期:2010-11-13  浏览次数:21044 次

众所周知,得到IP地址的方法是

<%=Request.ServerVariables("REMOTE_ADDR")%>

可如果客户使用的代理服务器,那么用这个方法得到了就是代理服务器的IP了,下面是穿透服务器得到真实IP的代码:

function GetIp()dim realip,proxyrealip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")proxy = Request.ServerVariables("REMOTE_ADDR")if realip = "" thenGetIp = proxyelseGetIp = realipend ifend function