检测域名的路由规则
@access protected
@return Domain
548030
protected function checkDomain()
    {
        // 获取当前子域名
        $subDomain = $this->getSubDomain();

        $item = false;

        if ($subDomain && count($this->domains) > 1) {
            $domain = explode('.', $subDomain);
            $domain2 = array_pop($domain);

            if ($domain) {
                // 存在三级域名
                $domain3 = array_pop($domain);
            }

            if ($subDomain && isset($this->domains[$subDomain])) {
                // 子域名配置
                $item = $this->domains[$subDomain];
            } elseif (isset($this->domains['*.' . $domain2]) && !empty($domain3)) {
                // 泛三级域名
                $item = $this->domains['*.' . $domain2];
                $panDomain = $domain3;
            } elseif (isset($this->domains['*']) && !empty($domain2)) {
                // 泛二级域名
                if ('www' != $domain2) {
                    $item = $this->domains['*'];
                    $panDomain = $domain2;
                }
            }

            if (isset($panDomain)) {
                // 保存当前泛域名
                $this->request->setPanDomain($panDomain);
            }
        }

        if (false === $item) {
            // 检测当前完整域名
            $item = $this->domains[$this->host];
        }

        if (is_string($item)) {
            $item = $this->domains[$item];
        }

        return $item;
    }
31019
public function getHostName()
    {
        $remoteAddress = $this->server()->remoteAddress();

        $host = $this->server()->serverName();
        $fwdHost = $this->server()->get($this->getTrustedHeaders()['client_host']);
        if ($fwdHost && $fwdHost != '' && in_array($remoteAddress, $this->getTrustedProxies())) {
            $host = $fwdHost;
        }

        return strtolower($host);
    }
1075163
public function getSubstitutedDomain()
    {
        $currentHost = $_SERVER['HTTP_HOST'];

        // If there are wildcards in the primary domain (not recommended), make some
        // educated guesses about what to replace them with:
        $domain = preg_replace('/\.\*$/', ".{$currentHost}", $this->Domain);

        // Default to "subsite." prefix for first wildcard
        // TODO Whats the significance of "subsite" in this context?!
        $domain = preg_replace('/^\*\./', "subsite.", $domain);

        // *Only* removes "intermediate" subdomains, so 'subdomain.www.domain.com' becomes 'subdomain.domain.com'
        $domain = str_replace('.www.', '.', $domain);

        return $domain;
    }
1225911
public function domain($tldLength = 1)
    {
        $segments = explode('.', $this->host());
        $domain = array_slice($segments, -1 * ($tldLength + 1));

        return implode('.', $domain);
    }
216221
public function getName()
    {
        $name = '';

        switch ($this->_clientId)
        {
            case Bootstrapper::SITE:
                $name = 'site';
                break;
            case Bootstrapper::ADMIN:
                $name = 'administrator';
                break;
            default:
                $name = 'cli';
                break;
        }

        return $name;
    }
1035853
protected static function domainWord()
    {
        $words = explode(' ', Company::name());
        shuffle($words);

        return strtolower(preg_replace('/\W/', '', current($words)));
    }
1211425
protected function checkDomain()
    {
        if ($this->domain === null) {
            return true;
        }

        if (self::$cachehost !== null) {
            $host = self::$cachehost;
        } else {
            $fhost = Request::header('Host');
            $host = strstr($fhost, ':', true);
            $host = $host ? $host : $fhost;

            self::$cachehost = $host;
        }

        if ($host === $this->domain) {
            return true;
        } elseif ($host) {
            $re = Regex::parse($this->domain);

            if ($re === false || preg_match('#^' . $re . '$#', $host, $matches) === 0) {
                return false;
            }

            array_shift($matches);

            $this->arguments = array_merge($this->arguments, $matches);

            return true;
        }

        return false;
    }
1162292
protected function getDomains() {
        if (!$this->_domains) {
            $this->_domains = new DomainList($this->version, $this->solution['accountSid']);
        }

        return $this->_domains;
    }
