Exemplo n.º 1
0
 /**
  * 登录检查输入
  *
  * @param string $username
  * @return array
  */
 public function checkInput($username)
 {
     $r = array();
     //手机号码登录
     if (PwUserValidator::isMobileValid($username) === true && in_array(4, $this->loginConfig['ways'])) {
         $mobileInfo = Wekit::load('user.PwUserMobile')->getByMobile($username);
         if (!$mobileInfo) {
             return array();
         }
         $r = $this->_getWindid()->getUser($mobileInfo['uid'], 1);
     }
     //UID登录
     if (!$r && is_numeric($username) && in_array(1, $this->loginConfig['ways'])) {
         $r = $this->_getWindid()->getUser($username, 1);
     }
     //email登录
     if (!$r && WindValidator::isEmail($username) && in_array(2, $this->loginConfig['ways'])) {
         $r = $this->_getWindid()->getUser($username, 3);
     }
     //用户名登录
     if (!$r && in_array(3, $this->loginConfig['ways'])) {
         $r = $this->_getWindid()->getUser($username, 2);
     }
     return $r;
 }
Exemplo n.º 2
0
 /** 
  * 获得登录用户信息
  *
  * @param string $username 登录输入
  * @param string $password 密码
  * @param string $ip 尝试的IP地址
  * @param boolean $checkQ 是否验证安全问题
  * @param string $safeQuestion 安全问题
  * @param string $safeAnswer 安全问题答案
  * @return array
  */
 public function auth($username, $password, $ip = '', $checkQ = false, $safeQuestion = '', $safeAnswer = '')
 {
     $r = array(-14, array());
     //手机号码登录
     if (PwUserValidator::isMobileValid($username) === true && in_array(4, $this->loginConfig['ways'])) {
         $mobileInfo = Wekit::load('user.PwUserMobile')->getByMobile($username);
         if (!$mobileInfo) {
             return $this->checkVerifyResult(-1, array());
         }
         $r = $this->_getWindid()->login($mobileInfo['uid'], $password, 1, $checkQ, $safeQuestion, $safeAnswer);
     }
     //UID登录
     if ($r[0] == -14 && is_numeric($username) && in_array(1, $this->loginConfig['ways'])) {
         $r = $this->_getWindid()->login($username, $password, 1, $checkQ, $safeQuestion, $safeAnswer);
     }
     //email登录
     if ($r[0] == -14 && WindValidator::isEmail($username) && in_array(2, $this->loginConfig['ways'])) {
         $r = $this->_getWindid()->login($username, $password, 3, $checkQ, $safeQuestion, $safeAnswer);
     }
     //用户名登录
     if ($r[0] == -14 && in_array(3, $this->loginConfig['ways'])) {
         $r = $this->_getWindid()->login($username, $password, 2, $checkQ, $safeQuestion, $safeAnswer);
     }
     return $this->checkVerifyResult($r[0], $r[1]);
 }
Exemplo n.º 3
0
 /**
  * 检查手机号码格式是否正确
  */
 public function checkPhoneFormatAction()
 {
     if (!PwUserValidator::isMobileValid($this->getInput('phone', 'post'))) {
         $this->showError('USER:mobile.error.formate');
     } else {
         $this->showMessage();
     }
 }
