| 1 |
<? |
<? |
| 2 |
|
require_once "common.inc.php"; |
| 3 |
|
|
| 4 |
function Client_Address() |
function Client_Address($addr=null,$x_addr=null) |
| 5 |
{ |
{ |
| 6 |
if (isset($_SERVER["HTTP_X_CLIENT_ADDR"])) |
global $SYS_proxy_ip; |
| 7 |
return $_SERVER["HTTP_X_CLIENT_ADDR"]; |
|
| 8 |
else |
$proxy_ip = $SYS_proxy_ip; |
| 9 |
return $_SERVER["REMOTE_ADDR"]; |
|
| 10 |
|
if ($addr == null) |
| 11 |
|
$addr = $_SERVER["REMOTE_ADDR"]; |
| 12 |
|
|
| 13 |
|
if ($x_addr == null && isset($_SERVER["HTTP_X_FORWARDED_FOR"])) |
| 14 |
|
$x_addr = $_SERVER["HTTP_X_FORWARDED_FOR"]; |
| 15 |
|
|
| 16 |
|
foreach($proxy_ip as $ip) |
| 17 |
|
{ |
| 18 |
|
if (ereg($ip[0],$addr)) |
| 19 |
|
{ |
| 20 |
|
if ($x_addr != null) |
| 21 |
|
{ |
| 22 |
|
$client_addr = explode(",",$x_addr); |
| 23 |
|
for($i=count($client_addr)-1;$i>=0;$i--) |
| 24 |
|
{ |
| 25 |
|
$proxy = false; |
| 26 |
|
foreach($proxy_ip as $ip) |
| 27 |
|
{ |
| 28 |
|
if (ereg($ip,$client_addr[$i])) |
| 29 |
|
$proxy = true; |
| 30 |
|
} |
| 31 |
|
if (!$proxy) |
| 32 |
|
return trim($client_addr[$i]); |
| 33 |
|
} |
| 34 |
|
return trim($client_addr[0]); |
| 35 |
|
} |
| 36 |
|
else |
| 37 |
|
{ |
| 38 |
|
return $_SERVER["REMOTE_ADDR"]; |
| 39 |
|
} |
| 40 |
|
} |
| 41 |
|
} |
| 42 |
|
|
| 43 |
|
return $_SERVER["REMOTE_ADDR"]; |
| 44 |
} |
} |
| 45 |
|
|
| 46 |
?> |
?> |