From bec023dc4d9dacbd4ab60047fef984083554f067 Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Tue, 18 Jul 2017 11:36:57 +0200 Subject: [PATCH] Fixed meta event table in cli and api functions --- pandora_console/include/functions_api.php | 7 +++--- pandora_server/util/pandora_manage.pl | 28 +++++++++++++++++++---- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index ccadee5349..ac71131094 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -9062,8 +9062,9 @@ function api_set_create_event($id, $trash1, $other, $returnType) { * http://127.0.0.1/pandora_console/include/api.php?op=set&op2=add_event_comment&id=event_id&other=string|&other_mode=url_encode_separator_|&apipass=1234&user=admin&pass=pandora */ function api_set_add_event_comment($id, $thrash2, $other, $thrash3) { + $meta = false; if (defined ('METACONSOLE')) { - return; + $meta = true; } if ($other['type'] == 'string') { @@ -9072,11 +9073,9 @@ function api_set_add_event_comment($id, $thrash2, $other, $thrash3) { } else if ($other['type'] == 'array') { $comment = io_safe_input($other['data'][0]); - $meta = $other['data'][1]; $history = $other['data'][2]; - $status = events_comment($id, $comment, 'Added comment', $meta, - $history); + $status = events_comment($id, $comment, 'Added comment', $meta, $history); if (is_error($status)) { returnError('error_add_event_comment', __('Error adding event comment.')); diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index e5d9202cfb..9401f721c9 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -3212,8 +3212,13 @@ sub cli_get_event_info () { exist_check($event_name,'event',$id_event); $csv_separator = '|' unless defined($csv_separator); + + my $event_table = "tevento"; + if (is_metaconsole($conf) == 1) { + $event_table = "tmetaconsole_event"; + } - my $query = "SELECT * FROM tevento where id_evento=".$id_event; + my $query = "SELECT * FROM " . $event_table . " where id_evento=" . $id_event; my $header = "Event ID".$csv_separator."Event name".$csv_separator."Agent ID".$csv_separator."User ID".$csv_separator. "Group ID".$csv_separator."Status".$csv_separator."Timestamp".$csv_separator."Event type".$csv_separator. @@ -4560,7 +4565,12 @@ sub cli_set_event_storm_protection () { sub pandora_get_event_name($$) { my ($dbh,$id_event) = @_; - my $event_name = get_db_value($dbh, 'SELECT evento FROM tevento WHERE id_evento = ?',$id_event); + my $event_table = "tevento"; + if (is_metaconsole($conf) == 1) { + $event_table = "tmetaconsole_event"; + } + + my $event_name = get_db_value($dbh, 'SELECT evento FROM ' . $event_table . ' WHERE id_evento = ?',$id_event); return defined ($event_name) ? $event_name : -1; } @@ -4571,7 +4581,12 @@ sub pandora_get_event_name($$) { sub pandora_update_event_from_hash ($$$$) { my ($parameters, $where_column, $where_value, $dbh) = @_; - my $event_id = db_process_update($dbh, 'tevento', $parameters, {$where_column => $where_value}); + my $event_table = "tevento"; + if (is_metaconsole($conf) == 1) { + $event_table = "tmetaconsole_event"; + } + + my $event_id = db_process_update($dbh, $event_table, $parameters, {$where_column => $where_value}); return $event_id; } @@ -4582,7 +4597,12 @@ sub pandora_update_event_from_hash ($$$$) { sub pandora_get_event_comment($$) { my ($dbh,$id_event) = @_; - my $event_name = get_db_value($dbh, 'SELECT user_comment FROM tevento WHERE id_evento = ?',$id_event); + my $event_table = "tevento"; + if (is_metaconsole($conf) == 1) { + $event_table = "tmetaconsole_event"; + } + + my $event_name = get_db_value($dbh, 'SELECT user_comment FROM ' . $event_table . ' WHERE id_evento = ?',$id_event); return defined ($event_name) ? $event_name : -1; }