public function setUser($username, $password, $email, $groupid = 3, $uid = 0)
 {
     if (!$email) {
         return new PwError('ADMIN:founder.edit.fail.email.empty');
     }
     Wind::import('SRV:user.dm.PwUserInfoDm');
     $userDm = new PwUserInfoDm($uid);
     $userDm->setEmail($email);
     $userDm->setGroupid($groupid);
     $password && $userDm->setPassword($password);
     if (!$uid) {
         $userDm->setUsername($username);
         return $this->loadUser()->addUser($userDm);
     } else {
         return $this->loadUser()->editUser($userDm);
     }
 }
Ejemplo n.º 2
0
 public function setUser($username, $password, $email, $groupid = 3, $uid = 0)
 {
     if (!$email) {
         return new PwError('ADMIN:founder.edit.fail.email.empty');
     }
     Wind::import('SRV:user.dm.PwUserInfoDm');
     $userDm = new PwUserInfoDm($uid);
     $userDm->setUsername($username);
     $userDm->setEmail($email);
     $userDm->setGroupid($groupid);
     $password && $userDm->setPassword($password);
     if (!$uid) {
         $uid = $this->loadUser()->addUser($userDm);
         //默认头像处理 windid处理
         //Wekit::load('SRV:user.srv.PwUserService')->restoreDefualtAvatar($uid);
         return $uid;
     } else {
         return $this->loadUser()->editUser($userDm);
     }
 }
Ejemplo n.º 3
0
 /**
  * 执行第三方授权登录后的注册动作
  * 
  */
 public function doThirdRegistAction()
 {
     //第三方登录注册不校验验证码
     /*
             if(Wekit::load("verify.srv.PwCheckVerifyService")->checkVerify($this->getInput('code')) != true){
        $this->showError('USER:verifycode.error','index.php?m=u&c=login');
             }
     */
     //post参数中获取用户注册信息、第三方授权获取的信息通过hidden标签保存
     $username = $this->getInput('username', 'post');
     $password = $this->getInput('password', 'post');
     $email = $this->getInput('email', 'post');
     $gender = $this->getInput('gender', 'post');
     $uid = $this->getInput('uid', 'post');
     $type = $this->getInput('type', 'post');
     $avatar = $this->getInput('avatar', 'post');
     //执行注册
     Wind::import('SRC:service.user.dm.PwUserInfoDm');
     $userDm = new PwUserInfoDm();
     $userDm->setUsername($username);
     $userDm->setPassword($password);
     $userDm->setEmail($email);
     $userDm->setGender($gender);
     $userDm->setRegdate(Pw::getTime());
     $userDm->setLastvisit(Pw::getTime());
     $userDm->setRegip(Wind::getComponent('request')->getClientIp());
     $userDm->setStatus(0);
     Wind::import('SRV:user.srv.PwRegisterService');
     $registerService = new PwRegisterService();
     $registerService->setUserDm($userDm);
     // [u_regsiter]:插件扩展
     $this->runHook('c_register', $registerService);
     if (($info = $registerService->register()) instanceof PwError) {
         $this->showError($info->getError());
     }
     // 这里取了lastInsertId,但已经指定了主键的值,所以返回false表示成功。。
     if ($this->_getUserOpenAccountDs()->addUser($info['uid'], $uid, $type) == false) {
         $this->downloadThirdPlatformAvatar($info['uid'], $avatar);
     }
     // 以便后面登录用到
     $acctRelationData = array('uid' => $info['uid']);
     //继续登录
     $login = new PwLoginService();
     $this->runHook('c_login_dorun', $login);
     Wind::import('SRV:user.srv.PwRegisterService');
     $registerService = new PwRegisterService();
     $info = $registerService->sysUser($acctRelationData['uid']);
     if (!$info) {
         $this->showError('USER:user.syn.error');
     }
     $identity = PwLoginService::createLoginIdentify($info);
     $identity = base64_encode($identity . '|' . $this->getInput('backurl') . '|' . '0');
     $this->forwardRedirect(WindUrlHelper::createUrl('u/login/welcome', array('_statu' => $identity)));
 }
