/**
  * 登录检查输入
  *
  * @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;
 }
Exemple #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]);
 }
 /**
  * 检查手机号码格式是否正确
  */
 public function checkPhoneFormatAction()
 {
     if (!PwUserValidator::isMobileValid($this->getInput('phone', 'post'))) {
         $this->showError('USER:mobile.error.formate');
     } else {
         $this->showMessage();
     }
 }
Exemple #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;
 }
 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;
 }
 /**
  * 获取注册的信息
  *
  * @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;
 }
Exemple #7
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;
 }
Exemple #8
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');
     }
 }
 /**
  * 密码校验
  */
 public function checkpwdAction()
 {
     $pwd = $this->getInput('pwd', 'post');
     $result = PwUserValidator::isPwdValid($pwd, $this->loginUser->username);
     if ($result instanceof PwError) {
         $this->showError($result->getError());
     }
     $this->addMessage(PwUserHelper::checkPwdStrong($pwd), 'rank');
     $this->showMessage();
 }
 /** 
  * 密码验证
  */
 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');
     }
 }
Exemple #11
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;
 }
Exemple #12
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());
     }
 }