获取请求地址

@access public
@return string
766136
public function _uri() {
        //处理requestUri
        $requestUri = '/';

        if (isset($_SERVER['HTTP_X_REWRITE_URL'])) { // check this first so IIS will catch
            $requestUri = $_SERVER['HTTP_X_REWRITE_URL'];
        }
        elseif (
            // IIS7 with URL Rewrite: make sure we get the unencoded url (double slash problem)
            isset($_SERVER['IIS_WasUrlRewritten'])
            && $_SERVER['IIS_WasUrlRewritten'] == '1'
            && isset($_SERVER['UNENCODED_URL'])
            && $_SERVER['UNENCODED_URL'] != ''
        ) {
            $requestUri = $_SERVER['UNENCODED_URL'];
        }
        elseif (isset($_SERVER['REQUEST_URI'])) {
            $requestUri = $_SERVER['REQUEST_URI'];
            $parts = @parse_url($requestUri);

            if (isset($_SERVER['HTTP_HOST']) && strstr($requestUri, $_SERVER['HTTP_HOST'])) {
                if (false !== $parts) {
                    $requestUri = (empty($parts['path']) ? '' : $parts['path'])
                        . ((empty($parts['query'])) ? '' : '?' . $parts['query']);
                }
            }
            elseif (!empty($_SERVER['QUERY_STRING']) && empty($parts['query'])) {
                // fix query missing
                $requestUri .= '?' . $_SERVER['QUERY_STRING'];
            }
        }
        elseif (isset($_SERVER['ORIG_PATH_INFO'])) { // IIS 5.0, PHP as CGI
            $requestUri = $_SERVER['ORIG_PATH_INFO'];
            if (!empty($_SERVER['QUERY_STRING'])) {
                $requestUri .= '?' . $_SERVER['QUERY_STRING'];
            }
        }

        return $requestUri;
    }
457708
protected static function getRequestUrl()
    {
        $hostname = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null);

        if(isset($hostname))
        {
            $protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';

            if(!isset($_SERVER['REQUEST_URI']))
            {
                if(isset($_SERVER['QUERY_STRING']))
                {
                    return $protocol . '://' . $hostname . $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'];
                }
                else
                {
                    return $protocol . '://' . $hostname . $_SERVER['PHP_SELF'];
                }
            }
            else
            {
                return $protocol . '://' . $hostname . $_SERVER['REQUEST_URI'];
            }
        }
        else
        {
            return null;
        }
    }
697813
private function getUrl() {
        $url = getSourceUrl($_SERVER['REQUEST_URI']);
        //移除page参数
        $urlInfo = parse_url($url);
        if ( $urlInfo['query'] ) {
            parse_str($urlInfo['query'], $query);
            unset($query['page']);
            if ( !empty($query) ) {
                foreach ( $query as $key => $value ) {
                    $query[$key] = urldecode($value);
                }
                $url = $urlInfo['path'].'?'.http_build_query($query);
            } else {
                $url = $urlInfo['path'];
            }

        }
        //判断是否还有其他参数
        $position = strpos($url, '?');
        if ( strpos($url, '?') === false ) {
            return $url.'?page=';
        } else if( ($position + 1) == strlen($url) ) {
            return $url.'page=';
        } else {
            return $url.'&page=';
        }
    }
79823
public function route() {
        static $alias = false;
        $response = Response::getInstance();
        $uri      = self::getURI();
        if ($uri == '/' || !$uri) {
            $uri = '/index.html';
        }
        //解析url
        $this->urlParams  = [];
        $this->requestURI = parse_url($uri, PHP_URL_PATH);
        //从原生的URL中解析出参数
        $query = @parse_url($uri, PHP_URL_QUERY);
        $args  = [];
        if ($query) {
            parse_str($query, $args);
            $this->xssCleaner->xss_clean($args);
        }
        $this->queryParams = $args;
        $url               = apply_filter('router\parse_url', trim($this->requestURI, '/'));
        if (!$url) {
            $url = 'index.html';
        }
        //URL转换处理
        $url              = $this->transform($url);
        $this->requestURL = $url;
        if (defined('ALIAS_ENABLED') && ALIAS_ENABLED) {
            if ($alias === false) {
                $aliasFile = MODULES_PATH . 'alias.php';
                if (is_file($aliasFile)) {
                    $alias = (array)include $aliasFile;
                } else {
                    $alias = [];
                }
            }
            if ($url && isset($alias[ $url ]) && $alias[ $url ]) {
                $url = $alias[ $url ];
            }
        }
        fire('router\beforeDispatch', $this, $url);
        //预处理
        $view = null;
        foreach ($this->preDispatchers as $dispatchers) {
            foreach ($dispatchers as $d) {
                if ($d instanceof IURLPreDispatcher) {
                    $view = $d->preDispatch($url, $this, $view);
                }
            }
        }
        if ($view) {
            $response->output($view);
        } else {
            // 真正分发
            $this->urlParsedInfo = new UrlParsedInfo ($uri, $url, $args);
            foreach ($this->dispatchers as $dispatchers) {
                foreach ($dispatchers as $d) {
                    if ($d instanceof IURLDispatcher) {
                        $view = $d->dispatch($url, $this, $this->urlParsedInfo);
                        if (is_array($view) || $view) {
                            break;
                        }
                        $this->urlParsedInfo->reset();
                    }
                }
                if (is_array($view) || $view) {
                    break;
                }
            }

            foreach ($this->postDispatchers as $dispatchers) {
                foreach ($dispatchers as $d) {
                    if ($d instanceof IURLPostDispatcher) {
                        $view = $d->postDispatch($url, $this, $view);
                    }
                }
            }
            if (is_array($view) || $view) {
                $response->output($view);
            } else if (PHP_SAPI == 'cli-server' && is_file(WWWROOT . ltrim($this->requestURI, '/'))) {
                while (@ob_get_level()) {
                    @ob_end_clean();
                }

                return false;
            } else if (defined('DEBUG') && DEBUG < DEBUG_ERROR) {
                throw new \Exception(__('no route for %s', $uri));
            } else {
                Response::respond(404);
            }
        }
        $response->close(false);

        return true;
    }