Ejemplo n.º 4
0
 public function updateMyInfoAction()
 {
     $userid = $this->loginUser->uid;
     $txt_real_name = $this->getInput("Txt_petname");
     $rd_sex = $this->getInput("Rd_sex_1");
     $txt_blog = trim($this->getInput("Txt_blog"));
     $txt_introduce = trim($this->getInput("Txt_introduce"));
     //Txt_introduce
     $txt_qq = $this->getInput("Txt_qq");
     //Txt_qq
     $txt_alipay = $this->getInput("Txt_alipay");
     //Txt_alipay
     $byear = $this->getInput("byear");
     $bmonth = $this->getInput("bmonth");
     $bday = $this->getInput("bday");
     $email = trim($this->getInput('Txt_email', 'post'));
     $userDm = new PwUserInfoDm($this->loginUser->uid);
     $userDm->setRealname($txt_real_name);
     $userDm->setByear($byear);
     $userDm->setBmonth($bmonth);
     $userDm->setBday($bday);
     $userDm->setGender($rd_sex);
     $userDm->setHomepage($txt_blog);
     $userDm->setProfile($txt_introduce);
     $userDm->setAliww($txt_alipay);
     $userDm->setQq($txt_qq);
     $userDm->setEmail($email);
     $returnData = array("success" => true, "data" => "更新成功");
     if ($email) {
         $r = PwUserValidator::isEmailValid($email, $this->loginUser->username);
         if ($r instanceof PwError) {
             $code = $r->getError();
             $message = "邮箱地址已经被占用, 请使用另外一个地址";
             if ($code == 'USER:user.error.-7') {
                 $message = "请输入有效的邮箱地址";
             }
             $returnData['success'] = false;
             $returnData['data'] = $message;
             print_r(json_encode($returnData));
             die;
         }
     }
     //更新成功, 页面将刷新
     $userDs = Wekit::load('user.PwUser');
     $result = $userDs->editUser($userDm, PwUser::FETCH_MAIN + PwUser::FETCH_INFO);
     if ($result instanceof PwError) {
         $code = $result->getError();
         if ($code == "USER:error.profile.length") {
             $message = "您最多输入250个字的自我描述";
         } else {
             if ($code == "USER:error.homepage") {
                 $message = "博客地址不正确,需要以http开头";
             } else {
                 $message = "信息填写不完全" . $code;
             }
         }
         $returnData['success'] = false;
         $returnData['data'] = $message;
         // "请设置正确的博客链接";
         print_r(json_encode($returnData));
         die;
     }
     print_r(json_encode($returnData));
     die;
 }
Ejemplo n.º 5
0
 /**
  * 获取注册的信息
  *
  * @return PwUserInfoDm
  */
 private function _getUserDm()
 {
     list($username, $password, $repassword, $email, $aliww, $qq, $msn, $mobile, $mobileCode, $hometown, $location, $question, $answer, $regreason, $code) = $this->getInput(array('username', 'password', 'repassword', 'email', 'aliww', 'qq', 'msn', 'mobile', 'mobileCode', 'hometown', 'location', 'question', 'answer', 'regreason', 'code'), 'post');
     //	验证输入
     Wind::import('Wind:utility.WindValidator');
     $config = $this->_getRegistConfig();
     if (!$username) {
         $this->showError('USER:user.error.-1', 'u/register/run');
     }
     if (!$password) {
         $this->showError('USER:pwd.require', 'u/register/run');
     }
     if (!$email) {
         $this->showError('USER:user.error.-6', 'u/register/run');
     }
     if (!WindValidator::isEmail($email)) {
         $this->showError('USER:user.error.-7', 'u/register/run');
     }
     foreach ($config['active.field'] as $field) {
         if (!$this->getInput($field, 'post')) {
             $this->showError('USER:register.error.require.needField.' . $field, 'u/register/run');
         }
     }
     if ($config['active.check'] && !$regreason) {
         $this->showError('USER:register.error.require.regreason', 'u/register/run');
     }
     if ($config['active.phone']) {
         !PwUserValidator::isMobileValid($mobile) && $this->showError('USER:error.mobile', 'u/register/run');
         if (($mobileCheck = Wekit::load('mobile.srv.PwMobileService')->checkVerify($mobile, $mobileCode)) instanceof PwError) {
             $this->showError($mobileCheck->getError());
         }
     }
     if ($repassword != $password) {
         $this->showError('USER:user.error.-20', 'u/register/run');
     }
     if (in_array('register', (array) Wekit::C('verify', 'showverify'))) {
         $veryfy = Wekit::load("verify.srv.PwCheckVerifyService");
         if (false === $veryfy->checkVerify($code)) {
             $this->showError('USER:verifycode.error', 'u/register/run');
         }
     }
     Wind::import('SRC:service.user.dm.PwUserInfoDm');
     $userDm = new PwUserInfoDm();
     $userDm->setUsername($username);
     $userDm->setPassword($password);
     $userDm->setEmail($email);
     $userDm->setRegdate(Pw::getTime());
     $userDm->setLastvisit(Pw::getTime());
     $userDm->setRegip(Wind::getComponent('request')->getClientIp());
     $userDm->setAliww($aliww);
     $userDm->setQq($qq);
     $userDm->setMsn($msn);
     $userDm->setMobile($mobile);
     $userDm->setMobileCode($mobileCode);
     $userDm->setQuestion($question, $answer);
     $userDm->setRegreason($regreason);
     $areaids = array($hometown, $location);
     if ($areaids) {
         $srv = WindidApi::api('area');
         $areas = $srv->fetchAreaInfo($areaids);
         $userDm->setHometown($hometown, isset($areas[$hometown]) ? $areas[$hometown] : '');
         $userDm->setLocation($location, isset($areas[$location]) ? $areas[$location] : '');
     }
     return $userDm;
 }
