Asp obtains the code of the real IP address, and obtains the asp function code normally if there is no proxy, first-level or multi-level proxy in the environment test:
The code is as follows:
Function checkip (checkstring) 'uses regular expressions to determine whether the IP address is valid.
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 () ': obtains the real IP address. first, HTTP_CLIENT_IP, then HTTP_X_FORWARDED_FOR, and then 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
Use the php code of the real IP address in the discuz Forum. for other similar code, see make some modifications.
(Discuz modify include/common. inc. php)
Use the following code:
The code is as follows:
If (getenv ('http _ CLIENT_IP ') & strcasecmp (getenv ('http _ CLIENT_IP'), 'Unknown ')){
$ Onlineip = getenv ('http _ CLIENT_IP ');
} Elseif (getenv ('http _ X_FORWARDED_FOR ') & strcasecmp (getenv ('http _ X_FORWARDED_FOR '),
'Unknown ')){
$ Testip = explode ('.', getenv ('http _ X_FORWARDED_FOR '));
If ($ testip [0] = '000000' & $ testip [1] = '000000 ′){
$ Onlineip = getenv ('remote _ ADDR ');
}
Elseif ($ testip [0] = '10 ′){
$ Onlineip = getenv ('remote _ ADDR ');
}
Else {
$ Onlineip = getenv ('http _ X_FORWARDED_FOR ');
}
// Gamesir hack end} elseif (getenv ('remote _ ADDR ') & strcasecmp (getenv ('remote _ ADDR '),
'Unknown ')){
$ Onlineip = getenv ('remote _ ADDR ');
} Elseif (isset ($ _ SERVER ['remote _ ADDR ']) & $ _ SERVER ['remote _ ADDR'] & strcasecmp ($ _ SERVER
['Remote _ ADDR '], 'Unknown ')){
// By Johnny
$ Tmp_ip = explode (',', $ _ SERVER ['http _ X_FORWARDED_FOR ']);
$ Tmp_ip1 = explode (',', $ tmp_ip [0]);
If ($ tmp_ip1 [0] = '000000' & $ tmp_ip1 [1] = '000000 ′){
$ Onlineip = getenv ('remote _ ADDR ');
} Else if ($ tmp_ip1 [0] = '10 ′){
$ Onlineip = getenv ('remote _ ADDR ');
}
Else {
$ Onlineip = $ tmp_ip [0];
}
Unset ($ tmp_ip); unset ($ tmp_ip1 );
}
Replace this code:
The code is as follows:
If (getenv ('http _ CLIENT_IP ') & strcasecmp (getenv ('http _ CLIENT_IP'), 'Unknown ')){
$ Onlineip = getenv ('http _ CLIENT_IP ');
} Elseif (getenv ('http _ X_FORWARDED_FOR ') & strcasecmp (getenv ('http _ X_FORWARDED_FOR '),
'Unknown ')){
$ Onlineip = getenv ('http _ X_FORWARDED_FOR ');
} Elseif (getenv ('remote _ ADDR ') & strcasecmp (getenv ('remote _ ADDR'), 'Unknown ')){
$ Onlineip = getenv ('remote _ ADDR ');
} Elseif (isset ($ _ SERVER ['remote _ ADDR ']) & $ _ SERVER ['remote _ ADDR'] & strcasecmp ($ _ SERVER
['Remote _ ADDR '], 'Unknown ')){
$ Onlineip = $ _ SERVER ['remote _ ADDR '];
}