How to get visiter's real ip?

Discussion in 'PHP' started by Justin King, May 3, 2008.

  1. #1
    Some visiters will visit a web site via a proxy in order to hide his real ip, how to use php to check out the real ip?
     
    Justin King, May 3, 2008 IP
  2. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Check all the headers, especially X_FORWARDED_FOR and such.

    Jay
     
    jayshah, May 3, 2008 IP
  3. astersuiren

    astersuiren Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    oh, i have a function to check visitor's real ip address:

    
    function getRealIpAddr()
    {
    	if (!empty($_SERVER['HTTP_CLIENT_IP']))
    	{
    		$ip=$_SERVER['HTTP_CLIENT_IP'];
    	}
    	else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
    	{
    		$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
    	}
    	else
    	{
    		$ip=$_SERVER['REMOTE_ADDR'];
    	}
    	return $ip;
    }
    
    Code (markup):
    one thing make me wonder. If we can know the real visitor's IP address,what is the use of proxy?
     
    astersuiren, May 3, 2008 IP
  4. roshanbh

    roshanbh Peon

    Messages:
    52
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
  5. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #5
    The levels of proxy:
    Transparent & Anonymous - Reveals real IP
    Elite - Does not reveal it's a proxy.

    Get an elite proxy and browse to your script, it won't detect your real IP.

    Jay
     
    jayshah, May 4, 2008 IP
  6. astersuiren

    astersuiren Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    ^thank you.
     
    astersuiren, May 4, 2008 IP