/**
  * 修改密码页面
  */
 public function changePwd()
 {
     if (IS_POST) {
         $oldPwd = I('post.oldPwd', '', 'trim');
         $newPwd = I('post.newPwd', '', 'trim');
         $renewPwd = I('post.renewPwd', '', 'trim');
         if (empty($oldPwd) || empty($newPwd) || empty($renewPwd)) {
             $this->error('必须输入原密码和新密码');
         }
         if ($newPwd != $renewPwd) {
             $this->error('两次输入的密码不一致');
         }
         if (!chkPwd($newPwd)) {
             $this->error('密码长度6-15位,同时包含数字、大写字母,小写字母');
         }
         $userModel = D('User');
         $where = array('id' => session('userid'), 'status' => '01');
         $userInfo = $userModel->field('username,password')->where($where)->find();
         if (empty($userInfo)) {
             $this->error('账号出现异常,请重新登陆', U('Backend/Index/logout'));
         }
         if (md5(md5($userInfo['username']) . $oldPwd) != $userInfo['password']) {
             $this->error('原密码不正确');
         }
         $data = array('password' => md5(md5($userInfo['username']) . $newPwd));
         $result = $userModel->where($where)->save($data);
         if (!$result) {
             $this->error('密码修改失败');
         }
         cookie('simplepwd', NULL);
         $this->success('密码修改成功', U('Backend/Index/index'));
         exit;
     }
     $this->display();
 }
 /**
  * 后台登陆页
  */
 public function index()
 {
     if (IS_POST) {
         $userModel = D('User');
         $userName = I('username');
         $password = I('password');
         $loginResult = $userModel->login($userName, $password);
         if ($loginResult['status']) {
             //登陆成功,设置相应session值
             session('roleid', $loginResult['userinfo']['roleid']);
             session('userid', $loginResult['userinfo']['id']);
             cookie('username', $loginResult['userinfo']['username']);
             cookie('cname', $loginResult['userinfo']['cname']);
             if (!chkPwd($password)) {
                 //密码规则太过简单,提示用户
                 cookie('simplepwd', 1);
             }
             $this->redirect('Backend/Index/index');
         }
     }
     layout(false);
     $this->display();
 }