check hosts file if $host is present.

@param string The $host is what we are searching for in the hosts file

@return bool
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;
    }
990050
public function blockOne($host)
    {
        return $this->exists($host)
            ? $this->updateOne($host)
            : $this->addOne($host);
    }
235186
public function addHost(Host $host)
    {
        if (empty($host)) return $this;

        $this->_host_list["{$host->name}:{$host->port}"] = $host;

        return $this;
    }
831015
public function connectRaw($host)
    {
        $this->type = 'raw';
        if (@inet_pton($host) === false) { // dirty check
            \PHPDaemon\Clients\DNS\Pool::getInstance()->resolve($host, function ($result) use ($host) {
                if ($result === false) {
                    Daemon::log(get_class($this) . '->connectRaw : unable to resolve hostname: ' . $host);
                    $this->onFailureEv();
                    return;
                }
                // @TODO stack of addrs
                if (is_array($result)) {
                    srand(Daemon::$process->getPid());
                    $real = $result[rand(0, sizeof($result) - 1)];
                    srand();
                } else {
                    $real = $result;
                }
                $this->connectRaw($real);
            });
            return true;
        }
        $this->hostReal = $host;
        if ($this->host === null) {
            $this->host = $this->hostReal;
        }
        $this->addr = $this->hostReal . ':raw';
        $fd = socket_create(\EventUtil::AF_INET, \EventUtil::SOCK_RAW, 1);
        if (!$fd) {
            return false;
        }
        socket_set_nonblock($fd);
        @socket_connect($fd, $host, 0);
        $this->setFd($fd);
        if (!$this->bev) {
            return false;
        }
        return true;
    }
404924
public static function parse_host($host) {
		// Try to parse it the easy way.
		$tmp = v_mb::parse_url($host, \PHP_URL_HOST);
		if ($tmp) {
			$host = $tmp;
		}
		// Or the hard way?
		else {
			r_cast::string($host, true);

			r_mb::trim($host);

			// Cut off the path, if any.
			if (false !== ($start = v_mb::strpos($host, '/'))) {
				$host = v_mb::substr($host, 0, $start);
			}

			// Cut off the query, if any.
			if (false !== ($start = v_mb::strpos($host, '?'))) {
				$host = v_mb::substr($host, 0, $start);
			}

			// Cut off credentials, if any.
			if (false !== ($start = v_mb::strpos($host, '@'))) {
				$host = v_mb::substr($host, $start + 1, null);
			}

			// Is this an IPv6 address?
			if (\filter_var($host, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) {
				r_sanitize::ip($host, true);
			}
			elseif (
				(0 === \strpos($host, '[')) &&
				false !== ($end = v_mb::strpos($host, ']'))
			) {
				$host = v_mb::substr($host, 1, $end - 1);
				r_sanitize::ip($host, true);
			}
			// Cut off port, if any.
			elseif (false !== ($start = v_mb::strpos($host, ':'))) {
				$host = v_mb::substr($host, 0, $start);
			}

			// If it is empty or invalid, there is nothing we can do.
			if (! \strlen($host)) {
				return false;
			}

			// Convert to ASCII if possible.
			if (\function_exists('idn_to_ascii')) {
				$host = \explode('.', $host);
				r_file::idn_to_ascii($host);
				$host = \implode('.', $host);
			}

			// Lowercase it.
			r_mb::strtolower($host, false);

			// Get rid of trailing periods.
			$host = \ltrim($host, '.');
			$host = \rtrim($host, '.');
		}

		// Liberate IPv6 from its walls.
		if (0 === \strpos($host, '[')) {
			$host = \str_replace(array('[', ']'), '', $host);
			r_sanitize::ip($host, true);
		}

		// Is this an IP address? If so, we're done!
		if (\filter_var($host, \FILTER_VALIDATE_IP)) {
			return $host;
		}

		// Look for illegal characters. At this point we should
		// only have nice and safe ASCII.
		if (\preg_match('/[^a-z\d\-\.]/u', $host)) {
			return false;
		}
		$host = \explode('.', $host);
		foreach ($host as $v) {
			// Gotta have length, and can't start or end with a dash.
			if (
				! \strlen($v) ||
				(0 === \strpos($v, '-')) ||
				('-' === \substr($v, -1))
			) {
				return false;
			}
		}

		return \implode('.', $host);
	}
314867
private function filterHost(string $host): string
    {
        if ($host && $host !== self::HTTP_DEFAULT_HOST && strpos($host, '.') === false) {
            throw new InvalidArgumentException("Host '{$host}' is illegal!");
        }

        return strtolower($host);
    }
1030065
private function config_host(string $host=null) {
		if (filter_var($host, FILTER_VALIDATE_URL,
				FILTER_FLAG_PATH_REQUIRED) === false)
			return;
		$host = rtrim($host, '/') . '/';
		$home = $this->home;
		if ($home == '/') {
			$this->host = $host;
			return;
		}
		# home must be at the end of host
		if (substr($host, -strlen($home)) != $home)
			return;
		$this->host = $host;
	}
536907
protected static function filterHost($host)
    {
        if (! is_string($host)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid host; must be a string argument; received %s',
                (is_object($host) ? get_class($host) : gettype($host))
            ));
        }

        return $host;
    }
