phpbar.de logo

Mailinglisten-Archive

AW: [php] ip adresse

AW: [php] ip adresse

"Meißner, Heinz" HMeissner at dgverlag.de
Mon Okt 6 17:40:12 CEST 2003


hi,
teste doch mal das hier :

<snip>
IP hinter PROXY:
<?php
function fetchip() {
//get useful vars:
$client_ip = $_SERVER['HTTP_CLIENT_IP'];
$x_forwarded_for = $_SERVER['HTTP_X_FORWARDED_FOR'];
$remote_addr = $_SERVER['REMOTE_ADDR'];

// then the script itself
if (!empty ($client_ip) ) {
    $ip_expl = explode('.',$client_ip);
    $referer = explode('.',$remote_addr);
    if($referer[0] != $ip_expl[0]) {
        $ip=array_reverse($ip_expl);
        $return=implode('.',$ip);
    } else {
        $return = $client_ip;
    };
} elseif (!empty($x_forwarded_for) ) {
    if(strstr($x_forwarded_for,',')) {
        $ip_expl = explode(',',$x_forwarded_for);
        $return = end($ip_expl);
    } else {
        $return = $x_forwarded_for;
    };
} else {
    $return = $remote_addr;
};
unset ($client_ip,$x_forwarded_for,$remote_addr,$ip_expl,);
return $return;
};
?>
<snip>
grüße
h1

php::bar PHP Wiki   -   Listenarchive