Exemplo n.º 1
0
 /**
  * 验证是否登录,如果已经登录,返回登录的uid 和 phone 否则返回false
  * @param  [type] $token [description]
  * @return [type]        [description]
  */
 public static function checkLogin($token)
 {
     $uid = security::decode(base64_decode($token));
     if (empty($uid)) {
         return false;
     }
     $db = DB::getInstance();
     $sql = "select a.uid, b.enable from t_login a , t_user b where a.uid={$uid} and a.token = '{$token}' and a.uid = b.uid limit 1";
     $rst = $db->get_one($sql);
     if (empty($rst)) {
         return false;
     }
     return $rst;
 }
Exemplo n.º 2
0
 protected function checkAdminLogin($type = 'json')
 {
     $token = cookie::get('adminLogin');
     $clientStr = security::decode($token);
     $hasLogin = false;
     if (!empty($clientStr) && !empty($token)) {
         $realUsername = DConfig::get('adminUserName');
         $realPwd = DConfig::get('adminPwd');
         $str = md5($realUsername . $realPwd);
         if ($str == $clientStr) {
             $hasLogin = true;
         }
     }
     if (!$hasLogin) {
         if ($type == 'json') {
             $this->msg = new Msg(-1, '对不起,请先登录');
             exit;
         } else {
             header("Location:/adminPage/login");
         }
     }
 }