From 3d635449398886bf4392cdd6ead6422744211480 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Thu, 7 Dec 2023 14:14:12 +0100 Subject: [PATCH 01/40] get data in file count from module --- .../include/class/ConsoleSupervisor.php | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index 83208256fb..e34740711e 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -27,6 +27,7 @@ */ use PandoraFMS\Tools\Files; +use PandoraFMS\Agent; global $config; @@ -1162,11 +1163,20 @@ class ConsoleSupervisor $this->cleanNotifications('NOTIF.WRITABLE.ATTACHMENT'); } - $filecount = $this->countFiles( - $config['attachment_store'], - '', - $config['num_files_attachment'] - ); + $agentId = db_get_value('id_agente', 'tagente', 'nombre', 'pandora.internals'); + if ($agentId !== false) { + $agent = new Agent($agentId); + + $moduleId = $agent->searchModules( + ['nombre' => 'Data_in_files'], + 1 + )->toArray()['id_agente_modulo']; + + if ($moduleId > 0) { + $filecount = (int) modules_get_last_value($moduleId); + } + } + if ($filecount > $config['num_files_attachment']) { $this->notify( [ From 2eae64407d4645cd8bc4eeb73a14005c4aac62fe Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Thu, 7 Dec 2023 14:17:42 +0100 Subject: [PATCH 02/40] get data in file count from module --- pandora_console/include/class/ConsoleSupervisor.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index e34740711e..a7676d4b40 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -1163,6 +1163,8 @@ class ConsoleSupervisor $this->cleanNotifications('NOTIF.WRITABLE.ATTACHMENT'); } + $filecount = 0; + $agentId = db_get_value('id_agente', 'tagente', 'nombre', 'pandora.internals'); if ($agentId !== false) { $agent = new Agent($agentId); From 7f4dc4fbe458b675a378b7e6813e908986eee0f1 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 11 Dec 2023 09:18:40 +0100 Subject: [PATCH 03/40] #12460 fixed log deprecated --- pandora_console/include/functions_api.php | 6 +++--- pandora_console/include/functions_ui.php | 4 ++++ .../include/lib/TacticalView/elements/NewsBoard.php | 2 ++ pandora_console/operation/events/events.php | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 8f5fb66f54..07b512f55c 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -541,7 +541,7 @@ function api_get_groups($thrash1, $thrash2, $other, $returnType, $user_in_db) } -function api_get_agent_module_name_last_value($agentName, $moduleName, $other=';', $returnType) +function api_get_agent_module_name_last_value($agentName, $moduleName, $other=';', $returnType='') { $idAgent = agents_get_agent_id($agentName); @@ -558,7 +558,7 @@ function api_get_agent_module_name_last_value($agentName, $moduleName, $other='; } -function api_get_agent_module_name_last_value_alias($alias, $moduleName, $other=';', $returnType) +function api_get_agent_module_name_last_value_alias($alias, $moduleName, $other=';', $returnType='') { $sql = sprintf( 'SELECT tagente_modulo.id_agente_modulo FROM tagente_modulo @@ -573,7 +573,7 @@ function api_get_agent_module_name_last_value_alias($alias, $moduleName, $other= } -function api_get_module_last_value($idAgentModule, $trash1, $other=';', $returnType) +function api_get_module_last_value($idAgentModule, $trash1, $other=';', $returnType='') { global $config; if (defined('METACONSOLE')) { diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 5c9a7e90fc..4a0db88991 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -147,6 +147,10 @@ function ui_print_truncate_text( $text_html_decoded = io_safe_output($text); $text_has_entities = $text != $text_html_decoded; + if ($text_html_decoded === null) { + $text_html_decoded = ''; + } + if (mb_strlen($text_html_decoded, 'UTF-8') > ($numChars)) { // '/2' because [...] is in the middle of the word. $half_length = intval(($numChars - 3) / 2); diff --git a/pandora_console/include/lib/TacticalView/elements/NewsBoard.php b/pandora_console/include/lib/TacticalView/elements/NewsBoard.php index 3be2dd685f..a2a2b7faba 100644 --- a/pandora_console/include/lib/TacticalView/elements/NewsBoard.php +++ b/pandora_console/include/lib/TacticalView/elements/NewsBoard.php @@ -117,6 +117,8 @@ class NewsBoard extends Element $output .= ''; return $output; + } else { + return ''; } } diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index be5f6047e3..c924794d6d 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -505,7 +505,7 @@ if (is_ajax() === true) { } } - if (strlen($tmp->server_name) >= 10) { + if (strlen(($tmp->server_name ?? '')) >= 10) { $tmp->server_name = ui_print_truncate_text( $tmp->server_name, 10, From a31f964753fbbec4e5d0a692e084969bc274fcfa Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 27 Dec 2023 11:12:43 +0100 Subject: [PATCH 04/40] #12460 fixed deprecated --- pandora_console/include/functions_api.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 07b512f55c..ba10227fa2 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -541,7 +541,7 @@ function api_get_groups($thrash1, $thrash2, $other, $returnType, $user_in_db) } -function api_get_agent_module_name_last_value($agentName, $moduleName, $other=';', $returnType='') +function api_get_agent_module_name_last_value($agentName, $moduleName, $other=';', $returnType='string') { $idAgent = agents_get_agent_id($agentName); @@ -558,7 +558,7 @@ function api_get_agent_module_name_last_value($agentName, $moduleName, $other='; } -function api_get_agent_module_name_last_value_alias($alias, $moduleName, $other=';', $returnType='') +function api_get_agent_module_name_last_value_alias($alias, $moduleName, $other=';', $returnType='string') { $sql = sprintf( 'SELECT tagente_modulo.id_agente_modulo FROM tagente_modulo @@ -573,7 +573,7 @@ function api_get_agent_module_name_last_value_alias($alias, $moduleName, $other= } -function api_get_module_last_value($idAgentModule, $trash1, $other=';', $returnType='') +function api_get_module_last_value($idAgentModule, $trash1, $other=';', $returnType='string') { global $config; if (defined('METACONSOLE')) { From e2471f817d41f9a30f453e238627bfa139db54d5 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 9 Jan 2024 14:38:44 +0100 Subject: [PATCH 05/40] #12321 Added widget Gis map --- pandora_console/extras/mr/68.sql | 7 + pandora_console/images/widgets/GisMap.png | Bin 0 -> 9713 bytes .../include/lib/Dashboard/Widgets/GisMap.php | 541 ++++++++++++++++++ .../operation/gis_maps/render_view.php | 18 +- pandora_console/pandoradb_data.sql | 3 +- .../views/dashboard/listWidgets.php | 4 + 6 files changed, 555 insertions(+), 18 deletions(-) create mode 100644 pandora_console/extras/mr/68.sql create mode 100644 pandora_console/images/widgets/GisMap.png create mode 100644 pandora_console/include/lib/Dashboard/Widgets/GisMap.php diff --git a/pandora_console/extras/mr/68.sql b/pandora_console/extras/mr/68.sql new file mode 100644 index 0000000000..669eceaecd --- /dev/null +++ b/pandora_console/extras/mr/68.sql @@ -0,0 +1,7 @@ +START TRANSACTION; + +SET @widget_id = NULL; +SELECT @widget_id := `id` FROM `twidget` WHERE `unique_name` = 'GisMap'; +INSERT IGNORE INTO `twidget` (`id`,`class_name`,`unique_name`,`description`,`options`,`page`) VALUES (@widget_id,'GisMap','GisMap','Gis map','','GisMap.php'); + +COMMIT; \ No newline at end of file diff --git a/pandora_console/images/widgets/GisMap.png b/pandora_console/images/widgets/GisMap.png new file mode 100644 index 0000000000000000000000000000000000000000..0cbfbf37b6e2c794aa04ac7dae32173dae9ed536 GIT binary patch literal 9713 zcmVAczO!S-4f~A|{oet>r8iym4p-@8;?ZWUKx$U7d}8t4;|Ka zUW|fV0m(mDvAatSwl6M}6X|6aIXW-gE_;{tjm4N*X0*H2D28=SGy#`f(Q-~qDF4na z>>JRAnK33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`Y_j2Du_2u(?_ERB zBVQDXLS1pe{^z#PlN?}y29Dr42#T=NWL-$Qigs8=?4W; zeB+wSsuOF^@G%cz;D~WzmMzJr^c2p6Pf?4z z{Ndep(W=F$ zMorVM`f{1rqykoyy+4;sPgW_*dTqH48L`p!Q){^Nk?!M~{~OjkYlep-;=wo{=z%uR6rR3PH;5-1@NtL!#6?}@0@&$N<3GfQ z>0PLb_LI77GxS#)R&!(o+XIR#Qn@vVzl?Yu`gHa7@cjJzh!CA2)b13*u9u}XFG=-U zO`gSJ%MT3=&AD%A*W5tkzrQ*tNqB`fNJ$FAjW=iQS|hFyuctBGWPr^`%3}2n&3)z_EZwuf`$D*W!VqpFP2ZE00000NkvXXu0mjfpGLkK literal 0 HcmV?d00001 diff --git a/pandora_console/include/lib/Dashboard/Widgets/GisMap.php b/pandora_console/include/lib/Dashboard/Widgets/GisMap.php new file mode 100644 index 0000000000..3cb967cf8c --- /dev/null +++ b/pandora_console/include/lib/Dashboard/Widgets/GisMap.php @@ -0,0 +1,541 @@ +width = $width; + + // Height. + $this->height = $height; + + // Grid Width. + $this->gridWidth = $gridWidth; + + // Cell Id. + $this->cellId = $cellId; + + // Options. + $this->values = $this->decoders($this->getOptionsWidget()); + + // Page. + $this->page = basename(__FILE__); + + // ClassName. + $class = new \ReflectionClass($this); + $this->className = $class->getShortName(); + + // Title. + $this->title = __('Gis map'); + + // Name. + if (empty($this->name) === true) { + $this->name = 'GisMap'; + } + + // This forces at least a first configuration. + $this->configurationRequired = false; + if (empty($this->values['gis_map']) === true) { + $this->configurationRequired = true; + } + } + + + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['gis_map']) === true) { + $values['gis_map'] = $decoder['gis_map']; + } + + return $values; + } + + + /** + * Generates inputs for form (specific). + * + * @return array Of inputs. + * + * @throws Exception On error. + */ + public function getFormInputs(): array + { + global $config; + + include_once $config['homedir'].'/include/functions_gis.php'; + + // Retrieve global - common inputs. + $inputs = parent::getFormInputs(); + + if ((bool) $config['activate_gis'] === true) { + $maps = gis_get_maps(); + } + + $array_map = []; + foreach ($maps as $map) { + if (check_acl($config['id_user'], $map['group_id'], 'MR') === false + && check_acl($config['id_user'], $map['group_id'], 'MW') === false + && check_acl($config['id_user'], $map['group_id'], 'MM') === false + ) { + continue; + } + + $array_map[$map['id_tgis_map']] = $map['map_name']; + } + + // Filters. + $inputs[] = [ + 'class' => 'flex flex-row', + 'label' => __('GIS maps'), + 'arguments' => [ + 'type' => 'select', + 'fields' => $array_map, + 'name' => 'gis_map', + 'return' => true, + 'selected' => ($this->values['gis_map'] === null) ? 0 : $this->values['gis_map'], + ], + ]; + + return $inputs; + } + + + /** + * Get Post for widget. + * + * @return array + */ + public function getPost(): array + { + // Retrieve global - common inputs. + $values = parent::getPost(); + + $values['gis_map'] = \get_parameter('gis_map', 0); + + return $values; + } + + + /** + * Draw widget. + * + * @return string; + */ + public function load() + { + global $config; + + include_once $config['homedir'].'/include/functions_gis.php'; + include_once $config['homedir'].'/include/functions_agents.php'; + + \ui_require_javascript_file('openlayers.pandora', 'include/javascript/', true); + \ui_require_javascript_file('OpenLayers/OpenLayers', 'include/javascript/', true); + + $map = db_get_row('tgis_map', 'id_tgis_map', $this->values['gis_map']); + + $output = ''; + if (check_acl($config['id_user'], $map['group_id'], 'MR') === false + && check_acl($config['id_user'], $map['group_id'], 'MW') === false + && check_acl($config['id_user'], $map['group_id'], 'MM') === false + ) { + $output .= '
'; + $output .= ui_print_error_message( + __('You don\'t have access'), + '', + true + ); + $output .= '
'; + return $output; + } + + $confMap = gis_get_map_conf($this->values['gis_map']); + + // Default open map (used to overwrite unlicensed google map view). + $confMapDefault = get_good_con(); + $confMapDefaultFull = json_decode($confMapDefault['conection_data'], true); + $confMapUrlDefault = $confMapDefaultFull['url']; + + $num_baselayer = 0; + // Initialy there is no Gmap base layer. + $gmap_layer = false; + if ($confMap !== false) { + foreach ($confMap as $mapC) { + $baselayers[$num_baselayer]['typeBaseLayer'] = $mapC['connection_type']; + $baselayers[$num_baselayer]['name'] = $mapC['conection_name']; + $baselayers[$num_baselayer]['num_zoom_levels'] = $mapC['num_zoom_levels']; + $decodeJSON = json_decode($mapC['conection_data'], true); + + switch ($mapC['connection_type']) { + case 'OSM': + $baselayers[$num_baselayer]['url'] = $decodeJSON['url']; + break; + + case 'Gmap': + if (!isset($decodeJSON['gmap_key']) || empty($decodeJSON['gmap_key'])) { + // If there is not gmap_key, show the default view. + $baselayers[$num_baselayer]['url'] = $confMapUrlDefault; + $baselayers[$num_baselayer]['typeBaseLayer'] = 'OSM'; + } else { + $baselayers[$num_baselayer]['gmap_type'] = $decodeJSON['gmap_type']; + $baselayers[$num_baselayer]['gmap_key'] = $decodeJSON['gmap_key']; + $gmap_key = $decodeJSON['gmap_key']; + // Once a Gmap base layer is found we mark it to import the API. + $gmap_layer = true; + } + break; + + case 'Static_Image': + $baselayers[$num_baselayer]['url'] = $decodeJSON['url']; + $baselayers[$num_baselayer]['bb_left'] = $decodeJSON['bb_left']; + $baselayers[$num_baselayer]['bb_right'] = $decodeJSON['bb_right']; + $baselayers[$num_baselayer]['bb_bottom'] = $decodeJSON['bb_bottom']; + $baselayers[$num_baselayer]['bb_top'] = $decodeJSON['bb_top']; + $baselayers[$num_baselayer]['image_width'] = $decodeJSON['image_width']; + $baselayers[$num_baselayer]['image_height'] = $decodeJSON['image_height']; + break; + + case 'WMS': + $baselayers[$num_baselayer]['url'] = $decodeJSON['url']; + $baselayers[$num_baselayer]['layers'] = $decodeJSON['layers']; + break; + + default: + // Do nothing. + break; + } + + $num_baselayer++; + if ($mapC['default_map_connection'] == 1) { + $numZoomLevels = $mapC['num_zoom_levels']; + } + } + } + + if ($gmap_layer === true) { + if (https_is_running()) { + ?> + + + + values['gis_map']); + + $output .= '
'; + gis_print_map( + 'map_'.$this->cellId, + $map['zoom_level'], + $map['initial_latitude'], + $map['initial_longitude'], + $baselayers, + $controls + ); + $output .= '
'; + + if (empty($layers) === false) { + foreach ($layers as $layer) { + gis_make_layer( + $layer['layer_name'], + $layer['view_layer'], + null, + $layer['id_tmap_layer'] + ); + + // Calling agents_get_group_agents with none to obtain the names in the same case as they are in the DB. + $agentNamesByGroup = []; + if ($layer['tgrupo_id_grupo'] >= 0) { + $agentNamesByGroup = agents_get_group_agents( + $layer['tgrupo_id_grupo'], + false, + 'none', + true, + true, + false + ); + } + + $agentNamesByLayer = gis_get_agents_layer($layer['id_tmap_layer']); + + $groupsByAgentId = gis_get_groups_layer_by_agent_id($layer['id_tmap_layer']); + $agentNamesOfGroupItems = []; + foreach ($groupsByAgentId as $agentId => $groupInfo) { + $agentNamesOfGroupItems[$agentId] = $groupInfo['agent_name']; + } + + $agentNames = array_unique($agentNamesByGroup + $agentNamesByLayer + $agentNamesOfGroupItems); + + foreach ($agentNames as $key => $agentName) { + $idAgent = $key; + $coords = gis_get_data_last_position_agent($idAgent); + + if ($coords === false) { + $coords['stored_latitude'] = $map['default_latitude']; + $coords['stored_longitude'] = $map['default_longitude']; + } else { + if ($show_history == 'y') { + $lastPosition = [ + 'longitude' => $coords['stored_longitude'], + 'latitude' => $coords['stored_latitude'], + ]; + gis_add_path($layer['layer_name'], $idAgent, $lastPosition); + } + } + + $status = agents_get_status($idAgent, true); + $icon = gis_get_agent_icon_map($idAgent, true, $status); + $icon_size = getimagesize($icon); + $icon_width = $icon_size[0]; + $icon_height = $icon_size[1]; + + // Is a group item. + if (empty($groupsByAgentId[$idAgent]) === false) { + $groupId = (int) $groupsByAgentId[$idAgent]['id']; + $groupName = $groupsByAgentId[$idAgent]['name']; + + gis_add_agent_point( + $layer['layer_name'], + io_safe_output($groupName), + $coords['stored_latitude'], + $coords['stored_longitude'], + $icon, + $icon_width, + $icon_height, + $idAgent, + $status, + 'point_group_info', + $groupId + ); + } else { + $parent = db_get_value('id_parent', 'tagente', 'id_agente', $idAgent); + + gis_add_agent_point( + $layer['layer_name'], + io_safe_output($agentName), + $coords['stored_latitude'], + $coords['stored_longitude'], + $icon, + $icon_width, + $icon_height, + $idAgent, + $status, + 'point_agent_info', + $parent + ); + } + } + } + + gis_add_parent_lines(); + + $timestampLastOperation = db_get_value_sql('SELECT UNIX_TIMESTAMP()'); + + gis_activate_select_control(); + gis_activate_ajax_refresh($layers, $timestampLastOperation); + } + + return $output; + } + + + /** + * Get description. + * + * @return string. + */ + public static function getDescription() + { + return __('GIS map'); + } + + + /** + * Get Name. + * + * @return string. + */ + public static function getName() + { + return 'GisMap'; + } + + + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration(): array + { + $size = [ + 'width' => 500, + 'height' => 300, + ]; + + return $size; + } + + +} diff --git a/pandora_console/operation/gis_maps/render_view.php b/pandora_console/operation/gis_maps/render_view.php index e6cfaaee99..d826095a50 100644 --- a/pandora_console/operation/gis_maps/render_view.php +++ b/pandora_console/operation/gis_maps/render_view.php @@ -304,23 +304,7 @@ if ($layers != false) { gis_add_parent_lines(); - switch ($config['dbtype']) { - case 'mysql': - $timestampLastOperation = db_get_value_sql('SELECT UNIX_TIMESTAMP()'); - break; - - case 'postgresql': - $timestampLastOperation = db_get_value_sql( - "SELECT ceil(date_part('epoch', CURRENT_TIMESTAMP))" - ); - break; - - case 'oracle': - $timestampLastOperation = db_get_value_sql( - "SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) FROM dual' - ); - break; - } + $timestampLastOperation = db_get_value_sql('SELECT UNIX_TIMESTAMP()'); gis_activate_select_control(); gis_activate_ajax_refresh($layers, $timestampLastOperation); diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index a7df8d9764..25b7cc781d 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -2832,7 +2832,8 @@ INSERT INTO `twidget` (`id`,`class_name`,`unique_name`,`description`,`options`,` (44,'WuxWidget','wux_transaction','Agent WUX transaction','','wux_transaction.php'), (45,'WuxStatsWidget','wux_transaction_stats','WUX transaction stats','','wux_transaction_stats.php'), (46,'SecurityHardening','security_hardening','Security Hardening','','security_hardening.php'), - (47,'ServiceLevelWidget','service_level','Service Level','','service_level.php'); + (47,'ServiceLevelWidget','service_level','Service Level','','service_level.php'), + (48,'GisMap','GisMap','Gis map','','GisMap.php'); INSERT INTO `tmap` (`id`,`id_group`,`id_user`,`type`,`subtype`,`name`,`description`,`height`,`width`,`center_x`,`center_y`,`background`,`background_options`,`source_period`,`source`,`source_data`,`generation_method`,`generated`,`filter`,`id_group_map`,`refresh_time`) VALUES (1,'0','admin',0,0,'Sample dynamic map','This is a sample dynamic map.',900,900,0,0,'',0,60,0,'0',6,0,'{\"dont_show_subgroups\":0,\"node_radius\":40,\"x_offs\":\"0\",\"y_offs\":\"0\",\"z_dash\":\"1\",\"node_sep\":\"0.25\",\"rank_sep\":\"0.5\",\"mindist\":\"1\",\"kval\":\"0.3\"}',0,300); INSERT INTO `treport` (`id_report`,`id_user`,`name`,`description`,`private`,`id_group`,`custom_logo`,`header`,`first_page`,`footer`,`custom_font`,`id_template`,`id_group_edit`,`metaconsole`,`non_interactive`,`hidden`,`orientation`,`cover_page_render`,`index_render`) VALUES (1,'admin','Sample report #1','This is a sample report, just to show you some general report items.',0,0,NULL,NULL,'<p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;"><img src="http://localhost/pandora_console//images/pandora_report_logo.png" alt="" width="800" /></p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;"><span style="font-size: xx-large;">(_REPORT_NAME_)</span></p> <p style="text-align: center;"><span style="font-size: large;">(_DATETIME_)</span></p>',NULL,'Lato-Regular.ttf',0,0,0,0,0,'vertical',1,1); diff --git a/pandora_console/views/dashboard/listWidgets.php b/pandora_console/views/dashboard/listWidgets.php index 01767c1f9c..2c4272ddeb 100644 --- a/pandora_console/views/dashboard/listWidgets.php +++ b/pandora_console/views/dashboard/listWidgets.php @@ -71,6 +71,10 @@ foreach ($widgets as $widget) { continue; } + if ($widget['unique_name'] === 'GisMap' && (bool) $config['activate_gis'] === false) { + continue; + } + $imageWidget = '/images/widgets/'.$widget['unique_name'].'.png'; $output .= '
'; From 678972bc587a9938cf7931b938ee7545125db77b Mon Sep 17 00:00:00 2001 From: "felix.suarez" Date: Tue, 9 Jan 2024 16:01:00 -0600 Subject: [PATCH 06/40] Add monitoring types --- pandora_agents/unix/pandora_agent | 59 ++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 65e217abf7..c56ccf33aa 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -3889,7 +3889,8 @@ sub module_logger ($) { my $status = grep_logs( $module->{'name'}, $module->{'params'}, - $module->{'filter'} + $module->{'filter'}, + $module->{'type'} ); return $status; @@ -3926,20 +3927,25 @@ my $encode_sub = defined(&MIME::Base64::encode_base64) ? \&MIME::Base64::encode_ }; sub grep_logs { - my ($str_name, $str_file, $str_regex) = @_; + my ($module_name, $log_file, $reg_exp, $module_type) = @_; - if(!$str_name){ + if(!$module_name){ log_message("module_logger", "Missing module name"); return; } - if(!$str_file){ + if(!$log_file){ log_message("module_logger", "Missing file name"); return; } - if(!$str_regex){ - $str_regex = '.*'; + if(!$module_type){ + log_message("module_logger", "Missing module type"); + return; + } + + if(!$reg_exp){ + $reg_exp = '.*'; } my $idx_dir = '/tmp/'; @@ -3947,9 +3953,6 @@ sub grep_logs { my $idx_pos = 0; my $idx_size = 0; my $idx_ino = ''; - my $module_name = $str_name; - my $log_file = $str_file; - my $reg_exp = $str_regex; # Check that log file exists if (! -e $log_file) { @@ -3975,7 +3978,7 @@ sub grep_logs { return if load_idx(\$idx_pos, \$idx_ino, \$idx_file, \$idx_size) == 1; my @data = parse_log(\$idx_pos, \$idx_ino, \$idx_file, \$log_file, \$module_name, \$reg_exp, \$idx_size); - my $output = create_log($module_name, @data); + my $output = create_log($module_name, $module_type, @data); return $output; } @@ -4090,19 +4093,26 @@ sub grep_logs { } sub create_log { - my ($module_name, @data) = @_; + my ($module_name, $module_type, @data) = @_; # No data - if ($#data < 0) { + if ($#data < 0 && $module_type ne "generic_proc") { return; } # Log module my $output = "\n"; - $output .= "\n"; - $output .= "base64\n"; - $output .= "\n"; + $output .= " \n"; + + my $data_content = process_log_monitoring($module_type, @data); + + if($module_type eq "log"){ + $output .= " base64\n"; + } + + $output .= " \n"; $output .= "\n"; @@ -4111,6 +4121,23 @@ sub grep_logs { } +sub process_log_monitoring { + my ($module_type, @data) = @_; + my $output = ""; + + if ($module_type eq "log"){ + $output = &$encode_sub(join('', @data), ''); + } elsif ($module_type eq "generic_data") { + $output = scalar @data; + } elsif ($module_type eq "generic_proc"){ + $output = scalar @data > 0 ? 1 : 0; + } elsif ($module_type eq "generic_data_string" || $module_type eq "async_string"){ + $output = join('', @data); + } + + return $output; +} + ################################################################################ # TERM Handler ################################################################################ From bb2d908de724b4af9cdd3c9864b13d24e37d8727 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 17 Jan 2024 12:25:57 +0100 Subject: [PATCH 07/40] #12460 fixed deprecated log --- .../godmode/wizards/Applications.class.php | 14 ++++++++++++++ pandora_console/godmode/wizards/Custom.class.php | 14 ++++++++++++++ .../godmode/wizards/DiscoveryTaskList.class.php | 7 +++++++ pandora_console/godmode/wizards/Wizard.main.php | 2 +- pandora_console/include/api.php | 4 +++- pandora_console/include/auth/mysql.php | 2 +- pandora_console/include/functions_events.php | 3 ++- pandora_console/include/functions_ui.php | 6 +----- .../lib/TacticalView/elements/SnmpTraps.php | 12 ++++++++++-- pandora_console/operation/events/events.php | 6 +++--- 10 files changed, 56 insertions(+), 14 deletions(-) diff --git a/pandora_console/godmode/wizards/Applications.class.php b/pandora_console/godmode/wizards/Applications.class.php index 7458aea872..29fee2e73a 100644 --- a/pandora_console/godmode/wizards/Applications.class.php +++ b/pandora_console/godmode/wizards/Applications.class.php @@ -37,6 +37,20 @@ class Applications extends Wizard */ public $mode; + /** + * Task properties. + * + * @var array + */ + public $task; + + /** + * Class of styles. + * + * @var string + */ + public $class; + /** * Constructor. diff --git a/pandora_console/godmode/wizards/Custom.class.php b/pandora_console/godmode/wizards/Custom.class.php index 41a177b3e3..9ddec3d9af 100644 --- a/pandora_console/godmode/wizards/Custom.class.php +++ b/pandora_console/godmode/wizards/Custom.class.php @@ -37,6 +37,20 @@ class Custom extends Wizard */ public $mode; + /** + * Task properties. + * + * @var array + */ + public $task; + + /** + * Class of styles. + * + * @var string + */ + public $class; + /** * Constructor. diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php index e831022c23..3a7628d8b9 100644 --- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -47,6 +47,13 @@ ui_require_javascript_file('simTree'); class DiscoveryTaskList extends HTML { + /** + * Task properties. + * + * @var array + */ + public $task; + /** * Constructor. diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index a286b97fca..06276cb187 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -517,7 +517,7 @@ class Wizard public static function printBigButtonsList($list_data) { echo '
    '; - array_map('self::printBigButtonElement', $list_data); + array_map(['Wizard', 'printBigButtonElement'], $list_data); echo '
'; } diff --git a/pandora_console/include/api.php b/pandora_console/include/api.php index b29dd06bd3..4836f98c64 100644 --- a/pandora_console/include/api.php +++ b/pandora_console/include/api.php @@ -380,5 +380,7 @@ if (session_status() !== PHP_SESSION_DISABLED) { // Could give a warning if no session file is created. Ignore. @session_destroy(); header_remove('Set-Cookie'); - setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/'); + if (isset($_COOKIE[session_name()]) === true) { + setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/'); + } } diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php index 76a6458f32..0a132829bf 100644 --- a/pandora_console/include/auth/mysql.php +++ b/pandora_console/include/auth/mysql.php @@ -575,7 +575,7 @@ function get_user_info($user) function get_users($order='fullname', $filter=false, $fields=false) { if (is_array($order) === true) { - $filter['order'] = $order['field'].' '.$order['order']; + $filter['order'] = (string) $order['field'].' '.(string) $order['order']; } else { if ($order !== 'registered' || $order !== 'last_connect' || $order !== 'fullname') { $order = 'fullname'; diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 747e5154ce..1f7a839e31 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -6471,7 +6471,8 @@ function event_print_graph( ]; $color[] = '#82b92f'; } - } else { + } else if ((int) $num_intervals > 0) { + // We assume that if num_interval is 0, not exist events. $interval_length = (int) ($period / $num_intervals); $intervals = []; $intervals[0] = $start_utimestamp; diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 4a0db88991..cbfe60d7db 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -147,11 +147,7 @@ function ui_print_truncate_text( $text_html_decoded = io_safe_output($text); $text_has_entities = $text != $text_html_decoded; - if ($text_html_decoded === null) { - $text_html_decoded = ''; - } - - if (mb_strlen($text_html_decoded, 'UTF-8') > ($numChars)) { + if (isset($text_html_decoded) === true && mb_strlen($text_html_decoded, 'UTF-8') > ($numChars)) { // '/2' because [...] is in the middle of the word. $half_length = intval(($numChars - 3) / 2); diff --git a/pandora_console/include/lib/TacticalView/elements/SnmpTraps.php b/pandora_console/include/lib/TacticalView/elements/SnmpTraps.php index f606893429..9e1de4d891 100644 --- a/pandora_console/include/lib/TacticalView/elements/SnmpTraps.php +++ b/pandora_console/include/lib/TacticalView/elements/SnmpTraps.php @@ -83,7 +83,11 @@ class SnmpTraps extends Element { if ($this->isEnabled() === true) { $value = $this->valueMonitoring('snmp_trap_queue'); - $total = round($value[0]['data']); + if (isset($value[0]['data']) === true) { + $total = round($value[0]['data']); + } else { + $total = __('N/A'); + } } else { $total = __('N/A'); } @@ -109,7 +113,11 @@ class SnmpTraps extends Element { if ($this->isEnabled() === true) { $value = $this->valueMonitoring('total_trap'); - $total = round($value[0]['data']); + if (isset($value[0]['data']) === true) { + $total = round($value[0]['data']); + } else { + $total = __('N/A'); + } } else { $total = __('N/A'); } diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index c924794d6d..976012720a 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -505,7 +505,7 @@ if (is_ajax() === true) { } } - if (strlen(($tmp->server_name ?? '')) >= 10) { + if (isset($tmp->server_name) === true && strlen($tmp->server_name) >= 10) { $tmp->server_name = ui_print_truncate_text( $tmp->server_name, 10, @@ -1216,7 +1216,7 @@ if (is_ajax() === true) { if (empty($tmp) === false && $regex !== '') { $regex_validation = false; foreach (json_decode(json_encode($tmp), true) as $key => $field) { - if (preg_match('/'.$regex.'/', $field)) { + if (isset($field) === true && preg_match('/'.$regex.'/', $field)) { $regex_validation = true; } } @@ -1234,7 +1234,7 @@ if (is_ajax() === true) { $data = array_values( array_filter( - $data, + ((is_array($data) === true) ? $data : []), function ($item) { return (bool) (array) $item; } From 209b4b3e8bbb2ec6c0dc7711395fa8b58b5f8298 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 17 Jan 2024 12:41:56 +0100 Subject: [PATCH 08/40] #12460 fixed deprecated in library phpchartjs --- .../vendor/artica/phpchartjs/src/Delegate/JsonSerializable.php | 2 +- .../vendor/artica/phpchartjs/src/Options/Elements.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/vendor/artica/phpchartjs/src/Delegate/JsonSerializable.php b/pandora_console/vendor/artica/phpchartjs/src/Delegate/JsonSerializable.php index abf59aa9f6..c689aae0ac 100644 --- a/pandora_console/vendor/artica/phpchartjs/src/Delegate/JsonSerializable.php +++ b/pandora_console/vendor/artica/phpchartjs/src/Delegate/JsonSerializable.php @@ -15,7 +15,7 @@ trait JsonSerializable /** * @return array */ - public function jsonSerialize() + public function jsonSerialize():mixed { return array_map(function ($value) { if ($value instanceof JsonSerializableInterface) { diff --git a/pandora_console/vendor/artica/phpchartjs/src/Options/Elements.php b/pandora_console/vendor/artica/phpchartjs/src/Options/Elements.php index b63513bc23..4350718958 100644 --- a/pandora_console/vendor/artica/phpchartjs/src/Options/Elements.php +++ b/pandora_console/vendor/artica/phpchartjs/src/Options/Elements.php @@ -148,7 +148,7 @@ class Elements implements ArraySerializableInterface, JsonSerializable /** * @return array */ - public function jsonSerialize() + public function jsonSerialize():mixed { return $this->getArrayCopy(); } From 29207ed367a1c2383c0cc3ba0e9439bedc7e57a6 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 22 Jan 2024 12:59:11 +0100 Subject: [PATCH 09/40] #12617 add class correct colum --- pandora_console/godmode/servers/servers.build_table.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/servers/servers.build_table.php b/pandora_console/godmode/servers/servers.build_table.php index 23a284caf9..1589f33fc9 100644 --- a/pandora_console/godmode/servers/servers.build_table.php +++ b/pandora_console/godmode/servers/servers.build_table.php @@ -115,7 +115,7 @@ foreach ($servers as $server) { $table->cellclass[] = [ 3 => 'progress_bar', - 8 => 'table_action_buttons', + 9 => 'table_action_buttons', ]; $data[0] = ''.strip_tags($server['name']).''; From 17056e4ac33cf26abbb74d360e37bd967196f111 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 22 Jan 2024 15:30:46 +0100 Subject: [PATCH 10/40] #12460 merge with 12643 --- pandora_console/operation/events/events.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 86a499762f..a668829d49 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -1253,15 +1253,6 @@ if (is_ajax() === true) { ); } - $data = array_values( - array_filter( - ((is_array($data) === true) ? $data : []), - function ($item) { - return (bool) (array) $item; - } - ) - ); - $count = count($data); // RecordsTotal && recordsfiltered resultados totales. echo json_encode( [ From a747308b268e4d3c9c1b04b1c5f721473e6e9b04 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 22 Jan 2024 16:21:51 +0100 Subject: [PATCH 11/40] #12636 fix errors --- pandora_console/godmode/setup/os.builder.php | 6 ++-- pandora_console/godmode/setup/os.php | 8 ++++++ pandora_console/include/functions_ui.php | 30 ++++++++++++++------ 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/pandora_console/godmode/setup/os.builder.php b/pandora_console/godmode/setup/os.builder.php index 6313aa3edd..4f7b77099b 100644 --- a/pandora_console/godmode/setup/os.builder.php +++ b/pandora_console/godmode/setup/os.builder.php @@ -48,7 +48,7 @@ if ($idOS > 0) { } else { $name = io_safe_input(strip_tags(trim(io_safe_output((string) get_parameter('name'))))); $description = io_safe_input(strip_tags(io_safe_output((string) get_parameter('description')))); - $icon = get_parameter('icon', 0); + $icon = get_parameter('icon', 'os@svg.svg'); } $icon_upload = get_parameter('icon_upload', null); @@ -246,7 +246,7 @@ $iconData[] = html_print_select( 'icon', $icon, 'show_icon_OS();', - __('None'), + '', 0, true ); @@ -356,6 +356,8 @@ function get_list_os_icons_dir() } } + $return['os@svg.svg'] = __('None'); + return $return; } diff --git a/pandora_console/godmode/setup/os.php b/pandora_console/godmode/setup/os.php index dcfe95ecdb..403232c868 100644 --- a/pandora_console/godmode/setup/os.php +++ b/pandora_console/godmode/setup/os.php @@ -88,6 +88,14 @@ switch ($tab) { break; case 'manage_os': + $id_os = get_parameter('id_os', ''); + if ($id_os !== '') { + $headerTitle = __('Edit OS'); + } else { + $headerTitle = __('Create OS'); + } + break; + case 'list': if ($action === 'edit') { $headerTitle = __('Edit OS'); diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index d6078c56a7..f36b024ac1 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -969,15 +969,27 @@ function ui_print_os_icon( $options['title'] = $os_name; } - $output = html_print_image( - 'images/'.$subfolder.'/'.$icon, - true, - $options, - false, - $relative, - $no_in_meta, - true - ); + if ($icon === '.png') { + $output = html_print_image( + 'images/os@svg.svg', + true, + $options, + false, + $relative, + $no_in_meta, + true + ); + } else { + $output = html_print_image( + 'images/'.$subfolder.'/'.$icon, + true, + $options, + false, + $relative, + $no_in_meta, + true + ); + } } } else { // $output = "" . $os_name . ""; From 7f604f0c8dccbb4795fcfaeae9e33af860dc4b42 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Tue, 23 Jan 2024 17:47:26 +0100 Subject: [PATCH 12/40] #12460 fixed deprecated --- pandora_console/include/graphs/functions_gd.php | 7 +++++++ .../include/lib/ClusterViewer/ClusterWizard.php | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/pandora_console/include/graphs/functions_gd.php b/pandora_console/include/graphs/functions_gd.php index e32e76222f..b34bed47f7 100755 --- a/pandora_console/include/graphs/functions_gd.php +++ b/pandora_console/include/graphs/functions_gd.php @@ -301,6 +301,13 @@ function gd_progress_bubble($width, $height, $progress, $title, $font, $out_of_l function ImageRectangleWithRoundedCorners(&$im, $x1, $y1, $x2, $y2, $radius, $color) { + $x1 = (int) $x1; + $y1 = (int) $y1; + $x2 = (int) $x2; + $y2 = (int) $y2; + $radius = (int) $radius; + $color = (int) $color; + // Draw rectangle without corners imagefilledrectangle($im, ($x1 + $radius), $y1, ($x2 - $radius), $y2, $color); imagefilledrectangle($im, $x1, ($y1 + $radius), $x2, ($y2 - $radius), $color); diff --git a/pandora_console/include/lib/ClusterViewer/ClusterWizard.php b/pandora_console/include/lib/ClusterViewer/ClusterWizard.php index 3c4c4eb293..0c67cc64f9 100644 --- a/pandora_console/include/lib/ClusterViewer/ClusterWizard.php +++ b/pandora_console/include/lib/ClusterViewer/ClusterWizard.php @@ -113,6 +113,13 @@ class ClusterWizard extends \HTML */ private $agent; + /** + * Id of clusters. + * + * @var integer + */ + public $id; + /** * Builds a Cluster Wizard. From fd8d233cf88cf2195f1242bdd3f4528de07527c4 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 24 Jan 2024 13:28:43 +0100 Subject: [PATCH 13/40] #12460 fixed deprecated --- pandora_console/godmode/agentes/module_manager_editor.php | 2 +- .../godmode/agentes/module_manager_editor_plugin.php | 7 ++++++- pandora_console/godmode/wizards/HostDevices.class.php | 2 +- pandora_console/include/class/Diagnostics.class.php | 7 +++++++ pandora_console/include/class/NetworkMap.class.php | 2 +- pandora_console/include/functions.php | 6 +++++- pandora_console/include/functions_io.php | 4 +--- 7 files changed, 22 insertions(+), 8 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index 130f31c79d..543d241fc9 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -150,7 +150,7 @@ if (is_ajax()) { $component = db_get_row('tlocal_component', 'id', $id_component); foreach ($component as $index => $element) { $component[$index] = html_entity_decode( - $element, + (isset($element) === true) ? $element : '', ENT_QUOTES, 'UTF-8' ); diff --git a/pandora_console/godmode/agentes/module_manager_editor_plugin.php b/pandora_console/godmode/agentes/module_manager_editor_plugin.php index 9b5d98c27d..abbbc4d9c1 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_plugin.php +++ b/pandora_console/godmode/agentes/module_manager_editor_plugin.php @@ -60,7 +60,12 @@ $data[1] = html_print_select_from_sql( $disabledBecauseInPolicy ); // Store the macros in base64 into a hidden control to move between pages -$data[1] .= html_print_input_hidden('macros', base64_encode($macros), true); +$data[1] .= html_print_input_hidden( + 'macros', + (isset($macros) === true) ? base64_encode($macros) : '', + true +); + $table_simple->colspan['plugin_1'][2] = 2; if (!empty($id_plugin)) { diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 4f0043f038..08a47b12f8 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -1109,7 +1109,7 @@ class HostDevices extends Wizard 'return' => true, 'selected' => explode( ',', - $this->task['id_network_profile'] + (isset($this->task['id_network_profile']) === true) ? $this->task['id_network_profile'] : '' ), 'nothing_value' => 0, 'nothing' => __('None'), diff --git a/pandora_console/include/class/Diagnostics.class.php b/pandora_console/include/class/Diagnostics.class.php index 9d4a3b2901..898d9f5af9 100644 --- a/pandora_console/include/class/Diagnostics.class.php +++ b/pandora_console/include/class/Diagnostics.class.php @@ -54,6 +54,13 @@ class Diagnostics extends Wizard */ public $pdf; + /** + * Product name. + * + * @var string + */ + public $product_name; + /** * Constructor. diff --git a/pandora_console/include/class/NetworkMap.class.php b/pandora_console/include/class/NetworkMap.class.php index 184e830e9c..3a8b947926 100644 --- a/pandora_console/include/class/NetworkMap.class.php +++ b/pandora_console/include/class/NetworkMap.class.php @@ -706,7 +706,7 @@ class NetworkMap */ public function setNodes($nodes) { - $this->nodes = $nodes; + $this->nodes = (array) $nodes; } diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 7c1638f8fa..421d3e7725 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -2925,6 +2925,10 @@ function delete_dir($dir) */ function is_image_data($data) { + if (isset($data) === false) { + return false; + } + return (substr($data, 0, 10) == 'data:image'); } @@ -2947,7 +2951,7 @@ function is_snapshot_data($data) */ function is_text_to_black_string($data) { - if (is_image_data($data)) { + if (isset($data) === false || is_image_data($data)) { return false; } diff --git a/pandora_console/include/functions_io.php b/pandora_console/include/functions_io.php index 445504b11c..dd8dd1f6dc 100755 --- a/pandora_console/include/functions_io.php +++ b/pandora_console/include/functions_io.php @@ -561,10 +561,8 @@ function io_output_password($password, $wrappedBy='') ] ); - $output = ($plaintext === ENTERPRISE_NOT_HOOK) ? $password : $plaintext; - // If password already decrypt return same password. - $output = (empty($plaintext) === true) ? $password : $plaintext; + $output = (empty($plaintext) === true || $plaintext === ENTERPRISE_NOT_HOOK) ? $password : $plaintext; return sprintf( '%s%s%s', From 22598b4bc26f08bdba5e5b019da31a99081b156a Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 29 Jan 2024 17:31:19 +0100 Subject: [PATCH 14/40] #12460 fixed deprecated --- pandora_console/include/ajax/heatmap.ajax.php | 1 + .../include/class/OrderInterpreter.class.php | 7 +++++++ .../include/functions_forecast.php | 2 +- .../include/lib/Dashboard/Manager.php | 14 +++++++++++++ .../include/lib/Dashboard/Widget.php | 21 +++++++++++++++++++ .../lib/Dashboard/Widgets/AgentHive.php | 2 +- .../lib/Dashboard/Widgets/DataMatrix.php | 7 +++++++ .../lib/Dashboard/Widgets/ModulesByStatus.php | 7 +++++++ .../lib/Dashboard/Widgets/agent_module.php | 2 +- .../lib/Dashboard/Widgets/events_list.php | 14 +++++++++++++ .../include/lib/Dashboard/Widgets/heatmap.php | 6 +++--- pandora_console/views/dashboard/cell.php | 7 ++++++- 12 files changed, 83 insertions(+), 7 deletions(-) diff --git a/pandora_console/include/ajax/heatmap.ajax.php b/pandora_console/include/ajax/heatmap.ajax.php index 71020ad67f..83c7226388 100644 --- a/pandora_console/include/ajax/heatmap.ajax.php +++ b/pandora_console/include/ajax/heatmap.ajax.php @@ -250,6 +250,7 @@ if (is_ajax() === true) { if ($getInfo === true) { enterprise_include_once('include/functions_agents.php'); + include_once $config['homedir'].'/include/functions_graph.php'; $id = get_parameter('id', 0); $id_server = get_parameter('id_server', 0); if (empty($id_server) === false) { diff --git a/pandora_console/include/class/OrderInterpreter.class.php b/pandora_console/include/class/OrderInterpreter.class.php index d41fbbf837..b96ad6e510 100644 --- a/pandora_console/include/class/OrderInterpreter.class.php +++ b/pandora_console/include/class/OrderInterpreter.class.php @@ -52,6 +52,13 @@ class OrderInterpreter extends Wizard */ public $ajaxController; + /** + * Pages menu + * + * @var array + */ + public $pages_menu; + /** * Generates a JSON error. diff --git a/pandora_console/include/functions_forecast.php b/pandora_console/include/functions_forecast.php index 540bbf7174..1f0d1e59d9 100644 --- a/pandora_console/include/functions_forecast.php +++ b/pandora_console/include/functions_forecast.php @@ -100,7 +100,7 @@ function forecast_projection_graph( $data[0] = ''; $data[1] = $cont; - $data[2] = date($config['date_format'], $row[0]); + $data[2] = date($config['date_format'], (int) $row[0]); $data[3] = $row[0]; $data[4] = $row[1]; $data[5] = ($row[0] * $row[1]); diff --git a/pandora_console/include/lib/Dashboard/Manager.php b/pandora_console/include/lib/Dashboard/Manager.php index 670487081d..c5b75dcb4d 100644 --- a/pandora_console/include/lib/Dashboard/Manager.php +++ b/pandora_console/include/lib/Dashboard/Manager.php @@ -167,6 +167,20 @@ class Manager implements PublicLogin */ private $duplicateCellId; + /** + * Url + * + * @var string + */ + public $url; + + /** + * Widget + * + * @var Widget + */ + public $cWidget; + /** * Allowed methods to be called using AJAX request. * diff --git a/pandora_console/include/lib/Dashboard/Widget.php b/pandora_console/include/lib/Dashboard/Widget.php index 5746bdb142..f8079571c4 100644 --- a/pandora_console/include/lib/Dashboard/Widget.php +++ b/pandora_console/include/lib/Dashboard/Widget.php @@ -65,6 +65,27 @@ class Widget */ private $dateTo; + /** + * Data cell + * + * @var array + */ + public $dataCell; + + /** + * Overflow scrollbar. + * + * @var boolean + */ + public $overflow_scrollbars; + + /** + * Position + * + * @var array + */ + public $position; + /** * Contructor widget. diff --git a/pandora_console/include/lib/Dashboard/Widgets/AgentHive.php b/pandora_console/include/lib/Dashboard/Widgets/AgentHive.php index 0e426ed08a..b393f786ec 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/AgentHive.php +++ b/pandora_console/include/lib/Dashboard/Widgets/AgentHive.php @@ -226,7 +226,7 @@ class AgentHive extends Widget 'name' => 'groups[]', 'returnAllGroup' => false, 'privilege' => 'AR', - 'selected' => explode(',', $values['groups'][0]), + 'selected' => (isset($values['groups'][0]) === true) ? explode(',', $values['groups'][0]) : [], 'return' => true, 'multiple' => true, 'required' => true, diff --git a/pandora_console/include/lib/Dashboard/Widgets/DataMatrix.php b/pandora_console/include/lib/Dashboard/Widgets/DataMatrix.php index 770a3152fe..337f33364e 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/DataMatrix.php +++ b/pandora_console/include/lib/Dashboard/Widgets/DataMatrix.php @@ -117,6 +117,13 @@ class DataMatrix extends Widget */ protected $cellId; + /** + * Position + * + * @var array + */ + public $size; + /** * Construct. diff --git a/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php b/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php index e490135734..767410c25b 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php +++ b/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php @@ -115,6 +115,13 @@ class ModulesByStatus extends Widget */ protected $cellId; + /** + * Size + * + * @var array + */ + public $size; + /** * Construct. diff --git a/pandora_console/include/lib/Dashboard/Widgets/agent_module.php b/pandora_console/include/lib/Dashboard/Widgets/agent_module.php index 56ab854375..f5c4ff5a96 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/agent_module.php +++ b/pandora_console/include/lib/Dashboard/Widgets/agent_module.php @@ -355,7 +355,7 @@ class AgentModuleWidget extends Widget */ public function getIdCacheAgent($id_agents) { - $target_agents = explode(',', $id_agents); + $target_agents = explode(',', ($id_agents ?? '')); $cache_id_agents = []; foreach ($target_agents as $agent_id) { if (str_contains($agent_id, '|') === false) { diff --git a/pandora_console/include/lib/Dashboard/Widgets/events_list.php b/pandora_console/include/lib/Dashboard/Widgets/events_list.php index a50cab93e4..beb7a92b5f 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/events_list.php +++ b/pandora_console/include/lib/Dashboard/Widgets/events_list.php @@ -111,6 +111,20 @@ class EventsListWidget extends Widget */ protected $publicLink; + /** + * Overflow scrollbar. + * + * @var boolean + */ + public $overflow_scrollbars; + + /** + * Position + * + * @var array + */ + public $position; + /** * Construct. diff --git a/pandora_console/include/lib/Dashboard/Widgets/heatmap.php b/pandora_console/include/lib/Dashboard/Widgets/heatmap.php index e199a80ad8..ada804bedb 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/heatmap.php +++ b/pandora_console/include/lib/Dashboard/Widgets/heatmap.php @@ -271,7 +271,7 @@ class HeatmapWidget extends Widget 'name' => 'groups[]', 'returnAllGroup' => true, 'privilege' => 'AR', - 'selected' => explode(',', $values['groups'][0]), + 'selected' => (isset($values['groups'][0]) === true) ? explode(',', $values['groups'][0]) : [], 'return' => true, 'multiple' => true, ], @@ -305,7 +305,7 @@ class HeatmapWidget extends Widget 'type' => 'select', 'fields' => $tags, 'name' => 'tags[]', - 'selected' => explode(',', $values['tags'][0]), + 'selected' => (isset($values['tags'][0]) === true) ? explode(',', $values['tags'][0]) : [], 'return' => true, 'multiple' => true, ], @@ -332,7 +332,7 @@ class HeatmapWidget extends Widget 'type' => 'select', 'fields' => $module_groups, 'name' => 'module_groups[]', - 'selected' => explode(',', $values['module_groups'][0]), + 'selected' => (isset($values['module_groups'][0]) === true) ? explode(',', $values['module_groups'][0]) : [], 'return' => true, 'multiple' => true, 'nothing' => __('Not assigned'), diff --git a/pandora_console/views/dashboard/cell.php b/pandora_console/views/dashboard/cell.php index 5b4e7f311e..910e7a114b 100644 --- a/pandora_console/views/dashboard/cell.php +++ b/pandora_console/views/dashboard/cell.php @@ -34,7 +34,12 @@ if ($redraw === false) { $output .= '
'; $output .= '
'; -$options = json_decode($cellData['options'], true); +if (isset($cellData['options']) === true) { + $options = json_decode($cellData['options'], true); +} else { + $options = []; +} + if ($cellData['id_widget'] !== '0') { $output .= $options['title']; } else { From c0ad5476253eeabe95ede70f5dd43f316aa5a72b Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Tue, 30 Jan 2024 13:14:54 +0100 Subject: [PATCH 15/40] #12460 fixed deprecated --- .../extensions/realtime_graphs/ajax.php | 4 +- .../agentes/module_manager_editor_common.php | 4 +- .../include/class/AuditLog.class.php | 42 +++++++++++++++++++ .../include/class/CredentialStore.class.php | 2 +- .../include/class/SatelliteAgent.class.php | 28 +++++++++++++ .../include/functions_extensions.php | 2 +- .../include/functions_notifications.php | 2 +- .../Dashboard/Widgets/security_hardening.php | 2 +- .../views/dashboard/configurationWidgets.php | 2 +- 9 files changed, 79 insertions(+), 9 deletions(-) diff --git a/pandora_console/extensions/realtime_graphs/ajax.php b/pandora_console/extensions/realtime_graphs/ajax.php index 8b633171ab..1482540f91 100644 --- a/pandora_console/extensions/realtime_graphs/ajax.php +++ b/pandora_console/extensions/realtime_graphs/ajax.php @@ -128,6 +128,6 @@ if (empty($data)) { } echo '{ - "label": "'.htmlspecialchars($graph_title, ENT_QUOTES).'", - "data": [["'.time().'", '.htmlspecialchars($data, ENT_QUOTES).']] + "label": "'.htmlspecialchars(($graph_title ?? ''), ENT_QUOTES).'", + "data": [["'.time().'", '.htmlspecialchars(($data ?? ''), ENT_QUOTES).']] }'; diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index 47c843f2d9..a9d809d29f 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -505,7 +505,7 @@ $tableBasicThresholds->data['caption_switch_warning_inverse_string'][0] = html_p $tableBasicThresholds->data['caption_warning_threshold'][0] .= '('.__('Str.').')'; $tableBasicThresholds->data['warning_threshold'][0] .= html_print_input_text( 'str_warning', - str_replace('"', '', $str_warning), + str_replace('"', '', (isset($str_warning) === true) ? $str_warning : ''), '', 10, 1024, @@ -602,7 +602,7 @@ $tableBasicThresholds->data['switch_critical_threshold'][0] .= html_print_div( $tableBasicThresholds->data['caption_critical_threshold'][0] .= '('.__('Str.').')'; $tableBasicThresholds->data['critical_threshold'][0] .= html_print_input_text( 'str_critical', - str_replace('"', '', $str_critical), + str_replace('"', '', (isset($str_critical) === true) ? $str_critical : ''), '', 10, 1024, diff --git a/pandora_console/include/class/AuditLog.class.php b/pandora_console/include/class/AuditLog.class.php index ceb98875a1..a4988e8042 100644 --- a/pandora_console/include/class/AuditLog.class.php +++ b/pandora_console/include/class/AuditLog.class.php @@ -53,6 +53,48 @@ class AuditLog extends HTML */ private $ajaxController; + /** + * TableId + * + * @var integer + */ + public $tableId; + + /** + * FilterIp + * + * @var array + */ + public $filterIp; + + /** + * FilterPeriod + * + * @var integer + */ + public $filterPeriod; + + /** + * FilterText + * + * @var string + */ + public $filterText; + + /** + * FilterType + * + * @var string + */ + public $filterType; + + /** + * FilterUser + * + * @var string + */ + public $filterUser; + /** * Class constructor diff --git a/pandora_console/include/class/CredentialStore.class.php b/pandora_console/include/class/CredentialStore.class.php index 94036c7ad8..1da01cd96a 100644 --- a/pandora_console/include/class/CredentialStore.class.php +++ b/pandora_console/include/class/CredentialStore.class.php @@ -850,7 +850,7 @@ class CredentialStore extends Wizard 'privilege' => 'AR', 'type' => 'select_groups', 'nothing' => false, - 'selected' => (defined($id_group_filter) ? $id_group_filter : 0), + 'selected' => ((isset($id_group_filter) === true) ? $id_group_filter : 0), 'return' => true, 'size' => '80%', ], diff --git a/pandora_console/include/class/SatelliteAgent.class.php b/pandora_console/include/class/SatelliteAgent.class.php index a40b3ecc7a..5dc149ffb4 100644 --- a/pandora_console/include/class/SatelliteAgent.class.php +++ b/pandora_console/include/class/SatelliteAgent.class.php @@ -67,6 +67,34 @@ class SatelliteAgent extends HTML */ private $ajaxController; + /** + * Satellite_name + * + * @var string + */ + public $satellite_name; + + /** + * Satellite_server + * + * @var string + */ + public $satellite_server; + + /** + * TableId + * + * @var integer + */ + public $tableId; + + /** + * Satellite_config + * + * @var string + */ + public $satellite_config; + /** * Class constructor diff --git a/pandora_console/include/functions_extensions.php b/pandora_console/include/functions_extensions.php index f381484461..0a40a38e5a 100755 --- a/pandora_console/include/functions_extensions.php +++ b/pandora_console/include/functions_extensions.php @@ -440,7 +440,7 @@ function extensions_add_operation_menu_option($name, $fatherId=null, $icon=null, $option_menu['acl'] = $acl; $extension = &$config['extensions'][$extension_file]; - $option_menu['sec2'] = $extension['dir'].'/'.mb_substr($extension_file, 0, -4); + $option_menu['sec2'] = $extension['dir'].'/'.mb_substr(($extension_file ?? ''), 0, -4); $option_menu['fatherId'] = $fatherId; $option_menu['subfatherId'] = $subfatherId; $option_menu['icon'] = $icon; diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 61330b66f7..b6acadc952 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -818,7 +818,7 @@ function notifications_print_global_source_configuration($source) $html_checkboxes = ''; - $blacklist = json_decode($source['subtype_blacklist'], 1); + $blacklist = json_decode(($source['subtype_blacklist'] ?? ''), 1); if (json_last_error() !== JSON_ERROR_NONE) { $blacklist = []; } diff --git a/pandora_console/include/lib/Dashboard/Widgets/security_hardening.php b/pandora_console/include/lib/Dashboard/Widgets/security_hardening.php index 9f7d726677..88e37c58b5 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/security_hardening.php +++ b/pandora_console/include/lib/Dashboard/Widgets/security_hardening.php @@ -446,7 +446,7 @@ class SecurityHardening extends Widget { global $config; - $id_groups = explode(',', $group); + $id_groups = explode(',', ($group ?? '')); if (in_array(0, $id_groups) === true) { $id_groups = array_keys(users_get_groups($config['id_user'], 'AR', false)); } diff --git a/pandora_console/views/dashboard/configurationWidgets.php b/pandora_console/views/dashboard/configurationWidgets.php index 68a51edbaa..24f2019f86 100644 --- a/pandora_console/views/dashboard/configurationWidgets.php +++ b/pandora_console/views/dashboard/configurationWidgets.php @@ -43,7 +43,7 @@ $form = [ 'extra' => 'novalidate', ]; -$js = 'tinymce.init({ +$js .= ' tinymce.init({ selector: "#textarea_text", plugins: "preview, searchreplace, table, nonbreaking, link, image", promotion: false, From f68615cba06e9a3e3647829ebab2a445574d16db Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Tue, 30 Jan 2024 17:00:38 +0100 Subject: [PATCH 16/40] #12460 fixed deprecated --- .../godmode/massive/massive_edit_modules.php | 2 +- pandora_console/godmode/tag/tag.php | 2 +- .../godmode/wizards/Wizard.main.php | 7 +++ .../include/class/CalendarManager.class.php | 7 +++ .../include/class/ExternalTools.class.php | 56 +++++++++++++++++++ pandora_console/include/functions_profile.php | 1 + .../include/functions_treeview.php | 2 +- .../operation/inventory/inventory.php | 2 +- .../lib/UpdateManager/UI/Manager.php | 2 +- 9 files changed, 76 insertions(+), 5 deletions(-) diff --git a/pandora_console/godmode/massive/massive_edit_modules.php b/pandora_console/godmode/massive/massive_edit_modules.php index 9b11b86916..b1e63ff05d 100755 --- a/pandora_console/godmode/massive/massive_edit_modules.php +++ b/pandora_console/godmode/massive/massive_edit_modules.php @@ -1500,7 +1500,7 @@ $table->data[39][0] = html_print_label_input_block( '', '', true - ).html_print_input_hidden('macros', base64_encode($macros), true) + ).html_print_input_hidden('macros', base64_encode(($macros ?? '')), true) ); require_once $config['homedir'].'/include/class/CredentialStore.class.php'; diff --git a/pandora_console/godmode/tag/tag.php b/pandora_console/godmode/tag/tag.php index 220c6c244c..1bef19495e 100644 --- a/pandora_console/godmode/tag/tag.php +++ b/pandora_console/godmode/tag/tag.php @@ -386,7 +386,7 @@ if (empty($result) === false) { $data[4] = $output; $phone_large = io_safe_output($tag['phone']); - $phone_small = substr($phone_large, 0, 24); + $phone_small = substr(($phone_large ?? ''), 0, 24); if ($phone_large == $phone_small) { $output = $phone_large; } else { diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index f48a318c17..9eb223e744 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -97,6 +97,13 @@ class Wizard */ public $access = 'AR'; + /** + * Root url. + * + * @var string + */ + public $rootUrl; + /** * Setter for breadcrum diff --git a/pandora_console/include/class/CalendarManager.class.php b/pandora_console/include/class/CalendarManager.class.php index 560fb6f4ad..b5ef6456a7 100644 --- a/pandora_console/include/class/CalendarManager.class.php +++ b/pandora_console/include/class/CalendarManager.class.php @@ -66,6 +66,13 @@ class CalendarManager */ private $message; + /** + * Access + * + * @var string + */ + public $access; + /** * Allowed methods to be called using AJAX request. * diff --git a/pandora_console/include/class/ExternalTools.class.php b/pandora_console/include/class/ExternalTools.class.php index 7165a4fcbb..215a664cb2 100644 --- a/pandora_console/include/class/ExternalTools.class.php +++ b/pandora_console/include/class/ExternalTools.class.php @@ -38,6 +38,62 @@ require_once $config['homedir'].'/include/class/HTML.class.php'; class ExternalTools extends HTML { + /** + * Origin + * + * @var string + */ + public $origin; + + /** + * PathCustomComm + * + * @var string + */ + public $pathCustomComm; + + /** + * PathDig + * + * @var string + */ + public $pathDig; + + /** + * PathNmap + * + * @var string + */ + public $pathNmap; + + /** + * PathPing + * + * @var string + */ + public $pathPing; + + /** + * PathSnmpget + * + * @var string + */ + public $pathSnmpget; + + /** + * PathTraceroute + * + * @var string + */ + public $pathTraceroute; + + /** + * UpdatePaths + * + * @var string + */ + public $updatePaths; + /** * Constructor. diff --git a/pandora_console/include/functions_profile.php b/pandora_console/include/functions_profile.php index d97edf17aa..278d39f9a6 100644 --- a/pandora_console/include/functions_profile.php +++ b/pandora_console/include/functions_profile.php @@ -243,6 +243,7 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c $profile = json_decode($profile); } + $result = []; $result[] = [ 'id_grupo' => $profile->group, 'id_perfil' => $profile->profile, diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index 66dad24db6..ada7841ab7 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -1039,7 +1039,7 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false) echo "