public static function clientIP()
    {
        $customHTTPHeader = eZINI::instance()->variable( 'HTTPHeaderSettings', 'ClientIpByCustomHTTPHeader' );
        if( $customHTTPHeader && $customHTTPHeader != 'false' )
        {
            // Transforms for instance, X-Forwarded-For into X_FORWARDED_FOR
            $phpHeader = 'HTTP_' . str_replace( '-', '_', strtoupper( $customHTTPHeader ) );
            $forwardedClientsString = eZSys::serverVariable( $phpHeader, true );

            if ( $forwardedClientsString )
            {
                // $forwardedClientsString (usually) contains a comma+space separated list of IPs
                // where the left-most being the farthest downstream client. All the others are proxy servers.
                // As X-Forwarded-For is not a standard header yet, we prefer to use a simple comma as the explode delimiter
                $forwardedClients = explode( ',', $forwardedClientsString );
                if( !empty( $forwardedClients ) )
                {
                    return trim( $forwardedClients[0] );
                }
            }
        }

        return self::serverVariable( 'REMOTE_ADDR', true );
    }