获取上一页的链接地址
@param  int    $curpage       当前页码
@param  string $url           当前链接地址
@return string 链接地址
554066
public function getNextUrl($curpage, $url)
    {
        if ($curpage == $this->totalpage) {
            return 'javascript:;';
        }
        $pagenum = min($this->totalpage, $curpage + 1);
        return $url . $pagenum;
    }
902705
public static Page getPage(TagSupport tag, PageContext context,
			String strPage, int iLevel) {
		Page page = null;

		SiteContext sc = (SiteContext) context.getRequest().getAttribute(
				SiteContext.SITE_CONTEXT_KEY);
		AuthorizationEngine ap = ContextUtils
				.getAuthorizationEngine((HttpServletRequest) context
						.getRequest());

		if (strPage != null) {
			if (strPage.equals("AE_ROOT"))
				page = sc.getBranch().getHome(ap);
			else if (strPage.equals("AE_CURRENT"))
				page = sc.getPage();
			else
				page = (Page) context.getAttribute(strPage);
		} else if (iLevel >= 0) {
			Page currentInTree = sc.getPage();
			if (iLevel <= currentInTree.getLevel()) {
				page = currentInTree;
				while (iLevel < page.getLevel())
					page = page.getParent();
			}
		} else {
			TreeTag tt = (TreeTag) TagSupport.findAncestorWithClass(tag,
					TreeTag.class);
			if (tt != null)
				page = tt.getPage();
			else {
				PathTag pt = (PathTag) TagSupport.findAncestorWithClass(tag,
						PathTag.class);
				if (pt != null)
					page = pt.getPage();
			}
		}

		if (page == null)
			page = sc.getPage();

		return page;
	}
102637
static function  parseRelativePath($current, $url)
    {
        //非HTTP开头的，相对路径
        if (substr($url, 0, 7) !== 'http://' and substr($url, 0, 8) !== 'https://' )
        {
            //以/开头的
            if ($url[0] == '/')
            {
                $_u = parse_url($current);
                return $_u['scheme'].'://'.$_u['host'].$url;
            }
            else
            {
                $n = strrpos($current, '/');
                return substr($current, 0, $n + 1).$url;
            }
        }
        else
        {
            return $url;
        }
    }
658743
function ParseUrl($url) {
	    $content = null;

    	$this->Clear();

		$this->url = htmlspecialchars_decode($url);

	    ob_start();
	    if (function_exists('curl_init')) {
		    //curl is the preferred function
		    $crl = curl_init();
		    curl_setopt($crl, CURLOPT_URL, $url);
		    curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1);
		    curl_setopt($crl, CURLOPT_CONNECTTIMEOUT, 5);
		    curl_setopt($crl, CURLOPT_TIMEOUT, 20);
		    $FileData = curl_exec($crl);
		    $FileInfo = curl_getinfo($crl);
		    curl_close($crl);
		    if ($FileInfo['http_code'] != 200) {
			    throw new \HttpRequestException($FileInfo['http_code'] . ' error for file: ' . $url);
		    }
	    } else {
		    //see if we can use fopen to get file
		    $fopen_check = ini_get('allow_url_fopen');
		    if (!empty($fopen_check)) {
			    $content = file_get_contents($url);
		    } else {
			    throw new \RuntimeException('CURL_DISABLED');
		    }
	    }
	    ob_end_clean();

		if(strlen($content)) {
			$this->modifyContent($content);
			$this->ParseStr($content);
			return true;
		} else {
			return false;
		}
	}
624209
static function GatherParams($url)
    {
        $reader = new StringReader($url);
        $param = '';
        $params = array();
        $start = false;
        while (false !== ($ch = $reader->ReadChar())) {
            if ($ch == '{') {
                $start = true;
            }
            else if ($ch == '}' && $start) {
                $params[] = $param;
                $param = '';
                $start = false;
            }
            else if ($start) {
                $param .= $ch;
            }
        }
        return $params;
    }
23190
protected function _getCurlInitialization($url)
  {
    $connection = $this->_curl_init($url);

    $this->_curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
    $this->_curl_setopt($connection, CURLOPT_FOLLOWLOCATION, 0);
    $this->_curl_setopt($connection, CURLOPT_HEADER, 1);
    $this->_curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, 1);
    $this->_curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, 2);
    $this->_curl_setopt($connection, CURLOPT_CAINFO, __DIR__ . '/cacert.pem');
    $this->_curl_setopt(
      $connection, CURLOPT_USERAGENT,
      'codebird-php/' . $this->getVersion() . ' +https://github.com/jublonet/codebird-php'
    );

    if ($this->_hasProxy()) {
      $this->_curl_setopt($connection, CURLOPT_PROXYTYPE, $this->_getProxyType());
      $this->_curl_setopt($connection, CURLOPT_PROXY, $this->_getProxyHost());
      $this->_curl_setopt($connection, CURLOPT_PROXYPORT, $this->_getProxyPort());

      if ($this->_getProxyAuthentication()) {
        $this->_curl_setopt($connection, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
        $this->_curl_setopt($connection, CURLOPT_PROXYUSERPWD, $this->_getProxyAuthentication());
      }
    }

    return $connection;
  }
