'----------------------------------------------------------------'
' getIP
' 获取客户端 IP
' 返回值:字符串 (xxx.xxx.xxx.xxx 形式的 IP 字符串)
'----------------------------------------------------------------'
Function getIP()
Dim strIP
If Request.ServerVariables("HTTP_X_FORWARDED_FOR") = "" Or InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), "unknown") > 0 Then
strIP = Request.ServerVariables("REMOTE_ADDR")
ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",") > 0 Then
strIP = 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
strIP = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";") - 1)
Else
strIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
End If
getIP = Trim(Mid(strIP, 1, 30))
End Function
asp自定义函数:获取客户端的ip地址
原创文章如转载,请注明:转载自悠悠博客 [ http://www.ajaxstu.com/ ]
相关文章:
- Aspjpeg入门详解(2007-11-26 4:56:2)
- ASP操作Excel常见错误(2007-11-15 4:39:21)
- 同一个用户不允许同时登陆两次(2007-11-15 1:17:43)
- 罗列全部session和application(2007-11-12 6:26:16)
- 访问和更新Cookies集合(2007-11-11 1:42:29)
- asp中cookie使用示例(2007-11-7 3:2:28)
- ASPImage组件制作水印的过程(2007-11-4 5:10:36)
- asp重定向-response.redirect和server.transfer(2007-10-24 9:18:30)
- vbscript Replace 函数(2007-10-21 4:33:2)
- asp:Server对象(2007-10-11 7:9:58)
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
