Пример #1
0
 public function Init()
 {
     /**
      * show all errors
      */
     show_errors();
     /**
      * check if page is secured
      */
     if (protocol() == 'https') {
         forceHTTPS();
     }
     /**
      * initializing session
      */
     sessions::init();
     /**
      * getting requested url
      */
     $this->Get_Url();
     /**
      * replace - to _
      */
     array_walk($this->_Url, array($this, 'Url_replace'));
     /**
      * check if controller name not exists
      */
     if (empty($this->_Url[0])) {
         $this->_Url[0] = default_controller();
     }
     $this->Set_Controller();
     $this->Set_Method();
 }
Пример #2
0
function base_url()
{
    static $base;
    if (empty($base)) {
        $base = protocol() . $_SERVER['HTTP_HOST'] . base_uri();
    }
    return $base;
}
Пример #3
0
function base_url()
{
    static $base_url;
    if (!isset($base_url)) {
        $base_url = protocol() . '://' . $_SERVER['HTTP_HOST'];
    }
    return $base_url;
}
Пример #4
0
function get_absolute_url($relative_url)
{
    if ($relative_url[0] != DIRECTORY_SEPARATOR) {
        return protocol() . host() . cur_directory() . DIRECTORY_SEPARATOR . $relative_url;
    } else {
        return protocol() . host() . $relative_url;
    }
}
Пример #5
0
function full_url()
{
    return protocol() . "://" . $_SERVER['HTTP_HOST'] . current_url();
}
Пример #6
0
 /**
  * returning domain with protocol
  * @return string
  */
 function site_addr()
 {
     return protocol() . '://' . domain();
 }
Пример #7
0
 /**
  * 组合url
  * @param  string $path moudle/controller/action
  * @param  string $param 链接参数
  * @return string
  */
 function url($path, $param = array())
 {
     //获得当前模块控制器方法
     $moudle = system\core\Router::getMoudle();
     $controller = system\core\Router::getController();
     $action = system\core\Router::getAction();
     //解析
     $path = strtolower(trim($path, '/'));
     $pathArr = explode('/', $path);
     $pathCount = count($pathArr);
     if ($pathCount == 1) {
         $action = $pathArr[0];
     } else {
         if ($pathCount == 2) {
             $controller = $pathArr[0];
             $action = $pathArr[1];
         } else {
             if ($pathCount == 3) {
                 $moudle = $pathArr[0];
                 $controller = $pathArr[1];
                 $action = $pathArr[2];
             } else {
                 throw new Exception('url()参数错误');
             }
         }
     }
     //组合url
     $url = protocol() . "://" . $_SERVER['SERVER_NAME'] . '/' . $moudle . '/' . ucfirst($controller) . '/' . $action;
     //解析参数
     if (!empty($param)) {
         $param_str = parse_url_array($param);
         $url .= '/' . $param_str;
     }
     return $url;
 }