實(shí)時(shí)發(fā)布天互官方新聞和媒體報(bào)道,了解天互最新動(dòng)態(tài)
寫(xiě)了下asp取真實(shí)IP的代碼,搭環(huán)境測(cè)試無(wú)代理、一級(jí)或多級(jí)代理的情況,可以正常獲取
function checkip(checkstring)'用正則判斷IP是否合法
dim re1
set re1=new RegExp
re1.pattern="^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$"
re1.global=false
re1.Ignorecase=false
checkip=re1.test(checkstring)
set re1=nothing
end function
function get_cli_ip()'取真實(shí)IP函數(shù),先 HTTP_CLIENT_IP 再 HTTP_X_FORWARDED_FOR 再 REMOTE_ADDR
dim client_ip
if checkip(Request.ServerVariables("HTTP_CLIENT_IP"))=true then
get_cli_ip = checkip(Request.ServerVariables("HTTP_CLIENT_IP"))
else
MyArray = split(Request.ServerVariables("HTTP_X_FORWARDED_FOR"),",")
if ubound(MyArray)>=0 then
client_ip = trim(MyArray(0))
if checkip(client_ip)=true then
get_cli_ip = client_ip
exit function
end if
end if
get_cli_ip = Request.ServerVariables("REMOTE_ADDR")
end if
end function
咨詢熱線
400-675-6239
關(guān)注微信公眾號(hào)
公司地址:陜西省西安市高新區(qū)科技路50號(hào)金橋國(guó)際廣場(chǎng)A座2單元21702號(hào)
郵編:710116