lib/ezutils/classes/ezsys.php
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 );
    }
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 );
    }
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 ) ; }
Returns the client IP whether he's behind a proxy or not

Use [HTTPHeaderSettings].ClientIpByCustomHTTPHeader in site.ini if you want
to use a custom http header such as X-Forwarded-For

Note: X-Forwarded-For is transformed by PHP
into $_SERVER['HTTP_X_FORWARDED_FOR]

eZDebug calls in this method should be avoided as there is a risk of infinite recurstion
due to IP check (http://issues.ez.no/19045

@return string
Returns the client IP whether he s behind a proxy or not