ManaPHP\Http\Request::getClientAddress PHP Метод

getClientAddress() публичный Метод

Gets most possible client IPv4 Address. This method search in $_SERVER['REMOTE_ADDR'] and optionally in $_SERVER['HTTP_X_FORWARDED_FOR']
public getClientAddress ( ) : string
Результат string
    public function getClientAddress()
    {
        if ($this->_clientAddress === null) {
            if (!isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
                $this->_clientAddress = $_SERVER['REMOTE_ADDR'];
            } else {
                $client_address = $_SERVER['REMOTE_ADDR'];
                if (Text::startsWith($client_address, '127.0.') || Text::startsWith($client_address, '192.168.') || Text::startsWith($client_address, '10.')) {
                    $this->_clientAddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
                } else {
                    $this->_clientAddress = $_SERVER['REMOTE_ADDR'];
                }
            }
        }
        return $this->_clientAddress;
    }