public function add()
 {
     if (isset($_SESSION['name']) && $_SESSION['role'] == 1) {
         $Manager = new \Model\ManagerModel();
         if (!empty($_POST)) {
             $z = $Manager->create();
             if (!$z) {
                 $this->error($Manager->getError() . '!', 'javascript:history.back();');
             } else {
                 $z = $Manager->add();
                 if ($z) {
                     $this->success("添加管理员成功!", U('index'));
                 } else {
                     $this->error("添加管理员失败!", U('index'));
                 }
             }
         } else {
             $this->assign('id', $_SESSION['id']);
             $this->assign('name', $_SESSION['name']);
             $this->assign('role', $_SESSION['role']);
             $front = D("Front");
             $fid = 1;
             $resultByFront = $front->where('fid = ' . $fid)->find();
             $this->assign('resultByFront', $resultByFront);
             $this->display();
         }
     } else {
         $this->error("非法访问,你不是超级管理员!", U('Index/index'));
     }
 }
コード例 #2
0
 public function updpsd()
 {
     if (isset($_SESSION['name'])) {
         if (!empty($_POST)) {
             //判断密码与确认密码是否一致,不一致就提示再返回,为空也返回
             if (empty($_POST['password']) || empty($_POST['password0'])) {
                 $this->error('新密码不能为空!', U('index'));
             }
             if ($_POST['password'] != $_POST['password0']) {
                 $this->error('密码与确认密码不一致!', U('index'));
             }
             //添加当前用户的id,name值到$_POST
             $_POST['id'] = $_SESSION['id'];
             $_POST['name'] = $_SESSION['name'];
             //将确认密码unset掉
             unset($_POST['password0']);
             //密码要进行MD5加密
             $_POST['password'] = MD5($_POST['password']);
             $Manager = new \Model\ManagerModel();
             $Manager->create();
             $z = $Manager->save();
             if (!$z) {
                 $this->error($Manager->getError() . '!', U('index'));
             } else {
                 $this->success("修改密码成功!", U('index'));
             }
         } else {
             $this->assign('id', $_SESSION['id']);
             $this->assign('name', $_SESSION['name']);
             $this->assign('role', $_SESSION['role']);
             $front = D("Front");
             $fid = 1;
             $resultByFront = $front->where('fid = ' . $fid)->find();
             $this->assign('resultByFront', $resultByFront);
             $this->display();
         }
     } else {
         $this->error("非法访问,请登录后重试!", U('Login'));
     }
 }