Results 1 to 7 of 7
  1. #1

    Will this always Visitors browsing IP

    Hi,

    Will the below code, always get the visitors IP they are browsing the site with?

    Code:
    $ip_addr = getenv(REMOTE_ADDR);
    Thanks,
    DolphinEcho

  2. #2
    It's impossible to *always* reliably get the end-users IP address. If they are behind a firewall, using an anonymizing network, behind a transparent proxy server, etc. you may not be able to get their IP address at all.

    Something like this will be more reliable than your current solution, but again, you'll never be able to get their IP address 100% of the time:
    http://roshanbh.com.np/2007/12/getti...ss-in-php.html

  3. #3
    Hi,

    Thanks for the reply

    What I am trying to do is get the IP that is visiting the site with, be it a proxy or non-proxy IP, so basically what the site see as the visitors IP.

    Have I got this correct with the bit of code in the first post:

    If the visitor is behind any proxy the code will get the proxy IP ?
    If they not behind a proxy the code will get the ISP IP ?

    I am not overall bothered if I get the end user IP, just the IP that is visiting the site.
    Thanks,
    DolphinEcho

  4. #4
    Yes, you could also use:
    $ip_addr = $_SERVER['REMOTE_ADDR'];

    If the visitor is behind any proxy the code will get the proxy IP ?
    Yes.

    If they not behind a proxy the code will get the ISP IP ?
    You'll get the IP address of the visitor that their ISP has assigned to them.

    If they are behind a firewall, you may get the firewall's IP address.

  5. #5
    Join Date
    Jul 2009
    Location
    Rethimno, Crete, Greece
    Posts
    7
    Here's the function I use to pass the proxy problem.

    function getRealIpAddr(){
    if (!empty($_SERVER['HTTP_CLIENT_IP'])){
    //check ip from share internet
    $ip = $_SERVER['HTTP_CLIENT_IP'];
    }
    elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
    //to check ip is pass from proxy
    $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    else{
    $ip = $_SERVER['REMOTE_ADDR'];
    }
    return $ip;
    }

  6. #6
    Quote Originally Posted by sdiama View Post
    Here's the function I use to pass the proxy problem.

    function getRealIpAddr(){
    if (!empty($_SERVER['HTTP_CLIENT_IP'])){
    //check ip from share internet
    $ip = $_SERVER['HTTP_CLIENT_IP'];
    }
    elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
    //to check ip is pass from proxy
    $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    else{
    $ip = $_SERVER['REMOTE_ADDR'];
    }
    return $ip;
    }
    Thanks for sharing. I am just in need of this script to block some visit via proxy.

  7. #7
    Join Date
    Mar 2007
    Location
    Phoenix, AZ, United State
    Posts
    1,492
    There is no reliable way to get a user's IP Address when taking into account HTTP proxies.

Similar Threads

  1. Replies: 8
    Last Post: 09-28-2005, 08:50 AM
  2. 3 Traffic names: 1229 visitors, 2838 visitors, 15 289 visitors
    By Johnnywj in forum Domain Name Offers
    Replies: 7
    Last Post: 03-28-2005, 10:37 AM
  3. Guaranteed Website Visitors / 1000 Visitors $1.75
    By geesh.net in forum Other Offers & Requests
    Replies: 2
    Last Post: 03-02-2004, 06:28 AM
  4. co-browsing
    By mas2424 in forum Web Hosting
    Replies: 0
    Last Post: 09-04-2003, 12:29 PM
  5. What do you like to do while browsing WHT?
    By smidwap in forum Web Hosting Lounge
    Replies: 24
    Last Post: 08-01-2002, 07:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •