From c208df980ece022a79fa67b9e803416849b8c4aa Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Fri, 16 Jun 2023 11:50:52 +0200 Subject: [PATCH 001/129] limited access to nodes when merging --- .../general/admin_maintenance_mode.php | 81 +++++++++++++++++++ pandora_console/index.php | 27 +++++++ 2 files changed, 108 insertions(+) create mode 100644 pandora_console/general/admin_maintenance_mode.php diff --git a/pandora_console/general/admin_maintenance_mode.php b/pandora_console/general/admin_maintenance_mode.php new file mode 100644 index 0000000000..eda793120f --- /dev/null +++ b/pandora_console/general/admin_maintenance_mode.php @@ -0,0 +1,81 @@ + + + + +
+

+ +

+
+
+ + 'responsive flex margn'] + ); + html_print_image( + 'images/maintenance.png', + false, + [ + 'class' => 'responsive', + 'width' => 800, + ] + ); + ?> + +
+
+

+
+ + + + + \ No newline at end of file diff --git a/pandora_console/index.php b/pandora_console/index.php index aaf960eb91..6dfb64d33f 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -1042,6 +1042,33 @@ if (isset($config['id_user']) === false) { } } +if ((bool) ($config['maintenance_mode'] ?? false) === true + && is_user_admin($config['id_user']) === false +) { + // Show maintenance web-page. For non-admin users only. + include $config['homedir'].'/general/maintenance.php'; + + while (ob_get_length() > 0) { + ob_end_flush(); + } + + exit(''); +} + +if ((bool) ($config['maintenance_mode'] ?? false) === true + && $page !== 'advanced/command_center' + && is_user_admin($config['id_user']) === true +) { + // Prevent access to metaconsole if not merged. + include 'general/admin_maintenance_mode.php'; + + while (ob_get_length() > 0) { + ob_end_flush(); + } + + exit(''); +} + // Enterprise support. if (file_exists(ENTERPRISE_DIR.'/load_enterprise.php')) { include_once ENTERPRISE_DIR.'/load_enterprise.php'; From 89355f07a429961eb800fdb4f4ade246e9c4e7d9 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Fri, 16 Jun 2023 12:03:44 +0200 Subject: [PATCH 002/129] #11595 The title and the url of the Tip are updated in the English language. --- pandora_console/extras/mr/66.sql | 10 ++++++++++ pandora_console/pandoradb_data.sql | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 pandora_console/extras/mr/66.sql diff --git a/pandora_console/extras/mr/66.sql b/pandora_console/extras/mr/66.sql new file mode 100644 index 0000000000..e97889494f --- /dev/null +++ b/pandora_console/extras/mr/66.sql @@ -0,0 +1,10 @@ +START TRANSACTION; + + +UPDATE `twelcome_tip` + SET title = 'Scheduled downtimes', + url = 'https://pandorafms.com/manual/en/documentation/04_using/11_managing_and_administration#scheduled_downtimes' + WHERE title = 'planned stops'; + + +COMMIT; diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 7409d3cfcd..3ae4079cac 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -2611,7 +2611,7 @@ INSERT INTO `twelcome_tip_file` (`twelcome_tip_file`,`filename`,`path`) VALUES ( INSERT INTO `twelcome_tip` (`id_lang`,`id_profile`,`title`,`text`,`url`,`enable`) VALUES ('en_GB',0,'Monitor routes from one IP to another','There is a special plugin that is used to visually monitor the routes from one IP to another in a visual and dynamic way, as it changes over time.','https://pandorafms.com/manual/en/documentation/03_monitoring/03_remote_monitoring#monitorizacion_de_rutas',1); SELECT @last_id := LAST_INSERT_ID(); INSERT INTO `twelcome_tip_file` (`twelcome_tip_file`,`filename`,`path`) VALUES (@last_id,'monitorizar_desde_ip.png','images/tips/'); -INSERT INTO `twelcome_tip` (`id_lang`,`id_profile`,`title`,`text`,`url`,`enable`) VALUES ('en_GB',0,'planned stops','It is possible to define, at the agent level and at the module level, periods in which the alerts and/or the collected data are ignored. It is perfect for planning service stops or disconnection of monitored systems. It also affects SLA reporting, preventing those time intervals from being taken into account.','https://pandorafms.com/manual/en/documentation/04_using/11_managing_and_administration#paradas_de_servicio_planificadas',1); +INSERT INTO `twelcome_tip` (`id_lang`,`id_profile`,`title`,`text`,`url`,`enable`) VALUES ('en_GB',0,'Scheduled downtimes','It is possible to define, at the agent level and at the module level, periods in which the alerts and/or the collected data are ignored. It is perfect for planning service stops or disconnection of monitored systems. It also affects SLA reporting, preventing those time intervals from being taken into account.','https://pandorafms.com/manual/en/documentation/04_using/11_managing_and_administration#scheduled_downtimes',1); SELECT @last_id := LAST_INSERT_ID(); INSERT INTO `twelcome_tip_file` (`twelcome_tip_file`,`filename`,`path`) VALUES (@last_id,'paradas_planificadas.png','images/tips/'); INSERT INTO `twelcome_tip` (`id_lang`,`id_profile`,`title`,`text`,`url`,`enable`) VALUES ('en_GB',0,'Customize alert emails','Did you know that Pandora alert emails can be customized? You only have to edit the default HTML code of the email type alert actions.','https://pandorafms.com/manual/en/documentation/04_using/01_alerts#editing_an_action',1); From 3b6320e35f6d5e0031cd5828157a0c111e98df07 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Tue, 20 Jun 2023 16:25:49 +0200 Subject: [PATCH 003/129] fix pass encryption --- pandora_console/include/functions_modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 26e63c5975..8208eeac34 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -788,7 +788,7 @@ function modules_create_agent_module( // Encrypt passwords. if (isset($values['plugin_pass']) === true) { // Avoid two times encryption. - $plugin_pass = io_safe_output($values['plugin_pass']); + $plugin_pass = io_output_password($values['plugin_pass']); $values['plugin_pass'] = io_input_password($plugin_pass); } From d2c3982a5db42ece9b93c8e2c87bbfd8b881e450 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 21 Jun 2023 13:05:37 +0200 Subject: [PATCH 004/129] #11375 bulk add profile error already exists --- pandora_console/godmode/massive/massive_add_profiles.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/massive/massive_add_profiles.php b/pandora_console/godmode/massive/massive_add_profiles.php index 6fa11d357f..5e23637453 100644 --- a/pandora_console/godmode/massive/massive_add_profiles.php +++ b/pandora_console/godmode/massive/massive_add_profiles.php @@ -103,6 +103,7 @@ if ($create_profiles) { $groups_id = get_parameter('groups_id', -1); $users_id = get_parameter('users_id', -1); $n_added = 0; + $msg_error = __('Profiles cannot be added'); if ($profiles_id == -1 || $groups_id == -1 || $users_id == -1) { $result = false; @@ -155,6 +156,8 @@ if ($create_profiles) { if ($return !== false) { $n_added++; } + } else { + $msg_error = __('The profile already exist on the user'); } } } @@ -182,7 +185,7 @@ if ($create_profiles) { ui_print_result_message( $n_added > 0, __('Profiles added successfully').'('.$n_added.')', - __('Profiles cannot be added') + $msg_error ); } From 66ba29581bfe7f69413f98b53864fbf7c2ca685c Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Thu, 22 Jun 2023 15:06:16 +0200 Subject: [PATCH 005/129] #11059 added new property in graphjs for add text in center --- pandora_console/include/graphs/fgraph.php | 11 +++ .../Widgets/top_n_events_by_group.php | 62 +++++++++++--- .../phpchartjs/src/Options/Elements.php | 26 ++++++ .../src/Options/Elements/Center.php | 85 +++++++++++++++++++ .../phpchartjs/src/Renderer/JavaScript.php | 43 ++++++++++ 5 files changed, 214 insertions(+), 13 deletions(-) create mode 100644 pandora_console/vendor/artica/phpchartjs/src/Options/Elements/Center.php diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index db068d2140..447ec9efb3 100644 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -649,6 +649,17 @@ function get_build_setup_charts($type, $options, $data) } $chart->options()->setMaintainAspectRatio($maintainAspectRatio); + if (isset($options['elements']) === true) { + if (isset($options['elements']['center']) === true) { + if (isset($options['elements']['center']['text']) === true) { + $chart->options()->getElements()->center()->setText($options['elements']['center']['text']); + } + + if (isset($options['elements']['center']['color']) === true) { + $chart->options()->getElements()->center()->setColor($options['elements']['center']['color']); + } + } + } // Set Responsive for responsive charts. $responsive = true; diff --git a/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_group.php b/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_group.php index 8c4fece94e..0a47ea71b8 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_group.php +++ b/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_group.php @@ -226,6 +226,10 @@ class TopNEventByGroupWidget extends Widget $values['legendPosition'] = $decoder['legendPosition']; } + if (isset($decoder['show_total_data']) === true) { + $values['show_total_data'] = $decoder['show_total_data']; + } + return $values; } @@ -329,6 +333,16 @@ class TopNEventByGroupWidget extends Widget ], ]; + $inputs[] = [ + 'label' => __('Show total data'), + 'arguments' => [ + 'type' => 'switch', + 'name' => 'show_total_data', + 'value' => $values['show_total_data'], + 'return' => true, + ], + ]; + return $inputs; } @@ -347,6 +361,7 @@ class TopNEventByGroupWidget extends Widget $values['maxHours'] = \get_parameter('maxHours', 0); $values['groupId'] = \get_parameter('groupId', []); $values['legendPosition'] = \get_parameter('legendPosition', 0); + $values['show_total_data'] = \get_parameter_switch('show_total_data', 0); return $values; } @@ -364,7 +379,7 @@ class TopNEventByGroupWidget extends Widget $output = ''; $size = parent::getSize(); - + $show_total_data = (bool) $this->values['show_total_data']; $this->values['groupId'] = explode(',', $this->values['groupId'][0]); if (empty($this->values['groupId']) === true) { @@ -425,6 +440,7 @@ class TopNEventByGroupWidget extends Widget } else { $data_pie = []; $labels = []; + $sum = 0; foreach ($result as $row) { if ($row['id_agente'] == 0) { $name = __('System'); @@ -444,7 +460,7 @@ class TopNEventByGroupWidget extends Widget } $name .= ' ('.$row['count'].')'; - + $sum += $row['count']; $labels[] = io_safe_output($name); $data_pie[] = $row['count']; } @@ -474,17 +490,37 @@ class TopNEventByGroupWidget extends Widget break; } - $output .= pie_graph( - $data_pie, - [ - 'legend' => [ - 'display' => true, - 'position' => 'right', - 'align' => 'center', - ], - 'labels' => $labels, - ] - ); + if ($show_total_data === true) { + $output .= ring_graph( + $data_pie, + [ + 'legend' => [ + 'display' => true, + 'position' => 'right', + 'align' => 'center', + ], + 'elements' => [ + 'center' => [ + 'text' => '10000', + 'color' => '#2c3e50', + ], + ], + 'labels' => $labels, + ] + ); + } else { + $output .= pie_graph( + $data_pie, + [ + 'legend' => [ + 'display' => true, + 'position' => 'right', + 'align' => 'center', + ], + 'labels' => $labels, + ] + ); + } } return $output; diff --git a/pandora_console/vendor/artica/phpchartjs/src/Options/Elements.php b/pandora_console/vendor/artica/phpchartjs/src/Options/Elements.php index 116fc46758..b63513bc23 100644 --- a/pandora_console/vendor/artica/phpchartjs/src/Options/Elements.php +++ b/pandora_console/vendor/artica/phpchartjs/src/Options/Elements.php @@ -8,6 +8,7 @@ use Artica\PHPChartJS\Options\Elements\Arc; use Artica\PHPChartJS\Options\Elements\Line; use Artica\PHPChartJS\Options\Elements\Point; use Artica\PHPChartJS\Options\Elements\Rectangle; +use Artica\PHPChartJS\Options\Elements\Center; use JsonSerializable; /** @@ -39,6 +40,11 @@ class Elements implements ArraySerializableInterface, JsonSerializable */ private $arc; + /** + * @var Center + */ + private $center; + /** * @return Rectangle */ @@ -119,6 +125,26 @@ class Elements implements ArraySerializableInterface, JsonSerializable return $this->arc; } + /** + * @return Center + */ + public function center() + { + if (is_null($this->center)) { + $this->center = new Center(); + } + + return $this->center; + } + + /** + * @return Center + */ + public function getCenter() + { + return $this->center; + } + /** * @return array */ diff --git a/pandora_console/vendor/artica/phpchartjs/src/Options/Elements/Center.php b/pandora_console/vendor/artica/phpchartjs/src/Options/Elements/Center.php new file mode 100644 index 0000000000..d8b35b4e89 --- /dev/null +++ b/pandora_console/vendor/artica/phpchartjs/src/Options/Elements/Center.php @@ -0,0 +1,85 @@ +text; + } + + /** + * Set text center graph. + * + * @param string $text Text center graph. + * + * @return self + */ + public function setText(string $text) + { + $this->text = $text; + + return $this; + } + + /** + * Get color text. + * + * @return string + */ + public function getColor() + { + return $this->color; + } + + /** + * Set color text. + * + * @param string $color Color text. + * + * @return self + */ + public function setColor(string $color) + { + $this->color = $color; + + return $this; + } + + /** + * @return array + */ + public function jsonSerialize() + { + return $this->getArrayCopy(); + } +} diff --git a/pandora_console/vendor/artica/phpchartjs/src/Renderer/JavaScript.php b/pandora_console/vendor/artica/phpchartjs/src/Renderer/JavaScript.php index 100276743f..b1fcb1bb9f 100644 --- a/pandora_console/vendor/artica/phpchartjs/src/Renderer/JavaScript.php +++ b/pandora_console/vendor/artica/phpchartjs/src/Renderer/JavaScript.php @@ -32,6 +32,49 @@ class JavaScript extends Renderer if (empty($this->chart->defaults()->getWatermark()) === false) { $script[] = 'const chart_watermark_'.$this->chart->getId().' = { id: "chart_watermark_'.$this->chart->getId().'", + beforeDraw: (chart) => { + if (Object.prototype.hasOwnProperty.call(chart, "config") && + Object.prototype.hasOwnProperty.call(chart.config.options, "elements") && + Object.prototype.hasOwnProperty.call(chart.config.options.elements, "center")) + { + var ctx = chart.ctx; + + ctx.save(); + + var centerConfig = chart.config.options.elements.center; + var txt = centerConfig.text; + var color = centerConfig.color || "#000"; + ctx.textAlign = "center"; + ctx.textBaseline = "middle"; + var centerX = (chart.chartArea.left + chart.chartArea.right) / 2; + var centerY = (chart.chartArea.top + chart.chartArea.bottom) / 2; + + var outerRadius = Math.min(ctx.canvas.width, ctx.canvas.height) / 2; + + var padding = 20; + + var innerRadius = outerRadius - padding; + + ctx.font = "30px "; + var sidePaddingCalculated = (92/100) * (innerRadius * 2) + + var stringWidth = ctx.measureText(txt).width; + var elementWidth = (innerRadius * 2) - sidePaddingCalculated; + + var widthRatio = elementWidth / stringWidth; + var newFontSize = Math.floor(30 * widthRatio); + var elementHeight = (innerRadius * 2); + + var fontSizeToUse = Math.min(newFontSize, elementHeight); + + ctx.font = fontSizeToUse + "px Lato, sans-serif"; + ctx.fillStyle = color; + + ctx.fillText(txt, centerX, centerY); + + ctx.restore(); + } + }, afterDraw: (chart) => { const image = new Image(); image.src = "'.$this->chart->defaults()->getWatermark()->getSrc().'"; From eac656dfc02ba8c2effab7ae1a7c96ae2505dc82 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Thu, 22 Jun 2023 15:08:52 +0200 Subject: [PATCH 006/129] #11059 fixed setted number --- .../include/lib/Dashboard/Widgets/top_n_events_by_group.php | 2 +- .../vendor/artica/phpchartjs/src/Renderer/JavaScript.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_group.php b/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_group.php index 0a47ea71b8..3c1e6a22bf 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_group.php +++ b/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_group.php @@ -501,7 +501,7 @@ class TopNEventByGroupWidget extends Widget ], 'elements' => [ 'center' => [ - 'text' => '10000', + 'text' => $sum, 'color' => '#2c3e50', ], ], diff --git a/pandora_console/vendor/artica/phpchartjs/src/Renderer/JavaScript.php b/pandora_console/vendor/artica/phpchartjs/src/Renderer/JavaScript.php index b1fcb1bb9f..8786ca6fe8 100644 --- a/pandora_console/vendor/artica/phpchartjs/src/Renderer/JavaScript.php +++ b/pandora_console/vendor/artica/phpchartjs/src/Renderer/JavaScript.php @@ -56,7 +56,7 @@ class JavaScript extends Renderer var innerRadius = outerRadius - padding; ctx.font = "30px "; - var sidePaddingCalculated = (92/100) * (innerRadius * 2) + var sidePaddingCalculated = (93/100) * (innerRadius * 2) var stringWidth = ctx.measureText(txt).width; var elementWidth = (innerRadius * 2) - sidePaddingCalculated; From cc20640acdb279605f54e11e59feb04ca99d439b Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 26 Jun 2023 09:19:26 +0200 Subject: [PATCH 007/129] #11316 new modal help --- pandora_console/general/header.php | 94 ++++++++++------------ pandora_console/images/help@header.svg | 8 ++ pandora_console/include/styles/pandora.css | 40 ++++++++- 3 files changed, 90 insertions(+), 52 deletions(-) create mode 100644 pandora_console/images/help@header.svg diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 2c311f33ec..8b8a9a0e4a 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -351,59 +351,37 @@ echo sprintf('
', $menuTypeClass); $header_autorefresh_counter .= '
'; } - // Button for feedback pandora. - if (enterprise_installed()) { - $header_feedback = '
'; - $header_feedback .= ''; - $header_feedback .= ''; - $header_feedback .= html_print_image( - 'images/send_feedback@header.svg', - true, - [ - 'class' => 'main_menu_icon invert_filter', - 'title' => __('Feedback'), - 'id' => 'feedback-header', - 'alt' => __('Feedback'), - 'style' => 'cursor: pointer;', - ] - ); - $header_feedback .= '
'; - } - - - // Support. - if (enterprise_installed()) { - $header_support_link = $config['custom_support_url']; + $modal_box = ''; - // Documentation. - $header_docu = ''; // User. @@ -457,11 +435,11 @@ echo sprintf('
', $menuTypeClass); echo ''; echo '
'; echo '
'; - echo '
'.$header_support, $header_docu, $header_user, $header_logout.'
'; + echo '
'.$modal_help, $header_user, $header_logout.'
'; } else { echo '
'.$config['custom_title_header'].''.$config['custom_subtitle_header'].'
'.$header_searchbar.'
-
'.$header_autorefresh, $header_autorefresh_counter, $header_discovery, $servers_list, $header_feedback, $header_support, $header_docu, $header_user, $header_logout.'
'; +
'.$header_autorefresh, $header_autorefresh_counter, $header_discovery, $servers_list, $modal_help, $header_user, $header_logout.'
'; } ?> @@ -907,8 +885,6 @@ echo sprintf('
', $menuTypeClass); // Feedback. $("#feedback-header").click(function () { - // Clean DOM. - $("#feedback-header").empty(); // Function charge Modal. show_feedback(); }); @@ -1014,6 +990,22 @@ echo sprintf('
', $menuTypeClass); return false; }); + + + $(document).click(function(event) { + if (!$(event.target).closest('#modal-help-content').length && + $('#modal_help').hasClass('invisible') === false) { + $('#modal_help').addClass('invisible'); + } + }); + + $('#modal-help-content').on('click', (e) => { + if($(e.target).prop('tagName') === 'A') { + $('#modal_help').addClass('invisible'); + } else { + $('#modal_help').removeClass('invisible'); + } + }); }); /* ]]> */ diff --git a/pandora_console/images/help@header.svg b/pandora_console/images/help@header.svg new file mode 100644 index 0000000000..e561a7c09e --- /dev/null +++ b/pandora_console/images/help@header.svg @@ -0,0 +1,8 @@ + + + help_pandora + + + + + \ No newline at end of file diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 034467f83e..1e6bd0e72a 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -1517,7 +1517,45 @@ div#head { input.datos { background-color: #f5f5f5; } - +#modal_help { + position: absolute; + top: -2px; + right: 32px; + background: white; + display: flex; + min-width: 160px; + flex-direction: column; + filter: drop-shadow(1px 2px 2px #0000005e); + padding: 10px 0px; +} +#modal-help-content { + position: relative; + cursor: pointer; +} +#modal_help a { + margin: 3px 0px; + padding: 0px 15px; +} +#modal_help a:hover { + color: var(--primary-color); +} +#modal_help .separator { + width: 100%; + opacity: 0.4; +} +#modal_help::before { + content: ""; + border: 8px solid #0000; + border-bottom: 8px solid white; + left: auto; + right: -16px; + top: 5px; + position: absolute; + transform: rotate(90deg); +} +#modal_help.invisible { + display: none; +} /* * --------------------------------------------------------------------- * - REPORTS - From adb7c33863cff0ac45f6c067116aec4099a83c27 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 26 Jun 2023 17:05:46 +0200 Subject: [PATCH 008/129] #10870 changed status from view details views when is agruped by extraid --- pandora_console/include/ajax/events.php | 18 ++++++++++++++---- pandora_console/include/functions_events.php | 8 ++++++-- .../include/javascript/pandora_events.js | 5 +++-- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index 666d23d244..991081b2aa 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -1487,6 +1487,7 @@ if ($add_comment === true) { if ($change_status === true) { $event_ids = get_parameter('event_ids'); $new_status = get_parameter('new_status'); + $group_rep = (int) get_parameter('group_rep', 0); $server_id = 0; if (is_metaconsole() === true) { $server_id = (int) get_parameter('server_id'); @@ -1500,10 +1501,19 @@ if ($change_status === true) { $node->connect(); } - $return = events_change_status( - explode(',', $event_ids), - $new_status - ); + if ($group_rep !== 3) { + $return = events_change_status( + explode(',', $event_ids), + $new_status + ); + } else { + // Update all elements with same extraid. + $return = events_update_status( + $event_ids, + (int) $new_status, + ['group_rep' => $group_rep] + ); + } } catch (\Exception $e) { // Unexistent agent. if (is_metaconsole() === true diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 8d5aeedd6f..c2c790d951 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -477,7 +477,7 @@ function events_update_status($id_evento, $status, $filter=null) { global $config; - if (!$status) { + if (!$status && $status !== 0) { return false; } @@ -3595,11 +3595,15 @@ function events_page_responses($event) ); if ($status_blocked === false) { + if (isset($event['server_id']) === false) { + $event['server_id'] = '0'; + } + $data[2] = html_print_button( __('Update'), 'status_button', false, - 'event_change_status("'.$event['similar_ids'].'",'.$event['server_id'].');', + 'event_change_status("'.$event['similar_ids'].'",'.$event['server_id'].', '.$event['group_rep'].');', [ 'icon' => 'next', 'mode' => 'link', diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index 2092d30589..2e78370908 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -322,7 +322,7 @@ function perform_response(response, response_id, index = "") { } // Change the status of an event to new, in process or validated. -function event_change_status(event_ids, server_id) { +function event_change_status(event_ids, server_id, group_rep) { var new_status = $("#estado").val(); $("#button-status_button").attr("disabled", "disabled"); @@ -334,7 +334,8 @@ function event_change_status(event_ids, server_id) { change_status: 1, event_ids: event_ids, new_status: new_status, - server_id: server_id + server_id: server_id, + group_rep: group_rep }, type: "POST", url: getUrlAjax(), From ada52da89812fed6b55c7914ef19ccb3d794ca8f Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Thu, 29 Jun 2023 16:09:07 +0200 Subject: [PATCH 009/129] #10850 agent detail view added to favorites system --- pandora_console/operation/agentes/estado_agente.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pandora_console/operation/agentes/estado_agente.php b/pandora_console/operation/agentes/estado_agente.php index 3a130c1d76..7e36c63491 100644 --- a/pandora_console/operation/agentes/estado_agente.php +++ b/pandora_console/operation/agentes/estado_agente.php @@ -205,6 +205,14 @@ if ($loaded_filter['id_filter'] > 0) { if (is_array($policies) === false) { $policies = json_decode(io_safe_output($policies), true); } + + // Fav menu. + $fav_menu = [ + 'id_element' => $loaded_filter['id_filter'], + 'url' => 'operation/agentes/estado_agente&pure=&load_filter=1&filter_id='.$loaded_filter['id_filter'], + 'label' => $loaded_filter['id_name'], + 'section' => 'Agente', + ]; } if ((bool) check_acl($config['id_user'], 0, 'AW') === true) { @@ -249,7 +257,8 @@ ui_print_standard_header( 'link' => '', 'label' => __('Views'), ], - ] + ], + (empty($fav_menu) === true) ? [] : $fav_menu ); if ((bool) $strict_user === false) { From 5f864d53a8a694f6eb22e92f106e88926e3d054e Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Mon, 3 Jul 2023 09:18:30 +0200 Subject: [PATCH 010/129] #11051 Add action to mark all notification as read --- pandora_console/general/header.php | 27 +++++++++++++++++++ .../godmode/setup/setup_notifications.php | 21 +++++++++++++++ .../include/class/ConsoleSupervisor.php | 7 +++-- pandora_console/include/functions_html.php | 3 +++ .../include/functions_notifications.php | 15 ++++++++++- pandora_console/include/styles/pandora.css | 5 ++++ 6 files changed, 75 insertions(+), 3 deletions(-) diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 6129fcebb4..ba6922e03c 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -539,6 +539,33 @@ echo sprintf('
', $menuTypeClass); element.style.display = "none" } + function notifications_clean_all() { + let wrapper_inner = document.getElementById('notification-wrapper-inner'); + while (wrapper_inner.firstChild) { + wrapper_inner.removeChild(wrapper_inner.firstChild); + } + } + + function mark_all_notification_as_read() { + jQuery.post ("ajax.php", + { + "page" : "godmode/setup/setup_notifications", + "mark_all_notification_as_read" : 1 + }, + function (data, status) { + notifications_clean_all(); + location.reload(); + }, + "json" + ) + .fail(function(xhr, textStatus, errorThrown){ + console.error( + "Failed to mark al notification as read. Error: ", + xhr.responseText + ); + }); + } + function click_on_notification_toast(event) { var match = /notification-(.*)-id-([0-9]+)/.exec(event.target.id); if (!match) { diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php index 6aaaabf032..f2289a7cc3 100644 --- a/pandora_console/godmode/setup/setup_notifications.php +++ b/pandora_console/godmode/setup/setup_notifications.php @@ -187,6 +187,27 @@ if (get_parameter('mark_notification_as_read', 0)) { return; } +if (get_parameter('mark_all_notification_as_read', 0)) { + $unread_messages = db_get_all_rows_sql('SELECT id_mensaje FROM tnotification_user WHERE utimestamp_read is NULL'); + + if ($unread_messages !== false) { + foreach ($unread_messages as $messages) { + messages_process_read($messages['id_mensaje']); + } + + $result = true; + } else { + $result = false; + } + + // If there is new messages, get the info. + echo json_encode( + ['result' => $result] + ); + + return; +} + if (get_parameter('get_notifications_dropdown', 0)) { echo notifications_print_dropdown(); return; diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index 7ef169aec1..99299a21ac 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -169,6 +169,7 @@ class ConsoleSupervisor * NOTIF.PHP.DISABLE_FUNCTIONS * NOTIF.PHP.CHROMIUM * NOTIF.PHP.VERSION + * NOTIF.PHP.VERSION.SUPPORT */ $this->checkPHPSettings(); @@ -377,6 +378,7 @@ class ConsoleSupervisor * NOTIF.PHP.DISABLE_FUNCTIONS * NOTIF.PHP.CHROMIUM * NOTIF.PHP.VERSION + * NOTIF.PHP.VERSION.SUPPORT */ $this->checkPHPSettings(); @@ -853,6 +855,7 @@ class ConsoleSupervisor case 'NOTIF.PHP.DISABLE_FUNCTIONS': case 'NOTIF.PHP.CHROMIUM': case 'NOTIF.PHP.VERSION': + case 'NOTIF.PHP.VERSION.SUPPORT': case 'NOTIF.HISTORYDB': case 'NOTIF.PANDORADB': case 'NOTIF.PANDORADB.HISTORICAL': @@ -1807,14 +1810,14 @@ class ConsoleSupervisor $url = 'https://www.php.net/supported-versions.php'; $this->notify( [ - 'type' => 'NOTIF.PHP.VERSION', + 'type' => 'NOTIF.PHP.VERSION.SUPPORT', 'title' => __('PHP UPDATE REQUIRED'), 'message' => __('You should update your PHP version because it will be out of official support').'
'.__('Current PHP version: ').PHP_VERSION, 'url' => $url, ] ); } else { - $this->cleanNotifications('NOTIF.PHP.VERSION'); + $this->cleanNotifications('NOTIF.PHP.VERSION.SUPPORT'); } } diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 076a81e7f3..652e878e82 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -2849,6 +2849,8 @@ function html_print_anchor( $output .= '>'; + $output .= (isset($options['text']) === true) ? $options['text'] : ''; + $output .= (isset($options['content']) === true) ? io_safe_input_html($options['content']) : ''; $output .= ''; @@ -6882,6 +6884,7 @@ function html_print_menu_button(array $options, bool $return=false) 'class' => ($options['class'] ?? ''), 'style' => ($options['style'] ?? ''), 'onClick' => ($options['onClick'] ?? ''), + 'text' => ($options['text'] ?? ''), 'content' => $content, ], $return diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index ee23d122a4..dce8fa3502 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -136,6 +136,7 @@ function notifications_get_subtypes(?string $source=null) 'NOTIF.PHP.DISABLE_FUNCTIONS', 'NOTIF.PHP.CHROMIUM', 'NOTIF.PHP.VERSION', + 'NOTIF.PHP.VERSION.SUPPORT', 'NOTIF.HISTORYDB', 'NOTIF.PANDORADB', 'NOTIF.PANDORADB.HISTORICAL', @@ -1025,9 +1026,20 @@ function notifications_print_dropdown() $mess = []; } + $notification_menu = html_print_menu_button( + [ + 'href' => 'javascript:', + 'class' => 'notification_menu_actions', + 'text' => __('Mark all as read'), + 'onClick' => 'mark_all_notification_as_read()', + ], + true + ); + return sprintf( "
+ %s
@@ -1037,6 +1049,7 @@ function notifications_print_dropdown() >
", + $notification_menu, array_reduce( $mess, function ($carry, $message) { @@ -1114,7 +1127,7 @@ function notifications_print_dropdown_element($message_info)

", - $action.';click_on_notification_toast(event)', + $action.'; click_on_notification_toast(event)', $message_info['id_mensaje'], messages_get_url($message_info['id_mensaje']), $target, diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 06a3640c7c..11580027bf 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -12289,3 +12289,8 @@ tr[id^="network_component-plugin-wmi-fields-dynamicMacroRow-"] input, tr[id^="network_component-plugin-snmp-fields-dynamicMacroRow-"] input { width: 100% !important; } + +.notification_menu { + padding-top: 10px; + padding-left: 15px; +} From 4ff400f54cb0dc826cc016614628b6e8906d14dc Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Mon, 3 Jul 2023 13:18:50 +0200 Subject: [PATCH 011/129] #11022 Add agent usage details --- pandora_console/godmode/setup/license.php | 101 +++++++++++++++++++++- 1 file changed, 97 insertions(+), 4 deletions(-) diff --git a/pandora_console/godmode/setup/license.php b/pandora_console/godmode/setup/license.php index e11c54eec9..e3e25935f9 100644 --- a/pandora_console/godmode/setup/license.php +++ b/pandora_console/godmode/setup/license.php @@ -189,7 +189,8 @@ $table->data[1][1] = html_print_label_input_block( 255, true, true - ).' '.($license['limit_mode'] == 0 ? __('agents') : __('modules')) + ) + // .' '.($license['limit_mode'] == 0 ? __('agents') : __('modules')) ); $table->data[2][0] = html_print_label_input_block( @@ -202,7 +203,8 @@ $table->data[2][0] = html_print_label_input_block( 255, true, true - ).' '.($license['limit_mode'] == 0 ? __('agents') : __('modules')) + ) + // .' '.($license['limit_mode'] == 0 ? __('agents') : __('modules')) ); $table->data[2][1] = html_print_label_input_block( @@ -215,7 +217,8 @@ $table->data[2][1] = html_print_label_input_block( 255, true, true - ).' '.($license['limit_mode'] == 0 ? __('agents') : __('modules')) + ) + // .' '.($license['limit_mode'] == 0 ? __('agents') : __('modules')) ); $table->data[3][0] = html_print_label_input_block( @@ -228,7 +231,8 @@ $table->data[3][0] = html_print_label_input_block( 255, true, true - ).' '.($license['limit_mode'] == 0 ? __('agents') : __('modules')) + ) + // .' '.($license['limit_mode'] == 0 ? __('agents') : __('modules')) ); $table->data[3][1] = html_print_label_input_block( @@ -325,6 +329,18 @@ if (enterprise_installed() || defined('DESTDIR')) { ], true ); + $buttons .= html_print_button( + __('Show agent usage details'), + 'agents_details', + false, + 'show_agents_details_dialog()', + [ + 'fixed_id' => 'button-agents_details', + 'icon' => 'next', + 'mode' => 'secondary', + ], + true + ); html_print_action_buttons( $buttons @@ -369,3 +385,80 @@ if (enterprise_hook('print_activate_licence_dialog') == ENTERPRISE_NOT_HOOK) { echo ''; echo '
'; } + +$table = new stdClass(); +$table->width = '100%'; +$table->class = 'databox filter-table-adv'; +$table->size = []; +$table->size[0] = '50%'; +$table->size[1] = '50%'; +$table->data = []; +$table->colspan = []; + +$table->data[0][0] = html_print_label_input_block( + __('Total Agents'), + html_print_input_text( + 'total_agents', + $total_agents, + '', + 30, + 255, + true, + true + ) +); + +$table->data[0][1] = html_print_label_input_block( + __('Network & other devices'), + html_print_input_text( + 'type_network', + $network_others, + '', + 30, + 255, + true, + true + ) +); + +$table->data[1][0] = html_print_label_input_block( + __('Workstations'), + html_print_input_text( + 'type_workstation', + $workstations, + '', + 30, + 255, + true, + true + ) +); + +$table->data[1][1] = html_print_label_input_block( + __('Servers'), + html_print_input_text( + 'type_server', + $servers, + '', + 30, + 255, + true, + true + ) +); + +$table->data[2][0] = html_print_label_input_block( + __('Show disabled agents'), + html_print_checkbox_switch( + 'show_disabled_agents', + 1, + 1, + true, + false, + 'show_disabled_agents()' + ) +); + +echo ''; \ No newline at end of file From d25a5e2b8991f01602c468c92f3775baf984b240 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Mon, 3 Jul 2023 17:37:01 +0200 Subject: [PATCH 012/129] #11543 Added login screen changes in white mode --- pandora_console/general/login_page.php | 10 ++++++---- pandora_console/godmode/users/user_management.php | 10 +++++++++- pandora_console/include/styles/login.css | 1 + 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/pandora_console/general/login_page.php b/pandora_console/general/login_page.php index d3d9c7e686..2b2d4ffa30 100755 --- a/pandora_console/general/login_page.php +++ b/pandora_console/general/login_page.php @@ -30,7 +30,7 @@ require_once __DIR__.'/../include/functions_html.php'; echo '