409080
public static function resolve_url($url)
    {
        // prepend protocol://hostname:port
        if (!preg_match('|^https?://|', $url)) {
            $schema       = 'http';
            $default_port = 80;

            if (self::https_check()) {
                $schema       = 'https';
                $default_port = 443;
            }

            $prefix = $schema . '://' . preg_replace('/:\d+$/', '', $_SERVER['HTTP_HOST']);
            if ($_SERVER['SERVER_PORT'] != $default_port) {
                $prefix .= ':' . $_SERVER['SERVER_PORT'];
            }

            $url = $prefix . ($url[0] == '/' ? '' : '/') . $url;
        }

        return $url;
    }
996828
public function wechatURL($url = '') {
        $weixin = array('system', 'wechat');
        $string = trim($_SERVER['REQUEST_URI'], "/");
        #判断是否是微信链接-内部跳转链接
        if (strstr($string, md5('wechat') . "_wechat")) {
            $weixin[] = 'userAuthorization';
            #获取自定义数据 4910_wechat/type/get/callback/-1?code=
            #为了获取URL地址中间4910_wechat到？之间的数据为自定义参数
            $wechat = md5('wechat') . "_wechat";
            $str    = strlen($wechat);
            $len    = strrpos($string, '?');
            $num    = $len - $str;
            $new    = trim(substr($string, $str, $num), '/');
            $weixin = array_merge($weixin, explode("/", $new));
            #格式化数据
            $pieces = explode("?", $string);
            parse_str($pieces[1], $array);
            foreach ($array as $key => $value) {
                $weixin[] = $key;
                $weixin[] = $value;
            }
            return $weixin;
        }
        #第三方-授权事件接收URL  md5("Wechat Third-party) . "_wechat"; //事件回调
        elseif (strstr($string, md5('Wechat Third-party callback') . "_wechat")) {
            #thirdPartiesMessages
            $weixin[] = 'thirdPartiesMessages';
            $pieces   = explode("?", $string);
            if (isset($pieces[1]) && !empty($pieces[1])) {
                parse_str($pieces[1], $array);
                foreach ($array as $key => $value) {
                    $weixin[] = $key;
                    $weixin[] = $value;
                }
            }
            return $weixin;
        }
        #第三方-授权事件回调地址
        elseif (strstr($string, md5('Wechat authorization callback') . "_wechat")) {
            $weixin[] = 'thirdAuthorizeCallback';
            $wechat   = md5('Wechat Third-party callback') . "_wechat";
            #获取中间跳转地址
            $str    = strlen($wechat);
            $len    = strrpos($string, '?');
            $num    = $len - $str;
            $new    = trim(substr($string, $str, $num), '/');
            $weixin = array_merge($weixin, explode("/", $new));
            #格式化数据
            $pieces = explode("?", $string);
            if (isset($pieces[1]) && !empty($pieces[1])) {
                parse_str($pieces[1], $array);
                foreach ($array as $key => $value) {
                    $weixin[] = $key;
                    $weixin[] = $value;
                }
            }
            return $weixin;
        }
        #第三方-消息与事件接收URL
        elseif (strstr($string, md5('Wechat callback') . "_wechat")) {
            $weixin[] = 'thirdCallback';
            $wechat   = md5('Wechat callback') . "_wechat";
            #获取中间跳转地址
            $str    = strlen($wechat);
            $len    = strrpos($string, '?');
            $num    = $len - $str;
            $new    = trim(substr($string, $str, $num), '/');
            $weixin = array_merge($weixin, explode("/", $new));
            #格式化数据
            $pieces = explode("?", $string);
            if (isset($pieces[1]) && !empty($pieces[1])) {
                parse_str($pieces[1], $array);
                foreach ($array as $key => $value) {
                    $weixin[] = $key;
                    $weixin[] = $value;
                }
            }
            return $weixin;
        } else {
            return $url;
        }

    }
