<% '------------------------------------------------------------------------------------------------- Function GetUserIPInfo '根据当前用户使用线路信息 Set XMLHTTP = Server.CreateObject("MSXML2.XMLHTTP") XMLHTTP.Open "Get","http://www.dns7.cn/ip/?ip="&GetUserIP(),false XMLHTTP.Send strResult= bytes2BSTR(XMLHTTP.ResponseBody) GetUserIPInfo=strResult End Function '------------------------------------------------------------------------------------------------- Function RemoteGetIPInfo(IP) '根据用户IP,得到使用线路信息 Set XMLHTTP = Server.CreateObject("MSXML2.XMLHTTP") XMLHTTP.Open "Get","http://www.dns7.cn/ip/?ip="&IP,false XMLHTTP.Send strResult= bytes2BSTR(XMLHTTP.ResponseBody) RemoteGetIPInfo=strResult End Function '------------------------------------------------------------------------------------------------- Function GetUserIP() '得到用户IP地址 Dim userip,userip2 userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR") userip2 = Request.ServerVariables("REMOTE_ADDR") If userip = "" Then GetUserIP=userip2 Else GetUserIP=userip End If End Function '------------------------------------------------------------------------------------------------- Function bytes2BSTR(vIn) '内部函数调用 strReturn = "" For i = 1 To LenB(vIn) ThisCharCode = AscB(MidB(vIn,i,1)) If ThisCharCode < &H80 Then strReturn = strReturn & Chr(ThisCharCode) Else NextCharCode = AscB(MidB(vIn,i+1,1)) strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode)) i = i + 1 End If Next bytes2BSTR = strReturn End Function '-------------------------------------------------------------------------------------------------
%>
<% Response.write GetUserIP() %> <br> <% Response.write RemoteGetIPInfo(GetUserIP()) %> <br> <% Response.write GetUserIPInfo %>
----------------------------------------
|