getContext()->getRequest(); $admin_name = $this->getContext()->getStorage()->read('admin_id'); // 管理员账号 $rew = ""; // 查询角色 $sql = "select * from lkt_role"; $r_1 = $db->select($sql); if($r_1){ foreach ($r_1 as $k => $v){ $rew .= ""; } } $request->setAttribute("list",$rew); return View :: INPUT; } public function execute(){ $db = DBAction::getInstance(); $request = $this->getContext()->getRequest(); // 接收数据 $admin_id = $this->getContext()->getStorage()->read('admin_id'); $name = addslashes(trim($request->getParameter('name'))); // 管理员账号 $password = md5(addslashes(trim($request->getParameter('password')))); // 密码 $password1 = md5(addslashes(trim($request->getParameter('password1')))); // 确认密码 $role = addslashes(trim($request->getParameter('role'))); // 角色 $sql = "select id from lkt_admin where name = '$admin_id'"; $r_1 = $db->select($sql); $sid = $r_1[0]->id; //检查是否重复 $s = "select * from lkt_admin where name = '$name'"; $sr = $db->insert($s); if($sr && count($sr) > 0){ header("Content-type:text/html;charset=utf-8"); echo ""; return $this->getDefaultView(); }else{ if($password == $password1){ if($role == 0){ header("Content-type:text/html;charset=utf-8"); echo ""; return $this->getDefaultView(); }else{ // $sql = "insert into lkt_admin(sid,name,password,role,status,add_date,recycle) values('$sid','$name','$password','$role',2,CURRENT_TIMESTAMP,0)"; $r = $db->insert($sql); if($r == -1){ $db->admin_record($admin_id,'添加管理员失败',1); header("Content-type:text/html;charset=utf-8"); echo ""; return $this->getDefaultView(); }else{ $db->admin_record($admin_id,'添加管理员'.$name,1); header("Content-type:text/html;charset=utf-8"); echo ""; return $this->getDefaultView(); } } }else{ header("Content-type:text/html;charset=utf-8"); echo ""; return $this->getDefaultView(); } } return; } public function getRequestMethods(){ return Request :: POST; } } ?>