Exemplo n.º 4
0
 /** 
  * 检查转换数据
  * 
  * @return boolean|PwError 
  */
 private function check()
 {
     if ($this->_data['groups']) {
         $this->_data['groups'] = implode(',', $this->_data['groups']);
     }
     //【用户资料验证】手机号码格式验证
     if (($_tmp = $this->getField('mobile')) && true !== ($r = PwUserValidator::isMobileValid($_tmp))) {
         return $r;
     }
     //【用户资料验证】固定电话号码格式验证
     if (($_tmp = $this->getField('telphone')) && true !== ($r = PwUserValidator::isTelPhone($_tmp))) {
         return $r;
     }
     //【用户资料验证】邮编格式验证
     if (($_tmp = $this->getField('zipcode')) && false === WindValidator::isZipcode($_tmp)) {
         return new PwError('USER:error.zipcode');
     }
     //【用户资料验证】个人主页长度限制
     if (($_tmp = $this->getField('homepage')) && (false === WindValidator::isUrl($_tmp) || true === WindValidator::isLegalLength($_tmp, 200))) {
         return new PwError('USER:error.homepage');
     }
     //【用户资料验证】自我简介长度限制
     if (($_tmp = $this->getField('profile')) && true === WindValidator::isLegalLength($_tmp, 250)) {
         return new PwError('USER:error.profile.length', array('{length}' => 250));
     }
     //TODO【用户资料验证】BBS签名验证长度判断----后台权限设置
     /*
     if (($_tmp = $this->getField('bbs_sign')) && (true === WindValidator::isLegalLength($_tmp, 500))) {
     	return new PwError('USER:error.bbs_sign.length', array('{length}' => 500));
     }
     */
     return true;
 }
Exemplo 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;
 }
Exemplo n.º 6
0
 private function _checkMobileRight($mobile)
 {
     $config = Wekit::C('register');
     if (!$config['active.phone']) {
         return new PwError('USER:mobile.reg.open.error');
     }
     Wind::import('SRV:user.validator.PwUserValidator');
     if (!PwUserValidator::isMobileValid($mobile)) {
         return new PwError('USER:error.mobile');
     }
     $mobileInfo = Wekit::load('user.PwUserMobile')->getByMobile($mobile);
     if ($mobileInfo) {
         return new PwError('USER:mobile.mobile.exist');
     }
     return true;
 }
Exemplo n.º 7
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');
     }
 }
Exemplo n.º 8
0
 private function _checkMobileRight($mobile, $uid)
 {
     Wind::import('SRV:user.validator.PwUserValidator');
     if (!PwUserValidator::isMobileValid($mobile)) {
         return new PwError('USER:error.mobile');
     }
     $mobileInfo = Wekit::load('user.PwUserMobile')->getByMobile($mobile);
     if ($mobileInfo && $mobileInfo['uid'] != $uid) {
         $this->showError('USER:mobile.mobile.exist');
     }
     return true;
 }
Exemplo n.º 9
0
 /** 
  * 获得登录用户信息
  *
  * @param string $username 用户名
  * @param string $password 密码
  * @param boolean $checkQ 是否验证安全问题
  * @param string $safeQuestion 安全问题
  * @param string $safeAnswer 安全问题答案
  * @return array
  */
 public function auth($username, $password, $checkQ = false, $safeQuestion = '', $safeAnswer = '')
 {
     $r = array(-14, array());
     //手机号码登录
     if (PwUserValidator::isMobileValid($username) === true && in_array(4, $this->loginConfig['ways'])) {
         $mobileInfo = Wekit::load('user.PwUserMobile')->getByMobile($username);
         if (!$mobileInfo) {
             return array(-1, array());
         }
         $r = $this->_getWindid()->login($mobileInfo['uid'], $password, 1, $checkQ, $safeQuestion, $safeAnswer);
     }
     //UID登录
     if ($r[0] == -14 && is_numeric($username) && in_array(1, $this->loginConfig['ways'])) {
         $r = $this->_getWindid()->login($username, $password, 1, $checkQ, $safeQuestion, $safeAnswer);
     }
     //email登录
     if ($r[0] == -14 && WindValidator::isEmail($username) && in_array(2, $this->loginConfig['ways'])) {
         $r = $this->_getWindid()->login($username, $password, 3, $checkQ, $safeQuestion, $safeAnswer);
     }
     //用户名登录
     if ($r[0] == -14 && in_array(3, $this->loginConfig['ways'])) {
         $r = $this->_getWindid()->login($username, $password, 2, $checkQ, $safeQuestion, $safeAnswer);
     }
     switch ($r[0]) {
         case 1:
             //用户信息正常
             return array(1, $r[1]);
         case -13:
             //用户密码错误
             return array(-2, $r[1]);
         case -20:
             //用户安全问题错误
             return array(-3, $r[1]);
         case -14:
             //用户不存在
         //用户不存在
         default:
             return array(-1, array());
     }
 }