[h1]Get Passed Some Proxies![/h1]Today, we will be making a code that displays the
real IP of the user, because it can get past proxies! So let's just jump right into it, again this is a very short script. Remember, comments are talking about the code
ABOVE.
<?php
//This of course tells the website that what follows
$realip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ?
//This may seem a little confusing, but for the most part you don't need to learn this, unless of course you want to make PHP scripts that have to do with IPs. But at the
//beginning, notice $realip = blah blah, well the money sign means that what follows is a variable, a variable can be anything depending on what you set it to, and can be
//different depending on who is viewing the script, in this case it says that the variable $realip should be set to the user's real IP, which is what all that code means after
//$realip =.
$_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
//This code simply means if there is no proxy, then real IP should be set to the normal way of getting a IP, (which was used in my last tut).
echo 'Haha, you trying to trick me with your proxy? Your <i>real</i> IP is '.$realip;
//Again, we have echo, which is what is returned from the script, and the 'Haha, you trying...' part is what the text will say, and then after IP is, there is another ', which
//means that the following part should not be plain text, but whatever the variable is. Also, you see a period right before the variable, which is very important, because it's
//telling the PHP to include the variable in the echo, then we have ; which of course ends the line.
?>
Then the last line of code simply means that is the end of the code. If you have any questions just post 'em here. Here is the code w/o the comments.
<?php
$realip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ?
$_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
echo 'Haha, you trying to trick me with your proxy? Your <i>real</i> IP is '.$realip;
?>
Click here to see this script in action!If you like this tutorial, please
click here to register.
Click the link below to download the PHP file for this tutorial.
Get Passed Proxies! PHP