#!/usr/local/bin/php . All rights reserved. Copyright (C) 2003-2005 Manuel Kasper . All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ require("guiconfig.inc"); $pgtitle = array("System", "Group manager"); // Returns an array of pages with their descriptions function getAdminPageList() { global $g; $tmp = Array(); if ($dir = opendir($g['www_path'])) { while($file = readdir($dir)) { // Make sure the file exists if($file != "." && $file != ".." && $file[0] != '.') { // Is this a .php file? if (fnmatch('*.php',$file)) { // Read the description out of the file $contents = file_get_contents($file); // Looking for a line like: // $pgtitle = array("System", "Group manager"); $offset = strpos($contents,'$pgtitle'); $titlepos = strpos($contents,'(',$offset); $titleendpos = strpos($contents,')',$titlepos); if (($offset > 0) && ($titlepos > 0) && ($titleendpos > 0)) { // Title found, extract it $title = str_replace(',',':',str_replace(array('"'),'',substr($contents,++$titlepos,($titleendpos - $titlepos)))); $tmp[$file] = trim($title); } else { $tmp[$file] = ''; } } } } closedir($dir); // Sets Interfaces:Optional page that didn't read in properly with the above method, // and pages that don't have descriptions. $tmp['interfaces_opt.php'] = "Interfaces: Optional"; $tmp['graph.php'] = "Diagnostics: Interface Traffic"; $tmp['graph_cpu.php'] = "Diagnostics: CPU Utilization"; $tmp['exec.php'] = "Hidden: Exec"; $tmp['exec_raw.php'] = "Hidden: Exec Raw"; $tmp['status.php'] = "Hidden: Detailed Status"; $tmp['uploadconfig.php'] = "Hidden: Upload Configuration"; $tmp['index.php'] = "*Landing Page after Login"; $tmp['system_usermanager.php'] = "*User Password"; $tmp['diag_logs_settings.php'] = "Diagnostics: Logs: Settings"; $tmp['diag_logs_vpn.php'] = "Diagnostics: Logs: PPTP VPN"; $tmp['diag_logs_filter.php'] = "Diagnostics: Logs: Firewall"; $tmp['diag_logs_portal.php'] = "Diagnostics: Logs: Captive Portal"; $tmp['diag_logs_dhcp.php'] = "Diagnostics: Logs: DHCP"; $tmp['diag_logs.php'] = "Diagnostics: Logs: System"; $tmp['interfaces_secondaries.php'] = "Interfaces: Add Secondary IP addresses"; // Add appropriate descriptions for extensions, if they exist if(file_exists("extensions.inc")){ include("extensions.inc"); } asort($tmp); return $tmp; } } // Get a list of all admin pages & Descriptions $pages = getAdminPageList(); if (!is_array($config['system']['group'])) { $config['system']['group'] = array(); } admin_groups_sort(); $a_group = &$config['system']['group']; $id = $_GET['id']; if (isset($_POST['id'])) $id = $_POST['id']; if ($_GET['act'] == "del") { if ($a_group[$_GET['id']]) { $ok_to_delete = true; if (isset($config['system']['user'])) { foreach ($config['system']['user'] as $userent) { if ($userent['groupname'] == $a_group[$_GET['id']]['name']) { $ok_to_delete = false; $input_errors[] = "users still exist who are members of this group!"; break; } } } if ($ok_to_delete) { unset($a_group[$_GET['id']]); write_config(); header("Location: system_groupmanager.php"); exit; } } } if ($_POST) { unset($input_errors); $pconfig = $_POST; /* input validation */ $reqdfields = explode(" ", "groupname"); $reqdfieldsn = explode(",", "Group Name"); do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); if (preg_match("/[^a-zA-Z0-9\.\-_ ]/", $_POST['groupname'])) $input_errors[] = "The group name contains invalid characters."; if (!$input_errors && !(isset($id) && $a_group[$id])) { /* make sure there are no dupes */ foreach ($a_group as $group) { if ($group['name'] == $_POST['groupname']) { $input_errors[] = "Another entry with the same group name already exists."; break; } } } if (!$input_errors) { if (isset($id) && $a_group[$id]) $group = $a_group[$id]; $group['name'] = $_POST['groupname']; $group['description'] = $_POST['description']; unset($group['pages']); foreach ($pages as $fname => $title) { $identifier = str_replace('.php','',$fname); if ($_POST[$identifier] == 'yes') { $group['pages'][] = $fname; } } if (isset($id) && $a_group[$id]) $a_group[$id] = $group; else $a_group[] = $group; write_config(); header("Location: system_groupmanager.php"); exit; } } ?>
    'system_usermanager.php', 'Groups' => 'system_groupmanager.php'); dynamic_tab_menu($tabs); ?>
Group name
Description
Group description, for your own information only

 Select that pages that this group may access. Members of this group will be able to perform all actions that
  are possible from each individual web page. Ensure you set access levels appropriately.

 Note: Pages marked with an * are strongly recommended for every group.
$title) { $identifier = str_replace('.php','',$fname); ?>
  Page Description Filename
>
 
Group name Description Pages Accessible
      edit group  delete group
add group
Additional webGUI admin groups can be added here. Each group can be restricted to specific portions of the webGUI. Individually select the desired web pages each group may access. For example, a troubleshooting group could be created which has access only to selected Status and Diagnostics pages.