$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=? and port=?", [ $id, $port ]); if ($port_id) { delete_record($db_link, "device_ports", "id=?" ,[ $port_id ]); run_sql($db_link, "DELETE FROM connections WHERE port_id=?", [ $port_id ]); } else { LOG_DEBUG($db_link, "Device id: $id port_id not found for port: $port!"); } } } } unset($new); if (isset($_POST["f_ip"])) { $new['ip'] = $_POST["f_ip"]; $new['ip_int'] = ip2long($new['ip']); } $cur_device = get_record_sql($db_link, "SELECT * FROM devices WHERE id=?", [ $id ]); //main device info if (!empty($new['ip'])) { $cur_auth = get_record_sql($db_link, "SELECT * FROM user_auth WHERE deleted=0 AND ip=?",[ $new['ip'] ]); } if (isset($_POST["f_device_model_id"])) { $new['device_model_id'] = $_POST["f_device_model_id"] * 1; $new['vendor_id'] = get_device_model_vendor($db_link, $new['device_model_id']); } if (isset($_POST["f_port_count"])) { $new['port_count'] = $sw_ports; } if (isset($_POST["f_devtype_id"])) { $new['device_type'] = $_POST["f_devtype_id"] * 1; } if (isset($_POST["f_description"])) { $new['description'] = $_POST["f_description"]; } if (isset($_POST["f_SN"])) { $new['SN'] = $_POST["f_SN"]; } if (isset($_POST["f_firmware"])) { $new['firmware'] = $_POST["f_firmware"]; } //snmp if (isset($_POST["f_snmp_version"])) { $new['snmp_version'] = $_POST["f_snmp_version"] * 1; } if (isset($_POST["f_community"])) { $new['community'] = substr($_POST["f_community"], 0, 50); } if (isset($_POST["f_snmp3_auth_proto"])) { $new['snmp3_auth_proto'] = trim(substr($_POST["f_snmp3_auth_proto"], 0, 10)); } if (isset($_POST["f_snmp3_priv_proto"])) { $new['snmp3_priv_proto'] = trim(substr($_POST["f_snmp3_priv_proto"], 0, 10)); } if (isset($_POST["f_rw_community"])) { $new['rw_community'] = substr($_POST["f_rw_community"], 0, 50); } if (isset($_POST["f_snmp3_user_rw"])) { $new['snmp3_user_rw'] = substr($_POST["f_snmp3_user_rw"], 0, 20); } if (isset($_POST["f_snmp3_user_ro"])) { $new['snmp3_user_ro'] = substr($_POST["f_snmp3_user_ro"], 0, 20); } if (isset($_POST["f_snmp3_user_rw_password"])) { $new['snmp3_user_rw_password'] = substr($_POST["f_snmp3_user_rw_password"], 0, 20); } if (isset($_POST["f_snmp3_user_ro_password"])) { $new['snmp3_user_ro_password'] = substr($_POST["f_snmp3_user_ro_password"], 0, 20); } //acl & configuration options if (isset($_POST["f_queue_enabled"])) { $new['queue_enabled'] = $_POST["f_queue_enabled"] * 1; } if (isset($_POST["f_connected_user_only"])) { $new['connected_user_only'] = $_POST["f_connected_user_only"] * 1; } if (isset($_POST["f_dhcp"])) { $new['dhcp'] = $_POST["f_dhcp"] * 1; } if (isset($_POST["f_user_acl"])) { $new['user_acl'] = $_POST["f_user_acl"] * 1; } //interfaces if (isset($_POST["f_wan"])) { $new['wan_int'] = $_POST["f_wan"]; } if (isset($_POST["f_lan"])) { $new['lan_int'] = $_POST["f_lan"]; } //location if (isset($_POST["f_building_id"])) { $new['building_id'] = $_POST["f_building_id"] * 1; } //access if (isset($_POST["f_login"])) { $new['login'] = $_POST["f_login"]; } if (!empty($_POST["f_password"])) { if (!preg_match('/^\*+$/', $_POST["f_password"])) { $new['password'] = crypt_string($_POST["f_password"]); } } if (isset($_POST["f_protocol"])) { $new['protocol'] = $_POST["f_protocol"] * 1; } if (isset($_POST["f_control_port"])) { $new['control_port'] = $_POST["f_control_port"] * 1; } if (isset($_POST["f_save_netflow"])) { $new['netflow_save'] = $_POST["f_save_netflow"] * 1; } //discovery if (isset($_POST["f_discovery"])) { $new['discovery'] = $_POST["f_discovery"]; } //nagios if (isset($_POST["f_nagios"])) { $new['nagios'] = $_POST["f_nagios"] * 1; if ($new['nagios'] == 0) { $new['nagios_status'] = 'UP'; } } else { if (!empty($cur_auth)) { $new['nagios'] = 0; $new['nagios_status'] = $cur_auth['nagios_status']; } } if ($new['device_type'] == 0 or $new['protocol']<0) { $new['queue_enabled'] = 0; $new['connected_user_only'] = 1; $new['user_acl'] = 0; } update_record($db_link, "devices", "id=?", $new, [ $id ]); header("Location: " . $_SERVER["REQUEST_URI"]); exit; } $device = get_record($db_link, 'devices', "id=?" ,[ $id]); $user_info = get_record_sql($db_link, "SELECT * FROM user_list WHERE id=?", [ $device['user_id'] ]); unset($_POST); require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php"); print_device_submenu($page_url); print_editdevice_submenu($page_url, $id, $device['device_type'], $user_info['login']); ?>
'; } } ?>