Checks domain availability.

@param string $domain
765345
public function check($domain)
    {
        return $this->client
            ->query($domain)
            ->then(function ($result) use ($domain) {
                return Factory::create($domain, $result)->isAvailable();
            });
    }
1149952
protected function addPortToDomain($domain)
    {
        if (in_array($this->request->getPort(), array('80', '443'))) {
            return $domain;
        }

        return $domain .':' .$this->request->getPort();
    }
385542
public function matchesDomain($domain)
    {
        // Remove the leading '.' as per spec in RFC 6265: http://tools.ietf.org/html/rfc6265#section-5.2.3
        $cookieDomain = ltrim($this->getDomain(), '.');

        // Domain not set or exact match.
        if (!$cookieDomain || !strcasecmp($domain, $cookieDomain)) {
            return true;
        }

        // Matching the subdomain according to RFC 6265: http://tools.ietf.org/html/rfc6265#section-5.1.3
        if (filter_var($domain, FILTER_VALIDATE_IP)) {
            return false;
        }

        return (bool) preg_match('/\.' . preg_quote($cookieDomain, '/') . '$/i', $domain);
    }
170261
public function setDomain(string $domain = '', bool $forSubdomains = true): void
    {
        $subdomainIndicator = $forSubdomains === true ? '.' : '';
        $this->domain = \sprintf('%s%s', $subdomainIndicator, \preg_replace('/^(\.)?(preview\.)?/', '', $domain));
    }
780839
protected function tryGuessScheme(?string $domain) : ?string
    {
        if ($domain !== null) {
            if (Str::startsWith($domain, 'https')) {
                return 'https://';
            }

            if (Str::startsWith($domain, 'http')) {
                return 'http://';
            }
        }

        return (isset($_SERVER['HTTPS'])
            && !empty($_SERVER['HTTPS'])
            && strtolower($_SERVER['HTTPS']) !== 'off')
            ? 'https://' : 'http://';
    }
1276267
public function checkDomain()
    {
        // parent
        if ($this->group && ! $this->group->checkDomain())
            return false;

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

        $domain = empty($_SERVER['SERVER_NAME']) ? null : $_SERVER['SERVER_NAME'];
        if ($domain === null)
            return false;

        return $domain === $this->domain;
    }
571494
public function startSession($domain) {
        $this->cookieLocation = str_replace('APP_ROOT', APP_ROOT, $this->cookieLocation);
        if (!is_dir($this->cookieLocation))
            mkdir($this->cookieLocation);
        if (!is_dir($this->cookieLocation)) {
            $this->error($this->error = "Can't create folder {$this->cookieLocation}");
        }
        $this->currentFile = $this->cookieLocation . date('YmdHis') . '-' . md5($domain);
        fclose(fopen($this->currentFile, 'w'));
    }
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;
    }
300649
public function lookupDomain($domain)
    {
        $serverObj = new Server();
        $server = $serverObj->getServerByTld($this->tld);
        if (!$server) {
            throw new Exception("Error: No appropriate Whois server found for $domain domain!");
        }
        $result = $this->queryServer($server, $domain);
        if (!$result) {
            throw new Exception("Error: No results retrieved from $server server for $domain domain!");
        } else {
            while (strpos($result, "Whois Server:") !== false) {
                preg_match("/Whois Server: (.*)/", $result, $matches);
                $secondary = $matches[1];
                if ($secondary) {
                    $result = $this->queryServer($secondary, $domain);
                    $server = $secondary;
                }
            }
        }
        return "$domain domain lookup results from $server server:\n\n" . $result;
    }
494357
public function domain($domain, $protocol = null) {

		if(false === is_string($domain)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($domain)), E_USER_ERROR);
		}

		//Check if identifier exists
		if(false === Router :: routeExists($this -> identifier, $domain)) {
			return trigger_error(sprintf('Identifier "%s" with domain "%s" does not exists', $this -> identifier, $domain), E_USER_ERROR);	
		}

		if(null !== $protocol && false === is_string($protocol)) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($protocol)), E_USER_ERROR);
		}

		if(null === $protocol) {
			$protocol = Request :: getScheme();
		}

		$this -> domain = sprintf('%s://%s', $protocol, $domain);

		return $this;
	}
895436
public function getIdByDomain($domain)
    {
        return $this->cache->get('appDomain' . $domain, 86400, function () use ($domain) {
            $app = wei()->appRecord()->select('name')->fetch(['domain' => $domain]);

            return $app ? $app['name'] : false;
        });
    }
326008
public function deleteDomainAction(Domain $domain)
    {
        $site = $domain->getSite();
        if ($site->getPrimaryDomain() === $domain) {
            $site->setPrimaryDomain(null);
            $this->siteRepository->update($site);
        }
        $this->domainRepository->remove($domain);
        $this->addFlashMessage('The domain "%s" has been deleted.', 'Domain deleted', Message::SEVERITY_OK, [htmlspecialchars($domain)], 1412373310);
        $this->unsetLastVisitedNodeAndRedirect('edit', null, null, ['site' => $site]);
    }
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);
    }
1202120
protected function getDnsRecord($domain)
    {
        if (filter_var($domain, FILTER_VALIDATE_URL) === false) {
            $this->eye->logger()->debug('DNS URL not valid', $domain);
            return false;
        }

        try {
            $dns = $this->pollDns($this->parseUrl($domain));
        } catch (Exception $e) {
            $this->eye->logger()->debug('DNS lookup failed', ['domain' => $domain,
                                                              'exception' => $e->getMessage()]);
            return false;
        }

        return $this->stripTtlFromDns($dns);
    }
103112
public function domain($domain = null)
    {
        deprecationWarning('Email::domain() is deprecated. Use Email::setDomain() or Email::getDomain() instead.');

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

        return $this->setDomain($domain);
    }
1110462
public function domainIndex(string $domain)
    {
        Assert::stringNotEmpty($domain);

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

        return $this->hydrateResponse($response, IndexResponse::class);
    }
1146885
public static function domainExists($domain) {

		if(false === is_string($domain)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($domain)), E_USER_ERROR);
		}

		$routes = static :: getRoutes();

		foreach($routes as $route) {

			$domains = $route -> getDomain();

			if(true === is_array($domains)) {

				foreach($domains as $url) {

					if(preg_match('#'. str_replace('#', '\#', $url) .'#', $domain) || $url === $domain) {
						return true;
					}
				}
			}
		}

		return false;
	}