705903
public function toString ()
	{
		$content = "<VirtualHost {$this->address}:{$this->port}>" . PHP_EOL;
		
		foreach ($this->directives as $directive) {
			$content .= $directive->toString() . PHP_EOL;
		}
		
		$content .= PHP_EOL;
		
		foreach ($this->directories as $directory) {
			$content .= $directory->toString() . PHP_EOL;
		}
		$content .= PHP_EOL;
		
		$content .= "</VirtualHost>";
		
		return $content;
	}
603938
public function parseURL() {

        $appConfigs = getConfigs(); //获取app配置

        self::$urlMappingRules = $appConfigs['url_mapping_rules'];
        //优先处理短链接映射
        $this->requestUri = self::url2source($this->requestUri);
        $_SERVER['REQUEST_URI'] = $this->requestUri;

        $defaultUrl = $appConfigs['default_url'];
        $urlInfo = parse_url($this->requestUri);

        if ( $urlInfo['path'] && $urlInfo['path'] != '/' ) {
            $filename = str_replace(EXT_URI, '', $urlInfo['path']);
            $filename = rtrim($filename, "/");
            $pathInfo = explode('/', $filename);
            array_shift($pathInfo);
            if ( $pathInfo[0] ) $this->setModule($pathInfo[0]);
            if ( $pathInfo[1] ) $this->setAction($pathInfo[1]);
            if ( $pathInfo[2] ) $this->setMethod($pathInfo[2]);

            //提取pathinfo参数
            if ( count($pathInfo) > 3 ) {
                if ( isset($pathInfo[3]) ) {
                    $params = explode('-', $pathInfo[3]);
                    for ( $i = 0; $i < count($params); $i++ ) {
                        if ( $i % 2 == 0 ) {
                            if ( trim($params[$i]) == '' ) {
                                continue;
                            }
                            $_GET[$params[$i]] = $params[$i+1];
                        }
                    }
                }
            }

            //提取query参数
            if ( isset($urlInfo['query']) ) {
                $params = explode('&', $urlInfo['query']);
                foreach ( $params as $values ) {
                    $__p = explode('=', $values);
                    if ( trim($__p[0]) == '' ) {
                        continue;
                    }
                    $_GET[$__p[0]] = urldecode($__p[1]);
                }
            }

        }

        //如果没有任何参数，则访问默认页面。如http://www.herosphp.my这种格式
        if ( !$this->module ) $this->setModule($defaultUrl['module']);
        if ( !$this->action ) $this->setAction($defaultUrl['action']);
        if ( !$this->method ) $this->setMethod($defaultUrl['method']);

        $this->setParameters($_GET + $_POST);

        //die();
    }
713250
public function ip()
	{
		if( is_null($this->ip_address) )
		{
			$remote = isset( $this->server["REMOTE_ADDR"] );

			if( $remote && isset( $this->server["HTTP_CLIENT_IP"] ) )
			{
				$this->ip_address = $this->server["HTTP_CLIENT_IP"];
			}
			else if( $remote )
			{
				$this->ip_address = $_SERVER["REMOTE_ADDR"];
			}
			else if ( isset( $this->server["HTTP_CLIENT_IP"] ) )
			{
				$this->ip_address = $this->server["HTTP_CLIENT_IP"];
			}
			else if( isset( $this->server["HTTP_X_FORWARDED_FOR"] ) )
			{
				$this->ip_address = $this->server["HTTP_X_FORWARDED_FOR"];
			}
			else
			{
				$this->ip_address = "0.0.0.0";
			}

			if( strpos( $this->ip_address, ',' ) !== false )
			{
				$this->ip_address = end( explode( ',', $this->ip_address ) );
			}

			if( ! $this->ip_address )
			{
				$this->ip_address = "0.0.0.0";
			}
		}

		return $this->ip_address;
	}
