Пример #1
0
 /**
  * function register
  * 
  *  注册用户
  * 
  * @param
  * @return void
  */
 public static function register($request)
 {
     $username = $request->username;
     $password = $request->password;
     if (strlen($username) < 4 || strlen($username) > 40) {
         return -101;
     }
     if (strlen($password) < 6 || strlen($password) > 40) {
         return -121;
     }
     //判断用户是否存在
     if (self::isAvailableUid($request->username) != TRUE) {
         return -108;
     }
     //判断手机邮箱是否存在
     if (self::isAvailableEmail($request->email) != TRUE || self::isAvailableMobile($request->mobile) != TRUE) {
         return -109;
     }
     $email = $request->email;
     $mobile = $request->mobile;
     $now = $request->REQUEST_TIME;
     $rowUser['userid'] = $username;
     $rowUser['pwd'] = $password;
     $rowUser['mobile'] = $mobile;
     $rowUser['email'] = $email;
     $rowUser['kid'] = $now + 10;
     //加密kid
     $rowUser['regtime'] = $now;
     $rowUser['regip'] = $request->CLIENT_IP;
     $rowUser['status'] = 0;
     $_refs = Sp_Session::getReferers();
     $uid = self::storeUser($rowUser);
     if ($uid > 0) {
         $_user = self::load($uid);
         Sp_Account_SignIn::setHttpCookie($_user);
         //设置登录
         $sql = "update ht_users set login_nums = login_nums+1, logintime = ?, loginip=? where id=?";
         $sth = Da_Wrapper::dbo(self::DB_TABLE_USER)->prepare($sql);
         $ret = $sth->execute(array($request->REQUEST_TIME, $request->CLIENT_IP, $uid));
     }
     return $uid;
 }