Horde_Service_Weather_Base::_ipIsUnique PHP Method

_ipIsUnique() protected method

Check if an IP address is a globally unique address and not in RFC1918 or RFC3330 address space.
protected _ipIsUnique ( string $ip ) : boolean
$ip string The IPv4 IP address to check.
return boolean True if the IP address is globally unique, otherwise false.
    protected function _ipIsUnique($ip)
    {
        // Make sure it's sane
        $parts = explode('.', $ip);
        if (count($parts) != 4) {
            return false;
        }
        // zero config IPs RFC3330
        if ($parts[0] == 169 && $parts[1] == 254) {
            return false;
        }
        // reserved RFC 1918
        if ($parts[0] == 10 || $parts[0] == 192 && $parts[1] == 168 || $parts[0] == 172 && ($parts[1] >= 16 && $parts[1] <= 31)) {
            return false;
        }
        // Loopback
        if ($parts[0] == 127) {
            return false;
        }
        return true;
    }