asp 取得用户真实IP,对代理地址仍然有效的函数
程序员文章站
2022-05-28 16:25:33
<% '****************************** '函数:getusertrueip() '参数:无 '作者:阿里西西 '日期:2007/7/13...
<%
'******************************
'函数:getusertrueip()
'参数:无
'作者:阿里西西
'日期:2007/7/13
'描述:取得用户真实ip,对代理地址仍然有效;返回值:文本类型的ip地址
'示例:<%=getusertrueip()%>
'******************************
function getusertrueip()
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
getusertrueip = trim(mid(stripaddr, 1, 30))
end function
%>
'******************************
'函数:getusertrueip()
'参数:无
'作者:阿里西西
'日期:2007/7/13
'描述:取得用户真实ip,对代理地址仍然有效;返回值:文本类型的ip地址
'示例:<%=getusertrueip()%>
'******************************
function getusertrueip()
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
getusertrueip = trim(mid(stripaddr, 1, 30))
end function
%>
上一篇: asp 通用数据库连接过程函数
下一篇: 古代女子进后宫,用什么方法验证清白?