FOF30\Utils\Ip::detectAndCleanIP PHP Метод

detectAndCleanIP() защищенный статический Метод

Gets the visitor's IP address. Automatically handles reverse proxies reporting the IPs of intermediate devices, like load balancers. Examples: https://www.akeebabackup.com/support/admin-tools/13743-double-ip-adresses-in-security-exception-log-warnings.html http://stackoverflow.com/questions/2422395/why-is-request-envremote-addr-returning-two-ips The solution used is assuming that the last IP address is the external one.
protected static detectAndCleanIP ( ) : string
Результат string
    protected static function detectAndCleanIP()
    {
        $ip = self::detectIP();
        if (strstr($ip, ',') !== false || strstr($ip, ' ') !== false) {
            $ip = str_replace(' ', ',', $ip);
            $ip = str_replace(',,', ',', $ip);
            $ips = explode(',', $ip);
            $ip = '';
            while (empty($ip) && !empty($ips)) {
                $ip = array_pop($ips);
                $ip = trim($ip);
            }
        } else {
            $ip = trim($ip);
        }
        return $ip;
    }