Linux-Noob Forums

Full Version: proxy/ip detection script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.



Code:
<?php
$reqhost = $_SERVER['HTTP_HOST'];
$proxy = $_SERVER['HTTP_X_FORWARDED_FOR'];
$ipaddr = $_SERVER['REMOTE_ADDR'];
$revdns = $_SERVER['REMOTE_HOST'];
$final = "";
if ($revdns) {$final = $revdns;}
else {$final = $ipaddr;}
if ($proxy) {
       $final = $proxy;
       $prxyhost = gethostbyaddr($_SERVER['HTTP_X_FORWARDED_FOR']);
       if ($prxyhost) {$final = $prxyhost;}
       }
echo"your ip/revdns is $final";
?>




 

this little script will check if there's a proxy by checking if there is a X_FORWARDED_FOR in the header (which contains the client's ip) and will try to get the reverse dns of that ip, if there's no revdns, it prints the ip, if there's no X_FORWARDED_FOR, it will try to get the reverse dns of the remote ip (REMOTE_HOST), if there's no revdns, it will print the ip (REMOTE_ADDR).

awesome! I was looking for that..