做了CDN加速的ASP網(wǎng)站獲取用戶真實(shí)IP程序
更新時(shí)間:2010年11月03日 11:40:31 作者:
寫了下asp取真實(shí)IP的代碼,搭環(huán)境測(cè)試無(wú)代理、一級(jí)或多級(jí)代理的情況,可以正常獲取
復(fù)制代碼 代碼如下:
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
復(fù)制代碼 代碼如下:
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
相關(guān)文章
asp之GetArray提取鏈接地址,以$Array$分隔的代碼
asp之GetArray提取鏈接地址,以$Array$分隔的代碼...2007-09-09
ASP中用select case代替其他語(yǔ)言中的switch case, default用case else
這篇文章主要介紹了ASP中用select case代替其他語(yǔ)言中的switch case, default用case else ,需要的朋友可以參考下2015-11-11
在asp中使用js的encodeURIComponent方法
encodeURIComponent 方法返回一個(gè)已編碼的 URI。如果您將編碼結(jié)果傳遞給 decodeURIComponent,那么將返回初始的字符串2012-03-03
關(guān)于ASP循環(huán)表格的問(wèn)題之解答[比較詳細(xì)]
在很多時(shí)候,我們采用原始的方法來(lái)解決一行內(nèi)循環(huán)3張圖片,如果上傳者只上傳了2張圖片,那么2張圖片間的距離會(huì)很大,因?yàn)槿鄙倭艘粋€(gè)<td> </td>.2008-11-11

