public function loginAction()
 {
     session_start();
     if (IS_POST) {
         $username = I('post.username');
         $password = I('post.password');
         if (empty($username) || empty($password)) {
             $this->error('请输入用户名及密码');
         }
         $acl = new Acl();
         $user = $acl->getUser($username, true);
         if (!empty($user)) {
             $pwd = Utility::encodePassword($password, $user['salt']);
             if ($pwd != $user['password']) {
                 $this->error('您输入的密码错误');
             }
             if ($user['status'] == Acl::STATUS_DISABLED) {
                 $this->error('您的账号已经被禁用, 请联系系统管理员');
             }
             $user = coll_elements(array('uid', 'username', 'role'), $user);
             session('user', $user);
             $forward = I('get.forward');
             if (empty($forward)) {
                 $forward = U('bench/welcome/index');
             } else {
                 $forward = base64_decode($forward);
             }
             $this->success('成功登陆', $forward);
         } else {
             $this->error('您输入的用户名或密码错误');
         }
         exit;
     }
     $this->display('Wander/login');
 }
 public function modifyAction($uid)
 {
     $uid = intval($uid);
     $user = $this->acl->getUser($uid, true);
     if (empty($user)) {
         $this->error('访问错误');
     }
     if (IS_POST) {
         $input = $this->validateForm(true);
         $ret = $this->acl->modifyUser($uid, $input);
         if (is_error($ret)) {
             $this->error($ret['message']);
         } else {
             $this->success('保存成功');
             exit;
         }
     }
     $this->assign('user', $user);
     $this->display('form');
 }
 public function deleteAction($uid)
 {
     $uid = intval($uid);
     if ($uid == '1') {
         $this->error('创建用户不能删除');
     }
     $user = $this->acl->getUser($uid, true);
     if (empty($user)) {
         $this->error('访问错误');
     }
     $ret = $this->acl->table('__USR_USERS__')->where("`uid`={$uid}")->delete();
     if (empty($ret)) {
         $this->error('删除用户信息失败, 请稍后重试');
     } else {
         $this->success('删除成功');
     }
 }
 public function profileAction()
 {
     $user = session('user');
     $u = new Acl();
     $user = $u->getUser($user['username']);
     if (IS_POST) {
         $user['password'] = I('post.password');
         $ret = $u->modifyUser($user['uid'], $user);
         if ($ret === false) {
             $this->error('保存用户信息失败, 请稍后重试');
         } else {
             $this->success('保存成功');
             exit;
         }
     }
     $this->assign('user', $user);
     $this->display('profile');
 }