Where to read the visitor info

前端 未结 6 920
迷失自我
迷失自我 2021-01-03 15:29

UPDATE:

This question exposed the obsolete, worst approach for visitors count and it should be avoided by everyone out there. Use sophis

6条回答
  •  北荒
    北荒 (楼主)
    2021-01-03 16:08

    Hi this is what i am using to register visitors ip.

    function get_IP() {
    
        // ADRES IP
        if     (getenv('HTTP_CLIENT_IP'))       $ipaddress = getenv('HTTP_CLIENT_IP');
        else if(getenv('HTTP_X_FORWARDED_FOR')) $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
        else if(getenv('HTTP_X_FORWARDED'))     $ipaddress = getenv('HTTP_X_FORWARDED');
        else if(getenv('HTTP_FORWARDED_FOR'))   $ipaddress = getenv('HTTP_FORWARDED_FOR');
        else if(getenv('HTTP_FORWARDED'))       $ipaddress = getenv('HTTP_FORWARDED');
        else if(getenv('REMOTE_ADDR'))          $ipaddress = getenv('REMOTE_ADDR');
        else                                    $ipaddress = 'UNKNOWN';
        //
        return $ipaddress;
    }
    

提交回复
热议问题