fooidfoofoo descbaridbarbar desc
*/
$useract = $_GET['useract'];
if (isset($_POST['useract']))
$useract = $_POST['useract'];
/* USERID must be set no matter whether this is a new entry or an existing entry */
$userid = $_GET['userid'];
if (isset($_POST['userid']))
$userid = $_POST['userid'];
/* ID is only set if the user wants to edit an existing entry */
$id = $_GET['id'];
if (isset($_POST['id']))
$id = $_POST['id'];
if (empty($config['system']['user'][$userid])) {
pfSenseHeader("system_usermanager.php?id={$userid}&act={$_GET['useract']}");
exit;
}
if (!is_array($config['system']['user'][$userid]['priv'])) {
$config['system']['user'][$userid]['priv'] = array();
}
$t_privs = &$config['system']['user'][$userid]['priv'];
if (isset($id) && $t_privs[$id]) {
$pconfig['pid'] = $t_privs[$id]['id'];
$pconfig['pname'] = $t_privs[$id]['name'];
$pconfig['descr'] = $t_privs[$id]['descr'];
} else {
$pconfig['pid'] = $_GET['pid'];
$pconfig['pname'] = $_GET['pname'];
$pconfig['descr'] = $_GET['descr'];
}
if ($_POST) {
unset($input_errors);
$pconfig = $_POST;
/* input validation */
$reqdfields = explode(" ", "pid pname");
$reqdfieldsn = explode(",", "ID, Privilege Name");
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
/* check for overlaps */
foreach ($t_privs as $priv) {
if (isset($id) && ($t_privs[$id]) && ($t_privs[$id] === $priv)) {
continue;
}
if ($priv['id'] == $pconfig['pid']) {
$input_errors[] = gettext("This privilege ID already exists.");
break;
}
}
if (hasShellAccess($userindex[$userid]['name']) ||
isAllowedToCopyFiles($userindex[$userid]['name'])) {
if (preg_match("/[^a-zA-Z0-9\.\-_]/", $userindex[$userid]['name']))
$input_errors[] = gettext("The username contains invalid characters " .
"((this means this user can't be used to create" .
" a shell account).");
}
/* if this is an AJAX caller then handle via JSON */
if(isAjax() && is_array($input_errors)) {
input_errors2Ajax($input_errors);
exit;
}
if (!$input_errors) {
$priv = array();
$priv['id'] = $pconfig['pid'];
$priv['name'] = $pconfig['pname'];
$priv['descr'] = $pconfig['descr'];
if (isset($id) && $t_privs[$id])
$t_privs[$id] = $priv;
else
$t_privs[] = $priv;
if ($priv['id'] == "hasshell") {
assignUID($user['name']);
assignGID($user['groupname']);
}
write_config();
$retval = 0;
config_lock();
config_unlock();
$savemsg = get_std_save_message($retval);
pfSenseHeader("system_usermanager.php?id={$userid}&act={$useract}");
exit;
}
}
/* if ajax is calling, give them an update message */
if(isAjax())
print_info_box_np($savemsg);
include("head.inc");
/* put your custom HTML head content here */
/* using some of the $pfSenseHead function calls */
$jscriptstr = <<
EOD;
$pfSenseHead->addScript($jscriptstr);
echo $pfSenseHead->getHTML();
?>
">