Exemple #1
0
 public function checkUser()
 {
     if (!$this->usercode) {
         self::output('缺少参数:usercode', $this->errorCode);
     }
     $code = zmf::jieMi($this->usercode);
     $arr = explode('#', $code);
     //如果不能解密字符串,或者不是类似于'123#ios#1412555521'则报错
     if (!$code || !$arr || count($arr) != 3 || $arr[1] != $this->appPlatform) {
         self::output('验证用户信息失败,请重新登录', 400);
     }
     $this->uid = $arr[0];
     $this->userInfo = User::model()->findByPk($this->uid);
     if (!$this->userInfo) {
         self::output('验证用户信息错误:不存在的用户', 400);
     }
     if ($this->userInfo['code'] != $this->usercode) {
         self::output('您的账号已在其他设备登录,请重新登录', 400);
     }
     //如果已经过期
     if (zmf::now() - $arr[2] > 86400 * 30) {
         self::output('由于长时间未登录,请重新登录', 400);
     }
 }
Exemple #2
0
 public static function decode($code)
 {
     $_de = zmf::jieMi($code);
     $_arr = explode('#', $_de);
     return array('id' => $_arr[0], 'type' => $_arr[1]);
 }