当前位置: 首页>>代码示例>>PHP>>正文


PHP Typecho_Common::buildUrl方法代码示例

本文整理汇总了PHP中Typecho_Common::buildUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Typecho_Common::buildUrl方法的具体用法?PHP Typecho_Common::buildUrl怎么用?PHP Typecho_Common::buildUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Typecho_Common的用法示例。


在下文中一共展示了Typecho_Common::buildUrl方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getTokenUrl

 /**
  * 生成带token的路径
  *
  * @param $path
  * @return string
  */
 public function getTokenUrl($path)
 {
     $parts = parse_url($path);
     $params = array();
     if (!empty($parts['query'])) {
         parse_str($parts['query'], $params);
     }
     $params['_'] = $this->getToken($this->request->getRequestUrl());
     $parts['query'] = http_build_query($params);
     return Typecho_Common::buildUrl($parts);
 }
开发者ID:hongweipeng,项目名称:typecho,代码行数:17,代码来源:Security.php

示例2: send

 /**
  * 发送请求
  *
  * @access public
  * @param string $url 请求地址
  * @return string
  * @throws Typecho_Http_Client_Exception
  * @internal param string $rfc 请求协议
  */
 public function send($url)
 {
     $params = parse_url($url);
     if (!empty($params['host'])) {
         $this->host = $params['host'];
     } else {
         throw new Typecho_Http_Client_Exception('Unknown Host', 500);
     }
     if (!empty($params['path'])) {
         $this->path = $params['path'];
     }
     $query = empty($params['query']) ? '' : $params['query'];
     if (!empty($this->query)) {
         $query = empty($query) ? $this->query : '&' . $this->query;
     }
     if (!empty($query)) {
         $this->path .= '?' . $query;
         $params['query'] = $query;
     }
     $this->scheme = $params['scheme'];
     $this->port = 'https' == $params['scheme'] ? 443 : 80;
     $url = Typecho_Common::buildUrl($params);
     if (!empty($params['port'])) {
         $this->port = $params['port'];
     }
     /** 整理cookie */
     if (!empty($this->cookies)) {
         $this->setHeader('Cookie', str_replace('&', '; ', http_build_query($this->cookies)));
     }
     $response = $this->httpSend($url);
     if (!$response) {
         return;
     }
     str_replace("\r", '', $response);
     $rows = explode("\n", $response);
     $foundStatus = false;
     $foundInfo = false;
     $lines = array();
     foreach ($rows as $key => $line) {
         if (!$foundStatus) {
             if (0 === strpos($line, "HTTP/")) {
                 if ('' == trim($rows[$key + 1])) {
                     continue;
                 } else {
                     $status = explode(' ', str_replace('  ', ' ', $line));
                     $this->responseStatus = intval($status[1]);
                     $foundStatus = true;
                 }
             }
         } else {
             if (!$foundInfo) {
                 if ('' != trim($line)) {
                     $status = explode(':', $line);
                     $name = strtolower(array_shift($status));
                     $data = implode(':', $status);
                     $this->responseHeader[trim($name)] = trim($data);
                 } else {
                     $foundInfo = true;
                 }
             } else {
                 $lines[] = $line;
             }
         }
     }
     $this->responseBody = implode("\n", $lines);
     return $this->responseBody;
 }
开发者ID:computercomity,项目名称:typecho,代码行数:76,代码来源:Adapter.php

示例3: sendPingHandle

 /**
  * 发送pingback实现
  *
  * @access public
  * @return void
  */
 public function sendPingHandle()
 {
     /** 验证权限 */
     $this->user->pass('contributor');
     /** 忽略超时 */
     ignore_user_abort(true);
     /** 获取post */
     $post = $this->widget('Widget_Archive', "type=post", "cid={$this->request->cid}");
     if ($post->have() && preg_match_all("|<a[^>]*href=[\"'](.*?)[\"'][^>]*>(.*?)</a>|", $post->text, $matches)) {
         $links = array_unique($matches[1]);
         $permalinkPart = parse_url($post->permalink);
         /** 发送pingback */
         foreach ($links as $url) {
             $urlPart = parse_url($url);
             if (isset($urlPart['scheme'])) {
                 if ('http' != $urlPart['scheme'] || 'https' != $urlPart['scheme']) {
                     continue;
                 }
             } else {
                 $urlPart['scheme'] = 'http';
                 $url = Typecho_Common::buildUrl($urlPart);
             }
             if ($permalinkPart['host'] == $urlPart['host'] && $permalinkPart['path'] == $urlPart['path']) {
                 continue;
             }
             $spider = Typecho_Http_Client::get();
             if ($spider) {
                 $spider->setTimeout(10)->send($url);
                 if (!($xmlrpcUrl = $spider->getResponseHeader('x-pingback'))) {
                     if (preg_match("/<link[^>]*rel=[\"']pingback[\"'][^>]*href=[\"']([^\"']+)[\"'][^>]*>/i", $spider->getResponseBody(), $out)) {
                         $xmlrpcUrl = $out[1];
                     }
                 }
                 if (!empty($xmlrpcUrl)) {
                     try {
                         $xmlrpc = new IXR_Client($xmlrpcUrl);
                         $xmlrpc->pingback->ping($post->permalink, $url);
                         unset($xmlrpc);
                     } catch (Exception $e) {
                         continue;
                     }
                 }
             }
             unset($spider);
         }
     }
     /** 发送trackback */
     if ($post->have() && !empty($this->request->trackback)) {
         $links = $this->request->trackback;
         foreach ($links as $url) {
             $client = Typecho_Http_Client::get();
             if ($client) {
                 try {
                     $client->setTimeout(5)->setData(array('blog_name' => $this->options->title . ' &raquo ' . $post->title, 'url' => $post->permalink, 'excerpt' => $post->excerpt))->send($url);
                     unset($client);
                 } catch (Typecho_Http_Client_Exception $e) {
                     continue;
                 }
             }
         }
     }
 }
