手机
当前位置:查字典教程网 >编程开发 >ASP教程 >用通ASP直接获取用户真实IP地址
用通ASP直接获取用户真实IP地址
摘要:通用FUNCTION,如果不能取真实IP,就会取代理IPPrivateFunctiongetIP()DimstrIPAddrIfReques...

通用FUNCTION,如果不能取真实IP,就会取代理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)

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)

Else

strIPAddr = Request.ServerVariables("HTTP_X_FORWARDED_FOR")

End If

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

End Function

【用通ASP直接获取用户真实IP地址】相关文章:

在ASP编程中使用数组

asp获取用户真实IP地址的方法

用ASP设计购物推车

ASP小偷(远程数据获取)程序入门教程

ASP如何获取真实IP地址

常见的ASP获取时间操作的代码

利用ASP规划聊天室

ASP简洁的多重查询的解决方案

用ASP读取XML文件的具体方法与示例

ASP智能搜索的实现

精品推荐
分类导航