コード例 #1
0
 /**
  * 设置登录状态、记录登录知识
  * @param integer $uid 用户ID
  * @param boolean $is_remember_me 是否记录登录状态,默认为false
  * @return boolean 操作是否成功
  */
 private function _recordLogin($uid, $is_remember_me = false)
 {
     // 注册cookie
     if (!$this->getCookieUid() && $is_remember_me) {
         $expire = 3600 * 24 * 30;
         cookie('TSV3_LOGGED_USER', $this->jiami(C('SECURE_CODE') . ".{$uid}"), $expire);
     }
     // 记住活跃时间
     cookie('TSV4_ACTIVE_TIME', time() + 60 * 30);
     cookie('login_error_time', null);
     // 更新登陆时间
     model('User')->setField('last_login_time', $_SERVER['REQUEST_TIME'], 'uid=' . $uid);
     // 记录登陆知识,首次登陆判断
     empty($this->rel) && ($this->rel = D('')->table(C('DB_PREFIX') . 'login_record')->where("uid = " . $uid)->getField('login_record_id'));
     $credit_map['uid'] = $uid;
     $credit_map['ctime'] = array('EGT', strtotime(date('Y-m-d', time())));
     $firstTime = D('')->table(C('DB_PREFIX') . 'login_record')->where($credit_map)->count();
     if ($firstTime == 0) {
         //添加积分
         model('Credit')->setUserCredit($uid, 'user_login');
     }
     // 注册session
     $_SESSION['mid'] = intval($uid);
     $_SESSION['SITE_KEY'] = getSiteKey();
     $inviterInfo = model('User')->getUserInfo($uid);
     $map['ip'] = get_client_ip();
     $map['ctime'] = time();
     $map['locktime'] = 0;
     $this->success = '登录成功,努力加载中。。';
     if ($this->rel) {
         D('')->table(C('DB_PREFIX') . 'login_record')->where("uid = " . $uid)->save($map);
     } else {
         $map['uid'] = $uid;
         D('')->table(C('DB_PREFIX') . 'login_record')->add($map);
     }
     return true;
 }
コード例 #2
0
 /**
  * 设置登录状态、记录登录日志
  * @param integer $uid 用户ID
  * @param boolean $is_remember_me 是否记录登录状态,默认为false
  * @return boolean 操作是否成功
  */
 private function _recordLogin($uid, $is_remember_me = false)
 {
     // 注册cookie
     if (!$this->getCookieUid() && $is_remember_me) {
         $expire = 3600 * 24 * 365;
         cookie('TSV3_LOGGED_USER', $this->jiami(C('SECURE_CODE') . ".{$uid}"), $expire);
     }
     // 记住活跃时间
     cookie('TSV3_ACTIVE_TIME', time() + 60 * 30);
     cookie('login_error_time', null);
     // 更新登陆时间
     model('User')->setField('last_login_time', $_SERVER['REQUEST_TIME'], 'uid=' . $uid);
     // 记录登陆日志,首次登陆判断
     empty($this->rel) && ($this->rel = D('')->table(C('DB_PREFIX') . 'login_record')->where("uid = " . $uid)->find());
     // 注册session
     $_SESSION['mid'] = intval($uid);
     $_SESSION['SITE_KEY'] = getSiteKey();
     $inviterInfo = model('User')->getUserInfo($uid);
     $map['uid'] = $uid;
     $map['ip'] = get_client_ip();
     $map['ctime'] = time();
     $map['locktime'] = 0;
     if ($this->rel) {
         D('')->table(C('DB_PREFIX') . 'login_record')->where("uid = " . $uid)->save($map);
     } else {
         D('')->table(C('DB_PREFIX') . 'login_record')->add($map);
     }
     return true;
 }