PDA

View Full Version : PHP Help - Noone looks in Coding bit :)



Recursion
04-02-2007, 05:27 PM
Hi all,

Can someone make me a line of code that will output:

Your 'Real' IP is: "Users IP Here", But using our proxy your IP will be: "Servers IP Here"!

Please help!

Thanks
Tom

Edited by Lµke (Forum Moderator): Thread Moved from Website Designing. Please post in the correct section next time, Thanks :).

ZAG
04-02-2007, 05:56 PM
<?php
echo "Your 'Real' IP is: ".$_SERVER['REMOTE_ADDR'].", But using our proxy your IP will be: ".$_SERVER['SERVER_ADDR']."!";
?>


That should work.

Mentor
04-02-2007, 05:57 PM
At simplist


echo "your ip is ".$_SERVER['REMOTE_ADDR'].". with prox your ip will be ".$_SERVER['SERVER_ADDR'];

or if you want to see threw proxies they may already be useing


$ip = "";
if ((isset($_SERVER['HTTP_X_FORWARDED_FOR'])) && (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])))
{
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
elseif ((isset($_SERVER['HTTP_CLIENT_IP'])) && (!empty($_SERVER['HTTP_CLIENT_IP'])))
{
$ip = explode(".",$_SERVER['HTTP_CLIENT_IP']);
$ip = $ip[3].".".$ip[2].".".$ip[1].".".$ip[0];
}
elseif ((!isset($_SERVER['HTTP_X_FORWARDED_FOR'])) || (empty($_SERVER['HTTP_X_FORWARDED_FOR'])))
{
if ((!isset($_SERVER['HTTP_CLIENT_IP'])) && (empty($_SERVER['HTTP_CLIENT_IP'])))
{
$ip = $_SERVER['REMOTE_ADDR'];
}
}
else
{
$ip = "0.0.0.0";
}

My be a better way to access there current ip adress

Jackboy
05-02-2007, 09:32 AM
At simplist


echo "your ip is ".$_SERVER['REMOTE_ADDR'].". with prox your ip will be ".$_SERVER['SERVER_ADDR'];

or if you want to see threw proxies they may already be useing


$ip = "";
if ((isset($_SERVER['HTTP_X_FORWARDED_FOR'])) && (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])))
{
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
elseif ((isset($_SERVER['HTTP_CLIENT_IP'])) && (!empty($_SERVER['HTTP_CLIENT_IP'])))
{
$ip = explode(".",$_SERVER['HTTP_CLIENT_IP']);
$ip = $ip[3].".".$ip[2].".".$ip[1].".".$ip[0];
}
elseif ((!isset($_SERVER['HTTP_X_FORWARDED_FOR'])) || (empty($_SERVER['HTTP_X_FORWARDED_FOR'])))
{
if ((!isset($_SERVER['HTTP_CLIENT_IP'])) && (empty($_SERVER['HTTP_CLIENT_IP'])))
{
$ip = $_SERVER['REMOTE_ADDR'];
}
}
else
{
$ip = "0.0.0.0";
}

My be a better way to access there current ip adress


+rep for showing more advanced way ;P

Want to hide these adverts? Register an account for free!