Esempio n. 1
0
 public function run()
 {
     $account = $this->getDataItem('account', 1);
     //帐号
     $password = $this->getDataItem('password', 1);
     //密码
     $nickname = Keyword::Filter($this->getDataItem('nickname', 1));
     //昵称
     $smsCode = $this->getDataItem('sms_code', '');
     //短信验证
     if ($this->userInfoByAccount($account)) {
         $this->setResult(['success' => $this->success, 'user_token' => $this->userToken, 'message' => '账户名已存在']);
         return;
     }
     if (!MobileSMS::Check('register', $smsCode, $account, $this->apiAccessToken->id)) {
         $this->setResult(['success' => $this->success, 'user_token' => $this->userToken, 'message' => '短信验证码错误']);
         return;
     }
     if (empty($password) || empty($nickname)) {
         $this->setResult(['success' => $this->success, 'user_token' => $this->userToken, 'message' => '密码和昵称不能为空']);
         return;
     }
     $this->userInfo = new UserBase();
     $this->userInfo->user_account = $account;
     $this->userInfo->user_password = $this->hashPassword($password);
     $this->userInfo->user_nickname = $nickname;
     $this->userInfo->user_cover = $this->getConfig()->defaultCover;
     //'default.jpg';
     if ($this->userInfo->save()) {
         $this->success = 1;
         $this->message = '注册成功';
         $this->saveUserAuth($this->apiAccessToken->id, $this->userInfo->user_id);
         $this->userToken = $this->getUserAuth()->userToken;
     } else {
         $this->message = '注册失败';
         $this->databaseErrorLog($this->userInfo);
     }
     $this->setResult(['success' => $this->success, 'user_token' => $this->userToken, 'message' => $this->message, 'user_id' => $this->userInfo->user_id]);
 }
Esempio n. 2
0
 public function run()
 {
     $account = $this->getDataItem('account', 1);
     //帐号
     $password = $this->getDataItem('password', 1);
     //密码
     $nickname = Keyword::Filter($this->getDataItem('nickname', 1));
     //昵称
     $smsCode = $this->getDataItem('sms_code', '');
     //短信验证
     if ($this->userInfoByAccount($account)) {
         $this->setResult(['success' => 101, 'user_token' => $this->userToken, 'message' => '账户名已存在']);
         return;
     }
     if (empty($password) || empty($nickname)) {
         $this->setResult(['success' => 103, 'user_token' => $this->userToken, 'message' => '密码和昵称不能为空']);
         return;
     }
     if (empty($smsCode)) {
         $this->setResult(['success' => 102, 'user_token' => $this->userToken, 'message' => '短信验证码必填']);
         return;
     }
     if (!MobileSMS::Check('register', $smsCode, $account, $this->apiAccessToken->id)) {
         $this->setResult(['success' => 102, 'user_token' => $this->userToken, 'message' => '短信验证码错误']);
         return;
     }
     $this->userInfo = new UserBase();
     $this->userInfo->user_account = $account;
     $this->userInfo->user_password = $this->hashPassword($password);
     $this->userInfo->user_nickname = $nickname;
     $this->userInfo->user_cover = $this->getConfig()->defaultCover;
     //'default.jpg';
     $this->userInfo->bind_phone = $account;
     if ($this->userInfo->save()) {
         $this->success = 1;
         $this->message = '注册成功';
         $this->saveUserAuth($this->apiAccessToken->id, $this->userInfo->user_id);
         $this->userToken = $this->getUserAuth()->userToken;
     } else {
         $this->message = '注册失败';
         $this->databaseErrorLog($this->userInfo);
     }
     if ($this->success == 1) {
         if ($model = UserBase::findFirst('user_id = ' . $this->userInfo->user_id)) {
             $info = $model->toArray();
         } else {
             $info = [];
         }
         $info['user_mobile'] = $info['bind_phone'];
         $info['user_cover'] = $info['user_cover'] ? PicUrl::UserCover($info['user_cover'], $this->getDi()) : '';
         // 获取城市信息
         $SysAreaZipDistrictPhonecode = new SysAreaZipDistrictPhonecode();
         $city = $SysAreaZipDistrictPhonecode->getOne($info['user_district']);
         $info['user_district'] = $city['FULL_NAME'] ?: '';
         // 删除不要的字段
         unset($info['user_account'], $info['user_password'], $info['user_state'], $info['user_addtime'], $info['is_manage']);
         $this->setResult(array_merge($info, ['success' => $this->success, 'user_token' => $this->userToken, 'message' => $this->message]));
     } else {
         $this->setResult(['success' => $this->success, 'user_token' => $this->userToken, 'message' => $this->message, 'user_id' => $this->userInfo->user_id]);
     }
 }
