Exemple #1
0
 /**
  * URL路径解析,pages 函数的辅助函数
  *
  * @param string $par 传入需要解析的变量 默认为,page={$page}
  * @param string $url URL地址
  * @return URL
  */
 public static function url_par($par, $url = '')
 {
     if ($url == '') {
         $url = Base_Request::get_request_uri();
     }
     $pos = strpos($url, '?');
     if ($pos === false) {
         $url .= '?' . $par;
     } else {
         $querystring = substr(strstr($url, '?'), 1);
         parse_str($querystring, $pars);
         $query_array = array();
         foreach ($pars as $k => $v) {
             if ($k == 'page') {
                 continue;
             }
             $query_array[$k] = $v;
         }
         if ($query_array) {
             $querystring = http_build_query($query_array) . '&' . $par;
         } else {
             $querystring = $par;
         }
         $url = substr($url, 0, $pos) . '?' . $querystring;
     }
     return $url;
 }
Exemple #2
0
 public function _initialize()
 {
     if (C('router', SITE_HOST)) {
         // 加载基于域名的URL 路由配置
         $this->_config = C('router', SITE_HOST);
         define('SUB_DOMAIN', strtolower(substr(SITE_HOST, 0, strpos(SITE_HOST, '.'))));
         // 二级域名定义
         $this->params = array('action' => 2, 'controller' => 1);
     } else {
         // 使用默认路由配置
         $this->_config = C('router', 'default');
     }
     $full_url = Base_Request::get_host_info() . Base_Request::get_request_uri();
     $this->_pathinfo = $_pathinfo = trim(str_replace(Base_Request::get_base_url(true), '', $full_url), '/');
 }
Exemple #3
0
 /**
  * (non-PHPdoc)
  *
  * @see Base_Router::_initialize()
  */
 public function _initialize()
 {
     $this->_config = C('router', 'api');
     $full_url = Base_Request::get_host_info() . Base_Request::get_request_uri();
     $this->_pathinfo = $_pathinfo = trim(str_replace(Base_Request::get_base_url(true), '', $full_url), '/');
 }
Exemple #4
0
 /**
  * 获得当前页面完整的URL
  *
  * <pre>Example:
  * 请求: http://www.tintsoft.com/example/index.php?a=test
  * 返回: http://www.tintsoft.com/example/index.php?a=test
  * </pre>
  *
  * @return string
  * @throws Base_Exception 获取主机信息失败的时候抛出异常
  */
 public static function get_url()
 {
     return self::get_base_url(true) . Base_Request::get_request_uri();
 }