623192
public function getUrl()
    {
        if (!$this->isSortable()) {
            return '';
        }

        $params = ['sort_key' => $this->key];

        if ($this->isSortKey()) {
            $params['sort_order'] = $this->request->input('sort_order') == 'desc' ? 'asc' : 'desc';
        }

        return '?'.http_build_query($params + $this->request->all());
    }
77520
public static function getURI()
    {
        $s = $_SERVER;
        $ssl = (!empty($s['HTTPS']) && $s['HTTPS'] == 'on');
        $sp = strtolower(array_get($s, 'SERVER_PROTOCOL', 'http://'));
        $protocol = substr($sp, 0, strpos($sp, '/')) . (($ssl) ? 's' : '');
        $port = array_get($s, 'SERVER_PORT', '80');
        $port = ((!$ssl && $port == '80') || ($ssl && $port == '443')) ? '' : ':' . $port;
        $host = (isset($s['HTTP_HOST']) ? $s['HTTP_HOST'] : array_get($s, 'SERVER_NAME', 'localhost'));
        $host = (strpos($host, ':') !== false) ? $host : $host . $port;

        return $protocol . '://' . $host;
    }
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];
    }
1307299
private static function getRootUrl(){
    	// Returns TAO ROOT url based on a call to the API.
    	$isHTTPS = common_http_Request::isHttps();
    	$host = $_SERVER['HTTP_HOST'];
    	$uri = $_SERVER['REQUEST_URI'];
    	$currentUrl = ($isHTTPS ? 'https' : 'http' ). '://' . $host . $uri;
    	$parsed = parse_url($currentUrl);
    	$port = (empty($parsed['port'])) ? '' : ':' . $parsed['port'];
    	$rootUrl = $parsed['scheme'] . '://' . $parsed['host'] . $port . $parsed['path'];
    	return str_replace('/tao/install/api.php', '', $rootUrl);
    }
22364
protected static function getBaseUrl()
  {
    $baseUrl = 'https://';
    if (!self::$ssl) {
      $baseUrl = 'http://';
    }
    $baseUrl .= sprintf('%s:%s/%s/', self::$host, self::$port, self::$context);
    return $baseUrl;
  }
1309794
public function host()
    {
        if (Validation::ip($this->_config['host'])) {
            return gethostbyaddr($this->_config['host']);
        }

        return gethostbyaddr($this->address());
    }
755789
public static function getUriFromGlobals()
    {
        $uri = new Uri('');

        if (isset($_SERVER['HTTPS'])) {
            $uri = $uri->withScheme($_SERVER['HTTPS'] == 'on' ? 'https' : 'http');
        }

        if (isset($_SERVER['HTTP_HOST'])) {
            $uri = $uri->withHost($_SERVER['HTTP_HOST']);
        } elseif (isset($_SERVER['SERVER_NAME'])) {
            $uri = $uri->withHost($_SERVER['SERVER_NAME']);
        }

        if (isset($_SERVER['SERVER_PORT'])) {
            $uri = $uri->withPort($_SERVER['SERVER_PORT']);
        }

        if (isset($_SERVER['REQUEST_URI'])) {
            $uri = $uri->withPath(current(explode('?', $_SERVER['REQUEST_URI'])));
        }

        if (isset($_SERVER['QUERY_STRING'])) {
            $uri = $uri->withQuery($_SERVER['QUERY_STRING']);
        }

        return $uri;
    }
990578
public function baseUrl()
    {
        if (!$this->baseUrl) {
            $this->baseUrl = $this->request->getScheme()
                . '://' . $this->request->getHttpHost();
        }
        return $this->baseUrl;
    }
922315
protected function getWhere()
    {
        // 删除条件
        $pk = $this->getPk();

        if (is_string($pk) && isset($this->data[$pk])) {
            $where[] = [$pk, '=', $this->data[$pk]];
        } elseif (!empty($this->updateWhere)) {
            $where = $this->updateWhere;
        } else {
            $where = null;
        }

        return $where;
    }
1198839
public static function getHost()
    {
        $host = '';
        if (isset($_SERVER['HTTP_X_FORWARDED_HOST']) && $host = $_SERVER['HTTP_X_FORWARDED_HOST']) {
            $elements = explode(',', $host);
            $host     = trim(end($elements));
        } else {
            if (isset($_SERVER['HTTP_HOST']) && !$host = $_SERVER['HTTP_HOST']) {
                if (isset($_SERVER['SERVER_NAME']) && !$host = $_SERVER['SERVER_NAME']) {
                    $host = !empty($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '';
                }
            }
        }
        // Remove port number from host
        $host = preg_replace('/:\d+$/', '', $host);

        return trim($host);
    }