示例#1
0
 public function aoto_verify()
 {
     //目录
     $directory = substr($this->ci_obj->router->fetch_directory(), 0, -1);
     //控制器
     $controller = $this->ci_obj->router->fetch_class();
     //方法
     $function = $this->ci_obj->router->fetch_method();
     //UURI(MD5)
     $this->ci_obj->uuri = md5($directory . $controller . $function);
     if ($directory != "") {
         //当非主目录
         if ($this->ci_obj->config->item('rbac_auth_on')) {
             //开启认证
             if (!in_array($directory, $this->ci_obj->config->item('rbac_notauth_dirc'))) {
                 //需要验证的目录
                 //验证是否登录
                 //echo rbac_conf(array('INFO','id'));
                 if (!rbac_conf(array('INFO', 'id'))) {
                     error_redirct($this->ci_obj->config->item('rbac_auth_gateway'), "请先登录!");
                     die;
                 }
                 if ($this->ci_obj->config->item('rbac_auth_type') == 2) {
                     //若为实时认证
                     $this->ci_obj->load->model("rbac_model");
                     //检测用户状态
                     $STATUS = $this->ci_obj->rbac_model->check_user_by_id(rbac_conf(array('INFO', 'id')));
                     if ($STATUS == FALSE) {
                         error_redirct($this->config->item('rbac_auth_gateway'), $STATUS);
                     }
                     //ACL重新赋权
                     $this->ci_obj->rbac_model->get_acl(rbac_conf(array('INFO', 'role_id')));
                 }
                 //验证ACL权限
                 if (!rbac_conf(array('ACL', $directory, $controller, $function))) {
                     error_redirct("", "无权访问此节点!(" . $directory . "/" . $controller . "/" . $function . ")");
                     die;
                 }
             }
         }
         //已登录且有权限,获取左侧菜单
         if ($this->ci_obj->config->item('rbac_auth_type') == 2) {
             //若为实时认证
             $this->ci_obj->get_menu = $this->get_menu();
         } else {
             if (rbac_conf(array('MENU'))) {
                 $this->ci_obj->get_menu = rbac_conf(array('MENU'));
             } else {
                 rbac_conf(array('MENU'), $this->get_menu());
                 $this->ci_obj->get_menu = rbac_conf(array('MENU'));
             }
         }
     }
 }
示例#2
0
文件: index.php 项目: jsbj708/mifan
 /**
  * 用户登录
  */
 public function login()
 {
     $this->load->model("rbac_model");
     $username = $this->input->post('username');
     $password = $this->input->post('password');
     if ($username && $password) {
         $STATUS = $this->rbac_model->check_user($username, md5($password));
         if ($STATUS === TRUE) {
             success_redirct($this->config->item('rbac_default_index'), "登录成功!");
         } else {
             error_redirct($this->config->item('rbac_auth_gateway'), $STATUS);
             die;
         }
     } else {
         $this->load->view("login");
     }
 }
示例#3
0
 public function edit()
 {
     $this->view_override = FALSE;
     if ($this->input->post()) {
         //表单验证
         $this->load->library('form_validation');
         if ($this->form_validation->run('tools/setup/edit') === FALSE) {
             error_redirct("tools/setup/edit/?dwz=" . $_POST['dwz']);
         } else {
             $this->tools_setup_model->update_data($this->input->post(), $this->fid);
             success_redirct("tools/setup/pannel/?dwz=" . $_POST['dwz']);
         }
     } else {
         if ($_GET['dwz']) {
             $data = $this->tools_setup_model->get_info($this->fid);
             $this->load->view("tools/setup/edit", $data);
         }
     }
 }
示例#4
0
 /**
  * 修改面板
  */
 public function edit()
 {
     $this->view_override = FALSE;
     if (!empty($_POST)) {
         //表单验证
         $this->load->library('form_validation');
         if ($this->form_validation->run('tools/tasks/edit') === FALSE) {
             error_redirct("tools/tasks/edit/?dwz=" . $_POST['dwz']);
         } else {
             $this->tools_task_model->update_data($this->fid, $_POST['borad'], $_POST['task']);
             success_redirct("tools/tasks/pannel/?dwz=" . $_POST['dwz']);
         }
     } else {
         if ($_GET['dwz']) {
             $data = $this->tools_task_model->get_info($this->fid);
             $this->load->view("tools/tasks/edit", $data);
         }
     }
 }
示例#5
0
文件: member.php 项目: jsbj708/mifan
 /**
  * 人员删除
  * @param number $id
  */
 public function delete($id)
 {
     $query = $this->db->query("SELECT * FROM rbac_user WHERE id = " . $id);
     $data = $query->row_array();
     if ($data) {
         if ($this->input->post()) {
             $verfiy = $this->input->post("verfiy");
             if ($verfiy) {
                 $sql = "DELETE FROM rbac_user WHERE id = " . $id . " ";
                 $this->db->query($sql);
                 success_redirct("manage/member/index", "用户删除成功");
             } else {
                 error_redirct("manage/member/index", "操作失败");
             }
         }
         $this->load->view("manage/member/delete", array("data" => $data));
     } else {
         error_redirct("manage/member/index", "未找到此用户");
     }
 }
