Jump to content

proxy/ip detection script

Recommended Posts

$reqhost = $_SERVER['HTTP_HOST'];
$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).

Link to post
Share on other sites
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...