problem with REMOTE_ADDR

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bawar

    problem with REMOTE_ADDR

    I want to put a script on my site that shows how many users are online
    on my site. I found one, and that is shown below. It also shows a
    log with the IP-addresses of those visitors. Buuut... the counter
    always stays on 1...
    When I look at the log, every visitor seems to have the same
    IP-address. When I look up that address, I see it is from the host of
    my webspace.

    Can someone offer me a solution?
    Thanx,

    Bart


    <?php
    ############### ############### ############### ############### ############
    # Copyright © 2001 Wanja Hemmerich
    #
    # First version published April 2001 - This version November 2001
    #
    ############### ############### ############### ############### ############
    # COPYRIGHT NOTICE
    #
    # Copyright 2001 Wanja Hemmerich. All rights reserved.
    #
    #
    #
    # This program may be used and modified, as long as this copyright
    #
    # notice stays intact.
    #
    #
    #
    # Wanja Hemmerich is not responsible for damage, which is possibly
    #
    # caused by his program.
    #
    #
    #
    # This program code may not be sold, nor auctioneered, nor be used in
    #
    # any other commercial way in order to make money.
    #
    #
    #
    # This Programm may not be distributed to download neither by
    #
    # Internet, nor by another medium.
    #
    ############### ############### ############### ############### ############
    # By using this programm, you agree with these conditions.
    #
    #
    #
    ############### ############### ############### ############### ############
    # The text above must be kept intact under all circumstances.
    #
    ############### ############### ############### ############### ############


    include ("./config.php3");

    if (!$datei) $datei = dirname(__FILE_ _)."/$filename";
    $time = @time();
    $ip = getenv("REMOTE_ ADDR");
    $string = "$ip|$time\ n";
    $a = fopen("$filenam e", "a+");
    fputs($a, $string);
    fclose($a);

    $timeout = time()-(60*$timer);

    $all = "";
    $i = 0;
    $datei = file($filename) ;
    for ($num = 0; $num < count($datei); $num++) {
    $pieces = explode("|",$da tei[$num]);

    if ($pieces[1] > $timeout) {
    $all .= $pieces[0];
    $all .= ",";
    }
    $i++;
    }

    $all = substr($all,0,s trlen($all)-1);
    $arraypieces = explode(",",$al l);
    $useronline = count(array_fli p(array_flip($a rraypieces)));

    // display how many people where activ within $timeout
    echo $useronline;

    // Delete
    $dell = "";
    for ($numm = 0; $numm < count($datei); $numm++) {
    $tiles = explode("|",$da tei[$numm]);
    if ($tiles[1] > $timeout) {
    $dell .= "$tiles[0]|$tiles[1]";
    }
    }

    if (!$datei) $datei = dirname(__FILE_ _)."/$filename";
    $time = @time();
    $ip = getenv("REMOTE_ ADDR");
    $string = "$dell";
    $a = fopen("$filenam e", "w+");
    fputs($a, $string);
    fclose($a);
    ?>
  • Robert Downes

    #2
    Re: problem with REMOTE_ADDR

    Try

    $_SERVER["REMOTE_ADD R"]

    instead.
    --
    Bob
    London, UK
    echo Mail fefsensmrrjyahe eoceoq\! | tr "jefroq\!" "@obe.uk"

    Comment

    • bawar

      #3
      Re: problem with REMOTE_ADDR

      > Try[color=blue]
      >
      > $_SERVER["REMOTE_ADD R"]
      >
      > instead.[/color]

      the problem remains :s ...
      Some other scripts also take the IP from the users, and that works...

      Comment

      • Robert Downes

        #4
        Re: problem with REMOTE_ADDR

        bawar wrote:[color=blue][color=green]
        >>Try
        >>
        >> $_SERVER["REMOTE_ADD R"]
        >>
        >>instead.[/color]
        >
        >
        > the problem remains :s ...
        > Some other scripts also take the IP from the users, and that works...[/color]

        $_SERVER["REMOTE_ADD R"] gives you your own IP address? That is weird.
        Sounds like some funky-ass network configuration your web host is using.
        (Like a bad proxy server which only reports its IP.) If so, I don't
        think you'll be able to fix that. Web hosts are very stubborn about
        fixing their network setups. I'm trying to persuade mine to get the
        latest version of PHP 'cause a script I've written depends on a new
        function.

        Ah, to be able to run a server from home on a fat connection...
        --
        Bob
        London, UK
        echo Mail fefsensmrrjyahe eoceoq\! | tr "jefroq\!" "@obe.uk"

        Comment

        Working...