Copy Code code as follows:
function Checkip (checkstring) ' uses regular to determine whether IP is legal
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
Copy Code code as follows:
Function Get_cli_ip () "Take the real IP function, http_client_ip before http_x_forwarded_for again Remote_addr
Dim client_ip
If Checkip (Request.ServerVariables ("Http_client_ip")) =true then
Get_cli_ip = C Heckip (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) =tr UE then
Get_cli_ip = client_ip
Exit Function
End If
End If
Get_cli_ip = Request.servervariab Les ("remote_addr")
End If
End Function