Exemple #1
0
 public function passwordAction()
 {
     $currUser = $this->refreshCurrentUser();
     //$currUser = $this->getCurrentUser ();
     if (ComTool::isAjax()) {
         if (isset($_POST['captcha'])) {
             $captcha = trim($this->post('captcha'));
             if (!ComTool::checkCaptcha($captcha)) {
                 ComTool::ajax(100001, '验证码错误');
             }
         }
         $curpass = trim($this->post('curpass'));
         ComTool::checkEmpty($curpass, '请输入当前密码');
         ComTool::checkMinMaxLen($curpass, 6, 16, '密码6-16位');
         ComTool::checkEqual(md5($curpass), $currUser['passwd'], '当前密码错误,请检查');
         $passwd = trim($this->post('passwd'));
         ComTool::checkEmpty($passwd, '请输入新密码');
         ComTool::checkMinMaxLen($passwd, 6, 16, '密码6-16位');
         $cpasswd = trim($this->post('cpasswd'));
         ComTool::checkEqual($passwd, $cpasswd, '两次输入的密码不同');
         $passwd = md5($passwd);
         $time = time();
         $sql = "update `user` set passwd='{$passwd}',update_time='{$time}' where id={$currUser['id']} limit 1";
         $res = UserData::sql($sql);
         ComTool::result($res, '服务器忙,请重试', '保存成功');
     }
     $this->display();
 }