unset($input_errors); $pconfig = $_POST; if (isset($_POST['Cancel']) && $_POST['Cancel']) { header("Location: access_users_groups.php"); exit; } // Input validation $reqdfields = explode(" ", "name desc groupid"); $reqdfieldsn = array(gettext("Name"), gettext("Description"), gettext("Group ID")); $reqdfieldst = explode(" ", "string string numeric"); do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); do_input_validation_type($_POST, $reqdfields, $reqdfieldsn, $reqdfieldst, $input_errors); if ($_POST['name'] && !is_domain($_POST['name'])) { $input_errors[] = gettext("The group name contains invalid characters."); } if ($_POST['desc'] && !is_validdesc($_POST['desc'])) { $input_errors[] = gettext("The group description contains invalid characters."); } // Check for name conflicts. Only check if group is created. if (!(isset($uuid) && FALSE !== $cnid) && (is_array($a_group_system) && array_key_exists($_POST['name'], $a_group_system) || is_array($a_group_system) && in_array($_POST['groupid'], $a_group_system) || false !== array_search_ex($_POST['name'], $a_group, "name"))) { $input_errors[] = gettext("This group already exists in the group list."); } // Validate if ID is unique. Only check if user is created. if (!(isset($uuid) && FALSE !== $cnid) && false !== array_search_ex($_POST['groupid'], $a_group, "id")) { $input_errors[] = gettext("The unique group ID is already used."); } if (empty($input_errors)) { $groups = array(); $groups['uuid'] = $_POST['uuid']; $groups['id'] = $_POST['groupid']; $groups['name'] = $_POST['name'];
$pconfig['name'] = ""; $pconfig['address'] = ""; $pconfig['descr'] = ""; } if ($_POST) { unset($input_errors); $pconfig = $_POST; if (isset($_POST['Cancel']) && $_POST['Cancel']) { header("Location: system_hosts.php"); exit; } // Input validation. $reqdfields = explode(" ", "name address"); $reqdfieldsn = array(gettext("Hostname"), gettext("IP address")); do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); if ($_POST['name'] && !is_validdesc($_POST['name'])) { $input_errors[] = gettext("The host name contain invalid characters."); } if ($_POST['address'] && !is_ipaddr($_POST['address'])) { $input_errors[] = gettext("A valid IP address must be specified."); } // Check for duplicates. $index = array_search_ex($_POST['name'], $a_hosts, "name"); if (FALSE !== $index) { if (!(FALSE !== $cnid && $a_hosts[$cnid]['uuid'] === $a_hosts[$index]['uuid'])) { $input_errors[] = gettext("An host with this name already exists."); } } if (empty($input_errors)) { $host = array(); $host['uuid'] = $_POST['uuid'];