Hey peaps. I want my site to log every IP that visits my site in a .txt file! I would also like to retrieve more info about the client, eg: OS, Browser, Date & Time visited etc. I know PHP can do this but I do not heh, can anyone give me help concerning this? thx!

    To get started, write a simple
    <?php echo phpinfo(); ?>
    routine. This will display all of the available globals like
    $REMOTE_ADDR (ip address) and
    $HTTP_USER_AGENT (browser information)

    Be aware that ip addresses may not be exactly what you expect. For example, users using a proxy server will all appear to have the same address.

    You might also want to consider just using the logs already being generated by your web server.

      You should use $SERVER["REMOTE_ADDR"] instead of $REMOTE_ADDR and $SERVER["HTTP_USER_AGENT"] instead of $HTTP_USER_AGENT. Why ? Security ! And in the last versionS of PHP, register_globals is set, by default, to off...

        Thx for the replies but you havnt really answered my question properly heh. I need to know how to log evey IP that visits my site, then stores them into a .txt file. I would also like other info, the info i stated above .

        PS: I dont own my web serverl Lycos does, do you really think they'll give me the server logs??? 🙂

          $str = $_SERVER["REMOTE_ADDR"] . " | " . $_SERVER["HTTP_USER_AGENT"] . "\n";
          $fp = fopen("./log.txt", "a+");
          fputs($fp, $str);
          fclose($fp);
          

            Thx for the script dude! One prob tho! it didnt work. No info was recorded into the log.txt file! What could be the problem??? Thx.

              If you echo $str, do you see something ?

                Actually, most providers do give you access to the logs for your domain.

                In any event, was a log.txt file actually created? If not then there is probably a file permission problem since the web server probably runs as a different user than the owner of the directory.

                You may need to create a logs directory and open up the permissions on it.

                  lycos.co.uk offers logs but you need to put a banner on your page to log visitors, its in the Extras menu I think on the left hand side

                    Write a Reply...