Check to see if the ISO county of the IP is blocked
@param string $ip This should be the IP you are checking if it is blocked
@return boolean If the IP country is blocked will return true else returns false
5928
public function isISOBlocked($ip){
        return $this->db->select($this->getBlockedISOTable(), ['iso' => $this->getIPCountryISO($ip)]);
    }
415993
public static function isValid($ip)
    {
        $valid = self::isValidv4($ip);
        if ($valid) {
            self::$ip = $ip;
            self::$isv6 = false;
            return true;
        }

        $valid = self::isValidv6($ip);
        if ($valid) {
            self::$ip = $ip;
            self::$isv6 = true;
            return true;
        }
        return false;
    }
1345465
public function ipValidate($ip)
    {
        $this->debug->info(__FUNCTION__, 'IP: ' . json_encode($ip));
        if (filter_var($ip, FILTER_VALIDATE_IP) === FALSE) {
            $this->debug->info(__FUNCTION__, 'Valid is FALSE');

            return FALSE;
        }
        $this->debug->info(__FUNCTION__, 'Valid is TRUE');

        return TRUE;
    }
1109998
public static function is_iplocation($ip, $location)
	{
		$iplocation = false;
		if ($ip && $location)
		{
			if (!($gdb = self::getGeoDBO()))
			{
				return $iplocation;
			}

			$sql = "SELECT COUNT(*) FROM iplocation WHERE ipfrom <= INET_ATON(" . $gdb->quote($ip) . ") AND ipto >= INET_ATON(" . $gdb->quote($ip) . ") AND LOWER(location) = LOWER(" . $gdb->quote($location) . ")";
			$gdb->setQuery($sql);
			$c = $gdb->loadResult();
			if ($c > 0)
			{
				$iplocation = true;
			}
		}
		return $iplocation;
	}
546691
public function hasIp($ip)
    {
        $this->processFile($this->getFile());

        return array_key_exists($ip, $this->ips);
    }
1256198
public static function isValid(string $ip = null)
    {
        if (is_null($ip)) {
            $ip = self::get();
        }

        return filter_var($ip, FILTER_VALIDATE_IP) == $ip;
    }
408237
public function find($ip)
    {
        if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === FALSE)
        {
           return FALSE; // or throw Exception?
        }

        $ips = explode('.', $ip);

        $nip = pack('N', ip2long($ip));

        $idx = 256 * $ips[0] + intval($ips[1]);
        $idx = $idx * 4;
        $start = unpack('Vlen', substr($this->index, $idx, 4));

        $off = NULL;
        $len = NULL;

        for ($start = $start['len'] * 13 + 262144; $start < $this->offset['len'] - 262148; $start += 13)
        {
            if ($nip >= ($this->index[$start] . $this->index[$start + 1] . $this->index[$start + 2] . $this->index[$start + 3]))
            {
                if ($nip <= ($this->index[$start + 4] . $this->index[$start + 5] . $this->index[$start + 6] . $this->index[$start + 7]))
                {
                    $off = unpack('Vlen', substr($this->index, $start + 8, 4));
                    $len = unpack('Clen', $this->index[$start + 12]);
                    break;
                }
            }
        }

        if ($off === NULL)
        {
            return NULL;
        }

        fseek($this->file, $this->offset['len'] + $off['len'] - 262144);

        return explode("\t", fread($this->file, $len['len']));
    }
663507
public function dnsLookupCallBack($ip)
    {
        if (empty($this->context) || empty($this->context->getLog())) {
            return true;
        }

        // swoole_http_client手工析构有Segmentation fault，暂时直接new
        //$this->client = $this->getObject(\swoole_http_client::class, [$ip, $this->urlData['port'], $this->urlData['ssl']]);
        $this->client = $this->getHttpClient($this->urlData['host'], $ip, $this->urlData['port'], $this->urlData['ssl']);

        $headers = array_merge($this->urlData['headers'], [
            'Host' => $this->urlData['host'],
            'X-Ngx-LogId' => $this->context->getLogId(),
            'Accept-Encoding' => 'gzip,deflate'
        ]);

        $this->setHeaders($headers);
        ($this->urlData['callBack'])($this);
    }
1012317
public static function isIp($ip)
    {
        $segments = explode('.', $ip);

        if (count($segments) === 4) {
            foreach ($segments as $segment) {
                if (!is_numeric($segment)) {
                    return false;
                }
            }

            return true;
        } else {
            return false;
        }
    }
