$alert_type, 'al_field1' => $al_field1, 'al_field2' => $al_field2, 'al_field3' => $al_field3, 'description' => $description, 'agent' => $source_ip, 'custom_oid' => $custom_value, 'oid' => $oid, 'time_threshold' => $time_threshold, 'max_alerts' => $max_alerts, 'min_alerts' => $min_alerts, 'priority' => $priority, '_snmp_f1_' => $custom_oid_data_1, '_snmp_f2_' => $custom_oid_data_2, '_snmp_f3_' => $custom_oid_data_3, '_snmp_f4_' => $custom_oid_data_4, '_snmp_f5_' => $custom_oid_data_5, '_snmp_f6_' => $custom_oid_data_6, 'trap_type' => $trap_type, 'single_value' => $single_value); $result = db_process_sql_insert('talert_snmp', $values); if (!$result) { db_pandora_audit("SNMP management", "Fail try to create snmp alert"); ui_print_error_message(__('There was a problem creating the alert')); } else { db_pandora_audit("SNMP management", "Create snmp alert #$result"); ui_print_success_message(__('Successfully created')); } } else { $sql = sprintf ("UPDATE talert_snmp SET priority = %d, id_alert = %d, al_field1 = '%s', al_field2 = '%s', al_field3 = '%s', description = '%s', agent = '%s', custom_oid = '%s', oid = '%s', time_threshold = %d, max_alerts = %d, min_alerts = %d, _snmp_f1_ = '%s', _snmp_f2_ = '%s', _snmp_f3_ = '%s', _snmp_f4_ = '%s', _snmp_f5_ = '%s', _snmp_f6_ = '%s', trap_type = %d, single_value = '%s' WHERE id_as = %d", $priority, $alert_type, $al_field1, $al_field2, $al_field3, $description, $source_ip, $custom_value, $oid, $time_threshold, $max_alerts, $min_alerts, $custom_oid_data_1, $custom_oid_data_2, $custom_oid_data_3, $custom_oid_data_4, $custom_oid_data_5, $custom_oid_data_6, $trap_type, $single_value, $id_as); $result = db_process_sql ($sql); if (!$result) { db_pandora_audit("SNMP management", "Fail try to update snmp alert #$id_as"); ui_print_error_message(__('There was a problem updating the alert')); } else { db_pandora_audit("SNMP management", "Update snmp alert #$id_as"); ui_print_success_message(__('Successfully updated')); } } } else { ui_print_page_header (__('SNMP Console')." » ".__('Alert overview'), "images/computer_error.png", false, "snmp_alert", true); } // From variable init // ================== if ((isset ($_GET["update_alert"])) && ($_GET["update_alert"] != -1)) { $id_as = (int) get_parameter_get ("update_alert", -1); $alert = db_get_row ("talert_snmp", "id_as", $id_as); $id_as = $alert["id_as"]; $source_ip = $alert["agent"]; $alert_type = $alert["id_alert"]; $description = $alert["description"]; $oid = $alert["oid"]; $custom_value = $alert["custom_oid"]; $time_threshold = $alert["time_threshold"]; $al_field1 = $alert["al_field1"]; $al_field2 = $alert["al_field2"]; $al_field3 = $alert["al_field3"]; $max_alerts = $alert["max_alerts"]; $min_alerts = $alert["min_alerts"]; $priority = $alert["priority"]; $custom_oid_data_1 = $alert["_snmp_f1_"]; $custom_oid_data_2 = $alert["_snmp_f2_"]; $custom_oid_data_3 = $alert["_snmp_f3_"]; $custom_oid_data_4 = $alert["_snmp_f4_"]; $custom_oid_data_5 = $alert["_snmp_f5_"]; $custom_oid_data_6 = $alert["_snmp_f6_"]; $trap_type = $alert["trap_type"]; $single_value = $alert["single_value"]; } elseif (isset ($_GET["update_alert"])) { // Variable init $id_as = -1; $source_ip = ""; $alert_type = 1; //Event, e-mail $description = ""; $oid = ""; $custom_value = ""; $time_threshold = SECONDS_5MINUTES; $al_field1 = ""; $al_field2 = ""; $al_field3 = ""; $max_alerts = 1; $min_alerts = 0; $priority = 0; $custom_oid_data_1 = ''; $custom_oid_data_2 = ''; $custom_oid_data_3 = ''; $custom_oid_data_4 = ''; $custom_oid_data_5 = ''; $custom_oid_data_6 = ''; $trap_type = -1; $single_value = ''; } // Header // Alert Delete // ============= if (isset ($_GET["delete_alert"])) { // Delete alert $alert_delete = (int) get_parameter_get ("delete_alert", 0); $result = db_process_sql_delete('talert_snmp', array('id_as' => $alert_delete)); if ($result === false) { db_pandora_audit("SNMP management", "Fail try to delete snmp alert #$alert_delete"); ui_print_error_message(__('There was a problem deleting the alert')); } else { db_pandora_audit("SNMP management", "Delete snmp alert #$alert_delete"); ui_print_success_message(__('Successfully deleted')); } } // Alert form if (isset ($_GET["update_alert"])) { //the update_alert means the form should be displayed. If update_alert > 1 then an existing alert is updated echo '