Example #1
0
 /**
  * 构造函数
  *
  * @access public
  */
 public function __construct()
 {
     parent::__construct();
     $this->title_prefix || ($this->title_prefix = lb_read_system('title_prefix'));
     $this->title_suffix || ($this->title_suffix = lb_read_system('title_suffix'));
     $this->title = $this->title_prefix . $this->title . $this->title_suffix;
 }
Example #2
0
 /**
  * 设置Cookie
  *
  * @access public
  * @param string $key 数据索引
  * @param string $value 数据值
  * @param int $time 过期时间
  * @param string $path 设置路径
  * @param string $domain 设置域
  * @return bool $cookie 返回状态
  */
 public static function set_cookie($key, $value, $time = 0, $path = NULL, $domain = NULL)
 {
     $time && ($time = time() + intval($time));
     $path || ($path = lb_read_system('cookie_path'));
     $domain || ($domain = lb_read_system('cookie_domain'));
     return setcookie($key, $value, $time, $path, $domain);
 }
Example #3
0
 public function act()
 {
     // 登录流程
     if (!$this->check_param('username, password, issave')) {
         V('Json.Base')->init(Const_Code::LOGIN_PARAM_ERROR, '登录传递参数错误');
         return;
     }
     $username = trim(Util_Server_Request::get_param('username', 'post'));
     $password = trim(Util_Server_Request::get_param('password', 'post'));
     $is_save = (int) Util_Server_Request::get_param('issave', 'post');
     $time = time();
     $seckey = lb_read_system('seckey');
     $user_id = (int) M('User')->check_password($username, md5($username . $password));
     if (!$user_id) {
         V('Json.Base')->init(Const_Code::LOGIN_FAIL, '帐号验证失败');
         return;
     }
     $user = M('User')->get_by_id($user_id);
     $expire_time = $is_save ? 86400 * 30 : 0;
     Util_Client_Cookie::set_cookie('userid', $user_id, $expire_time);
     Util_Client_Cookie::set_cookie('username', $user['name'], $expire_time);
     Util_Client_Cookie::set_cookie('userrole', $user['role'], $expire_time);
     Util_Client_Cookie::set_cookie('time', $time, $expire_time);
     Util_Client_Cookie::set_cookie('secstr', md5($user_id . '$' . $user['name'] . '$' . $user['role'] . '$' . $time . '$' . $seckey), $expire_time);
     V('Json.Base')->init(Const_Code::SUCCESS, '帐号验证通过');
 }
Example #4
0
 /**
  * 构造函数
  *
  * @access public
  * @param string $name 配置索引
  */
 public function __construct($name = 'mysql.master')
 {
     parent::__construct();
     $this->db_connect = Driver_Db_Factory::get_db_item($name);
     $this->table_prefix || ($this->table_prefix = lb_read_system('table_prefix'));
     $this->table_suffix || ($this->table_suffix = lb_read_system('table_suffix'));
     $this->table($this->table_name);
 }
Example #5
0
 protected function check_cookie()
 {
     $user_id = Util_Server_Request::get_cookie('userid');
     $user_name = Util_Server_Request::get_cookie('username');
     $user_role = Util_Server_Request::get_cookie('userrole');
     $time = Util_Server_Request::get_cookie('time');
     $secstr = Util_Server_Request::get_cookie('secstr');
     $seckey = lb_read_system('seckey');
     return $secstr === md5($user_id . '$' . $user_name . '$' . $user_role . '$' . $time . '$' . $seckey);
 }
Example #6
0
/**
 * 应用文件载入
 *
 * @param string $class 加载类名
 */
function lb_load_from_app($class)
{
    // 命名空间处理
    if (lb_read_system('namespace_path')) {
        $class = preg_replace('/\\\\/', '_', preg_replace('/^\\\\/', '', $class));
    } else {
        $class = preg_replace('/^\\\\/', '', substr($class, strripos($class, '\\')));
    }
    // 搜索应用库文件目录
    lb_require_lib(lb_convert_class_to_quote($class));
}
Example #7
0
/**
 * 调用控制器
 *
 * @param string $controller 控制器
 * @return type $act 返回结果
 */
function lb_call_controller($controller)
{
    // 命名空间处理
    $controller = lb_parse_classname($controller);
    $real_path = $controller['classname'];
    if (lb_read_system('namespace_path')) {
        $real_path = preg_replace('/\\\\/', '.', preg_replace('/^\\\\/', '', $controller['namespace'])) . $real_path;
    }
    // 控制器存在时执行操作
    if (lb_require_lib('Controller.' . $real_path)) {
        $controller_class = $controller['namespace'] . 'Controller_' . lb_convert_quote_to_class($controller['classname']);
        $controller = new $controller_class();
        return $controller->act();
    }
}
Example #8
0
 /**
  * 框架主执行函数
  *
  * @access public
  */
 public function run()
 {
     $this->controller = lb_call_router(lb_read_system('class_router'));
     $this->controller || ($this->controller = lb_read_system('error_page_404'));
     lb_call_controller($this->controller);
 }