开发者ID:menmenweiwei,项目名称:blog,代码行数:68,代码来源:Service.php

示例4: goBack

 /**
  * 返回来路
  *
  * @access public
  * @param string $anchor 附加地址
  * @param string $default 默认来路
  * @return void
  */
 public function goBack($suffix = NULL, $default = NULL)
 {
     //获取来源
     $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
     //判断来源
     if (!empty($referer)) {
         // ~ fix Issue 38
         if (!empty($suffix)) {
             $parts = parse_url($referer);
             $myParts = parse_url($suffix);
             if (isset($myParts['fragment'])) {
                 $parts['fragment'] = $myParts['fragment'];
             }
             if (isset($myParts['query'])) {
                 $args = array();
                 if (isset($parts['query'])) {
                     parse_str($parts['query'], $args);
                 }
                 parse_str($myParts['query'], $currentArgs);
                 $args = array_merge($args, $currentArgs);
                 $parts['query'] = http_build_query($args);
             }
             $referer = Typecho_Common::buildUrl($parts);
         }
         $this->redirect($referer, false);
     } else {
         if (!empty($default)) {
             $this->redirect($default);
         }
     }
 }
开发者ID:menmenweiwei,项目名称:blog,代码行数:39,代码来源:Response.php

示例5: makeUriByRequest

 /**
  * 根据当前uri构造指定参数的uri
  *
  * @access public
  * @param mixed $parameter 指定的参数
  * @return string
  */
 public function makeUriByRequest($parameter = NULL)
 {
     /** 初始化地址 */
     $requestUri = $this->getRequestUrl();
     $parts = parse_url($requestUri);
     /** 初始化参数 */
     if (is_string($parameter)) {
         parse_str($parameter, $args);
     } else {
         if (is_array($parameter)) {
             $args = $parameter;
         } else {
             return $requestUri;
         }
     }
     /** 构造query */
     if (isset($parts['query'])) {
         parse_str($parts['query'], $currentArgs);
         $args = array_merge($currentArgs, $args);
     }
     $parts['query'] = http_build_query($args);
     /** 返回地址 */
     return Typecho_Common::buildUrl($parts);
 }
开发者ID:BlueBreeze,项目名称:typecho,代码行数:31,代码来源:Request.php

示例6: __construct

 /**
  * 客户端构造函数
  *
  * @access public
  * @param string $server 服务端地址
  * @param bool|string $path 路径名称
  * @param integer $port 端口名称
  * @param string $useragent 客户端
  * @param null $prefix
  */
 public function __construct($server, $path = false, $port = 80, $useragent = self::DEFAULT_USERAGENT, $prefix = NULL)
 {
     if (!$path) {
         $this->url = $server;
         // Assume we have been given a Url instead
         $bits = parse_url($server);
         $this->server = $bits['host'];
         $this->port = isset($bits['port']) ? $bits['port'] : 80;
         $this->path = isset($bits['path']) ? $bits['path'] : '/';
         // Make absolutely sure we have a path
         if (isset($bits['query'])) {
             $this->path .= '?' . $bits['query'];
         }
     } else {
         /** Typecho_Common */
         require_once 'Typecho/Common.php';
         $this->url = Typecho_Common::buildUrl(array('scheme' => 'http', 'host' => $server, 'path' => $path, 'port' => $port));
         $this->server = $server;
         $this->path = $path;
         $this->port = $port;
     }
     $this->prefix = $prefix;
     $this->useragent = $useragent;
 }
开发者ID:computercomity,项目名称:typecho,代码行数:34,代码来源:Client.php

示例7: makeUriByRequest

 /**
  * 根据当前uri构造指定参数的uri
  *
  * @access public
  * @param mixed $parameter 指定的参数
  * @return string
  */
 public function makeUriByRequest($parameter = NULL)
 {
     /** 初始化地址 */
     list($scheme) = explode('/', $_SERVER["SERVER_PROTOCOL"]);
     $requestUri = strtolower($scheme) . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $parts = parse_url($requestUri);
     /** 初始化参数 */
     if (is_string($parameter)) {
         parse_str($parameter, $args);
     } else {
         if (is_array($parameter)) {
             $args = $parameter;
         } else {
             return $requestUri;
         }
     }
     /** 构造query */
     if (isset($parts['query'])) {
         parse_str($parts['query'], $currentArgs);
         $args = array_merge($currentArgs, $args);
     }
     $parts['query'] = http_build_query($args);
     /** Typecho_Common */
     require_once 'Typecho/Common.php';
     /** 返回地址 */
     return Typecho_Common::buildUrl($parts);
 }
开发者ID:raindali,项目名称:express,代码行数:34,代码来源:Request.php


注:本文中的Typecho_Common::buildUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。