Exemplo n.º 1
0
 public function ajaxSendEmailAction()
 {
     $email = Request::getPOST('email');
     $verify = Request::getPOST('verify');
     if (empty($verify)) {
         $this->renderAjax(1, '请输入图片验证码!');
     }
     if (empty($email)) {
         $this->renderAjax(1, '请填写邮箱!');
     }
     // 校验验证码
     $imgCode = Session::get('check_code');
     if (strtolower($verify) != $imgCode) {
         $this->renderAjax(2, '图片验证码错误!');
     }
     if (!Regex::match($email, RegexVars::EMAIL)) {
         $this->renderAjax(1, '邮箱格式错误!');
     }
     // 是否存在
     $userInfo = UcUserInterface::getByLoginName(array('login_name' => $email));
     if (empty($userInfo)) {
         $this->renderAjax(1, '用户邮箱不存在!');
     }
     $code = UcAuthInterface::sendEmailCode(array('email' => $email, 'repeat_at' => time() + 60));
     if (false === $code) {
         $this->renderAjax(1, '服务器繁忙,请1分钟后重试!');
     }
     $this->renderAjax(0);
 }
 public function ajaxSubmitAction()
 {
     $username = Request::getPOST('username');
     $password = Request::getPOST('password');
     $verify = Request::getPOST('verify');
     if (!Regex::match($username, RegexVars::USERNAME)) {
         $this->renderAjax(1, '用户名格式不正确!');
     }
     // 校验密码格式
     if (!Regex::match($password, RegexVars::PASSWORD)) {
         $this->renderAjax(1, '密码长度为6-20位!');
     }
     // 校验验证码
     $code = Session::get('check_code');
     if (strtolower($verify) != $code) {
         $this->renderAjax(1, '验证码错误,请重试!');
     }
     // 过滤用户名
     if (false !== strpos(strtolower($username), 'admin')) {
         $this->renderAjax(1, '用户已经存在!');
     }
     // 校验用户是否存在
     $userInfo = UcUserInterface::getByLoginName(array('login_name' => $username));
     if (!empty($userInfo)) {
         $this->renderAjax(1, '用户名已经被占用!');
     }
     // 保存
     $data = array('username' => $username, 'password' => $password, 'reg_ip' => Http::getClientIp());
     UcUserInterface::save($data);
     $this->renderAjax(0);
 }
Exemplo n.º 3
0
 private static function getController($location)
 {
     $location = strtolower($location);
     $pattern = '/controller/';
     $match = Regex::match($pattern, $location);
     if ($match > 0) {
         $location = Regex::replace($pattern, '', $location);
     }
     return $location;
 }
 public function ajaxUpdatePasswordAction()
 {
     // 获取参数
     $oldPassword = Request::getPOST('old-password');
     $password = trim(Request::getPOST('password'));
     if (!Regex::match($password, RegexVars::PASSWORD)) {
         $this->renderError('新密码限制为6-20位!');
     }
     $encryptPassword = UserCommonInterface::encryptPassword(array('password' => $oldPassword));
     if ($encryptPassword != $this->loginUserInfo['password']) {
         $this->renderError('旧密码不正确!');
     }
     $data = array('id' => $this->loginUserInfo['id'], 'password' => $password);
     UserCommonInterface::save($data);
     UserCommonInterface::logout();
     $this->renderAjax(0);
 }
Exemplo n.º 5
0
 public function ajaxSendEmailAction()
 {
     $email = Request::getPOST('email');
     if (empty($email)) {
         $this->renderError('请填写邮箱!');
     }
     if (!Regex::match($email, RegexVars::EMAIL)) {
         $this->renderError('邮箱格式错误!');
     }
     // 是否已经被绑定
     $userInfo = UserCommonInterface::getByLoginName(array('login_name' => $email));
     if (!empty($userInfo)) {
         $this->renderError('该邮箱已经被绑定!');
     }
     $code = AuthCommonInterface::sendEmailCode(array('email' => $email, 'repeat_at' => time() + 60));
     if (false === $code) {
         $this->renderError('服务器繁忙,请1分钟后重试!');
     }
     $this->renderAjax(0);
 }