diff --git a/pandora_agents/pc/pandora_agent_installer b/pandora_agents/pc/pandora_agent_installer
index 7d8de1134d..bcfee3eb00 100644
--- a/pandora_agents/pc/pandora_agent_installer
+++ b/pandora_agents/pc/pandora_agent_installer
@@ -467,7 +467,7 @@ fi
# Script banner at start
echo " "
-echo "Pandora FMS Agent UNIX Installer $PI_VERSION $PI_BUILD (c) 2008-2015 ArticaST"
+echo "Pandora FMS Agent UNIX Installer $PI_VERSION $PI_BUILD (c) 2008-2024 PandoraFMS"
echo "This program is licensed under GPL2 Terms. http://pandorafms.com"
echo " "
diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control
index ee0f6d119d..613b1aa407 100644
--- a/pandora_agents/unix/DEBIAN/control
+++ b/pandora_agents/unix/DEBIAN/control
@@ -1,5 +1,5 @@
package: pandorafms-agent-unix
-Version: 7.0NG.775-240207
+Version: 7.0NG.775-240219
Architecture: all
Priority: optional
Section: admin
diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh
index 157318b744..5775e5add8 100644
--- a/pandora_agents/unix/DEBIAN/make_deb_package.sh
+++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-pandora_version="7.0NG.775-240207"
+pandora_version="7.0NG.775-240219"
echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent
index 417ff01de6..21c40cf1f6 100755
--- a/pandora_agents/unix/pandora_agent
+++ b/pandora_agents/unix/pandora_agent
@@ -1039,7 +1039,7 @@ my $Sem = undef;
my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.775';
-use constant AGENT_BUILD => '240207';
+use constant AGENT_BUILD => '240219';
# Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000;
diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec
index 0daaad573f..0991f751ba 100644
--- a/pandora_agents/unix/pandora_agent.redhat.spec
+++ b/pandora_agents/unix/pandora_agent.redhat.spec
@@ -4,7 +4,7 @@
%global __os_install_post %{nil}
%define name pandorafms_agent_linux
%define version 7.0NG.775
-%define release 240207
+%define release 240219
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}
diff --git a/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec b/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec
index f17d3385b7..8e6422aa1b 100644
--- a/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec
+++ b/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec
@@ -5,7 +5,7 @@
%define name pandorafms_agent_linux_bin
%define source_name pandorafms_agent_linux
%define version 7.0NG.775
-%define release 240207
+%define release 240219
%define debug_package %{nil}
Summary: Pandora FMS Linux agent, binary version
diff --git a/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec b/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec
index fd8eaa717c..ccd6b33a73 100644
--- a/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec
+++ b/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec
@@ -5,7 +5,7 @@
%define name pandorafms_agent_linux_bin
%define source_name pandorafms_agent_linux
%define version 7.0NG.775
-%define release 240207
+%define release 240219
%define debug_package %{nil}
Summary: Pandora FMS Linux agent, binary version
diff --git a/pandora_agents/unix/pandora_agent.redhat_bin.spec b/pandora_agents/unix/pandora_agent.redhat_bin.spec
index 77ffa9603e..5ba59b0f96 100644
--- a/pandora_agents/unix/pandora_agent.redhat_bin.spec
+++ b/pandora_agents/unix/pandora_agent.redhat_bin.spec
@@ -5,7 +5,7 @@
%define name pandorafms_agent_linux_bin
%define source_name pandorafms_agent_linux
%define version 7.0NG.775
-%define release 240207
+%define release 240219
Summary: Pandora FMS Linux agent, binary version
Name: %{name}
diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec
index df8a8298ab..3e33ba4e3b 100644
--- a/pandora_agents/unix/pandora_agent.spec
+++ b/pandora_agents/unix/pandora_agent.spec
@@ -4,7 +4,7 @@
%global __os_install_post %{nil}
%define name pandorafms_agent_linux
%define version 7.0NG.775
-%define release 240207
+%define release 240219
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}
diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer
index af838ca3e9..ea2422a4d5 100755
--- a/pandora_agents/unix/pandora_agent_installer
+++ b/pandora_agents/unix/pandora_agent_installer
@@ -10,7 +10,7 @@
# **********************************************************************
PI_VERSION="7.0NG.775"
-PI_BUILD="240207"
+PI_BUILD="240219"
OS_NAME=`uname -s`
FORCE=0
@@ -579,7 +579,7 @@ fi
# Script banner at start
echo " "
-echo "Pandora FMS Agent UNIX Installer $PI_VERSION $PI_BUILD (c) 2008-2015 ArticaST"
+echo "Pandora FMS Agent UNIX Installer $PI_VERSION $PI_BUILD (c) 2008-2024 PandoraFMS"
echo "This program is licensed under GPL2 Terms. http://pandorafms.com"
echo " "
diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi
index 20ceb59ecc..26c45e0ae4 100644
--- a/pandora_agents/win32/installer/pandora.mpi
+++ b/pandora_agents/win32/installer/pandora.mpi
@@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
-{240207}
+{240219}
ViewReadme
{Yes}
diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc
index 5d63022c43..8565876bc3 100644
--- a/pandora_agents/win32/pandora.cc
+++ b/pandora_agents/win32/pandora.cc
@@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1
-#define PANDORA_VERSION ("7.0NG.775 Build 240207")
+#define PANDORA_VERSION ("7.0NG.775 Build 240219")
string pandora_path;
string pandora_dir;
diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc
index f4a25d4253..21bdebb9a1 100644
--- a/pandora_agents/win32/versioninfo.rc
+++ b/pandora_agents/win32/versioninfo.rc
@@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Pandora FMS"
VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent"
- VALUE "ProductVersion", "(7.0NG.775(Build 240207))"
+ VALUE "ProductVersion", "(7.0NG.775(Build 240219))"
VALUE "FileVersion", "1.0.0.0"
END
END
diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control
index 6db9add67d..9a6579605d 100644
--- a/pandora_console/DEBIAN/control
+++ b/pandora_console/DEBIAN/control
@@ -1,5 +1,5 @@
package: pandorafms-console
-Version: 7.0NG.775-240207
+Version: 7.0NG.775-240219
Architecture: all
Priority: optional
Section: admin
diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh
index da77fff309..efad6ffc68 100644
--- a/pandora_console/DEBIAN/make_deb_package.sh
+++ b/pandora_console/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-pandora_version="7.0NG.775-240207"
+pandora_version="7.0NG.775-240219"
package_pear=0
package_pandora=1
diff --git a/pandora_console/extensions/quick_shell.php b/pandora_console/extensions/quick_shell.php
index 9ea79ba364..a3f5872f84 100644
--- a/pandora_console/extensions/quick_shell.php
+++ b/pandora_console/extensions/quick_shell.php
@@ -394,7 +394,7 @@ function quickShellSettings()
__('Address'),
html_print_input_text(
'gotty_addr',
- $config['gotty_addr'],
+ ($config['gotty_addr'] ?? ''),
'',
30,
100,
@@ -443,9 +443,8 @@ function quickShellSettings()
html_print_checkbox_switch(
'gotty_ssh_use_ssl',
1,
- $config['gotty_ssh_use_ssl'],
- true,
- $disable_agentaccess
+ ($config['gotty_ssh_use_ssl'] ?? false),
+ true
)
);
@@ -497,7 +496,7 @@ function quickShellSettings()
html_print_checkbox_switch(
'gotty_telnet_use_ssl',
1,
- $config['gotty_telnet_use_ssl'],
+ ($config['gotty_telnet_use_ssl'] ?? false),
true
)
);
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/extensions/resource_exportation.php b/pandora_console/extensions/resource_exportation.php
deleted file mode 100755
index 476b7ef1bf..0000000000
--- a/pandora_console/extensions/resource_exportation.php
+++ /dev/null
@@ -1,497 +0,0 @@
-'."\n";
- echo "\n";
- echo ' \n";
- if (isset($report['description'])) {
- echo ' \n";
- }
-
- $group = db_get_value('nombre', 'tgrupo', 'id_grupo', $report['id_group']);
- echo ' \n";
- $items = db_get_all_rows_field_filter(
- 'treport_content',
- 'id_report',
- $report['id_report']
- );
- foreach ($items as $item) {
- echo "- \n";
- echo '
'.io_safe_output($item['type'])." \n";
- echo ''.io_safe_output($item['description'])." \n";
- echo ''.io_safe_output($item['period'])." \n";
- if ($item['id_agent'] != 0) {
- $agent = db_get_value('alias', 'tagente', 'id_agente', $item['id_agent']);
- }
-
- if ($item['id_agent_module'] != 0) {
- $module = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $item['id_agent_module']);
- $id_agent = db_get_value('id_agente', 'tagente_modulo', 'id_agente_modulo', $item['id_agent_module']);
- $agent = db_get_value('alias', 'tagente', 'id_agente', $item['id_agent']);
-
- echo ' \n";
- }
-
- if (isset($agent)) {
- echo ' \n";
- }
-
- $agent = null;
- switch (io_safe_output($item['type'])) {
- case 2:
- case 'custom_graph':
- case 'automatic_custom_graph':
- $graph = db_get_value('name', 'tgraph', 'id_graph', $item['id_gs']);
- echo ' \n";
- break;
-
- case 3:
- case 'SLA':
- echo ''.$item['only_display_wrong']." \n";
- echo ''.$item['monday']." \n";
- echo ''.$item['tuesday']." \n";
- echo ''.$item['wednesday']." \n";
- echo ''.$item['thursday']." \n";
- echo ''.$item['friday']." \n";
- echo ''.$item['saturday']." \n";
- echo ''.$item['sunday']." \n";
- echo ''.$item['time_from']." \n";
- echo ''.$item['time_to']." \n";
-
- $slas = db_get_all_rows_field_filter('treport_content_sla_combined', 'id_report_content', $item['id_rc']);
- if ($slas === false) {
- $slas = [];
- }
-
- foreach ($slas as $sla) {
- $module = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $sla['id_agent_module']);
- $id_agent = db_get_value('id_agente', 'tagente_modulo', 'id_agente_modulo', $sla['id_agent_module']);
- $agent = db_get_value('alias', 'tagente', 'id_agente', $item['id_agent']);
- echo '';
- echo ' \n";
- echo ' \n";
- echo ''.$sla['sla_max']." \n";
- echo ''.$sla['sla_min']." \n";
- echo ''.$sla['sla_limit']." \n";
- echo ' ';
- }
- break;
-
- case 'text':
- echo ' \n";
- break;
-
- case 'sql':
- echo ' \n";
- if (!empty($item['external_source'])) {
- echo ' \n";
- } else {
- $sql = db_get_value('sql', 'treport_custom_sql', 'id', $item['treport_custom_sql_id']);
- echo ''.io_safe_output($sql)." \n";
- }
- break;
-
- case 'sql_graph_pie':
- case 'sql_graph_vbar':
- case 'sql_graph_hbar':
- echo ''.io_safe_output($item['header_definition'])." \n";
- if (!empty($item['external_source'])) {
- echo ''.io_safe_output($item['external_source'])." \n";
- } else {
- $sql = db_get_value('sql', 'treport_custom_sql', 'id', $item['treport_custom_sql_id']);
- echo ''.io_safe_output($sql)." \n";
- }
- break;
-
- case 'event_report_group':
- $group = db_get_value('nombre', 'tgrupo', 'id_grupo', $item['id_agent']);
- echo ' \n";
- break;
-
- case 'url':
- echo ' ';
- break;
-
- case 'database_serialized':
- echo ' ';
- echo ' ';
- echo ' ';
- break;
-
- case 1:
- case 'simple_graph':
- case 'simple_baseline_graph':
- case 6:
- case 'monitor_report':
- case 7:
- case 'avg_value':
- case 8:
- case 'max_value':
- case 9:
- case 'min_value':
- case 10:
- case 'sumatory':
- case 'agent_detailed_event':
- case 'event_report_agent':
- case 'event_report_module':
- case 'alert_report_module':
- case 'alert_report_agent':
- case 'alert_report_group':
- default:
- // Do nothing.
- break;
- }
-
- echo " \n";
- }
-
- echo " \n";
-}
-
-
-function output_xml_visual_console($id)
-{
- $visual_map = db_get_row('tlayout', 'id', $id);
-
- echo ''."\n";
- echo "\n";
- echo ' \n";
- if ($visual_map['id_group'] != 0) {
- $group = db_get_value('nombre', 'tgrupo', 'id_grupo', $visual_map['id_group']);
- echo ' \n";
- }
-
- echo ' \n";
- echo ''.io_safe_output($visual_map['height'])." \n";
- echo ''.io_safe_output($visual_map['width'])." \n";
- $items = db_get_all_rows_field_filter('tlayout_data', 'id_layout', $visual_map['id']);
- if ($items === false) {
- $items = [];
- }
-
- foreach ($items as $item) {
- echo "- \n";
- echo '
'.$item['id']." \n";
- // OLD ID USE FOR parent item
- $agent = '';
- if ($item['id_agent'] != 0) {
- $agent = db_get_value('nombre', 'tagente', 'id_agente', $item['id_agent']);
- }
-
- if (!empty($item['label'])) {
- echo ' \n";
- }
-
- echo ''.$item['pos_x']." \n";
- echo ''.$item['pos_y']." \n";
- echo ''.$item['type']." \n";
- if ($item['width'] != 0) {
- echo ''.$item['width']." \n";
- }
-
- if ($item['height'] != 0) {
- echo ''.$item['height']." \n";
- }
-
- if (!empty($item['image'])) {
- echo ''.$item['image']." \n";
- }
-
- if ($item['period'] != 0) {
- echo ''.$item['period']." \n";
- }
-
- if (isset($item['id_agente_modulo'])) {
- if ($item['id_agente_modulo'] != 0) {
- $module = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $item['id_agente_modulo']);
- $id_agent = db_get_value('id_agente', 'tagente_modulo', 'id_agente_modulo', $item['id_agente_modulo']);
- $agent = db_get_value('nombre', 'tagente', 'id_agente', $id_agent);
-
- echo ' \n";
- }
- }
-
- if (!empty($agent)) {
- echo ' \n";
- }
-
- if ($item['id_layout_linked'] != 0) {
- echo ''.$item['id_layout_linked']." \n";
- }
-
- if ($item['parent_item'] != 0) {
- echo ''.$item['parent_item']." \n";
- }
-
- if (!empty($item['clock_animation'])) {
- echo ''.$item['clock_animation']." \n";
- }
-
- if (!empty($item['fill_color'])) {
- echo ''.$item['fill_color']." \n";
- }
-
- if (!empty($item['type_graph'])) {
- echo ''.$item['type_graph']." \n";
- }
-
- if (!empty($item['time_format'])) {
- echo ''.$item['time_format']." \n";
- }
-
- if (!empty($item['timezone'])) {
- echo ''.$item['timezone']." \n";
- }
-
- if (!empty($item['border_width'])) {
- echo ''.$item['border_width']." \n";
- }
-
- if (!empty($item['border_color'])) {
- echo ''.$item['border_color']." \n";
- }
-
- echo " \n";
- }
-
- echo " \n";
-}
-
-
-function get_name_xml_resource($hook_enterprise)
-{
- global $config;
-
- $type = get_parameter('type');
- $id = (int) get_parameter('id');
-
- switch ($type) {
- case 'report':
- $name = db_get_value('name', 'treport', 'id_report', $id);
- break;
-
- case 'visual_console':
- $name = db_get_value('name', 'tlayout', 'id', $id);
- break;
-
- default:
- if ($hook_enterprise === true) {
- return enterprise_get_name_xml_resource($type, $id);
- }
- break;
- }
-
- $file = io_safe_output($name).'.ptr';
-
- return $file;
-}
-
-
-function get_xml_resource()
-{
- global $config;
-
- $hook_enterprise = enterprise_include('extensions/resource_exportation/functions.php');
-}
-
-
-function resource_exportation_extension_main()
-{
- global $config;
-
- check_login();
-
- if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user'])) {
- db_pandora_audit(
- AUDIT_LOG_ACL_VIOLATION,
- 'Trying to access Setup Management'
- );
- include 'general/noaccess.php';
- return;
- }
-
- $hook_enterprise = enterprise_include('extensions/resource_exportation/functions.php');
-
- ui_print_standard_header(
- __('Resource exportation'),
- 'images/extensions.png',
- false,
- '',
- true,
- [],
- [
- [
- 'link' => '',
- 'label' => __('Resources'),
- ],
- [
- 'link' => '',
- 'label' => __('Resource exporting'),
- ],
- ]
- );
-
- ui_print_warning_message(
- __('This extension makes exportation of resource template more easy.').' '.__('You can export resource templates in .ptr format.')
- );
-
- $table = new stdClass();
- $table->class = 'databox filter-table-adv';
- $table->id = 'resource_exportation_table';
- $table->style = [];
- $table->style[0] = 'width: 30%';
- $table->style[1] = 'vertical-align: bottom;';
- $table->data = [];
- $table->data[0][] = html_print_label_input_block(
- __('Report'),
- html_print_div(
- [
- 'class' => 'flex-content-left',
- 'content' => html_print_select_from_sql('SELECT id_report, name FROM treport', 'report', '', '', '', 0, true),
- ],
- true
- )
- );
- $table->data[0][] = html_print_button(__('Export'), '', false, 'export_to_ptr("report");', '', true);
-
- $table->data[1][] = html_print_label_input_block(
- __('Visual console'),
- html_print_div(
- [
- 'class' => 'flex-content-left',
- 'content' => html_print_select_from_sql('SELECT id, name FROM tlayout', 'visual_console', '', '', '', 0, true),
- ],
- true
- )
- );
- $table->data[1][] = html_print_button(__('Export'), '', false, 'export_to_ptr("visual_console");', '', true);
-
- if ($hook_enterprise === true) {
- add_rows_for_enterprise($table->data);
- }
-
- html_print_table($table);
-
- ?>
-
- $name) {
- $values['id_report'] = $id;
- $result = (bool) db_process_sql_insert('treport_content', $values);
-
- ui_print_result_message(
- $result,
- sprintf(
- __("Success add '%s' item in report '%s'."),
- $values['type'],
- $name
- ),
- sprintf(
- __("Error create '%s' item in report '%s'."),
- $values['type'],
- $name
- )
- );
- }
-}
-
-
-function process_upload_xml_report($xml, $group_filter=0)
-{
- foreach ($xml->xpath('/report') as $reportElement) {
- $values = [];
-
- if (isset($reportElement->name)) {
- $values['name'] = $reportElement->name;
-
- $posible_name = $values['name'];
- $exist = true;
- $loops = 30;
- // Loops to exit or tries.
- while ($exist && $loops > 0) {
- $exist = (bool) db_get_row_filter(
- 'treport',
- ['name' => io_safe_input($posible_name)]
- );
-
- if ($exist) {
- $loops--;
- $posible_name = $values['name'].' ('.(30 - $loops).')';
- }
- }
-
- if ($exist) {
- ui_print_error_message(
- sprintf(
- __("Error create '%s' report, the name exist and there aren't free name."),
- $reportElement->name
- )
- );
- break;
- } else if ($loops != 30) {
- ui_print_warning_message(
- sprintf(
- __("Warning create '%s' report, the name exist, the report have a name %s."),
- $reportElement->name,
- $posible_name
- )
- );
- }
-
- $values['name'] = io_safe_input($posible_name);
- } else {
- ui_print_error_message(__("Error the report haven't name."));
- break;
- }
-
- if (isset($reportElement->group) === true
- && empty($reportElement->group) === false
- ) {
- $id_group = db_get_value(
- 'id_grupo',
- 'tgrupo',
- 'nombre',
- $reportElement->group
- );
- if ($id_group === false) {
- ui_print_error_message(__("Error the report haven't group."));
- break;
- }
- }
-
- if (isset($reportElement->description) === true) {
- $values['description'] = $reportElement->description;
- }
-
- $id_report = db_process_sql_insert('treport', $values);
-
- ui_print_result_message(
- $id_report,
- sprintf(__("Success create '%s' report."), $posible_name),
- sprintf(__("Error create '%s' report."), $posible_name)
- );
-
- if ($id_report) {
- db_pandora_audit(
- AUDIT_LOG_REPORT_MANAGEMENT,
- 'Create report '.$id_report,
- false,
- false
- );
- } else {
- db_pandora_audit(
- AUDIT_LOG_REPORT_MANAGEMENT,
- 'Fail to create report',
- false,
- false
- );
- break;
- }
-
- foreach ($reportElement->item as $item) {
- $item = (array) $item;
-
- $values = [];
- $values['id_report'] = $id_report;
- if (isset($item['description']) === true) {
- $values['description'] = io_safe_input($item['description']);
- }
-
- if (isset($item['period']) === true) {
- $values['period'] = io_safe_input($item['period']);
- }
-
- if (isset($item['type']) === true) {
- $values['type'] = io_safe_input($item['type']);
- }
-
- $agents_item = [];
- if (isset($item['agent']) === true) {
- $agents = agents_get_agents(
- ['id_grupo' => $group_filter],
- [
- 'id_agente',
- 'alias',
- ]
- );
-
- $agent_clean = str_replace(
- [
- '[',
- ']',
- ],
- '',
- io_safe_output($item['agent'])
- );
- $regular_expresion = ($agent_clean != $item['agent']);
-
- foreach ($agents as $agent) {
- if ($regular_expresion) {
- if ((bool) preg_match('/'.$agent_clean.'/', io_safe_output($agent['alias']))) {
- $agents_item[$agent['id_agente']]['name'] = $agent['alias'];
- }
- } else {
- if ($agent_clean == io_safe_output($agent['alias'])) {
- $agents_item[$agent['id_agente']]['name'] = $agent['alias'];
- }
- }
- }
- }
-
- if (isset($item['module']) === true) {
- $module_clean = str_replace(['[', ']'], '', $item['module']);
- $regular_expresion = ($module_clean != $item['module']);
-
- foreach ($agents_item as $id => $agent) {
- $modules = db_get_all_rows_filter(
- 'tagente_modulo',
- ['id_agente' => $id],
- [
- 'id_agente_modulo',
- 'nombre',
- ]
- );
-
- $agents_item[$id]['modules'] = [];
-
- foreach ($modules as $module) {
- if ($regular_expresion) {
- if ((bool) preg_match('/'.$module_clean.'/', io_safe_output($module['nombre']))) {
- $agents_item[$id]['modules'][$module['id_agente_modulo']]['name'] = $module['nombre'];
- }
- } else {
- if ($module_clean == io_safe_output($module['nombre'])) {
- $agents_item[$id]['modules'][$module['id_agente_modulo']]['name'] = $module['nombre'];
- }
- }
- }
- }
- }
-
- switch ($item['type']) {
- case 2:
- case 'custom_graph':
- case 'automatic_custom_graph':
- $group = db_get_value('id_grupo', 'tgrupo', 'nombre', io_safe_input($item['graph']));
- $values['id_gs'] = $group;
- break;
-
- case 3:
- case 'SLA':
- if (isset($item['only_display_wrong'])) {
- $values['only_display_wrong'] = (string) $item['only_display_wrong'];
- }
-
- if (isset($item['monday'])) {
- $values['monday'] = (string) $item['monday'];
- }
-
- if (isset($item['tuesday'])) {
- $values['tuesday'] = (string) $item['tuesday'];
- }
-
- if (isset($item['wednesday'])) {
- $values['wednesday'] = (string) $item['wednesday'];
- }
-
- if (isset($item['thursday'])) {
- $values['thursday'] = (string) $item['thursday'];
- }
-
- if (isset($item['friday'])) {
- $values['friday'] = (string) $item['friday'];
- }
-
- if (isset($item['saturday'])) {
- $values['saturday'] = (string) $item['saturday'];
- }
-
- if (isset($item['sunday'])) {
- $values['sunday'] = (string) $item['sunday'];
- }
-
- if (isset($item['time_from'])) {
- $values['time_from'] = (string) $item['time_from'];
- }
-
- if (isset($item['time_to'])) {
- $values['time_to'] = (string) $item['time_to'];
- }
-
- $slas = [];
- if (!isset($item['sla'])) {
- $item['sla'] = [];
- }
-
- foreach ($item['sla'] as $sla_xml) {
- if (isset($sla_xml->agent)) {
- $agents = agents_get_agents(['id_grupo' => $group_filter], ['id_agente', 'nombre']);
-
- $agent_clean = str_replace(['[', ']'], '', $sla_xml->agent);
- $regular_expresion = ($agent_clean != $sla_xml->agent);
-
- foreach ($agents as $agent) {
- $id_agent = false;
- if ($regular_expresion) {
- if ((bool) preg_match('/'.$agent_clean.'/', io_safe_output($agent['nombre']))) {
- $id_agent = $agent['id_agente'];
- } else {
- if ($agent_clean == io_safe_output($agent['nombre'])) {
- $id_agent = $agent['id_agente'];
- }
- }
- }
-
- if ($id_agent) {
- if (isset($sla_xml->module)) {
- $module_clean = str_replace(['[', ']'], '', $sla_xml->module);
- $regular_expresion = ($module_clean != $sla_xml->module);
-
- $modules = db_get_all_rows_filter(
- 'tagente_modulo',
- ['id_agente' => $id_agent],
- [
- 'id_agente_modulo',
- 'nombre',
- ]
- );
-
- foreach ($modules as $module) {
- if ($regular_expresion) {
- if ((bool) preg_match('/'.$module_clean.'/', io_safe_output($module['nombre']))) {
- $slas[] = [
- 'id_agent_module' => $module['id_agente_modulo'],
- 'sla_max' => (string) $sla_xml->sla_max,
- 'sla_min' => (string) $sla_xml->sla_min,
- 'sla_limit' => (string) $sla_xml->sla_limit,
- ];
- }
- } else {
- if ($module_clean == io_safe_output($module['nombre'])) {
- $slas[] = [
- 'id_agent_module' => $module['id_agente_modulo'],
- 'sla_max' => (string) $sla_xml->sla_max,
- 'sla_min' => (string) $sla_xml->sla_min,
- 'sla_limit' => (string) $sla_xml->sla_limit,
- ];
- }
- }
- }
- }
- }
- }
- }
- }
- break;
-
- case 'text':
- $values['text'] = io_safe_input($item['text']);
- break;
-
- case 'sql':
- $values['header_definition'] = io_safe_input($item['header_definition']);
- $values['external_source'] = io_safe_input($item['sql']);
- break;
-
- case 'sql_graph_pie':
- case 'sql_graph_vbar':
- case 'sql_graph_hbar':
- $values['header_definition'] = io_safe_input($item['header_definition']);
- $values['external_source'] = io_safe_input($item['sql']);
- break;
-
- case 'event_report_group':
- $values['id_agent'] = db_get_value('id_grupo', 'tgrupo', 'nombre', io_safe_input($item->group));
- break;
-
- case 'url':
- $values['external_source'] = io_safe_input($item['url']);
- break;
-
- case 'database_serialized':
- $values['header_definition'] = io_safe_input($item['header_definition']);
- $values['line_separator'] = io_safe_input($item['line_separator']);
- $values['column_separator'] = io_safe_input($item['column_separator']);
- break;
-
- case 1:
- case 'simple_graph':
- case 'simple_baseline_graph':
- case 6:
- case 'monitor_report':
- case 7:
- case 'avg_value':
- case 8:
- case 'max_value':
- case 9:
- case 'min_value':
- case 10:
- case 'sumatory':
- case 'event_report_module':
- case 'alert_report_module':
- case 'alert_report_agent':
- case 'alert_report_group':
- case 'agent_detailed_event':
- case 'event_report_agent':
- default:
- // Do nothing.
- break;
- }
-
- if (empty($agents_item) === true) {
- $id_content = db_process_sql_insert('treport_content', $values);
- ui_print_result_message(
- $id_content,
- sprintf(__("Success add '%s' content."), $values['type']),
- sprintf(__("Error add '%s' action."), $values['type'])
- );
-
- if ($item['type'] == 'SLA') {
- foreach ($slas as $sla) {
- $sla['id_report_content'] = $id_content;
- $result = db_process_sql_insert('treport_content_sla_combined', $sla);
- ui_print_result_message(
- $result,
- sprintf(__("Success add '%s' SLA."), $sla['id_agent_module']),
- sprintf(__("Error add '%s' SLA."), $sla['id_agent_module'])
- );
- }
- }
- } else {
- foreach ($agents_item as $id_agent => $agent) {
- if (empty($agent['modules'])) {
- $values['id_agent'] = $id_agent;
- $id_content = db_process_sql_insert('treport_content', $values);
- ui_print_result_message(
- $id_content,
- sprintf(__("Success add '%s' content."), $values['type']),
- sprintf(__("Error add '%s' action."), $values['type'])
- );
- } else {
- foreach ($agent['modules'] as $id_module => $module) {
- $values['id_agent_module'] = $id_module;
- $values['id_agent'] = $id_agent;
-
- $id_content = db_process_sql_insert('treport_content', $values);
- ui_print_result_message(
- $id_content,
- sprintf(__("Success add '%s' content."), $values['type']),
- sprintf(__("Error add '%s' action."), $values['type'])
- );
- }
- }
- }
- }
- }
- }
-}
-
-
-function process_upload_xml_visualmap($xml, $filter_group=0)
-{
- global $config;
-
- foreach ($xml->xpath('/visual_map') as $visual_map) {
- if (isset($visual_map->name)) {
- $values['name'] = (string) $visual_map->name;
- } else {
- ui_print_error_message(
- __("Error create '%s' visual map, lost tag name.")
- );
- break;
- }
-
- $values['id_group'] = 0;
- if (isset($visual_map->group)) {
- $id_group = db_get_value('id_grupo', 'tgrupo', 'nombre', io_safe_input($visual_map->group));
- if ($id_group !== false) {
- $values['id_group'] = $id_group;
- }
- }
-
- if (isset($visual_map->background)) {
- $values['background'] = (string) $visual_map->background;
- }
-
- $values['width'] = 0;
- if (isset($visual_map->width)) {
- $values['width'] = (string) $visual_map->width;
- }
-
- $values['height'] = 0;
- if (isset($visual_map->height)) {
- $values['height'] = (string) $visual_map->height;
- }
-
- $posible_name = $values['name'];
- $exist = true;
- $loops = 30;
- // Loops to exit or tries
- while ($exist && $loops > 0) {
- $exist = (bool) db_get_row_filter('tlayout', ['name' => io_safe_input($posible_name)]);
-
- if ($exist) {
- $loops--;
- $posible_name = $values['name'].' ('.(30 - $loops).')';
- }
- }
-
- if ($exist) {
- ui_print_error_message(
- sprintf(
- __("Error create '%s' visual map, the name exist and there aren't free name."),
- $values['name']
- )
- );
- continue;
- } else if ($loops != 30) {
- ui_print_error_message(
- sprintf(
- __("Warning create '%s' visual map, the name exist, the report have a name %s."),
- $values['name'],
- $posible_name
- )
- );
- }
-
- $values['name'] = io_safe_input($posible_name);
- $id_visual_map = db_process_sql_insert('tlayout', $values);
-
- ui_print_result_message(
- (bool) $id_visual_map,
- sprintf(__("Success create '%s' visual map."), $posible_name),
- sprintf(__("Error create '%s' visual map."), $posible_name)
- );
-
- if ($id_visual_map !== false) {
- db_pandora_audit(
- AUDIT_LOG_VISUAL_CONSOLE_MANAGEMENT,
- sprintf('Create Visual Console #%s', $id_visual_map),
- $config['id_user']
- );
- } else {
- break;
- }
-
- $relation_other_ids = [];
-
- foreach ($visual_map->item as $item) {
- $no_agents = true;
-
- if (isset($item->agent)) {
- $agent_clean = str_replace(['[', ']'], '', $item->agent);
- $regular_expresion = ($agent_clean != $item->agent);
-
- $agents = agents_get_agents(['id_grupo' => $filter_group], ['id_agente', 'nombre']);
- if ($agents === false) {
- $agents = [];
- }
-
- $temp = [];
- foreach ($agents as $agent) {
- $temp[$agent['id_agente']] = $agent['nombre'];
- }
-
- $agents = $temp;
-
- $agents_in_item = [];
- foreach ($agents as $id => $agent) {
- if ($regular_expresion) {
- if ((bool) preg_match('/'.$agent_clean.'/', io_safe_output($agent))) {
- $agents_in_item[$id]['name'] = $agent;
- $no_agents = false;
- }
- } else {
- if ($agent_clean == io_safe_output($agent)) {
- $agents_in_item[$id]['name'] = $agent;
- $no_agents = false;
- break;
- }
- }
- }
- }
-
- $no_modules = true;
- if (isset($item->module)) {
- $module_clean = str_replace(['[', ']'], '', $item->module);
- $regular_expresion = ($module_clean != $item->module);
-
- foreach ($agents_in_item as $id => $agent) {
- $modules = db_get_all_rows_filter(
- 'tagente_modulo',
- ['id_agente' => $id],
- [
- 'id_agente_modulo',
- 'nombre',
- ]
- );
-
- $modules_in_item = [];
- foreach ($modules as $module) {
- if ($regular_expresion) {
- if ((bool) preg_match('/'.$module_clean.'/', io_safe_output($module['nombre']))) {
- $modules_in_item[$module['id_agente_modulo']] = $module['nombre'];
- $no_modules = false;
- }
- } else {
- if ($module_clean == io_safe_output($module['nombre'])) {
- $modules_in_item[$module['id_agente_modulo']] = $module['nombre'];
- $no_modules = false;
- break;
- }
- }
- }
-
- $agents_in_item[$id]['modules'] = $modules_in_item;
- }
- }
-
- $values = [];
-
- $values['id_layout'] = $id_visual_map;
- if (isset($item->label)) {
- $values['label'] = io_safe_input($item->label);
- }
-
- if (isset($item->x)) {
- $values['pos_x'] = (string) $item->x;
- }
-
- if (isset($item->y)) {
- $values['pos_y'] = (string) $item->y;
- }
-
- if (isset($item->height)) {
- $values['height'] = (string) $item->height;
- }
-
- if (isset($item->width)) {
- $values['width'] = (string) $item->width;
- }
-
- if (isset($item->image)) {
- $values['image'] = (string) $item->image;
- }
-
- if (isset($item->period)) {
- $values['period'] = (string) $item->period;
- }
-
- if (isset($item->parent_item)) {
- // Hack for link the items use the OTHER_ID
- // and have too OTHER_ID
- // then $relation_other_ids[OTHER_ID] have the item_id in DB.
- $values['parent_item'] = (string) $relation_other_ids[(string) $item->parent_item];
- }
-
- if (isset($item->map_linked)) {
- $values['id_layout_linked'] = (string) $item->map_linked;
- }
-
- if (isset($item->type)) {
- $values['type'] = (string) $item->type;
- }
-
- if (isset($item->clock_animation)) {
- $values['clock_animation'] = (string) $item->clock_animation;
- }
-
- if (isset($item->fill_color)) {
- $values['fill_color'] = (string) $item->fill_color;
- }
-
- if (isset($item->type_graph)) {
- $values['type_graph'] = (string) $item->type_graph;
- }
-
- if (isset($item->time_format)) {
- $values['time_format'] = (string) $item->time_format;
- }
-
- if (isset($item->timezone)) {
- $values['timezone'] = (string) $item->timezone;
- }
-
- if (isset($item->border_width)) {
- $values['border_width'] = (string) $item->border_width;
- }
-
- if (isset($item->border_color)) {
- $values['border_color'] = (string) $item->border_color;
- }
-
- if ($no_agents) {
- $id_item = db_process_sql_insert('tlayout_data', $values);
-
- ui_print_result_message(
- (bool) $id_item,
- sprintf(__("Success create item type '%d' visual map."), $values['type']),
- sprintf(__("Error create item type '%d' visual map."), $values['type'])
- );
-
- if ($id_item !== false) {
- db_pandora_audit(
- AUDIT_LOG_VISUAL_CONSOLE_MANAGEMENT,
- sprintf('Create Item %s in Visual Console #%s', $id_item, $values['id_layout']),
- $config['id_user']
- );
- }
- } else {
- foreach ($agents_in_item as $id => $agent) {
- if ($no_modules) {
- $values['id_agent'] = $id;
-
- $id_item = db_process_sql_insert('tlayout_data', $values);
-
- if (isset($item->other_id) === true) {
- $relation_other_ids[(string) $item->other_id] = $id_item;
- }
-
- ui_print_result_message(
- (bool) $id_item,
- sprintf(__("Success create item for agent '%s' visual map."), $agent['name']),
- sprintf(__("Error create item for agent '%s' visual map."), $agent['name'])
- );
-
- if ($id_item !== false) {
- db_pandora_audit(
- AUDIT_LOG_VISUAL_CONSOLE_MANAGEMENT,
- sprintf('Create Item %s in Visual Console #%s', $id_item, $values['id_layout']),
- $config['id_user']
- );
- }
- } else {
- // TODO: Review this else.
- foreach ($agent['modules'] as $id_module => $module) {
- $values['id_agent'] = $id;
- $values['id_agente_modulo'] = $id_module;
-
- db_process_sql_insert('tlayout_data', $values);
-
- ui_print_result_message(
- (bool) $id_item,
- sprintf(__("Success create item for agent '%s' visual map."), $agent['name']),
- sprintf(__("Error create item for agent '%s' visual map."), $agent['name'])
- );
-
- if ($id_item !== false) {
- db_pandora_audit(
- AUDIT_LOG_VISUAL_CONSOLE_MANAGEMENT,
- sprintf('Create Item %s in Visual Console #%s', $id_item, $values['id_layout']),
- $config['id_user']
- );
- }
- }
- }
- }
- }
- }
- }
-}
-
-
-function process_upload_xml_component($xml)
-{
- // Extract components.
- $components = [];
- foreach ($xml->xpath('/component') as $componentElement) {
- $name = io_safe_input((string) $componentElement->name);
- $id_os = (int) $componentElement->id_os;
- $os_version = io_safe_input((string) $componentElement->os_version);
- $data = io_safe_input((string) $componentElement->data);
- $type = (int) $componentElement->type;
- $group = (int) $componentElement->group;
- $description = io_safe_input((string) $componentElement->description);
- $module_interval = (int) $componentElement->module_interval;
- $max = (float) $componentElement->max;
- $min = (float) $componentElement->min;
- $tcp_send = io_safe_input((string) $componentElement->tcp_send);
- $tcp_rcv_text = io_safe_input((string) $componentElement->tcp_rcv_text);
- $tcp_port = (int) $componentElement->tcp_port;
- $snmp_oid = io_safe_input((string) $componentElement->snmp_oid);
- $snmp_community = io_safe_input((string) $componentElement->snmp_community);
- $id_module_group = (int) $componentElement->id_module_group;
- $module_source = (int) $componentElement->module_source;
- $plugin = (int) $componentElement->plugin;
- $plugin_username = io_safe_input((string) $componentElement->plugin_username);
- $plugin_password = io_safe_input((string) $componentElement->plugin_password);
- $plugin_parameters = io_safe_input((string) $componentElement->plugin_parameters);
- $max_timeout = (int) $componentElement->max_timeout;
- $max_retries = (int) $componentElement->max_retries;
- $historical_data = (int) $componentElement->historical_data;
- $dynamic_interval = (int) $componentElement->dynamic_interval;
- $dynamic_min = (int) $componentElement->dynamic_min;
- $dynamic_max = (int) $componentElement->dynamic_max;
- $dynamic_two_tailed = (int) $componentElement->dynamic_two_tailed;
- $min_war = (float) $componentElement->min_war;
- $max_war = (float) $componentElement->max_war;
- $str_war = (string) $componentElement->str_war;
- $min_cri = (float) $componentElement->min_cri;
- $max_cri = (float) $componentElement->max_cri;
- $str_cri = (string) $componentElement->str_cri;
- $ff_treshold = (int) $componentElement->ff_treshold;
- $snmp_version = (int) $componentElement->snmp_version;
- $auth_user = io_safe_input((string) $componentElement->auth_user);
- $auth_password = io_safe_input((string) $componentElement->auth_password);
- $auth_method = io_safe_input((string) $componentElement->auth_method);
- $privacy_method = io_safe_input((string) $componentElement->privacy_method);
- $privacy_pass = io_safe_input((string) $componentElement->privacy_pass);
- $security_level = io_safe_input((string) $componentElement->security_level);
- $wmi_query = io_safe_input((string) $componentElement->wmi_query);
- $key_string = io_safe_input((string) $componentElement->key_string);
- $field_number = (int) $componentElement->field_number;
- $namespace = io_safe_input((string) $componentElement->namespace);
- $wmi_user = io_safe_input((string) $componentElement->wmi_user);
- $wmi_password = io_safe_input((string) $componentElement->wmi_password);
- $post_process = io_safe_input((float) $componentElement->post_process);
-
- $idComponent = false;
- switch ((int) $componentElement->module_source) {
- case 1:
- // Local component.
- $values = [
- 'description' => $description,
- 'id_network_component_group' => $group,
- 'os_version' => $os_version,
- ];
- $return = enterprise_hook('local_components_create_local_component', [$name, $data, $id_os, $values]);
- if ($return !== ENTERPRISE_NOT_HOOK) {
- $idComponent = $return;
- }
- break;
-
- case 2:
- // Network component
- // for modules
- // 15 = remote_snmp, 16 = remote_snmp_inc,
- // 17 = remote_snmp_string, 18 = remote_snmp_proc.
- $custom_string_1 = '';
- $custom_string_2 = '';
- $custom_string_3 = '';
- if ($type >= 15 && $type <= 18) {
- // New support for snmp v3.
- $tcp_send = $snmp_version;
- $plugin_user = $auth_user;
- $plugin_pass = $auth_password;
- $plugin_parameters = $auth_method;
- $custom_string_1 = $privacy_method;
- $custom_string_2 = $privacy_pass;
- $custom_string_3 = $security_level;
- }
-
- $idComponent = network_components_create_network_component(
- $name,
- $type,
- $group,
- [
- 'description' => $description,
- 'module_interval' => $module_interval,
- 'max' => $max,
- 'min' => $min,
- 'tcp_send' => $tcp_send,
- 'tcp_rcv' => $tcp_rcv_text,
- 'tcp_port' => $tcp_port,
- 'snmp_oid' => $snmp_oid,
- 'snmp_community' => $snmp_community,
- 'id_module_group' => $id_module_group,
- 'id_modulo' => $module_source,
- 'id_plugin' => $plugin,
- 'plugin_user' => $plugin_username,
- 'plugin_pass' => $plugin_password,
- 'plugin_parameter' => $plugin_parameters,
- 'max_timeout' => $max_timeout,
- 'max_retries' => $max_retries,
- 'history_data' => $historical_data,
- 'dynamic_interval' => $dynamic_interval,
- 'dynamic_min' => $dynamic_min,
- 'dynamic_max' => $dynamic_max,
- 'dynamic_two_tailed' => $dynamic_two_tailed,
- 'min_warning' => $min_war,
- 'max_warning' => $max_war,
- 'str_warning' => $str_war,
- 'min_critical' => $min_cri,
- 'max_critical' => $max_cri,
- 'str_critical' => $str_cri,
- 'min_ff_event' => $ff_treshold,
- 'custom_string_1' => $custom_string_1,
- 'custom_string_2' => $custom_string_2,
- 'custom_string_3' => $custom_string_3,
- 'post_process' => $post_process,
- ]
- );
- if ((bool) $idComponent === true) {
- $components[] = $idComponent;
- }
- break;
-
- case 4:
- // Plugin component.
- $idComponent = network_components_create_network_component(
- $name,
- $type,
- $group,
- [
- 'description' => $description,
- 'module_interval' => $module_interval,
- 'max' => $max,
- 'min' => $min,
- 'tcp_send' => $tcp_send,
- 'tcp_rcv' => $tcp_rcv_text,
- 'tcp_port' => $tcp_port,
- 'snmp_oid' => $snmp_oid,
- 'snmp_community' => $snmp_community,
- 'id_module_group' => $id_module_group,
- 'id_modulo' => $module_source,
- 'id_plugin' => $plugin,
- 'plugin_user' => $plugin_username,
- 'plugin_pass' => $plugin_password,
- 'plugin_parameter' => $plugin_parameters,
- 'max_timeout' => $max_timeout,
- 'max_retries' => $max_retries,
- 'history_data' => $historical_data,
- 'dynamic_interval' => $dynamic_interval,
- 'dynamic_min' => $dynamic_min,
- 'dynamic_max' => $dynamic_max,
- 'dynamic_two_tailed' => $dynamic_two_tailed,
- 'min_warning' => $min_war,
- 'max_warning' => $max_war,
- 'str_warning' => $str_war,
- 'min_critical' => $min_cri,
- 'max_critical' => $max_cri,
- 'str_critical' => $str_cri,
- 'min_ff_event' => $ff_treshold,
- 'custom_string_1' => $custom_string_1,
- 'custom_string_2' => $custom_string_2,
- 'custom_string_3' => $custom_string_3,
- 'post_process' => $post_process,
- ]
- );
- if ((bool) $idComponent === true) {
- $components[] = $idComponent;
- }
- break;
-
- case 6:
- // WMI component.
- $idComponent = network_components_create_network_component(
- $name,
- $type,
- $group,
- [
- 'description' => $description,
- 'module_interval' => $module_interval,
- 'max' => $max,
- 'min' => $min,
- 'tcp_send' => $namespace,
- // work around
- 'tcp_rcv' => $tcp_rcv_text,
- 'tcp_port' => $field_number,
- // work around
- 'snmp_oid' => $wmi_query,
- // work around
- 'snmp_community' => $key_string,
- // work around
- 'id_module_group' => $id_module_group,
- 'id_modulo' => $module_source,
- 'id_plugin' => $plugin,
- 'plugin_user' => $wmi_user,
- // work around
- 'plugin_pass' => $wmi_password,
- // work around
- 'plugin_parameter' => $plugin_parameters,
- 'max_timeout' => $max_timeout,
- 'max_retries' => $max_retries,
- 'history_data' => $historical_data,
- 'dynamic_interval' => $dynamic_interval,
- 'dynamic_min' => $dynamic_min,
- 'dynamic_max' => $dynamic_max,
- 'dynamic_two_tailed' => $dynamic_two_tailed,
- 'min_warning' => $min_war,
- 'max_warning' => $max_war,
- 'str_warning' => $str_war,
- 'min_critical' => $min_cri,
- 'max_critical' => $max_cri,
- 'str_critical' => $str_cri,
- 'min_ff_event' => $ff_treshold,
- 'custom_string_1' => $custom_string_1,
- 'custom_string_2' => $custom_string_2,
- 'custom_string_3' => $custom_string_3,
- 'post_process' => $post_process,
- ]
- );
- if ((bool) $idComponent === true) {
- $components[] = $idComponent;
- }
- break;
-
- case 5:
- // Prediction component.
- case 7:
- // Web component.
- default:
- // Do nothing.
- break;
- }
-
- ui_print_result_message(
- (bool) $idComponent,
- sprintf(__("Success create '%s' component."), $name),
- sprintf(__("Error create '%s' component."), $name)
- );
- }
-
- // Extract the template.
- $templateElement = $xml->xpath('//template');
- if (empty($templateElement) === false) {
- $templateElement = $templateElement[0];
-
- $templateName = (string) $templateElement->name;
- $templateDescription = (string) $templateElement->description;
-
- $idTemplate = db_process_sql_insert('tnetwork_profile', ['name' => $templateName, 'description' => $templateDescription]);
-
- $result = false;
- if ((bool) $idTemplate) {
- foreach ($components as $idComponent) {
- db_process_sql_insert('tnetwork_profile_component', ['id_nc' => $idComponent, 'id_np' => $idTemplate]);
- }
- }
- }
-}
-
-
-function process_upload_xml($xml)
-{
- $hook_enterprise = enterprise_include('extensions/resource_registration/functions.php');
-
- // Extract component.
- process_upload_xml_component($xml);
-
- $group_filter = get_parameter('group');
-
- // Extract visual map.
- process_upload_xml_visualmap($xml, $group_filter);
-
- // Extract policies.
- if ($hook_enterprise === true) {
- $centralized_management = is_management_allowed();
- if ($centralized_management === true) {
- process_upload_xml_policy($xml, $group_filter);
- }
- }
-
- // Extract reports.
- process_upload_xml_report($xml, $group_filter);
-}
-
-
-function resource_registration_extension_main()
-{
- global $config;
-
- if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user'])) {
- db_pandora_audit(
- AUDIT_LOG_ACL_VIOLATION,
- 'Trying to access Setup Management'
- );
- include 'general/noaccess.php';
- return;
- }
-
- include_once $config['homedir'].'/include/functions_network_components.php';
- include_once $config['homedir'].'/include/functions_db.php';
- enterprise_include_once('include/functions_local_components.php');
-
- ui_print_standard_header(
- __('Resource registration'),
- 'images/extensions.png',
- false,
- '',
- true,
- [],
- [
- [
- 'link' => '',
- 'label' => __('Resources'),
- ],
- [
- 'link' => '',
- 'label' => __('Resource registration'),
- ],
- ]
- );
-
- if (extension_loaded('libxml') === false) {
- ui_print_error_message(_('Error, please install the PHP libXML in the system.'));
-
- return;
- }
-
- if (is_management_allowed() === false) {
- if (is_metaconsole() === false) {
- $url = ''.__('metaconsole').' ';
- } else {
- $url = __('any node');
- }
-
- ui_print_warning_message(
- __(
- 'This node is configured with centralized mode. Go to %s to create a policy.',
- $url
- )
- );
-
- return;
- }
-
- ui_print_warning_message(
- __('This extension makes registering resource templates easier.').' '.__('Here you can upload a resource template in .ptr format.').' '.__('Please refer to our documentation for more information on how to obtain and use %s resources.', get_product_name()).' '.' '.__('You can get more resurces in our Public Resource Library ')
- );
-
- $table = new stdClass();
- $table->class = 'databox filter-table-adv';
- $table->id = 'resource_registration_table';
-
- $table->data = [];
-
- $table->data[0][] = html_print_label_input_block(
- __('File to upload'),
- html_print_input_file('resource_upload', true)
- );
-
- $table->data[0][] = html_print_label_input_block(
- __('Group filter'),
- html_print_select_groups(false, 'AW', true, 'group', '', '', __('All'), 0, true)
- );
-
- // Upload form.
- echo '
';
- /*
- echo '';*/
-
- if (isset($_FILES['resource_upload']['tmp_name']) === false) {
- return;
- }
-
- $xml = simplexml_load_file($_FILES['resource_upload']['tmp_name'], null, LIBXML_NOCDATA);
-
- if ($xml === false) {
- ui_print_error_message(
- __('Error uploading resource. Check if the selected file is a valid resource template in .ptr format')
- );
- } else {
- process_upload_xml($xml);
- }
-}
-
-
-extensions_add_godmode_menu_option(__('Resource registration'), 'PM', 'gagente', '', 'v1r1');
-extensions_add_godmode_function('resource_registration_extension_main');
diff --git a/pandora_console/extras/delete_files/delete_files.txt b/pandora_console/extras/delete_files/delete_files.txt
index f3eada8070..b3fbea46dd 100644
--- a/pandora_console/extras/delete_files/delete_files.txt
+++ b/pandora_console/extras/delete_files/delete_files.txt
@@ -1736,3 +1736,5 @@ extensions/files_repo/sql/files_repo.oracle.sql
extensions/files_repo/sql/files_repo.postgreSQL.sql
extensions/files_repo/sql/files_repo.sql
extensions/files_repo
+extensions/resource_exportation.php
+extensions/resource_registration.php
diff --git a/pandora_console/extras/mr/68.sql b/pandora_console/extras/mr/68.sql
index 67ce78c9bc..30762d513b 100644
--- a/pandora_console/extras/mr/68.sql
+++ b/pandora_console/extras/mr/68.sql
@@ -40,9 +40,6 @@ CREATE TABLE IF NOT EXISTS `tmerge_queries` (
ALTER TABLE `tmerge_queries` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
--- Update version for plugin oracle
-UPDATE `tdiscovery_apps` SET `version` = '1.2' WHERE `short_name` = 'pandorafms.oracle';
-
ALTER TABLE `tevent_sound` MODIFY COLUMN `name` text NULL;
ALTER TABLE `tevent_sound` MODIFY COLUMN `sound` text NULL;
ALTER TABLE `treport_content` MODIFY COLUMN `use_prefix_notation` tinyint unsigned NOT NULL DEFAULT 1;
@@ -59,4 +56,42 @@ ALTER TABLE `tmensajes` ADD COLUMN `icon_notification` VARCHAR(250) NULL DEFAULT
UPDATE `tncm_template` SET `vendors` = CONCAT('["', TRIM(BOTH '"' FROM TRIM(BOTH ']' FROM TRIM(BOTH '[' FROM vendors))), '"]'), `models` = CONCAT('["', TRIM(BOTH '"' FROM TRIM(BOTH ']' FROM TRIM(BOTH '[' FROM models))), '"]');
UPDATE `tncm_agent_data_template` SET `vendors` = CONCAT('["', TRIM(BOTH '"' FROM TRIM(BOTH ']' FROM TRIM(BOTH '[' FROM vendors))), '"]'), `models` = CONCAT('["', TRIM(BOTH '"' FROM TRIM(BOTH ']' FROM TRIM(BOTH '[' FROM models))), '"]');
+-- Update version for plugin oracle
+UPDATE `tdiscovery_apps` SET `version` = '1.2' WHERE `short_name` = 'pandorafms.oracle';
+
+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');
+
+SET @class_name = 'ITSMIncidences';
+SET @unique_name = 'ITSMIncidences';
+SET @description = 'Pandora ITSM tickets';
+SET @page = 'ITSMIncidences.php';
+SET @widget_id = NULL;
+SELECT @widget_id := `id` FROM `twidget` WHERE `unique_name` = @unique_name;
+INSERT IGNORE INTO `twidget` (`id`,`class_name`,`unique_name`,`description`,`options`,`page`) VALUES (@widget_id,@class_name,@unique_name,@description,'',@page);
+
+-- Create SNMPv3 credentials for recon tasks and update them
+SET @creds_name = 'Recon-SNMP-creds-';
+INSERT IGNORE INTO `tcredential_store` (`identifier`, `id_group`, `product`, `extra_1`)
+ SELECT
+ CONCAT(@creds_name,`id_rt`) AS `identifier`,
+ `id_group`,
+ 'SNMP' AS `product`,
+ CONCAT(
+ '{',
+ '"community":"',`snmp_community`,'",',
+ '"version":"',`snmp_version`,'",',
+ '"securityLevelV3":"',`snmp_security_level`,'",',
+ '"authUserV3":"',`snmp_auth_user`,'",',
+ '"authMethodV3":"',`snmp_auth_method`,'",',
+ '"authPassV3":"',`snmp_auth_pass`,'",',
+ '"privacyMethodV3":"',`snmp_privacy_method`,'",',
+ '"privacyPassV3":"',`snmp_privacy_pass`,'"',
+ '}'
+ ) AS `extra1`
+ FROM `trecon_task` WHERE `snmp_version` = 3 AND `snmp_enabled` = 1
+;
+UPDATE `trecon_task` SET `auth_strings` = IF(`auth_strings` = '',CONCAT(@creds_name,`id_rt`),CONCAT(@creds_name,`id_rt`,',',`auth_strings`)) WHERE `snmp_version` = 3 AND `snmp_enabled` = 1;
+
COMMIT;
\ No newline at end of file
diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php
index 35b994fead..e2573bd859 100644
--- a/pandora_console/general/header.php
+++ b/pandora_console/general/header.php
@@ -54,7 +54,7 @@ echo sprintf('
'',
+ 'content' => '
To detect and find systems on your network we will need access credentials. The SNMP community for network devices, and at least one set of credentials for Linux and Windows environments (they do not need to be super administrators, but they do need to be able to connect remotely). Without the credentials, we will only be able to detect if the devices are connected to the network.
',
+ ],
+ true
+ );
+
+ // SNMP Communities
+ echo html_print_label_input_block(
+ __('SNMP communities to try with').ui_print_help_tip(
+ __(
+ 'You can specify several values, separated by commas, for example: public,mysecret,1234'
+ ),
+ true
+ ),
+ html_print_input(
+ [
+ 'name' => 'community',
+ 'type' => 'text',
+ 'value' => 'public',
+ 'size' => 25,
+ 'return' => true,
+ ],
+ 'div',
+ true
+ ),
+ ['div_id' => 'snmp-communities-div']
+ );
+ ui_require_jquery_file('tag-editor.min', 'include/javascript/', true);
+ ui_require_jquery_file('caret.min', 'include/javascript/', true);
+ ui_require_css_file('jquery.tag-editor', 'include/styles/', true);
+
+ echo '
';
+
+ $spacing = '';
+ for ($i = 0; $i < 12; $i++) {
+ $spacing .= ' ';
+ }
+
+ // WMI Credentials
+ echo '
';
+ echo ''.__('WMI credentials').' ';
+ echo html_print_div(
+ [
+ 'id' => 'wmi-creds',
+ 'content' => '',
+ ],
+ true
+ );
+ echo html_print_div(
+ [
+ 'id' => 'wmi-cred-form',
+ 'hidden' => true,
+ 'style' => 'margin: 10px; display: flex; align-items: center;',
+ 'content' => html_print_div(
+ [
+ 'id' => 'wmi-cred-user-div',
+ 'style' => 'width: 260px;',
+ 'content' => html_print_label_input_block(
+ __('User').' ',
+ html_print_input_text(
+ 'wmi-cred-user',
+ '',
+ '',
+ false,
+ 50,
+ // Max length
+ true,
+ false,
+ true,
+ '',
+ 'w100p',
+ '',
+ 'off',
+ false,
+ '',
+ '',
+ '',
+ false,
+ '',
+ 'Username'
+ ),
+ ['div_style' => 'display: flex; align-items: center;']
+ ),
+ ],
+ true
+ ).html_print_div(
+ [
+ 'id' => 'wmi-cred-pass-div',
+ 'style' => 'width: 260px;',
+ 'content' => html_print_label_input_block(
+ $spacing.__('Password').' ',
+ html_print_input_password(
+ 'wmi-cred-pass',
+ '',
+ '',
+ false,
+ 50,
+ // Max length
+ true,
+ false,
+ true,
+ 'w100p',
+ 'off',
+ false,
+ ''
+ ),
+ ['div_style' => 'display: flex; align-items: center;']
+ ),
+ ],
+ true
+ ).html_print_div(
+ [
+ 'id' => 'wmi-cred-namespace-div',
+ 'style' => 'width: 260px;',
+ 'content' => html_print_label_input_block(
+ $spacing.__('Namespace').' ',
+ html_print_input_text(
+ 'wmi-cred-namespace',
+ '',
+ '',
+ false,
+ 50,
+ // Max length
+ true,
+ false,
+ true,
+ '',
+ 'w100p',
+ '',
+ 'off',
+ false,
+ '',
+ '',
+ '',
+ false,
+ '',
+ 'Namespace'
+ ),
+ ['div_style' => 'display: flex; align-items: center;']
+ ),
+ ],
+ true
+ ).''.html_print_image(
+ 'images/delete.svg',
+ true,
+ [
+ 'title' => __('Delete'),
+ 'style' => 'cursor: pointer;',
+ 'class' => 'main_menu_icon invert_filter',
+ ]
+ ).' ',
+ ],
+ true
+ );
+ echo '
';
+ echo html_print_button(
+ __('Add'),
+ 'add-wmi-cred',
+ false,
+ 'add_discovery_credential("wmi-cred-form","wmi-creds");',
+ [
+ 'icon' => 'plus',
+ 'mode' => 'secondary',
+ 'class' => 'mini',
+ ],
+ true,
+ false,
+ false,
+ ''
+ );
+ echo ' ';
+
+ echo '
';
+
+ // RCM Credentials
+ echo '
';
+ echo ''.__('Remote commands credentials').' ';
+ echo html_print_div(
+ [
+ 'id' => 'rcmd-creds',
+ 'content' => '',
+ ],
+ true
+ );
+ echo html_print_div(
+ [
+ 'id' => 'rcmd-cred-form',
+ 'hidden' => true,
+ 'style' => 'margin: 10px; display: flex; align-items: center;',
+ 'content' => html_print_div(
+ [
+ 'id' => 'rcmd-cred-user-div',
+ 'style' => 'width: 260px;',
+ 'content' => html_print_label_input_block(
+ __('User').' ',
+ html_print_input_text(
+ 'rcmd-cred-user',
+ '',
+ '',
+ false,
+ 50,
+ // Max length
+ true,
+ false,
+ true,
+ '',
+ 'w100p',
+ '',
+ 'off',
+ false,
+ '',
+ '',
+ '',
+ false,
+ '',
+ 'Username'
+ ),
+ ['div_style' => 'display: flex; align-items: center;']
+ ),
+ ],
+ true
+ ).html_print_div(
+ [
+ 'id' => 'rcmd-cred-pass-div',
+ 'style' => 'width: 260px;',
+ 'content' => html_print_label_input_block(
+ $spacing.__('Password').' ',
+ html_print_input_password(
+ 'rcmd-cred-pass',
+ '',
+ '',
+ false,
+ 50,
+ // Max length
+ true,
+ false,
+ true,
+ 'w100p',
+ 'off',
+ false,
+ ''
+ ),
+ ['div_style' => 'display: flex; align-items: center;']
+ ),
+ ],
+ true
+ ).''.html_print_image(
+ 'images/delete.svg',
+ true,
+ [
+ 'title' => __('Delete'),
+ 'style' => 'cursor: pointer;',
+ 'class' => 'main_menu_icon invert_filter',
+ ]
+ ).' ',
+ ],
+ true
+ );
+ echo '
';
+ echo html_print_button(
+ __('Add'),
+ 'add-rcmd-cred',
+ false,
+ 'add_discovery_credential("rcmd-cred-form","rcmd-creds");',
+ [
+ 'icon' => 'plus',
+ 'mode' => 'secondary',
+ 'class' => 'mini',
+ ],
+ true,
+ false,
+ false,
+ ''
+ );
+ echo ' ';
+
echo html_print_submit_button(__('Create'), 'basic_net', false, ['icon' => 'next', 'style' => 'margin-top:15px; float:right;']);
?>
+
$field) {
+ // Disregard repeated whitespaces in query searched string.
$sql_search .= sprintf(
- '%s %s %s like lower("%%%s%%")',
+ '%s REGEXP_REPLACE(%s, "( \\s*)+", " ") %s like lower("%%%s%%")',
($key === 0) ? '' : $nexo,
$field,
$not_search,
- $filter['search']
+ $collapsed_spaces_search
);
$sql_search .= ' ';
}
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_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/functions_io.php b/pandora_console/include/functions_io.php
index 445504b11c..cb6b5163ac 100755
--- a/pandora_console/include/functions_io.php
+++ b/pandora_console/include/functions_io.php
@@ -82,11 +82,11 @@ function io_safe_input($value)
return $value;
}
- if (! mb_check_encoding($value, 'UTF-8')) {
+ if (isset($value) === true && !mb_check_encoding($value, 'UTF-8')) {
$value = utf8_encode($value);
}
- $valueHtmlEncode = htmlentities($value, ENT_QUOTES, 'UTF-8', true);
+ $valueHtmlEncode = htmlentities(($value ?? ''), ENT_QUOTES, 'UTF-8', true);
// Replace the character '\' for the equivalent html entitie
$valueHtmlEncode = str_replace('\\', '\', $valueHtmlEncode);
@@ -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',
diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php
index 141d3ae8cc..f16e8fd25b 100644
--- a/pandora_console/include/functions_notifications.php
+++ b/pandora_console/include/functions_notifications.php
@@ -819,7 +819,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/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_reporting.php b/pandora_console/include/functions_reporting.php
index 7534cb5e23..c5c7090623 100755
--- a/pandora_console/include/functions_reporting.php
+++ b/pandora_console/include/functions_reporting.php
@@ -12546,7 +12546,7 @@ function reporting_get_stats_indicators($data, $width=280, $height=20, $html=tru
$table_ind = html_get_predefined_table();
$servers = [];
- $servers['all'] = (int) db_get_value('COUNT(id_server)', 'tserver');
+ $servers['all'] = (int) count((servers_get_info() ?? []));
$servers['up'] = (int) servers_check_status();
$servers['down'] = ($servers['all'] - $servers['up']);
if ($servers['all'] == 0) {
@@ -12607,7 +12607,7 @@ function reporting_get_stats_indicators_mobile($data, $width=280, $height=20, $h
$table_ind = html_get_predefined_table();
$servers = [];
- $servers['all'] = (int) db_get_value('COUNT(id_server)', 'tserver');
+ $servers['all'] = (int) count((servers_get_info() ?? []));
$servers['up'] = (int) servers_check_status();
$servers['down'] = ($servers['all'] - $servers['up']);
if ($servers['all'] == 0) {
@@ -16206,7 +16206,8 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
// Si viene de no iniciado busco el primer dato del modulo y si es de histórico.
$first_utimestamp = false;
$search_historydb = false;
- $extract_first_data = modules_get_first_date($content['id_agent_module'], 0);
+ // Limitamos el primer dato al rango de tiempo seleccionado por el usuario.
+ $extract_first_data = modules_get_first_date($content['id_agent_module'], $date_start);
if (empty($extract_first_data) === false) {
$first_utimestamp = $extract_first_data['first_utimestamp'];
$search_historydb = (isset($extract_first_data['search_historydb']) === true) ? $extract_first_data['search_historydb'] : false;
@@ -16311,7 +16312,8 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
$return['data_ok'] = $check_ok;
$return['data_total'] = $check_total;
if ($check_total > 0) {
- $return['percent_ok'] = (($time_ok * 100) / $content['period']);
+ $percent_ok = (($time_ok * 100) / $content['period']);
+ $return['percent_ok'] = ($percent_ok > 100) ? 100 : $percent_ok;
} else {
$return['percent_ok'] = 0;
}
diff --git a/pandora_console/include/functions_servers.php b/pandora_console/include/functions_servers.php
index bdc8a56fc9..8805998232 100644
--- a/pandora_console/include/functions_servers.php
+++ b/pandora_console/include/functions_servers.php
@@ -615,7 +615,7 @@ function servers_get_rate($avg_interval, $num_modules)
* This function will get all the server information in an array
* or a specific server.
*
- * @param integer $id_server An optional integer or array of integers
+ * @param integer|array $id_server An optional integer or array of integers
* to select specific servers.
*
* @return mixed False in case the server doesn't exist or an array with info.
@@ -624,28 +624,63 @@ function servers_get_info($id_server=-1, $sql_limit=-1)
{
global $config;
- if (is_array($id_server)) {
- $select_id = ' WHERE id_server IN ('.implode(',', $id_server).')';
+ $select_id = '';
+ if (is_array($id_server) === true) {
+ $select_id = ' AND id_server IN ('.implode(',', $id_server).')';
} else if ($id_server > 0) {
- $select_id = ' WHERE id_server IN ('.(int) $id_server.')';
- } else {
- $select_id = '';
+ $select_id = ' AND id_server IN ('.(int) $id_server.')';
}
- $sql = '
- SELECT *
- FROM tserver '.$select_id.'
- ORDER BY server_type';
+ $types_sql = sprintf(
+ ' AND (
+ `server_type` != %d AND
+ `server_type` != %d
+ )',
+ SERVER_TYPE_AUTOPROVISION,
+ SERVER_TYPE_MIGRATION
+ );
+ if (is_metaconsole() === true && isset($config['ndbh']) === false) {
+ $types_sql = sprintf(
+ ' AND (
+ `server_type` = %d OR
+ `server_type` = %d OR
+ `server_type` = %d OR
+ `server_type` = %d
+ )',
+ SERVER_TYPE_AUTOPROVISION,
+ SERVER_TYPE_EVENT,
+ SERVER_TYPE_MIGRATION,
+ SERVER_TYPE_PREDICTION
+ );
+ }
+
+ $sql = sprintf(
+ 'SELECT *
+ FROM tserver
+ WHERE 1=1
+ %s
+ %s
+ ORDER BY server_type',
+ $select_id,
+ $types_sql
+ );
if ($sql_limit !== -1) {
- $sql = '
- SELECT *
- FROM tserver '.$select_id.'
- ORDER BY server_type'.$sql_limit;
+ $sql = sprintf(
+ 'SELECT *
+ FROM tserver
+ WHERE 1=1
+ %s
+ %s
+ ORDER BY server_type
+ %s',
+ $select_id,
+ $types_sql,
+ $sql_limit
+ );
}
$result = db_get_all_rows_sql($sql);
- $time = get_system_time();
if (empty($result)) {
return false;
@@ -1445,6 +1480,12 @@ function servers_get_server_string_name(int $server)
case SERVER_TYPE_NCM:
return __('NCM server');
+ case SERVER_TYPE_AUTOPROVISION:
+ return __('Autoprovision server');
+
+ case SERVER_TYPE_MIGRATION:
+ return __('Migration server');
+
default:
return __('N/A');
}
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 "
+
+
+ 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/include/lib/Dashboard/Widgets/ModulesByStatus.php b/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php
index 69c0a36f44..1bbcc3be33 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/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/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/include/styles/jquery.tag-editor.css b/pandora_console/include/styles/jquery.tag-editor.css
index 5d535dba1e..31040fca45 100644
--- a/pandora_console/include/styles/jquery.tag-editor.css
+++ b/pandora_console/include/styles/jquery.tag-editor.css
@@ -108,9 +108,7 @@
cursor: default;
font-size: 14px;
}
-.ui-front {
- z-index: 9999;
-}
+
.ui-menu {
list-style: none;
padding: 1px;
diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css
index 7b9bd5ed17..57ecd8544e 100644
--- a/pandora_console/include/styles/pandora.css
+++ b/pandora_console/include/styles/pandora.css
@@ -10954,6 +10954,18 @@ div.status_dot {
-webkit-mask: url(../../images/status_dot.svg) no-repeat center / contain;
}
+button div.import {
+ mask: url(../../images/import.svg) no-repeat center / contain;
+ -webkit-mask: url(../../images/import.svg) no-repeat center / contain;
+ height: 1.5rem;
+}
+
+button div.export {
+ mask: url(../../images/export.svg) no-repeat center / contain;
+ -webkit-mask: url(../../images/export.svg) no-repeat center / contain;
+ height: 1.5rem;
+}
+
.status_dot.ok {
background-color: #82b92e;
}
@@ -13508,3 +13520,71 @@ tr.shown td.details-control {
#modules-toggle > .modules > .white-box-content div {
z-index: 1 !important;
}
+
+/* Import/export */
+.div-import-export {
+ display: flex;
+ flex-direction: row;
+}
+
+.form-import {
+ width: 48%;
+ height: auto;
+ margin-right: 40px;
+}
+
+.div-import {
+ background-color: #ffffff;
+ border: 1px solid #e5e9ed;
+ border-radius: 8px;
+ width: 100%;
+ height: 180px;
+ display: flex;
+ flex-direction: row;
+ align-items: normal;
+ padding-top: 20px;
+ padding-left: 20px;
+ margin-bottom: 20px;
+}
+
+.div-export {
+ background-color: #ffffff;
+ border: 1px solid #e5e9ed;
+ border-radius: 8px;
+ width: 48%;
+ height: 180px;
+ display: flex;
+ flex-direction: row;
+ align-items: normal;
+ padding-top: 20px;
+ padding-left: 20px;
+ margin-bottom: 20px;
+}
+
+@media (max-width: 1300px) {
+ .div-import-export {
+ display: flex;
+ flex-direction: column;
+ }
+
+ .div-export {
+ width: calc(100% - 20px);
+ }
+
+ .form-import {
+ width: calc(100% - 20px);
+ }
+}
+
+.input-file-style::file-selector-button {
+ background-color: #ffffff;
+ border: 1px solid #979797;
+ border-radius: 4px;
+ width: 120px;
+ height: 32px;
+}
+
+button.disabled {
+ background: #c0ccdc !important;
+ border: 0px;
+}
diff --git a/pandora_console/install.php b/pandora_console/install.php
index 5b2aec429c..0f60b2f62e 100644
--- a/pandora_console/install.php
+++ b/pandora_console/install.php
@@ -131,7 +131,7 @@
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,
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/operation/inventory/inventory.php b/pandora_console/operation/inventory/inventory.php
index 43296a1b26..a841c53266 100755
--- a/pandora_console/operation/inventory/inventory.php
+++ b/pandora_console/operation/inventory/inventory.php
@@ -382,7 +382,7 @@ ui_print_standard_header(
$inventory_id_agent = (int) get_parameter('agent_id', -1);
$inventory_agent = (string) get_parameter('agent', '');
-if (strlen($inventory_agent) == 0) {
+if (strlen(($inventory_agent ?? '')) == 0) {
$inventory_id_agent = -1;
$inventory_agent = __('All');
} else if ($inventory_agent == __('All')) {
diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec
index 90434e837f..60a70bfe74 100644
--- a/pandora_console/pandora_console.redhat.spec
+++ b/pandora_console/pandora_console.redhat.spec
@@ -6,7 +6,7 @@
%define debug_package %{nil}
%define name pandorafms_console
%define version 7.0NG.775
-%define release 240207
+%define release 240219
# User and Group under which Apache is running
%define httpd_name httpd
diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec
index 04c2c438d3..0c8f776b02 100644
--- a/pandora_console/pandora_console.rhel7.spec
+++ b/pandora_console/pandora_console.rhel7.spec
@@ -6,7 +6,7 @@
%define debug_package %{nil}
%define name pandorafms_console
%define version 7.0NG.775
-%define release 240207
+%define release 240219
# User and Group under which Apache is running
%define httpd_name httpd
diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec
index 59e23165c5..95d4244636 100644
--- a/pandora_console/pandora_console.spec
+++ b/pandora_console/pandora_console.spec
@@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.775
-%define release 240207
+%define release 240219
%define httpd_name httpd
# User and Group under which Apache is running
%define httpd_name apache2
diff --git a/pandora_console/pandora_console_install b/pandora_console/pandora_console_install
index b2175d21d4..7393ef7493 100755
--- a/pandora_console/pandora_console_install
+++ b/pandora_console/pandora_console_install
@@ -239,7 +239,7 @@ help () {
# Script banner at start
echo " "
-echo "Pandora FMS Console Installer $PI_VERSION $PI_BUILD (c) 2008-2015 ArticaST"
+echo "Pandora FMS Console Installer $PI_VERSION $PI_BUILD (c) 2008-2024 PandoraFMS"
echo "This program is licensed under GPL2 Terms. http://pandorafms.com"
echo " "
diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql
index 280bf8423b..d5846d1777 100644
--- a/pandora_console/pandoradb_data.sql
+++ b/pandora_console/pandoradb_data.sql
@@ -2832,7 +2832,9 @@ 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'),
+ (49,'ITSMIncidences','ITSMIncidences','Pandora ITSM tickets','','ITSMIncidences.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;"> </p>
<p style="text-align: center;"> </p>
<p style="text-align: center;"> </p>
<p style="text-align: center;"> </p>
<p style="text-align: center;"> </p>
<p style="text-align: center;"> </p>
<p style="text-align: center;"> </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;"> </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/update_manager_client/lib/UpdateManager/UI/Manager.php b/pandora_console/update_manager_client/lib/UpdateManager/UI/Manager.php
index f351c6f37d..8dd12e745f 100644
--- a/pandora_console/update_manager_client/lib/UpdateManager/UI/Manager.php
+++ b/pandora_console/update_manager_client/lib/UpdateManager/UI/Manager.php
@@ -123,7 +123,7 @@ class Manager
string $public_url,
?string $ajax_url=null,
?string $page=null,
- array $settings,
+ array $settings=[],
?int $mode=null,
bool $composer=false
) {
diff --git a/pandora_console/update_manager_client/views/register.php b/pandora_console/update_manager_client/views/register.php
index bfc70570f3..666c026b89 100644
--- a/pandora_console/update_manager_client/views/register.php
+++ b/pandora_console/update_manager_client/views/register.php
@@ -132,6 +132,15 @@ $product_name = get_product_name(); ?>