.

alright, on a friend of mine's server, we are trying to implement a unique visitor counter. We are doing this via unique IP's. Problem is I've tried using several methods of capturing it, but it only returns the server ip... obviously rendering this counter useless. I'm sure it has something to do with his server (Mac OS X Server). Not sure if the settings would be in apache or in his firewall settings, but we've tried a bunch of stuff, and can't get it to work. I know this doesn't really relate to PHP, but I figured i'd give it a try. If anyone can offer any help or advice, it would be greatly appreciated. Thanks.

    There's sometimes problems with which ip the remote_addr fetches, but this is the first time I've heard about it grabbing the servers own.

    Check this:

    Fetch the client ip

    if(getenv(HTTP_X_FORWARDED_FOR)) {
    $thisip = getenv(HTTP_X_FORWARDED_FOR);
    } else {
    $thisip = getenv(REMOTE_ADDR);
    }

    The getenv might not work if globals are off, so you might use the $_SERVER var.
    But the x-forward should take care of (in most situations) the problem with firewalls/proxys.

    If that doesn't work, try the good old phpinfo(); and see what it says about your remote_addr

    knutm 😃

      .

      tried 'em both ($_SERVER and getenv)... still doesn't work. Thanks tho. Got any other ideas?.😕 Thanks.

        .

        i did however creat phpinfo and searched for my ip address and came up with this:

        HTTP_PC_REMOTE_ADDR

        so in case anyone encounters this problem, try using this string. I used it like:

        $_SERVER[HTTP_PC_REMOTE_ADDR]

        and now it works fine. Thanks mogster for having me refer to the phpinfo file... I tried searching all over the net for this problem and found nothing... but was too stupid to look there:p . Thanks for the help.

          Well, I'm not sure.
          Have you tried the phpinfo()?

          This is what it says in my case (server/client is on internal network, behind fw):

          REMOTE_ADDR 192.168.0.6
          REMOTE_PORT 2132

          Check it out, as it may provide additional info about your system/config.

          knutm

            Ah... 😃

            Posting in the same second, are we? 😉

              Write a Reply...