Пример #1
0
 public function editAdmin()
 {
     //edit admin
     if (!($id = intval($_GET['id']))) {
         showmsg($this->MyLang['param_error']);
         die;
     }
     if ($_SERVER["REQUEST_METHOD"] == "GET") {
         $data = $this->admin_mod->get_one($id);
         $roles = $this->admin_role_mod->get_all();
         $data['roles'] = $roles;
         $data['platforms'] = $this->admin_platform_mod->getPlatformNames();
         $this->view('admin.form.php', $data);
     } else {
         $data = $_POST;
         unset($data['re_password']);
         $data['dateline'] = time();
         $data['salt'] = 'CwrFTvWR';
         if (!empty($data['password'])) {
             $data['password'] = md532($data['password'], $data['salt']);
         } else {
             unset($data['password']);
         }
         $data['platform_id'] = isset($_POST['platform_id']) ? join(',', $_POST['platform_id']) : '';
         if ($this->admin_mod->update($id, $data)) {
             $link[0]['link_url'] = 'index.php?app=admin';
             $link[0]['link_name'] = $this->MyLang['back_list'];
             showmsg($this->MyLang['save_success'], $link);
         } else {
             showmsg($this->MyLang['save_failed']);
         }
     }
 }
Пример #2
0
 public function login()
 {
     if (isset($_POST['submit'])) {
         $username = trim(addslashes($this->input->post('username')));
         $password = $this->input->post('password');
         if (empty($username)) {
             showmsg('请输入用户名');
         }
         if (empty($password)) {
             showmsg('请输入密码');
         }
         //以用户名查信息
         $data = $this->admin_mod->get_by_username($username);
         if (empty($data)) {
             showmsg('用户输入有误');
         }
         if (md532($password, $data['salt']) != $data['password']) {
             showmsg('密码不正确');
         }
         //登陆成功
         $session = array('user_id' => $data['id'], 'user_name' => $data['username'], 'login_time' => $this->time, 'login_ip' => $this->input->ip_address(), 'last_login_time' => $data['login_time'], 'last_login_ip' => $data['login_ip']);
         $this->session->set_userdata($session);
         $this->role_info = $this->__setCurrentUserRole($data);
         //更新数据库
         $udata = array('login_time' => $this->time, 'login_ip' => $this->input->ip_address());
         $this->admin_mod->update($data['id'], $udata);
         $link[0]['link_url'] = 'index.php';
         $link[0]['link_name'] = '后台管理首页';
         showmsg('登陆成功', $link);
     }
     $this->load->view('admin/common/login');
 }