Ejemplo n.º 6
0
 /** 
  * 编辑email
  *
  * @param int $uid 用户id
  * @param int $email email
  * @return boolean|PwError
  */
 public function updateEmail($uid, $email)
 {
     $userBo = new PwUserBo(intval($uid));
     if (!$userBo->isExists()) {
         return $this->buildResponse(USER_NOT_EXISTS);
     }
     if (!$email || WindValidator::isEmail($email) !== true) {
         return $this->buildResponse(USER_INVALID_PARAMS);
     }
     Wind::import('SRC:service.user.dm.PwUserInfoDm');
     $userDm = new PwUserInfoDm($uid);
     $userDm->setEmail($email);
     $result = $this->getUser()->editUser($userDm, PwUser::FETCH_MAIN);
     if ($result instanceof PwError) {
         return $this->buildResponse(-1, $result->getError());
     }
     return $this->buildResponse(0, $result);
 }
Ejemplo n.º 7
0
 /** 
  * 编辑用户信息操作
  * 
  * @return voido
  */
 public function doEditAction()
 {
     $info = $this->checkUser();
     Wind::import('SRC:service.user.dm.PwUserInfoDm');
     $dm = new PwUserInfoDm($info['uid']);
     //用户信息
     //$dm->setUsername($this->getInput('username', 'post'));
     list($password, $repassword) = $this->getInput(array('password', 'repassword'), 'post');
     if ($password) {
         if ($password != $repassword) {
             $this->showError('USER:user.error.-20');
         }
         $dm->setPassword($password);
     }
     $dm->setEmail($this->getInput('email', 'post'));
     list($question, $answer) = $this->getInput(array('question', 'answer'), 'post');
     switch ($question) {
         case '-2':
             $dm->setQuestion('', '');
             break;
         case '-1':
         default:
             break;
     }
     $dm->setRegdate(Pw::str2time($this->getInput('regdate', 'post')));
     $dm->setRegip($this->getInput('regip', 'post'));
     $dm->setOnline(intval($this->getInput('online', 'post')) * 3600);
     //基本资料
     $dm->setRealname($this->getInput('realname', 'post'));
     $dm->setGender($this->getInput('gender', 'post'));
     $birthday = $this->getInput('birthday', 'post');
     if ($birthday) {
         $bir = explode('-', $birthday);
         isset($bir[0]) && $dm->setByear($bir[0]);
         isset($bir[1]) && $dm->setBmonth($bir[1]);
         isset($bir[2]) && $dm->setBday($bir[2]);
     } else {
         $dm->setBday('')->setByear('')->setBmonth('');
     }
     list($hometown, $location) = $this->getInput(array('hometown', 'location'), 'post');
     $srv = WindidApi::api('area');
     $areas = $srv->fetchAreaInfo(array($hometown, $location));
     $dm->setLocation($location, isset($areas[$location]) ? $areas[$location] : '');
     $dm->setHometown($hometown, isset($areas[$hometown]) ? $areas[$hometown] : '');
     $dm->setHomepage($this->getInput('homepage', 'post'));
     $dm->setProfile($this->getInput('profile', 'post'));
     //交易信息
     $dm->setAlipay($this->getInput('alipay', 'post'));
     $dm->setMobile($this->getInput('mobile', 'post'));
     $dm->setTelphone($this->getInput('telphone', 'post'));
     $dm->setAddress($this->getInput('address', 'post'));
     $dm->setZipcode($this->getInput('zipcode', 'post'));
     //联系信息
     $dm->setEmail($this->getInput('email', 'post'));
     $dm->setAliww($this->getInput('aliww', 'post'));
     $dm->setQq($this->getInput('qq', 'post'));
     $dm->setMsn($this->getInput('msn', 'post'));
     /* @var $pwUser PwUser */
     $pwUser = Wekit::load('user.PwUser');
     $result = $pwUser->editUser($dm);
     if ($result instanceof PwError) {
         $this->showError($result->getError());
     }
     $isFounder = $this->isFounder($info['username']);
     $this->showMessage($isFounder ? 'USER:founder.update.success' : 'USER:update.success', 'u/manage/edit?uid=' . $info['uid']);
 }
 /** 
  * 编辑email
  *
  * @param int $uid 用户id
  * @param int $email email
  * @return boolean|PwError
  */
 public function updateEmail($uid, $email)
 {
     $uid = intval($uid);
     if ($uid < 1) {
         return $this->buildResponse(USER_INVALID_PARAMS, "参数错误");
     }
     $loginUser = Wekit::getLoginUser();
     if ($loginUser['uid'] == 0) {
         return $this->buildResponse(USER_NOT_LOGIN, "用户未登录");
     }
     if (!$email || WindValidator::isEmail($email) !== true) {
         return $this->buildResponse(USER_INVALID_PARAMS, "参数错误");
     }
     Wind::import('SRC:service.user.dm.PwUserInfoDm');
     $userDm = new PwUserInfoDm($uid);
     $userDm->setEmail($email);
     $result = $this->getUser()->editUser($userDm, PwUser::FETCH_MAIN);
     if ($result instanceof PwError) {
         return $this->buildResponse(-1, $result->getError());
     }
     return $this->buildResponse(0, array('uid' => $uid));
 }
