At 11:04 23/04/2002 +0300, Cosmin Vlasiu wrote:
>Hello,
>How can I take the IP of the visitator of my php page?
>not gethostbyname...
>I need the ip of any visitator not for the specified visitator.
>
>Thank you
>
>Cosmin

Hello,

function http_data()
{
         $user_data = array ();

// IP Number
if (getenv(HTTP_X_FORWARDED_FOR)){
         $user_data['ip']=getenv(HTTP_X_FORWARDED_FOR);
         } else {
                 $user_data['ip'] =getenv(REMOTE_ADDR);
         }

// HOSTNAME
         if ((getenv("REMOTE_HOST ")== "")){
                 $r_hostname = @gethostbyaddr($REMOTE_ADDR);
                 if ($r_hostname ==""){
                         $user_data['machine']   = 'unknown';
                           }else {
                         $user_data['machine'] = $r_hostname;
                         }
         } else {
                 $user_data['machine']   = getenv("REMOTE_HOST ");
                 }

// Browser
         $user_data['navigateur']        =       getenv("HTTP_USER_AGENT");

// HTTP Refer
         $user_data['comefrom']  =       getenv("HTTP_REFERER");

         return $user_data;
}

Hope this helps

Luc


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

Reply via email to