Esempio n. 3
0
 private function register($type, $attrType, $openId, $nickname, $cover, $otherData)
 {
     // 添加基础信息
     $base = new UserBase();
     $base->user_account = '';
     $base->user_password = '';
     $base->user_nickname = $nickname;
     /* if($cover!=''){
       	$base->user_cover = $this->getConfig()->defaultCover; //'default.png';
        } */
     //$config=$this->Config()->aliyun->oss;
     $img = file_get_contents($cover);
     file_put_contents('img/1.jpg', $img);
     $oss = new OSS('dUBfr1wNHjgMnJsd', '1U6ZSbOKhGBffxsopuMIKN6xCpSzUe', 'oss-cn-beijing.aliyuncs.com');
     $options = array();
     $object_name = time() . rand(10000, 99999);
     $file_path = "user-cover/" . date("Y/m/d") . "/" . $object_name . ".jpg";
     $response = $oss->upload_file_by_file('meelier', $file_path, 'img/1.jpg');
     unlink('img/1.jpg');
     $url = $response->header['_info']['url'];
     $url = str_replace("http://oss-cn-beijing.aliyuncs.com/meelier/", "", $url);
     if ($attrType == 101) {
         $base->user_cover = json_decode($otherData)->headimgurl ?: $url;
     } else {
         $base->user_cover = $url;
     }
     // $base->user_cover=$this->getConfig()->defaultCover;
     if (!$base->save()) {
         $this->databaseErrorLog($base);
         return false;
     }
     $userId = $base->user_id;
     // 保存第三方登录信息
     $attr = new UserAttribute();
     $attr->user_id = $userId;
     $attr->attr_type = 100;
     $attr->attr_key = $type;
     $attr->attr_value_json = $openId;
     if (!$attr->save()) {
         $this->databaseErrorLog($attr);
         return false;
     }
     $attr2 = new UserAttribute();
     $attr2->user_id = $userId;
     $attr2->attr_type = $attrType;
     $attr2->attr_key = $openId;
     $attr2->attr_value_json = $otherData;
     if (!$attr2->save()) {
         $this->databaseErrorLog($attr2);
         return false;
     }
     return $userId;
 }
Esempio n. 4
0
 /**
  * 保存马甲用户信息
  * @date: 2016-1-4 
  * @author: futao
  */
 public function addsaveAction()
 {
     $req = $this->request;
     $account = $req->getPost('account', null, '');
     $district = $req->getPost('district', null, '');
     $password = $req->getPost('password', null, '');
     $nickname = $req->getPost('nickname', null, '');
     $realname = $req->getPost('realname', null, '');
     $phone = $req->getPost('phone', null, '');
     $persional_sign = $req->getPost('persional_sign', null, '');
     $birthday = $req->getPost('birthday', null, '');
     $gender = $req->getPost('sex', null, 2);
     $echo = function ($msg, $state = false) {
         echo '<script type="text/javascript">';
         echo 'parent.formResult("' . $msg . '", ' . ($state ? 1 : 0) . ')';
         echo '</script>';
     };
     $userinfo = UserBase::findFirst("user_account={$account}");
     if ($userinfo) {
         $echo('账号已被注册!');
         return;
     }
     $uploadFile = new UploadPic();
     $uploadFile->request = $req;
     $cover = $uploadFile->userCover();
     if ($cover == false) {
         if ($_FILES['avatar']['error'] == 1) {
             $echo('封面大小超过了2M!');
         } else {
             $echo('封面必须上传!');
         }
         return;
     }
     $usermodel = new UserBase();
     //个性签名编码
     if ($persional_sign != '') {
         $usermodel->persional_sign = base64_encode(serialize($persional_sign));
     }
     $usermodel->user_account = $account;
     $usermodel->user_password = UserCommon::hashPassword($password, $this->di);
     $usermodel->user_district = $district;
     $usermodel->user_nickname = $nickname;
     $usermodel->user_realname = $realname;
     $usermodel->bind_phone = $phone;
     //$usermodel->persional_sign=$persional_sign;
     $usermodel->user_birthday = $birthday;
     $usermodel->user_cover = $cover;
     $usermodel->is_manage = 1;
     $usermodel->user_gender = $gender;
     if ($usermodel->save()) {
         $echo('ok', true);
     } else {
         $echo("添加失败!");
     }
 }