asp 取得用户真实IP,对代理地址仍然有效的函数
程序员文章站
2023-01-25 08:05:42
<% '****************************** '函数: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加密解密函数decrypt
下一篇: asp 实现视频显示的效果函数