1) { LOG_ERROR($db_link, "Mac $mac already exists in this subnet! Skip creating $ip [$mac] auth_id: ".$mac_exists['2']); header("Location: " . $_SERVER["REQUEST_URI"]); exit; } $range = cidrToRange($ip); $first_user_ip = $range[0]; $last_user_ip = $range[1]; $cidr = $range[2][1]; if (isset($cidr) and $cidr < 32) { $ip = $first_user_ip . '/' . $cidr; } else { $ip = $first_user_ip; } $ip_aton = ip2long($first_user_ip); $ip_aton_end = ip2long($last_user_ip); list ($parent_id) = mysqli_fetch_array(mysqli_query($db_link, "Select user_id from User_auth where id=$id")); list ($lid) = mysqli_fetch_array(mysqli_query($db_link, "Select user_id from User_auth where ($ip_aton BETWEEN ip_int and ip_int_end) and id<>$id and deleted=0")); if (isset($lid) and ($lid != $parent_id)) { list ($lname) = mysqli_fetch_array(mysqli_query($db_link, "Select login from User_list where id=$lid")); $msg_error = "$ip $msg_exists Принадлежит пользователю $lname."; unset($_POST); } else { $new[ip] = $ip; $new[ip_int] = $ip_aton; $new[ip_int_end] = $ip_aton_end; $new[mac] = mac_dotted($_POST["f_mac"]); $new[clientid] = $_POST["f_clientid"]; $new[comments] = $_POST["f_comments"]; $f_dnsname=trim($_POST["f_dns_name"]); if (!empty($f_dnsname) and checkValidHostname($f_dnsname) and checkUniqHostname($db_link,$id,$f_dnsname)) { $new[dns_name] = $f_dnsname; } if (empty($f_dnsname)) { $new[dns_name] = ''; } $new[host_model] = $_POST["f_host_model"]; $new[save_traf] = $_POST["f_save_traf"] * 1; $new[dhcp_acl] = trim($_POST["f_acl"]); if ($default_user_id == $parent_id or $hotspot_user_id == $parent_id) { $new[nagios_handler] = ''; $new[enabled] = 0; $new[link_check] = 0; $new[nagios] = 0; $new[blocked] = 0; $new[day_quota] = 0; $new[month_quota] = 0; $new[queue_id] = 0; $new[filter_group_id] = 0; } else { $new[nagios_handler] = $_POST["f_handler"]; $new[enabled] = $_POST["f_enabled"] * 1; $new[link_check] = $_POST["f_link"] * 1; $new[nagios] = $_POST["f_nagios"] * 1; $new[dhcp] = $_POST["f_dhcp"] * 1; $new[blocked] = $_POST["f_blocked"] * 1; $new[day_quota] = $_POST["f_day_q"] * 1; $new[month_quota] = $_POST["f_month_q"] * 1; $new[queue_id] = $_POST["f_queue_id"] * 1; $new[filter_group_id] = $_POST["f_group_id"] * 1; } $changes = get_diff_rec($db_link,"User_auth","id='$id'", $new, 1); if (!empty($changes)) { LOG_WARNING($db_link,"Изменен адрес доступа! Список изменений: $changes"); } update_record($db_link, "User_auth", "id='$id'", $new); } } else { $msg_error = "$msg_ip_error xxx.xxx.xxx.xxx/xx"; } header("Location: " . $_SERVER["REQUEST_URI"]); } if (isset($_POST["moveauth"]) and !$old_auth_info[deleted]) { $new[user_id] = $_POST["new_parent"]; $changes = get_diff_rec($db_link,"User_auth","id='$id'", $new, 1); if (!empty($changes)) { LOG_WARNING($db_link,"Адрес доступа перемещён к другому пользователю! Применено: $changes"); } update_record($db_link, "User_auth", "id='$id'", $new); header("Location: " . $_SERVER["REQUEST_URI"]); } if (isset($_POST["recovery"])) { $ip = trim($_POST["f_ip"]); if (checkValidIp($ip)) { $range = cidrToRange($ip); $first_user_ip = $range[0]; $last_user_ip = $range[1]; $cidr = $range[2][1]; if (isset($cidr) and $cidr < 32) { $ip = $first_user_ip . '/' . $cidr; } else { $ip = $first_user_ip; } $ip_aton = ip2long($first_user_ip); $ip_aton_end = ip2long($last_user_ip); list ($parent_id) = mysqli_fetch_array(mysqli_query($db_link, "Select user_id from User_auth where id=$id")); list ($lid) = mysqli_fetch_array(mysqli_query($db_link, "Select user_id from User_auth where ($ip_aton BETWEEN ip_int and ip_int_end) and id<>$id and deleted=0")); if (isset($lid) and ($lid != $parent_id)) { list ($lname) = mysqli_fetch_array(mysqli_query($db_link, "Select login from User_list where id=$lid")); $msg_error = "$ip $msg_exists Принадлежит пользователю $lname."; unset($_POST); } else { $new[deleted] = 0; if ($default_user_id == $parent_id or $hotspot_user_id == $parent_id) { $new[nagios_handler] = ''; $new[enabled] = 0; $new[link_check] = 0; $new[nagios] = 0; $new[blocked] = 0; $new[day_quota] = 0; $new[month_quota] = 0; $new[queue_id] = 0; $new[filter_group_id] = 0; } else { $new[nagios_handler] = $_POST["f_handler"]; $new[enabled] = $_POST["f_enabled"] * 1; $new[link_check] = $_POST["f_link"] * 1; $new[nagios] = $_POST["f_nagios"] * 1; $new[dhcp] = $_POST["f_dhcp"] * 1; $new[blocked] = $_POST["f_blocked"] * 1; $new[day_quota] = $_POST["f_day_q"] * 1; $new[month_quota] = $_POST["f_month_q"] * 1; $new[queue_id] = $_POST["f_queue_id"] * 1; $new[filter_group_id] = $_POST["f_group_id"] * 1; } $changes = get_diff_rec($db_link,"User_auth","id='$id'", $new, 1); if (!empty($changes)) { LOG_WARNING($db_link,"Восстановлен адрес доступа! Применено: $changes"); } update_record($db_link, "User_auth", "id='$id'", $new); } } else { $msg_error = "$msg_ip_error xxx.xxx.xxx.xxx/xx"; } header("Location: " . $_SERVER["REQUEST_URI"]); } unset($_POST); require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php"); $sSQL = "SELECT * FROM User_auth WHERE id=$id"; $auth_info = get_record_sql($db_link, $sSQL); $parent_name = get_login($db_link, $auth_info[user_id]); if ($auth_info[dhcp_time] == '0000-00-00 00:00:00') { $dhcp_str = ''; } else { $dhcp_str = $auth_info[dhcp_time] . " (" . $auth_info[dhcp_action] . ")"; } if ($auth_info[last_found] == '0000-00-00 00:00:00') { $auth_info[last_found] = ''; } ?>