717076
public static function parseUrl($url)
    {
        $parseUrlResult = parse_url($url);
        if ($parseUrlResult === false) {
            return false;
        }

        if (empty($parseUrlResult['scheme'])) {
            $parseUrlResult['scheme'] = 'http';
        }

        if (empty($parseUrlResult['host'])) {
            return false;
        }

        $parseUrlResult['url'] = $url;

        if (empty($parseUrlResult['port'])) {
            if ($parseUrlResult['scheme'] == 'http') {
                $parseUrlResult['port'] = 80;
                $parseUrlResult['ssl']  = false;
            } else {
                $parseUrlResult['port'] = 443;
                $parseUrlResult['ssl']  = true;
            }
        } else {
            if ($parseUrlResult['scheme'] == 'http') {
                $parseUrlResult['ssl']  = false;
            } else {
                $parseUrlResult['ssl']  = true;
            }
        }

        if (empty($parseUrlResult['path'])) {
            $parseUrlResult['path'] = '/';
        }

        if (empty($parseUrlResult['query'])) {
            $parseUrlResult['query'] = '';
        } else {
            $parseUrlResult['query'] = '?' . $parseUrlResult['query'];
        }

        return $parseUrlResult;
    }
513614
public function matchWhen($url = null)
    {
        if (null !== $url) {
            $this->setMatchUrl($url);
        }

        return strpos($this->getRequestedUrl(), $this->getMatchUrl()) === 0;
    }
1170937
private function processURL($url) {

        // Clean up special characters in url params
        $url = str_replace("%20", " ", $url);

        // Store a private copy for use later
        $this->url = URLHelper::$testURL == null ? $url : URLHelper::$testURL;

        // Split it on protocol first if required.
        if (substr($url, 0, 4) == "http") {
            $splitProtocol = explode("://", $url);
            $requestSection = sizeof($splitProtocol) > 1 ? $splitProtocol [1] : $splitProtocol [0];
            $requestSection = substr($requestSection, strpos($requestSection, "/"));
        } else {
            $requestSection = $url;
        }
        $this->requestURI = $requestSection;

        // Now split it on question mark for query if required.
        $splitQuestionMark = explode("?", $requestSection);
        $queryStripped = $splitQuestionMark [0];

        // Now ensure no trailing or leading slash.
        if (substr($queryStripped, 0, 1) == '/') $queryStripped = substr($queryStripped, 1);
        if (substr($queryStripped, strlen($queryStripped) - 1) == '/') $queryStripped = substr($queryStripped, 0, strlen($queryStripped) - 1);

        // Now simply set the segments array to be the split on "/"
        $this->segments = explode("/", $queryStripped);

    }
596959
protected function getProtocolLength($url)
    {
        if (substr_compare($url, 'http://', 0, 7, true) === 0) {
            return 7;
        }
        if (substr_compare($url, 'https://', 0, 8, true) === 0) {
            return 8;
        }
        if (substr_compare($url, '//', 0, 2, false) === 0) {
            return 2;
        }

        return null;
    }
1124720
private function wrapUrl($url)
    {
        if ($this->balancer) {
            $url = sprintf('%s?url=%s', $this->balancer, urlencode($url));
        }

        $this->lastUrl = $url;

        return $url;
    }
1066746
public static function urlToPath($url)
    {
        $path = str_replace('http://', '', $url);
        $path = str_replace('https://', '', $path);
        $path = str_replace($_SERVER['HTTP_HOST'], '', $path);

        if (substr($path, 0, 1) == '/') {
            $path = substr($path, 1);
        }

        return $_SERVER['DOCUMENT_ROOT'] . '/' . $path;
    }
1297440
public function get($url, $sloppy304=false) 
    {
        if(!$this->sendRequest($url)) {
            return false;
        }
        
        if($this->rspStatus == 304 && $sloppy304) {
            return $this->rspBody;
        }
        
        if($this->rspStatus != 200) {
            return false;
        }
        
        return $this->rspBody;
    }
1227713
public function purgeUrl ($url = null)
    {
        $apiKey = $this->settings->apiKey;

        Craft::trace(
            Craft::t(
                'imgix',
                'Purging asset: {url}', [ 'url' => $url ]
            ),
            'imgix');

        try {
            $client = Craft::createGuzzleClient([ 'timeout' => 30, 'connect_timeout' => 30 ]);

            $response = $client->post(self::IMGIX_PURGE_ENDPOINT, [
                'auth'        => [
                    $apiKey, ''
                ],
                'form_params' => [
                    'url' => $url,
                ]
            ]);

            Craft::trace(
                Craft::t(
                    'imgix',
                    'Purged asset: {url} - Status code {statusCode}', [
                        'url'        => $url,
                        'statusCode' => $response->getStatusCode()
                    ]
                ),
                'imgix');

            return $response->getStatusCode() >= 200 && $response->getStatusCode() < 400;
        }
        catch (RequestException $e) {
            Craft::error(
                Craft::t(
                    'imgix',
                    'Failed to purge {url}: {statusCode} {error}', [
                        'url'        => $url,
                        'error'      => $e->getMessage(),
                        'statusCode' => $e->getResponse()->getStatusCode() ]
                ),
                'imgix'
            );

            return false;
        }
    }
735140
private function urlGen($url)
    {
        if (empty($url) && empty($this->url)) {
            throw new \Exception("URL not set!", 1);
        }
        return empty($url) ? $this->url : $url;
    }