Merge remote-tracking branch 'origin/develop' into ent-12333-anadir-tablas-dinamicas-a-pandoradb-sql

Conflicts:
	pandora_console/extras/delete_files/delete_files.txt
	pandora_console/extras/mr/67.sql
	pandora_console/operation/menu.php
This commit is contained in:
daniel 2023-12-14 11:21:51 +01:00
commit 3cb4b5cce4
180 changed files with 7392 additions and 1615 deletions

View File

@ -234,6 +234,21 @@ module_description Number of cron task files
module_unit files
module_end
# This module /var/log/syslog file, under the module name "syslog"
# And search for "ssh" string into it, sending only that information.
module_begin
module_name Syslog
module_description Search for ssh string into /var/log/syslog file
module_type log
module_regexp /var/log/syslog
module_pattern ssh
module_end
#Hardening plugin for security compliance analysis. Enable to use it.
#module_begin
#module_plugin /usr/share/pandora_agent/plugins/pandora_hardening -t 150
#module_absoluteinterval 7d
#module_end
# Plugin example
@ -241,11 +256,6 @@ module_end
module_plugin pandora_df
# This parses /var/log/syslog file, under the module name "syslog"
# And search for "ssh" string into it, sending only that information.
module_plugin grep_log /var/log/syslog Syslog ssh
# Get disk space free in MB
#module_begin
#module_name disk_root_free
@ -270,7 +280,6 @@ module_plugin grep_log /var/log/syslog Syslog ssh
#module_end
# Plugin for inventory on the agent.
# module_plugin inventory 1 cpu ram video nic hd cdrom software init_services filesystem users process ip route
# Example of preconditions
@ -303,4 +312,13 @@ module_plugin grep_log /var/log/syslog Syslog ssh
# This plugin runs several security checks in a Linux system
#module_plugin pandora_security_check
#module_plugin pandora_security_check
# Extraction module example
#module_begin
#module_name Collector
#module_description Logs extraction module
#module_type log
#module_regexp /var/log/logfile.log
#module_pattern .*
#module_end

View File

@ -147,22 +147,23 @@ module_max_critical 20
module_end
# Log events
# Get logs from System source.
module_begin
module_name System Events (TermService)
module_type async_string
module_logevent
module_description Log Events coming from Terminal Service
module_type log
module_logevent
module_source System
module_application TermService
module_end
# Get logs from Security source.
module_begin
module_name Security Events (Invalid Login)
module_type async_string
module_description Security log events for invalid login attempt
module_name Security Events
module_description Security log events
module_type log
module_logevent
module_source Security
module_eventcode 529
module_end
# Check if Dhcp service is enabled
@ -219,6 +220,12 @@ module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\df.vbs"
# module_description Free space on drive D: (%)
# module_end
# Hardening plugin for security compliance analysis.
# module_begin
# module_plugin "%PROGRAMFILES%\Pandora_Agent\util\pandora_hardening.exe -t 150"
# module_absoluteinterval 7d
# module_end
# Sample of Windows inventory module (ONLY ENTERPRISE)!
#module_begin
#module_name Inventory
@ -344,4 +351,13 @@ module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\df.vbs"
#module_condition (3,8) cmd.exe /c echo range >> c:\log.txt
#module_exec echo 5
#module_description Postcondition test module
#module_end
# Example of collector module
#module_begin
#module_name Collector
#module_description Logs extraction module
#module_type log
#module_regexp /var/log/logfile.log
#module_pattern .*
#module_end

View File

