Here is a function a found on php.net that turns the IP.

Everything that Justin said is true too.  If they have a dial-up user or are
behind a proxy server you can't track them.

Also if you are saving this to a database table it will get very big fast,
just like Justin said.  I would create a table just for today's hits, then
have a script run at 12:01 everyday that creates a summary record and saves
it to another table.  Then delete the records from the today hits.  You
could setup a crontab to run the script for you.

function getip() {
     if (isSet($_SERVER)) {
          if (isSet($_SERVER["HTTP_X_FORWARDED_FOR"])) {
               $realip = $_SERVER["HTTP_X_FORWARDED_FOR"];
          } elseif (isSet($_SERVER["HTTP_CLIENT_IP"])) {
               $realip = $_SERVER["HTTP_CLIENT_IP"];
          } else {
               $realip = $_SERVER["REMOTE_ADDR"];
          }

     } else {
          if ( getenv( 'HTTP_X_FORWARDED_FOR' ) ) {
               $realip = getenv( 'HTTP_X_FORWARDED_FOR' );
          } elseif ( getenv( 'HTTP_CLIENT_IP' ) ) {
               $realip = getenv( 'HTTP_CLIENT_IP' );
          } else {
               $realip = getenv( 'REMOTE_ADDR' );
          }
        }
 return $realip;
}
_________________________________________
Mark McCulligh, Application Developer / Analyst
Sykes Canada Corporation www.SykesCanada.com
(888)225-6824 ex. 3262
[EMAIL PROTECTED]
----- Original Message -----
From: "Sebastian Marcu" <[EMAIL PROTECTED]>
Newsgroups: php.general
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 04, 2002 12:00 PM
Subject: getting the IP address off a visitor


> Hi there,
>
> I am new to PHP and need some help.
> I was wondering if there is a way to get hold of the IP address of a site
> visitor with PHP. I'm trying to develop an interaction where the server
> would recognise a new visitor from a returning visitor via the IP address.
>
> Regards,
>
>
> Sebastian
>
>
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to