Fetching out proxy users and exposing their real IP is what I really enjoy, I remember using Google Search in Opera Mini Mobile which uses its proxy to forward. But to my suprise, it got to know am in Nigeria and redirect me to .com.ng :D .
So glad to find out PHP doing this, which makes our site or project more mature and advance :) . In PHP simply use the $_SERVER['HTTP_X_FORWARDED_FOR'] :)
$_SERVER['HTTP_X_FORWARDED_FOR'] is only available if the server detects the client using a proxy else it turns empty or unavailable. This looks for original IP that is been forwarded.
Now lets use this function, firstly lets check if the client is really using a Proxy and echo his real IP
if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
//Actually he is! :D, lets expose him and tell him his right IP
echo 'The main IP of the Proxy or Opera Mini is'.$_SERVER['HTTP_X_FORWARDED_FOR'];
}
we are done with that and the above code will only run if he is on proxy, now lets write one that will tell the Client he/she is not using proxy if necessary :)
if(empty($_SERVER['HTTP_X_FORWARDED_FOR']))
{
echo 'You are currently not using a proxy';
}
I guess we are done here, below is the full code<?php
//Lets be sure if he is using proxy
if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
//Actually he is! :D, lets expose him and tell him his right IP
echo 'The main IP of the Proxy or Opera Mini is'.$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
//Oh, he is browsing with his normal IP :)
echo 'The user is currently not using a proxy';
}
?>
very bad
ReplyDeleteHi,
DeletePls how do you mean very bad? :)