Ejemplo n.º 9
0
 /** 
  * 编辑联系方式
  */
 public function docontactAction()
 {
     $userDm = new PwUserInfoDm($this->loginUser->uid);
     $userDm->setTelphone($this->getInput('telphone', 'post'));
     $userDm->setAddress($this->getInput('address', 'post'));
     $userDm->setZipcode($this->getInput('zipcode', 'post'));
     $userDm->setAliww($this->getInput('aliww', 'post'));
     $userDm->setQq($this->getInput('qq', 'post'));
     $userDm->setMsn($this->getInput('msn', 'post'));
     list($alipay, $mobile, $email) = $this->getInput(array('alipay', 'mobile', 'email'), 'post');
     if ($alipay) {
         $r = PwUserValidator::isAlipayValid($alipay, $this->loginUser->username);
         if ($r instanceof PwError) {
             $this->showError($r->getError());
         }
     }
     if ($mobile) {
         $r = PwUserValidator::isMobileValid($mobile);
         if ($r instanceof PwError) {
             $this->showError($r->getError());
         }
     }
     if ($email) {
         $r = PwUserValidator::isEmailValid($email, $this->loginUser->username);
         if ($r instanceof PwError) {
             $this->showError($r->getError());
         }
     }
     $userDm->setEmail($email);
     $userDm->setMobile($mobile);
     $userDm->setAlipay($alipay);
     $result = $this->_editUser($userDm, PwUser::FETCH_MAIN + PwUser::FETCH_INFO);
     if ($result instanceof PwError) {
         $this->showError($result->getError());
     } else {
         $this->loginUser->info = array_merge($this->loginUser->info, $userDm->getData());
         $this->showMessage('USER:user.edit.contact.success');
     }
 }
Ejemplo n.º 10
0
 /** 
  * 密码验证
  */
 public function doeditemailAction()
 {
     list($passwd, $email) = $this->getInput(array('passwd', 'email'), 'post');
     if (!$passwd || !$email) {
         $this->showError('USER:empty.error');
     }
     Wind::import('SRV:user.srv.PwTryPwdBp');
     $tryPwdBp = new PwTryPwdBp();
     if (($result = $tryPwdBp->checkPassword($this->loginUser->uid, $passwd, $this->getRequest()->getClientIp())) instanceof PwError) {
         list($error, ) = $result->getError();
         if ($error == 'USER:login.error.pwd') {
             $this->showError($result->getError());
         } else {
             Wind::import('SRC:service.user.srv.PwUserService');
             $srv = new PwUserService();
             $srv->logout();
             $this->forwardAction('u/login/run', array('backurl' => WindUrlHelper::createUrl('profile/index/run')));
         }
     }
     $userDm = new PwUserInfoDm($this->loginUser->uid);
     $r = PwUserValidator::isEmailValid($email, $this->loginUser->username);
     if ($r instanceof PwError) {
         $this->showError($r->getError());
     }
     $userDm->setEmail($email);
     $result = $this->_editUser($userDm, PwUser::FETCH_MAIN);
     if ($result instanceof PwError) {
         $this->showError($result->getError());
     } else {
         $this->loginUser->info = array_merge($this->loginUser->info, $userDm->getData());
         $this->showMessage('USER:user.edit.contact.success', 'profile/index/contact?_tab=contact');
     }
 }
