$d_ports) { $start_port = $d_ports + 1; LOG_DEBUG($db_link, "Device id: $id add connection for port from $start_port to $sw_ports."); for ($port = $start_port; $port <= $sw_ports; $port ++) { $new[device_id] = $id; $new[snmp_index] = $port; $new[port] = $port; insert_record($db_link, "device_ports", $new); } } if ($sw_ports < $d_ports) { LOG_DEBUG($db_link, "Device id: $id remove connection for port from $d_ports to $sw_ports"); for ($port = $d_ports; $port > $sw_ports; $port --) { $port_id = get_id_record($db_link, 'device_ports', "device_id='" . $id . "' and port='" . $port . "'"); if ($port_id) { delete_record($db_link, "device_ports", "id='" . $port_id . "'"); delete_record($db_link, "connections", "port_id='" . $port_id . "'"); } else { LOG_DEBUG($db_link, "Device id: $id port_id not found for port: $port!"); } } } } unset($new); $new[device_name] = substr($_POST["f_device_name"], 0, 50); $new[device_model] = substr($_POST["f_device_model"], 0, 50); $new[comment] = $_POST["f_comment"]; $new[ip] = substr($_POST["f_ip"], 0, 15); $new[mac] = mac_dotted($_POST["f_mac"]); $new[snmp_version] = $_POST["f_snmp_version"] * 1; $new[community] = substr($_POST["f_community"], 0, 50); $new[rw_community] = substr($_POST["f_rw_community"], 0, 50); $new[queue_enabled] = $_POST["f_queue_enabled"] * 1; $new[connected_user_only] = $_POST["f_connected_user_only"] * 1; $new[snmp3_user_rw] = substr($_POST["f_snmp3_user_rw"], 0, 20); $new[snmp3_user_ro] = substr($_POST["f_snmp3_user_ro"], 0, 20); $new[snmp3_user_rw_password] = substr($_POST["f_snmp3_user_rw_password"], 0, 20); $new[snmp3_user_ro_password] = substr($_POST["f_snmp3_user_ro_password"], 0, 20); $new[fdb_snmp_index] = $_POST["f_fdb_snmp"]; $new[discovery] = $_POST["f_discovery"]; $new[dhcp] = $_POST["f_dhcp"] * 1; $new[internet_gateway] = $_POST["f_gateway"] * 1; $new[wan_int] = $_POST["f_wan"]; $new[lan_int] = $_POST["f_lan"]; $new[building_id] = $_POST["f_building_id"] * 1; $new[user_id] = $_POST["f_user_id"] * 1; if ($new[internet_gateway]) { $new[is_router] = 1; } else { $new[is_router] = $_POST["f_router"]; } $new[nagios] = $_POST["f_nagios"] * 1; if (! $new[nagios]) { $new[nagios_status] = 'UP'; } $new[vendor_id] = $_POST["f_vendor_id"] * 1; $new[port_count] = $sw_ports; update_record($db_link, "devices", "id='$id'", $new); header("Location: " . $_SERVER["REQUEST_URI"]); } if (isset($_POST["undelete"]) and isset($id)) { unset($new); $new[deleted] = 0; LOG_INFO($db_link, "Recovery deleted device id: $id"); update_record($db_link, "devices", "id='$id'", $new); header("Location: " . $_SERVER["REQUEST_URI"]); } $switch=get_record($db_link,'devices',"id=".$id); unset($_POST); require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php"); print_editdevice_submenu($page_url,$id); ?>