From 9508511faf31301ebe09c2a1f9de50e01460fe7e Mon Sep 17 00:00:00 2001 From: vgilc Date: Wed, 19 Sep 2012 11:28:57 +0000 Subject: [PATCH] 2012-09-19 Vanessa Gil * include/functions_api.php: Added functions: event_info and create_event. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6986 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 5 ++ pandora_console/include/functions_api.php | 90 +++++++++++++++++++++++ 2 files changed, 95 insertions(+) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index b7b54fccf0..fdde306cd1 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,8 @@ +2012-09-19 Vanessa Gil + + * include/functions_api.php: Added functions: event_info + and create_event. + 2012-09-18 Vanessa Gil * include/functions_config.php: Fixed bug in netflow diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 8fa765f2b1..b32d15e283 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -5432,4 +5432,94 @@ function api_get_alert_action_by_group($id_group, $id_action, $trash2, $returnTy returnData($returnType, $data); } +// http://localhost/pandora_console/include/api.php?op=get&op2=event_info&id=58&apipass=1234&user=admin&pass=pandora +function api_get_event_info($id_event, $trash1, $trash, $returnType) { + + $sql = "SELECT * FROM tevento WHERE id_evento=$id_event"; + $event_data = db_get_row_sql($sql); + + $i = 0; + foreach ($event_data as $data) { + if ($i == 0) + $result = $data; + else + $result .= ';'.$data; + $i++; + } + + $data = array('type' => 'string', 'data' => $result); + + returnData($returnType, $data); + return; +} + +// http://localhost/pandora_console/include/api.php?op=get&op2=create_event&id=name_event&other=2|admin|2|4|1|system|8|4|0|3|comments||Pandora||critical_inst|warning_inst|unknown_inst&other_mode=url_encode_separator_|&apipass=1234&user=admin&pass=pandora +function api_set_create_event($id, $trash1, $other, $trash2) { + if ($other['type'] == 'string') { + returnError('error_parameter', 'Error in the parameters.'); + return; + } + else if ($other['type'] == 'array') { + + $values = array(); + if ($other['data'][0] != '') + $values['id_agente'] = $other['data'][0]; + if ($other['data'][1] != '') + $values['id_usuario'] = $other['data'][1]; + if ($other['data'][2] != '') + $values['id_grupo'] = $other['data'][2]; + if ($other['data'][3] != '') + $values['estado'] = $other['data'][3]; + $values['timestamp'] = date("Y-m-d H:i:s", get_system_time()); + + $values['evento'] = $id; + $values['utimestamp'] = get_system_time (); + if ($other['data'][4] != '') + $values['event_type'] = $other['data'][4]; + if ($other['data'][5] != '') + $values['id_agentmodule'] = $other['data'][5]; + if ($other['data'][6] != '') + $values['id_alert_am'] = $other['data'][6]; + if ($other['data'][7] != '') + $values['criticity'] = $other['data'][7]; + if ($other['data'][8] != '') { + $values['user_comment'] = $other['data'][8]; + } + if ($other['data'][9] != '') { + $values['tags'] = $other['data'][9]; + } else { + if ($other['data'][9] != '' && $other['data'][9] > 0) { + + } + } + if ($other['data'][10] != '') + $values['source'] = $other['data'][10]; + else + $values['source'] = 'Pandora'; + if ($other['data'][11] != '') + $values['id_extra'] = $other['data'][11]; + if ($other['data'][12] != '') { + $values['critical_instructions'] = $other['data'][12]; + } + if ($other['data'][13] != '') { + $values['warning_instructions'] = $other['data'][13]; + } + if ($other['data'][14] != '') { + $values['unknown_instructions'] = $other['data'][14]; + } + + $return = db_process_sql_insert('tevento', $values); + + $data['type'] = 'string'; + if ($return === false) { + $data['data'] = 0; + } + else { + $data['data'] = $return; + } + returnData('string', $data); + return; + } +} + ?>