185927
function _filterHost($host)
    {
        if (strstr($host, ':') !== false)
            throw new \InvalidArgumentException('Host name can`t contains port number.');

        $host = strtolower($host);
        return $host;
    }
884727
public static function host($host)
    {
        if (!isset($_SERVER['HTTP_HOST'])) {
            return false;
        }
        $lower = \strtolower($_SERVER['HTTP_HOST']);

        if (\is_string($host)) {
            return $host === $lower;
        }

        if (\is_array($host)) {
            foreach ($host as $item) {
                if ($item === $lower) {
                    return true;
                }
            }
            return false;
        }
        return false;
    }
407105
private function checkHosts():bool
    {
        if (null === $this->config) {
            return (true);
        }
        $current_env = FEnv::get("framework.env");
        $ip = ToolsExceptions::getClientIp();
        $result = true;
        if ("dev" === $current_env) {
            if (property_exists($this->config, "hosts_denied_dev")) {
                $dd = $this->config->hosts_denied_dev;
                if (null !== $dd) {
                    if (false != in_array("*", $dd)) {
                        $result = false;
                    } elseif (false != in_array($ip, $dd)) {
                        $result = false;
                    }
                }
            }
            if (property_exists($this->config, "hosts_allowed_dev")) {
                $dd = $this->config->hosts_allowed_dev;
                if (null !== $dd) {
                    if (true == in_array("*", $dd) && $result) {
                        $result = true;
                    } elseif (true === in_array($ip, $dd) && false === $result) {
                        $result = true;
                    }
                }
            }
        } elseif ("prod" === $current_env) {
            if (property_exists($this->config, "hosts_denied_prod")) {
                $dd = $this->config->hosts_denied_prod;
                if (null !== $dd) {
                    if (false != in_array("*", $dd)) {
                        $result = false;
                    } elseif (false != in_array($ip, $dd)) {
                        $result = false;
                    }
                }
            }
            if (property_exists($this->config, "hosts_allowed_prod")) {
                $dd = $this->config->hosts_allowed_prod;
                if (null !== $dd) {
                    if (true == in_array("*", $dd) && $result) {
                        $result = true;
                    } elseif (true === in_array($ip, $dd) && false === $result) {
                        $result = true;
                    }
                }
            }
        }

        if (false === $result) {
            throw new Server403(new \ArrayObject(array("solution" =>
                "Add the current host to the allowed hosts list")));
        }

        return (true);
    }
1069537
private function isValidIpv6Hostname(string $host): bool
    {
        [$ipv6, $scope] = explode('%', $host, 2) + [1 => null];
        if (null === $scope) {
            return (bool) filter_var($ipv6, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);
        }

        $scope = rawurldecode('%'.$scope);

        return 1 !== preg_match(self::REGEXP_NON_ASCII_PATTERN, $scope)
            && 1 !== preg_match(self::REGEXP_GEN_DELIMS, $scope)
            && filter_var($ipv6, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)
            && 0 === strpos((string) inet_pton((string) $ipv6), self::ADDRESS_BLOCK);
    }
1298132
public function addHost($host)
    {
        if (!isset($this->hosts[$host])) {
            $this->hosts[$host] = $host;
        }

        return $this;
    }
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;
    }
371294
public function setHost($host)
  {
    if ($this->isLocked()) {
      return $this->getObj()->setHost($host)->setLocked();
    } else {
      return parent::setHost($host);
    }
  }
815735
public function setHost($host)
    {
        $this->host = $host;
        if (strpos($host, '/') !== false || strpos($host, '?') !== false) {
            if (strpos($host, 'http') === false) {
                $host = 'https://' . $host;
            }
            $url = parse_url($host);
            $this->host = $url['host'];

            if (isset($url['path'])) {
                $this->setPath($url['path']);
            }

            if (isset($url['query'])) {
                if (!isset($url['path'])) { // for example.org?query=string
                    $this->setPath('/');
                }
                $this->setQuery($url['query']);
            }
        }

        return $this;
    }
534053
public function setHost($host = null)
    {
        if ($host === null) {
            $host = '127.0.0.1';
        }

        if (substr($host, 0, 6) == 'ssl://') {
            $this->_protocol = 'ssl';
            $this->_secure = 'ssl';
            $host = substr($host, 6);
        }
        $this->_host = $host;
    }