function admin_login() { if (isset($_POST['dosubmit'])) { $um = new usermodel("admin_user"); //获得post数据 $username = $_POST['username']; $password = $_POST['password']; $verifycode = $_POST['verifycode']; //验证post数据 if (strtolower($_SESSION['verifycode']) != $verifycode) { $this->jump("验证码不正确", 0); } if (empty($username) || empty($password)) { $this->jump("用户名密码为空", 0); } //验证通过 //md5密码验证 $data = $um->excute("select * from admin_user where username='******'"); if ($data[0]["password"] == md5($password)) { $_SESSION['admin_user'] = array("uid" => $data[0]['userid'], "username" => $data[0]['username']); $this->jump("登录成功", 1, "/tcphp/index.php/admin/index/main"); } else { $this->jump("用户名密码错误", 0); } } else { $this->display(); } }
public function rolelists() { $page = isset($_POST['page']) ? intval($_POST['page']) : 1; $rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10; $usermodel = new usermodel("admin_role"); $result["total"] = $usermodel->count(); $offset = $rows * ($page - 1); $data = $usermodel->excute("select roleid,rolename,description,disabled from admin_role\n order by roleid desc limit {$offset},{$rows} "); foreach ($data as $key => $row) { if ($data[$key]['disabled'] == '1') { $data[$key]['disabled'] = '正常'; } else { $data[$key]['disabled'] = '禁用'; } } $result['rows'] = $data; $this->ajaxReturn($result); }
public function useradd() { if (isset($_GET['role'])) { $rolemodel = new rolemodel("admin_role"); $data = $rolemodel->excute("select roleid, rolename from admin_role"); $this->ajaxReturn($data); } elseif (isset($_POST['dosubmit'])) { $username = trim($_POST['username']); $usermodel = new usermodel('admin_user'); $exsituser = $usermodel->excute("select userid from admin_user where username='******' limit 1"); if (!empty($exsituser[0]['userid'])) { $returndata = array("errorMsg" => '用户名重复'); } else { $usermodel->data['lastlogintime'] = time(); $usermodel->data['lastloginip'] = ip(); $usermodel->data['regtime'] = time(); $usermodel->data['regip'] = ip(); if (isset($_POST['username'])) { $usermodel->data['username'] = $_POST['username']; } if (isset($_POST['password'])) { $usermodel->data['password'] = md5($_POST['username']); } if (isset($_POST['email'])) { $usermodel->data['email'] = $_POST['email']; } if (isset($_POST['roleid'])) { $usermodel->data['roleid'] = $_POST['roleid']; } $row = $usermodel->add(); if ($row > 0) { $returndata = array("successMsg" => '用户添加成功'); } else { $returndata = array("errorMsg" => '用户添加失败'); } } $this->ajaxReturn($returndata); } }