示例#6
0
文件: node.php 项目: ishawge/SmartCI
 /**
  * 修改节点
  * @param unknown $id
  */
 public function edit($id)
 {
     $query = $this->db->query("SELECT * FROM rbac_node WHERE id = " . $id);
     $data = $query->row_array();
     if ($data) {
         if ($this->input->post()) {
             $memo = $this->input->post("memo");
             $status = $this->input->post("status") == 1 ? 1 : 0;
             if ($memo) {
                 $sql = "UPDATE rbac_node set `memo`='{$memo}',`status` = '{$status}' WHERE id = {$id}";
                 $this->db->query($sql);
                 success_redirct("manage/node/index", "节点修改成功");
             } else {
                 error_redirct('', "信息填写不全!");
             }
         }
         $this->load->view("manage/node/edit", array('data' => $data));
     } else {
         error_redirct("manage/node/index", "未找到此节点");
     }
 }
示例#7
0
文件: menu.php 项目: jsbj708/mifan
 /**
  * 菜单修改
  */
 public function edit($id, $level, $p_id = "NULL")
 {
     if ($this->input->post()) {
         $id = $this->input->post("id");
         $title = $this->input->post("title");
         $sort = $this->input->post("sort");
         $node = $this->input->post("node");
         $level = $this->input->post("level");
         if ($id && $level) {
             if ($title) {
                 $p_id = $this->input->post("p_id") == "NULL" ? "p_id = NULL" : "p_id='{$p_id}'";
                 $status = $this->input->post("status") == "" ? "status='0'" : "status='1'";
                 $sql = "UPDATE rbac_menu SET {$status},title='{$title}',sort='{$sort}',node_id='{$node}',{$p_id} WHERE id = '{$id}'";
                 $this->db->query($sql);
                 success_redirct("manage/menu/index", "菜单修改成功!");
             } else {
                 error_redirct("", "标题不能为空!");
             }
         } else {
             error_redirct("", "参数不正确!");
         }
     }
     $query = $this->db->query("SELECT rm.id,rm.title,rm.node_id,rm.p_id,rm.sort,rm.status,rn.memo FROM rbac_menu rm left join rbac_node rn on rm.node_id = rn.id WHERE rm.id =" . $id);
     $data = $query->row_array();
     if ($data) {
         $rbac_where = "";
         $node_hidden_array = $this->config->item('rbac_manage_node_hidden');
         if (!empty($node_hidden_array)) {
             foreach ($node_hidden_array as $node_hidden) {
                 $rbac_where .= "AND dirc != '{$node_hidden}' ";
             }
         }
         $node_query = $this->db->query("SELECT * FROM rbac_node WHERE status = 1 {$rbac_where} ORDER BY dirc,cont");
         $node_data = $node_query->result();
         $this->load->view("manage/menu/edit", array("data" => $data, "node" => $node_data, "level" => $level, "p_id" => $p_id));
     } else {
         error_redirct("manage/menu/index", "未找到此菜单");
     }
 }
示例#8
0
文件: Role.php 项目: huzs1622/CI-RBAC
 /**
  * 角色赋权
  * @param number $id
  */
 public function action($id, $node_id = NULL)
 {
     if (!$id) {
         error_redirct("manage/role/index", "未找到此角色");
     }
     if ($node_id != NULL) {
         $query = $this->db->query("SELECT node_id FROM rbac_auth WHERE node_id= {$node_id} AND role_id={$id}");
         $data = $query->row_array();
         if ($data) {
             $sql = "DELETE FROM rbac_auth WHERE node_id= {$node_id} AND role_id={$id}";
         } else {
             $sql = "INSERT INTO rbac_auth (`node_id`,`role_id`) values('{$node_id}','{$id}')";
         }
         $this->db->query($sql);
         success_redirct("", "节点操作成功", 1);
     }
     $rbac_where = "";
     $node_hidden_array = $this->config->item('rbac_manage_node_hidden');
     if (!empty($node_hidden_array)) {
         $rbac_where = "WHERE ";
         foreach ($node_hidden_array as $node_hidden) {
             $rbac_where .= "dirc != '{$node_hidden}' AND ";
         }
         $rbac_where = substr($rbac_where, 0, -4);
     }
     $query = $this->db->query("SELECT * FROM rbac_node {$rbac_where} ORDER BY dirc,cont,func");
     $data = $query->result();
     foreach ($data as $vo) {
         $node_list[$vo->dirc][$vo->cont][$vo->func] = $vo;
     }
     $query = $this->db->query("SELECT id,dirc,cont,func FROM `rbac_node` WHERE id in (SELECT node_id FROM `rbac_auth` WHERE role_id = " . $id . ")");
     $role_data = $query->result();
     foreach ($role_data as $vo) {
         $role_node_list[$vo->dirc][$vo->cont][$vo->func] = TRUE;
     }
     if (!isset($role_node_list)) {
         $role_node_list = NULL;
     }
     $this->load->view('manage/role/action', array('role_id' => $id, 'node' => $node_list, 'rnl' => $role_node_list));
 }