From 6121c2a32b28d1649f8f22f69e12afce64f7e5fb Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 19 Mar 2019 17:16:31 +0100 Subject: [PATCH 1/2] Added types reports to send email Former-commit-id: 7d2f349c47d81de454cb5464146d4f0ac2fc3fb6 --- pandora_console/extras/mr/27.sql | 6 ++++++ .../extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 9 +++++++-- .../godmode/reporting/reporting_builder.php | 8 +++----- pandora_console/include/functions_reporting.php | 4 ++-- .../include/functions_reporting_xml.php | 14 ++++++++------ pandora_console/pandoradb_data.sql | 4 ++-- 6 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 pandora_console/extras/mr/27.sql diff --git a/pandora_console/extras/mr/27.sql b/pandora_console/extras/mr/27.sql new file mode 100644 index 0000000000..f85064c9eb --- /dev/null +++ b/pandora_console/extras/mr/27.sql @@ -0,0 +1,6 @@ +START TRANSACTION; + +UPDATE tuser_task SET parameters = 'a:5:{i:0;a:6:{s:11:\"description\";s:28:\"Report pending to be created\";s:5:\"table\";s:7:\"treport\";s:8:\"field_id\";s:9:\"id_report\";s:10:\"field_name\";s:4:\"name\";s:4:\"type\";s:3:\"int\";s:9:\"acl_group\";s:8:\"id_group\";}i:1;a:2:{s:11:\"description\";s:46:\"Send to email addresses (separated by a comma)\";s:4:\"type\";s:4:\"text\";}i:2;a:2:{s:11:\"description\";s:7:\"Subject\";s:8:\"optional\";i:1;}i:3;a:3:{s:11:\"description\";s:7:\"Message\";s:4:\"type\";s:4:\"text\";s:8:\"optional\";i:1;}i:4;a:2:{s:11:\"description\";s:11:\"Report Type\";s:4:\"type\";s:11:\"report_type\";}}' where function_name = "cron_task_generate_report"; + + +COMMIT; \ No newline at end of file diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 822134c54d..f0e504a6b9 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1199,13 +1199,13 @@ ALTER TABLE titem MODIFY `source_data` int(10) unsigned; INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30'); -INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 26); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 27); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_docs_logo', 'default_docs.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png'); UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager'; DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise'; -INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '733'); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '734'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp'); -- --------------------------------------------------------------------- @@ -2041,3 +2041,8 @@ INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Di -- Add column in table `tagent_custom_fields` -- ---------------------------------------------------------------------- ALTER TABLE tagent_custom_fields ADD COLUMN `combo_values` VARCHAR(255) DEFAULT ''; + +-- ---------------------------------------------------------------------- +-- Update table `tuser_task` +-- ---------------------------------------------------------------------- +UPDATE tuser_task set parameters = 'a:5:{i:0;a:6:{s:11:\"description\";s:28:\"Report pending to be created\";s:5:\"table\";s:7:\"treport\";s:8:\"field_id\";s:9:\"id_report\";s:10:\"field_name\";s:4:\"name\";s:4:\"type\";s:3:\"int\";s:9:\"acl_group\";s:8:\"id_group\";}i:1;a:2:{s:11:\"description\";s:46:\"Send to email addresses (separated by a comma)\";s:4:\"type\";s:4:\"text\";}i:2;a:2:{s:11:\"description\";s:7:\"Subject\";s:8:\"optional\";i:1;}i:3;a:3:{s:11:\"description\";s:7:\"Message\";s:4:\"type\";s:4:\"text\";s:8:\"optional\";i:1;}i:4;a:2:{s:11:\"description\";s:11:\"Report Type\";s:4:\"type\";s:11:\"report_type\";}}' where function_name = "cron_task_generate_report"; diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index fd64d9ac5e..1aa7804860 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -117,10 +117,10 @@ if ($schedule_report != '') { $date = date(DATE_FORMAT); $time = date(TIME_FORMAT); $parameters[0] = get_parameter('id_schedule_report'); - // $parameters[1] = db_get_value('schedule_email', 'treport', 'id_report', $id_report); $parameters[1] = get_parameter('schedule_email_address'); $parameters[2] = get_parameter('schedule_subject', ''); $parameters[3] = get_parameter('schedule_email', ''); + $parameters[4] = get_parameter('report_type', ''); $parameters['first_execution'] = strtotime($date.' '.$time); $values = [ @@ -141,7 +141,7 @@ if ($schedule_report != '') { echo '
'; } -// Other Checks for the edit the reports +// Other Checks for the edit the reports. if ($idReport != 0) { $report = db_get_row_filter('treport', ['id_report' => $idReport]); $type_access_selected = reports_get_type_access($report); @@ -293,7 +293,7 @@ switch ($action) { $temp = []; foreach ($items as $item) { - // Remove the contents from the block to sort + // Remove the contents from the block to sort. if (array_search($item['id_rc'], $ids) === false) { $temp[$item['order']] = $item['id_rc']; } @@ -1298,7 +1298,6 @@ switch ($action) { $values['exception_condition_value'] = get_parameter('exception_condition_value'); $values['id_module_group'] = get_parameter('combo_modulegroup'); $values['id_group'] = get_parameter('combo_group'); - $values['show_extended_events'] = get_parameter('include_extended_events'); $values['server_name'] = get_parameter('server_name'); $server_id = (int) get_parameter('server_id'); if ($server_id != 0) { @@ -1690,7 +1689,6 @@ switch ($action) { $values['exception_condition_value'] = get_parameter('exception_condition_value'); $values['id_module_group'] = get_parameter('combo_modulegroup'); $values['id_group'] = get_parameter('combo_group'); - $values['show_extended_events'] = get_parameter('include_extended_events'); if ((($values['type'] == 'custom_graph') or ($values['type'] == 'automatic_custom_graph')) && ($values['id_gs'] == 0 || $values['id_gs'] == '')) { diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index f65849bb54..e2d244e3d4 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -7770,11 +7770,11 @@ function reporting_get_agents_detailed_event( foreach ($events as $eventRow) { foreach ($eventRow as $k => $event) { - // First pass along the class of this row + // First pass along the class of this row. $table->cellclass[$k][1] = $table->cellclass[$k][2] = $table->cellclass[$k][4] = $table->cellclass[$k][5] = $table->cellclass[$k][6] = get_priority_class($event['criticity']); $data = []; - // Colored box + // Colored box. switch ($event['estado']) { case 0: $img_st = 'images/star.png'; diff --git a/pandora_console/include/functions_reporting_xml.php b/pandora_console/include/functions_reporting_xml.php index d1b28ac2a0..565fac557a 100644 --- a/pandora_console/include/functions_reporting_xml.php +++ b/pandora_console/include/functions_reporting_xml.php @@ -31,7 +31,7 @@ function reporting_xml_get_report($report, $filename, $return=false) unset($report['private']); unset($report['custom_logo']); // ---------------------------------------------------------------------- - // change agent name + // change agent name. if (count($report['contents']) > 0) { for ($i = 0; $i < count($report['contents']); $i++) { $aux = explode('-', $report['contents'][$i]['subtitle']); @@ -44,16 +44,18 @@ function reporting_xml_get_report($report, $filename, $return=false) $xml = preg_replace('/(<[^>]+>)(<[^>]+>)(<[^>]+>)/', "$1\n$2\n$3", $xml); $xml = preg_replace('/(<[^>]+>)(<[^>]+>)/', "$1\n$2", $xml); - // Return if is marked to return + // Return if is marked to return. if ($return) { return $xml; } - // Download if marked to download - header('Content-Type: application/xml; charset=UTF-8'); - header('Content-Disposition: attachment; filename="'.$filename.'.xml"'); + // Download if marked to download. + if ($filename === false) { + header('Content-Type: application/xml; charset=UTF-8'); + header('Content-Disposition: attachment; filename="'.$filename.'.xml"'); + } - // Clean the output buffer + // Clean the output buffer. ob_clean(); echo $xml; diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index ee4ad45c06..f98cc3b511 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -114,10 +114,10 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_report_front_logo', 'images/pandora_logo_white.jpg'), ('custom_report_front_header', ''), ('custom_report_front_footer', ''), -('MR', 26), +('MR', 27), ('identification_reminder', 1), ('identification_reminder_timestamp', 0), -('current_package_enterprise', '733'), +('current_package_enterprise', '734'), ('post_process_custom_values', '{"0.00000038580247":"Seconds to months","0.00000165343915":"Seconds to weeks","0.00001157407407":"Seconds to days","0.01666666666667":"Seconds to minutes","0.00000000093132":"Bytes to Gigabytes","0.00000095367432":"Bytes to Megabytes","0.0009765625":"Bytes to Kilobytes","0.00000001653439":"Timeticks to weeks","0.00000011574074":"Timeticks to days"}'), ('custom_docs_logo', 'default_docs.png'), ('custom_support_logo', 'default_support.png'), From 05ab375f8ae8f291901e301964abb91569cf8d4e Mon Sep 17 00:00:00 2001 From: manuel Date: Wed, 20 Mar 2019 11:32:25 +0100 Subject: [PATCH 2/2] Fixed bug in meta Former-commit-id: abccf5d87390bdb9981928e975947fe3ad71cc70 --- pandora_console/include/functions_cron.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandora_console/include/functions_cron.php b/pandora_console/include/functions_cron.php index e56a3d4a52..4bb7f5c752 100644 --- a/pandora_console/include/functions_cron.php +++ b/pandora_console/include/functions_cron.php @@ -429,8 +429,10 @@ function cron_list_table() } $email = $args[1]; + $report_type = $args[4]; $data[2] .= '
- '.__('Report').": "; $data[2] .= $report['name'].''; + $data[2] .= '
- '.__('Report type').': '.$report_type; $data[2] .= '
- '.__('Email').": "; $data[2] .= ui_print_truncate_text($email, 60, false).''; break;