trim(getPOST("f_group_name", null, $ou_info['ou_name'])), 'default_users' => (int)getPOST("f_default", null, 0), 'default_hotspot' => (int)getPOST("f_default_hotspot", null, 0), 'nagios_dir' => trim(getPOST("f_nagios", null, '')), 'nagios_host_use' => trim(getPOST("f_nagios_host", null, '')), 'nagios_ping' => trim(getPOST("f_nagios_ping", null, 0)), 'nagios_default_service' => trim(getPOST("f_nagios_service", null, '')), 'queue_id' => (int)getPOST("f_queue_id", null, 0), 'filter_group_id' => (int)getPOST("f_filter_group_id", null, 0), 'enabled' => (int)getPOST("f_enabled", null, 0), 'dynamic' => (int)getPOST("f_dynamic", null, 0) ]; // Обработка life_duration if ($new['dynamic']) { $tmp_life_duration = str_replace(',', '.', getPOST("f_life_duration", null, 0)); $new['life_duration'] = (!empty($tmp_life_duration) && is_numeric($tmp_life_duration)) ? (float)$tmp_life_duration : 0; } else { $new['life_duration'] = 0; } // Сброс флагов по умолчанию if ($new['default_users']) { update_records($db_link, "ou", "id != ?", ['default_users' => 0], [$id]); } if ($new['default_hotspot']) { update_records($db_link, "ou", "id != ?", ['default_hotspot' => 0], [$id]); } update_record($db_link, "ou", "id = ?", $new, [$id]); header("Location: " . $_SERVER["REQUEST_URI"]); exit; } // Удаление правил авторизации if (getPOST("s_remove") !== null) { $s_id = getPOST("s_id", null, []); if (!empty($s_id) && is_array($s_id)) { foreach ($s_id as $val) { $val = trim($val); if ($val === '') continue; delete_record($db_link, "auth_rules", "id = ?", [(int)$val]); } } header("Location: " . $_SERVER["REQUEST_URI"]); exit; } // Сохранение изменений в правилах if (getPOST("s_save") !== null) { $s_ids = getPOST("s_id", null, []); $n_ids = getPOST("n_id", null, []); $s_types = getPOST("s_type", null, []); $s_rules = getPOST("s_rule", null, []); $s_descriptions = getPOST("s_description", null, []); if (is_array($s_ids) && is_array($n_ids)) { // Преобразуем ID в целые числа $n_ids = array_map('intval', $n_ids); $s_ids = array_map('intval', $s_ids); foreach ($s_ids as $save_id) { if ($save_id <= 0) continue; $idx = array_search($save_id, $n_ids, true); if ($idx === false) continue; // Получаем тип правила $rule_type = (int)($s_types[$idx] ?? 3); // Получаем и очищаем правило $raw_rule = trim($s_rules[$idx] ?? ''); if ($raw_rule === '') continue; $new_rule = $raw_rule; // Валидация в зависимости от типа if ($rule_type == 1) { // IP-адрес if (!checkValidIp($new_rule)) { continue; // пропускаем невалидный IP } } elseif ($rule_type == 2) { // MAC-адрес $normalized_mac = MayBeMac($new_rule); if ($normalized_mac === null) { continue; // пропускаем невалидный MAC } $new_rule = $normalized_mac; } // Для других типов (3 и т.д.) — без валидации $new = [ 'rule_type' => $rule_type, 'rule' => $new_rule, 'description' => trim($s_descriptions[$idx] ?? '') ]; update_record($db_link, "auth_rules", "id = ?", $new, [$save_id]); } } header("Location: " . $_SERVER["REQUEST_URI"]); exit; } // Создание нового правила if (getPOST("s_create") !== null) { $new_rule = trim(getPOST("s_new_rule", null, '')); if ($new_rule !== '') { $rule_type = (int)getPOST("s_new_type", null, 3); if ($rule_type == 1 and !checkValidIp($new_rule)) { header("Location: " . $_SERVER["REQUEST_URI"]); exit; } if ($rule_type == 2 and MayBeMac($new_rule)==null) { header("Location: " . $_SERVER["REQUEST_URI"]); exit; } if ($rule_type == 2) { $new_rule = MayBeMac($new_rule); } $new = [ 'rule_type' => $rule_type, 'rule' => $new_rule, 'ou_id' => $id ]; insert_record($db_link, "auth_rules", $new); } header("Location: " . $_SERVER["REQUEST_URI"]); exit; } require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php"); fix_auth_rules($db_link); ?>
> \n"; print "\n"; if ($ou_info['default_users']) { $cl = "up"; } else { $cl="data"; } print "\n"; if ($ou_info['default_hotspot']) { $cl = "up"; } else { $cl="data"; } print "\n"; print "\n"; ?> \n"; print "\n"; print "\n"; print "\n"; print "\n"; ?> \n"; ?> \n"; ?>
Default Hotspot
"; print_qa_select("f_default",$ou_info['default_users']); print ""; print_qa_select("f_default_hotspot",$ou_info['default_hotspot']); print ""; print_qa_select("f_dynamic",$ou_info['dynamic']); print "
Nagios directory Host template Ping Host service
"; print_qa_select("f_nagios_ping",$ou_info['nagios_ping']); print "


: hotspot => subnet => mac => hostname => default user

"; ?> \n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; } ?>
id
{$row['id']}"; print_qa_rule_select("s_type[]","{$row['rule_type']}"); print "
"; ?>