Ejemplo n.º 11
0
 /**
  * 确认邮箱认证
  */
 public function verifyEmailAction()
 {
     $code = $this->getInput('code');
     $activeCodeDs = Wekit::load('user.PwUserActiveCode');
     $data = $activeCodeDs->getInfoByUid($this->loginUser->uid, self::VERIFY_EMAIL);
     if ($code != $data['code']) {
         $this->showError('该邮箱认证链接已过期,请重新认证');
     }
     $info = $this->_getUser()->getUserByEmail($data['email']);
     if ($info && $info['uid'] != $this->loginUser->uid) {
         $this->showError('该邮箱已存在');
     }
     if ($data['email'] != $this->loginUser->info['email']) {
         $dm = new PwUserInfoDm($this->loginUser->uid);
         $dm->setEmail($data['email']);
         $this->_getUser()->editUser($dm, PwUser::FETCH_MAIN);
     }
     $result = $this->_getService()->updateVerifyInfo($this->loginUser->uid, App_Verify::VERIFY_EMAIL);
     if ($result instanceof PwError) {
         $this->showError($result->getError());
     }
     //认证完成删除
     $activeCodeDs->deleteInfoByUid($this->loginUser->uid);
     $this->forwardRedirect(WindUrlHelper::createUrl('profile/extends/run?_left=verify'));
 }
Ejemplo n.º 12
0
 /**
 * 开放帐号注册到本系统内
 *
 * @access public
 * @return void
 * @example
 <pre>
 os可以是android或者ios <br>
 post: access_token&platformname&native_name&username&email&sex
 </pre>
 */
 public function openAccountRegisterAction()
 {
     //        if($this->_getUserOpenAccountDs()->addUser(56,56,56)==false){
     //        if(true){
     //            echo "true";
     //            $this->downloadThirdPlatformAvatar(59,"http://q.qlogo.cn/qqapp/1104230675/A773C383D93AAF2986157BA34965A5CD/100");
     //        }else{
     //            echo "false";
     //        }
     //        exit;
     $accountData = $this->authThirdPlatform();
     //
     list($username, $email, $sex) = $this->getInput(array('username', 'email', 'sex'));
     //随机密码
     $password = substr(str_shuffle('abcdefghigklmnopqrstuvwxyz1234567890~!@#$%^&*()'), 0, 7);
     //
     Wind::import('SRC:service.user.dm.PwUserInfoDm');
     $userDm = new PwUserInfoDm();
     $userDm->setUsername($username);
     $userDm->setPassword($password);
     $userDm->setEmail($email);
     $userDm->setGender($sex);
     $userDm->setRegdate(Pw::getTime());
     $userDm->setLastvisit(Pw::getTime());
     $userDm->setRegip(Wind::getComponent('request')->getClientIp());
     //
     $registerService = new PwRegisterService();
     $registerService->setUserDm($userDm);
     /*[u_regsiter]:插件扩展*/
     $this->runHook('c_register', $registerService);
     if (($info = $registerService->register()) instanceof PwError) {
         $this->showError($info->getError());
     } else {
         // 这里注册成功,要把第三方帐号的头像下载下来并处理
         // 这里取了lastInsertId,但已经指定了主键的值,所以返回false表示成功
         if ($this->_getUserOpenAccountDs()->addUser($info['uid'], $accountData['uid'], $accountData['type']) == false) {
             $this->downloadThirdPlatformAvatar($info['uid'], $accountData['avatar']);
             $laiwangOK = PwLaiWangSerivce::registerUser($info['uid'], $info['username'], $info['password'], Pw::getAvatar($info['uid'], 'big'), $accountData['gender']);
             // 重置uid
             $this->uid = $info['uid'];
             $userdata = $this->_getUserInfo($laiwangOK);
             $this->setOutput($userdata, 'data');
             $this->showMessage('USER:register.success');
         }
     }
 }