582677
public function lookupIp($ip)
    {
        $results = array();

        $continentServer = new Server();
        foreach ($continentServer->getContinentServers() as $server) {
            $result = $this->queryServer($server, $ip);
                if ($result && !in_array($result, $results)) {
                    $results[$server]= $result;
                }
        }
        $res = "RESULTS FOUND: " . count($results);
        foreach ($results as $server => $result) {
            $res .= "Lookup results for " . $ip . " from " . $server . " server: " . $result;
        }
        return $res;
    }
493058
public function validateIpAddress(string $ipAddress) : bool
    {
        if ($ipAddress === '') {
            return false;
        }

        return (bool) filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE);
    }
585943
private function ip($ip)
    {
        return ((false === ip2long($ip)) || (long2ip(ip2long($ip)) !== $ip)) ? false : true;
    }
234735
public function ipValidateV6($ip)
    {
        $this->debug->info(__FUNCTION__, 'IP: ' . json_encode($ip));
        if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === FALSE) {
            $this->debug->info(__FUNCTION__, 'Valid is FALSE');

            return FALSE;
        }

        $this->debug->info(__FUNCTION__, 'Valid is TRUE');

        return TRUE;
    }
1133256
protected function dnsResolutionIsOk($domain = null, $ip = null)
    {
        if ($this->dnsAlreadyResolved) {
            return true;
        }

        $domain = $domain ? $domain: $this->obtainDomain();
        $ip = $ip ? $ip: $this->obtainIp();

        if ($domain != null && $ip != null) {
            $resolved_ip = gethostbyname($domain);
            if ($resolved_ip != $domain && $resolved_ip == $ip) {
                $this->dnsAlreadyResolved = true;
                return true;
            }
        }
        return false;
    }
1084760
public static function checkIP($UserIP = false)
    {
        // Check if IP present
        if ($UserIP === false)
        {
            if (\Environment::get('ip'))
            {
                if (strpos(\Environment::get('ip'), ',') !== false) //first IP
                {
                    $UserIP =  trim(substr(\Environment::get('ip'), 0, strpos(\Environment::get('ip'), ',')));
                }
                else
                {
                    $UserIP = trim(\Environment::get('ip'));
                }
            }
            else
            {
                return false; // No IP, no search.
            }
            //Test for private IPs
            if ( true === static::checkPrivateIP($UserIP) &&
                false === empty($_SERVER['HTTP_X_FORWARDED_FOR'])
            )
            {
                //second try
                $HTTPXFF = $_SERVER['HTTP_X_FORWARDED_FOR'];
                $_SERVER['HTTP_X_FORWARDED_FOR'] = '';
            
                $UserIP = \Environment::get('ip');
                if (strpos($UserIP, ',') !== false) //first IP
                {
                    $UserIP = trim( substr($UserIP, 0, strpos($UserIP, ',') ) );
                }
                $_SERVER['HTTP_X_FORWARDED_FOR'] = $HTTPXFF;
            }
        }
        // IPv4 or IPv6 ?
        switch (static::getIpVersion($UserIP))
        {
        	case "IPv4":
        	    if ( static::checkBotIPv4($UserIP, static::getBotIpv4List()) === true) { return true; }
        	    break;
        	case "IPv6":
        	    if ( static::checkBotIPv6($UserIP, static::getBotIpv6List()) === true) { return true; }
        	    break;
        	default:
        	    return false;
        	    break;
        }
        return false;
    }
1125585
public function is_ip(bool $restricted=true) {
		if (! $this->is_valid()) {
			return false;
		}

		if ($restricted) {
			return !! \filter_var($this->host, \FILTER_VALIDATE_IP);
		}

		return !! \filter_var(
			$this->host,
			\FILTER_VALIDATE_IP,
			\FILTER_FLAG_NO_PRIV_RANGE | \FILTER_FLAG_NO_RES_RANGE
		);
	}
244842
public function validIpv6($ip, $strict = true)
    {
        $flags = FILTER_FLAG_IPV6;
        if ($strict) {
            $flags = FILTER_FLAG_IPV6 | FILTER_FLAG_NO_PRIV_RANGE;
        }

        if (filter_var($ip, FILTER_VALIDATE_IP, array('flags' => $flags)) !== false) {
            return true;
        }

        return false;
    }