袁来如此的工作笔记
袁来如此的工作笔记
竹杖芒鞋轻胜马,谁怕? 一蓑烟雨任平生。

asp 获取ip

浏览量:865

Function GetIp()

Dim DulIp,ProIP

DulIp=Request.ServerVariables("HTTP_X_FORWARDED_FOR")

ProIP=Request.ServerVariables("REMOTE_ADDR")

If DulIp="" Then

  GetIp=ProIP

Else

  GetIp=DulIp

End If

End Function

 

 

Private Function getIP()

Dim strIPAddr

If Request.ServerVariables("HTTP_X_FORWARDED_FOR") = "" OR InStr(Request.ServerVariab

les("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.Ser

verVariables("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.Ser

verVariables("HTTP_X_FORWARDED_FOR"), ";")-1)

Else

strIPAddr = Request.ServerVariables("HTTP_X_FORWARDED_FOR")

End If

getIP = Trim(Mid(strIPAddr, 1, 30))

End Function

 

192.168.1.2客户端访问时显示“你的ip是:192.168.1.2”,你是“2”号用户!

vip = request.servervariables("http_x_forwarded_for")

if vip = "" then vip = Request.ServerVariables("Remote_Addr")

str=right(vip,len(vip)-InstrRev(vip,"."))

 

 

 


打赏