returns True if the $host has $ip

@param  string  $ip
@param  string  $host

@return boolean
480579
public function has($ip, $host)
    {
        $this->processFile($this->getFile());
        return in_array($ip, $this->hosts[$host]);
    }
687638
protected function filterHost($host)
    {
        if ($host) {
            if (filter_var($host, FILTER_VALIDATE_IP)) {
                $host = strval($host);
            } elseif (preg_match(
                '/^(?:[' . self::CHARACTERS_UNRESERVED . self::CHARACTERS_SUB_DELIMS . ':@\/\?]+|%[A-Fa-f0-9]{2})+$/',
                $host
            )
            ) {
                $host = strval($host);
            } else {
                throw new InvalidArgumentException('Invalid host "%s".', $host);
            }
        } else {
            $host = '';
        }

        return $host;
    }
1288910
public function setIP($ip)
    {
        $this->logger->debug('setting: set IP address to ' . $ip);
        $this->ip = $ip;
        return true;
    }
437277
public static function check_ipv6($ip)
	{
		$ip = self::uncompress($ip);
		list($ipv6, $ipv4) = self::split_v6_v4($ip);
		$ipv6 = explode(':', $ipv6);
		$ipv4 = explode('.', $ipv4);
		if (count($ipv6) === 8 && count($ipv4) === 1 || count($ipv6) === 6 && count($ipv4) === 4)
		{
			foreach ($ipv6 as $ipv6_part)
			{
				// The section can't be empty
				if ($ipv6_part === '')
					return false;

				// Nor can it be over four characters
				if (strlen($ipv6_part) > 4)
					return false;

				// Remove leading zeros (this is safe because of the above)
				$ipv6_part = ltrim($ipv6_part, '0');
				if ($ipv6_part === '')
					$ipv6_part = '0';

				// Check the value is valid
				$value = hexdec($ipv6_part);
				if (dechex($value) !== strtolower($ipv6_part) || $value < 0 || $value > 0xFFFF)
					return false;
			}
			if (count($ipv4) === 4)
			{
				foreach ($ipv4 as $ipv4_part)
				{
					$value = (int) $ipv4_part;
					if ((string) $value !== $ipv4_part || $value < 0 || $value > 0xFF)
						return false;
				}
			}
			return true;
		}
		else
		{
			return false;
		}
	}
148037
public static function isValidHost($host)
    {
        //Simple syntax limits
        if (empty($host)
            or !is_string($host)
            or strlen($host) > 256
        ) {
            return false;
        }
        //Looks like a bracketed IPv6 address
        if (trim($host, '[]') != $host) {
            return (bool) filter_var(trim($host, '[]'), FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);
        }
        //If removing all the dots results in a numeric string, it must be an IPv4 address.
        //Need to check this first because otherwise things like `999.0.0.0` are considered valid host names
        if (is_numeric(str_replace('.', '', $host))) {
            //Is it a valid IPv4 address?
            return (bool) filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
        }
        if (filter_var('http://' . $host, FILTER_VALIDATE_URL)) {
            //Is it a syntactically valid hostname?
            return true;
        }

        return false;
    }
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;
	}
420704
public function check($host)
    {
        $this->validHost($host);

        $host = trim($host);
        $valid = false; // init as false
        $this->file->rewind();

        while (!$this->file->eof()) {
            $pattern = '/\b'.$host.'\b/i';
            if (preg_match($pattern, $this->file->current())) {
                $valid = trim($this->file->current());
                break; // Once you find the string, you should break out the loop.
            }
            $this->file->next();
        }

        return $valid;
    }
202789
private static function isValidAuthHost(string $host): bool
    {
        if ($host === '') {
            return true;
        }

        // http://tools.ietf.org/html/rfc3986#section-3.2.2
        // A host identified by an Internet Protocol literal address, version 6
        // [RFC3513] or later, is distinguished by enclosing the IP literal
        // within square brackets ("[" and "]").  This is the only place where
        // square bracket characters are allowed in the URI syntax.
        if (strpos($host, '[') !== false) {
            return self::isValidIpLiteral($host);
        }

        // IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet
        $dec = '(?:(?:2[0-4]|1[0-9]|[1-9])?[0-9]|25[0-5])';
        $ipV4 = sprintf('/\A(?:%s\.){3}%s\z/', $dec, $dec);
        if (preg_match($ipV4, $host)) {
            return true;
        }

        // reg-name = *( unreserved / pct-encoded / sub-delims )
        $pattern = sprintf(
            '/\A(?:[%s%s]|(?:%s))*\z/i',
            'a-z0-9\-._~',
            '!$&\'()*+,;=',
            '%[a-f0-9]{2}'
        );

        return !!preg_match($pattern, $host);
    }
926557
def is_same_host(host1, host2):

    
    try:

        if host1 == host2:
            return True
        else:
            ips1 = get_host_ips(host1)
            ips2 = get_host_ips(host2)
            return len(set(ips1) & set(ips2)) > 0
    except Exception, ex:
        log_exception(ex)
        return False
506302
protected function matchHost($host, array $hosts)
    {
        foreach ($hosts as $trusted) {
            if (0 === strcmp($host, $trusted) || preg_match('#^'. $trusted .'#s', $host)) {
                return true;
            }
        }
        return false;
    }
141720
public function isBlocked($host)
    {
        $host = parse_url($host, PHP_URL_HOST);
        $host = utf8_encode(trim($host));

        if (empty($host)) return false;

        $fullDomain = $this->getFullDomain($host);
        $rootDomain = $this->getRootDomain($fullDomain);

        return $this->spammers()
            ->whereHostIn([$fullDomain, $rootDomain])
            ->whereBlocked()
            ->count() > 0;
    }
546691
public function hasIp($ip)
    {
        $this->processFile($this->getFile());

        return array_key_exists($ip, $this->ips);
    }
558194
public synchronized boolean isAllowedHost(String host) {
    boolean isIncluded = includes.isEmpty() || includes.contains(host);
    boolean isExcluded = excludes.contains(host);
    return isIncluded && !isExcluded;
  }
901271
protected function validateIp($ip)
    {
        if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE | FILTER_FLAG_IPV6) === false) {
            return false;
        }

        return true;
    }
228304
public function contains($ip_or_block): bool
    {
        if ((is_string($ip_or_block) && strpos($ip_or_block, '/') !== false) || $ip_or_block instanceof IPBlock) {
            return $this->containsBlock($ip_or_block);
        } else {
            return $this->containsIP($ip_or_block);
        }
    }
159478
public function ipAddress($subject) : bool
    {
        if ($subject === null) {
            return false;
        }
        $v = '' . $subject;
        return $v === '' ? false : !!filter_var($v, FILTER_VALIDATE_IP);
    }
378737
public function isAllowed ($ip, $priority = 'deny,allow')
	{
		
		// Convert IP to decimal
		
		$ipDec = (float)sprintf ("%u", ip2long ($ip));
		
		// Check
		
		foreach (explode (',', $priority) as $type)
		{
			
			switch ($type)
			{
				
				// Check if the IP is allowed
				
				case 'allow':
					
					foreach ($this->allowIPs as $name => $range)
					{
						if ($this->isInside ($ipDec, $name, $range))
						{
							return TRUE;
						}
					}
					
					break;
				
				// Check if IP is denied
					
				case 'deny':
					
					foreach ($this->denyIPs as $name => $range)
					{
						if ($this->isInside ($ipDec, $name, $range))
						{
							return FALSE;
						}
					}
					
					break;
				
			}
			
		}
		
		// Not allowed by default
		
		return FALSE;
		
	}