Function to validate a domain, though this is not quite what
you expect of a strict internet domain.

domain = sub-domain *("." sub-domain)

@param string $domain The string to check.
@return mixed False on failure, or the validated domain on success.
339678
protected function _validateDomain($domain)
    {
        // Note the different use of $subdomains and $sub_domains
        $subdomains = explode('.', $domain);

        while (count($subdomains) > 0) {
            $sub_domains[] = $this->_splitCheck($subdomains, '.');
            for ($i = 0; $i < $this->index + 1; $i++)
                array_shift($subdomains);
        }

        foreach ($sub_domains as $sub_domain) {
            if (!$this->_validateSubdomain(trim($sub_domain)))
                return false;
        }

        // Managed to get here, so return input.
        return $domain;
    }
292860
public boolean matches(String domain) {
        if (pattern != null) {
            return pattern.matcher(domain).matches();
        }

        return this.domain.equals(domain);
    }
951800
public static function isExampleDomain(string $domain): bool
    {
        if (self::$domainsExample === null) {
            self::$domainsExample = self::getData('domainsExample');
        }

        if (\in_array($domain, self::$domainsExample, true)) {
            return true;
        }

        return false;
    }
80886
public function validate($input): bool
    {
        if (\is_string($input) && filter_var($input, FILTER_VALIDATE_EMAIL)) {
            [, $domain] = explode('@', $input, 2);
            if ($this->checkDns) {
                return checkdnsrr($domain, 'MX') || checkdnsrr($domain, 'A');
            }
            return true;
        }
        return false;
    }
847750
public function isValidDomain()
    {
        $domain = isset($_SERVER[ 'HTTP_HOST' ])
            ? $_SERVER[ 'HTTP_HOST' ]
            : $_SERVER[ 'SERVER_NAME' ];

        if ($this->domain === $domain) {
            return true;
        }

        return false;
    }
170261
public function setDomain(string $domain = '', bool $forSubdomains = true): void
    {
        $subdomainIndicator = $forSubdomains === true ? '.' : '';
        $this->domain = \sprintf('%s%s', $subdomainIndicator, \preg_replace('/^(\.)?(preview\.)?/', '', $domain));
    }
489383
public function isAuthority($domain): bool
    {
        foreach ($this->resolvers as $resolver) {
            if ($resolver->isAuthority($domain)) {
                return true;
            }
        }

        return false;
    }
1034852
public function getDomainInfo( $domain ) {
		$domain = $this->normalizeDomain( $domain );
		// Check cache and custom-registered domains
		if ( !isset( $this->domainInfos[ $domain ] ) ) {
			// Default to local domain
			$dir = $this->localBaseDir . '/language/messages/' . $domain;
			if ( !is_dir( $dir ) ) {
				// Domain does not exist
				return false;
			}
			$this->domainInfos[ $domain ] = [
				'dir' => $dir,
			];
		}
		return $this->domainInfos[ $domain ];
	}
52210
public function validationDomain($domain = null)
    {
        if ($domain === null) {
            return $this->_validationDomain;
        }
        $this->_validationDomain = $domain;
    }
1036595
public static function domainFromString($url)
    {
        $domain = parse_url($url, PHP_URL_HOST);
        if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs)) {
            return $regs['domain'];
        }
        return false;
    }
1004499
public function matchDomain($domain)
    {
        $host = $this->host;
        if (is_null($host)) {
            return false;
        }

        $match_domain = explode('.', $domain);
        $match_host = array_slice(explode('.', $host), count($match_domain) * -1);

        return (strcasecmp($domain, implode('.', $match_host)) === 0);
    }
664942
public function matchesDomain($domain)
    {
        if (!$this->_data['domain']) {
            return false;
        }

        $hostDomain = strtolower($domain);
        $cookieDomain = ltrim(strtolower($this->_data['domain']), '.');

        if (!$cookieDomain || !strcmp($domain, $cookieDomain)) {
            return true;
        }

        if (filter_var($hostDomain, FILTER_VALIDATE_IP)) {
            return false;
        }

        return (bool) preg_match('~\.' . preg_quote($cookieDomain) . '$~', $hostDomain);
    }
1325224
public function verify(string $domain)
    {
        Assert::stringNotEmpty($domain);

        $response = $this->httpPut(sprintf('/v3/domains/%s/verify', $domain));

        return $this->hydrateResponse($response, VerifyResponse::class);
    }
806710
protected function isValidDomain($domain)
    {
        if (filter_var($domain, FILTER_VALIDATE_URL) === false) {
            $this->eye->logger()->debug('SSL URL not valid', $domain);
            return false;
        }

        return true;
    }
562937
public static function isValidDomain($domain)
    {
        $valid = mb_strlen($domain, 'UTF-8') <= self::PHP_IDN_HANDLEABLE_LENGTH;

        if ($valid) {
            $result = idn_to_ascii(
                $domain,
                IDNA_USE_STD3_RULES | IDNA_NONTRANSITIONAL_TO_ASCII,
                INTL_IDNA_VARIANT_UTS46
            );

            if (!is_string($result)) {
                $valid = false;
            }
        }
        
        if ($valid) {
            $domainNameLength = strlen($result);
            if ($domainNameLength < 1 || $domainNameLength > 253) {
                $valid = false;
            }
        }
        
        if ($valid) {
            foreach (explode('.', $result) as $label) {
                $labelLength = strlen($label);
                if ($labelLength < 1 || $labelLength > 63) {
                    $valid = false;
                    break;
                }
            }
        }
        
        if ($valid) {
            $result = idn_to_utf8($result, IDNA_USE_STD3_RULES, INTL_IDNA_VARIANT_UTS46, $idna_info);
            if ($idna_info['errors'] !== 0) {
                $valid = false;
            }
        }
        
        return $valid;
    }
51088
protected function _validateSubdomain($subdomain)
    {
        if (preg_match('|^\[(.*)]$|', $subdomain, $arr)){
            if (!$this->_validateDliteral($arr[1])) return false;
        } else {
            if (!$this->_validateAtom($subdomain)) return false;
        }

        // Got here, so return successful.
        return true;
    }
1259675
public function isWildcardDomain(string $domain): bool
    {
        $domain = rtrim($domain, '.').'.';
        $pattern = '/^\*\.(?:[a-zA-Z0-9\-\_]+\.)*$/';

        return (bool) preg_match($pattern, $domain);
    }