@ -2179,16 +2179,7 @@ sub configure ($) {
#Launch tentacle server in proxy mode if configured
if ($Conf{'proxy_mode'}) {
#Check if user is root
if ($> != 0) {
if (launch_tentacle_proxy() != 0) {
return 1;
}
} else {
error ('Proxy mode can not be launched as root');
return 1;
}
return 1 if (launch_tentacle_proxy() != 0);
}
# Add the plugins directory to the PATH

View File

@ -157,12 +157,32 @@ module_exec last | head -1
module_description Last Login
module_end
# Plugin example
#Hardening plugin for security compliance analysis. Enable to use it.
#module_begin
#module_plugin /usr/share/pandora_agent/plugins/pandora_hardening -t 150
#module_absoluteinterval 7d
#module_end
# This parses /var/log/syslog file, under the module name "syslog"
# This module parses /var/log/syslog file, under the module name "syslog"
# And search for "ssh" string into it, sending only that information.
module_begin
module_name Syslog
module_description Search for ssh string into /var/log/syslog file
module_type log
module_regexp /var/log/syslog
module_pattern ssh
module_end
module_plugin grep_log /var/log/syslog Syslog ssh
# Plugin example
# Plugin for inventory on the agent.
# module_plugin inventory 1 cpu ram video nic hd cdrom software
# Extraction module example
#module_begin
#module_name Collector
#module_description Logs extraction module
#module_type log
#module_regexp /var/log/logfile.log
#module_pattern .*
#module_end

View File

@ -372,13 +372,32 @@ module_end
#module_description XGrid
#module_end
#Hardening plugin for security compliance analysis. Enable to use it.
#module_begin
#module_plugin /usr/share/pandora_agent/plugins/pandora_hardening -t 150
#module_absoluteinterval 7d
#module_end
# This module parses /var/log/syslog file, under the module name "syslog"
# And search for "ssh" string into it, sending only that information.
module_begin
module_name Syslog
module_description Log collection modules
module_type log
module_regexp /var/log/syslog
module_pattern ssh
module_end
# Plugin example
# This parses /var/log/syslog file, under the module name "syslog"
# And search for "ssh" string into it, sending only that information.
#module_plugin grep_log /var/log/syslog Syslog ssh
# Plugin for inventory on the agent.
# module_plugin inventory 1 cpu ram video nic hd cdrom software
# Extraction module example
#module_begin
#module_name Collector
#module_description Logs extraction module
#module_type log
#module_regexp /var/log/logfile.log
#module_pattern .*
#module_end

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.774-231128
Version: 7.0NG.774-231214
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.774-231128"
pandora_version="7.0NG.774-231214"
echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -271,11 +271,17 @@ module_plugin pandora_netusage
module_plugin autodiscover --default
# Plugin for inventory on the agent.
#module_plugin inventory 1 cpu ram video nic hd cdrom software init_services filesystem users route
# module_plugin inventory 1 cpu ram video nic hd cdrom software init_services filesystem users route
# Log collection modules. This will collect log files for forensic analysis and store everything
# This is for LOG monitoring. Different than log monitoring.
#module_plugin grep_log_module /var/log/messages Syslog \.\*
module_begin
module_name Syslog
module_description Log collection modules
module_type log
module_regexp /var/log/messages
module_pattern .*
module_end
# Another samples of monitoring modules
@ -317,9 +323,9 @@ module_plugin autodiscover --default
#module_absoluteinterval 7d
#module_end
# Logs extraction
# Extraction module example
#module_begin
#module_name Syslog
#module_name Collector
#module_description Logs extraction module
#module_type log
#module_regexp /var/log/logfile.log

View File

@ -1039,7 +1039,7 @@ my $Sem = undef;
my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.774';
use constant AGENT_BUILD => '231128';
use constant AGENT_BUILD => '231214';
# Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000;
@ -4436,14 +4436,7 @@ my $PID = $$;
#Launch tentacle server in proxy mode if configured
if ($Conf{'proxy_mode'}) {
#Check if user is root
if ($> != 0) {
launch_tentacle_proxy();
} else {
log_message ('error', 'Proxy mode can not be launched as root');
exit 1;
}
launch_tentacle_proxy();
}
# Advice if YAML::Tiny is allowed in this system

View File

@ -4,7 +4,7 @@
%global __os_install_post %{nil}
%define name pandorafms_agent_linux
%define version 7.0NG.774
%define release 231128
%define release 231214
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -5,7 +5,7 @@
%define name pandorafms_agent_linux_bin
%define source_name pandorafms_agent_linux
%define version 7.0NG.774
%define release 231128
%define release 231214
%define debug_package %{nil}
Summary: Pandora FMS Linux agent, binary version

View File

@ -5,7 +5,7 @@
%define name pandorafms_agent_linux_bin
%define source_name pandorafms_agent_linux
%define version 7.0NG.774
%define release 231128
%define release 231214
%define debug_package %{nil}
Summary: Pandora FMS Linux agent, binary version

View File

@ -5,7 +5,7 @@
%define name pandorafms_agent_linux_bin
%define source_name pandorafms_agent_linux
%define version 7.0NG.774
%define release 231128
%define release 231214
Summary: Pandora FMS Linux agent, binary version
Name: %{name}

View File

@ -4,7 +4,7 @@
%global __os_install_post %{nil}
%define name pandorafms_agent_linux
%define version 7.0NG.774
%define release 231128
%define release 231214
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -10,7 +10,7 @@
# **********************************************************************
PI_VERSION="7.0NG.774"
PI_BUILD="231128"
PI_BUILD="231214"
OS_NAME=`uname -s`
FORCE=0

View File

@ -179,6 +179,22 @@ module_description Total number of TCP connections active
module_group Networking
module_end
# Get logs from System source.
module_begin
module_name Eventlog_System
module_type log
module_logevent
module_source System
module_end
# Get logs from Security source.
module_begin
module_name Eventlog_Security
module_type log
module_logevent
module_source Security
module_end
# Example plugin to retrieve drive usage
module_plugin cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\df_percent_used.vbs"
@ -273,22 +289,6 @@ module_plugin "%PROGRAMFILES%\Pandora_Agent\util\autodiscover.exe" --default
#module_type generic_data_string
#module_end
# Get logs from System source. Need enterprise version.
#module_begin
#module_name Eventlog_System
#module_type log
#module_logevent
#module_source System
#module_end
# Get logs from Security source. Need enterprise version.
#module_begin
#module_name Eventlog_Security
#module_type log
#module_logevent
#module_source Security
#module_end
# Get logs from Application source. Need enterprise version.
#module_begin
#module_name Eventlog_Application

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{231128}
{231214}
ViewReadme
{Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.774 Build 231128")
#define PANDORA_VERSION ("7.0NG.774 Build 231214")
string pandora_path;
string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Pandora FMS"
VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.774(Build 231128))"
VALUE "ProductVersion", "(7.0NG.774(Build 231214))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 7.0NG.774-231128
Version: 7.0NG.774-231214
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.774-231128"
pandora_version="7.0NG.774-231214"
package_pear=0
package_pandora=1

View File

@ -183,7 +183,9 @@ if (isset($config['force_instant_logout']) === true
$_SESSION = [];
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), '/');
}
if ($config['auth'] === 'saml' && empty($public_hash) === true) {
include_once $config['saml_path'].'simplesamlphp/lib/_autoload.php';

View File

@ -34,11 +34,11 @@ if ((bool) $config['metaconsole']) {
include_once $config['homedir'].'/include/functions_modules.php';
include_once $config['homedir'].'/include/functions_users.php';
} else {
include_once '../include/config.php';
include_once '../include/functions_agents.php';
include_once '../include/functions_reporting.php';
include_once '../include/functions_modules.php';
include_once '../include/functions_users.php';
include_once __DIR__.'/../include/config.php';
include_once __DIR__.'/../include/functions_agents.php';
include_once __DIR__.'/../include/functions_reporting.php';
include_once __DIR__.'/../include/functions_modules.php';
include_once __DIR__.'/../include/functions_users.php';
}

View File

@ -31,7 +31,7 @@ function view_logfile($file_name, $toggle=false)
} else {
$file_size = filesize($file_name);
if ($memory_limit < $file_size) {
if ($memory_limit < $file_size && $memory_limit !== '-1') {
$code .= '<pre><h2>'.$file_name.' ('.__('File is too large than PHP memory allocated in the system.').')</h2>';
$code .= '<h2>'.__('The preview file is imposible.').'</h2>';
} else if ($file_size > ($config['max_log_size'] * 1000)) {
@ -117,6 +117,7 @@ function pandoralogs_extension_main()
view_logfile($config['homedir'].'/log/console.log', true);
}
view_logfile('/var/log/php-fpm/www-error.log', true);
view_logfile($logs_directory.'/pandora_server.log', true);
view_logfile($logs_directory.'/pandora_server.error', true);

View File

@ -1720,6 +1720,7 @@ include/functions_integriaims.php
include/ajax/integria_incidents.ajax.php
enterprise/operation/log/log_source.php
enterprise/include/class/LogSource.class.php
include/chart_generator.php
enterprise/extensions/translate_string.php
enterprise/extensions/translate_string/functions.php
enterprise/extensions/translate_string/translate_string.oracle.sql
@ -1734,4 +1735,4 @@ extensions/files_repo/functions_files_repo.php
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/files_repo

View File

@ -1,4 +1,4 @@
pandorafms.vmware=9959cc3e5cc6bfcfadd6d05b56d4a11b
pandorafms.vmware=248788e0fb2cd4e11623e4a52ee7d05b
pandorafms.mysql=fadb4750d18285c0eca34f47c6aa3cfe
pandorafms.mssql=1cc215409741d19080269ffba112810e
pandorafms.oracle=2d9320a514d1e48a0b2804e1653c31c6

File diff suppressed because it is too large Load Diff

View File

@ -35,7 +35,7 @@ echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
$notifications_numbers['last_id']
).'</div>';
$header_welcome = '';
if (check_acl($config['id_user'], $group, 'AW')) {
if (check_acl($config['id_user'], 0, 'AW')) {
$header_welcome .= '<div id="welcome-icon-header">';
$header_welcome .= html_print_image(
'images/wizard@svg.svg',
@ -455,19 +455,28 @@ echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
);
$header_logout .= '</a></div>';
if (enterprise_installed()) {
$subtitle_header = $config['custom_subtitle_header'];
$class_header = '';
} else {
$subtitle_header = __('the Flexible Monitoring System (OpenSource version)');
echo '<div id="dialog_why_enterprise" class="invisible"></div>';
$class_header = 'underline-hover modal_module_list';
}
if (is_reporting_console_node() === true) {
echo '<div class="header_left">';
echo '<div class="header_left '.$class_header.'">';
echo '<span class="header_title">';
echo $config['custom_title_header'];
echo '</span>';
echo '<span class="header_subtitle">';
echo $config['custom_subtitle_header'];
echo $subtitle_header;
echo '</span>';
echo '</div>';
echo '<div class="header_center"></div>';
echo '<div class="header_right">'.$modal_help, $header_user, $header_logout.'</div>';
} else {
echo '<div class="header_left"><span class="header_title">'.$config['custom_title_header'].'</span><span class="header_subtitle">'.$config['custom_subtitle_header'].'</span></div>
echo '<div class="header_left '.$class_header.'"><span class="header_title">'.$config['custom_title_header'].'</span><span class="header_subtitle">'.$subtitle_header.'</span></div>
<div class="header_center">'.$header_searchbar.'</div>
<div class="header_right">'.$header_autorefresh, $header_autorefresh_counter, $header_discovery, $header_welcome, $servers_list, $modal_help, $header_setup, $header_user, $header_logout.'</div>';
}
@ -916,6 +925,46 @@ echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
$(document).ready (function () {
<?php if (enterprise_installed() === false) { ?>
$('.header_left').on('click', function(){
// Hidden tips modal.
$(".window").css("display", "none");
jQuery.post(
"ajax.php",
{
page: "include/functions_menu",
'why_enterprise': "true"
},
function(data) {
if (data) {
$("#dialog_why_enterprise").html(data);
// Open dialog
$("#dialog_why_enterprise").dialog({
resizable: false,
draggable: false,
modal: true,
show: {
effect: "fade",
duration: 200
},
hide: {
effect: "fade",
duration: 200
},
closeOnEscape: true,
width: 700,
height: 450,
close: function(){
$('#dialog_why_enterprise').html('');
}
});
}
},
"html"
);
});
<?php } ?>
// Check new notifications on a periodic way
setInterval(check_new_notifications, 60000);

View File

@ -600,43 +600,176 @@ html_print_div(
'content' => html_print_table($tableAgent, true).$CodeQRTable,
]
);
/*
TODO REVIEW
$table_satellite = '';
if ($remote_agent === true) {
// Satellite server selector.
$satellite_servers = db_get_all_rows_filter(
'tserver',
['server_type' => SERVER_TYPE_ENTERPRISE_SATELLITE],
[
'id_server',
'name',
]
);
$satellite_names = [];
if (empty($satellite_servers) === false) {
foreach ($satellite_servers as $s_server) {
$satellite_names[$s_server['id_server']] = $s_server['name'];
// Basic Options.
$tableBasicAgent = new stdClass();
$tableBasicAgent->class = 'filter-table-adv';
$tableBasicAgent->data = [];
$disabledBasic = false;
$tableClassDisabled = '';
if ($new_agent === true || $remote_agent === false || $has_remote_conf === false) {
$disabledBasic = true;
$tableClassDisabled = ' basic-options-disabled';
}
if (enterprise_installed()) {
// Get all plugins (BASIC OPTIONS).
$agent_plugin = new PandoraFMS\Agent($id_agente);
$plugins = $agent_plugin->getPlugins();
// Check if some plugin was enabled/disabled in conf.
foreach ($plugins as $key => $row) {
if (preg_match('/pandora_hardening/', $row['raw']) === 1) {
if ($row['disabled'] === 1) {
$security_hardening = 0;
} else {
$security_hardening = 1;
}
}
$table_satellite = '<div class="label_select"><p class="input_label">'.__('Satellite').'</p>';
$table_satellite .= '<div class="label_select_parent">';
if ($id_os === '1' || $id_os === '8') {
if (preg_match('/(module_plugin grep_log_module ).*/', $row['raw']) === 1) {
if ($row['disabled'] === 1) {
$enable_log_collector = 0;
} else {
$enable_log_collector = 1;
}
}
$table_satellite .= html_print_input(
if (preg_match('/(module_plugin inventory).*/', $row['raw']) === 1) {
if ($row['disabled'] === 1) {
$enable_inventory = 0;
} else {
$enable_inventory = 1;
}
}
} else {
if (preg_match('/.vbs/', $row['raw']) === 1 && preg_match('/nettraffic.vbs/', $row['raw']) === 0 && preg_match('/software_installed.vbs/', $row['raw']) === 0 && preg_match('/df.vbs/', $row['raw']) === 0 && preg_match('/win_cf.vbs/', $row['raw']) === 0) {
if ($row['disabled'] === 1) {
$enable_inventory = 0;
} else {
$enable_inventory = 1;
}
}
}
}
if ($id_os === '9') {
$modules = $agent_plugin->getModules();
foreach ($modules as $key => $row) {
if (preg_match('/PandoraAgent_log/', $row['raw']) === 1) {
if ($row['disabled'] === 1) {
$enable_log_collector = 0;
} else {
$enable_log_collector = 1;
}
}
}
}
unset($agent_plugin, $plugins);
if (($new_agent === true && $config['current_package'] >= 774) || ($agent_version >= 774 && $new_agent === false)) {
if ($disabledBasic === true || $has_remote_conf === false) {
$message = __('Remote config disabled, please activate to enable agent basic options');
$tableBasicAgent->data[] = '<span>'.$message.'</span>';
}
$tableBasicAgent->data[] = html_print_label_input_block(
__('Enable security hardening monitoring'),
html_print_input(
[
'type' => 'select',
'fields' => $satellite_names,
'name' => 'satellite_server',
'selected' => $satellite_server,
'nothing' => __('None'),
'nothinf_value' => 0,
'return' => true,
'type' => 'switch',
'id' => 'security_hardening',
'name' => 'security_hardening',
'value' => $security_hardening,
'disabled' => $disabledBasic,
]
).'<div class="label_select_child_icons"></div></div></div>';
).html_print_input_hidden('options_package', '1', true)
);
$tableBasicAgent->data[] = html_print_label_input_block(
__('Enable log collection'),
html_print_input(
[
'type' => 'switch',
'id' => 'enable_log_collector',
'name' => 'enable_log_collector',
'value' => $enable_log_collector,
'disabled' => $disabledBasic,
]
)
);
}
$tableBasicAgent->data[] = html_print_label_input_block(
__('Enable inventory'),
html_print_input(
[
'type' => 'switch',
'id' => 'enable_inventory',
'name' => 'enable_inventory',
'value' => $enable_inventory,
'disabled' => $disabledBasic,
]
).html_print_input_hidden('enable_basic_options', '1', true)
);
if ($config['ehorus_enabled'] === '1') {
$pandoraRC_Id = html_print_image(
'images/alert_recovered@svg.svg',
true,
[
'class' => 'invert_filter main_menu_icon',
'title' => __('Pandora RC connected with id ').$config['ehorus_custom_field'],
]
);
} else {
$pandoraRC_Id = html_print_image(
'images/alerts.svg',
true,
[
'class' => 'invert_filter main_menu_icon',
'title' => __('This agent do not have a Pandora RC agent installed, install one.'),
]
);
}
*/
$tableBasicAgent->data[] = html_print_label_input_block(
__('Enable remote control'),
$pandoraRC_Id
);
$WarningPackage = '';
if (($new_agent === true && $config['current_package'] < 774) || ($agent_version < 774 && $new_agent === false)) {
$WarningPackage = html_print_image(
'images/alert-yellow@svg.svg',
true,
[
'title' => __('Only available for agents 774 or higher'),
'alt' => __('Only available for agents 774 or higher'),
'class' => 'main_menu_icon mrgn_lft_5px',
]
);
}
} else {
$tableBasicAgent->data[] = '<span>'.__('Remote config is enabled only in the Enteprise version').'</span>';
$tableBasicAgent->data[] .= html_print_input_hidden(
'enable_basic_options',
'0',
true
);
}
ui_toggle(
html_print_table($tableBasicAgent, true),
'<span class="subsection_header_title">'.__('Basic options').$WarningPackage.'</span>',
'',
'basic_options',
true,
false,
'white_box_content',
'no-border white_table_graph'.$tableClassDisabled,
'box-flat white_table_graph invisible'
);
// Advanced options.
$tableAdvancedAgent = new stdClass();
@ -922,22 +1055,25 @@ $tableAdvancedAgent->data['safe_operation'][] = html_print_label_input_block(
)
);
$tableAdvancedAgent->data['vul_scan_enabled'][] = html_print_label_input_block(
__('Vulnerability scanning'),
html_print_select(
[
0 => __('Disabled'),
1 => __('Enabled'),
2 => __('Use global settings'),
],
'vul_scan_enabled',
$vul_scan_enabled,
'',
'',
0,
true
)
);
if (enterprise_installed() === true) {
$tableAdvancedAgent->data['vul_scan_enabled'][] = html_print_label_input_block(
__('Vulnerability scanning'),
html_print_select(
[
0 => __('Disabled'),
1 => __('Enabled'),
2 => __('Use global settings'),
],
'vul_scan_enabled',
$vul_scan_enabled,
'',
'',
0,
true
)
);
}
ui_toggle(
html_print_table($tableAdvancedAgent, true),
@ -1101,11 +1237,24 @@ if ($new_agent === false) {
$actionButtons .= html_print_input_hidden('id_agente', $id_agente);
if (is_management_allowed() === true) {
$clusters = agents_get_agent_belongs_cluster($id_agente);
$cluster_belongs = '';
if (empty($clusters) === false) {
$clusters = array_reduce(
$clusters,
function ($carry, $item) {
$carry[] = $item['name'];
return $carry;
}
);
$cluster_belongs = implode(', ', $clusters);
}
$actionButtons .= html_print_button(
__('Delete agent'),
'deleteAgent',
false,
'deleteAgentDialog('.$id_agente.')',
'deleteAgentDialog('.$id_agente.', "'.$cluster_belongs.'")',
[
'icon' => 'delete',
'mode' => 'secondary dialog_opener',
@ -1153,10 +1302,18 @@ ui_require_jquery_file('bgiframe');
}
}
function deleteAgentDialog($idAgente) {
function deleteAgentDialog($idAgente, cluster) {
var msg_cluster = '';
if(cluster) {
msg_cluster = "<?php echo __('This agent belongs to the clusters'); ?>";
msg_cluster += ': ';
msg_cluster += cluster;
msg_cluster += '. ';
}
confirmDialog({
title: "<?php echo __('Delete agent'); ?>",
message: "<?php echo __('This action is not reversible. Are you sure'); ?>",
message: msg_cluster + "<?php echo __('This action is not reversible. Are you sure'); ?>",
onAccept: function() {
window.location.assign('index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente='+$idAgente);
}
@ -1253,7 +1410,8 @@ ui_require_jquery_file('bgiframe');
});
$("#checkbox-cascade_protection").change(function () {
var checked = $("#checkbox-cascade_protection").is(":checked"); if (checked) {
var checked = $("#checkbox-cascade_protection").is(":checked");
if (checked) {
$("#cascade_protection_module").removeAttr("disabled");
$("#text-id_parent").attr("required", "required");
}
@ -1263,7 +1421,7 @@ ui_require_jquery_file('bgiframe');
$("#text-id_parent").removeAttr("required");
}
});
var safe_mode_checked = $("#checkbox-safe_mode").is(":checked");
if (safe_mode_checked) {
$("#safe_mode_module").removeAttr("disabled");
@ -1271,10 +1429,10 @@ ui_require_jquery_file('bgiframe');
else {
$("#safe_mode_module").attr("disabled", 'disabled');
}
$("#checkbox-safe_mode").change(function () {
var safe_mode_checked = $("#checkbox-safe_mode").is(":checked");
if (safe_mode_checked) {
$("#safe_mode_module").removeAttr("disabled");
}
@ -1308,5 +1466,17 @@ ui_require_jquery_file('bgiframe');
}
});
check_basic_options();
$('#id_os').on('change', function(){
check_basic_options();
})
});
function check_basic_options(){
if ($('#id_os').val() == 1 || $('#id_os').val() == 8 || $('#id_os').val() == 9) {
$('#basic_options').removeClass('invisible');
} else {
$('#basic_options').addClass('invisible');
}
}
</script>

View File

@ -232,7 +232,7 @@ if ($create_agent) {
$cps = (int) get_parameter_switch('cps', -1);
$fixed_ip = (int) get_parameter_switch('fixed_ip', 0);
$vul_scan_enabled = (int) get_parameter_switch('vul_scan_enabled', 2);
$agent_version = $config['current_package'];
$secondary_groups = (array) get_parameter('secondary_groups_selected', '');
$fields = db_get_all_fields_in_table('tagent_custom_fields');
@ -300,6 +300,7 @@ if ($create_agent) {
'cps' => $cps,
'fixed_ip' => $fixed_ip,
'vul_scan_enabled' => $vul_scan_enabled,
'agent_version' => $agent_version,
]
);
} else {
@ -1015,6 +1016,13 @@ if ($update_agent) {
$satellite_server = (int) get_parameter('satellite_server', 0);
$fixed_ip = (int) get_parameter_switch('fixed_ip', 0);
$vul_scan_enabled = (int) get_parameter_switch('vul_scan_enabled', 2);
$security_vunerability = (int) get_parameter_switch('security_vunerability', 0);
$security_hardening = (int) get_parameter_switch('security_hardening', 0);
$security_monitoring = (int) get_parameter_switch('security_monitoring', 0);
$enable_log_collector = (int) get_parameter_switch('enable_log_collector', 0);
$enable_inventory = (int) get_parameter_switch('enable_inventory', 0);
$enable_basic_options = get_parameter('enable_basic_options');
$options_package = get_parameter('options_package', '0');
if ($fields === false) {
$fields = [];
@ -1243,6 +1251,81 @@ if ($update_agent) {
);
}
}
if ($enable_basic_options === '1') {
// Get all plugins (BASIC OPTIONS).
$agent = new PandoraFMS\Agent($id_agente);
$plugins = $agent->getPlugins();
foreach ($plugins as $key => $row) {
// Only check plugins when agent package is bigger than 774.
if ($options_package === '1') {
if (preg_match('/pandora_hardening/', $row['raw']) === 1) {
if ($security_hardening === 1) {
if ($row['disabled'] === 1) {
$agent->enablePlugins($row['raw']);
}
} else {
if ($row['disabled'] !== 1) {
$agent->disablePlugins($row['raw']);
}
}
}
if (preg_match('/(module_plugin grep_log_module ).*/', $row['raw']) === 1) {
if ($enable_log_collector === 1) {
if ($row['disabled'] === 1) {
$agent->enablePlugins($row['raw']);
}
} else {
if ($row['disabled'] !== 1) {
$agent->disablePlugins($row['raw']);
}
}
}
}
// Inventory switch enable when basic options are enabled.
if (preg_match('/(module_plugin inventory).*/', $row['raw']) === 1) {
if ($enable_inventory === 1) {
if ($row['disabled'] === 1) {
$agent->enablePlugins($row['raw']);
}
} else {
if ($row['disabled'] !== 1) {
$agent->disablePlugins($row['raw']);
}
}
}
// Inventory switch enable when basic options are enabled.
if (preg_match('/.vbs/', $row['raw']) === 1 && preg_match('/nettraffic.vbs/', $row['raw']) === 0 && preg_match('/software_installed.vbs/', $row['raw']) === 0 && preg_match('/df.vbs/', $row['raw']) === 0 && preg_match('/win_cf.vbs/', $row['raw']) === 0) {
if ($enable_inventory === 1) {
if ($row['disabled'] === 1) {
$agent->enablePlugins($row['raw']);
}
} else {
if ($row['disabled'] !== 1) {
$agent->disablePlugins($row['raw']);
}
}
}
}
$modules = $agent->getModules();
foreach ($modules as $key => $row) {
if (preg_match('/PandoraAgent_log/', $row['raw']) === 1) {
if ($enable_log_collector === 1) {
if ($row['disabled'] === 1) {
$agent->enableModule($row['module_name'], $row);
}
} else {
if ($row['disabled'] !== 1) {
$agent->disableModule($row['module_name'], $row);
}
}
}
}
}
}
// Read agent data
@ -1300,6 +1383,19 @@ if ($id_agente) {
$satellite_server = (int) $agent['satellite_server'];
$fixed_ip = (int) $agent['fixed_ip'];
$vul_scan_enabled = (int) $agent['vul_scan_enabled'];
if (strpos($agent['agent_version'], '(')) {
$agent_version = (int) explode('.', explode('(', $agent['agent_version'])[0])[2];
} else {
if (strpos($agent['agent_version'], 'build') || strpos($agent['agent_version'], 'Build')) {
$agent_version = (int) explode('.', explode('build', $agent['agent_version'])[0])[2];
} else {
if (strpos($agent['agent_version'], '.')) {
$agent_version = (int) explode('.', $agent['agent_version'])[2];
} else {
$agent_version = $agent['agent_version'];
}
}
}
}
$update_module = (bool) get_parameter('update_module');
@ -2162,6 +2258,28 @@ if ($update_module || $create_module
|| ($module_in_policy && !$module_linked)
) {
if ($success_action > 0) {
if (empty($old_configuration_data) === true
&& empty($configuration_data) === true && $disabled === '0'
&& ($enable_module || $disable_module)
) {
$modulo_nombre = io_safe_output(
db_get_value(
'nombre',
'tagente_modulo',
'id_agente_modulo',
(empty($disable_module) === false) ? $disable_module : $enable_module
)
);
$old_configuration_data = config_agents_get_module_from_conf(
$id_agente,
$modulo_nombre
);
$configuration_data = $old_configuration_data;
$disabled = (empty($disable_module) === false) ? true : false;
}
enterprise_hook(
'config_agents_write_module_in_conf',
[
@ -2310,7 +2428,6 @@ if ($disable_module) {
$modulo_nombre = io_safe_output($modulo_nombre['nombre']);
if ($result === NOERR) {
enterprise_hook('config_agents_disable_module_conf', [$id_agente, $disable_module]);
db_pandora_audit(
AUDIT_LOG_MODULE_MANAGEMENT,
'Disable #'.$disable_module.' | '.$modulo_nombre.' | '.$agent['alias']

View File

@ -566,10 +566,10 @@ if ($search != '') {
if ($id != '') {
$aux = $id[0]['id_agent'];
$search_sql = sprintf(
' AND ( nombre LIKE "%%%s%%"
OR alias LIKE "%%%s%%"
OR comentarios LIKE "%%%s%%"
OR EXISTS (SELECT * FROM tagent_custom_data WHERE id_agent = id_agente AND description LIKE "%%%s%%")
' AND ( REPLACE(nombre, "&#x20;", " ") LIKE "%%%s%%"
OR REPLACE(alias, "&#x20;", " ") LIKE "%%%s%%"
OR REPLACE(comentarios, "&#x20;", " ") LIKE "%%%s%%"
OR EXISTS (SELECT * FROM tagent_custom_data WHERE id_agent = id_agente AND REPLACE(description, "&#x20;", " ") LIKE "%%%s%%")
OR tagente.id_agente = %d',
$search,
$search,
@ -591,10 +591,10 @@ if ($search != '') {
$search_sql .= ')';
} else {
$search_sql = sprintf(
' AND ( nombre
LIKE "%%%s%%" OR alias
LIKE "%%%s%%" OR comentarios LIKE "%%%s%%"
OR EXISTS (SELECT * FROM tagent_custom_data WHERE id_agent = id_agente AND description LIKE "%%%s%%"))',
' AND ( REPLACE(nombre, "&#x20;", " ")
LIKE "%%%s%%" OR REPLACE(alias, "&#x20;", " ")
LIKE "%%%s%%" OR REPLACE(comentarios, "&#x20;", " ") LIKE "%%%s%%"
OR EXISTS (SELECT * FROM tagent_custom_data WHERE id_agent = id_agente AND REPLACE(description, "&#x20;", " ") LIKE "%%%s%%"))',
$search,
$search,
$search,
@ -958,12 +958,33 @@ if ($agents !== false) {
);
if ($check_aw === true && is_management_allowed() === true) {
if ($agent['id_os'] != CLUSTER_OS_ID) {
$onClickActionDeleteAgent = 'if (!confirm(\' '.__('Are you sure?').'\')) return false;';
} else {
$onClickActionDeleteAgent = 'if (!confirm(\' '.__('WARNING! - You are going to delete a cluster agent. Are you sure?').'\')) return false;';
$clusters = agents_get_agent_belongs_cluster($agent['id_agente']);
$cluster_belongs = '';
if (empty($clusters) === false) {
$clusters = array_reduce(
$clusters,
function ($carry, $item) {
$carry[] = $item['name'];
return $carry;
}
);
$cluster_belongs = implode(', ', $clusters);
}
$msg = '';
if ($agent['id_os'] == CLUSTER_OS_ID) {
$msg .= __('You are going to delete a cluster agent');
$msg .= '. ';
} else if (empty($cluster_belongs) === false) {
$msg .= __('This agent belongs to the clusters');
$msg .= ': ';
$msg .= $cluster_belongs;
$msg .= '. ';
}
$msg .= __('Are you sure?');
$onClickActionDeleteAgent = 'if (!confirm(\' '.$msg.'\')) return false;';
$agentActionButtons[] = html_print_menu_button(
[
'href' => ui_get_full_url(

View File

@ -38,6 +38,7 @@ $isFunctionPolicies = enterprise_include_once('include/functions_policies.php');
require_once $config['homedir'].'/include/functions_modules.php';
require_once $config['homedir'].'/include/functions_agents.php';
require_once $config['homedir'].'/include/functions_servers.php';
require_once $config['homedir'].'/include/functions_macros.php';
$search_string = get_parameter('search_string');
@ -574,7 +575,7 @@ $where = sprintf('delete_pending = 0 AND id_agente = %s', $id_agente);
$search_string_entities = io_safe_input($search_string);
$basic_where = sprintf(
"(nombre LIKE '%%%s%%' OR nombre LIKE '%%%s%%' OR descripcion LIKE '%%%s%%' OR descripcion LIKE '%%%s%%') AND",
"(REPLACE(nombre, '&#x20;', ' ') LIKE '%%%s%%' OR REPLACE(nombre, '&#x20;', ' ') LIKE '%%%s%%' OR REPLACE(descripcion, '&#x20;', ' ') LIKE '%%%s%%' OR REPLACE(descripcion, '&#x20;', ' ') LIKE '%%%s%%') AND",
$search_string,
$search_string_entities,
$search_string,
@ -949,7 +950,23 @@ if ($modules !== false) {
);
if (strlen($module['ip_target']) !== 0) {
$title .= '<br/>IP: '.$module['ip_target'];
// Check if value is custom field.
if ($module['ip_target'][0] == '_' && $module['ip_target'][(strlen($module['ip_target']) - 1)] == '_') {
$custom_field_name = substr($module['ip_target'], 1, -1);
$custom_value = agents_get_agent_custom_field($id_agente, $custom_field_name);
if (isset($custom_value) && $custom_value !== false) {
$title .= '<br/>IP: '.$custom_value;
} else {
$array_macros = return_agent_macros($id_agente);
if (isset($array_macros[$module['ip_target']])) {
$title .= '<br/>IP: '.$array_macros[$module['ip_target']];
} else {
$title .= '<br/>IP: '.$module['ip_target'];
}
}
} else {
$title .= '<br/>IP: '.$module['ip_target'];
}
}
// This module is initialized ? (has real data).

View File

@ -2003,23 +2003,14 @@ ui_require_jquery_file('json');
var type_names = jQuery.parseJSON(Base64.decode($('#hidden-type_names').val()));
var type_name_selected = type_names[type_selected];
if ($('#radius-percentage_warning').prop('checked') === true || $('#radius-percentage_critical').prop('checked') === true || type_name_selected == 'generic_data_string') {
if (($('#radius-percentage_warning').prop('checked') === true && $('#radius-percentage_critical').prop('checked') === true) || type_name_selected == 'generic_data_string') {
paint_graph_values();
$("#svg_dinamic").hide();
} else {
paint_graph_values();
$("#svg_dinamic").show();
}
if ($('#radius-percentage_warning').prop('checked') === true) {
$('#radius-warning_inverse').hide();
$('#label-radius-warning_inverse').hide();
}
if ($('#radius-warning_inverse').prop('checked') === true) {
$('#radius-percentage_warning').hide();
$('#label-radius-percentage_warning').hide();
}
if ($('#radius-normal_warning').prop('checked') === true) {
$('#radius-warning_inverse').show();
$('#label-radius-warning_inverse').show();
@ -2027,17 +2018,6 @@ ui_require_jquery_file('json');
$('#label-radius-percentage_warning').show();
}
if ($('#radius-percentage_critical').prop('checked') === true) {
$('#radius-critical_inverse').hide();
$('#label-radius-critical_inverse').hide();
}
if ($('#radius-critical_inverse').prop('checked') === true) {
$('#radius-percentage_critical').hide();
$('#label-radius-percentage_critical').hide();
}
if ($('#radius-normal_critical').prop('checked') === true) {
$('#radius-critical_inverse').show();
$('#label-radius-critical_inverse').show();
@ -2354,30 +2334,48 @@ ui_require_jquery_file('json');
var message_error_percentage = '<?php echo __('Please introduce a positive percentage value'); ?>';
//if haven't error
if (max_w == 0 || max_w > min_w) {
if (max_c == 0 || max_c > min_c) {
paint_graph_status(
min_w, max_w, min_c, max_c, inverse_w,
inverse_c, error_w, error_c,
legend_normal, legend_warning, legend_critical,
message_error_warning, message_error_critical
);
if (max_w == 0 || max_w > min_w || $('#radius-percentage_warning').is(':checked') === true) {
if (max_c == 0 || max_c > min_c || $('#radius-percentage_critical').is(':checked') === true) {
error_c = 0;
error_w = 0;
} else {
error_c = 1;
paint_graph_status(
0, 0, 0, 0, 0, 0, error_w, error_c,
legend_normal, legend_warning, legend_critical,
message_error_warning, message_error_critical
);
min_w = 0;
max_w = 0;
min_c = 0;
max_c = 0;
inverse_w = 0;
inverse_c = 0;
}
} else {
if (max_c !== 0 && max_c < min_c && $('#radius-percentage_critical').is(':checked') === false) {
error_c = 2;
}
error_w = 1;
paint_graph_status(
0, 0, 0, 0, 0, 0, error_w, error_c,
legend_normal, legend_warning, legend_critical,
message_error_warning, message_error_critical
);
min_w = 0;
max_w = 0;
min_c = 0;
max_c = 0;
inverse_w = 0;
inverse_c = 0;
}
if ($('#radius-percentage_warning').is(':checked') === true){
min_w = 0;
max_w = 0;
}
if ($('#radius-percentage_critical').is(':checked') === true){
min_c = 0;
max_c = 0;
}
paint_graph_status(
min_w, max_w, min_c, max_c, inverse_w,
inverse_c, error_w, error_c,
legend_normal, legend_warning, legend_critical,
message_error_warning, message_error_critical
);
}
/* ]]> */

View File

@ -171,7 +171,7 @@ foreach ($password_fields as $k => $p) {
}
$(document).ready(function () {
if ($("#id_plugin").val() === 0) {
if ($("#id_plugin").val() !== 0) {
changePluginSelect();
}
});

View File

@ -256,7 +256,7 @@ $schedule = io_safe_output(
$data[0] = '';
$data[0] .= html_print_input_hidden('schedule', $schedule, true);
$data[0] .= '<div id="calendar_map"></div>';
$data[0] .= '<div id="calendar_map" class="alert_view_calendar"></div>';
$data[1] = '';
$table_conditions->data[] = $data;

View File

@ -115,6 +115,7 @@ $fields_available['module_status'] = __('Module Status');
$fields_available['mini_severity'] = __('Severity mini');
$fields_available['module_custom_id'] = __('Module custom ID');
$fields_available['custom_data'] = __('Custom data');
$fields_available['event_custom_id'] = __('Event Custom ID');
// Remove fields already selected.

View File

@ -243,10 +243,15 @@ switch ($action) {
$map_default_altitude = get_parameter('map_default_altitude');
$map_group_id = get_parameter('map_group_id');
$map_levels_zoom = get_parameter('map_levels_zoom', 16);
$map_connection_list_temp = explode(',', get_parameter('map_connection_list'));
$map_connection_list_temp_string = implode(',', $map_connection_list_temp);
if (strlen($map_connection_list_temp_string) > 0) {
$where_map_connection = ' WHERE id_tmap_connection IN('.$map_connection_list_temp_string.')';
} else {
$where_map_connection = '';
}
$listConnectionTemp = db_get_all_rows_sql('SELECT id_tmap_connection, conection_name, group_id FROM tgis_map_connection');
$listConnectionTemp = db_get_all_rows_sql('SELECT id_tmap_connection, conection_name, group_id FROM tgis_map_connection'.$where_map_connection);
foreach ($map_connection_list_temp as $index => $value) {
$cleanValue = trim($value);
@ -256,7 +261,6 @@ switch ($action) {
}
$map_connection_default = get_parameter('map_connection_default');
$map_connection_list = [];
foreach ($listConnectionTemp as $idMapConnection) {
$default = 0;
@ -345,7 +349,7 @@ function deleteConnectionMap(idConnectionMap) {
checked = $("#radiobtn0001", $("#map_connection_" + idConnectionMap)).attr('checked');
$("#map_connection_" + idConnectionMap).remove();
if (checked) {
//Checked first, but not is index = 0 maybe.
@ -485,7 +489,7 @@ foreach ($listConnectionTemp as $connectionTemp) {
$table->data[1][0] = __('Add Map connection').$iconError;
$table->data[1][1] = "<table class='no-class' border='0' id='map_connection'>
<tr>
<td>".html_print_select($listConnection, 'map_connection_list', '', '', '', '0', true)."
<td>".html_print_select($listConnection, 'select-map_connection_list', '', '', '', '0', true)."
</td>
<td >
<a href='javascript: addConnectionMap();'>".html_print_image(

View File

@ -84,6 +84,9 @@ if (is_ajax() === true) {
}
$group = db_get_row('tgrupo', 'id_grupo', $id_group);
if (str_contains($group['icon'], '.png') === true) {
$group['folder'] = 'groups_small/';
}
echo json_encode($group);
return;

View File

@ -154,7 +154,7 @@ if ($is_management_allowed === true && $update_group === true) {
$subcheck = db_get_value('name', 'tmodule_group', 'id_mg', $id_group);
if ($name) {
if (!$check || $subcheck == $name) {
if ($check === false || strcasecmp($subcheck, $name) === 0) {
$result = db_process_sql_update(
'tmodule_group',
['name' => $name],

View File

@ -111,7 +111,8 @@ if ($delete) {
$alerts_agent_modules = [];
foreach ($agent_alerts['simple'] as $agent_alert) {
if ((in_array($agent_alert['id_alert_template'], $id_alert_templates)) && (in_array($agent_alert['id_agent_module'], $modules_id))) {
$alerts_agent_modules = array_merge($alerts_agent_modules, alerts_get_alerts_agent_module($agent_alert['id_agent_module'], true, false, 'id'));
// $alerts_agent_modules = array_merge($alerts_agent_modules, alerts_get_alerts_agent_module($agent_alert['id_agent_module'], true, false, 'id'));
$alerts_agent_modules[] = $agent_alert['id'];
}
}
@ -126,7 +127,7 @@ if ($delete) {
$agent_module_actions = [];
foreach ($alerts_agent_modules as $alert_agent_module) {
$agent_module_actions = alerts_get_alert_agent_module_actions($alert_agent_module['id'], ['id', 'id_alert_action']);
$agent_module_actions = alerts_get_alert_agent_module_actions($alert_agent_module, ['id', 'id_alert_action']);
foreach ($agent_module_actions as $agent_module_action) {
foreach ($actions as $action) {

View File

@ -478,8 +478,8 @@ if ($access_console_node === true) {
}
}
$sub2['godmode/setup/setup&section=ehorus']['text'] = __('Pandora RC');
$sub2['godmode/setup/setup&section=ehorus']['refr'] = 0;
$sub2['godmode/setup/setup&section=pandorarc']['text'] = __('Pandora RC');
$sub2['godmode/setup/setup&section=pandorarc']['refr'] = 0;
$sub2['godmode/setup/setup&section=ITSM']['text'] = __('ITSM');
$sub2['godmode/setup/setup&section=ITSM']['refr'] = 0;
@ -577,12 +577,13 @@ if ($access_console_node === true) {
continue;
}
$extmenu = [];
if ($extension['godmode_menu']['name'] !== __('DB Schema check') && $extension['godmode_menu']['name'] !== __('DB interface')) {
$extmenu = $extension['godmode_menu'];
}
// Check the ACL for this user.
if ((bool) check_acl($config['id_user'], 0, $extmenu['acl']) === false) {
if ((bool) check_acl($config['id_user'], 0, ($extmenu['acl'] ?? '')) === false) {
continue;
}
@ -744,7 +745,7 @@ if ((bool) $config['pure'] === false) {
echo '<div id="about-div"></div>';
// Need to be here because the translate string.
if (check_acl($config['id_user'], $group, 'AW')) {
if (check_acl($config['id_user'], 0, 'AW')) {
?>
<script type="text/javascript">
$("#conf_wizard").click(function() {

View File

@ -729,7 +729,7 @@ if ($search_id_group) {
}
if ($search_string != '') {
$filter[] = '(name LIKE '."'%".$search_string."%'".'OR description LIKE '."'%".$search_string."%'".'OR tcp_send LIKE '."'%".$search_string."%'".'OR tcp_rcv LIKE '."'%".$search_string."%'".')';
$filter[] = '(REPLACE(name, "&#x20;", " ") LIKE '."'%".$search_string."%'".' OR REPLACE(REPLACE(description, "&#x20;", " "), "&#x20", " ")LIKE '."'%".$search_string."%'".' OR REPLACE(tcp_send, "&#x20;", " ") LIKE '."'%".$search_string."%'".'OR REPLACE(tcp_rcv, "&#x20;", " ") LIKE '."'%".$search_string."%'".')';
}
$total_components = network_components_get_network_components(

View File

@ -117,6 +117,8 @@ $exception_condition = REPORT_EXCEPTION_CONDITION_EVERYTHING;
$exception_condition_value = 10;
$modulegroup = 0;
$period = SECONDS_1DAY;
$period_time_service_level = '28800';
$show_agents = false;
$search = '';
$full_text = 0;
$log_number = 1000;
@ -882,6 +884,28 @@ switch ($action) {
$idAgentModule = $module;
break;
case 'service_level':
$description = $item['description'];
$es = json_decode($item['external_source'], true);
$period_time_service_level = $es['period_time_service_level'];
$show_agents = $es['show_agents'];
// Decode agents and modules.
$id_agents = json_decode(
io_safe_output(base64_decode($es['id_agents'])),
true
);
$module = json_decode(
io_safe_output(base64_decode($es['module'])),
true
);
$recursion = $item['recursion'];
$group = $item['id_group'];
$modulegroup = $item['id_module_group'];
$idAgentModule = $module;
break;
case 'end_of_life':
$es = json_decode($item['external_source'], true);
@ -1038,7 +1062,13 @@ switch ($action) {
break;
case 'ncm':
$idAgent = $item['id_agent'];
$id_agent_ncm = json_decode($item['ncm_agents']);
$ncm_group = $item['id_group'];
break;
case 'ncm_backups':
$id_agent_ncm = json_decode($item['ncm_agents']);
$ncm_group = $item['id_group'];
break;
case 'top_n_agents_sh':
@ -1086,6 +1116,50 @@ switch ($action) {
$period = $item['period'];
break;
case 'vuls_severity_graph':
$group = $item['id_group'];
break;
case 'vuls_attack_complexity':
$group = $item['id_group'];
break;
case 'vuls_by_packages':
$group = $item['id_group'];
break;
case 'vuls_by_agent':
$group = $item['id_group'];
$es = json_decode($item['external_source'], true);
$selected_agent_custom_field_filter = $es['agent_custom_field_filter'];
$security_hardening_score = $es['security_hardening_score'];
$vulnerabilities_status = $es['vulnerabilities_status'];
$secmon_status = $es['secmon_status'];
break;
case 'vuls_info_agent':
$idAgent = $item['id_agent'];
$es = json_decode($item['external_source'], true);
$vul_package = $es['vul_package'];
$vul_severity = $es['vul_severity'];
$vul_ac = $es['vul_ac'];
$vul_pr = $es['vul_pr'];
$vul_ui = $es['vul_ui'];
$vul_av = (empty($es['vul_av']) === true) ? 'all' : $es['vul_av'];
break;
case 'top_n_agents_vuls':
$group = $item['id_group'];
$recursion = $item['recursion'];
$top_n_value = (empty($item['top_n_value']) === true) ? 10 : $item['top_n_value'];
break;
case 'top_n_vuls_count':
$group = $item['id_group'];
$recursion = $item['recursion'];
$top_n_value = (empty($item['top_n_value']) === true) ? 10 : $item['top_n_value'];
break;
default:
// It's not possible.
break;
@ -1102,6 +1176,7 @@ switch ($action) {
case 'sumatory':
case 'database_serialized':
case 'last_value':
case 'service_level':
case 'monitor_report':
case 'min_value':
case 'max_value':
@ -1598,7 +1673,7 @@ if (is_metaconsole() === true) {
10,
false,
false,
true,
false,
'',
false,
false,
@ -1612,6 +1687,53 @@ if (is_metaconsole() === true) {
</td>
</tr>
<tr id="row_period_service_level" class="datos">
<td class="bolder">
<?php
echo __('Time lapse');
ui_print_help_tip(
__('This is the range, or period of time over which the report renders the information for this report type. For example, a week means data from a week ago from now. ')
);
?>
</td>
<td >
<?php
$fields_time_service_level = [
'604800' => __('1 week'),
'172800' => __('48 hours'),
'86400' => __('24 hours'),
'43200' => __('12 hours'),
'28800' => __('8 hours'),
];
html_print_select(
$fields_time_service_level,
'period_time_service_level',
$period_time_service_level,
);
?>
</td>
</tr>
<tr id="row_show_agents" class="datos">
<td class="bolder" class="datos">
<?php
echo __('Show agents');
?>
</td>
<td >
<?php
html_print_checkbox_switch(
'show_agents',
'1',
$show_agents,
false,
false,
);
?>
</td>
</tr>
<tr id="row_period_range" class="datos">
<td class="bolder">
<?php
@ -1632,7 +1754,7 @@ if (is_metaconsole() === true) {
10,
false,
false,
true,
false,
'',
false,
false,
@ -1686,7 +1808,7 @@ if (is_metaconsole() === true) {
10,
false,
false,
true,
false,
'',
false,
false,
@ -1711,7 +1833,7 @@ if (is_metaconsole() === true) {
<td >
<?php
html_print_extended_select_for_time(
'period',
'period3',
(string) $period,
'onselect=loadLogAgents();',
'',
@ -1749,7 +1871,7 @@ if (is_metaconsole() === true) {
10,
false,
false,
true,
false,
'',
false,
false,
@ -1963,6 +2085,71 @@ if (is_metaconsole() === true) {
?>
</td>
</tr>
<tr id="row_ncm_group" class="datos">
<td class="bolder"><?php echo __('Group NCM'); ?></td>
<td >
<?php
echo '<div class="w250px inline padding-right-2-imp">';
$url = ui_get_full_url('ajax.php');
html_print_input_hidden('url_ajax', $url, false, false, false, 'url_ajax');
if (check_acl($config['id_user'], 0, 'RW')) {
html_print_select_groups(
$config['id_user'],
'RW',
true,
'ncm_group',
$ncm_group,
'filterNcmAgentChange()',
);
} else if (check_acl($config['id_user'], 0, 'RM')) {
html_print_select_groups(
$config['id_user'],
'RM',
true,
'ncm_group',
$ncm_group,
'filterNcmAgentChange()',
);
}
echo '</div>';
?>
</td>
</tr>
<tr id="row_ncm_agent">
<td class="bolder"><?php echo __('Agent NCM'); ?></td>
<td >
<?php
echo '<div class="w250px inline padding-right-2-imp">';
$all_agents = agents_get_agents_selected($ncm_group);
html_print_select(
$all_agents,
'agent_ncm[]',
$id_agent_ncm,
'',
__('Any'),
0,
false,
true,
true,
'',
false,
'width: 100%;',
false,
false,
false,
'',
false,
false,
false,
false,
true,
true,
);
echo '</div>';
?>
</td>
</tr>
<tr id="row_source" class="datos">
<td class="bolder"><?php echo __('Source'); ?></td>
<td >
@ -2219,7 +2406,7 @@ if (is_metaconsole() === true) {
$modulegroup,
$id_agents,
!$selection_a_m,
false
true
);
}
@ -3965,6 +4152,217 @@ if (is_metaconsole() === true) {
?>
</td>
</tr>
<tr id="row_secmon_status" class="datos">
<td class="bolder">
<?php
echo __('Secmon status');
?>
</td>
<td>
<?php
html_print_select(
[
'all' => __('All'),
'critical' => __('Critical'),
'warning' => __('Warning'),
],
'secmon_status',
$secmon_status,
);
?>
</td>
</tr>
<tr id="row_security_hardening_score" class="datos">
<td class="bolder">
<?php
echo __('Security hardening score');
?>
</td>
<td>
<?php
html_print_select(
[
'all' => __('All'),
'90' => __('< 90%'),
'80' => __('< 80%'),
'70' => __('< 70%'),
'60' => __('< 60%'),
'50' => __('< 50%'),
'40' => __('< 40%'),
'30' => __('< 30%'),
'20' => __('< 20%'),
'10' => __('< 10%'),
],
'security_hardening_score',
(empty($security_hardening_score) === false) ? $security_hardening_score : 'all',
'',
'',
0,
false,
false,
false
);
?>
</td>
</tr>
<tr id="row_vulnerabilities_status" class="datos">
<td class="bolder">
<?php
echo __('Vulnerabilities status');
?>
</td>
<td>
<?php
html_print_select(
[
'all' => __('All'),
'crit' => __('Critical'),
'warn' => __('Warning'),
],
'vulnerabilities_status',
$vulnerabilities_status,
);
?>
</td>
</tr>
<tr id="row_vulnerabilities_packages" class="datos">
<td class="bolder">
<?php
echo __('Package').ui_print_help_tip(__('Select a agent for load his packages.'), true);
?>
</td>
<td>
<?php
html_print_select(
[
'all' => __('All'),
],
'vul_package',
$vul_package,
);
?>
</td>
</tr>
<tr id="row_vulnerabilities_severity" class="datos">
<td class="bolder">
<?php
echo __('Severity');
?>
</td>
<td>
<?php
html_print_select(
[
'all' => __('All'),
'high' => __('High'),
'low' => __('Low'),
'none' => __('None'),
],
'vul_severity',
$vul_severity,
);
?>
</td>
</tr>
<tr id="row_vulnerabilities_ac" class="datos">
<td class="bolder">
<?php
echo __('Attack Complexity');
?>
</td>
<td>
<?php
html_print_select(
[
'all' => __('All'),
'H' => __('High'),
'L' => __('Low'),
],
'vul_ac',
$vul_ac,
);
?>
</td>
</tr>
<tr id="row_vulnerabilities_pr" class="datos">
<td class="bolder">
<?php
echo __('Privileges Required');
?>
</td>
<td>
<?php
html_print_select(
[
'all' => __('All'),
'H' => __('High'),
'L' => __('Low'),
'N' => __('None'),
],
'vul_pr',
$vul_pr,
);
?>
</td>
</tr>
<tr id="row_vulnerabilities_ui" class="datos">
<td class="bolder">
<?php
echo __('User Interaction');
?>
</td>
<td>
<?php
html_print_select(
[
'all' => __('All'),
'R' => __('Required'),
'N' => __('None'),
],
'vul_ui',
$vul_ui,
);
?>
</td>
</tr>
<tr id="row_vulnerabilities_av" class="datos">
<td class="bolder">
<?php
echo __('Attack vector');
?>
</td>
<td>
<?php
html_print_select(
[
'all' => __('All'),
'A' => __('Adjacent Network'),
'L' => __('Local'),
'N' => __('Network'),
'P' => __('Physical'),
],
'vul_av',
(empty($vul_av) === true) ? 'all' : $vul_av,
'',
'',
0,
false,
false,
false
);
?>
</td>
</tr>
<?php endif; ?>
<tr id="row_status_check" class="datos">
@ -5607,8 +6005,13 @@ $(document).ready (function () {
switch (type){
case 'agent_module':
case 'agent_module_status':
case 'service_level':
case 'alert_report_actions':
var agents_multiple = $('#id_agents2').val();
if (agents_multiple.length == 0) {
dialog_message('#message_no_agent');
return false;
}
var modules_multiple = $('#module').val();
$('#hidden-id_agents2-multiple-text').val(JSON.stringify(agents_multiple));
$('#hidden-module-multiple-text').val(JSON.stringify(modules_multiple));
@ -5634,6 +6037,7 @@ $(document).ready (function () {
case 'agent_configuration':
case 'module_histogram_graph':
case 'increment':
case 'service_level':
if ($("#hidden-id_agent").val() == 0) {
dialog_message('#message_no_agent');
return false;
@ -5692,6 +6096,27 @@ $(document).ready (function () {
return false;
}
break;
case 'vuls_info_agent':
if ($("#hidden-id_agent").val() == 0) {
dialog_message('#message_no_agent');
return false;
}
break;
case 'top_n_agents_vuls':
if ($("#text-max_items").val() == '') {
dialog_message('#message_no_max_item');
return false;
}
break;
case 'top_n_vuls_count':
if ($("#text-max_items").val() == '') {
dialog_message('#message_no_max_item');
return false;
}
break;
default:
break;
}
@ -5773,8 +6198,13 @@ $(document).ready (function () {
switch (type){
case 'agent_module':
case 'agent_module_status':
case 'service_level':
case 'alert_report_actions':
var agents_multiple = $('#id_agents2').val();
if (agents_multiple.length == 0) {
dialog_message('#message_no_agent');
return false;
}
var modules_multiple = $('#module').val();
$('#hidden-id_agents2-multiple-text').val(JSON.stringify(agents_multiple));
$('#hidden-module-multiple-text').val(JSON.stringify(modules_multiple));
@ -5800,6 +6230,7 @@ $(document).ready (function () {
case 'agent_configuration':
case 'module_histogram_graph':
case 'increment':
case 'service_level':
if ($("#hidden-id_agent").val() == 0) {
dialog_message('#message_no_agent');
return false;
@ -5846,7 +6277,24 @@ $(document).ready (function () {
return false;
}
break;
case 'vuls_info_agent':
if ($("#hidden-id_agent").val() == 0) {
dialog_message('#message_no_agent');
return false;
}
break;
case 'top_n_agents_vuls':
if ($("#text-max_items").val() == '') {
dialog_message('#message_no_max_item');
return false;
}
break;
case 'top_n_vuls_count':
if ($("#text-max_items").val() == '') {
dialog_message('#message_no_max_item');
return false;
}
break;
default:
break;
}
@ -6737,7 +7185,7 @@ function loadLogAgents() {
params["get_agent_source"] = 1;
params["log_alert"] = 1;
params["page"] = "enterprise/include/ajax/log_viewer.ajax";
params["date"] = $('#period_select').val();
params["date"] = $('#period3_select').val();
jQuery.ajax({
data: params,
dataType: "json",
@ -6778,6 +7226,9 @@ function chooseType() {
$("#row_agent").hide();
$("#row_module").hide();
$("#row_search").hide();
$("#row_period").hide();
$("#row_period_service_level").hide();
$("#row_show_agents").hide();
$("#row_log_number").hide();
$("#row_period1").hide();
$("#row_period2").hide();
@ -6903,6 +7354,15 @@ function chooseType() {
$("#row_cat_security_hardening").hide();
$("#row_ignore_skipped").hide();
$("#row_status_check").hide();
$("#row_secmon_status").hide();
$("#row_security_hardening_score").hide();
$("#row_vulnerabilities_status").hide();
$("#row_vulnerabilities_packages").hide();
$("#row_vulnerabilities_severity").hide();
$("#row_vulnerabilities_ac").hide();
$("#row_vulnerabilities_pr").hide();
$("#row_vulnerabilities_ui").hide();
$("#row_vulnerabilities_av").hide();
// SLA list default state.
$("#sla_list").hide();
@ -6916,6 +7376,10 @@ function chooseType() {
$('#agent_autocomplete_events').show();
// NCM fields.
$("#row_ncm_group").hide();
$("#row_ncm_agent").hide();
switch (type) {
case 'event_report_group':
$("#row_description").show();
@ -7465,6 +7929,22 @@ function chooseType() {
}
$("#row_historical_db_check").hide();
break;
case 'service_level':
$("#row_period_service_level").show();
$("#row_show_agents").show();
$("#row_description").show();
$("#row_group").show();
$("#select_agent_modules").show();
$("#agents_modules_row").show();
$("#modules_row").show();
$("#row_historical_db_check").hide();
loadGeneralAgents();
$("#combo_group").change(function() {
loadGeneralAgents($(this).val());
});
$("#row_module_group").show();
break;
case 'agent_module':
$("#row_module_group").show();
@ -7763,7 +8243,13 @@ function chooseType() {
break;
case 'ncm':
$("#row_agent").show();
$("#row_ncm_group").show();
$("#row_ncm_agent").show();
break;
case 'ncm_backups':
$("#row_ncm_group").show();
$("#row_ncm_agent").show();
break;
case 'top_n_agents_sh':
@ -7803,6 +8289,50 @@ function chooseType() {
$("#row_group").show();
$('#row_period').show();
break;
case 'vuls_severity_graph':
$("#row_group").show();
break;
case 'vuls_attack_complexity':
$("#row_group").show();
break;
case 'vuls_by_packages':
$("#row_group").show();
break;
case 'vuls_by_agent':
$("#row_group").show();
$("#row_custom_field_filter").show();
$("#row_secmon_status").show();
$("#row_security_hardening_score").show();
$("#row_vulnerabilities_status").show();
break;
case 'vuls_info_agent':
$("#row_agent").show();
$("#row_vulnerabilities_packages").show();
$("#row_vulnerabilities_severity").show();
$("#row_vulnerabilities_ac").show();
$("#row_vulnerabilities_pr").show();
$("#row_vulnerabilities_ui").show();
$("#row_vulnerabilities_av").show();
updatePackages();
$('#row_agent input[type=text]').change(function(e) {
updatePackages();
});
break;
case 'top_n_agents_vuls':
$("#row_group").show();
$("#row_max_items").show();
break;
case 'top_n_vuls_count':
$("#row_group").show();
$("#row_max_items").show();
break;
}
switch (type) {
@ -8045,6 +8575,46 @@ function control_period_range() {
}, 800);
}
}
function updateSelect(element, fields, selected) {
if (typeof fields === "object") {
$(element).find("select").empty();
$(element).find(".select2-container .select2-selection__rendered").empty();
Object.keys(fields).forEach(function(key) {
if (key === selected) {
$(element).find(".select2-container .select2-selection__rendered").append(`${fields[key]}`);
$(element).find("select").append(`<option value="${key}" selected>${fields[key]}</option>`);
} else {
$(element).find("select").append(`<option value="${key}">${fields[key]}</option>`);
}
});
}
}
function updatePackages() {
let id_agent = $('#hidden-id_agent').val();
let server_id = $('#hidden-server_id').val();
$.ajax({
method: "POST",
url: "<?php echo ui_get_full_url('ajax.php'); ?>",
data: {
page: "<?php echo ENTERPRISE_DIR.'/include/ajax/vulnerabilities.ajax'; ?>",
action: "updatePackages",
id_agent: id_agent,
server_id: server_id,
},
success: function(data) {
const json = JSON.parse(data);
if (json.success) {
updateSelect("#row_vulnerabilities_packages", json.data, '<?php echo $vul_package; ?>');
}
}
});
}
$(document).ready(function () {
$('[id^=period], #combo_graph_options, #combo_sla_sort_options').next().css('z-index', 0);
@ -8062,4 +8632,43 @@ $(document).ready(function () {
});
});
// Ncm agent filter by group.
function filterNcmAgentChange() {
var idGroup = $("#ncm_group").val();
const url_ajax = $("#url_ajax").val();
$.ajax({
url: url_ajax,
type: "POST",
dataType: "json",
async: false,
data: {
page: "operation/agentes/ver_agente",
get_ncm_agents: 1,
id_group: idGroup,
privilege: "AW",
keys_prefix: "_"
},
success: function(data) {
$("#agent_ncm").empty();
var optionAny = $("<option></option>")
.attr("value",0)
.html("Any");
// Add any option.
$("#agent_ncm").append(optionAny);
data.map(item => {
var option = $("<option></option>")
.attr("value", item.id_agent)
.html(item.alias);
// Add agents options.
$("#agent_ncm").append(option);
});
},
error: function(err) {
console.error(err);
}
});
}
</script>

View File

@ -1643,7 +1643,7 @@ switch ($action) {
$es['log_number'] = $log_number;
$values['external_source'] = json_encode($es);
$values['period'] = get_parameter('period');
$values['period'] = get_parameter('period3');
$good_format = true;
break;
@ -1661,7 +1661,7 @@ switch ($action) {
$es['log_number'] = $log_number;
$values['external_source'] = json_encode($es);
$values['period'] = get_parameter('period');
$values['period'] = get_parameter('period3');
$values['period_range'] = get_parameter('period_range');
$values['show_graph'] = get_parameter('combo_graph_options');
$values['group_by_agent'] = get_parameter('checkbox_row_group_by_agent');
@ -1730,10 +1730,20 @@ switch ($action) {
$good_format = true;
break;
case 'service_level':
$es['period_time_service_level'] = get_parameter('period_time_service_level', '28800');
$es['show_agents'] = get_parameter('show_agents', false);
case 'agent_module':
case 'agent_module_status':
$agents_to_report_text = get_parameter('id_agents2-multiple-text', '');
if ($agents_to_report_text === '' || $agents_to_report_text === 'null') {
$agents_to_report_text = io_safe_input(json_encode(get_parameter('id_agents2', '')));
}
$modules_to_report_text = get_parameter('module-multiple-text', '');
if ($modules_to_report_text === '' || $modules_to_report_text === 'null') {
$modules_to_report_text = io_safe_input(json_encode(get_parameter('module', '')));
}
// Decode json check modules.
$agents_to_report = json_decode(
@ -1745,11 +1755,16 @@ switch ($action) {
true
);
$es['module'] = get_same_modules_all(
$agents_to_report,
$modules_to_report
);
if ((bool) is_metaconsole() === true) {
$es['module'] = $modules_to_report;
}
// Encode json modules and agents.
$es['module'] = base64_encode(json_encode($es['module']));
$es['id_agents'] = base64_encode(json_encode($agents_to_report));
@ -2046,6 +2061,70 @@ switch ($action) {
$good_format = true;
break;
case 'ncm_backups':
$agents_ncm = get_parameter('agent_ncm');
$values['ncm_agents'] = json_encode($agents_ncm);
$values['id_group'] = get_parameter('ncm_group');
$good_format = true;
break;
case 'ncm':
$agents_ncm = get_parameter('agent_ncm');
$values['ncm_agents'] = json_encode($agents_ncm);
$values['id_group'] = get_parameter('ncm_group');
$good_format = true;
break;
case 'vuls_severity_graph':
$values['id_group'] = get_parameter('combo_group');
$good_format = true;
break;
case 'vuls_attack_complexity':
$values['id_group'] = get_parameter('combo_group');
$good_format = true;
break;
case 'vuls_by_packages':
$values['id_group'] = get_parameter('combo_group');
$good_format = true;
break;
case 'vuls_by_agent':
$values['id_group'] = get_parameter('combo_group');
$es['agent_custom_field_filter'] = get_parameter('agent_custom_field_filter');
$es['secmon_status'] = get_parameter('secmon_status');
$es['security_hardening_score'] = get_parameter('security_hardening_score');
$es['vulnerabilities_status'] = get_parameter('vulnerabilities_status');
$values['external_source'] = json_encode($es);
$good_format = true;
break;
case 'vuls_info_agent':
$values['id_agent'] = get_parameter('id_agent');
$es['server_id'] = get_parameter('server_id');
$es['vul_package'] = get_parameter('vul_package');
$es['vul_severity'] = get_parameter('vul_severity');
$es['vul_ac'] = get_parameter('vul_ac');
$es['vul_pr'] = get_parameter('vul_pr');
$es['vul_ui'] = get_parameter('vul_ui');
$es['vul_av'] = get_parameter('vul_av');
$values['external_source'] = json_encode($es);
$good_format = true;
break;
case 'top_n_agents_vuls':
$values['id_group'] = get_parameter('combo_group');
$values['top_n_value'] = get_parameter('max_items');
$good_format = true;
break;
case 'top_n_vuls_count':
$values['id_group'] = get_parameter('combo_group');
$values['top_n_value'] = get_parameter('max_items');
$good_format = true;
break;
default:
$values['period'] = get_parameter('period');
$values['top_n'] = get_parameter(
@ -2066,7 +2145,10 @@ switch ($action) {
break;
}
$values['id_agent'] = get_parameter('id_agent');
if (isset($values['id_agent']) === false) {
$values['id_agent'] = get_parameter('id_agent');
}
$values['id_gs'] = get_parameter('id_custom_graph');
$values['id_agent_module'] = '';
@ -2182,7 +2264,10 @@ switch ($action) {
$values['id_module_group'] = get_parameter(
'combo_modulegroup'
);
$values['id_group'] = get_parameter('combo_group');
if (isset($values['id_group']) === false) {
$values['id_group'] = get_parameter('combo_group');
}
if ($values['server_name'] == '') {
$values['server_name'] = get_parameter(
@ -2705,7 +2790,7 @@ switch ($action) {
$es['log_number'] = $log_number;
$values['external_source'] = json_encode($es);
$values['period'] = get_parameter('period');
$values['period'] = get_parameter('period3');
$good_format = true;
break;
@ -2723,17 +2808,27 @@ switch ($action) {
$es['log_number'] = $log_number;
$values['external_source'] = json_encode($es);
$values['period'] = get_parameter('period');
$values['period'] = get_parameter('period3');
$values['period_range'] = get_parameter('period_range');
$values['show_graph'] = get_parameter('combo_graph_options');
$values['group_by_agent'] = get_parameter('checkbox_row_group_by_agent');
$good_format = true;
break;
case 'service_level':
$es['period_time_service_level'] = get_parameter('period_time_service_level', '28800');
$es['show_agents'] = get_parameter('show_agents', false);
case 'agent_module':
case 'agent_module_status':
$agents_to_report_text = get_parameter('id_agents2-multiple-text');
$agents_to_report_text = get_parameter('id_agents2-multiple-text', '');
if ($agents_to_report_text === '' || $agents_to_report_text === 'null') {
$agents_to_report_text = io_safe_input(json_encode(get_parameter('id_agents2', '')));
}
$modules_to_report_text = get_parameter('module-multiple-text', '');
if ($modules_to_report_text === '' || $modules_to_report_text === 'null') {
$modules_to_report_text = io_safe_input(json_encode(get_parameter('module', '')));
}
// Decode json check modules.
$agents_to_report = json_decode(
@ -2750,11 +2845,14 @@ switch ($action) {
$modules_to_report
);
if ((bool) is_metaconsole() === true) {
$es['module'] = $modules_to_report;
}
// Encode json modules and agents.
$es['module'] = base64_encode(json_encode($es['module']));
$es['id_agents'] = base64_encode(json_encode($agents_to_report));
$es['show_type'] = get_parameter('show_type', 0);
$values['external_source'] = json_encode($es);
$good_format = true;
break;
@ -2979,6 +3077,71 @@ switch ($action) {
$good_format = true;
break;
case 'ncm_backups':
$agents_ncm = get_parameter('agent_ncm');
$values['ncm_agents'] = json_encode($agents_ncm);
$values['id_group'] = get_parameter('ncm_group');
$good_format = true;
break;
case 'ncm':
$agents_ncm = get_parameter('agent_ncm');
$values['ncm_agents'] = json_encode($agents_ncm);
$values['id_agent'] = get_parameter('agent_ncm');
$values['id_group'] = get_parameter('ncm_group');
$good_format = true;
break;
case 'vuls_severity_graph':
$values['id_group'] = get_parameter('combo_group');
$good_format = true;
break;
case 'vuls_attack_complexity':
$values['id_group'] = get_parameter('combo_group');
$good_format = true;
break;
case 'vuls_by_packages':
$values['id_group'] = get_parameter('combo_group');
$good_format = true;
break;
case 'vuls_by_agent':
$values['id_group'] = get_parameter('combo_group');
$es['agent_custom_field_filter'] = get_parameter('agent_custom_field_filter');
$es['secmon_status'] = get_parameter('secmon_status');
$es['security_hardening_score'] = get_parameter('security_hardening_score');
$es['vulnerabilities_status'] = get_parameter('vulnerabilities_status');
$values['external_source'] = json_encode($es);
$good_format = true;
break;
case 'vuls_info_agent':
$values['id_agent'] = get_parameter('id_agent');
$es['server_id'] = get_parameter('server_id');
$es['vul_package'] = get_parameter('vul_package');
$es['vul_severity'] = get_parameter('vul_severity');
$es['vul_ac'] = get_parameter('vul_ac');
$es['vul_pr'] = get_parameter('vul_pr');
$es['vul_ui'] = get_parameter('vul_ui');
$es['vul_av'] = get_parameter('vul_av');
$values['external_source'] = json_encode($es);
$good_format = true;
break;
case 'top_n_agents_vuls':
$values['id_group'] = get_parameter('combo_group');
$values['top_n_value'] = get_parameter('max_items');
$good_format = true;
break;
case 'top_n_vuls_count':
$values['id_group'] = get_parameter('combo_group');
$values['top_n_value'] = get_parameter('max_items');
$good_format = true;
break;
default:
$values['period'] = get_parameter('period');
$values['top_n'] = get_parameter(
@ -3005,7 +3168,10 @@ switch ($action) {
);
}
$values['id_agent'] = get_parameter('id_agent');
if (isset($values['id_agent']) === false) {
$values['id_agent'] = get_parameter('id_agent');
}
$values['id_gs'] = get_parameter('id_custom_graph');
if (($values['type'] == 'alert_report_agent')
|| ($values['type'] == 'event_report_agent')
@ -3119,7 +3285,9 @@ switch ($action) {
$values['id_module_group'] = get_parameter(
'combo_modulegroup'
);
$values['id_group'] = get_parameter('combo_group');
if (isset($values['id_group']) === false) {
$values['id_group'] = get_parameter('combo_group');
}
if ((($values['type'] == 'custom_graph')

View File

@ -539,6 +539,7 @@ foreach ($layoutDatas as $layoutData) {
$table->data[($i + 1)][5] .= html_print_checkbox('multiple_delete_items', $idLayoutData, false, true);
$table->data[($i + 1)][5] .= '<a href="'.$url_delete.'"onclick="javascript: if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/delete.svg', true, ['class' => 'main_menu_icon invert_filter']).'</a>';
$table->data[($i + 1)][5] .= html_print_input_hidden('updated_'.$idLayoutData, '0', true);
$table->data[($i + 1)][5] .= html_print_input_hidden('rowtype_'.$idLayoutData, $layoutData['type'], true);
// Second row
$table->data[($i + 2)]['icon'] = '';
@ -789,14 +790,6 @@ if ($x > ini_get('max_input_vars')) {
$pure = get_parameter('pure', 0);
if (is_metaconsole() === false) {
echo '<form id="vc_elem_form" method="post" action="index.php?sec=network&sec2=godmode/reporting/visual_console_builder&tab='.$activeTab.'&id_visual_console='.$visualConsole['id'].'">';
html_print_input_hidden('action', 'update');
} else {
echo "<form id='vc_elem_form' method='post' action='index.php?operation=edit_visualmap&sec=screen&sec2=screens/screens&action=visualmap&pure=0&tab=list_elements&id_visual_console=".$idVisualConsole."'>";
html_print_input_hidden('action2', 'update');
}
html_print_table($table);
// Form for multiple delete.
@ -806,15 +799,14 @@ if (is_metaconsole() === false) {
$url_multiple_delete = 'index.php?sec=screen&sec2=screens/screens&action=visualmap&tab='.$activeTab.'&id_visual_console='.$visualConsole['id'];
}
echo '</form>';
$buttons = html_print_submit_button(
__('Update'),
'go',
false,
[
'icon' => 'next',
'form' => 'vc_elem_form',
'icon' => 'next',
'form' => 'vc_elem_form',
'onclick' => 'submit_update_json()',
],
true
);
@ -976,4 +968,76 @@ ui_require_javascript_file('tinymce', 'vendor/tinymce/tinymce/');
return false;
}
function submit_update_json() {
var array_update = [];
$('input[id^=hidden-updated_]').each(function(){
var id = $(this).attr('id').split('_')[1];
var label = $('#hidden-label_'+id).val();
var image = $('#image_'+id).val();
var width = $('#text-width_'+id).val();
var height = $('#text-height_'+id).val();
var pos_x = $('#text-left_'+id).val();
var pos_y = $('#text-top_'+id).val();
var parent = $('#parent_'+id).val();
var agent = $('#hidden-agent_'+id).val();
var module = $('#module_'+id).val();
var period = $('#hidden-period_'+id).val();
var map_linked = $('#map_linked_'+id).val();
var id_server = $('#id_server_id_'+id).val();
var rowtype = $('rowtype_'+id).val();
var custom_graph = $('#custom_graph_'+id).val();
array_update.push({
'id': id,
'label': label,
'image': image,
'width': width,
'height': height,
'pos_x': pos_x,
'pos_y': pos_y,
'parent': parent,
'agent': agent,
'module': module,
'period': period,
'map_linked': map_linked,
'rowtype': rowtype,
'custom_graph': custom_graph,
'id_server': id_server,
});
});
var background_width = $('#text-width').val();
var background_height = $('#text-height').val();
if (background_height > 0 && background_width > 0){
$.ajax({
type: "POST",
url: "ajax.php",
data: {
page: "godmode/reporting/visual_console_builder",
action: "update_json",
tab: "list_elements",
array_update: JSON.stringify(array_update),
id_visual_console: "<?php echo (is_metaconsole() === true) ? $idVisualConsole : $visualConsole['id']; ?>",
background: $('#background').val(),
background_width: $('#text-width').val(),
background_height: $('#text-height').val(),
},
dataType: "json",
complete: function (data) {
location.reload();
}
});
} else {
confirmDialog({
title: "<?php echo __('Error.'); ?>",
message: "<?php echo __('The width and height property is required and should greater than 0'); ?>",
strOKButton: "<?php echo __('Close'); ?>",
hideCancelButton: true,
size: 300,
});
}
}
</script>

View File

@ -78,6 +78,7 @@ $action = get_parameterBetweenListValues(
'update',
'delete',
'multiple_delete',
'update_json',
],
'new'
);
@ -163,7 +164,10 @@ switch ($activeTab) {
$background_color = (string) get_parameter('background_color');
$width = (int) get_parameter('width');
$height = (int) get_parameter('height');
$visualConsoleName = (string) io_safe_input(get_parameter('name'));
$visualConsoleName = (string) get_parameter('name');
$visualConsoleName = str_replace('&lt;', '', $visualConsoleName);
$visualConsoleName = str_replace('&gt;', '', $visualConsoleName);
$visualConsoleName = (string) io_safe_input($visualConsoleName);
$is_favourite = (int) get_parameter('is_favourite_sent');
$auto_adjust = (int) get_parameter('auto_adjust_sent');
@ -523,6 +527,110 @@ switch ($activeTab) {
}
break;
case 'update_json':
// Update background.
$background = get_parameter('background');
$width = get_parameter('background_width');
$height = get_parameter('background_height');
if ($width == 0 && $height == 0) {
$sizeBackground = getimagesize(
$config['homedir'].'/images/console/background/'.$background
);
$width = $sizeBackground[0];
$height = $sizeBackground[1];
}
db_process_sql_update(
'tlayout',
[
'background' => $background,
'width' => $width,
'height' => $height,
],
['id' => $idVisualConsole]
);
// Return the updated visual console.
$visualConsole = db_get_row_filter(
'tlayout',
['id' => $idVisualConsole]
);
// Update elements in visual map.
$idsElements = db_get_all_rows_filter(
'tlayout_data',
['id_layout' => $idVisualConsole],
[
'id',
'type',
]
);
$array_update = json_decode(io_safe_output(get_parameter('array_update')), true);
if (count($array_update)) {
foreach ($array_update as $row) {
$id = $row['id'];
$values = [];
$values['label'] = $row['label'];
$values['image'] = $row['image'];
$values['width'] = $row['width'];
$values['height'] = $row['height'];
$values['pos_x'] = $row['pos_x'];
$values['pos_y'] = $row['pos_y'];
switch ($row['rowtype']) {
case NETWORK_LINK:
case LINE_ITEM:
continue 2;
break;
case SIMPLE_VALUE_MAX:
case SIMPLE_VALUE_MIN:
case SIMPLE_VALUE_AVG:
$values['period'] = $row['period'];
break;
case MODULE_GRAPH:
$values['period'] = $row['period'];
unset($values['image']);
break;
case GROUP_ITEM:
$values['id_group'] = $row['group'];
break;
case CIRCULAR_PROGRESS_BAR:
case CIRCULAR_INTERIOR_PROGRESS_BAR:
case PERCENTILE_BUBBLE:
case PERCENTILE_BAR:
unset($values['height']);
break;
}
if (defined('METACONSOLE')) {
$values['id_metaconsole'] = $row['id_server'];
}
$values['id_agent'] = $row['agent'];
$values['id_agente_modulo'] = $row['module'];
$values['id_custom_graph'] = $row['custom_graph'];
$values['parent_item'] = $row['parent'];
$values['id_layout_linked'] = $row['map_linked'];
if (enterprise_installed()) {
enterprise_visual_map_update_action_from_list_elements($row['rowtype'], $values, $id);
}
db_process_sql_update('tlayout_data', $values, ['id' => $id]);
}
return true;
}
break;
case 'delete':
$id_element = get_parameter('id_element');
$result = db_process_sql_delete('tlayout_data', ['id' => $id_element]);

View File

@ -860,8 +860,10 @@ if (empty($create) === false || empty($view) === false) {
if ($management_allowed === false) {
ui_print_warning_message(
__(
'This console is not manager of this environment,
please manage this feature from centralized manager console (Metaconsole).'
'This console is not manager of this environment, please manage this feature from feature from %s.',
'<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=godmode/servers/plugin_registration&tab=plugin_registration&pure=0'
).'">'.__('metaconsole').'</a>'
)
);
}

View File

@ -179,7 +179,7 @@ foreach ($servers as $server) {
}
$data[7] = '';
if ($server['queued_modules'] > 500) {
if ($server['queued_modules'] >= $config['number_modules_queue']) {
$data[7] .= '<div class="inline"><a onclick="show_dialog();" >'.html_print_image(
'images/info-warning.svg',
true,
@ -276,7 +276,7 @@ foreach ($servers as $server) {
$data[9] .= '</a>';
if (($names_servers[$safe_server_name] === true) && ($ext === '_server' || $server['type'] === 'enterprise satellite')) {
$data[9] .= '<a href="'.ui_get_full_url('index.php?sec=gservers&sec2=godmode/servers/modificar_server&server_remote='.$server['id_server'].'&ext='.$ext.'&tab=agent_editor').'">';
$data[9] .= '<a href="'.ui_get_full_url('index.php?sec=gservers&sec2=godmode/servers/modificar_server&server_remote='.$server['id_server'].'&ext='.$ext.'&tab=advanced_editor').'">';
$data[9] .= html_print_image(
'images/agents@svg.svg',
true,

View File

@ -54,8 +54,12 @@ if (isset($_POST['create'])) {
if (! $result) {
ui_print_error_message(__('There was a problem creating link'));
} else {
ui_print_success_message(__('Successfully created'));
$id_link = $result;
ui_print_result_message(
$id_link,
__('Successfully created'),
__('Could not be created')
);
}
}
@ -111,8 +115,8 @@ if ((isset($_GET['form_add'])) or (isset($_GET['form_edit']))) {
$link = '';
}
echo '<table class="databox filters filter-table-adv max_floating_element_size" cellpadding="4" cellspacing="4" width="100%">';
echo '<form name="ilink" method="post" action="index.php?sec=gsetup&sec2=godmode/setup/links">';
echo '<table class="databox filters filter-table-adv max_floating_element_size" cellpadding="4" cellspacing="4" width="100%">';
if ($creation_mode == 1) {
echo "<input type='hidden' name='create' value='1'>";
} else {
@ -179,10 +183,10 @@ if ((isset($_GET['form_add'])) or (isset($_GET['form_edit']))) {
)
);
echo '</form></td></tr></table>';
echo '</td></tr></table></form>';
} else {
// Main list view for Links editor
$rows = db_get_all_rows_in_table('tlink', 'name');
// Main list view for Links editor.
$rows = db_get_all_fields_in_table('tlink', '', '', 'name');
if ($rows === false) {
$rows = [];
}

View File

@ -184,7 +184,7 @@ $buttons['ITSM'] = [
$buttons['ehorus'] = [
'active' => false,
'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup&section=ehorus').'">'.html_print_image(
'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup&section=pandorarc').'">'.html_print_image(
'images/RC.png',
true,
[
@ -297,7 +297,7 @@ switch ($section) {
$help_header = 'setup_flow_tab';
break;
case 'ehorus':
case 'pandorarc':
$buttons['ehorus']['active'] = true;
$subpage = __('Pandora RC');
$help_header = 'setup_ehorus_tab';
@ -442,7 +442,7 @@ switch ($section) {
include_once $config['homedir'].'/godmode/setup/setup_visuals.php';
break;
case 'ehorus':
case 'pandorarc':
include_once $config['homedir'].'/godmode/setup/setup_ehorus.php';
break;

View File

@ -187,7 +187,8 @@ $button_test .= '&nbsp;<span id="ITSM-message" class="invisible"></span>';
$row['control'] = html_print_label_input_block(
__('Test connection pandora to ITSM'),
$button_test
$button_test,
['div_class' => 'ITSM-remote-setup-ITSM_token']
);
$table_remote->data['ITSM_test'] = $row;

View File

@ -405,19 +405,6 @@ $table->data[$i++][] = html_print_label_input_block(
$table->data[$i][] = html_print_label_input_block(
__('Enable Sflow'),
html_print_checkbox_switch_extended(
'activate_sflow',
1,
$config['activate_sflow'],
$rbt_disabled,
'',
'',
true
),
);
$table->data[$i++][] = html_print_label_input_block(
__('General network path'),
html_print_input_text(
'general_network_path',
@ -733,7 +720,7 @@ $table->data[$i++][] = html_print_label_input_block(
);
$help_tip = ui_print_help_tip(
__('If there are any &#x22;In process&#x22; events with a specific Extra ID and a New event with that Extra ID is received, it will be created as &#x22;In process&#x22; instead.'),
__('If there are any &#x22;In process&#x22; events with a specific Extra ID and a New event with that Extra ID is received, it will be created as &#x22;In process&#x22; instead. The new events also inherit Event Custom ID'),
true
);
@ -766,6 +753,16 @@ $table->data[$i][] = html_print_label_input_block(
true
)
);
$table->data[$i++][] = html_print_label_input_block(
__('Number of modules in queue'),
html_print_input_number(
[
'name' => 'number_modules_queue',
'min' => 0,
'value' => $config['number_modules_queue'],
]
)
);
echo '<form class="max_floating_element_size" id="form_setup" method="post" action="index.php?sec=gsetup&sec2=godmode/setup/setup&amp;section=general&amp;pure='.$config['pure'].'">';
@ -899,6 +896,35 @@ echo '<legend>'.__('Mail configuration').'</legend>';
echo '</fieldset>';
echo '<fieldset class="margin-bottom-10">';
echo '<legend>'.__('NCM Configuration').'</legend>';
$table_ncm_config = new stdClass();
$table_ncm_config->width = '100%';
$table_ncm_config->class = 'databox filter-table-adv';
$table_ncm_config->size = [];
$table_ncm_config->size[0] = '50%';
$table_ncm_config->data = [];
$table_ncm_config->data[0][] = html_print_label_input_block(
__('FTP server IP').ui_print_help_tip(__('This value will be used by TFTP_SERVER_IP macro in NCM scripts.'), true),
html_print_input_text(
'tftp_server_ip',
$config['tftp_server_ip'],
'',
false,
255,
true,
false,
false,
'',
'w50p'
)
);
html_print_table($table_ncm_config);
echo '</fieldset>';
html_print_action_buttons(
html_print_submit_button(
@ -1116,9 +1142,9 @@ $(document).ready (function () {
id_imodule = $(value).attr('value');
$("select[name='inventory_changes_blacklist[]']")
.append(
$("<option></option>")
$("<option selected='selected'></option>")
.val(id_imodule)
.html('<i>' + imodule_name + '</i>')
.text(imodule_name)
);
$("#inventory_changes_blacklist_out")
.find("option[value='" + id_imodule + "']").remove();
@ -1144,7 +1170,7 @@ $(document).ready (function () {
.append(
$("<option></option>")
.val(id_imodule)
.html('<i>' + imodule_name + '</i>')
.text(imodule_name)
);
$("#inventory_changes_blacklist")
.find("option[value='" + id_imodule + "']").remove();
@ -1160,12 +1186,15 @@ $(document).ready (function () {
}
}
});
$("#inventory_changes_blacklist > option").each(function(key, value) {
$(value).prop('selected',true).trigger('change');
});
});
$("#submit-update_button").click(function () {
$('#inventory_changes_blacklist option').map(function(){
$(this).prop('selected', true);
});
$("#inventory_changes_blacklist > option").each(function(key, value) {
$(value).prop('selected',true).trigger('change');
});
});
</script>

View File

@ -83,6 +83,19 @@ $table->data[3][] = html_print_label_input_block(
html_print_checkbox_switch_extended('netflow_get_ip_hostname', 1, $config['netflow_get_ip_hostname'], false, $onclick, '', true)
);
$table->data[4][] = html_print_label_input_block(
__('Enable Sflow'),
html_print_checkbox_switch_extended(
'activate_sflow',
1,
$config['activate_sflow'],
$rbt_disabled,
'',
'',
true
),
);
echo '<form class="max_floating_element_size" id="netflow_setup" method="post">';
html_print_table($table);
html_print_input_hidden('update_config', 1);

View File

@ -61,7 +61,7 @@ $license = db_get_value(
);
if (isset($config['lts_updates']) === false) {
$config['lts_updates'] = false;
$config['lts_updates'] = true;
}
if (empty($license) === true) {

View File

@ -0,0 +1,111 @@
<?php
/**
* Modal LTS versions update manager.
*
* @category Update Manager
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2023 Pandora FMS
* Please see https://pandorafms.com/community/ for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
global $config;
check_login();
// The ajax is in include/ajax/update_manager.php.
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;
}
require_once $config['homedir'].'/vendor/autoload.php';
$php_version = phpversion();
$php_version_array = explode('.', $php_version);
if ($php_version_array[0] < 7) {
include_once 'general/php_message.php';
}
?>
<!-- Lts Updates. -->
<div id="lts-updates" title="
<?php echo __('LTS versions'); ?>
" class="invisible">
<div style="display: flex; justify-content: space-between">
<div style="width: 250px; padding: 36px">
<?php
echo html_print_image(
'images/info-warning.svg',
true,
[ 'style' => 'padding-top: 30px' ]
);
?>
</div>
<div style="padding: 5px 90px 5px 5px;">
<p class="lato font_10pt bolder">
<?php
echo __('There are two types of versions in Pandora FMS: the LTS versions (Long-Term Support), e.g: 772 LTS, and the RRR (Regular Rolling Release) versions, e.g: 771, 773, 774, 775.');
?>
</p>
<p class="lato font_10pt bolder">
<?php
echo __('LTS versions have frequent, periodic updates (fixes), correcting both security problems and critical bugs detected in the tool. These are the versions we recommend to use in production environments.');
?>
</p>
<p class="lato font_10pt bolder">
<?php
echo __('RRR versions incorporate new features in each version, as well as bug fixes, but due to their dynamic nature, errors are more likely.');
?>
</p>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
// Lts Updates.
$("#lts-updates").dialog({
resizable: true,
draggable: true,
modal: true,
width: 740,
overlay: {
opacity: 0.5,
background: "black"
},
closeOnEscape: true,
buttons: [{
text: "OK",
click: function() {
$(this).dialog("close");
}
}],
open: function(event, ui) {
$(".ui-dialog-titlebar-close").hide();
}
});
});
</script>

View File

@ -119,11 +119,13 @@ switch ($tab) {
case 'setup':
include $config['homedir'].'/godmode/update_manager/update_manager.setup.php';
include $config['homedir'].'/godmode/update_manager/modal_lts_update.php';
break;
case 'offline':
$mode = \UpdateManager\UI\Manager::MODE_OFFLINE;
include $config['homedir'].'/godmode/um_client/index.php';
include $config['homedir'].'/godmode/update_manager/modal_lts_update.php';
break;
case 'online':
@ -163,5 +165,6 @@ switch ($tab) {
$mode = \UpdateManager\UI\Manager::MODE_ONLINE;
include $config['homedir'].'/godmode/um_client/index.php';
include $config['homedir'].'/godmode/update_manager/modal_lts_update.php';
break;
}

View File

@ -63,6 +63,10 @@ if (users_is_admin()) {
}
}
if (isset($config['lts_updates']) === false) {
config_update_value('lts_updates', 1);
}
if (!$action_update_url_update_manager) {
$url_update_manager = get_parameter(
'url_update_manager',

View File

@ -424,8 +424,10 @@ if ($create_user === true) {
$values['data_section'] = $dashboard;
} else if (io_safe_output($values['section']) === HOME_SCREEN_VISUAL_CONSOLE) {
$values['data_section'] = $visual_console;
} else if ($values['section'] === HOME_SCREEN_OTHER || io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) {
$values['data_section'] = get_parameter('data_section');
} else if ($values['section'] === HOME_SCREEN_OTHER) {
$values['data_section'] = get_parameter('data_section_other');
} else if (io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) {
$values['data_section'] = get_parameter('data_section_external');
}
// $values['section'] = $homeScreenValues[$values['section']];
@ -672,8 +674,11 @@ if ($update_user) {
$values['email'] = (string) get_parameter('email');
$values['phone'] = (string) get_parameter('phone');
$values['comments'] = io_safe_input(strip_tags(io_safe_output((string) get_parameter('comments'))));
$values['allowed_ip_active'] = ((int) get_parameter('allowed_ip_active', -1) === 0);
$values['allowed_ip_list'] = io_safe_input(strip_tags(io_safe_output((string) get_parameter('allowed_ip_list'))));
if (users_is_admin($config['id_user']) === true || (bool) check_acl($config['id_user'], 0, 'PM') === true) {
$values['allowed_ip_active'] = ((int) get_parameter('allowed_ip_active', -1) === 0);
$values['allowed_ip_list'] = io_safe_input(strip_tags(io_safe_output((string) get_parameter('allowed_ip_list'))));
}
$values['is_admin'] = (get_parameter('is_admin', 0) === 0) ? 0 : 1;
$values['language'] = (string) get_parameter('language');
$values['timezone'] = (string) get_parameter('timezone');
@ -719,8 +724,10 @@ if ($update_user) {
$values['data_section'] = $dashboard;
} else if (io_safe_output($values['section']) === HOME_SCREEN_VISUAL_CONSOLE) {
$values['data_section'] = $visual_console;
} else if ($values['section'] === HOME_SCREEN_OTHER || io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) {
$values['data_section'] = get_parameter('data_section');
} else if ($values['section'] === HOME_SCREEN_OTHER) {
$values['data_section'] = get_parameter('data_section_other');
} else if (io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) {
$values['data_section'] = get_parameter('data_section_external');
}
// $values['section'] = $homeScreenValues[$values['section']];

View File

@ -81,6 +81,11 @@ $customHomeScreenAddition[HOME_SCREEN_DASHBOARD] = html_print_select(
false,
'width: 100%'
);
// Home screen. Visual consoles.
$customHomeScreenAddition[HOME_SCREEN_VISUAL_CONSOLE] = html_print_select($layouts_aux, 'visual_console', $user_info['data_section'], '', '', '', true, false, true, 'w100p', false, 'width: 100%');
// Home screen. External link and Other.
$customHomeScreenAddition[HOME_SCREEN_EXTERNAL_LINK] = html_print_input_text('data_section_external', $user_info['data_section'], '', 60, 255, true);
$customHomeScreenAddition[HOME_SCREEN_OTHER] = html_print_input_text('data_section_other', $user_info['data_section'], '', 60, 255, true);
$layouts = visual_map_get_user_layouts($config['id_user'], true);
$layouts_aux = [];
@ -859,50 +864,56 @@ $userManagementTable->data['fields_addSettings'][0] = html_print_textarea(
''
);
$userManagementTable->data['captions_addSettings'][1] = __('Login allowed IP list');
$userManagementTable->data['fields_addSettings'][1] = html_print_div(
[
'class' => 'edit_user_allowed_ip',
'content' => html_print_textarea(
'allowed_ip_list',
5,
65,
($user_info['allowed_ip_list'] ?? ''),
(((bool) $view_mode === true) ? 'readonly="readonly"' : ''),
true
),
],
true
);
if (users_is_admin($config['id_user']) === true || (bool) check_acl($config['id_user'], 0, 'PM') === true) {
$allowAllIpsContent = [];
$allowAllIpsContent[] = '<span>'.__('Enable IP allowlist').'</span>';
$allowAllIpsContent[] = html_print_div(
[
'content' => html_print_checkbox_switch(
'allowed_ip_active',
0,
($user_info['allowed_ip_active'] ?? 0),
true,
false,
'handleIpAllowlist(this)'
),
],
true
);
$userManagementTable->data['fields_addSettings'][1] .= ui_print_input_placeholder(
__('Add the source IPs that will allow console access. Each IP must be separated only by comma. * allows all.'),
true
);
$userManagementTable->data['captions_addSettings'][1] = html_print_div(
[
'class' => 'margin-top-10',
'style' => 'display: flex; flex-direction: row-reverse; align-items: center;',
'content' => implode('', $allowAllIpsContent),
],
true
);
$allowAllIpsContent = [];
$allowAllIpsContent[] = '<span>'.__('Allow all IPs').'</span>';
$allowAllIpsContent[] = html_print_div(
[
'content' => html_print_checkbox_switch(
'allowed_ip_active',
0,
($user_info['allowed_ip_active'] ?? 0),
true
),
],
true
);
$userManagementTable->data['fields_addSettings'][1] .= html_print_div(
[
'class' => 'margin-top-10',
'style' => 'display: flex; flex-direction: row-reverse; align-items: center;',
'content' => implode('', $allowAllIpsContent),
],
true
);
$userManagementTable->data['fields_addSettings'][1] .= html_print_div(
[
'class' => 'edit_user_allowed_ip '.(((int) $user_info['allowed_ip_active'] === 1) ? '' : 'invisible'),
'content' => html_print_textarea(
'allowed_ip_list',
5,
65,
($user_info['allowed_ip_list'] ?? ''),
(((bool) $view_mode === true) ? 'readonly="readonly"' : ''),
true
),
],
true
);
$userManagementTable->data['fields_addSettings'][1] .= ui_print_input_placeholder(
__('Add the source IPs that will allow console access. Each IP must be separated only by comma. * allows all.'),
true,
[
'id' => 'info_allowed_ip',
'class' => ((int) $user_info['allowed_ip_active'] === 1) ? 'input_sub_placeholder' : 'input_sub_placeholder invisible',
]
);
}
if ($config['ITSM_enabled'] && $config['ITSM_user_level_conf']) {
// Pandora ITSM user remote login.
@ -1040,4 +1051,14 @@ $(document).ready(function () {
}
})
});
function handleIpAllowlist(e){
if(e.checked === true) {
$('.edit_user_allowed_ip').show();
$('#info_allowed_ip').show();
} else {
$('.edit_user_allowed_ip').hide();
$('#info_allowed_ip').hide();
}
}
</script>

View File

@ -1422,6 +1422,14 @@ class DiscoveryTaskList extends HTML
$table->rowid = [];
$table->data = [];
$countErrors = 1;
$tableErrors = new StdClasS();
$tableErrors->class = 'databox data';
$tableErrors->width = '75%';
$tableErrors->styleTable = 'margin: 2em auto 0;border: 1px solid #ddd;background: white;';
$tableErrors->rowid = [];
$tableErrors->data = [];
if ($task['review_mode'] == DISCOVERY_RESULTS) {
$agents_review = db_get_all_rows_filter(
'tdiscovery_tmp_agents',
@ -1476,11 +1484,11 @@ class DiscoveryTaskList extends HTML
$countSummary = 1;
if (is_array($task['stats']) === true && count(array_filter(array_keys($task['stats']), 'is_numeric')) === count($task['stats'])) {
foreach ($task['stats'] as $key => $summary) {
$table->data[$i][0] = '<b>'.__('Summary').' '.$countSummary.'</b>';
$table->data[$i][1] = '';
$countSummary++;
$i++;
if (is_array($summary) === true) {
$table->data[$i][0] = '<b>'.__('Summary').' '.$countSummary.'</b>';
$table->data[$i][1] = '';
$countSummary++;
$i++;
if (empty($summary['summary']) === true && empty($summary['info']) === true) {
$table->data[$i][0] = json_encode($summary, JSON_PRETTY_PRINT);
$table->data[$i][1] = '';
@ -1517,8 +1525,12 @@ class DiscoveryTaskList extends HTML
$i++;
}
} else {
$table->data[$i][0] = $summary;
$table->data[$i][1] = '';
$tableErrors->data[$i][0] = '<b>'.__('Error %s', $countErrors).'</b>';
$tableErrors->data[$i][1] = '';
$i++;
$tableErrors->data[$i][0] = $summary;
$tableErrors->data[$i][1] = '';
$countErrors++;
$i++;
}
}
@ -1560,12 +1572,26 @@ class DiscoveryTaskList extends HTML
$table->data[$i++][1] .= '</span>';
}
} else {
$table->data[$i][0] = $task['stats']['summary'];
$tableErrors->data[$i][0] = '<b>'.__('Error %s', $countErrors).'</b>';
$tableErrors->data[$i][1] = '';
$i++;
$tableErrors->data[$i][0] = $task['stats']['summary'];
$tableErrors->data[$i][1] = '';
$countErrors++;
$i++;
}
}
$output = '<div class="subtitle"><span>'.__('Summary').'</span></div>';
$output .= html_print_table($table, true).'</div>';
if (is_array($table->data) === true && count($table->data) > 0) {
$output .= html_print_table($table, true);
}
if (is_array($tableErrors->data) === true && count($tableErrors->data) > 0) {
$output .= html_print_table($tableErrors, true);
}
$output .= '</div>';
}
return $output;

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Icons/Dark/20/desacoplar-ventana</title>
<g id="Icons/Dark/20/desacoplar-ventana" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Back" transform="translate(3, 1)">
<rect id="Rectangle-2" stroke="#3F3F3F" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" x="0" y="0" width="20" height="16" rx="1"></rect>
<path d="M3,4 C3.55228475,4 4,3.55228475 4,3 C4,2.44771525 3.55228475,2 3,2 C2.44771525,2 2,2.44771525 2,3 C2,3.55228475 2.44771525,4 3,4 Z M6,4 C6.55228475,4 7,3.55228475 7,3 C7,2.44771525 6.55228475,2 6,2 C5.44771525,2 5,2.44771525 5,3 C5,3.55228475 5.44771525,4 6,4 Z M9,4 C9.55228475,4 10,3.55228475 10,3 C10,2.44771525 9.55228475,2 9,2 C8.44771525,2 8,2.44771525 8,3 C8,3.55228475 8.44771525,4 9,4 Z" id="Oval-2" fill="#3F3F3F"></path>
</g>
<g id="Front" transform="translate(0, 8)">
<rect id="Rectangle-2" fill="#3F3F3F" x="0" y="0" width="20" height="16" rx="1"></rect>
<path d="M3,4 C3.55228475,4 4,3.55228475 4,3 C4,2.44771525 3.55228475,2 3,2 C2.44771525,2 2,2.44771525 2,3 C2,3.55228475 2.44771525,4 3,4 Z M6,4 C6.55228475,4 7,3.55228475 7,3 C7,2.44771525 6.55228475,2 6,2 C5.44771525,2 5,2.44771525 5,3 C5,3.55228475 5.44771525,4 6,4 Z M9,4 C9.55228475,4 10,3.55228475 10,3 C10,2.44771525 9.55228475,2 9,2 C8.44771525,2 8,2.44771525 8,3 C8,3.55228475 8.44771525,4 9,4 Z" id="Oval-2" fill="#FFFFFF"></path>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="20px" height="20px" viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>donut</title>
<g id="donut" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<path d="M10,1 C14.9705627,1 19,5.02943725 19,10 C19,14.9705627 14.9705627,19 10,19 C5.02943725,19 1,14.9705627 1,10 C1,5.02943725 5.02943725,1 10,1 Z M10,6 C7.790861,6 6,7.790861 6,10 C6,12.209139 7.790861,14 10,14 C12.209139,14 14,12.209139 14,10 C14,7.790861 12.209139,6 10,6 Z" id="Oval" fill="#484848" fill-rule="nonzero"></path>
</g>
</svg>

After

Width:  |  Height:  |  Size: 649 B

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Icons/Dark/20/minimizar</title>
<g id="Icons/Dark/20/minimizar" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<rect id="Rectangle" fill="#3F3F3F" x="2" y="18" width="20" height="4" rx="2"></rect>
</g>
</svg>

After

Width:  |  Height:  |  Size: 436 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -435,6 +435,7 @@ if ($get_agent_alerts_datatable === true) {
}
$idGroup = $filter_alert['ag_group'];
$search_sg = $filter_alert['search_sg'];
$tag_filter = $filter_alert['tag'];
$action_filter = $filter_alert['action'];
@ -651,31 +652,30 @@ if ($get_agent_alerts_datatable === true) {
if (is_metaconsole() === true) {
include_once $config['homedir'].'/enterprise/meta/include/functions_alerts_meta.php';
if ($idAgent !== 0) {
$alerts['alerts_simple'] = alerts_meta_get_alerts($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter);
$alerts['alerts_simple'] = alerts_meta_get_alerts($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, false, false, $tag_filter, $action_filter);
$countAlertsSimple = alerts_meta_get_alerts($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter);
$countAlertsSimple = alerts_meta_get_alerts($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, false, $tag_filter, $action_filter);
} else {
$id_groups = array_keys(
users_get_groups($config['id_user'], 'AR', false)
);
$alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, false, false, $tag_filter, $action_filter, $search_sg);
$alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter);
$countAlertsSimple = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter);
$countAlertsSimple = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, false, $tag_filter, $action_filter, $search_sg);
}
} else {
if ($idAgent !== 0) {
$alerts['alerts_simple'] = agents_get_alerts_simple($idAgent, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter);
$alerts['alerts_simple'] = agents_get_alerts_simple($idAgent, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, false, $tag_filter);
$countAlertsSimple = agents_get_alerts_simple($idAgent, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter);
$countAlertsSimple = agents_get_alerts_simple($idAgent, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, false, $tag_filter);
} else {
$id_groups = array_keys(
users_get_groups($config['id_user'], $access, false)
);
$alerts['alerts_simple'] = get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter, false);
$alerts['alerts_simple'] = get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, false, $tag_filter, $action_filter, false, $search_sg);
$countAlertsSimple = get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter, false);
$countAlertsSimple = get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, false, $tag_filter, $action_filter, false, $search_sg);
}
}

View File

@ -92,6 +92,7 @@ $get_id_source_event = get_parameter('get_id_source_event');
$node_id = (int) get_parameter('node_id', 0);
$settings_modal = get_parameter('settings', 0);
$parameters_modal = get_parameter('parameters', 0);
$update_event_custom_id = get_parameter('update_event_custom_id', 0);
$draw_events_graph = get_parameter('drawEventsGraph', false);
// User private filter.
@ -313,6 +314,7 @@ if ($save_event_filter) {
$values['severity'] = implode(',', get_parameter('severity', -1));
$values['status'] = get_parameter('status');
$values['search'] = get_parameter('search');
$values['regex'] = get_parameter('regex');
$values['not_search'] = get_parameter('not_search');
$values['text_agent'] = get_parameter('text_agent');
$values['id_agent'] = get_parameter('id_agent');
@ -381,6 +383,7 @@ if ($update_event_filter) {
$values['severity'] = implode(',', get_parameter('severity', -1));
$values['status'] = get_parameter('status');
$values['search'] = get_parameter('search');
$values['regex'] = get_parameter('regex');
$values['not_search'] = get_parameter('not_search');
$values['text_agent'] = get_parameter('text_agent');
$values['id_agent'] = get_parameter('id_agent');
@ -640,6 +643,8 @@ function load_form_filter() {
$("#status").val(val);
if (i == 'search')
$('#text-search').val(val);
if (i == 'regex')
$('#text-regex').val(val);
if (i == 'not_search')
$('#checkbox-not_search').val(val);
if (i == 'text_agent')
@ -970,6 +975,7 @@ function save_new_filter() {
"severity" : $("#severity").val(),
"status" : $("#status").val(),
"search" : $("#text-search").val(),
"regex" : $('#text-regex').val(),
"not_search" : $("#checkbox-not_search").val(),
"text_agent" : $("#text_id_agent").val(),
"id_agent" : $('input:hidden[name=id_agent]').val(),
@ -1050,6 +1056,7 @@ function save_update_filter() {
"severity" : $("#severity").val(),
"status" : $("#status").val(),
"search" : $("#text-search").val(),
"regex" : $('#text-regex').val(),
"not_search" : $("#checkbox-not_search").val(),
"text_agent" : $("#text_id_agent").val(),
"id_agent" : $('input:hidden[name=id_agent]').val(),
@ -2644,6 +2651,8 @@ if ($get_events_fired) {
$filter['date_to'] = date('Y-m-d', $end);
$filter['time_from'] = date('H:i:s', $start);
$filter['time_to'] = date('H:i:s', $end);
$filter['severity'] = explode(',', $filter['severity']);
$data = events_get_all(
['te.*'],
$filter
@ -2754,6 +2763,52 @@ if ($draw_row_response_info === true) {
return;
}
if ($update_event_custom_id) {
$event_custom_id = get_parameter('event_custom_id');
$event_id = get_parameter('event_id');
$server_id = 0;
if (is_metaconsole() === true) {
$server_id = (int) get_parameter('server_id');
}
// Safe custom fields for hacks.
if (preg_match('/script/i', io_safe_output($event_custom_id))) {
$return = false;
} else {
try {
if (is_metaconsole() === true
&& $server_id > 0
) {
$node = new Node($server_id);
$node->connect();
}
$return = events_event_custom_id(
$event_id,
$event_custom_id
);
} catch (\Exception $e) {
// Unexistent agent.
if (is_metaconsole() === true
&& $server_id > 0
) {
$node->disconnect();
}
$return = false;
} finally {
if (is_metaconsole() === true
&& $server_id > 0
) {
$node->disconnect();
}
}
}
echo ($return === true) ? 'update_ok' : 'update_error';
return;
}
if ((bool) $draw_events_graph === true) {
$filter = get_parameter('filter');
$output = event_print_graph($filter);

View File

@ -35,6 +35,7 @@ if (check_login()) {
include_once $config['homedir'].'/include/functions_agents.php';
include_once $config['homedir'].'/include/functions_modules.php';
include_once $config['homedir'].'/include/functions_ui.php';
include_once $config['homedir'].'/include/functions_macros.php';
enterprise_include_once('include/functions_metaconsole.php');
$get_plugin_macros = get_parameter('get_plugin_macros');
@ -755,6 +756,7 @@ if (check_login()) {
$access = ($agent_a === true) ? 'AR' : (($agent_w === true) ? 'AW' : 'AR');
$id_agent = (int) get_parameter('id_agente');
$id_agente = $id_agent;
$id_grupo = agents_get_agent_group($id_agent);
$show_notinit = (bool) get_parameter('show_notinit');
$cluster_list = (int) get_parameter('cluster_list');
$sortField = (string) get_parameter('sort_field');
@ -1206,7 +1208,23 @@ if (check_login()) {
);
if (strlen($module['ip_target']) !== 0) {
$title .= '<br/>IP: '.$module['ip_target'];
// Check if value is custom field.
if ($module['ip_target'][0] == '_' && $module['ip_target'][(strlen($module['ip_target']) - 1)] == '_') {
$custom_field_name = substr($module['ip_target'], 1, -1);
$custom_value = agents_get_agent_custom_field($id_agente, $custom_field_name);
if (isset($custom_value) && $custom_value !== false) {
$title .= '<br/>IP: '.$custom_value;
} else {
$array_macros = return_agent_macros($id_agente);
if (isset($array_macros[$module['ip_target']])) {
$title .= '<br/>IP: '.$array_macros[$module['ip_target']];
} else {
$title .= '<br/>IP: '.$module['ip_target'];
}
}
} else {
$title .= '<br/>IP: '.$module['ip_target'];
}
}
$last_status_change_text = __('Time elapsed since last status change: ');

View File

@ -251,7 +251,7 @@ if ($change_custom_fields_macros_report === true) {
}
if ($get_agents === true) {
$agents_id = str_replace('&quot;', '', $agents_id);
$agents_id = str_replace('&quot;', '"', $agents_id);
try {
$agents_id = json_decode($agents_id, true);

View File

@ -1,324 +0,0 @@
<?php
/**
* Generate charts with given parameters.
*
* @category ChartGenerator.
* @package Pandora FMS
* @subpackage Opensource.
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2023 Pandora FMS
* Please see https://pandorafms.com/community/ for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
require_once __DIR__.'/config.php';
require_once __DIR__.'/functions.php';
require_once __DIR__.'/functions_db.php';
require_once __DIR__.'/auth/mysql.php';
require_once $config['homedir'].'/include/lib/User.php';
require_once $config['homedir'].'/include/functions_reporting.php';
require_once $config['homedir'].'/include/functions_graph.php';
require_once $config['homedir'].'/include/functions_custom_graphs.php';
require_once $config['homedir'].'/include/functions_modules.php';
require_once $config['homedir'].'/include/functions_agents.php';
require_once $config['homedir'].'/include/functions_tags.php';
$data_raw = get_parameter('data');
$data_decoded = json_decode(io_safe_output($data_raw), true);
if (json_last_error() === JSON_ERROR_NONE) {
$data = $data_decoded['data'];
$session_id = $data_decoded['session_id'];
$type_graph_pdf = $data_decoded['type_graph_pdf'];
$id_user = $data_decoded['id_user'];
$slicebar = $data_decoded['slicebar'];
$slicebar_value = $data_decoded['slicebar_value'];
$data_combined = [];
if (isset($data_decoded['data_combined']) === true) {
$data_combined = $data_decoded['data_combined'];
}
$data_module_list = [];
if (isset($data_decoded['data_module_list']) === true) {
$data_module_list = $data_decoded['data_module_list'];
}
}
// Initialize session.
global $config;
// Care whit this!!! check_login not working if you remove this.
$config['id_user'] = $id_user;
$_SESSION['id_usuario'] = $id_user;
// Checks for server api req.
$bypassLogin = false;
if ($data_decoded['apipass'] !== null
&& ($config['server_unique_identifier'] === $_SESSION['id_usuario'])
) {
$apiPassword = io_output_password(
db_get_value_filter(
'value',
'tconfig',
['token' => 'api_password']
)
);
if ($apiPassword === $data_decoded['apipass']) {
$bypassLogin = true;
}
}
if (!isset($config[$slicebar])) {
$config[$slicebar] = $slicebar_value;
}
// Try to initialize session using existing php session id.
$user = new PandoraFMS\User(['phpsessionid' => $session_id]);
if (check_login(false) === false && $bypassLogin !== true) {
// Error handler.
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Access denied</title>
<link rel="stylesheet" href="styles/pandora.css?v=<?php echo $config['current_package']; ?>" type="text/css" />
<link rel="stylesheet" href="styles/pandora_minimal.css?v=<?php echo $config['current_package']; ?>" type="text/css" />
<link rel="stylesheet" href="styles/js/jquery-ui.min.css?v=<?php echo $config['current_package']; ?>" type="text/css" />
<link rel="stylesheet" href="styles/js/jquery-ui_custom.css?v=<?php echo $config['current_package']; ?>" type="text/css" />
<script language="javascript" type='text/javascript' src='javascript/pandora.js?v=<?php echo $config['current_package']; ?>'></script>
<script language="javascript" type='text/javascript' src='javascript/pandora_ui.js?v=<?php echo $config['current_package']; ?>'></script>
<script language="javascript" type='text/javascript' src='javascript/jquery.current.js?v=<?php echo $config['current_package']; ?>'></script>
</head>
<body>
<h1>Access is not granted</h1>
<div id="container-chart-generator-item" style="display:none; margin:0px;width:100px;height:100px;">
</body>
</html>
<?php
exit;
}
// Access granted.
$params = $data;
if (isset($params['backgroundColor']) === false) {
$params['backgroundColor'] = 'inherit';
}
// Metaconsole connection to the node.
$server_id = 0;
if (isset($params['server_id']) === true) {
$server_id = $params['server_id'];
}
if (is_metaconsole() === true && empty($server_id) === false) {
$server = metaconsole_get_connection_by_id($server_id);
// Error connecting.
if (metaconsole_connect($server) !== NOERR) {
?>
<html>
<body>
<?php
ui_print_error_message(
__('There was a problem connecting with the node')
);
?>
</body>
</html>
<?php
exit;
}
}
$user_language = get_user_language($config['id_user']);
if (file_exists('languages/'.$user_language.'.mo') === true) {
$cfr = new CachedFileReader('languages/'.$user_language.'.mo');
$l10n = new gettext_reader($cfr);
$l10n->load_tables();
}
$hack_metaconsole = (is_metaconsole() === true) ? '../../' : '';
?>
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Pandora FMS Graph</title>
<link rel="stylesheet" href="<?php echo ui_get_full_url($hack_metaconsole.'include/styles/pandora.css'); ?>?v=<?php echo $config['current_package']; ?>" type="text/css" />
<link rel="stylesheet" href="<?php echo ui_get_full_url($hack_metaconsole.'include/styles/pandora_minimal.css'); ?>?v=<?php echo $config['current_package']; ?>" type="text/css" />
<link rel="stylesheet" href="<?php echo ui_get_full_url($hack_metaconsole.'include/styles/js/jquery-ui.min.css'); ?>?v=<?php echo $config['current_package']; ?>" type="text/css" />
<link rel="stylesheet" href="<?php echo ui_get_full_url($hack_metaconsole.'include/styles/js/jquery-ui_custom.css'); ?>?v=<?php echo $config['current_package']; ?>" type="text/css" />
<script language="javascript" type='text/javascript' src='<?php echo ui_get_full_url($hack_metaconsole.'include/javascript/pandora_ui.js'); ?>?v=<?php echo $config['current_package']; ?>'></script>
<script language="javascript" type='text/javascript' src='<?php echo ui_get_full_url($hack_metaconsole.'include/javascript/jquery.current.js'); ?>?v=<?php echo $config['current_package']; ?>'></script>
<script language="javascript" type='text/javascript' src='<?php echo ui_get_full_url($hack_metaconsole.'include/javascript/jquery.pandora.js'); ?>?v=<?php echo $config['current_package']; ?>'></script>
<script language="javascript" type='text/javascript' src='<?php echo ui_get_full_url($hack_metaconsole.'include/javascript/jquery-ui.min.js'); ?>?v=<?php echo $config['current_package']; ?>'></script>
<script language="javascript" type='text/javascript' src='<?php echo ui_get_full_url($hack_metaconsole.'include/javascript/pandora.js'); ?>?v=<?php echo $config['current_package']; ?>'></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.min.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.time.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.pie.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.crosshair.min.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.stack.min.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.selection.min.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.resize.min.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.threshold.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.threshold.multiple.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.symbol.min.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.exportdata.pandora.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/jquery.flot.axislabels.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script type="text/javascript">
var phpTimezone = "<?php echo date_default_timezone_get(); ?>";
</script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/flot/pandora.flot.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/chartjs/chart.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo ui_get_full_url($hack_metaconsole.'include/graphs/chartjs/chartjs-plugin-datalabels.min.js'); ?>?v=<?php echo $config['current_package']; ?>"></script>
</head>
<body style='width:794px; margin: 0px; background-color: <?php echo $params['backgroundColor']; ?>;'>
<?php
$params['only_image'] = false;
$params['menu'] = false;
$params['disable_black'] = true;
$params_combined = $data_combined;
$module_list = $data_module_list;
$viewport = [
'width' => 0,
'height' => 0,
];
$style = 'width:100%;';
if (isset($params['options']['viewport']) === true) {
$viewport = $params['options']['viewport'];
if (empty($viewport['width']) === false) {
$style .= 'width:'.$viewport['width'].'px;';
}
if (empty($viewport['height']) === false) {
$style .= 'height:'.$viewport['height'].'px;';
}
}
echo '<div id="container-chart-generator-item" style="'.$style.' margin:0px;">';
switch ($type_graph_pdf) {
case 'combined':
$params['pdf'] = true;
$result = graphic_combined_module(
$module_list,
$params,
$params_combined
);
echo $result;
break;
case 'sparse':
$params['pdf'] = true;
echo grafico_modulo_sparse($params);
break;
case 'pie_graph':
$params['pdf'] = true;
$chart = get_build_setup_charts(
'PIE',
$params['options'],
$params['chart_data']
);
echo $chart->render(true);
break;
case 'vbar_graph':
$params['pdf'] = true;
$chart = get_build_setup_charts(
'BAR',
$params['options'],
$params['chart_data']
);
echo $chart->render(true);
break;
case 'ring_graph':
$params['pdf'] = true;
$params['options']['width'] = 500;
$params['options']['height'] = 500;
$chart = get_build_setup_charts(
'DOUGHNUT',
$params['options'],
$params['chart_data']
);
echo $chart->render(true);
break;
case 'line_graph':
$params['pdf'] = true;
$params['options']['width'] = '100%';
$params['options']['height'] = 200;
$chart = get_build_setup_charts(
'LINE',
$params['options'],
$params['chart_data']
);
echo $chart->render(true);
break;
case 'slicebar':
// TO-DO Cambiar esto para que se pase por POST, NO SE PUEDE PASAR POR GET.
$params['graph_data'] = json_decode(io_safe_output($config[$params['tokem_config']]), true);
delete_config_token($params['tokem_config']);
echo flot_slicesbar_graph(
$params['graph_data'],
$params['period'],
$params['width'],
$params['height'],
$params['legend'],
$params['colors'],
$params['fontpath'],
$params['round_corner'],
$params['homeurl'],
$params['watermark'],
$params['adapt_key'],
$params['stat_winalse'],
$params['id_agent'],
$params['full_legend_daterray'],
$params['not_interactive'],
$params['ttl'],
$params['sizeForTicks'],
$params['show'],
$params['date_to'],
$params['server_id']
);
break;
default:
// Code...
break;
}
echo '</div>';
?>
</body>
</html>

View File

@ -118,7 +118,7 @@ class ConfigPEN extends HTML
if (is_array($filter)) {
if (!empty($filter['free_search'])) {
$sql_filters[] = vsprintf(
' AND (lower(`manufacturer`) like lower("%%%s%%")
' AND (lower(REPLACE(manufacturer, "&#x20;", " ")) like lower("%%%s%%")
OR pen = "%s") ',
array_fill(0, 2, $filter['free_search'])
);

View File

@ -2383,7 +2383,7 @@ class ConsoleSupervisor
$this->notify(
[
'type' => 'NOTIF.UPDATEMANAGER.REGISTRATION',
'title' => __('This instance is not registered in the Update manager section'),
'title' => __('This instance is not registered in the Warp Update section'),
'message' => __('Click here to start the registration process'),
'url' => '__url__/index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online',
]
@ -2404,13 +2404,17 @@ class ConsoleSupervisor
{
global $config;
include_once $config['homedir'].'/include/functions_update_manager.php';
$server_name = db_get_value_filter(
'name',
'tserver',
[ 'server_type' => '1' ]
);
if (update_manager_verify_api() === false) {
$this->notify(
[
'type' => 'NOTIF.API.ACCESS',
'title' => __('Cannot access the Pandora FMS API '),
'message' => __('Please check the configuration, some components may fail due to this misconfiguration.'),
'message' => __('Please check the configuration, some components may fail due to this misconfiguration in '.$server_name.' ('.$config['public_url'].')'),
]
);
} else {

View File

@ -701,6 +701,10 @@ class Diagnostics extends Wizard
{
global $config;
// Get version comment DB.
$sql_version_comment = 'select @@version_comment as version_comment';
$version_comment = db_get_sql($sql_version_comment);
$result = [
'error' => false,
'data' => [
@ -716,6 +720,14 @@ class Diagnostics extends Wizard
'name' => __('DB Schema Build'),
'value' => $config['db_scheme_build'],
],
'dbVersion' => [
'name' => __('Engine version'),
'value' => $config['dbconnection']->server_info,
],
'dbVersionComment' => [
'name' => __('Version comment'),
'value' => $version_comment,
],
],
];
@ -737,7 +749,7 @@ class Diagnostics extends Wizard
$cpuModelName = 'cat /proc/cpuinfo | grep "model name" | tail -1 | cut -f 2 -d ":"';
$cpuProcessor = 'cat /proc/cpuinfo | grep "processor" | wc -l';
$ramMemTotal = 'cat /proc/meminfo | grep "MemTotal"';
$distroInfo = 'cat /etc/os-release | grep "PRETTY_NAME" | cut -f 2 -d "="';
exec(
"ifconfig | awk '{ print $2}' | grep -E -o '([0-9]{1,3}[\.]){3}[0-9]{1,3}'",
$output
@ -756,6 +768,10 @@ class Diagnostics extends Wizard
'name' => __('RAM'),
'value' => exec($ramMemTotal),
],
'distroInfo' => [
'name' => __('Distro'),
'value' => str_replace('"', '', exec($distroInfo)),
],
'osInfo' => [
'name' => __('Os'),
'value' => exec('uname -a'),

View File

@ -549,8 +549,12 @@ class Heatmap
global $config;
$filter_group = '';
if (empty($this->filter) === false && current($this->filter) != -1) {
if (empty($this->filter) === false && current($this->filter) != -1
&& implode(',', $this->filter) !== ''
) {
$filter_group = 'AND am.id_module_group IN ('.implode(',', $this->filter).')';
} else {
return false;
}
$filter_name = '';

View File

@ -333,6 +333,7 @@ class TreeService extends Tree
$services[$service['id']]['id'] = $service['id'];
$services[$service['id']]['description'] = $service['description'];
$services[$service['id']]['serviceDetail'] = 'index.php?sec=network&sec2=enterprise/operation/services/services&tab=service_map&id_service='.(int) $service['id'];
$services[$service['id']]['title'] = services_get_parents_title((int) $service['id']);
}
return $services;
@ -627,6 +628,7 @@ class TreeService extends Tree
$tmp['type'] = 'services';
$tmp['rootType'] = 'services';
$tmp['children'] = [];
$tmp['servicesChildren'] = services_get_services_children($item->service()->id());
$tmp['serviceDetail'] = ui_get_full_url(
'index.php?sec=network&sec2=enterprise/operation/services/services&tab=service_map&id_service='.$item->service()->id()
);
@ -731,7 +733,10 @@ class TreeService extends Tree
if (isset($this->filter['searchService']) === true
&& empty($this->filter['searchService']) === false
) {
return " AND (ts.name LIKE '%".$this->filter['searchService']."%' OR ts.description LIKE '%".$this->filter['searchService']."%')";
$whereAncestors = ' AND ts.name LIKE "%'.$this->filter['searchService'].'%"
OR ts.description LIKE "%'.$this->filter['searchService'].'%"';
return $whereAncestors;
}
return '';

View File

@ -606,7 +606,7 @@ class WelcomeWindow extends Wizard
],
[
'arguments' => [
'label' => __("Let's do it!"),
'label' => __('Let&apos;s do it!'),
'type' => 'button',
'attributes' => [
'class' => 'secondary',

View File

@ -20,7 +20,7 @@
/**
* Pandora build version and version
*/
$build_version = 'PC231128';
$build_version = 'PC231214';
$pandora_version = 'v7.0NG.774';
// Do not overwrite default timezone set if defined.

View File

@ -306,32 +306,48 @@ function format_for_graph(
}
function human_milliseconds_to_string($seconds)
function human_milliseconds_to_string($seconds, $size_text='large')
{
$ret = '';
// get the days
$days = intval(intval($seconds) / (360000 * 24));
if ($days > 0) {
$ret .= "$days days ";
if ($size_text === 'short') {
$ret .= str_replace(' ', '', "$days d").' ';
} else {
$ret .= "$days days ";
}
}
// get the hours
$hours = ((intval($seconds) / 360000) % 24);
if ($hours > 0) {
$ret .= "$hours hours ";
if ($size_text === 'short') {
$ret .= str_replace(' ', '', "$hours h").' ';
} else {
$ret .= "$hours hours ";
}
}
// get the minutes
$minutes = ((intval($seconds) / 6000) % 60);
if ($minutes > 0) {
$ret .= "$minutes minutes ";
if ($size_text === 'short') {
$ret .= str_replace(' ', '', "$minutes m").' ';
} else {
$ret .= "$minutes minutes ";
}
}
// get the seconds
$seconds = ((intval($seconds) / 100) % 60);
if ($seconds > 0) {
$ret .= "$seconds seconds";
if ($size_text === 'short') {
$ret .= str_replace(' ', '', "$seconds s").' ';
} else {
$ret .= "$seconds seconds ";
}
}
return $ret;
@ -990,6 +1006,70 @@ function get_parameter($name, $default='')
}
function get_parameter_date($name, $default='', $date_format='Y/m/d')
{
$date_end = get_parameter('date_end', 0);
$time_end = get_parameter('time_end');
$datetime_end = strtotime($date_end.' '.$time_end);
$custom_date = get_parameter('custom_date', 0);
$range = get_parameter('range', SECONDS_1DAY);
$date_text = get_parameter('range_text', SECONDS_1DAY);
$date_init_less = (strtotime(date('Y/m/d')) - SECONDS_1DAY);
$date_init = get_parameter('date_init', date(DATE_FORMAT, $date_init_less));
$time_init = get_parameter('time_init', date(TIME_FORMAT, $date_init_less));
$datetime_init = strtotime($date_init.' '.$time_init);
if ($custom_date === '1') {
if ($datetime_init >= $datetime_end) {
$datetime_init = $date_init_less;
}
$date_init = date('Y/m/d H:i:s', $datetime_init);
$date_end = date('Y/m/d H:i:s', $datetime_end);
$period = ($datetime_end - $datetime_init);
} else if ($custom_date === '2') {
$date_units = get_parameter('range_units');
$date_end = date('Y/m/d H:i:s');
$date_init = date('Y/m/d H:i:s', (strtotime($date_end) - ((int) $date_text * (int) $date_units)));
$period = (strtotime($date_end) - strtotime($date_init));
} else if (in_array($range, ['this_week', 'this_month', 'past_week', 'past_month'])) {
if ($range === 'this_week') {
$monday = date('Y/m/d', strtotime('last monday'));
$sunday = date('Y/m/d', strtotime($monday.' +6 days'));
$period = (strtotime($sunday) - strtotime($monday));
$date_init = $monday;
$date_end = $sunday;
} else if ($range === 'this_month') {
$date_end = date('Y/m/d', strtotime('last day of this month'));
$first_of_month = date('Y/m/d', strtotime('first day of this month'));
$date_init = $first_of_month;
$period = (strtotime($date_end) - strtotime($first_of_month));
} else if ($range === 'past_month') {
$date_end = date('Y/m/d', strtotime('last day of previous month'));
$first_of_month = date('Y/m/d', strtotime('first day of previous month'));
$date_init = $first_of_month;
$period = (strtotime($date_end) - strtotime($first_of_month));
} else if ($range === 'past_week') {
$date_end = date('Y/m/d', strtotime('sunday', strtotime('last week')));
$first_of_week = date('Y/m/d', strtotime('monday', strtotime('last week')));
$date_init = $first_of_week;
$period = (strtotime($date_end) - strtotime($first_of_week));
}
} else {
$date_end = date('Y/m/d H:i:s');
$date_init = date('Y/m/d H:i:s', (strtotime($date_end) - $range));
$period = (strtotime($date_end) - strtotime($date_init));
}
return [
'date_init' => date($date_format, strtotime($date_init)),
'date_end' => date($date_format, strtotime($date_end)),
'period' => $period,
];
}
/**
* Get a parameter from a get request.
*
@ -4310,48 +4390,22 @@ function generator_chart_to_pdf(
$module_list=false
) {
global $config;
if (is_metaconsole()) {
$hack_metaconsole = '';
if (is_metaconsole() === true) {
$hack_metaconsole = '../..';
} else {
$hack_metaconsole = '';
}
$url = ui_get_full_url(false).$hack_metaconsole.'/include/chart_generator.php';
if (!$params['return_img_base_64']) {
$img_file = 'img_'.uniqid().'.png';
$img_path = $config['homedir'].'/attachment/'.$img_file;
$img_url = ui_get_full_url(false).$hack_metaconsole.'/attachment/'.$img_file;
}
$session_id = session_id();
if ($type_graph_pdf === 'combined') {
$data = [
'data' => $params,
'session_id' => $session_id,
'type_graph_pdf' => $type_graph_pdf,
'data_module_list' => $module_list,
'data_combined' => $params_combined,
'id_user' => $config['id_user'],
'slicebar' => $_SESSION['slicebar'],
'slicebar_value' => $config[$_SESSION['slicebar']],
'apipass' => get_parameter('apipass', null),
];
} else {
$data = [
'data' => $params,
'session_id' => $session_id,
'type_graph_pdf' => $type_graph_pdf,
'id_user' => $config['id_user'],
'slicebar' => $_SESSION['slicebar'],
'slicebar_value' => $config[$_SESSION['slicebar']],
'apipass' => get_parameter('apipass', null),
];
if ($type_graph_pdf !== 'combined') {
$params_combined = [];
$module_list = [];
}
unset($data['data']['graph_data']);
// If not install chromium avoid 500 convert tu images no data to show.
$chromium_dir = io_safe_output($config['chromium_path']);
$result_ejecution = exec($chromium_dir.' --version');
@ -4371,22 +4425,16 @@ function generator_chart_to_pdf(
// Creates a new page.
$page = $browser->createPage();
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, ['data' => json_encode($data)]);
// Generate Html.
$html = chart_generator(
$type_graph_pdf,
$params,
$params_combined,
$module_list
);
$response = curl_exec($curl);
curl_close($curl);
$page->setHtml($response);
/*
//For debug url with parameters.
$navigation = $page->navigate($url.'?data='.urlencode(json_encode($data)));
$navigation->waitForNavigation(Page::DOM_CONTENT_LOADED);
*/
$page->setHtml($html);
// Dynamic.
$dynamic_height = $page->evaluate('document.getElementById("container-chart-generator-item").clientHeight')->getReturnValue();
@ -4433,6 +4481,211 @@ function generator_chart_to_pdf(
}
/**
* Html print chart for chromium
*
* @param string $type_graph_pdf Chart mode.
* @param array $params Params.
* @param array $params_combined Params Combined charts.
* @param array $module_list Module list Combined charts.
*
* @return string Output Html.
*/
function chart_generator(
string $type_graph_pdf,
array $params,
array $params_combined=[],
array $module_list=[]
) : string {
global $config;
include_once $config['homedir'].'/include/graphs/functions_d3.php';
if (isset($params['backgroundColor']) === false) {
$params['backgroundColor'] = 'inherit';
}
$hack_metaconsole = (is_metaconsole() === true) ? '../../' : '';
$output = '<!DOCTYPE>';
$output .= '<html>';
$output .= '<head>';
$output .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
$output .= '<title>Pandora FMS Graph</title>';
$output .= '<script type="text/javascript">';
$output .= 'var phpTimezone = "'.date_default_timezone_get().'";';
$output .= 'var configHomeurl = "'.((is_metaconsole() === false) ? $config['homeurl'] : '../../').'";';
$output .= '</script>';
$css_files = [
'pandora' => 'include/styles/',
'pandora_minimal' => 'include/styles/',
'jquery-ui.min' => 'include/styles/js/',
'jquery-ui_custom' => 'include/styles/js/',
];
foreach ($css_files as $name => $path) {
$output .= ui_require_css_file($name, $path, true, true);
}
$js_files = [
'pandora_ui' => 'include/javascript/',
'jquery.current' => 'include/javascript/',
'jquery.pandora' => 'include/javascript/',
'jquery-ui.min' => 'include/javascript/',
'date' => 'include/javascript/timezone/src/',
'pandora' => 'include/javascript/',
'jquery.flot' => 'include/graphs/flot/',
'jquery.flot.min' => 'include/graphs/flot/',
'jquery.flot.time' => 'include/graphs/flot/',
'jquery.flot.pie' => 'include/graphs/flot/',
'jquery.flot.crosshair.min' => 'include/graphs/flot/',
'jquery.flot.stack.min' => 'include/graphs/flot/',
'jquery.flot.selection.min' => 'include/graphs/flot/',
'jquery.flot.resize.min' => 'include/graphs/flot/',
'jquery.flot.threshold' => 'include/graphs/flot/',
'jquery.flot.threshold.multiple' => 'include/graphs/flot/',
'jquery.flot.symbol.min' => 'include/graphs/flot/',
'jquery.flot.exportdata.pandora' => 'include/graphs/flot/',
'jquery.flot.axislabels' => 'include/graphs/flot/',
'pandora.flot' => 'include/graphs/flot/',
'chart' => 'include/graphs/chartjs/',
'chartjs-plugin-datalabels.min' => 'include/graphs/chartjs/',
];
foreach ($js_files as $name => $path) {
$output .= ui_require_javascript_file($name, $path, true, true);
}
$output .= include_javascript_d3(true, true);
$output .= '</head>';
$output .= '<body style="width:794px; margin: 0px; background-color:'.$params['backgroundColor'].';">';
$params['only_image'] = false;
$params['menu'] = false;
$params['disable_black'] = true;
$viewport = [
'width' => 0,
'height' => 0,
];
$style = 'width:100%;';
if (isset($params['options']['viewport']) === true) {
$viewport = $params['options']['viewport'];
if (empty($viewport['width']) === false) {
$style .= 'width:'.$viewport['width'].'px;';
}
if (empty($viewport['height']) === false) {
$style .= 'height:'.$viewport['height'].'px;';
}
}
$output .= '<div id="container-chart-generator-item" style="'.$style.' margin:0px;">';
switch ($type_graph_pdf) {
case 'combined':
$params['pdf'] = true;
$result = graphic_combined_module(
$module_list,
$params,
$params_combined
);
$output .= $result;
break;
case 'sparse':
$params['pdf'] = true;
$output .= grafico_modulo_sparse($params);
break;
case 'pie_graph':
$params['pdf'] = true;
$chart = get_build_setup_charts(
'PIE',
$params['options'],
$params['chart_data']
);
$output .= $chart->render(true);
break;
case 'vbar_graph':
$params['pdf'] = true;
$chart = get_build_setup_charts(
'BAR',
$params['options'],
$params['chart_data']
);
$output .= $chart->render(true);
break;
case 'ring_graph':
$params['pdf'] = true;
$params['options']['width'] = 500;
$params['options']['height'] = 500;
$chart = get_build_setup_charts(
'DOUGHNUT',
$params['options'],
$params['chart_data']
);
$output .= $chart->render(true);
break;
case 'line_graph':
$params['pdf'] = true;
$params['options']['width'] = '100%';
$params['options']['height'] = 200;
$chart = get_build_setup_charts(
'LINE',
$params['options'],
$params['chart_data']
);
$output .= $chart->render(true);
break;
case 'slicebar':
$output .= flot_slicesbar_graph(
$params['graph_data'],
$params['period'],
$params['width'],
$params['height'],
$params['legend'],
$params['colors'],
$params['fontpath'],
$params['round_corner'],
$params['homeurl'],
$params['watermark'],
$params['adapt_key'],
$params['stat_winalse'],
$params['id_agent'],
$params['full_legend_daterray'],
$params['not_interactive'],
$params['ttl'],
$params['sizeForTicks'],
$params['show'],
$params['date_to'],
$params['server_id']
);
break;
default:
// Code...
break;
}
$output .= '</div>';
$output .= '</body>';
$output .= '</html>';
return $output;
}
/**
* Get the product name.
*

View File

@ -3643,7 +3643,7 @@ function select_modules_for_agent_group(
if (!$selection && $agents != null) {
$number_agents = count($id_agents);
$selection_filter = "HAVING COUNT(id_agente_modulo) = $number_agents";
$selection_filter = "GROUP BY nombre HAVING COUNT(id_agente_modulo) = $number_agents";
}
if (tags_has_user_acl_tags(false)) {
@ -3664,7 +3664,7 @@ function select_modules_for_agent_group(
$sql = "SELECT * FROM
(
SELECT DISTINCT(tagente_modulo.id_agente_modulo), tagente_modulo.nombre
SELECT (tagente_modulo.id_agente_modulo), tagente_modulo.nombre, tagente.alias
FROM tagente_modulo
$sql_tags_inner
INNER JOIN tagente
@ -3679,7 +3679,7 @@ function select_modules_for_agent_group(
$filter_not_string_modules
$sql_conditions_tags
) x
GROUP BY nombre
$selection_filter";
$modules = db_get_all_rows_sql($sql);
@ -4752,7 +4752,7 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent)
$secondary_groups = enterprise_hook('agents_get_secondary_groups', [$id_agente]);
$secondaryLinks = [];
if (empty($secondary_groups['for_select']) === true) {
$secondaryLinks[] = '<em>'.__('N/A').'</em>';
$secondaryLinks = [];
} else {
foreach ($secondary_groups['for_select'] as $id => $name) {
$secondaryLinks[] = html_print_anchor(
@ -4811,22 +4811,22 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent)
'content' => groups_get_name($agent['id_grupo']),
],
true
);
).' '.ui_print_group_icon($agent['id_grupo'], true, '', 'margin-left: 2%;', true, false, false, '', true);
$table_contact->data[] = $data;
// Secondary groups.
$data = [];
$data[0] = '<b>'.__('Secondary groups').'</b>';
$data[1] = implode(', ', $secondaryLinks);
$table_contact->data[] = $data;
if (!empty($secondaryLinks) === true) {
$data[0] = '<b>'.__('Secondary groups').'</b>';
$data[1] = implode(', ', $secondaryLinks);
$table_contact->data[] = $data;
}
// Parent agent line.
if (enterprise_installed() === true) {
$data = [];
$data[0] = '<b>'.__('Parent').'</b>';
if ((int) $agent['id_parent'] === 0) {
$data[1] = '<em>'.__('N/A').'</em>';
} else {
if ((int) $agent['id_parent'] !== 0) {
$data = [];
$data[0] = '<b>'.__('Parent').'</b>';
$data[1] = html_print_anchor(
[
'href' => 'index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$agent['id_parent'],
@ -4834,9 +4834,9 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent)
],
true
);
}
$table_contact->data[] = $data;
$table_contact->data[] = $data;
}
}
// Last status change line.
@ -4845,6 +4845,44 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent)
$data[1] = $time_elapsed;
$table_contact->data[] = $data;
$has_remote_conf = enterprise_hook(
'config_agents_has_remote_configuration',
[$agent['id_agente']]
);
if ((bool) $has_remote_conf) {
$data = [];
$data[0] = __('Remote configuration');
$data[1] = '<spam style="position: relative;top: -10%; margin-right: 10px;">'.__('Enabled').'</spam>';
$data[1] .= html_print_menu_button(
[
'href' => ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=remote_configuration&id_agente='.$agent['id_agente'].'&disk_conf=1'),
'image' => 'images/remote-configuration@svg.svg',
'title' => __('Edit remote config'),
],
true
);
$satellite_server = (int) db_get_value_filter(
'satellite_server',
'tagente',
['id_agente' => $id_agente]
);
if (empty($satellite_server) === false) {
$satellite_name = db_get_value_filter(
'name',
'tserver',
['id_server' => $satellite_server]
);
$data[0] = __('Satellite server');
$data[1] = $satellite_name;
}
$table_contact->data[] = $data;
}
if (enterprise_installed() === true) {
// SecurityMon line.
$id_module_group = db_get_value('id_mg', 'tmodule_group', 'name', 'Security');
@ -4887,6 +4925,43 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent)
}
}
// Optional data
// Position Information.
if ((bool) $config['activate_gis'] === true) {
$data = [];
$dataPositionAgent = gis_get_data_last_position_agent(
$agent['id_agente']
);
if (is_array($dataPositionAgent) === true && $dataPositionAgent['stored_longitude'] !== '' && $dataPositionAgent['stored_latitude'] !== '') {
$data[0] = __('Position (Long, Lat)');
$dataOptionalOutput = html_print_anchor(
[
'href' => 'index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;tab=gis&amp;id_agente='.$id_agente,
'content' => $dataPositionAgent['stored_longitude'].', '.$dataPositionAgent['stored_latitude'],
],
true
);
if (empty($dataPositionAgent['description']) === false) {
$dataOptionalOutput .= ' ('.$dataPositionAgent['description'].')';
}
$data[1] = $dataOptionalOutput;
}
$table_contact->data[] = $data;
}
// Timezone Offset.
if ((int) $agent['timezone_offset'] !== 0) {
$data = [];
$data[0] = __('Timezone Offset');
$data[1] = $agent['timezone_offset'];
$table_contact->data[] = $data;
}
$agent_contact = html_print_div(
[
'class' => 'agent_details_header',
@ -4901,13 +4976,38 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent)
}
/**
* agent belongs to the clusters.
*
* @param integer $idAgent
*
* @return array Names clusters.
*/
function agents_get_agent_belongs_cluster(int $idAgent): array
{
$sql = sprintf(
'SELECT tcluster.name
FROM tcluster
INNER JOIN tcluster_agent
ON tcluster.id = tcluster_agent.id_cluster
WHERE tcluster_agent.id_agent = %d',
$idAgent
);
$result = db_get_all_rows_sql($sql);
if ($result === false) {
$result = [];
}
return $result;
}
/**
* Return an array with a list of status agents
*
* @return array.
*/
function agents_status_list()
{
$status_list = [];

View File

@ -2169,13 +2169,16 @@ function get_group_alerts(
$strict_user=false,
$tag=false,
$action_filter=false,
$alert_action=true
$alert_action=true,
$search_sg=false
) {
global $config;
$group_query = '';
if (!empty($idGroup)) {
$group_query = ' AND id_grupo = '.$idGroup;
if ((bool) $search_sg === true) {
$group_query .= ' OR tasg.id_group = '.$idGroup;
}
}
if (is_array($filter)) {

View File

@ -82,7 +82,7 @@ function parseOtherParameter($other, $otherType, $rawDecode)
case 'url_encode':
$returnVar = [
'type' => 'string',
'data' => urldecode($other),
'data' => $rawDecode ? rawurldecode($other) : urldecode($other),
];
break;
@ -10301,8 +10301,7 @@ function api_set_module_data($id, $thrash2, $other, $trash1)
modules_get_type_name($agentModule['id_tipo_modulo']),
$data
);
if (false === @file_put_contents($config['remote_config'].'/'.io_safe_output($agent['nombre']).'.'.$time.'.data', $xml)) {
if (false === @file_put_contents($config['remote_config'].'/'.io_safe_output($agent['nombre']).'.'.$idAgentModule.'.'.$time.'.data', $xml)) {
returnError(sprintf('XML file could not be generated in path: %s', $config['remote_config']));
} else {
echo __('XML file was generated successfully in path: ').$config['remote_config'];
@ -13132,7 +13131,7 @@ function api_set_create_event($id, $trash1, $other, $returnType)
if ($other['data'][18] != '') {
$values['id_extra'] = $other['data'][18];
$sql_validation = 'SELECT id_evento,estado,ack_utimestamp,id_usuario
$sql_validation = 'SELECT id_evento,estado,ack_utimestamp,id_usuario,event_custom_id
FROM tevento
WHERE estado IN (0,2) AND id_extra ="'.$other['data'][18].'";';
@ -13147,6 +13146,7 @@ function api_set_create_event($id, $trash1, $other, $returnType)
$values['status'] = 2;
$ack_utimestamp = $val['ack_utimestamp'];
$values['id_usuario'] = $val['id_usuario'];
$values['event_custom_id'] = $val['event_custom_id'];
}
api_set_validate_event_by_id($val['id_evento']);
@ -13177,7 +13177,8 @@ function api_set_create_event($id, $trash1, $other, $returnType)
$custom_data,
$values['server_id'],
$values['id_extra'],
$ack_utimestamp
$ack_utimestamp,
$values['event_custom_id'] ?? null
);
if ($other['data'][12] != '') {
@ -17787,6 +17788,48 @@ function api_token_check(string $token)
}
/**
* Set custom field value in tevento
*
* @param mixed $id_event Event id.
* @param mixed $custom_field Custom field to set.
* @return void
*/
function api_set_event_custom_id($id, $value)
{
// Get the event
$event = events_get_event($id, false, is_metaconsole());
// If event not exists, end the execution.
if ($event === false) {
returnError(
'event_not_exists',
'Event not exists'
);
$result = false;
}
// Safe custom fields for hacks.
if (preg_match('/script/i', io_safe_output($value))) {
$result = false;
}
$result = events_event_custom_id(
$id,
$value
);
// If update results failed
if (empty($result) === true || $result === false) {
returnError(
'The event could not be updated'
);
return false;
} else {
returnData('string', ['data' => 'Event updated.']);
}
}
/**
* Extract info Agents for inventories ITSM.
*

View File

@ -249,10 +249,6 @@ function config_update_config()
$error_update[] = __('Enable Netflow');
}
if (config_update_value('activate_sflow', (bool) get_parameter('activate_sflow'), true) === false) {
$error_update[] = __('Enable Sflow');
}
if (config_update_value('activate_feedback', (bool) get_parameter('activate_feedback'), true) === false) {
$error_update[] = __('Enable Feedback');
}
@ -371,6 +367,10 @@ function config_update_config()
$error_update[] = __('show_experimental_features');
}
if (config_update_value('number_modules_queue', get_parameter('number_modules_queue'), true) === false) {
$error_update[] = __('number_modules_queue');
}
if (config_update_value('console_log_enabled', get_parameter('console_log_enabled'), true) === false) {
$error_update[] = __('Console log enabled');
}
@ -431,6 +431,10 @@ function config_update_config()
if (config_update_value('inventory_changes_blacklist', implode(',', $inventory_changes_blacklist), true) === false) {
$error_update[] = __('Inventory changes blacklist');
}
if (config_update_value('tftp_server_ip', (string) get_parameter('tftp_server_ip'), true) === false) {
$error_update[] = __('Ftp server ip');
}
break;
case 'enterprise':
@ -1619,6 +1623,10 @@ function config_update_config()
if (config_update_value('netflow_get_ip_hostname', (int) get_parameter('netflow_get_ip_hostname'), true) === false) {
$error_update[] = __('Name resolution for IP address');
}
if (config_update_value('activate_sflow', (bool) get_parameter('activate_sflow'), true) === false) {
$error_update[] = __('Enable Sflow');
}
break;
case 'sflow':
@ -2441,6 +2449,10 @@ function config_process_config()
config_update_value('show_experimental_features', 0);
}
if (!isset($config['number_modules_queue'])) {
config_update_value('number_modules_queue', 500);
}
if (!isset($config['agent_vulnerabilities'])) {
config_update_value('agent_vulnerabilities', 1);
}

View File

@ -459,17 +459,17 @@ function cron_task_start_gotty(bool $restart_mode=true)
// Check prev process running and kill it (only if port changed in setup params).
if (empty($config['restart_gotty_next_cron_port']) === false) {
config_update_value('restart_gotty_next_cron_port', '');
$prevProcessRunning = shell_exec("pgrep -f 'pandora_gotty.*-p ".$config['restart_gotty_next_cron_port']."'");
$prevProcessRunning = shell_exec("pgrep -af 'pandora_gotty.*-p ".$config['restart_gotty_next_cron_port']."' | grep -v 'pgrep'");
if (empty($prevProcessRunning) === false) {
shell_exec("pkill -f 'pandora_gotty.*-p ".$config['restart_gotty_next_cron_port']."'");
}
config_update_value('restart_gotty_next_cron_port', '');
}
// Check if gotty is running on the configured port.
$processRunning = shell_exec("pgrep -f 'pandora_gotty.*-p ".$config['gotty_port']."'");
$processRunning = shell_exec("pgrep -af 'pandora_gotty.*-p ".$config['gotty_port']."' | grep -v 'pgrep'");
$start_proc = true;

View File

@ -194,11 +194,11 @@ function custom_graphs_get_user($id_user=0, $only_names=false, $returnAllGroup=t
function custom_graphs_search($id_group, $search)
{
if ($id_group != '' && $search != '') {
$all_graphs = db_get_all_rows_sql('select * from tgraph where id_group = '.$id_group.' AND (name LIKE "%'.$search.'%" OR description LIKE "'.$search.'")');
$all_graphs = db_get_all_rows_sql('select * from tgraph where id_group = '.$id_group.' AND (REPLACE(name, "&#x20;", " ") LIKE "%'.$search.'%" OR REPLACE(description, "&#x20;", " ") LIKE "'.$search.'")');
} else if ($id_group != '') {
$all_graphs = db_get_all_rows_sql('select * from tgraph where id_group = '.$id_group.'');
} else {
$all_graphs = db_get_all_rows_sql('select * from tgraph where name LIKE "%'.$search.'%" OR description LIKE "'.$search.'"');
$all_graphs = db_get_all_rows_sql('select * from tgraph where REPLACE(name, "&#x20;", " ") LIKE "%'.$search.'%" OR REPLACE(description, "&#x20;", " ") LIKE "'.$search.'"');
}
if ($all_graphs === false) {

View File

@ -127,6 +127,58 @@ function events_translate_event_type($event_type)
}
/**
* Module status event_type into descriptive text.
*
* @param integer $event_type Event type.
*
* @return string Module status.
*/
function events_status_module_event_type($event_type)
{
$module_status = '';
switch ($event_type) {
case 'alert_fired':
case 'alert_recovered':
case 'alert_ceased':
case 'alert_manual_validation':
$module_status = AGENT_MODULE_STATUS_CRITICAL_ALERT;
break;
case 'going_down_normal':
case 'going_up_normal':
$module_status = AGENT_MODULE_STATUS_NORMAL;
break;
case 'going_unknown':
case 'unknown':
$module_status = AGENT_MODULE_STATUS_UNKNOWN;
break;
case 'going_up_warning':
case 'going_down_warning':
$module_status = AGENT_MODULE_STATUS_WARNING;
break;
case 'going_up_critical':
case 'going_down_critical':
$module_status = AGENT_MODULE_STATUS_CRITICAL_BAD;
break;
case 'recon_host_detected':
case 'system':
case 'error':
case 'new_agent':
case 'configuration_change':
default:
$module_status = AGENT_MODULE_STATUS_NOT_INIT;
break;
}
return $module_status;
}
/**
* Translates a numeric value event_status into descriptive text.
*
@ -219,6 +271,7 @@ function events_get_all_fields()
$columns['module_status'] = __('Module status');
$columns['module_custom_id'] = __('Module custom id');
$columns['custom_data'] = __('Custom data');
$columns['event_custom_id'] = __('Event Custom ID');
return $columns;
}
@ -322,6 +375,9 @@ function events_get_column_name($field, $table_alias=false)
case 'custom_data':
return __('Custom data');
case 'event_custom_id':
return __('Event Custom ID');
default:
return __($field);
}
@ -2356,7 +2412,8 @@ function events_create_event(
$custom_data='',
$server_id=0,
$id_extra='',
$ack_utimestamp=0
$ack_utimestamp=0,
$event_custom_id=null
) {
if ($source === false) {
$source = get_product_name();
@ -2388,6 +2445,7 @@ function events_create_event(
'custom_data' => $custom_data,
'data' => '',
'module_status' => 0,
'event_custom_id' => $event_custom_id,
];
return (int) db_process_sql_insert('tevento', $values);
@ -2611,7 +2669,6 @@ function events_print_type_img(
$urlImage = ui_get_full_url(false);
$icon = '';
$style = 'main_menu_icon';
switch ($type) {
case 'alert_recovered':
$icon = 'images/alert_recovered@svg.svg';
@ -2677,16 +2734,6 @@ function events_print_type_img(
if ($only_url) {
$output = $urlImage.'/'.$icon;
} else {
/*
$output .= html_print_div(
[
'title' => events_print_type_description($type, true),
'class' => $style,
'style' => ((empty($icon) === false) ? 'background-image: url('.$icon.'); background-repeat: no-repeat;' : ''),
],
true
);
*/
$output .= html_print_image(
$icon,
true,
@ -4658,6 +4705,30 @@ function events_page_details($event, $server_id=0)
$data[1] = '<i>'.__('N/A').'</i>';
}
$table_details->data[] = $data;
$readonly = true;
if (check_acl($config['id_user'], 0, 'EW')) {
$readonly = false;
}
$data = [];
$data[0] = __('Event Custom ID');
$data[1] = '<div class="flex-row-center">'.html_print_input_text('event_custom_id', $event['event_custom_id'], '', false, 255, true, $readonly, false, '', 'w60p');
if ($readonly === false) {
$data[1] .= html_print_button(
__('Update'),
'update_event_custom_id',
false,
'update_event_custom_id('.$event['id_evento'].', '.$event['server_id'].');',
[
'icon' => 'next',
'mode' => 'link',
],
true
);
}
$data[1] .= '</div>';
$table_details->data[] = $data;
$details = '<div id="extended_event_details_page" class="extended_event_pages">'.html_print_table($table_details, true).'</div>';
@ -4968,7 +5039,11 @@ function events_page_general($event)
$data[1] = $user_owner;
}
$table_general->cellclass[3][1] = 'general_owner';
if (is_metaconsole() === true && $event['server_name'] !== '') {
$table_general->cellclass[4][1] = 'general_owner';
} else {
$table_general->cellclass[3][1] = 'general_owner';
}
$table_general->data[] = $data;
@ -5028,38 +5103,21 @@ function events_page_general($event)
$table_general->cellclass[count($table_general->data)][1] = 'general_acknowleded';
$data = [];
if (empty($event['server_id']) === false && (int) $event['server_id'] > 0
&& is_metaconsole() === true
) {
$node_connect = new Node($event['server_id']);
$node_connect->connect();
}
$data[0] = __('Acknowledged by');
$data[1] = events_page_general_acknowledged($event['id_evento']);
if ($event['estado'] == 1 || $event['estado'] == 2) {
if (empty($event['id_usuario']) === true) {
$user_ack = __('Autovalidated');
} else {
$user_ack = db_get_value(
'fullname',
'tusuario',
'id_user',
$event['id_usuario']
);
if (empty($user_ack) === true) {
$user_ack = $event['id_usuario'];
}
}
$data[1] = $user_ack.'&nbsp;(&nbsp;';
if ($event['ack_utimestamp_raw'] !== false
&& $event['ack_utimestamp_raw'] !== 'false'
&& empty($event['ack_utimestamp_raw']) === false
) {
$data[1] .= date(
$config['date_format'],
$event['ack_utimestamp_raw']
);
}
$data[1] .= '&nbsp;)&nbsp;';
} else {
$data[1] = '<i>'.__('N/A').'</i>';
if (empty($event['server_id']) === false && (int) $event['server_id'] > 0
&& is_metaconsole() === true
) {
$node_connect->disconnect();
}
$table_general->cellclass[7][1] = 'general_status';
@ -5166,15 +5224,19 @@ function events_page_general_acknowledged($event_id)
$Acknowledged = '';
$event = db_get_row('tevento', 'id_evento', $event_id);
if ($event !== false && ($event['estado'] == 1 || $event['estado'] == 2)) {
$user_ack = db_get_value(
'fullname',
'tusuario',
'id_user',
$config['id_user']
);
if (empty($event['id_usuario']) === true) {
$user_ack = __('Autovalidated');
} else {
$user_ack = db_get_value(
'fullname',
'tusuario',
'id_user',
$config['id_user']
);
if (empty($user_ack) === true) {
$user_ack = $config['id_user'];
if (empty($user_ack) === true) {
$user_ack = $config['id_user'];
}
}
$Acknowledged = $user_ack.'&nbsp;(&nbsp;';
@ -5189,7 +5251,7 @@ function events_page_general_acknowledged($event_id)
$Acknowledged .= '&nbsp;)&nbsp;';
} else {
$Acknowledged = 'N/A';
$Acknowledged = '<i>'.__('N/A').'</i>';
}
return $Acknowledged;
@ -5775,7 +5837,7 @@ function events_get_field_value_by_event_id(
}
function events_get_instructions($event)
function events_get_instructions($event, $max_text_length=300)
{
if (is_array($event) === false) {
return '';
@ -5823,17 +5885,17 @@ function events_get_instructions($event)
return '';
}
$max_text_length = 300;
$over_text = io_safe_output($value);
if (strlen($over_text) > ($max_text_length + 3)) {
$over_text = substr($over_text, 0, $max_text_length).'...';
} else {
return $value;
}
$output = '<div id="hidden_event_instructions_'.$event['id_evento'].'"';
$output .= ' class="event_instruction">';
$output .= $value;
$output .= '</div>';
$output .= '<center>';
$output .= '<span id="value_event_'.$event['id_evento'].'" class="nowrap">';
$output .= '<span id="value_event_text_'.$event['id_evento'].'"></span>';
$output .= '<a href="javascript:show_instructions('.$event['id_evento'].')">';
@ -5842,7 +5904,6 @@ function events_get_instructions($event)
true,
['title' => $over_text]
).'</a></span>';
$output .= '</center>';
return $output;
}
@ -6260,6 +6321,63 @@ function event_get_counter_extraId(array $event, ?array $filters)
}
/**
* Update event detail custom field
*
* @param mixed $id_event Event ID or array of events.
* @param string $event_custom_id Event custom ID to be update.
*
* @return boolean Whether or not it was successful
*/
function events_event_custom_id(
$id_event,
$event_custom_id,
) {
global $config;
// Cleans up the selection for all unwanted values also casts any single
// values as an array.
if (![$id_event]) {
$id_event = (array) safe_int($id_event, 1);
}
// Check ACL.
foreach ($id_event as $k => $id) {
$event_group = events_get_group($id);
if (check_acl($config['id_user'], $event_group, 'EW') == 0) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Attempted updating event #'.$id
);
unset($id_event[$k]);
}
}
if (empty($id_event) === true) {
return false;
}
// Get the current event comments.
$first_event = $id_event;
if (is_array($id_event) === true) {
$first_event = reset($id_event);
}
// Update comment.
$ret = db_process_sql_update(
'tevento',
['event_custom_id' => $event_custom_id],
['id_evento' => $first_event]
);
if (($ret === false) || ($ret === 0)) {
return false;
}
return true;
}
function event_print_graph(
$filter,
$graph_height=100,
@ -6344,7 +6462,12 @@ function event_print_graph(
$color[] = '#82b92f';
}
} else {
$interval_length = (int) ($period / $num_intervals);
if ($num_intervals > 0) {
$interval_length = (int) ($period / $num_intervals);
} else {
$interval_length = 0;
}
$intervals = [];
$intervals[0] = $start_utimestamp;
for ($i = 0; $i < $num_intervals; $i++) {

View File

@ -128,19 +128,18 @@ function upload_file($upload_file_or_zip, $default_real_directory, $destination_
$extension = pathinfo($filename, PATHINFO_EXTENSION);
$umask = io_safe_output((string) get_parameter('umask'));
$parse_all_queries = explode('&', parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY));
$parse_sec2_query = explode('=', $parse_all_queries[1]);
$check_extension = true;
if ($parse_sec2_query[1] === 'operation/snmpconsole/snmp_mib_uploader') {
if ((strtolower($extension) !== 'mib' && strtolower($extension) !== 'zip')) {
$check_extension = false;
} else {
$check_extension = true;
}
}
// $parse_all_queries = explode('&', parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY));
// $parse_sec2_query = explode('=', $parse_all_queries[1]);
// $check_extension = true;
// if ($parse_sec2_query[1] === 'operation/snmpconsole/snmp_mib_uploader') {
// if ((strtolower($extension) !== 'mib' && strtolower($extension) !== 'zip')) {
// $check_extension = false;
// } else {
// $check_extension = true;
// }
// }
// (strtolower($extension) !== 'mib' && strtolower($extension) !== 'zip')
if (strpos($real_directory, $default_real_directory) !== 0 || $check_extension === false) {
if (strpos($real_directory, $default_real_directory) !== 0) {
// Perform security check to determine whether received upload
// directory is part of the default path for caller uploader and
// user is not trying to access an external path (avoid
@ -152,12 +151,12 @@ function upload_file($upload_file_or_zip, $default_real_directory, $destination_
// Copy file to directory and change name.
$nombre_archivo = sprintf('%s/%s', $real_directory, $filename);
try {
$mimeContentType = mime_content_type($_FILES['file']['tmp_name']);
if (empty($filterFilesType) === true || in_array($mimeContentType, $filterFilesType) === true) {
$ext = strtolower(pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION));
if (empty($filterFilesType) === true || in_array($ext, $filterFilesType) === true) {
$result = copy($_FILES['file']['tmp_name'], $nombre_archivo);
} else {
$error_message = 'The uploaded file is not allowed. Only gif, png or jpg files can be uploaded.';
$types_allowed = implode(', ', $filterFilesType);
$error_message = 'The uploaded file is not allowed. Only '.$types_allowed.' files can be uploaded.';
throw new Exception(__($error_message));
}
} catch (Exception $ex) {
@ -199,19 +198,29 @@ function upload_file($upload_file_or_zip, $default_real_directory, $destination_
$filepath = $_FILES['file']['tmp_name'];
$real_directory = filemanager_safe_directory($destination_directory);
$secure = true;
if ($parse_sec2_query[1] === 'operation/snmpconsole/snmp_mib_uploader') {
// Security control structure.
$zip = new \ZipArchive;
if ($zip->open($filepath) === true) {
for ($i = 0; $i < $zip->numFiles; $i++) {
$unzip_filename = $zip->getNameIndex($i);
$extension = pathinfo($unzip_filename, PATHINFO_EXTENSION);
if (strtolower($extension) !== 'mib') {
$secure = false;
break;
try {
$ext = strtolower(pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION));
if (empty($filterFilesType) === true || in_array($ext, $filterFilesType) === true) {
// Security control structure.
$zip = new \ZipArchive;
if ($zip->open($filepath) === true) {
for ($i = 0; $i < $zip->numFiles; $i++) {
$unzip_filename = $zip->getNameIndex($i);
$extension = pathinfo($unzip_filename, PATHINFO_EXTENSION);
if (in_array(strtolower($extension), $filterFilesType) === false) {
$error_message = 'The uploaded file is not allowed. Only '.$types_allowed.' files can be uploaded.';
$secure = false;
throw new Exception(__($error_message));
}
}
}
}
} catch (Exception $ex) {
db_pandora_audit(
AUDIT_LOG_FILE_MANAGER,
'Error Uploading files: '.$ex->getMessage()
);
$config['filemanager']['message'] = ui_print_error_message(__('Upload error').': '.$ex->getMessage());
}
if (strpos($real_directory, $default_real_directory) !== 0 || $secure === false) {

View File

@ -1585,7 +1585,7 @@ function gis_add_conection_maps_in_form($map_connection_list)
<tr class="row_0">
<td>'.html_print_input_text('map_connection_name_'.$mapConnection['id_conection'], $mapConnectionRowDB['conection_name'], '', 20, 40, true, true).'</td>
<td>'.$radioButton.'</td>
<td><a id="delete_row" href="javascript: deleteConnectionMap(\''.$mapConnection['id_conection'].'\')">'.html_print_image('images/delete.svg', true, ['alt' => '', 'class' => 'invert_filter']).'</a></td>
<td><a id="delete_row" href="javascript: deleteConnectionMap(\''.$mapConnection['id_conection'].'\')">'.html_print_image('images/delete.svg', true, ['alt' => '', 'class' => 'invert_filter main_menu_icon']).'</a></td>
</tr>
</tbody>
<script type="text/javascript">

View File

@ -1745,20 +1745,37 @@ function html_print_select_multiple_modules_filtered(array $data):string
}
}
$output .= html_print_input(
[
'label' => __('Agents'),
'label_class' => 'font-title-font',
'type' => 'select_from_sql',
'sql' => 'SELECT `id_agente`,`alias` FROM tagente',
'name' => 'filtered-module-agents-'.$uniqId,
'selected' => explode(',', $data['mAgents']),
'return' => true,
'multiple' => true,
'style' => 'min-width: 200px;max-width:200px;',
'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')',
]
);
if (is_metaconsole() === true) {
$output .= html_print_input(
[
'label' => __('Agents'),
'label_class' => 'font-title-font',
'type' => 'select',
'fields' => $agents,
'name' => 'filtered-module-agents-'.$uniqId,
'selected' => explode(',', $data['mAgents']),
'return' => true,
'multiple' => true,
'style' => 'min-width: 200px;max-width:200px;',
'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')',
]
);
} else {
$output .= html_print_input(
[
'label' => __('Agents'),
'label_class' => 'font-title-font',
'type' => 'select_from_sql',
'sql' => 'SELECT `id_agente`,`alias` FROM tagente',
'name' => 'filtered-module-agents-'.$uniqId,
'selected' => explode(',', $data['mAgents']),
'return' => true,
'multiple' => true,
'style' => 'min-width: 200px;max-width:200px;',
'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')',
]
);
}
$commonModules = 0;
if (empty($data['mShowCommonModules']) === false) {

View File

@ -77,7 +77,7 @@ function inventory_get_data(
}
if ($inventory_search_string != '') {
array_push($where, "tagent_module_inventory.data LIKE '%".$inventory_search_string."%'");
array_push($where, "REPLACE(tagent_module_inventory.data, '&#x20;', ' ') LIKE '%".$inventory_search_string."%'");
}
$offset = (int) get_parameter('offset');
@ -746,7 +746,7 @@ function inventory_get_datatable(
}
if ($inventory_search_string != '') {
array_push($where, "tagent_module_inventory.data LIKE '%".$inventory_search_string."%'");
array_push($where, "REPLACE(tagente_datos_inventory.data, '&#x20;', ' ') LIKE '%".$inventory_search_string."%'");
}
if ($utimestamp > 0) {
@ -786,7 +786,6 @@ function inventory_get_datatable(
}
$rows = db_get_all_rows_sql($sql);
if ($order_by_agent === false) {
$modules = [];
foreach ($rows as $row) {
@ -796,7 +795,13 @@ function inventory_get_datatable(
$data_rows = explode(PHP_EOL, $row['data_inventory']);
foreach ($data_rows as $data_key => $data_value) {
if (empty($data_value) === false) {
if (empty($inventory_search_string) !== true) {
$search_check = strpos(str_replace('&#x20;', ' ', $data_value), $inventory_search_string);
} else {
$search_check = true;
}
if (empty($data_value) === false && $search_check !== false) {
$row['data'] = $data_value;
$modules[$row['name']][$row['name_agent'].'-'.$data_key.'-'.$data_value] = $row;
}
@ -889,7 +894,7 @@ function get_data_basic_info_sql($params, $count=false)
if ($params['search'] > 0) {
$where .= sprintf(
' AND ( alias LIKE "%%%s%%" )',
' AND ( REPLACE(alias, "&#x20;", " ") LIKE "%%%s%%" )',
$params['search']
);
}

View File

@ -563,6 +563,9 @@ 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;
return sprintf(
'%s%s%s',
$wrappedBy,

View File

@ -0,0 +1,61 @@
<?php
// Pandora FMS - https://pandorafms.com
// ==================================================
// Copyright (c) 2005-2023 Pandora FMS
// Please see https://pandorafms.com/community/ for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
/**
* Return array with macros of agent like core.pm
*
* @param interger $id_agente Id agent to return data.
*
* @return array Array with all macros.
*/
function return_agent_macros($id_agente)
{
global $config;
$array_macros = [];
$grupo = [];
$agente = db_get_row_sql(
'SELECT * FROM tagente WHERE id_agente = '.$id_agente
);
if (isset($agente['id_grupo'])) {
$grupo = db_get_row_sql(
'SELECT * FROM tgrupo WHERE id_grupo = '.$agente['id_grupo']
);
}
if (isset($agente['server_name'])) {
$server_ip = db_get_row_sql(
'SELECT ip_address FROM tserver WHERE name = "'.$agente['server_name'].'"'
)['id_address'];
}
$array_macros = [
'_agentname_' => ($agente['nombre']) ?: '',
'_agentalias_' => ($agente['alias']) ?: '',
'_agent_' => ($agente['alias']) ?: (($agente['nombre']) ?: ''),
'_agentcustomid_' => ($agente['custom_id']) ?: '',
'_agentdescription_' => ($agente['comentarios']) ?: '',
'_agentgroup_' => ($grupo['nombre']) ?: '',
'_agentos_' => ($agente['id_os']) ?: '',
'_address_' => ($agente['direccion']) ?: '',
'_homeurl_' => ($config['public_url']) ?: '',
'_groupcontact_' => ($agente['contact']) ?: '',
'_groupcustomid_' => ($agente['custom_id']) ?: '',
'_groupother_' => ($agente['other']) ?: '',
'_server_ip_' => ($server_ip) ?: '',
'_server_name_' => ($agente['server_name']) ?: '',
];
return $array_macros;
}

View File

@ -330,7 +330,7 @@ function menu_print_menu(&$menu)
if (isset($sub['type']) && $sub['type'] == 'direct') {
// This is an external link.
$submenu_output .= '<li title="'.$sub['id'].'" id="'.str_replace(' ', '_', $sub['id']).'" class="'.$class.'">';
$submenu_output .= '<li title="'.$sub['text'].'" id="'.str_replace(' ', '_', $sub['id']).'" class="'.$class.'">';
if (isset($sub['subtype']) && $sub['subtype'] == 'nolink') {
$submenu_output .= '<div class=" SubNoLink '.$sub_tree_class.'"><span class="w70p span_has_menu_text">'.$sub['text'].'</span><div class="w21p arrow_menu_down"></div></div>';
@ -875,6 +875,7 @@ function menu_pepare_acl_select_data($pages, $sec)
if (is_ajax()) {
$about = (bool) get_parameter('about');
$about_operation = (bool) get_parameter('about_operation');
$why_enterprise = (bool) get_parameter('why_enterprise');
if ($about) {
global $config;
global $pandora_version;
@ -1003,7 +1004,7 @@ if (is_ajax()) {
$dialogButtons = [];
$dialogButtons[] = html_print_button(
__('Update manager'),
__('Warp update'),
'update_manager',
false,
'location.href="'.ui_get_full_url('/index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=history', false, false, false).'"',
@ -1107,10 +1108,10 @@ if (is_ajax()) {
</tr>
<tr class="about-last-tr">
<th style="width: 50%;">
<p class="about-last-p"><span>'.$db_info->data->dbSize->name.'</span></p>
<p class="about-last-p"><span>'.$db_info->data->dbVersion->name.'</span></p>
</th>
<th style="width: 50%;">
<p class="about-last-p" style="font-size: 10pt;">'.$db_info->data->dbSize->value.'</p>
<p class="about-last-p" style="font-size: 10pt;">'.$db_info->data->dbVersion->value.'</p>
</th>
</tr>
@ -1170,6 +1171,14 @@ if (is_ajax()) {
<p style="font-size: 10pt;">'.$sys_info->data->ramInfo->value.'</p>
</th>
</tr>
<tr>
<th style="width: 15%;">
<p><span>'.$sys_info->data->distroInfo->name.'</span></p>
</th>
<th style="width: 85%;">
<p style="font-size: 10pt;">'.$sys_info->data->distroInfo->value.'</p>
</th>
</tr>
<tr>
<th style="width: 15%;">
<p><span>'.$sys_info->data->osInfo->name.'</span></p>
@ -1362,4 +1371,50 @@ if (is_ajax()) {
echo $dialog;
}
if ($why_enterprise) {
global $config;
global $pandora_version;
$product_name = io_safe_output(get_product_name());
$lts_name = '';
if (empty($config['lts_name']) === false) {
$lts_name = ' <i>'.$config['lts_name'].'</i>';
}
$image_about = ui_get_full_url('/images/custom_logo/logo-default-pandorafms-collapsed.svg', false, false, false);
$url_why_enterprise = 'https://pandorafms.com/en/why-enterprise/';
$lang = users_get_user_by_id($config['id_user'])['language'];
if ($lang === 'es') {
$url_why_enterprise = 'https://pandorafms.com/es/por-que-pandora-fms-enterprise/';
}
$dialog = '
<div id="about-tabs" class="overflow-hidden">
<div id="tab-general-view">
<table class="table-about">
<tbody>
<tr>
<th style="width: 40%; border: 0px;">
<a href="https://pandorafms.com/" target="_blank">
<img src="'.$image_about.'" alt="logo" width="50%">
</a>
</th>
<th style="width: 60%; text-align: left; border: 0px;">
<h1>'.$product_name.'</h1>
<p><span>'.__('Version').' '.$pandora_version.$lts_name.' - '.(enterprise_installed() ? 'Enterprise' : 'Community').'</span></p>
<p>'.__('You are using the free, OpenSource version of Pandora FMS.').'</p>
<p>'.__('This version has no official support or warranty, you can purchase the Enterprise version, which offers support, warranty and additional features to the Opensource version.').'</p>
<p><span><a href="'.$url_why_enterprise.'">'.__('Click on this link for more information.').'</a></span></p>
</th>
</tr>
</tbody>
</table>
<p class="trademark-copyright">Trademark and copyright 2004 - '.date('Y').' <a href="https://pandorafms.com/" target="_blank">Pandora FMS</a>. All rights reserved</p>
</div>
</div>
';
echo $dialog;
}
}

View File

@ -251,6 +251,11 @@ function modules_copy_agent_module_to_agent($id_agent_module, $id_destiny_agent,
unset($new_module['id_agente_modulo']);
unset($new_module['id_agente']);
// Set debug content.
if (empty($new_module['debug_content']) === false) {
$new_module['debug_content'] = str_replace("'", '"', $new_module['debug_content']);
}
$id_new_module = modules_create_agent_module(
$id_destiny_agent,
$new_module['nombre'],
@ -2619,12 +2624,26 @@ function modules_get_agentmodule_data_for_humans($module)
$salida = human_milliseconds_to_string($module['datos']);
}
} else {
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator']));
$salida = remove_right_zeros(
number_format(
$module['datos'],
$config['graph_precision'],
$config['decimal_separator'],
($config['thousand_separator'] ?? null)
)
);
}
break;
default:
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator']));
$salida = remove_right_zeros(
number_format(
$module['datos'],
$config['graph_precision'],
$config['decimal_separator'],
($config['thousand_separator'] ?? null)
)
);
break;
}
break;
@ -2643,12 +2662,26 @@ function modules_get_agentmodule_data_for_humans($module)
$salida = human_milliseconds_to_string($module['datos']);
}
} else {
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator']));
$salida = remove_right_zeros(
number_format(
$module['datos'],
$config['graph_precision'],
$config['decimal_separator'],
($config['thousand_separator'] ?? null)
)
);
}
break;
default:
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator']));
$salida = remove_right_zeros(
number_format(
$module['datos'],
$config['graph_precision'],
$config['decimal_separator'],
($config['thousand_separator'] ?? null)
)
);
break;
}
}
@ -2930,7 +2963,14 @@ function modules_get_status($id_agent_module, $db_status, $data, &$status, &$tit
}
if (is_numeric($data)) {
$title .= ': '.remove_right_zeros(number_format($data, $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator']));
$title .= ': '.remove_right_zeros(
number_format(
$data,
$config['graph_precision'],
$config['decimal_separator'],
($config['thousand_separator'] ?? null)
)
);
} else {
$text = io_safe_output($data);
@ -3761,7 +3801,7 @@ function get_modules_agents(
$return = array_reduce(
$modules[$tserver],
function ($carry, $item) use ($tserver, $nodes) {
function ($carry, $item) use ($tserver, $nodes, $selection) {
$t = [];
foreach ($item as $k => $v) {
$t[$k] = $v;
@ -3769,9 +3809,15 @@ function get_modules_agents(
$t['id_node'] = $tserver;
if ($nodes[$tserver] !== null) {
$t['nombre'] = io_safe_output(
$nodes[$tserver]->server_name().' &raquo; '.$t['nombre']
);
if (isset($t['alias']) === true && (bool) $selection === true) {
$t['nombre'] = io_safe_output(
$nodes[$tserver]->server_name().' &raquo; '.$t['alias'].' &raquo; '.$t['nombre']
);
} else {
$t['nombre'] = io_safe_output(
$nodes[$tserver]->server_name().' &raquo; '.$t['nombre']
);
}
}
$carry[] = $t;
@ -3805,9 +3851,23 @@ function get_modules_agents(
$selection,
false,
$useName,
false,
true,
$notStringModules
);
$modules = array_reduce(
$modules,
function ($carry, $item) use ($id_agents, $selection) {
if (count($id_agents) > 1 && (bool) $selection === true) {
$carry[$item['id_agente_modulo']] = $item['alias'].' &raquo; '.$item['nombre'];
} else {
$carry[$item['id_agente_modulo']] = $item['nombre'];
}
return $carry;
},
[]
);
}
return $modules;
@ -4765,7 +4825,231 @@ function export_agents_module_csv($filters)
/**
* Check if modules are compatible with MADE server.
* Function to return Mean Time Between Failure, Mean Time To Solution (in seconds)
* and Availability of a module
*
* @param string $datetime_from Start time of the interval.
*
* @param string $datetime_to End time of the interval.
*
* @param string $id_agentmodule id_agentmodule of the module
*
* @return array Returns an array with the data
*/
function service_level_module_data($datetime_from, $datetime_to, $id_agentmodule)
{
$data = [];
$data['mtbf'] = false;
$data['mtrs'] = false;
$data['availability'] = false;
$data['critical_events'] = false;
$data['warning_events'] = false;
$data['last_status_change'] = false;
$data['module_name'] = false;
$availability = 0;
$type = '';
if ((bool) is_metaconsole() === true) {
if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) {
$server_id = [];
$server_id['id'] = explode('|', $id_agentmodule)[0];
$id_agentmodule = explode('|', $id_agentmodule)[1];
$server_name = db_get_row_filter('tmetaconsole_setup', $server_id, 'server_name');
$connection = metaconsole_get_connection($server_name);
if (metaconsole_load_external_db($connection) !== NOERR) {
// Restore db connection.
metaconsole_restore_db();
return $data;
}
}
}
$uncompressed_data = db_uncompress_module_data(
$id_agentmodule,
$datetime_from,
$datetime_to
);
$first_utimestamp = 0;
foreach ($uncompressed_data as $data_module) {
foreach ($data_module['data'] as $subdata) {
if (!empty($subdata['datos'])) {
$first_utimestamp = $subdata['utimestamp'];
if (isset($subdata['type'])) {
$type = $subdata['type'];
}
break;
}
}
}
$interval_time = ($datetime_to - $datetime_from);
$current_time = time();
$sql = 'SELECT utimestamp, event_type FROM tevento
WHERE id_agentmodule = '.$id_agentmodule.'
AND utimestamp >= '.$datetime_from.'
AND utimestamp <= '.$datetime_to.'
ORDER BY utimestamp DESC';
$events_time = db_get_all_rows_sql($sql);
// Count events.
$sql = 'SELECT COUNT(*) as critical_events FROM tevento
WHERE id_agentmodule= '.$id_agentmodule.'
AND utimestamp >= '.$datetime_from.'
AND utimestamp <= '.$datetime_to.'
AND (event_type = "going_up_critical" OR event_type = "going_down_critical")';
$critical_events = db_get_sql($sql);
$sql = 'SELECT COUNT(*) as warning_events FROM tevento
WHERE id_agentmodule= '.$id_agentmodule.'
AND utimestamp >= '.$datetime_from.'
AND utimestamp <= '.$datetime_to.'
AND (event_type = "going_up_warning" OR event_type = "going_down_warning")';
$warning_events = db_get_sql($sql);
if ($events_time !== false && count($events_time) > 0) {
$failed_event = [];
$normal_event = [];
$events_time = array_reverse($events_time);
$mtrs_events = [];
foreach ($events_time as $key => $event) {
if ($event['event_type'] === 'going_up_critical' || $event['event_type'] === 'going_down_critical') {
$failed_event[] = $event['utimestamp'];
$mtrs_events[]['failed_event'] = $event['utimestamp'];
}
if ($event['event_type'] === 'going_up_normal'
|| $event['event_type'] === 'going_down_normal'
|| $event['event_type'] === 'going_up_warning'
|| $event['event_type'] === 'going_down_warning'
) {
$normal_event[] = $event['utimestamp'];
$mtrs_events[]['normal_event'] = $event['utimestamp'];
}
}
$process_mtrs_events = [];
if (empty($mtrs_events) === false) {
$last_event_key = '';
foreach ($mtrs_events as $key => $val) {
if (key($val) !== $last_event_key) {
$last_event_key = key($val);
$process_mtrs_events[] = $val;
}
}
}
$mtrs_array = [];
if (empty($normal_event) === true) {
$mtrs_array[] = ($current_time - $failed_event[0]);
} else if (empty($failed_event) === true) {
$mtrs_array[] = 0;
} else {
$last_value = '';
foreach ($process_mtrs_events as $key => $val) {
$current_value = $val[key($val)];
if ($last_value !== '') {
$mtrs_array[] = ($current_value - $last_value);
}
$last_value = $current_value;
}
$last_mtrs_event = key(end($process_mtrs_events));
if ($last_mtrs_event === 'failed_event') {
$mtrs_array[] = ($current_time - $last_value);
}
}
$mtbf_array = [];
if (!empty($failed_event) === true) {
if (count($failed_event) > 1) {
for ($i = 1; $i <= array_key_last($failed_event); $i++) {
$mtbf_array[] = ($failed_event[$i] - ($failed_event[($i - 1)]));
}
} else {
$mtbf_array[] = 0;
}
} else {
$mtbf_array[] = 0;
}
$total_time_failed = array_sum($mtrs_array);
$total_time_ok = ($interval_time - $total_time_failed);
if (count($events_time) === 1) {
if ((int) $first_utimestamp !== 0) {
$availability = round((($total_time_ok / $interval_time) * 100), 2);
}
} else {
$availability = round((($total_time_ok / $interval_time) * 100), 2);
}
if ($critical_events > 1) {
$mtbf = round(array_sum($mtbf_array) / count($mtbf_array));
} else {
$mtbf = false;
}
if (count($mtrs_array) === 1 && (int) $first_utimestamp !== 0) {
$mtrs = round($total_time_failed / count($mtrs_array));
} else if (count($mtrs_array) > 1 && (int) $first_utimestamp !== 0) {
$mtrs = round((array_sum($mtrs_array) / count($mtrs_array)));
} else {
$mtrs = false;
}
$data['mtbf'] = $mtbf;
$data['mtrs'] = $mtrs;
$data['availability'] = $availability;
} else {
$data['mtbf'] = false;
$data['mtrs'] = false;
$data['availability'] = false;
}
// Get last status change.
$sql = 'SELECT last_status_change FROM tagente_estado
WHERE id_agente_modulo = '.$id_agentmodule.' ';
$last_status_change = db_get_sql($sql);
// Get module name.
/*
$sql = 'SELECT nombre FROM tagente_modulo
WHERE id_agente_modulo = '.$id_agentmodule;*/
$sql = 'SELECT tagente_modulo.nombre as nombre, tagente.alias as alias
FROM tagente_modulo INNER JOIN tagente
ON tagente_modulo.id_agente = tagente.id_agente
WHERE id_agente_modulo = '.$id_agentmodule.' ';
$sql_query = db_get_all_rows_sql($sql);
$data['critical_events'] = $critical_events;
$data['warning_events'] = $warning_events;
$data['last_status_change'] = $last_status_change;
$data['module_name'] = $sql_query[0]['nombre'];
if ((bool) is_metaconsole() === true) {
$data['agent_alias'] = $server_name['server_name'].' » '.$sql_query[0]['alias'];
} else {
$data['agent_alias'] = $sql_query[0]['alias'];
}
if ((bool) is_metaconsole() === true) {
metaconsole_restore_db();
}
return $data;
}
/*
Check if modules are compatible with MADE server.
*
* @param integer $id_tipo_modulo
* @retur boolean True if compatible, false otherwise.

View File

@ -1066,7 +1066,7 @@ function notification_filter()
break;
case 'UPDATEMANAGER':
$type_name = 'UPDATE MANAGER';
$type_name = 'WARP UPDATE';
break;
case 'ALLOWOVERRIDE':

View File

@ -804,6 +804,13 @@ function reporting_make_reporting_data(
);
break;
case 'service_level':
$report['contents'][] = reporting_service_level_detail(
$report,
$content
);
break;
case 'end_of_life':
$report['contents'][] = reporting_end_of_life(
$report,
@ -966,7 +973,15 @@ function reporting_make_reporting_data(
break;
case 'ncm':
$report['contents'][] = reporting_ncm_config(
$report['contents'][] = reporting_ncm_list(
$report,
$content,
$pdf
);
break;
case 'ncm_backups':
$report['contents'][] = reporting_ncm_backups(
$report,
$content,
$pdf
@ -1024,6 +1039,62 @@ function reporting_make_reporting_data(
);
break;
case 'vuls_severity_graph':
$report['contents'][] = reporting_vuls_severity_graph(
$report,
$content,
$type
);
break;
case 'vuls_attack_complexity':
$report['contents'][] = reporting_vuls_attack_complexity_graph(
$report,
$content,
$type
);
break;
case 'vuls_by_packages':
$report['contents'][] = reporting_vuls_by_packages_graph(
$report,
$content,
$type
);
break;
case 'vuls_by_agent':
$report['contents'][] = reporting_vuls_by_agent(
$report,
$content,
$type
);
break;
case 'vuls_info_agent':
$report['contents'][] = reporting_vuls_info_agent(
$report,
$content,
$type
);
break;
case 'top_n_agents_vuls':
$report['contents'][] = reporting_top_n_agents_vuls(
$report,
$content,
$type
);
break;
case 'top_n_vuls_count':
$report['contents'][] = reporting_top_n_vuls_count(
$report,
$content,
$type
);
break;
default:
// Default.
break;
@ -3651,6 +3722,60 @@ function reporting_agent_module_status($report, $content)
}
/**
* Service level detail
*
* @param array $report Info Report.
* @param array $content Info content.
*
* @return array
*/
function reporting_service_level_detail($report, $content)
{
global $config;
$return['type'] = 'service_level';
$module_data = [];
$interval_range = [];
$service_level_data = [];
$current_timestamp = time();
$return['title'] = io_safe_output($content['name']);
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['description'] = io_safe_output($content['description']);
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
$es = json_decode($content['external_source'], true);
$return['date'] = [];
$return['date']['date'] = false;
$return['date']['period'] = $es['period_time_service_level'];
$return['show_agents'] = $es['show_agents'];
$modules = json_decode(base64_decode($es['module']), true);
$agents = json_decode(base64_decode($es['id_agents']), true);
$interval_range['start'] = ($current_timestamp - $es['period_time_service_level']);
$interval_range['end'] = $current_timestamp;
foreach ($modules as $module) {
$service_level_data = service_level_module_data($interval_range['start'], $interval_range['end'], $module);
$module_data[$module] = [];
$module_data[$module]['mtrs'] = ($service_level_data['mtrs'] !== false) ? human_milliseconds_to_string(($service_level_data['mtrs'] * 100), 'short') : '-';
$module_data[$module]['mtbf'] = ($service_level_data['mtbf'] !== false) ? human_milliseconds_to_string(($service_level_data['mtbf'] * 100), 'short') : '-';
$module_data[$module]['availability'] = ($service_level_data['availability'] !== false) ? $service_level_data['availability'] : '100';
$module_data[$module]['warning_events'] = ($service_level_data['warning_events'] !== false) ? $service_level_data['warning_events'] : '0';
$module_data[$module]['critical_events'] = ($service_level_data['critical_events'] !== false) ? $service_level_data['critical_events'] : '0';
$module_data[$module]['last_status_change'] = ($service_level_data['last_status_change'] !== false) ? $service_level_data['last_status_change'] : '';
$module_data[$module]['module_name'] = ($service_level_data['module_name'] !== false) ? $service_level_data['module_name'] : '';
$module_data[$module]['agent_alias'] = ($service_level_data['agent_alias'] !== false) ? $service_level_data['agent_alias'] : '';
}
$return['data'] = $module_data;
return reporting_check_structure_content($return);
}
/**
* OS Version End of Life
*
@ -13642,38 +13767,47 @@ function reporting_tiny_stats(
}
if ($modern === true) {
$out .= '<div id="bullets_modules">';
if (isset($fired_count) && $fired_count > 0) {
$out .= '<div class="bullets_modules">';
$out .= '<div><div id="fired_count_'.$uniq_id.'" class="forced_title bullet_modules orange_background"></div>';
$out .= '<span class="font_12pt">'.$fired_count.'</span></div>';
$out .= '</div>';
}
if (isset($critical_count) && $critical_count > 0) {
$out .= '<div class="bullets_modules">';
$out .= '<div><div id="critical_count_'.$uniq_id.'" class="forced_title bullet_modules red_background"></div>';
$out .= '<span class="font_12pt">'.$critical_count.'</span></div>';
$out .= '</div>';
}
if (isset($warning_count) && $warning_count > 0) {
$out .= '<div class="bullets_modules">';
$out .= '<div><div id="warning_count_'.$uniq_id.'" class="forced_title bullet_modules yellow_background"></div>';
$out .= '<span class="font_12pt">'.$warning_count.'</span></div>';
$out .= '</div>';
}
if (isset($unknown_count) && $unknown_count > 0) {
$out .= '<div class="bullets_modules">';
$out .= '<div><div id="unknown_count_'.$uniq_id.'" class="forced_title bullet_modules grey_background"></div>';
$out .= '<span class="font_12pt">'.$unknown_count.'</span></div>';
$out .= '</div>';
}
if (isset($not_init_count) && $not_init_count > 0) {
$out .= '<div class="bullets_modules">';
$out .= '<div><div id="not_init_count_'.$uniq_id.'" class="forced_title bullet_modules blue_background"></div>';
$out .= '<span class="font_12pt">'.$not_init_count.'</span></div>';
$out .= '</div>';
}
if (isset($normal_count) && $normal_count > 0) {
$out .= '<div class="bullets_modules">';
$out .= '<div><div id="normal_count_'.$uniq_id.'" class="forced_title bullet_modules green_background"></div>';
$out .= '<span class="font_12pt">'.$normal_count.'</span></div>';
$out .= '</div>';
}
$out .= '</div>';
} else {
// Classic ones.
$out .= '<b><span id="total_count_'.$uniq_id.'" class="forced_title" >'.$total_count.'</span>';
@ -15921,171 +16055,174 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
return false;
}
$module_interval = modules_get_interval(
$content['id_agent_module']
);
$slice = ($content['period'] / $module_interval);
if ($metaconsole_on && $server_name != '') {
// Restore db connection.
metaconsole_restore_db();
}
$result_sla = reporting_advanced_sla(
$content['id_agent_module'],
($report['datetime'] - $content['period']),
$report['datetime'],
null,
null,
$filter = [
'id_agentmodule' => $content['id_agent_module'],
'group_rep' => EVENT_GROUP_REP_ALL,
'date_to' => date('Y-m-d', ($report['datetime'] - $content['period'])),
'time_to' => date('H:i:s', ($report['datetime'] - $content['period'])),
];
if ($metaconsole_on && $server_name != '') {
$filter['id_server'] = $connection['id'];
}
$previous_event = events_get_all(
['te.event_type, te.timestamp, te.utimestamp'],
$filter,
0,
null,
null,
null,
$slice,
1,
'desc',
'timestamp',
true
);
// Select Warning and critical values.
$agentmodule_info = modules_get_agentmodule($content['id_agent_module']);
$min_value_critical = ($agentmodule_info['min_critical'] == 0) ? null : $agentmodule_info['min_critical'];
$status = '';
if ($previous_event !== false) {
$previous_event = end($previous_event);
$status = $previous_event['event_type'];
}
// Check if module type is string.
$modules_is_string = modules_is_string($agentmodule_info['id_agente_modulo']);
$date_start = ($report['datetime'] - $content['period']);
$filter = [
'id_agentmodule' => $content['id_agent_module'],
'group_rep' => EVENT_GROUP_REP_ALL,
'date_from' => date('Y-m-d', $date_start),
'date_to' => date('Y-m-d', $report['datetime']),
'time_from' => date('H:i:s', $date_start),
'time_to' => date('H:i:s', $report['datetime']),
];
if ($modules_is_string === false) {
if ($agentmodule_info['max_critical'] == 0) {
$max_value_critical = null;
if ($agentmodule_info['min_critical'] == 0) {
if ((bool) $content['dinamic_proc'] === true) {
$max_value_critical = 0.01;
}
if ($metaconsole_on && $server_name != '') {
$filter['id_server'] = $connection['id'];
}
$events = events_get_all(
['te.event_type, te.timestamp, te.utimestamp'],
$filter,
null,
null,
null,
null,
true
);
// Metaconsole connection.
if ($metaconsole_on && $server_name != '') {
$connection = metaconsole_get_connection($server_name);
if (!metaconsole_load_external_db($connection)) {
ui_print_error_message('Error connecting to '.$server_name);
}
}
$not_init_data = [];
$previous_data = [
'event_type' => $status,
'utimestamp' => $date_start,
];
if (empty($status) === true) {
// 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);
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;
}
// Si se encuentra algun dato.
// Si no hay eventos, la fecha del primer dato no sea mayor al fin del report (seria un bloque completo de no iniciado).
// Se comprueba que si existen eventos el dato no sea previo al evento.
if ($first_utimestamp !== false
&& ((empty($events) === true && $first_utimestamp < $report['datetime']) || (empty($events) === false && $first_utimestamp < $events[0]['utimestamp']))
) {
// Tenemos en cuenta si el modulo es de tipo string.
$module = modules_get_agentmodule($content['id_agent_module']);
$module_type = $module['id_tipo_modulo'];
$module_type_str = modules_get_type_name($module_type);
$table = 'tagente_datos';
if (strstr($module_type_str, 'string') !== false) {
$table = 'tagente_datos_string';
}
$query = sprintf(
'SELECT datos,utimestamp
FROM %s
WHERE id_agente_modulo = %d
AND utimestamp = %d
',
$table,
$content['id_agent_module'],
$first_utimestamp
);
$data = db_get_all_rows_sql($query, $search_historydb);
if ($data !== false) {
$not_init_data = [
'event_type' => $status,
'utimestamp' => $date_start,
];
$previous_data = [
'event_type' => 'going_up_normal',
'utimestamp' => $data[0]['utimestamp'],
];
}
} else {
$max_value_critical = $agentmodule_info['max_critical'];
}
} else {
if ($agentmodule_info['str_critical'] == '') {
$max_value_critical = null;
} else {
$max_value_critical = $agentmodule_info['str_critical'];
}
}
$inverse_critical = $agentmodule_info['critical_inverse'];
$min_value_warning = ($agentmodule_info['min_warning'] == 0) ? null : $agentmodule_info['min_warning'];
if ($modules_is_string === false) {
if ($agentmodule_info['max_warning'] == 0) {
$max_value_warning = null;
} else {
$max_value_warning = $agentmodule_info['max_warning'];
}
} else {
if ($agentmodule_info['str_warning'] == '') {
$max_value_warning = null;
} else {
$max_value_warning = $agentmodule_info['str_warning'];
}
$array_result = [];
$time_total = $content['period'];
$check_total = 0;
$check_ok = 0;
$time_ok = 0;
if (empty($events) === true) {
$events = [];
}
$inverse_warning = $agentmodule_info['warning_inverse'];
// Añadimos el dato previo.
array_unshift($events, $previous_data);
if (empty($not_init_data) === false) {
// Añadimos si viene de no iniciado el no iniciado.
array_unshift($events, $not_init_data);
}
$data = [];
$data['time_total'] = 0;
$data['time_ok'] = 0;
$data['time_error'] = 0;
$data['time_warning'] = 0;
$data['time_unknown'] = 0;
$data['time_not_init'] = 0;
$data['time_downtime'] = 0;
$data['checks_total'] = 0;
$data['checks_ok'] = 0;
$data['checks_error'] = 0;
$data['checks_warning'] = 0;
$data['checks_unknown'] = 0;
$data['checks_not_init'] = 0;
$array_graph = [];
$current_time = time();
$i = 0;
foreach ($result_sla as $value_sla) {
$data['time_total'] += $value_sla['time_total'];
$data['time_ok'] += $value_sla['time_ok'];
$data['time_error'] += $value_sla['time_error'];
$data['time_warning'] += $value_sla['time_warning'];
$data['time_unknown'] += $value_sla['time_unknown'];
$data['time_downtime'] += $value_sla['time_downtime'];
$data['time_not_init'] += $value_sla['time_not_init'];
$data['checks_total'] += $value_sla['checks_total'];
$data['checks_ok'] += $value_sla['checks_ok'];
$data['checks_error'] += $value_sla['checks_error'];
$data['checks_warning'] += $value_sla['checks_warning'];
$data['checks_unknown'] += $value_sla['checks_unknown'];
$data['checks_not_init'] += $value_sla['checks_not_init'];
// Generate raw data for graph.
if ($value_sla['time_total'] != 0) {
if ($value_sla['time_error'] > 0) {
// ERR.
$array_graph[$i]['data'] = 3;
} else if ($value_sla['time_unknown'] > 0) {
// UNKNOWN.
$array_graph[$i]['data'] = 4;
} else if ($value_sla['time_warning'] > 0) {
// Warning.
$array_graph[$i]['data'] = 2;
} else if ($value_sla['time_not_init'] == $value_sla['time_total']) {
// NOT INIT.
$array_graph[$i]['data'] = 6;
} else {
$array_graph[$i]['data'] = 1;
}
foreach ($events as $event) {
$array_result[$i]['data'] = events_status_module_event_type($event['event_type']);
if (isset($events[($i + 1)]) === true) {
$period = ($events[($i + 1)]['utimestamp'] - $event['utimestamp']);
$array_result[$i]['utimestamp'] = $period;
} else {
$array_graph[$i]['data'] = 7;
$period = ($report['datetime'] - $event['utimestamp']);
// El ultimo evento solo lo arrastramos hasta la fecha actual.
// Si pedimos mas fecha sera desconocido.
if ($report['datetime'] > $current_time) {
$period = ($current_time - $event['utimestamp']);
}
$array_result[$i]['utimestamp'] = $period;
}
$array_graph[$i]['utimestamp'] = ($value_sla['date_to'] - $value_sla['date_from']);
if ($array_result[$i]['data'] === AGENT_MODULE_STATUS_NORMAL) {
$check_ok++;
$time_ok += $period;
}
$check_total++;
$i++;
}
$data['sla_value'] = reporting_sla_get_compliance_from_array(
$data
);
$data['sla_fixed'] = sla_truncate(
$data['sla_value'],
$config['graph_precision']
);
$data_init = -1;
$acum = 0;
$sum = 0;
$array_result = [];
$i = 0;
foreach ($array_graph as $value) {
if ($data_init == -1) {
$data_init = $value['data'];
$acum = $value['utimestamp'];
} else {
if ($data_init == $value['data']) {
$acum = ($acum + $value['utimestamp']);
} else {
$array_result[$i]['data'] = $data_init;
$array_result[$i]['utimestamp'] = $acum;
$array_result[$i]['real_data'] = $sum;
$i++;
$data_init = $value['data'];
$acum = $value['utimestamp'];
}
}
// Bloque por si se pide mas fecha.
if ($report['datetime'] > $current_time) {
$array_result[$i]['data'] = AGENT_MODULE_STATUS_UNKNOWN;
$array_result[$i]['utimestamp'] = ($report['datetime'] - $current_time);
}
if (count($array_result) == 0) {
$array_result = $array_graph;
} else {
$array_result[$i]['data'] = $data_init;
$array_result[$i]['utimestamp'] = $acum;
$array_result[$i]['real_data'] = $sum;
}
$time_total = $data['time_total'];
// Slice graphs calculation.
$return['agent'] = modules_get_agentmodule_agent_alias(
$content['id_agent_module']
);
@ -16093,37 +16230,21 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
$content['id_agent_module']
);
$return['max_critical'] = $max_value_critical;
$return['min_critical'] = $min_value_critical;
$return['critical_inverse'] = $inverse_critical;
$return['max_warning'] = $max_value_warning;
$return['min_warning'] = $min_value_warning;
$return['warning_inverse'] = $inverse_warning;
$return['data_not_init'] = $data['checks_not_init'];
$return['data_unknown'] = $data['checks_unknown'];
$return['data_critical'] = $data['checks_error'];
$return['data_warning'] = $data['checks_warning'];
$return['data_ok'] = $data['checks_ok'];
$return['data_total'] = $data['checks_total'];
$return['time_not_init'] = $data['time_not_init'];
$return['time_unknown'] = $data['time_unknown'];
$return['time_critical'] = $data['time_error'];
$return['time_warning'] = $data['time_warning'];
$return['time_ok'] = $data['time_ok'];
if ($data['checks_total'] > 0) {
$return['percent_ok'] = (($data['checks_ok'] * 100) / $data['checks_total']);
$return['data_ok'] = $check_ok;
$return['data_total'] = $check_total;
if ($check_total > 0) {
$return['percent_ok'] = (($time_ok * 100) / $content['period']);
} else {
$return['percent_ok'] = 0;
}
$colors = [
1 => COL_NORMAL,
2 => COL_WARNING,
3 => COL_CRITICAL,
4 => COL_UNKNOWN,
5 => COL_DOWNTIME,
6 => COL_NOTINIT,
7 => COL_IGNORED,
AGENT_MODULE_STATUS_CRITICAL_ALERT => COL_ALERTFIRED,
AGENT_MODULE_STATUS_NORMAL => COL_NORMAL,
AGENT_MODULE_STATUS_UNKNOWN => COL_UNKNOWN,
AGENT_MODULE_STATUS_WARNING => COL_WARNING,
AGENT_MODULE_STATUS_CRITICAL_BAD => COL_CRITICAL,
AGENT_MODULE_STATUS_NOT_INIT => COL_NOTINIT,
];
$width_graph = 100;

View File

@ -260,7 +260,6 @@ function reporting_html_print_report($report, $mini=false, $report_info=1, $cust
}
$table->colspan['description_row']['description'] = 3;
switch ($item['type']) {
case 'availability':
default:
@ -403,6 +402,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1, $cust
reporting_html_agent_module_status($table, $item);
break;
case 'service_level':
reporting_html_service_level($table, $item);
break;
case 'end_of_life':
reporting_html_end_of_life($table, $item);
break;
@ -477,7 +480,11 @@ function reporting_html_print_report($report, $mini=false, $report_info=1, $cust
break;
case 'ncm':
reporting_html_ncm_config($table, $item);
reporting_html_ncm_list($table, $item);
break;
case 'ncm_backups':
reporting_html_ncm_backups($table, $item);
break;
case 'top_n_agents_sh':
@ -507,6 +514,34 @@ function reporting_html_print_report($report, $mini=false, $report_info=1, $cust
case 'evolution':
reporting_evolution_graph($table, $item);
break;
case 'vuls_severity_graph':
reporting_html_vuls_severity_graph($table, $item);
break;
case 'vuls_attack_complexity':
reporting_html_vuls_attack_complexity($table, $item);
break;
case 'vuls_by_packages':
reporting_html_vuls_by_packages($table, $item);
break;
case 'vuls_by_agent':
reporting_html_vuls_by_agent($table, $item);
break;
case 'vuls_info_agent':
reporting_html_vuls_info_agent($table, $item);
break;
case 'top_n_agents_vuls':
reporting_html_top_n_agents_vuls($table, $item);
break;
case 'top_n_vuls_count':
reporting_html_top_n_vuls_count($table, $item);
break;
}
if ($item['type'] == 'agent_module') {
@ -522,6 +557,300 @@ function reporting_html_print_report($report, $mini=false, $report_info=1, $cust
}
/**
* Function to print top vulnerabiries more common.
*
* @param object $table Head table or false if it comes from pdf.
* @param array $item Items data.
* @param integer $pdf Flag for return table.
*
* @return mixed
*/
function reporting_html_top_n_vuls_count($table, $item, $pdf=0)
{
global $config;
$table->width = '99%';
$table->styleTable = 'border: 0px;';
$table->colspan[2][0] = 3;
$table1 = new stdClass();
$table1->headstyle = [];
$table1->width = '99%';
$table1->class = 'info_table';
$table1->titleclass = 'title_table_pdf';
$table1->rowclass[0] = '';
$table1->head[0] = __('Vulnerability');
$table1->head[2] = __('Total');
$row = 2;
foreach ($item['data'] as $key => $vul) {
$table1->data[$row][0] = $vul['cve_id'];
$table1->data[$row][2] = $vul['count'];
$row++;
}
if ($pdf === 1) {
$table1->title = $item['title'];
$table1->titleclass = 'title_table_pdf';
$table1->titlestyle = 'text-align:left;';
}
$table->data[2][0] = html_print_table($table1, true);
if ($pdf === 1) {
return html_print_table($table, true);
}
}
/**
* Function to print top agents with worst score.
*
* @param object $table Head table or false if it comes from pdf.
* @param array $item Items data.
* @param integer $pdf Flag for return table.
*
* @return mixed
*/
function reporting_html_top_n_agents_vuls($table, $item, $pdf=0)
{
global $config;
$table->width = '99%';
$table->styleTable = 'border: 0px;';
$table->colspan[2][0] = 3;
$table1 = new stdClass();
$table1->headstyle = [];
$table1->width = '99%';
$table1->class = 'info_table';
$table1->titleclass = 'title_table_pdf';
$table1->rowclass[0] = '';
$table1->head[0] = __('Agent');
$table1->head[2] = __('Risk');
$row = 2;
foreach ($item['data'] as $key => $agent) {
$table1->data[$row][0] = $agent['alias'];
$table1->data[$row][2] = $agent['score'];
$row++;
}
if ($pdf === 1) {
$table1->title = $item['title'];
$table1->titleclass = 'title_table_pdf';
$table1->titlestyle = 'text-align:left;';
}
$table->data[2][0] = html_print_table($table1, true);
if ($pdf === 1) {
return html_print_table($table, true);
}
}
/**
* Function to print vulnerabilities of agent.
*
* @param object $table Head table or false if it comes from pdf.
* @param array $item Items data.
* @param integer $pdf Flag for return table.
*
* @return mixed
*/
function reporting_html_vuls_info_agent($table, $item, $pdf=0)
{
$table->width = '99%';
$table->styleTable = 'border: 0px;';
$table->colspan[2][0] = 3;
$table1 = new stdClass();
$table1->headstyle[0] = 'text-align: left';
$table1->headstyle[1] = 'text-align: left';
$table1->headstyle[2] = 'text-align: left';
$table1->width = '99%';
$table1->class = 'info_table';
$table1->titleclass = 'title_table_pdf';
$table1->rowclass[0] = '';
$table1->head[0] = __('Name');
$table1->head[1] = __('CVE');
$table1->head[2] = __('Version');
$table1->head[3] = __('Score');
$table1->head[4] = __('Detection time');
$table1->head[5] = __('Severity');
$table1->head[6] = __('Version');
$table1->head[7] = __('Attack Vector');
$table1->head[8] = __('Attack Complexity');
$table1->head[9] = __('Privileges Required');
$table1->head[10] = __('User Interaction');
$table1->head[11] = __('Scope');
$table1->head[12] = __('Confidentiality');
$table1->head[13] = __('Integrity');
$table1->head[14] = __('Availability');
$row = 1;
foreach ($item['data'] as $key => $vul) {
$table1->data[$row][0] = (key_exists('name', $vul) === true) ? $vul['name'] : '';
$table1->data[$row][1] = (key_exists('cve', $vul) === true) ? $vul['cve'] : '';
$table1->data[$row][2] = (key_exists('version', $vul) === true) ? $vul['version'] : '';
$table1->data[$row][3] = (key_exists('score', $vul) === true) ? $vul['score'] : '';
$table1->data[$row][4] = (key_exists('detection_time', $vul) === true) ? $vul['detection_time'] : '';
$table1->data[$row][5] = (key_exists('severity', $vul) === true) ? $vul['severity'] : '';
$table1->data[$row][6] = (key_exists('CVSS', $vul) === true) ? $vul['CVSS'] : '';
$table1->data[$row][7] = (key_exists('AV', $vul) === true) ? $vul['AV'] : '';
$table1->data[$row][8] = (key_exists('AC', $vul) === true) ? $vul['AC'] : '';
$table1->data[$row][9] = (key_exists('PR', $vul) === true) ? $vul['PR'] : '';
$table1->data[$row][10] = (key_exists('UI', $vul) === true) ? $vul['UI'] : '';
$table1->data[$row][11] = (key_exists('S', $vul) === true) ? $vul['S'] : '';
$table1->data[$row][12] = (key_exists('C', $vul) === true) ? $vul['C'] : '';
$table1->data[$row][13] = (key_exists('I', $vul) === true) ? $vul['I'] : '';
$table1->data[$row][14] = (key_exists('A', $vul) === true) ? $vul['A'] : '';
$row++;
}
$table->data[2][0] = html_print_table($table1, true);
if ($pdf === 1) {
$table1->title = $item['title'];
$table1->titleclass = 'title_table_pdf';
$table1->titlestyle = 'text-align:left;';
return html_print_table($table1, true);
}
}
/**
* Function to print total vulnerabilities by packages in graph.
*
* @param object $table Head table or false if it comes from pdf.
* @param array $item Items data.
* @param integer $pdf Flag for return table.
*
* @return mixed
*/
function reporting_html_vuls_by_packages($table, $item, $pdf=0)
{
$table->rowclass[0] = '';
$table->colspan['chart']['cell'] = 3;
$table->cellstyle['chart']['cell'] = 'text-align: center;';
$table->data['chart']['cell'] = $item['chart'];
if ($pdf === 1) {
return html_print_table($table, true);
}
}
/**
* Function to print attack complexity in graph
*
* @param object $table Head table or false if it comes from pdf.
* @param array $item Items data.
* @param integer $pdf Flag for return table.
*
* @return mixed
*/
function reporting_html_vuls_attack_complexity($table, $item, $pdf=0)
{
$table->rowclass[0] = '';
$table->colspan['chart']['cell'] = 3;
$table->cellstyle['chart']['cell'] = 'text-align: center;';
$table->data['chart']['cell'] = html_print_div(
[
'content' => $item['chart'],
'style' => 'width: 450px; height: 300px; margin: 0 auto;',
],
true
);
if ($pdf === 1) {
return html_print_table($table, true);
}
}
/**
* Function to print the severity vuls in graph.
*
* @param object $table Head table or false if it comes from pdf.
* @param array $item Items data.
* @param integer $pdf Flag for return table.
*
* @return mixed
*/
function reporting_html_vuls_severity_graph($table, $item, $pdf=0)
{
$table->rowclass[0] = '';
$table->colspan['chart']['cell'] = 3;
$table->cellstyle['chart']['cell'] = 'text-align: center;';
$table->data['chart']['cell'] = $item['chart'];
if ($pdf === 1) {
return html_print_table($table, true);
}
}
/**
* Function to print the all vulnerabilities by agent.
*
* @param object $table Head table or false if it comes from pdf.
* @param array $item Items data.
* @param integer $pdf Flag for return table.
*
* @return mixed
*/
function reporting_html_vuls_by_agent($table, $item, $pdf=0)
{
$table->width = '99%';
$table->styleTable = 'border: 0px;';
$table->colspan[2][0] = 3;
$table1 = new stdClass();
$table1->headstyle[0] = 'text-align: left';
$table1->headstyle[1] = 'text-align: left';
$table1->headstyle[2] = 'text-align: left';
$table1->width = '99%';
$table1->class = 'info_table';
$table1->titleclass = 'title_table_pdf';
$table1->rowclass[0] = '';
$table1->head[0] = __('Agent');
$table1->head[1] = __('OS');
$table1->head[2] = __('OS Version');
$table1->head[3] = __('Group');
$table1->head[4] = __('Ip');
$table1->head[5] = __('Status');
$table1->head[6] = __('SecMon');
$table1->head[7] = __('Hardening');
$table1->head[8] = __('Vulnerability');
$table1->head[9] = __('Last contact');
$table1->head[10] = __('L.S. Change');
$row = 1;
foreach ($item['data'] as $key => $vul) {
$table1->data[$row][0] = $vul['alias'];
$table1->data[$row][2] = $vul['name'];
$table1->data[$row][3] = $vul['os_version'];
$table1->data[$row][4] = $vul['nombre_gr'];
$table1->data[$row][5] = $vul['direccion'];
$table1->data[$row][6] = $vul['status'];
$table1->data[$row][7] = $vul['secmon'];
$table1->data[$row][8] = $vul['hardening'];
$table1->data[$row][9] = $vul['vulnerabilities'];
$table1->data[$row][10] = $vul['ultimo_contacto'];
$table1->data[$row][11] = $vul['last_status_c'];
$row++;
}
if ($pdf === 1) {
$table1->title = $item['title'];
$table1->titleclass = 'title_table_pdf';
$table1->titlestyle = 'text-align:left;';
}
$table->data[2][0] = html_print_table($table1, true);
if ($pdf === 1) {
return html_print_table($table1, true);
}
}
/**
* Function to print the security hardening evolution.
*
@ -953,7 +1282,7 @@ function reporting_html_SLA($table, $item, $mini, $pdf=0)
$table3->headstyle[5] = 'text-align: right';
foreach ($item['data'] as $sla) {
if (isset($sla) === true) {
if (isset($sla) === true && empty($sla['agent']) === false) {
// First_table.
$row = [];
$row[] = $sla['agent'];
@ -2758,6 +3087,85 @@ function reporting_html_agent_module_status($table, $item, $pdf=0)
}
function reporting_html_service_level($table, $item, $pdf=0)
{
global $config;
$return_pdf = '';
if (empty($item['data']) === true) {
if ($pdf !== 0) {
$return_pdf .= __('No items');
} else {
$table->colspan['group_report']['cell'] = 3;
$table->cellstyle['group_report']['cell'] = 'text-align: center;';
$table->data['group_report']['cell'] = __('No items');
}
} else {
$table_info = new stdClass();
$table_info->width = '99%';
if ($item['show_agents'] === '1') {
$show_agents = 'on';
} else {
$show_agents = 'off';
}
if ($show_agents === 'on') {
$table_info->head[0] = __('Agent / Module');
} else {
$table_info->head[0] = __('Module');
}
$table_info->head[1] = __('% Av.');
$table_info->head[2] = __('MTBF');
$table_info->head[3] = __('MTRS');
$table_info->head[4] = __('Crit. Events').ui_print_help_tip(__('Counted only critical events generated automatic by the module'), true);
$table_info->head[5] = __('Warn. Events').ui_print_help_tip(__('Counted only warning events generated automatic by the module'), true);
$table_info->head[6] = __('Last change');
$table_info->data = [];
$table_info->cellstyle = [];
$row = 0;
foreach ($item['data'] as $agentmodule_id => $module_data) {
if ($show_agents === 'on') {
$table_info->data[$row][0] = $module_data['agent_alias'].' / '.$module_data['module_name'];
$table_info->cellstyle[$row][0] = 'text-align:left; padding-left: 30px;';
} else {
$table_info->data[$row][0] = $module_data['module_name'];
$table_info->cellstyle[$row][0] = 'text-align:left; padding-left: 30px;';
}
$table_info->data[$row][1] = $module_data['availability'].'%';
$table_info->data[$row][2] = $module_data['mtbf'];
$table_info->data[$row][3] = $module_data['mtrs'];
$table_info->data[$row][4] = $module_data['critical_events'];
$table_info->data[$row][5] = $module_data['warning_events'];
if ($module_data['last_status_change'] !== '') {
$table_info->data[$row][6] = date(TIME_FORMAT, $module_data['last_status_change']);
}
// $table_info->data[$row][6] = date(TIME_FORMAT, $module_data['last_status_change']);
$row++;
}
if ($pdf !== 0) {
$table_info->title = $item['title'];
$table_info->titleclass = 'title_table_pdf';
$table_info->titlestyle = 'text-align:left;';
$return_pdf .= html_print_table($table_info, true);
} else {
$table->colspan['data']['cell'] = 3;
$table->cellstyle['data']['cell'] = 'text-align: center;';
$table->data['data']['cell'] = html_print_table($table_info, true);
}
}
if ($pdf !== 0) {
return $return_pdf;
}
}
/**
* Html report end of life.
*
@ -4630,7 +5038,7 @@ function reporting_html_value(
$table2->head = [
__('Agent'),
__('Module'),
__('Minimun'),
__('Minimum'),
];
break;
@ -4701,7 +5109,7 @@ function reporting_html_value(
case 'min_value':
$table1->head = [
__('Lapse'),
__('Minimun'),
__('Minimum'),
];
break;
@ -7343,40 +7751,146 @@ function reporting_html_permissions($table, $item, $pdf=0)
/**
* HTML content for ncm configuration diff report.
* HTML content for ncm devices list.
*
* @param array $item Content generated by reporting_ncm_config.
* @param array $item Content generated by reporting_ncm_list.
*
* @return string HTML code.
*/
function reporting_html_ncm_config($table, $item, $pdf=0)
function reporting_html_ncm_list($table, $item, $pdf=0)
{
$key = uniqid();
// Create table diff.
$table_ncm = new stdClass();
$table_ncm->width = '100%';
$table_ncm->class = 'info_table';
$table_ncm->styleTable = 'table-layout: fixed;';
$table_ncm->titleclass = 'title_table_pdf';
$table_ncm->align = [];
$table_ncm->align['name'] = 'left';
$table_ncm->align['ip'] = 'left';
$table_ncm->align['vendor'] = 'left';
$table_ncm->align['model'] = 'left';
$table_ncm->align['firmware'] = 'left';
$table_ncm->align['last_backup_date'] = 'left';
$table_ncm->headstyle['name'] = 'text-align: left';
$table_ncm->headstyle['ip'] = 'text-align: left';
$table_ncm->headstyle['vendor'] = 'text-align: left';
$table_ncm->headstyle['model'] = 'text-align: left';
$table_ncm->headstyle['firmware'] = 'text-align: left';
$table_ncm->headstyle['last_backup_date'] = 'text-align: left';
$table_ncm->head = [];
$table_ncm->head['name'] = __('Name');
$table_ncm->head['ip'] = __('Ip');
$table_ncm->head['vendor'] = __('Vendor');
$table_ncm->head['model'] = __('Model');
$table_ncm->head['firmware'] = __('Firmware');
$table_ncm->head['last_backup_date'] = __('Last backup date');
$table_ncm->data = [];
foreach ($item['data'] as $key => $row) {
$title = $row['last_error'];
if (empty($title) === true) {
$title = null;
}
$table_ncm->data[] = [
$row['alias'],
$row['direccion'],
$row['vendor'],
$row['model'],
$row['firmware'],
$row['last_backup_date'],
];
}
if ($pdf === 0) {
ui_require_javascript_file('diff2html-ui.min');
ui_require_css_file('diff2html.min');
$script = "$(document).ready(function() {
const configuration = {
drawFileList: false,
collapsed: true,
matching: 'lines',
outputFormat: 'side-by-side',
};
const diff2htmlUi = new Diff2HtmlUI(
document.getElementById('".$key."'),
atob('".base64_encode($item['data'])."'),
configuration
);
diff2htmlUi.draw();
});";
$content = '<div class="w100p" id="'.$key.'"></div class="w100p">';
$content .= '<script>'.$script.'</script>';
$table->data[1] = $content;
$table->colspan[1][0] = 2;
$table->colspan['data']['cell'] = 3;
$table->cellstyle['data']['cell'] = 'text-align: left;';
$table->data['data']['cell'] = html_print_table(
$table_ncm,
true
);
} else {
$content = '<div style="text-align:left;margin-left: 14px;">';
$content .= str_replace("\n", '<br>', $item['data']);
$content .= '</div>';
return $content;
$table_ncm->titleclass = 'title_table_pdf';
$table_ncm->titlestyle = 'text-align:left;';
return html_print_table(
$table_ncm,
true
);
}
}
/**
* HTML content for ncm backup report.
*
* @param array $item Content generated by reporting_ncm_backups.
*
* @return string HTML code.
*/
function reporting_html_ncm_backups($table, $item, $pdf=0)
{
ui_require_css_file('diff2html.min');
ui_require_css_file('highlight.min');
ui_require_css_file('highlight/vs.min');
ui_require_javascript_file('diff2html-ui.min');
ui_require_javascript_file('highlight.min');
ui_require_javascript_file('highlightjs-line-numbers.min');
ui_require_javascript_file('languages/plaintext.min');
ui_require_javascript_file('jquery', ENTERPRISE_DIR.'/include/javascript/');
ui_require_javascript_file('functions_ncm', ENTERPRISE_DIR.'/include/javascript/');
// Create table diff.
foreach ($item['data'] as $ncm_agent_key => $ncm_agent) {
$table_ncm = new stdClass();
if ($pdf === 1) {
$table_ncm->width = '100%';
}
$table_ncm->class = 'info_table';
$table_ncm->styleTable = 'table-layout: fixed;';
$table_ncm->headstyle[0] = 'width: 250px';
$table_ncm->head = [];
$table_ncm->head[0] = __('Date');
$table_ncm->head[1] = __('Diff');
$table_ncm->id = 'ncm_backups';
$table_ncm->name = 'ncm_backups';
$table_ncm->title = $ncm_agent['caption'];
$row = [];
foreach ($ncm_agent['data'] as $ncm_agent_data) {
if ($pdf === 1) {
$row[] = [
$ncm_agent_data['updated_at'],
($ncm_agent_data['diffstr'] === '') ? $ncm_agent_data['diff'] : str_replace("\n", '<br>', $ncm_agent_data['diffstr']),
];
} else {
$row[] = [
$ncm_agent_data['updated_at'],
$ncm_agent_data['diff'],
];
}
$table_ncm->data = $row;
}
$table->colspan[$ncm_agent_key]['cell'] = 3;
$table->cellstyle[$ncm_agent_key]['cell'] = 'text-align: left;';
$table->data[$ncm_agent_key]['cell'] = html_print_table(
$table_ncm,
true
);
}
if ($pdf === 1) {
$table->width = '100%';
return html_print_table(
$table,
true
);
}
}

View File

@ -777,6 +777,10 @@ function reports_get_report_types($template=false, $not_editor=false)
'optgroup' => __('Modules'),
'name' => __('Last value'),
];
$types['service_level'] = [
'optgroup' => __('Modules'),
'name' => __('Service Level Detailed'),
];
$types['general'] = [
'optgroup' => __('Grouped'),
@ -963,9 +967,14 @@ function reports_get_report_types($template=false, $not_editor=false)
];
}
$types['ncm_backups'] = [
'optgroup' => __('NCM'),
'name' => __('NCM configuration changes'),
];
$types['ncm'] = [
'optgroup' => __('NCM'),
'name' => __('Network configuration changes'),
'name' => __('NCM devices list'),
];
if (enterprise_installed() === true) {
@ -1003,6 +1012,41 @@ function reports_get_report_types($template=false, $not_editor=false)
'optgroup' => __('Security hardening'),
'name' => __('Evolution'),
];
$types['vuls_severity_graph'] = [
'optgroup' => __('Vulnerabilities'),
'name' => __('Severity graph bar'),
];
$types['vuls_attack_complexity'] = [
'optgroup' => __('Vulnerabilities'),
'name' => __('Attack complexity doughnut chart'),
];
$types['vuls_by_packages'] = [
'optgroup' => __('Vulnerabilities'),
'name' => __('By packages in pie chart'),
];
$types['vuls_by_agent'] = [
'optgroup' => __('Vulnerabilities'),
'name' => __('Detailed security report'),
];
$types['vuls_info_agent'] = [
'optgroup' => __('Vulnerabilities'),
'name' => __('Vulnerabilities of agent'),
];
$types['top_n_agents_vuls'] = [
'optgroup' => __('Vulnerabilities'),
'name' => __('Top-N agents with more risk'),
];
$types['top_n_vuls_count'] = [
'optgroup' => __('Vulnerabilities'),
'name' => __('Top-N common vulnerabilities'),
];
}
return $types;

View File

@ -1978,15 +1978,21 @@ function ui_print_help_icon(
*
* @return boolean True if the file was added. False if the file doesn't exist.
*/
function ui_require_css_file($name, $path='include/styles/', $echo_tag=false)
function ui_require_css_file($name, $path='include/styles/', $echo_tag=false, $return=false)
{
global $config;
$filename = $path.$name.'.css';
if ($echo_tag === true) {
echo '<link type="text/css" rel="stylesheet" href="'.ui_get_full_url($filename, false, false, false).'">';
return null;
$filename .= '?v='.$config['current_package'];
$tag_name = '<link type="text/css" rel="stylesheet" href="'.ui_get_full_url($filename, false, false, false).'">';
if ($return === false) {
echo $tag_name;
return null;
} else {
return $tag_name;
}
}
if (! isset($config['css'])) {
@ -2035,15 +2041,20 @@ function ui_require_css_file($name, $path='include/styles/', $echo_tag=false)
*
* @return boolean True if the file was added. False if the file doesn't exist.
*/
function ui_require_javascript_file($name, $path='include/javascript/', $echo_tag=false)
function ui_require_javascript_file($name, $path='include/javascript/', $echo_tag=false, $return=false)
{
global $config;
$filename = $path.$name.'.js';
if ($echo_tag) {
echo '<script type="text/javascript" src="'.ui_get_full_url($filename, false, false, false).'"></script>';
return null;
if ($echo_tag === true) {
$filename .= '?v='.$config['current_package'];
$tag_name = '<script type="text/javascript" src="'.ui_get_full_url($filename, false, false, false).'"></script>';
if ($return === false) {
echo $tag_name;
return null;
} else {
return $tag_name;
}
}
if (! isset($config['js'])) {
@ -7159,31 +7170,16 @@ function ui_print_comments($comment, $truncate_limit=255)
}
// Only show the last comment. If commment its too long,the comment will short with ...
// If $config['prominent_time'] is timestamp the date show Month, day, hour and minutes.
// Forced time commentary to use copact date for optimize space in table.
// Else show comments hours ago
if ($comment['action'] != 'Added comment') {
$comment['comment'] = $comment['action'];
}
$comment['comment'] = io_safe_output($comment['comment']);
$short_comment = substr($comment['comment'], 0, 20);
if ($config['prominent_time'] == 'timestamp') {
$comentario = '<i>'.date($config['date_format'], $comment['utimestamp']).'&nbsp;('.$comment['id_user'].'):&nbsp;'.$comment['comment'].'';
if (strlen($comentario) > '200px' && $truncate_limit >= 255) {
$comentario = '<i>'.date($config['date_format'], $comment['utimestamp']).'&nbsp;('.$comment['id_user'].'):&nbsp;'.$short_comment.'...';
}
} else {
$rest_time = (time() - $comment['utimestamp']);
$time_last = (($rest_time / 60) / 60);
$comentario = '<i>'.number_format($time_last, 0, $config['decimal_separator'], ($config['thousand_separator'] ?? ',')).'&nbsp; Hours &nbsp;('.$comment['id_user'].'):&nbsp;'.$comment['comment'].'';
if (strlen($comentario) > '200px' && $truncate_limit >= 255) {
$comentario = '<i>'.number_format($time_last, 0, $config['decimal_separator'], ($config['thousand_separator'] ?? ',')).'&nbsp; Hours &nbsp;('.$comment['id_user'].'):&nbsp;'.$short_comment.'...';
}
}
$comentario = io_safe_output($comentario);
$comentario = $comment['comment'];
if (strlen($comentario) >= $truncate_limit) {
$comentario = ui_print_truncate_text(
@ -7198,6 +7194,12 @@ function ui_print_comments($comment, $truncate_limit=255)
);
}
$comentario = '<i class="forced_title" data-use_title_for_force_title="1" data-title="'.date($config['date_format'], $comment['utimestamp']).'">'.ui_print_timestamp($comment['utimestamp'], true, ['style' => 'font-size: 10px; display: contents;', 'prominent' => 'compact']).'&nbsp;('.$comment['id_user'].'):&nbsp;'.$comment['comment'].'';
if (strlen($comentario) > '200px' && $truncate_limit >= 255) {
$comentario = '<i class="forced_title" data-use_title_for_force_title="1" data-title="'.date($config['date_format'], $comment['utimestamp']).'">'.ui_print_timestamp($comment['utimestamp'], true, ['style' => 'font-size: 10px; display: contents;', 'prominent' => 'compact']).'&nbsp;('.$comment['id_user'].'):&nbsp;'.$short_comment.'...';
}
return $comentario;
}

View File

@ -1004,6 +1004,13 @@ function get_build_setup_charts($type, $options, $data)
}
}
// Set display grid true or false.
if (isset($options['grid']) === true) {
$scales = $chart->options()->getScales();
$scales->getX()->grid()->setDrawOnChartArea($options['grid']);
$scales->getY()->grid()->setDrawOnChartArea($options['grid']);
}
// Radius is null maximum possible.
if (isset($options['radius']) === true
&& empty($options['radius']) === false

View File

@ -11,14 +11,14 @@
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
function include_javascript_d3($return=false)
function include_javascript_d3($return=false, $force=false)
{
global $config;
static $is_include_javascript = false;
$output = '';
if (!$is_include_javascript) {
if (!$is_include_javascript || $force === true) {
$is_include_javascript = true;
$output .= '<script type="text/javascript" src="';

View File

@ -756,9 +756,8 @@ function flot_slicesbar_graph(
global $config;
if ($ttl == 2) {
$tokem_config = uniqid('slicebar');
$params = [
'tokem_config' => $tokem_config,
'graph_data' => $graph_data,
'period' => $period,
'width' => $width,
'height' => $height,
@ -781,9 +780,6 @@ function flot_slicesbar_graph(
'server_id' => $server_id,
];
update_check_config_token($tokem_config, json_encode($graph_data));
$_SESSION['slicebar'] = $tokem_config;
$_SESSION['slicebar_value'] = json_encode($graph_data);
$graph = '<img src="data:image/png;base64,';
$graph .= generator_chart_to_pdf('slicebar', $params);
$graph .= '" />';

Some files were not shown because too many files have changed in this diff Show More