src/mako/http/Request.php
public function getIp(): string
	{
		if($this->ip === null)
		{
			$ip = $this->server->get('REMOTE_ADDR');

			if(!empty($this->trustedProxies))
			{
				$ips = $this->server->get('HTTP_X_FORWARDED_FOR');

				if(!empty($ips))
				{
					$ips = array_map('trim', explode(',', $ips));

					foreach($ips as $key => $value)
					{
						foreach($this->trustedProxies as $trustedProxy)
						{
							if(IP::inRange($value, $trustedProxy))
							{
								unset($ips[$key]);

								break;
							}
						}
					}

					$ip = end($ips);
				}
			}

			$this->ip = (filter_var($ip, FILTER_VALIDATE_IP) !== false) ? $ip : '127.0.0.1';
		}

		return $this->ip;
	}
public function getIp(): string
	{
		if($this->ip === null)
		{
			$ip = $this->server->get('REMOTE_ADDR');

			if(!empty($this->trustedProxies))
			{
				$ips = $this->server->get('HTTP_X_FORWARDED_FOR');

				if(!empty($ips))
				{
					$ips = array_map('trim', explode(',', $ips));

					foreach($ips as $key => $value)
					{
						foreach($this->trustedProxies as $trustedProxy)
						{
							if(IP::inRange($value, $trustedProxy))
							{
								unset($ips[$key]);

								break;
							}
						}
					}

					$ip = end($ips);
				}
			}

			$this->ip = (filter_var($ip, FILTER_VALIDATE_IP) !== false) ? $ip : '127.0.0.1';
		}

		return $this->ip;
	}
public function getIp ( ) : string { if ( $ this -> ip === null ) { $ ip = $ this -> server -> get ( 'REMOTE_ADDR' ) ; if ( ! empty ( $ this -> trustedProxies ) ) { $ ips = $ this -> server -> get ( 'HTTP_X_FORWARDED_FOR' ) ; if ( ! empty ( $ ips ) ) { $ ips = array_map ( 'trim' , explode ( ',' , $ ips ) ) ; foreach ( $ ips as $ key => $ value ) { foreach ( $ this -> trustedProxies as $ trustedProxy ) { if ( IP :: inRange ( $ value , $ trustedProxy ) ) { unset ( $ ips [ $ key ] ) ; break ; } } } $ ip = end ( $ ips ) ; } } $ this -> ip = ( filter_var ( $ ip , FILTER_VALIDATE_IP ) !== false ) ? $ ip : '127.0.0.1' ; } return $ this -> ip ; }
Returns the ip of the client that made the request.

@return string
Returns the ip of the client that made the request .