zoukankan      html  css  js  c++  java
  • 分析DuxCms之AdminUserModel

     1     /**
     2      * 获取信息
     3      * @param array $where 条件
     4      * @return array 信息
     5      */
     6  public function getWhereInfo($where)
     7     {
     8         return $this->table("__ADMIN_USER__ as A")   //table方法指定操作的数据表,__ADMIN_USER__简化数据表名,后面的as表示设置admin_user别名为A
     9                     ->join('__ADMIN_GROUP__ as B ON A.group_id = B.group_id')//用于根据两个或多个表中的列之间的关系,从这些表中查询数据
    10                     ->field('A.*,B.status as group_status,B.name as group_name,B.base_purview,B.menu_purview')//标识要返回或者操作的字段,可以用于查询和写入操作/
    11                     ->where($where)
    12                     ->find();
    13     }
     1 /**
     2      * 登录用户
     3      * @param int $userId ID
     4      * @return bool 登录状态
     5      */   
     6 public function setLogin($userId)
     7     {
     8         // 更新登录信息
     9         $data = array(
    10             'user_id' => $userId,
    11             'last_login_time' => NOW_TIME,
    12             'last_login_ip' => get_client_ip(),//调用thinkphp内置函数获取IP地址
    13         );
    14         $this->save($data);//将用户的登陆信息记录下来以备安全监测
    15         //写入系统记录
    16         api('Admin','AdminLog','addLog','登录系统');
    17         //设置cookie
    18         $auth = array(
    19             'user_id' => $userId,
    20         );
    21         session('admin_user', $auth);
    22         session('admin_user_sign', data_auth_sign($auth));
    23         return true;
    24     }

    这里将用户的IP地址和登陆时间记录下来了更安全。

  • 相关阅读:
    PAT 1088. Rational Arithmetic
    PAT 1087. All Roads Lead to Rome
    PAT 1086. Tree Traversals Again
    PAT 1085. Perfect Sequence
    PAT 1084. Broken Keyboard
    PAT 1083. List Grades
    PAT 1082. Read Number in Chinese
    求最大公因数
    [转载]Latex文件转成pdf后的字体嵌入问题的解决
    [转载]Matlab有用的小工具小技巧
  • 原文地址:https://www.cnblogs.com/disneyland/p/4264642.html
Copyright © 2011-2022 走看看