34373
public function getBind($domain = null)
    {
        if (is_null($domain)) {
            $domain = $this->domain;
        } elseif (true === $domain) {
            return $this->bind;
        } elseif (false === strpos($domain, '.')) {
            $domain .= '.' . $this->request->rootDomain();
        }

        $subDomain = $this->getSubDomain();

        if (strpos($subDomain, '.')) {
            $name = '*' . strstr($subDomain, '.');
        }

        if (isset($this->bind[$domain])) {
            $result = $this->bind[$domain];
        } elseif (isset($name) && isset($this->bind[$name])) {
            $result = $this->bind[$name];
        } elseif (isset($this->bind['*'])) {
            $result = $this->bind['*'];
        } else {
            $result = null;
        }

        return $result;
    }
144085
public function getURL() {
		return $this->scheme.'://'.$this->domain.$this->path.($this->parameters ? '?'.http_build_query($this->parameters) : '');
	}
711327
public static function fullServerName()
    {
        //$protocol = ($_SERVER['SERVER_PORT'] == '443') ? 'https://' : 'http://';
        $protocol = $_SERVER['REQUEST_SCHEME'] . '://';

        if ( isset($_SERVER['HTTP_X_FORWARDED_SERVER']) ) {
            $host = $_SERVER['HTTP_X_FORWARDED_SERVER'];
        } else {
            $host = $_SERVER['SERVER_NAME'] ?? '';
        }

        $port = ($_SERVER['SERVER_PORT'] == 80) ? '' : ":{$_SERVER['SERVER_PORT']}";

        return $protocol . $host . $port;
    }
1339730
public function getDomainName(): string
    {
        return $this->myDomainParts[count($this->myDomainParts) - 1] . ($this->myTld !== null ? '.' . $this->myTld : '');
    }
1356296
public function domain($domain = null) {

		if(null !== $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);
			}

			//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);	
			}

			$this -> domain = $domain;
		}

		return $this;
	}
403831
public function urlParam() {
        $a_url = array(
            'Domain' => $this->protocol . '://' . $this->host . '/domain', //域名
            'RecordType' => $this->protocol . '://' . $this->host . '/type', //记录类型
            'Line' => $this->protocol . '://' . $this->host . '/line', //线路
            'Host' => $this->protocol . '://' . $this->host . '/host', //主机记录
            'Record' => $this->protocol . '://' . $this->host . '/record', //解析记录
            'Statistics' => $this->protocol . '://' . $this->host . '/domain_stat', //解析量统计
            'Ns' => $this->protocol . '://' . $this->host . '/ns_server'  ,        //NS服务器
            'Ddns' => $this->protocol . '://' . $this->host . '/ddns'          //DDNS
        );
        $type = $this->apiType;

        return $a_url[$type];
    }
299408
public function getDomains()
    {
        $res = $this->doRequest('GET_DOMAINS');
        if (!$res) {
            return false;
        }

        $domains = array();

        for ($i = 1; $i <= $res['domains']; ++$i) {
            $dom = 'domain'.$i;
            $classes = array();

            // Associate classes to current domain (class name => mindevcount)
            for ($j = 1; $j <= $res[$dom.'classes']; ++$j) {
                $classes[$res[$dom.'class'.$j.'name']] = $res[$dom.'class'.$j.'mindevcount'];
            }

            $domains[] = array('name' => $res[$dom], 'classes' => $classes);
        }

        return $domains;
    }
325996
public function domainAdd($domain = '') {
        $arr = array("domain" => $domain);
        //设置参数体
        $this->setData(json_encode($arr));
        //设置请求的方法
        $this->setMethod('POST');
        //初始化参数
        $this->initParam();
        //获取返回值
        return $this->response();
    }
772617
protected function getBaseDomain() {
    // The base domain is stored in the metadata cookie if not we fallback
    // to the current hostname
    $metadata = $this->getMetadataCookie();
    if (array_key_exists('base_domain', $metadata) &&
        !empty($metadata['base_domain'])) {
      return trim($metadata['base_domain'], '.');
    }
    return $this->getHttpHost();
  }