Merge remote-tracking branch 'origin/develop' into ent-4822-estado-de-consola-visual-mantenimiento

Conflicts:
	pandora_console/extras/mr/58.sql
This commit is contained in:
Daniel Barbero 2022-10-26 09:42:02 +02:00
commit 3273fc23ed
92 changed files with 3479 additions and 2996 deletions

View File

@ -5,7 +5,7 @@
# Tentacle have IANA assigned port tpc/41121 as official port. # Tentacle have IANA assigned port tpc/41121 as official port.
########################################################################## ##########################################################################
# Copyright (c) 2007-2008 Ramon Novoa <rnovoa@artica.es> # Copyright (c) 2007-2008 Ramon Novoa <rnovoa@artica.es>
# Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L # Copyright (c) 2005-2022 Artica Soluciones Tecnologicas S.L
# #
# tentacle_server.pl Tentacle Server. See https://pandorafms.com/docs/ for # tentacle_server.pl Tentacle Server. See https://pandorafms.com/docs/ for
# protocol description. # protocol description.
@ -1740,6 +1740,19 @@ sub callback_stop {
Win32::Daemon::StopService(); Win32::Daemon::StopService();
} }
################################################################################
## SUB check_ssleay_version
## Print a message if the installed version of Net::SSLeay may leak memory.
################################################################################
sub check_ssleay_version {
eval {
require Net::SSLeay;
return unless defined($Net::SSLeay::VERSION) && $Net::SSLeay::VERSION =~ m/^(\d+)\.(\d+)/ && $1 <= 1 && $2 < 88;
print_log ("Net::SSLeay version $Net::SSLeay::VERSION detected. Versions prior to 1.88 may leak memory. To upgrade it see: https://metacpan.org/pod/Net::SSLeay");
};
}
################################################################################ ################################################################################
# Main # Main
################################################################################ ################################################################################
@ -1753,12 +1766,20 @@ if ($> == 0 && $^O ne 'MSWin32') {
# Parse command line options # Parse command line options
parse_options (); parse_options ();
# Try to open the log file.
if (defined($log_file)) {
open(my $fh, ">>", $log_file) || die("Error opening the log file '$log_file': $!.\n");
close($fh);
}
# Check command line arguments # Check command line arguments
if ($#ARGV != -1) { if ($#ARGV != -1) {
print_help (); print_help ();
exit 1; exit 1;
} }
check_ssleay_version() if $t_ssl == 1;
# Show IPv6 status # Show IPv6 status
if ($SOCKET_MODULE eq 'IO::Socket::INET') { if ($SOCKET_MODULE eq 'IO::Socket::INET') {
print_log ("IO::Socket::INET6 is not found. IPv6 is disabled."); print_log ("IO::Socket::INET6 is not found. IPv6 is disabled.");

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.765-221014 Version: 7.0NG.765-221026
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

@ -1015,7 +1015,7 @@ my $Sem = undef;
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.765'; use constant AGENT_VERSION => '7.0NG.765';
use constant AGENT_BUILD => '221014'; use constant AGENT_BUILD => '221026';
# Agent log default file size maximum and instances # Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000; use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.765 %define version 7.0NG.765
%define release 221014 %define release 221026
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.765 %define version 7.0NG.765
%define release 221014 %define release 221026
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -10,7 +10,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.765" PI_VERSION="7.0NG.765"
PI_BUILD="221014" PI_BUILD="221026"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

@ -5,7 +5,7 @@
# Tentacle have IANA assigned port tpc/41121 as official port. # Tentacle have IANA assigned port tpc/41121 as official port.
########################################################################## ##########################################################################
# Copyright (c) 2007-2008 Ramon Novoa <rnovoa@artica.es> # Copyright (c) 2007-2008 Ramon Novoa <rnovoa@artica.es>
# Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L # Copyright (c) 2005-2022 Artica Soluciones Tecnologicas S.L
# #
# tentacle_server.pl Tentacle Server. See https://pandorafms.com/docs/ for # tentacle_server.pl Tentacle Server. See https://pandorafms.com/docs/ for
# protocol description. # protocol description.
@ -1740,6 +1740,19 @@ sub callback_stop {
Win32::Daemon::StopService(); Win32::Daemon::StopService();
} }
################################################################################
## SUB check_ssleay_version
## Print a message if the installed version of Net::SSLeay may leak memory.
################################################################################
sub check_ssleay_version {
eval {
require Net::SSLeay;
return unless defined($Net::SSLeay::VERSION) && $Net::SSLeay::VERSION =~ m/^(\d+)\.(\d+)/ && $1 <= 1 && $2 < 88;
print_log ("Net::SSLeay version $Net::SSLeay::VERSION detected. Versions prior to 1.88 may leak memory. To upgrade it see: https://metacpan.org/pod/Net::SSLeay");
};
}
################################################################################ ################################################################################
# Main # Main
################################################################################ ################################################################################
@ -1753,12 +1766,20 @@ if ($> == 0 && $^O ne 'MSWin32') {
# Parse command line options # Parse command line options
parse_options (); parse_options ();
# Try to open the log file.
if (defined($log_file)) {
open(my $fh, ">>", $log_file) || die("Error opening the log file '$log_file': $!.\n");
close($fh);
}
# Check command line arguments # Check command line arguments
if ($#ARGV != -1) { if ($#ARGV != -1) {
print_help (); print_help ();
exit 1; exit 1;
} }
check_ssleay_version() if $t_ssl == 1;
# Show IPv6 status # Show IPv6 status
if ($SOCKET_MODULE eq 'IO::Socket::INET') { if ($SOCKET_MODULE eq 'IO::Socket::INET') {
print_log ("IO::Socket::INET6 is not found. IPv6 is disabled."); print_log ("IO::Socket::INET6 is not found. IPv6 is disabled.");

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{221014} {221026}
ViewReadme ViewReadme
{Yes} {Yes}

View File

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

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST" VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent" VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.765(Build 221014))" VALUE "ProductVersion", "(7.0NG.765(Build 221026))"
VALUE "FileVersion", "1.0.0.0" VALUE "FileVersion", "1.0.0.0"
END END
END END

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 7.0NG.765-221014 Version: 7.0NG.765-221026
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

@ -110,12 +110,13 @@ $auth_class = io_safe_output(
$page = (string) get_parameter('page'); $page = (string) get_parameter('page');
$page = safe_url_extraclean($page); $page = safe_url_extraclean($page);
$page .= '.php'; $page .= '.php';
$page = realpath($page);
$public_hash = get_parameter('auth_hash', false); $public_hash = get_parameter('auth_hash', false);
$public_login = false; $public_login = false;
if (false === ((bool) get_parameter('doLogin', false) === true if (false === ((bool) get_parameter('doLogin', false) === true
&& $page === 'include/rest-api/index.php') && $page === realpath('include/rest-api/index.php'))
) { ) {
// Check user. // Check user.
if (class_exists($auth_class) === false || $public_hash === false) { if (class_exists($auth_class) === false || $public_hash === false) {

View File

@ -1666,3 +1666,4 @@ godmode/um_client/vendor/sebastian/object-enumerator
godmode/um_client/vendor/sebastian godmode/um_client/vendor/sebastian
godmode/um_client/vendor godmode/um_client/vendor
update_manager_client/resources/styles/pandora.css update_manager_client/resources/styles/pandora.css
enterprise/meta/general/upload_head_image.php

View File

@ -2,7 +2,11 @@ START TRANSACTION;
ALTER TABLE `tlayout` ADD COLUMN `maintenance_mode` TEXT; ALTER TABLE `tlayout` ADD COLUMN `maintenance_mode` TEXT;
ALTER TABLE `tusuario` ADD COLUMN `auth_token_secret` VARCHAR(45) DEFAULT NULL;
ALTER TABLE `tmodule_inventory` ADD COLUMN `script_mode` INT NOT NULL DEFAULT 2; ALTER TABLE `tmodule_inventory` ADD COLUMN `script_mode` INT NOT NULL DEFAULT 2;
ALTER TABLE `tmodule_inventory` ADD COLUMN `script_path` VARCHAR(1000) DEFAULT ''; ALTER TABLE `tmodule_inventory` ADD COLUMN `script_path` VARCHAR(1000) DEFAULT '';
ALTER TABLE `tevent_filter` ADD COLUMN `search_recursive_groups` INT NOT NULL DEFAULT 0;
COMMIT; COMMIT;

View File

@ -181,7 +181,7 @@ $module_macros = [];
// Create agent. // Create agent.
if ($create_agent) { if ($create_agent) {
$mssg_warning = 0; $mssg_warning = 0;
$alias_safe_output = io_safe_output(get_parameter('alias', '')); $alias_safe_output = strip_tags(io_safe_output(get_parameter('alias', '')));
$alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$]/', '', $alias_safe_output))); $alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$]/', '', $alias_safe_output)));
$alias_as_name = (int) get_parameter_post('alias_as_name', 0); $alias_as_name = (int) get_parameter_post('alias_as_name', 0);
$direccion_agente = (string) get_parameter_post('direccion', ''); $direccion_agente = (string) get_parameter_post('direccion', '');
@ -935,7 +935,7 @@ if ($update_agent) {
$mssg_warning = 0; $mssg_warning = 0;
$id_agente = (int) get_parameter_post('id_agente'); $id_agente = (int) get_parameter_post('id_agente');
$nombre_agente = str_replace('`', '&lsquo;', (string) get_parameter_post('agente', '')); $nombre_agente = str_replace('`', '&lsquo;', (string) get_parameter_post('agente', ''));
$alias_safe_output = io_safe_output(get_parameter('alias', '')); $alias_safe_output = strip_tags(io_safe_output(get_parameter('alias', '')));
$alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$]/', '', $alias_safe_output))); $alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$]/', '', $alias_safe_output)));
$alias_as_name = (int) get_parameter_post('alias_as_name', 0); $alias_as_name = (int) get_parameter_post('alias_as_name', 0);
$direccion_agente = (string) get_parameter_post('direccion', ''); $direccion_agente = (string) get_parameter_post('direccion', '');
@ -1047,7 +1047,7 @@ if ($update_agent) {
// If there is an agent with the same name, but a different ID. // If there is an agent with the same name, but a different ID.
} }
if ($unique_ip && $direccion_agente != '') { if ($direccion_agente !== $address_list && (bool) $unique_ip === true && $direccion_agente != '') {
$sql = 'SELECT direccion FROM tagente WHERE direccion = "'.$direccion_agente.'"'; $sql = 'SELECT direccion FROM tagente WHERE direccion = "'.$direccion_agente.'"';
$exists_ip = db_get_row_sql($sql); $exists_ip = db_get_row_sql($sql);
} }

View File

@ -40,16 +40,7 @@ require_once $config['homedir'].'/include/functions_modules.php';
require_once $config['homedir'].'/include/functions_agents.php'; require_once $config['homedir'].'/include/functions_agents.php';
require_once $config['homedir'].'/include/functions_servers.php'; require_once $config['homedir'].'/include/functions_servers.php';
$search_string = io_safe_output( $search_string = get_parameter('search_string');
urldecode(
trim(
get_parameter(
'search_string',
''
)
)
)
);
global $policy_page; global $policy_page;

View File

@ -1104,11 +1104,7 @@ $table->data[1][0] = __('Available agents');
$table->data[1][1] = html_print_select($agents, 'id_agents[]', -1, '', _('Any'), -2, true, true, true, '', false, 'min-width: 250px;width: 70%;'); $table->data[1][1] = html_print_select($agents, 'id_agents[]', -1, '', _('Any'), -2, true, true, true, '', false, 'min-width: 250px;width: 70%;');
if ($type_downtime != 'quiet') { $table->rowid[2] = 'available_modules_selection_mode';
echo '<div id="available_modules_selection_mode" style="padding-top:20px;display: none;">';
} else {
echo '<div id="available_modules_selection_mode" style="padding-top:20px">';
}
$table->data[2][1] = html_print_select( $table->data[2][1] = html_print_select(
[ [
@ -1128,19 +1124,13 @@ $table->data[2][1] = html_print_select(
'min-width:180px;' 'min-width:180px;'
); );
echo '</div>';
$table->rowid[3] = 'available_modules';
$table->data[3][0] = __('Available modules:').ui_print_help_tip( $table->data[3][0] = __('Available modules:').ui_print_help_tip(
__('Only for type Quiet for downtimes.'), __('Only for type Quiet for downtimes.'),
true true
); );
if ($type_downtime != 'quiet') {
echo '<div id="available_modules" style="display: none;">';
} else {
echo '<div id="available_modules" style="">';
}
$table->data[3][1] = html_print_select( $table->data[3][1] = html_print_select(
[], [],
'module[]', 'module[]',
@ -1155,7 +1145,6 @@ $table->data[3][1] = html_print_select(
false, false,
'min-width: 250px;width: 70%;' 'min-width: 250px;width: 70%;'
); );
echo '</div>';
// Print agent table. // Print agent table.
html_print_table($table); html_print_table($table);
@ -1184,7 +1173,6 @@ if ($id_downtime > 0) {
} }
echo '</div>'; echo '</div>';
html_print_input_hidden('all_agents', implode(',', array_keys($agents)));
html_print_input_hidden('all_common_modules', ''); html_print_input_hidden('all_common_modules', '');
echo '</form>'; echo '</form>';
@ -1405,12 +1393,19 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
} }
$agents = (array) get_parameter('id_agents'); $agents = (array) get_parameter('id_agents');
$filter_group = (int) get_parameter('filter_group', 0);
$module_names = (array) get_parameter('module'); $module_names = (array) get_parameter('module');
$modules_selection_mode = (string) get_parameter('modules_selection_mode'); $modules_selection_mode = (string) get_parameter('modules_selection_mode');
$type_downtime = (string) get_parameter('type_downtime', 'quiet');
$recursion = (bool) get_parameter_checkbox('recursion', false);
$all_modules = ($modules_selection_mode === 'all' && (empty($module_names) || (string) $module_names[0] === '0')); $all_modules = ($modules_selection_mode === 'all' && (empty($module_names) || (string) $module_names[0] === '0'));
$all_common_modules = ($modules_selection_mode === 'common' && (empty($module_names) || (string) $module_names[0] === '0')); $all_common_modules = ($modules_selection_mode === 'common' && (empty($module_names) || (string) $module_names[0] === '0'));
if ($type_downtime === 'disable_agents') {
$all_modules = true;
}
if ($all_common_modules === true) { if ($all_common_modules === true) {
$module_names = explode(',', get_parameter('all_common_modules')); $module_names = explode(',', get_parameter('all_common_modules'));
} }
@ -1429,11 +1424,33 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
} else { } else {
// If is selected 'Any', get all the agents. // If is selected 'Any', get all the agents.
if (count($agents) === 1 && (int) $agents[0] === -2) { if (count($agents) === 1 && (int) $agents[0] === -2) {
$all_agents = get_parameter('all_agents'); if ($recursion === true) {
$agents = explode(',', $all_agents); $filter_group = groups_get_children_ids(
$filter_group,
false,
true,
'AW'
);
};
$agents = db_get_all_rows_filter(
'tagente',
['id_grupo' => $filter_group],
'id_agente'
);
$agents = array_reduce(
$agents,
function ($carry, $item) {
$carry[] = $item['id_agente'];
return $carry;
}
);
} }
foreach ($agents as $agent_id) { foreach ($agents as $agent_id) {
$agent_id = (int) $agent_id;
// Check module belongs to the agent. // Check module belongs to the agent.
if ($modules_selection_mode == 'all' && $all_modules === false) { if ($modules_selection_mode == 'all' && $all_modules === false) {
$check = false; $check = false;
@ -1466,17 +1483,40 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
continue; continue;
} }
$values = [ // Check if agent is already in downtime.
'id_downtime' => $id_downtime, $agent_in_downtime = db_get_value_filter(
'id_agent' => $agent_id, 'id_downtime',
'all_modules' => $all_modules,
];
$result = db_process_sql_insert(
'tplanned_downtime_agents', 'tplanned_downtime_agents',
$values [
'id_agent' => $agent_id,
'id_downtime' => $id_downtime,
]
); );
if ($result && !$all_modules) { if ($agent_in_downtime !== false) {
$values = ['all_modules' => $all_modules];
$result = db_process_sql_update(
'tplanned_downtime_agents',
$values,
[
'id_downtime' => $id_downtime,
'id_agent' => $agent_id,
]
);
} else {
$values = [
'id_downtime' => $id_downtime,
'id_agent' => $agent_id,
'all_modules' => $all_modules,
];
$result = db_process_sql_insert(
'tplanned_downtime_agents',
$values
);
}
if ($result !== false && (bool) $all_modules === false) {
foreach ($module_names as $module_name) { foreach ($module_names as $module_name) {
$module = modules_get_agentmodule_id( $module = modules_get_agentmodule_id(
$module_name, $module_name,
@ -1487,17 +1527,32 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
continue; continue;
} }
$values = [ // Check if modules are already in downtime.
'id_downtime' => $id_downtime, $module_in_downtime = db_get_value_filter(
'id_agent' => $agent_id, 'id_downtime',
'id_agent_module' => $module['id_agente_modulo'],
];
$result = db_process_sql_insert(
'tplanned_downtime_modules', 'tplanned_downtime_modules',
$values [
'id_downtime' => $id_downtime,
'id_agent' => $agent_id,
'id_agent_module' => $module['id_agente_modulo'],
]
); );
if ($result) { if ($module_in_downtime !== false) {
continue;
} else {
$values = [
'id_downtime' => $id_downtime,
'id_agent' => $agent_id,
'id_agent_module' => $module['id_agente_modulo'],
];
$result = db_process_sql_insert(
'tplanned_downtime_modules',
$values
);
}
if ($result !== false) {
$values = ['id_user' => $config['id_user']]; $values = ['id_user' => $config['id_user']];
$result = db_process_sql_update( $result = db_process_sql_update(
'tplanned_downtime', 'tplanned_downtime',
@ -1526,6 +1581,7 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
$("#available_modules_selection_mode").hide(); $("#available_modules_selection_mode").hide();
break; break;
case 'quiet': case 'quiet':
case 'disable_agent_modules':
$("#available_modules_selection_mode").show(); $("#available_modules_selection_mode").show();
$("#available_modules").show(); $("#available_modules").show();
break; break;
@ -1840,7 +1896,6 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
$('input.hasDatepicker[readonly]').disable(); $('input.hasDatepicker[readonly]').disable();
$("#checkbox-recursion").click(function() { $("#checkbox-recursion").click(function() {
recursion = this.checked;
$("#filter_group").trigger("change"); $("#filter_group").trigger("change");
}); });
@ -1850,6 +1905,7 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
}); });
function populate_agents_selector() { function populate_agents_selector() {
recursion = $("#checkbox-recursion").prop('checked');
jQuery.post ("ajax.php", jQuery.post ("ajax.php",
{"page": "operation/agentes/ver_agente", {"page": "operation/agentes/ver_agente",
"get_agents_group_json": 1, "get_agents_group_json": 1,

View File

@ -137,12 +137,49 @@ if (is_ajax() === true) {
'filters' => get_parameter('filter', []), 'filters' => get_parameter('filter', []),
]; ];
$modules = get_agents_modules_planned_dowtime($id, $options); $type_downtime = db_get_value_filter(
'type_downtime',
'tplanned_downtime',
['id' => $id]
);
if ($type_downtime === 'disable_agents') {
$sql = sprintf(
'SELECT ta.alias as agent_name
FROM tplanned_downtime_agents tpa JOIN tagente ta
ON tpa.id_agent = ta.id_agente
WHERE tpa.id_downtime = %d',
$id
);
$data = db_get_all_rows_sql($sql);
if (empty($data) === false) {
$data = array_reduce(
$data,
function ($carry, $item) {
global $config;
// Transforms array of arrays $data into an array
// of objects, making a post-process of certain fields.
$tmp = (object) $item;
$tmp->agent_name = io_safe_output($item['agent_name']);
$tmp->module_name = __('All modules');
$carry[] = $tmp;
return $carry;
}
);
}
} else {
$data = get_agents_modules_planned_dowtime($id, $options);
}
$count = get_agents_modules_planned_dowtime($id, $options, $count); $count = get_agents_modules_planned_dowtime($id, $options, $count);
echo json_encode( echo json_encode(
[ [
'data' => $modules, 'data' => $data,
'recordsTotal' => $count[0]['total'], 'recordsTotal' => $count[0]['total'],
'recordsFiltered' => $count[0]['total'], 'recordsFiltered' => $count[0]['total'],
] ]

View File

@ -797,11 +797,7 @@ foreach ($commands as $command) {
// (IMPORTANT, DO NOT CHANGE!) only users with permissions over "All" group have access to edition of commands belonging to "All" group. // (IMPORTANT, DO NOT CHANGE!) only users with permissions over "All" group have access to edition of commands belonging to "All" group.
if ($is_management_allowed === true && !$command['internal'] && check_acl_restricted_all($config['id_user'], $command['id_group'], 'LM')) { if ($is_management_allowed === true && !$command['internal'] && check_acl_restricted_all($config['id_user'], $command['id_group'], 'LM')) {
if (check_acl($config['id_user'], 0, 'PM') || is_user_admin( if (is_user_admin($config['id_user']) === true) {
$config['id_user
']
)
) {
$data['action'] = '<span class="inline_flex">'; $data['action'] = '<span class="inline_flex">';
$data['action'] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_commands&amp;copy_command=1&id='.$command['id'].'&pure='.$pure.'" $data['action'] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_commands&amp;copy_command=1&id='.$command['id'].'&pure='.$pure.'"
onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/copy.png', true, ['class' => 'invert_filter']).'</a>'; onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/copy.png', true, ['class' => 'invert_filter']).'</a>';
@ -828,7 +824,8 @@ if (isset($data) === true && count($table->data) > 0) {
); );
} }
if ($is_management_allowed === true && check_acl_restricted_all($config['id_user'], $command['id_group'], 'PM')) { // Commands can only be created by the super administrator.
if (users_is_admin() === true) {
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<div class="action-buttons" style="width: '.$table->width.'">';
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_command&pure='.$pure.'">'; echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_command&pure='.$pure.'">';
html_print_submit_button(__('Create'), 'create', false, 'class="sub next"'); html_print_submit_button(__('Create'), 'create', false, 'class="sub next"');

View File

@ -90,6 +90,7 @@ if ($id) {
$filter_only_alert = $filter['filter_only_alert']; $filter_only_alert = $filter['filter_only_alert'];
$search_secondary_groups = $filter['search_secondary_groups']; $search_secondary_groups = $filter['search_secondary_groups'];
$search_recursive_groups = $filter['search_recursive_groups'];
$custom_data = $filter['custom_data']; $custom_data = $filter['custom_data'];
$custom_data_filter_type = $filter['custom_data_filter_type']; $custom_data_filter_type = $filter['custom_data_filter_type'];
@ -128,6 +129,7 @@ if ($id) {
$tag_without_base64 = base64_encode($tag_without_json); $tag_without_base64 = base64_encode($tag_without_json);
$filter_only_alert = ''; $filter_only_alert = '';
$search_secondary_groups = 0; $search_secondary_groups = 0;
$search_recursive_groups = 0;
} }
if ($update || $create) { if ($update || $create) {
@ -170,6 +172,7 @@ if ($update || $create) {
$filter_only_alert = get_parameter('filter_only_alert', ''); $filter_only_alert = get_parameter('filter_only_alert', '');
$search_secondary_groups = get_parameter('search_secondary_groups', 0); $search_secondary_groups = get_parameter('search_secondary_groups', 0);
$search_recursive_groups = get_parameter('search_recursive_groups', 0);
$custom_data = get_parameter('custom_data', ''); $custom_data = get_parameter('custom_data', '');
$custom_data_filter_type = get_parameter('custom_data_filter_type', ''); $custom_data_filter_type = get_parameter('custom_data_filter_type', '');
@ -198,6 +201,7 @@ if ($update || $create) {
'user_comment' => $user_comment, 'user_comment' => $user_comment,
'filter_only_alert' => $filter_only_alert, 'filter_only_alert' => $filter_only_alert,
'search_secondary_groups' => $search_secondary_groups, 'search_secondary_groups' => $search_secondary_groups,
'search_recursive_groups' => $search_recursive_groups,
'custom_data' => $custom_data, 'custom_data' => $custom_data,
'custom_data_filter_type' => $custom_data_filter_type, 'custom_data_filter_type' => $custom_data_filter_type,
]; ];
@ -438,8 +442,12 @@ $table->data[10][1] = html_print_select(
true true
); );
$repeated_sel[0] = __('All events'); $repeated_sel = [
$repeated_sel[1] = __('Group events'); EVENT_GROUP_REP_ALL => __('All events'),
EVENT_GROUP_REP_EVENTS => __('Group events'),
EVENT_GROUP_REP_AGENTS => __('Group agents'),
EVENT_GROUP_REP_EXTRAIDS => __('Group extra id'),
];
$table->data[11][0] = '<b>'.__('Repeated').'</b>'; $table->data[11][0] = '<b>'.__('Repeated').'</b>';
$table->data[11][1] = html_print_select( $table->data[11][1] = html_print_select(
$repeated_sel, $repeated_sel,

View File

@ -701,6 +701,28 @@ if (enterprise_installed() === true) {
); );
} }
// Agent Wizard defaults.
$defaultAgentWizardOptions = json_decode(io_safe_output($config['agent_wizard_defaults']));
$tableSnmpWizard = new stdClass();
$tableSnmpWizard->width = '100%';
$tableSnmpWizard->class = 'databox filters';
$tableSnmpWizard->data = [];
$tableSnmpWizard->style[0] = 'font-weight: bold';
$tableSnmpWizard->style[2] = 'font-weight: bold';
$tableSnmpWizard->size[0] = '30%';
$tableSnmpWizard->size[2] = '30%';
$i = 0;
$j = 0;
foreach ($defaultAgentWizardOptions as $key => $value) {
$tableSnmpWizard->data[$i][$j++] = $key;
$tableSnmpWizard->data[$i][$j++] = html_print_checkbox_switch('agent_wizard_defaults_'.$key, 1, $value, true);
if ($j >= 3) {
$j = 0;
$i++;
}
}
echo '<form id="form_setup" method="post">'; echo '<form id="form_setup" method="post">';
echo '<fieldset class="full-column">'; echo '<fieldset class="full-column">';
@ -725,6 +747,11 @@ echo '<fieldset>';
html_print_table($table_other); html_print_table($table_other);
echo '</fieldset>'; echo '</fieldset>';
echo '<fieldset>';
echo '<legend>'.__('Agent SNMP Interface Wizard defaults').' '.ui_print_help_icon('agent_snmp_wizard_options_tab', true).'</legend>';
html_print_table($tableSnmpWizard);
echo '</fieldset>';
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_input_hidden('update_config', 1); html_print_input_hidden('update_config', 1);
html_print_submit_button( html_print_submit_button(

View File

@ -199,6 +199,21 @@ if (is_ajax()) {
); );
$table->data['ldap_admin_pass'] = $row; $table->data['ldap_admin_pass'] = $row;
// Ldapsearch timeout.
// Default Ldapsearch timeout.
set_when_empty($config['ldap_searh_timeout'], 5);
$row = [];
$row['name'] = __('Ldap search timeout (secs)');
$row['control'] = html_print_input_text(
'ldap_search_timeout',
$config['ldap_search_timeout'],
'',
10,
10,
true
);
$table->data['ldap_search_timeout'] = $row;
// Enable/disable secondary ldap. // Enable/disable secondary ldap.
// Set default value. // Set default value.
set_unless_defined($config['secondary_ldap_enabled'], false); set_unless_defined($config['secondary_ldap_enabled'], false);

View File

@ -442,6 +442,13 @@ if ($create_user) {
$password_new = ''; $password_new = '';
$password_confirm = ''; $password_confirm = '';
$new_user = true; $new_user = true;
} else if (excludedPassword($password_new) === true) {
$is_err = true;
ui_print_error_message(__('The password provided is not valid. Please set another one.'));
$user_info = $values;
$password_new = '';
$password_confirm = '';
$new_user = true;
} else { } else {
if ((!is_user_admin($config['id_user']) || $config['enable_pass_policy_admin']) && $config['enable_pass_policy']) { if ((!is_user_admin($config['id_user']) || $config['enable_pass_policy_admin']) && $config['enable_pass_policy']) {
$pass_ok = login_validate_pass($password_new, $id, true); $pass_ok = login_validate_pass($password_new, $id, true);
@ -509,6 +516,10 @@ if ($create_user) {
if (!empty($json_profile)) { if (!empty($json_profile)) {
$json_profile = json_decode(io_safe_output($json_profile), true); $json_profile = json_decode(io_safe_output($json_profile), true);
foreach ($json_profile as $key => $profile) { foreach ($json_profile as $key => $profile) {
if (is_array($profile) === false) {
$profile = json_decode($profile, true);
}
if (!empty($profile)) { if (!empty($profile)) {
$group2 = $profile['group']; $group2 = $profile['group'];
$profile2 = $profile['profile']; $profile2 = $profile['profile'];
@ -532,6 +543,14 @@ if ($create_user) {
$result_profile = profile_create_user_profile($id, $profile2, $group2, false, $tags, $no_hierarchy); $result_profile = profile_create_user_profile($id, $profile2, $group2, false, $tags, $no_hierarchy);
if ($result_profile === false) {
$is_err = true;
$user_info = $values;
$password_new = '';
$password_confirm = '';
$new_user = true;
}
ui_print_result_message( ui_print_result_message(
$result_profile, $result_profile,
__('Profile added successfully'), __('Profile added successfully'),
@ -824,6 +843,10 @@ if ($add_profile && empty($json_profile)) {
'Profile: '.$profile2.' Group: '.$group2.' Tags: '.$tags 'Profile: '.$profile2.' Group: '.$group2.' Tags: '.$tags
); );
$return = profile_create_user_profile($id2, $profile2, $group2, false, $tags, $no_hierarchy); $return = profile_create_user_profile($id2, $profile2, $group2, false, $tags, $no_hierarchy);
if ($return === false) {
$is_err = true;
}
ui_print_result_message( ui_print_result_message(
$return, $return,
__('Profile added successfully'), __('Profile added successfully'),
@ -1492,12 +1515,12 @@ if ($config['admin_can_add_user']) {
echo '</div>'; echo '</div>';
html_print_input_hidden('json_profile', ''); html_print_input_hidden('json_profile', $json_profile);
echo '</form>'; echo '</form>';
profile_print_profile_table($id); profile_print_profile_table($id, io_safe_output($json_profile));
echo '<br />'; echo '<br />';
@ -1613,13 +1636,18 @@ $(document).ready (function () {
switch_ehorus_conf(); switch_ehorus_conf();
}); });
$('#checkbox-ehorus_user_level_enabled').trigger('change'); $('#checkbox-ehorus_user_level_enabled').trigger('change');
var img_delete = '<?php echo $delete_image; ?>'; var img_delete = '<?php echo $delete_image; ?>';
var id_user = '<?php echo io_safe_output($id); ?>'; var id_user = '<?php echo io_safe_output($id); ?>';
var is_metaconsole = '<?php echo $meta; ?>'; var is_metaconsole = '<?php echo $meta; ?>';
var user_is_global_admin = '<?php echo users_is_admin($id); ?>'; var user_is_global_admin = '<?php echo users_is_admin($id); ?>';
var is_err = '<?php echo $is_err; ?>';
var data = []; var data = [];
var aux = 0;
if(json_profile.val() != '') {
var data = JSON.parse(json_profile.val());
}
$('input:image[name="add"]').click(function (e) { $('input:image[name="add"]').click(function (e) {
e.preventDefault(); e.preventDefault();
var profile = $('#assign_profile').val(); var profile = $('#assign_profile').val();
@ -1641,10 +1669,14 @@ $(document).ready (function () {
return; return;
} }
if (id_user === '') { if (id_user == '' || is_err == 1) {
let new_json = `{"profile":${profile},"group":${group},"tags":[${tags}],"hierarchy":${hierarchy}}`; let new_json = `{"profile":${profile},"group":${group},"tags":[${tags}],"hierarchy":${hierarchy}}`;
data.push(new_json); data.push(new_json);
json_profile.val('['+data+']'); json_profile.val(JSON.stringify(data));
profile_text = `<a href="index.php?sec2=godmode/users/configure_profile&id=${profile}">${profile_text}</a>`;
group_img = `<img id="img_group_${aux}" src="" data-title="${group_text}" data-use_title_for_force_title="1" class="bot forced_title" alt="${group_text}"/>`;
group_text = `<a href="index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60&group_id=${group}">${group_img}${group_text}</a>`;
$('#table_profiles tr:last').before( $('#table_profiles tr:last').before(
`<tr> `<tr>
<td>${profile_text}</td> <td>${profile_text}</td>
@ -1654,6 +1686,10 @@ $(document).ready (function () {
<td>${img_delete}</td> <td>${img_delete}</td>
</tr>` </tr>`
); );
getGroupIcon(group, $(`#img_group_${aux}`));
aux++;
} else { } else {
this.form.submit(); this.form.submit();
} }

View File

@ -31,8 +31,6 @@ global $config;
check_login(); check_login();
enterprise_hook('open_meta_frame');
require_once $config['homedir'].'/include/functions_profile.php'; require_once $config['homedir'].'/include/functions_profile.php';
require_once $config['homedir'].'/include/functions_users.php'; require_once $config['homedir'].'/include/functions_users.php';
require_once $config['homedir'].'/include/functions_groups.php'; require_once $config['homedir'].'/include/functions_groups.php';
@ -52,8 +50,47 @@ if (is_ajax()) {
$method = get_parameter('method'); $method = get_parameter('method');
$group_id = get_parameter('group_id'); $group_id = get_parameter('group_id');
$group_recursion = (bool) get_parameter('group_recursion', 0); $group_recursion = (bool) get_parameter('group_recursion', 0);
$get_user_profile_group = (bool) get_parameter('get_user_profile_group', false);
$return_all = false; $return_all = false;
if ($get_user_profile_group === true) {
$id_user = get_parameter('id_user');
$user_is_admin = users_is_admin();
$user_profiles = [];
if ($user_is_admin === false) {
$group_um = users_get_groups_UM($config['id_user']);
}
// User profiles.
if ($user_is_admin || $id_user == $config['id_user'] || isset($group_um[0])) {
$user_profiles = db_get_all_rows_field_filter(
'tusuario_perfil',
'id_usuario',
$id_user
);
} else {
$user_profiles_aux = users_get_user_profile($id_user);
foreach ($group_um as $key => $value) {
if (isset($user_profiles_aux[$key]) === true) {
$user_profiles[$key] = $user_profiles_aux[$key];
unset($user_profiles_aux[$key]);
}
}
}
foreach ($user_profiles as $key => $value) {
$user_profiles[$key]['id_perfil'] = profile_get_name($value['id_perfil']);
$user_profiles[$key]['id_grupo'] = groups_get_name($value['id_grupo'], true);
}
echo json_encode($user_profiles);
return;
}
if ($group_id == -1) { if ($group_id == -1) {
$sql = 'SELECT tusuario.id_user FROM tusuario $sql = 'SELECT tusuario.id_user FROM tusuario
LEFT OUTER JOIN tusuario_perfil LEFT OUTER JOIN tusuario_perfil
@ -95,6 +132,8 @@ if (is_ajax()) {
} }
} }
enterprise_hook('open_meta_frame');
$sortField = get_parameter('sort_field'); $sortField = get_parameter('sort_field');
$sort = get_parameter('sort', 'none'); $sort = get_parameter('sort', 'none');
$tab = get_parameter('tab', 'user'); $tab = get_parameter('tab', 'user');
@ -596,13 +635,11 @@ foreach ($info as $user_id => $user_info) {
// User profiles. // User profiles.
if ($user_is_admin || $user_id == $config['id_user'] || isset($group_um[0])) { if ($user_is_admin || $user_id == $config['id_user'] || isset($group_um[0])) {
$user_profiles = db_get_all_rows_field_filter( $user_profiles = db_get_all_rows_sql(
'tusuario_perfil', 'SELECT * FROM tusuario_perfil where id_usuario LIKE "'.$user_id.'" LIMIT 5'
'id_usuario',
$user_id
); );
} else { } else {
$user_profiles_aux = users_get_user_profile($user_id); $user_profiles_aux = users_get_user_profile($user_id, 'LIMIT 5');
$user_profiles = []; $user_profiles = [];
foreach ($group_um as $key => $value) { foreach ($group_um as $key => $value) {
if (isset($user_profiles_aux[$key]) === true) { if (isset($user_profiles_aux[$key]) === true) {
@ -682,39 +719,35 @@ foreach ($info as $user_id => $user_info) {
if ($user_profiles !== false) { if ($user_profiles !== false) {
$total_profile = 0; $total_profile = 0;
$data[4] .= '<div class="text_end">'; $data[4] .= '<div class="text_end">';
foreach ($user_profiles as $row) { foreach ($user_profiles as $row) {
if ($total_profile <= 5) { $data[4] .= "<div class='float-left'>";
$data[4] .= "<div class='float-left'>"; $data[4] .= profile_get_name($row['id_perfil']);
$data[4] .= profile_get_name($row['id_perfil']); $data[4] .= ' / </div>';
$data[4] .= ' / </div>'; $data[4] .= "<div class='float-left pdd_l_5px'>";
$data[4] .= "<div class='float-left pdd_l_5px'>"; $data[4] .= groups_get_name($row['id_grupo'], true);
$data[4] .= groups_get_name($row['id_grupo'], true); $data[4] .= '</div>';
$data[4] .= '</div>';
if ($total_profile == 0 && count($user_profiles) >= 5) { if ($total_profile == 0 && count($user_profiles) >= 5) {
$data[4] .= '<span onclick="showGroups()" class="pdd_l_15px"> $data[4] .= '<span onclick="showGroups(`'.$row['id_usuario'].'`)">'.html_print_image(
'.html_print_image( 'images/zoom.png',
'images/zoom.png', true,
true, [
[ 'title' => __('Show profiles'),
'title' => __('Show'), 'class' => 'invert_filter',
'class' => 'invert_filter', ]
] ).'</span>';
).'</span>';
}
$data[4] .= '<br />'; $data[4] .= html_print_input_hidden(
$data[4] .= '<br />'; 'show_groups_'.$row['id_usuario'],
$data[4] .= '</div>'; -1,
} else { true
$data[4] .= "<div id='groups_list' class='invisible'>"; );
$data[4] .= '<div >';
$data[4] .= profile_get_name($row['id_perfil']);
$data[4] .= ' / '.groups_get_name($row['id_grupo'], true).'</div>';
$data[4] .= '<br/>';
} }
$data[4] .= '<br/>';
$data[4] .= '<br/>';
$total_profile++; $total_profile++;
} }
@ -727,6 +760,8 @@ foreach ($info as $user_id => $user_info) {
} }
$data[4] .= '</div>'; $data[4] .= '</div>';
$data[4] .= '<div class="invisible" id="profiles_'.$user_profiles[0]['id_usuario'].'">';
$data[4] .= '</div>';
} else { } else {
$data[4] .= __('The user doesn\'t have any assigned profile/group'); $data[4] .= __('The user doesn\'t have any assigned profile/group');
} }
@ -890,16 +925,46 @@ echo '</div>';
enterprise_hook('close_meta_frame'); enterprise_hook('close_meta_frame');
echo '<script type="text/javascript"> ?>
function showGroups(){ <script type="text/javascript">
var groups_list = document.getElementById("groups_list"); function showGroups(id_user) {
if ($(`#hidden-show_groups_${id_user}`).val() === '-1') {
var request = $.ajax({
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
type: 'GET',
dataType: 'json',
data: {
page: 'godmode/users/user_list',
get_user_profile_group: 1,
id_user: id_user
},
success: function (data, textStatus, xhr) {
let count = 1;
data.forEach( function(valor, indice, array) {
if (count >= 6) {
let main_div = $(`#profiles_${id_user}`);
main_div.append(
`<div id="left_${id_user}_${count}" class='float-left'>${valor.id_perfil} / </div>`,
`<div id="right_${id_user}_${count}" class='float-left pdd_l_5px'>${valor.id_grupo}</div>`,
`<br/><br/>`
);
}
count ++;
});
},
error: function (e, textStatus) {
console.error(textStatus);
}
});
$(`#hidden-show_groups_${id_user}`).val('1');
$(`#profiles_${id_user}`).show();
} else if ($(`#hidden-show_groups_${id_user}`).val() === '1') {
$(`#hidden-show_groups_${id_user}`).val('0');
$(`#profiles_${id_user}`).hide();
} else {
$(`#hidden-show_groups_${id_user}`).val('1');
$(`#profiles_${id_user}`).show();
}
}
if(groups_list.style.display == "none"){ </script>
document.querySelectorAll("[id=groups_list]").forEach(element=>
element.style.display = "block");
}else{
document.querySelectorAll("[id=groups_list]").forEach(element=>
element.style.display = "none");
};
}
</script>';

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -1,6 +1,7 @@
<?php <?php
$token_name = get_parameter('token_name', 0); $token_name = get_parameter('token_name', 0);
$no_boolean = (bool) get_parameter('no_boolean', 0);
$value_token = db_get_value( $value_token = db_get_value(
'value', 'value',
@ -9,4 +10,8 @@ $value_token = db_get_value(
$token_name $token_name
); );
echo (bool) $value_token; if ($no_boolean === true) {
echo json_encode(io_safe_output($value_token));
} else {
echo (bool) $value_token;
}

View File

@ -64,9 +64,9 @@ $add_comment = (bool) get_parameter('add_comment');
$dialogue_event_response = (bool) get_parameter('dialogue_event_response'); $dialogue_event_response = (bool) get_parameter('dialogue_event_response');
$perform_event_response = (bool) get_parameter('perform_event_response'); $perform_event_response = (bool) get_parameter('perform_event_response');
$get_response = (bool) get_parameter('get_response'); $get_response = (bool) get_parameter('get_response');
$get_response_target = (bool) get_parameter('get_response_target'); $get_response_massive = (bool) get_parameter('get_response_massive');
$get_response_params = (bool) get_parameter('get_response_params'); $get_row_response_action = (bool) get_parameter('get_row_response_action');
$get_response_description = (bool) get_parameter('get_response_description'); $draw_row_response_info = (bool) get_parameter('draw_row_response_info', false);
$meta = get_parameter('meta', 0); $meta = get_parameter('meta', 0);
$history = get_parameter('history', 0); $history = get_parameter('history', 0);
$table_events = get_parameter('table_events', 0); $table_events = get_parameter('table_events', 0);
@ -90,7 +90,7 @@ $node_id = (int) get_parameter('node_id', 0);
if ($get_comments === true) { if ($get_comments === true) {
$event = get_parameter('event', false); $event = get_parameter('event', false);
$event_rep = get_parameter('event_rep', false); $event_rep = (int) get_parameter('event_rep', 0);
if ($event === false) { if ($event === false) {
return __('Failed to retrieve comments'); return __('Failed to retrieve comments');
} }
@ -98,7 +98,7 @@ if ($get_comments === true) {
$eventsGrouped = []; $eventsGrouped = [];
// Consider if the event is grouped. // Consider if the event is grouped.
$whereGrouped = '1=1'; $whereGrouped = '1=1';
if (isset($event_rep) === true && $event_rep > 0) { if ($event_rep === EVENT_GROUP_REP_EVENTS) {
// Default grouped message filtering (evento and estado). // Default grouped message filtering (evento and estado).
$whereGrouped = sprintf( $whereGrouped = sprintf(
'`evento` = "%s"', '`evento` = "%s"',
@ -119,6 +119,11 @@ if ($get_comments === true) {
(int) $event['id_agentmodule'] (int) $event['id_agentmodule']
); );
} }
} else if ($event_rep === EVENT_GROUP_REP_EXTRAIDS) {
$whereGrouped = sprintf(
'`id_extra` = "%s"',
$event['id_extra']
);
} else { } else {
$whereGrouped = sprintf('`id_evento` = %d', $event['id_evento']); $whereGrouped = sprintf('`id_evento` = %d', $event['id_evento']);
} }
@ -175,7 +180,7 @@ if ($delete_event === true) {
$filter = get_parameter('filter', []); $filter = get_parameter('filter', []);
$id_evento = (int) get_parameter('id_evento', 0); $id_evento = (int) get_parameter('id_evento', 0);
$server_id = (int) get_parameter('server_id', 0); $server_id = (int) get_parameter('server_id', 0);
$event_rep = get_parameter('event_rep', 0); $event_rep = (int) get_parameter('event_rep', 0);
try { try {
if (is_metaconsole() === true if (is_metaconsole() === true
@ -228,7 +233,7 @@ if ($validate_event === true) {
$filter = get_parameter('filter', []); $filter = get_parameter('filter', []);
$id_evento = (int) get_parameter('id_evento', 0); $id_evento = (int) get_parameter('id_evento', 0);
$server_id = (int) get_parameter('server_id', 0); $server_id = (int) get_parameter('server_id', 0);
$event_rep = get_parameter('event_rep', 0); $event_rep = (int) get_parameter('event_rep', 0);
try { try {
if (is_metaconsole() === true if (is_metaconsole() === true
@ -240,7 +245,7 @@ if ($validate_event === true) {
if ($event_rep === 0) { if ($event_rep === 0) {
// Disable group by when there're result is unique. // Disable group by when there're result is unique.
$filter['group_rep'] = 0; $filter['group_rep'] = EVENT_GROUP_REP_ALL;
} }
// Check acl. // Check acl.
@ -285,7 +290,7 @@ if ($in_process_event === true) {
$filter = get_parameter('filter', []); $filter = get_parameter('filter', []);
$id_evento = (int) get_parameter('id_evento', 0); $id_evento = (int) get_parameter('id_evento', 0);
$server_id = (int) get_parameter('server_id', 0); $server_id = (int) get_parameter('server_id', 0);
$event_rep = get_parameter('event_rep', 0); $event_rep = (int) get_parameter('event_rep', 0);
try { try {
if (is_metaconsole() === true if (is_metaconsole() === true
@ -297,7 +302,7 @@ if ($in_process_event === true) {
if ($event_rep === 0) { if ($event_rep === 0) {
// Disable group by when there're result is unique. // Disable group by when there're result is unique.
$filter['group_rep'] = 0; $filter['group_rep'] = EVENT_GROUP_REP_ALL;
} }
// Check acl. // Check acl.
@ -360,10 +365,11 @@ if ($save_event_filter) {
); );
$values['filter_only_alert'] = get_parameter('filter_only_alert'); $values['filter_only_alert'] = get_parameter('filter_only_alert');
$values['search_secondary_groups'] = get_parameter('search_secondary_groups'); $values['search_secondary_groups'] = get_parameter('search_secondary_groups');
$values['search_recursive_groups'] = get_parameter('search_recursive_groups');
$values['id_group_filter'] = get_parameter('id_group_filter'); $values['id_group_filter'] = get_parameter('id_group_filter');
$values['date_from'] = get_parameter('date_from'); $values['date_from'] = get_parameter('date_from', null);
$values['time_from'] = get_parameter('time_from'); $values['time_from'] = get_parameter('time_from');
$values['date_to'] = get_parameter('date_to'); $values['date_to'] = get_parameter('date_to', null);
$values['time_to'] = get_parameter('time_to'); $values['time_to'] = get_parameter('time_to');
$values['source'] = get_parameter('source'); $values['source'] = get_parameter('source');
$values['id_extra'] = get_parameter('id_extra'); $values['id_extra'] = get_parameter('id_extra');
@ -417,6 +423,7 @@ if ($update_event_filter) {
); );
$values['filter_only_alert'] = get_parameter('filter_only_alert'); $values['filter_only_alert'] = get_parameter('filter_only_alert');
$values['search_secondary_groups'] = get_parameter('search_secondary_groups'); $values['search_secondary_groups'] = get_parameter('search_secondary_groups');
$values['search_recursive_groups'] = get_parameter('search_recursive_groups');
$values['id_group_filter'] = get_parameter('id_group_filter'); $values['id_group_filter'] = get_parameter('id_group_filter');
$values['date_from'] = get_parameter('date_from'); $values['date_from'] = get_parameter('date_from');
$values['time_from'] = get_parameter('time_from'); $values['time_from'] = get_parameter('time_from');
@ -464,13 +471,13 @@ if ($get_filter_values) {
$event_filter = [ $event_filter = [
'status' => EVENT_NO_VALIDATED, 'status' => EVENT_NO_VALIDATED,
'event_view_hr' => $config['event_view_hr'], 'event_view_hr' => $config['event_view_hr'],
'group_rep' => 1,
'tag_with' => [], 'tag_with' => [],
'tag_without' => [], 'tag_without' => [],
'history' => false, 'history' => false,
'module_search' => '', 'module_search' => '',
'filter_only_alert' => '-1', 'filter_only_alert' => '-1',
'search_secondary_groups' => 0, 'search_secondary_groups' => 0,
'search_recursive_groups' => 0,
'user_comment' => '', 'user_comment' => '',
'id_extra' => '', 'id_extra' => '',
'id_user_ack' => '', 'id_user_ack' => '',
@ -480,7 +487,7 @@ if ($get_filter_values) {
'time_to' => '', 'time_to' => '',
'severity' => '', 'severity' => '',
'event_type' => '', 'event_type' => '',
'group_rep' => 0, 'group_rep' => EVENT_GROUP_REP_ALL,
'id_group' => 0, 'id_group' => 0,
'id_group_filter' => 0, 'id_group_filter' => 0,
'group_name' => 'All', 'group_name' => 'All',
@ -657,6 +664,8 @@ function load_form_filter() {
$("#filter_only_alert").val(val); $("#filter_only_alert").val(val);
if (i == 'search_secondary_groups') if (i == 'search_secondary_groups')
$("#checkbox-search_secondary_groups").val(val); $("#checkbox-search_secondary_groups").val(val);
if (i == 'search_recursive_groups')
$("#checkbox-search_recursive_groups").val(val);
if (i == 'id_group_filter') if (i == 'id_group_filter')
$("#id_group_filter").val(val); $("#id_group_filter").val(val);
if (i == 'source') if (i == 'source')
@ -900,6 +909,7 @@ function save_new_filter() {
"tag_without": Base64.decode($("#hidden-tag_without").val()), "tag_without": Base64.decode($("#hidden-tag_without").val()),
"filter_only_alert" : $("#filter_only_alert").val(), "filter_only_alert" : $("#filter_only_alert").val(),
"search_secondary_groups" : $("#checkbox-search_secondary_groups").val(), "search_secondary_groups" : $("#checkbox-search_secondary_groups").val(),
"search_recursive_groups" : $("#checkbox-search_recursive_groups").val(),
"id_group_filter": $("#id_group_filter_dialog").val(), "id_group_filter": $("#id_group_filter_dialog").val(),
"date_from": $("#text-date_from").val(), "date_from": $("#text-date_from").val(),
"time_from": $("#text-time_from").val(), "time_from": $("#text-time_from").val(),
@ -976,6 +986,7 @@ function save_update_filter() {
"tag_without" : Base64.decode($("#hidden-tag_without").val()), "tag_without" : Base64.decode($("#hidden-tag_without").val()),
"filter_only_alert" : $("#filter_only_alert").val(), "filter_only_alert" : $("#filter_only_alert").val(),
"search_secondary_groups" : $("#checkbox-search_secondary_groups").val(), "search_secondary_groups" : $("#checkbox-search_secondary_groups").val(),
"search_recursive_groups" : $("#checkbox-search_recursive_groups").val(),
"id_group_filter": $("#id_group_filter_dialog").val(), "id_group_filter": $("#id_group_filter_dialog").val(),
"date_from": $("#text-date_from").val(), "date_from": $("#text-date_from").val(),
"time_from": $("#text-time_from").val(), "time_from": $("#text-time_from").val(),
@ -1054,87 +1065,6 @@ $(document).ready(function (){
} }
if ($get_response_description) {
$response_id = get_parameter('response_id');
$description = db_get_value('description', 'tevent_response', 'id', $response_id);
if ($description === false) {
return;
}
$description = io_safe_output($description);
$description = str_replace("\r\n", '<br>', $description);
echo $description;
return;
}
if ($get_response_params) {
if (! check_acl($config['id_user'], 0, 'EW')) {
echo 'unauthorized';
return;
}
$response_id = get_parameter('response_id');
$params = db_get_value('params', 'tevent_response', 'id', $response_id);
if ($params === false) {
return;
}
echo json_encode(explode(',', $params));
return;
}
if ($get_response_target === true) {
if (! check_acl($config['id_user'], 0, 'EW')) {
echo 'unauthorized';
return;
}
$response_id = (int) get_parameter('response_id');
$event_id = (int) get_parameter('event_id');
$server_id = (int) get_parameter('server_id');
try {
if (is_metaconsole() === true
&& $server_id > 0
) {
$node = new Node($server_id);
$node->connect();
}
$event_response = db_get_row('tevent_response', 'id', $response_id);
if (empty($event_response) === true) {
return;
}
echo events_get_response_target($event_id, $response_id);
} catch (\Exception $e) {
// Unexistent agent.
if (is_metaconsole() === true
&& $server_id > 0
) {
$node->disconnect();
}
return;
} finally {
if (is_metaconsole() === true
&& $server_id > 0
) {
$node->disconnect();
}
}
return;
}
if ($get_response === true) { if ($get_response === true) {
if (! check_acl($config['id_user'], 0, 'EW')) { if (! check_acl($config['id_user'], 0, 'EW')) {
echo 'unauthorized'; echo 'unauthorized';
@ -1142,62 +1072,27 @@ if ($get_response === true) {
} }
$response_id = get_parameter('response_id'); $response_id = get_parameter('response_id');
$server_id = (int) get_parameter('server_id'); $server_id = (int) get_parameter('server_id', 0);
$event_id = (int) get_parameter('event_id', 0);
$response_parameters = json_decode(
io_safe_output(
get_parameter('response_parameters', '')
),
true
);
try { $event_response = db_get_row(
if (is_metaconsole() === true 'tevent_response',
&& $server_id > 0 'id',
) { $response_id
$node = new Node($server_id); );
$node->connect();
}
$event_response = db_get_row(
'tevent_response',
'id',
$response_id
);
} catch (\Exception $e) {
// Unexistent agent.
if (is_metaconsole() === true
&& $server_id > 0
) {
$node->disconnect();
}
return;
} finally {
if (is_metaconsole() === true
&& $server_id > 0
) {
$node->disconnect();
}
}
if (empty($event_response) === true) { if (empty($event_response) === true) {
return; return [];
} }
echo json_encode($event_response);
return; if (empty($event_id) === false) {
}
if ($perform_event_response === true) {
global $config;
if (! check_acl($config['id_user'], 0, 'EW')) {
echo 'unauthorized';
return;
}
$target = get_parameter('target', '');
$response_id = get_parameter('response_id');
$event_id = (int) get_parameter('event_id');
$server_id = (int) get_parameter('server_id', 0);
$event_response = false;
if (empty($target) === true) {
try { try {
if (is_metaconsole() === true if (is_metaconsole() === true
&& $server_id > 0 && $server_id > 0
@ -1206,20 +1101,12 @@ if ($perform_event_response === true) {
$node->connect(); $node->connect();
} }
$event_response = db_get_row( $event_response['target'] = events_get_response_target(
'tevent_response',
'id',
$response_id
);
if (empty($event_response) === true) {
return;
}
$command = events_get_response_target(
$event_id, $event_id,
$response_id, $event_response,
$server_id $response_parameters,
$server_id,
($server_id !== 0) ? $node->server_name() : 'Metaconsole'
); );
} catch (\Exception $e) { } catch (\Exception $e) {
// Unexistent agent. // Unexistent agent.
@ -1237,10 +1124,130 @@ if ($perform_event_response === true) {
$node->disconnect(); $node->disconnect();
} }
} }
} else {
$command = $target;
} }
echo json_encode($event_response);
return;
}
if ($get_response_massive === true) {
if (! check_acl($config['id_user'], 0, 'EW')) {
echo 'unauthorized';
return;
}
$response_id = get_parameter('response_id');
$event_response = db_get_row(
'tevent_response',
'id',
$response_id
);
if (empty($event_response) === true) {
return [];
}
$events = json_decode(
io_safe_output(
get_parameter('events', '')
),
true
);
$response_parameters = json_decode(
io_safe_output(
get_parameter('response_parameters', '')
),
true
);
$event_response_targets = [];
if (is_metaconsole() === true) {
foreach ($events as $server_id => $idEvents) {
foreach ($idEvents as $idEvent) {
$event_response_targets[$idEvent.'|'.$server_id]['target'] = get_events_get_response_target(
$idEvent,
$event_response,
$server_id,
$response_parameters
);
}
}
} else {
foreach ($events as $idEvent) {
$event_response_targets[$idEvent]['target'] = get_events_get_response_target(
$idEvent,
$event_response,
0,
$response_parameters
);
}
}
$result = [
'event_response' => $event_response,
'event_response_targets' => $event_response_targets,
];
echo json_encode($result);
return;
}
if ($get_row_response_action === true) {
$response_id = get_parameter('response_id');
$response = json_decode(
io_safe_output(
get_parameter('response', '')
),
true
);
$end = (bool) get_parameter('end', false);
$index = $response['event_id'];
if (is_metaconsole() === true) {
$index .= '-'.$response['server_id'];
}
echo get_row_response_action(
$response,
$response_id,
$end,
$index
);
return;
}
if ($perform_event_response === true) {
global $config;
if (! check_acl($config['id_user'], 0, 'EW')) {
echo __('unauthorized');
return;
}
$target = get_parameter('target', '');
$response_id = get_parameter('response_id');
$event_id = (int) get_parameter('event_id');
$server_id = (int) get_parameter('server_id', 0);
$response = json_decode(
io_safe_output(
get_parameter('response', '')
),
true
);
$event_response = $response;
if (empty($event_response) === true) {
echo __('No data');
return;
}
$command = $event_response['target'];
$command_timeout = ($event_response !== false) ? $event_response['command_timeout'] : 90; $command_timeout = ($event_response !== false) ? $event_response['command_timeout'] : 90;
if (enterprise_installed() === true) { if (enterprise_installed() === true) {
if ($event_response !== false if ($event_response !== false
@ -1320,7 +1327,7 @@ if ($perform_event_response === true) {
break; break;
} }
system($timeout_bin.' '.$command_timeout.' '.io_safe_output($command).' 2>&1', $ret_val); system($timeout_bin.' '.$command_timeout.' '.io_safe_output($command).' 2>&1', $ret_val);
} }
if ($ret_val != 0) { if ($ret_val != 0) {
@ -1343,78 +1350,19 @@ if ($dialogue_event_response) {
$event_id = get_parameter('event_id'); $event_id = get_parameter('event_id');
$response_id = get_parameter('response_id'); $response_id = get_parameter('response_id');
$command = get_parameter('target'); $command = get_parameter('target');
$massive = get_parameter('massive'); $event_response = json_decode(
$end = get_parameter('end'); io_safe_output(
$show_execute_again_btn = get_parameter('show_execute_again_btn'); get_parameter('response', '')
$out_iterator = get_parameter('out_iterator'); ),
$event_response = db_get_row('tevent_response', 'id', $response_id); true
$server_id = get_parameter('server_id'); );
$event = db_get_row('tevento', 'id_evento', $event_id);
$prompt = '<br>> ';
switch ($event_response['type']) { switch ($event_response['type']) {
case 'command': case 'command':
$display_command = (bool) $event_response['display_command']; echo get_row_response_action(
$command_str = ($display_command === true) ? $command : ''; $event_response,
$response_id
if ($massive) { );
echo "<div class='left'>";
echo $prompt.sprintf(
'(Event #'.$event_id.') '.__(
'Executing command: %s',
$command_str
)
);
echo '</div><br>';
echo "<div id='response_loading_command_".$out_iterator."' style='display: none'>";
echo html_print_image(
'images/spinner.gif',
true
);
echo '</div><br>';
echo "<br><div id='response_out_".$out_iterator."'><br><br></div><br>";
if ($end) {
echo "<br><div id='re_exec_command_".$out_iterator."' style='display: none'><br>";
html_print_button(
__('Execute again'),
'btn_str',
false,
'execute_event_response(false);',
"class='sub next'"
);
echo "<span id='execute_again_loading' style='display: none'>";
echo html_print_image(
'images/spinner.gif',
true
);
echo '</span>';
echo '</div>';
}
} else {
echo "<div class='left'>";
echo $prompt.'Executing command: '.$command_str;
echo '</div><br>';
echo "<div id='response_loading_command' style='display:none'>";
echo html_print_image('images/spinner.gif', true);
echo '</div>';
echo "<br><br><br><div id='response_out' class='left'></div>";
echo "<br><div id='re_exec_command' style='display:none'><br><br>";
html_print_button(
__('Execute again'),
'btn_str',
false,
"perform_response({'target':'".$command."','event_id':".$event_id.",'server_id':".$server_id.'}, '.$response_id.');',
"class='sub next'"
);
echo '</div>';
}
break; break;
case 'url': case 'url':
@ -2474,11 +2422,12 @@ if ($get_events_fired) {
'id_agent_module' => 0, 'id_agent_module' => 0,
'pagination' => 0, 'pagination' => 0,
'id_user_ack' => 0, 'id_user_ack' => 0,
'group_rep' => 0, 'group_rep' => EVENT_GROUP_REP_ALL,
'tag_with' => [], 'tag_with' => [],
'tag_without' => [], 'tag_without' => [],
'filter_only_alert' => -1, 'filter_only_alert' => -1,
'search_secondary_groups' => 0, 'search_secondary_groups' => 0,
'search_recursive_groups' => 0,
'source' => '', 'source' => '',
'id_extra' => '', 'id_extra' => '',
'user_comment' => '', 'user_comment' => '',
@ -2534,3 +2483,75 @@ if ($get_events_fired) {
echo io_json_mb_encode($return); echo io_json_mb_encode($return);
return; return;
} }
if ($draw_row_response_info === true) {
$event_response = json_decode(
io_safe_output(
get_parameter('response', '')
),
true
);
$massive = (bool) get_parameter('massive', false);
$output .= '';
if ($massive === true) {
$output .= '<div>';
$output .= '<h5>';
$output .= $event_response['description'];
$output .= '</h5>';
$output .= '</div>';
} else {
$output .= '<tr class="params_rows">';
$output .= '<td>';
$output .= __('Description');
$output .= '</td>';
$output .= '<td class="height_30px" colspan="2">';
$output .= $event_response['description'];
$output .= '</td>';
$output .= '</tr>';
}
if (empty($event_response['params']) === false) {
$response_params = explode(',', $event_response['params']);
if (is_array($response_params) === true) {
if ($massive === true) {
$output .= '<div>';
} else {
$output .= '<tr class="params_rows">';
$output .= '<td class="left pdd_l_20px height_30px" colspan="3">';
$output .= __('Parameters');
$output .= '</td>';
$output .= '</tr>';
}
foreach ($response_params as $param) {
$param = trim(io_safe_output($param));
if ($massive === true) {
$output .= '<div>';
$output .= '<label>';
$output .= $param;
$output .= '</label>';
$output .= '<input type="text" name="values_params_'.$param.'" />';
$output .= '</div>';
} else {
$output .= '<tr class="params_rows">';
$output .= '<td style="text-align:left; padding-left:40px; font-weight: normal; font-style: italic;">';
$output .= $param;
$output .= '</td>';
$output .= '<td style="text-align:left" colspan="2">';
$output .= '<input type="text" name="values_params_'.$param.'" />';
$output .= '</td>';
$output .= '</tr>';
}
}
if ($massive === true) {
$output .= '</div>';
}
}
}
echo $output;
return;
}

View File

@ -78,6 +78,7 @@ if (is_ajax() === true) {
0 => __('Group agents'), 0 => __('Group agents'),
1 => __('Group modules by tag'), 1 => __('Group modules by tag'),
2 => __('Group modules by module group'), 2 => __('Group modules by module group'),
3 => __('Group modules by agents'),
], ],
'type', 'type',
$type, $type,
@ -203,6 +204,10 @@ if (is_ajax() === true) {
'5' '5'
); );
break; break;
case 3:
// Empty.
break;
} }
echo '</div>'; echo '</div>';
@ -212,6 +217,7 @@ if (is_ajax() === true) {
enterprise_include_once('include/functions_agents.php'); enterprise_include_once('include/functions_agents.php');
$id = get_parameter('id', 0); $id = get_parameter('id', 0);
switch ($type) { switch ($type) {
case 3:
case 2: case 2:
$data = db_get_row('tagente_modulo', 'id_agente_modulo', $id); $data = db_get_row('tagente_modulo', 'id_agente_modulo', $id);

View File

@ -1,22 +1,38 @@
<?php <?php
// Pandora FMS - http://pandorafms.com /**
// ================================================== * MySQL Authentication functions.
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas *
// Please see http://pandorafms.org for full contribution list * @category Functions.
// This program is free software; you can redistribute it and/or * @package Pandora FMS
// modify it under the terms of the GNU Lesser General Public License * @subpackage Login.
// as published by the Free Software Foundation; version 2 * @version 1.0.0
// This program is distributed in the hope that it will be useful, * @license See below
// 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. * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org 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.
/** /**
* @package Include/auth * @package Include/auth
*/ */
if (!isset($config)) { if (isset($config) === false) {
die( die(
' '
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
@ -63,7 +79,7 @@ $config['user_can_update_password'] = true;
$config['admin_can_add_user'] = true; $config['admin_can_add_user'] = true;
$config['admin_can_delete_user'] = true; $config['admin_can_delete_user'] = true;
$config['admin_can_disable_user'] = false; $config['admin_can_disable_user'] = false;
// currently not implemented // Currently not implemented.
$config['admin_can_make_admin'] = true; $config['admin_can_make_admin'] = true;
@ -289,7 +305,7 @@ function process_user_login_remote($login, $pass, $api=false)
// Authentication ok, check if the user exists in the local database // Authentication ok, check if the user exists in the local database
if (is_user($login)) { if (is_user($login)) {
if (!user_can_login($login)) { if (!user_can_login($login) && $api === false) {
return false; return false;
} }
@ -544,7 +560,7 @@ function get_user_fullname($user)
/** /**
* Gets the users email * Gets the users email
* *
* @param mixed User id. * @param mixed $user User id.
* *
* @return string The users email address * @return string The users email address
*/ */
@ -557,14 +573,14 @@ function get_user_email($user)
/** /**
* Gets a Users info * Gets a Users info
* *
* @param mixed User id * @param mixed $user User id.
* *
* @return mixed An array of users * @return mixed An array of users
*/ */
function get_user_info($user) function get_user_info($user)
{ {
static $cache_user_info = []; static $cache_user_info = [];
if (array_key_exists($user, $cache_user_info)) { if (array_key_exists($user, $cache_user_info) === true) {
return $cache_user_info[$user]; return $cache_user_info[$user];
} else { } else {
$return = db_get_row('tusuario', 'id_user', get_user_id($user)); $return = db_get_row('tusuario', 'id_user', get_user_id($user));
@ -579,24 +595,19 @@ function get_user_info($user)
* We can't simplify this because some auth schemes (like LDAP) automatically (or it's at least cheaper to) return all the information * We can't simplify this because some auth schemes (like LDAP) automatically (or it's at least cheaper to) return all the information
* Functions like get_user_info allow selection of specifics (in functions_db) * Functions like get_user_info allow selection of specifics (in functions_db)
* *
* @param string Field to order by (id_user, fullname or registered) * @param mixed $order Field to order by (id_user, fullname or registered).
* @param string $filter Filter.
* @param string $fields Fields.
* *
* @return array An array of user information * @return array An array of user information
*/ */
function get_users($order='fullname', $filter=false, $fields=false) function get_users($order='fullname', $filter=false, $fields=false)
{ {
if (is_array($order)) { if (is_array($order) === true) {
$filter['order'] = $order['field'].' '.$order['order']; $filter['order'] = $order['field'].' '.$order['order'];
} else { } else {
switch ($order) { if ($order !== 'registered' || $order !== 'last_connect' || $order !== 'fullname') {
case 'registered': $order = 'fullname';
case 'last_connect':
case 'fullname':
break;
default:
$order = 'fullname';
break;
} }
$filter['order'] = $order.' ASC'; $filter['order'] = $order.' ASC';
@ -618,9 +629,11 @@ function get_users($order='fullname', $filter=false, $fields=false)
/** /**
* Sets the last login for a user * Sets the last login for a user
* *
* @param string User id * @param string $id_user User id.
*
* @return mixed.
*/ */
function process_user_contact($id_user) function process_user_contact(string $id_user)
{ {
return db_process_sql_update( return db_process_sql_update(
'tusuario', 'tusuario',
@ -633,6 +646,10 @@ function process_user_contact($id_user)
/** /**
* Create a new user * Create a new user
* *
* @param string $id_user Id User.
* @param string $password Password for this user.
* @param array $user_info Array with information of the user.
*
* @return boolean false * @return boolean false
*/ */
function create_user($id_user, $password, $user_info) function create_user($id_user, $password, $user_info)
@ -643,16 +660,48 @@ function create_user($id_user, $password, $user_info)
$values['last_connect'] = 0; $values['last_connect'] = 0;
$values['registered'] = get_system_time(); $values['registered'] = get_system_time();
return (@db_process_sql_insert('tusuario', $values)) !== false; $output = (@db_process_sql_insert('tusuario', $values)) !== false;
// Add user to notification system.
if ($output !== false) {
if (isset($values['is_admin']) === true && (bool) $values['is_admin'] === true) {
// Administrator user must be activated in all notifications sections.
$notificationSources = db_get_all_rows_filter('tnotification_source', [], 'id');
foreach ($notificationSources as $notification) {
@db_process_sql_insert(
'tnotification_source_user',
[
'id_source' => $notification['id'],
'id_user' => $id_user,
]
);
}
} else {
// Other users only will be activated in `Message` notifications.
$notificationSource = db_get_value('id', 'tnotification_source', 'description', 'Message');
@db_process_sql_insert(
'tnotification_source_user',
[
'id_source' => $notificationSource,
'id_user' => $id_user,
]
);
}
}
return $output;
} }
/** /**
* Save password history * Save password history
* *
* @param string $id_user Id User.
* @param string $password Password of user.
*
* @return boolean false * @return boolean false
*/ */
function save_pass_history($id_user, $password) function save_pass_history(string $id_user, string $password)
{ {
$values['id_user'] = $id_user; $values['id_user'] = $id_user;
$values['password'] = md5($password); $values['password'] = md5($password);
@ -665,9 +714,11 @@ function save_pass_history($id_user, $password)
/** /**
* Deletes the user * Deletes the user
* *
* @param string User id * @param string $id_user User id.
*
* @return boolean.
*/ */
function delete_user($id_user) function delete_user(string $id_user)
{ {
$result = db_process_sql_delete( $result = db_process_sql_delete(
'tusuario_perfil', 'tusuario_perfil',
@ -685,6 +736,12 @@ function delete_user($id_user)
return false; return false;
} }
// Remove from notification list as well.
$result = db_process_sql_delete(
'tnotification_source_user',
['id_user' => $id_user]
);
return true; return true;
} }
@ -693,15 +750,21 @@ function delete_user($id_user)
* Update the password in MD5 for user pass as id_user with * Update the password in MD5 for user pass as id_user with
* password in plain text. * password in plain text.
* *
* @param string user User ID * @param string $user User ID.
* @param string password Password in plain text. * @param string $password_new Password in plain text.
* *
* @return mixed False in case of error or invalid values passed. Affected rows otherwise * @return mixed False in case of error or invalid values passed. Affected rows otherwise
*/ */
function update_user_password($user, $password_new) function update_user_password(string $user, string $password_new)
{ {
global $config; global $config;
if (isset($config['auth']) && $config['auth'] == 'pandora') {
if (excludedPassword($password_new) === true) {
$config['auth_error'] = __('The password provided is not valid. Please, set another one.');
return false;
}
if (isset($config['auth']) === true && $config['auth'] === 'pandora') {
$sql = sprintf( $sql = sprintf(
"UPDATE tusuario SET password = '".md5($password_new)."', last_pass_change = '".date('Y-m-d H:i:s', get_system_time())."' WHERE id_user = '".$user."'" "UPDATE tusuario SET password = '".md5($password_new)."', last_pass_change = '".date('Y-m-d H:i:s', get_system_time())."' WHERE id_user = '".$user."'"
); );
@ -714,7 +777,7 @@ function update_user_password($user, $password_new)
); );
$remote_pass_update = db_process_sql($sql, 'affected_rows', $connection); $remote_pass_update = db_process_sql($sql, 'affected_rows', $connection);
if (!$remote_pass_update) { if ((bool) $remote_pass_update === false) {
$config['auth_error'] = __('Could not changes password on remote pandora'); $config['auth_error'] = __('Could not changes password on remote pandora');
return false; return false;
} }
@ -735,14 +798,14 @@ function update_user_password($user, $password_new)
* Update the data of a user that user is choose with * Update the data of a user that user is choose with
* id_user. * id_user.
* *
* @param string user User ID * @param string $id_user User ID.
* @param array values Associative array with index as name of field and content. * @param array $values Associative array with index as name of field and content.
* *
* @return mixed False in case of error or invalid values passed. Affected rows otherwise * @return mixed False in case of error or invalid values passed. Affected rows otherwise
*/ */
function update_user($id_user, $values) function update_user(string $id_user, array $values)
{ {
if (! is_array($values)) { if (is_array($values) === false) {
return false; return false;
} }
@ -799,8 +862,16 @@ function ldap_process_user_login($login, $password, $secondary_server=false)
return false; return false;
} }
// Set the LDAP version // Set the LDAP version.
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, $ldap['ldap_version']); ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, $ldap['ldap_version']);
ldap_set_option($ds, LDAP_OPT_NETWORK_TIMEOUT, 1);
// Set ldap search timeout.
ldap_set_option(
$ds,
LDAP_OPT_TIMELIMIT,
(empty($config['ldap_search_timeout']) === true) ? 5 : ((int) $config['ldap_search_timeout'])
);
if ($ldap['ldap_start_tls']) { if ($ldap['ldap_start_tls']) {
if (!@ldap_start_tls($ds)) { if (!@ldap_start_tls($ds)) {
@ -821,7 +892,8 @@ function ldap_process_user_login($login, $password, $secondary_server=false)
io_safe_output($ldap['ldap_admin_login']), io_safe_output($ldap['ldap_admin_login']),
io_output_password($ldap['ldap_admin_pass']), io_output_password($ldap['ldap_admin_pass']),
io_safe_output($login), io_safe_output($login),
$ldap['ldap_start_tls'] $ldap['ldap_start_tls'],
$config['ldap_search_timeout']
); );
if ($sr) { if ($sr) {
@ -1430,7 +1502,8 @@ function local_ldap_search(
$ldap_admin_user=null, $ldap_admin_user=null,
$ldap_admin_pass=null, $ldap_admin_pass=null,
$user=null, $user=null,
$ldap_start_tls=null $ldap_start_tls=null,
$ldap_search_time=5
) { ) {
global $config; global $config;
@ -1463,8 +1536,8 @@ function local_ldap_search(
} }
$dn = " -b '".$dn."'"; $dn = " -b '".$dn."'";
$ldapsearch_command = 'ldapsearch -LLL -o ldif-wrap=no -o nettimeout='.$ldap_search_time.' -x'.$ldap_host.$ldap_version.' -E pr=10000/noprompt '.$ldap_admin_user.$ldap_admin_pass.$dn.$filter.$tls.' | grep -v "^#\|^$" | sed "s/:\+ /=>/g"';
$shell_ldap_search = explode("\n", shell_exec('ldapsearch -LLL -o ldif-wrap=no -x'.$ldap_host.$ldap_version.' -E pr=10000/noprompt '.$ldap_admin_user.$ldap_admin_pass.$dn.$filter.$tls.' | grep -v "^#\|^$" | sed "s/:\+ /=>/g"')); $shell_ldap_search = explode("\n", shell_exec($ldapsearch_command));
foreach ($shell_ldap_search as $line) { foreach ($shell_ldap_search as $line) {
$values = explode('=>', $line); $values = explode('=>', $line);
if (!empty($values[0]) && !empty($values[1])) { if (!empty($values[0]) && !empty($values[1])) {

View File

@ -14,7 +14,7 @@
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
* *
* ============================================================================ * ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas * Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list * Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -285,6 +285,13 @@ class AgentWizard extends HTML
*/ */
private $wmiBinary = ''; private $wmiBinary = '';
/**
* Default values for SNMP Interfaces.
*
* @var string
*/
private $defaultSNMPValues = [];
/** /**
* Constructor * Constructor
@ -319,6 +326,7 @@ class AgentWizard extends HTML
$this->idPolicy = get_parameter('id', ''); $this->idPolicy = get_parameter('id', '');
$this->targetIp = get_parameter('targetIp', ''); $this->targetIp = get_parameter('targetIp', '');
$this->wmiBinary = $config['wmiBinary']; $this->wmiBinary = $config['wmiBinary'];
$this->defaultSNMPValues = (array) json_decode(io_safe_output($config['agent_wizard_defaults']));
if (empty($this->idAgent) === false) { if (empty($this->idAgent) === false) {
$array_aux = db_get_all_rows_sql( $array_aux = db_get_all_rows_sql(
@ -330,7 +338,7 @@ class AgentWizard extends HTML
) )
); );
if (!empty($array_aux)) { if (empty($array_aux) === false) {
$this->datalist = []; $this->datalist = [];
foreach ($array_aux as $key => $value) { foreach ($array_aux as $key => $value) {
$this->datalist[] = $value['ip']; $this->datalist[] = $value['ip'];
@ -547,7 +555,7 @@ class AgentWizard extends HTML
// Fill with servers to perform the discover. // Fill with servers to perform the discover.
$fieldsServers = []; $fieldsServers = [];
$fieldsServers[0] = __('Local console'); $fieldsServers[0] = __('Local console');
if (enterprise_installed()) { if (enterprise_installed() === true) {
enterprise_include_once('include/functions_satellite.php'); enterprise_include_once('include/functions_satellite.php');
// Get the servers. // Get the servers.
$rows = get_proxy_servers(); $rows = get_proxy_servers();
@ -607,7 +615,7 @@ class AgentWizard extends HTML
], ],
]; ];
if (!empty($this->datalist)) { if (empty($this->datalist) === false) {
$inputs[] = [ $inputs[] = [
'id' => 'li_address_list', 'id' => 'li_address_list',
'arguments' => [ 'arguments' => [
@ -4719,7 +4727,7 @@ class AgentWizard extends HTML
'execution_type' => 'network', 'execution_type' => 'network',
'value' => '1.3.6.1.2.1.2.2.1.8.'.$value, 'value' => '1.3.6.1.2.1.2.2.1.8.'.$value,
'module_unit' => '', 'module_unit' => '',
'default_enabled' => true, 'default_enabled' => (bool) $this->defaultSNMPValues['ifOperStatus'],
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => $min_warning, 'min_warning' => $min_warning,
@ -4776,7 +4784,7 @@ class AgentWizard extends HTML
'execution_type' => 'network', 'execution_type' => 'network',
'value' => '1.3.6.1.4.1.9.2.2.1.1.12.'.$value, 'value' => '1.3.6.1.4.1.9.2.2.1.1.12.'.$value,
'module_unit' => 'packets/s', 'module_unit' => 'packets/s',
'default_enabled' => true, 'default_enabled' => (bool) $this->defaultSNMPValues['locIfInCRC'],
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
@ -4830,7 +4838,7 @@ class AgentWizard extends HTML
'module_info' => 'Indicates whether the port is operating in half-duplex, full-duplex, disagree or auto negotiation mode. If the port could not agree with the far end on port duplex, the port will be in disagree(3) mode.', 'module_info' => 'Indicates whether the port is operating in half-duplex, full-duplex, disagree or auto negotiation mode. If the port could not agree with the far end on port duplex, the port will be in disagree(3) mode.',
'execution_type' => 'network', 'execution_type' => 'network',
'value' => $duplexMismatchOID, 'value' => $duplexMismatchOID,
'default_enabled' => true, 'default_enabled' => (bool) $this->defaultSNMPValues['DuplexMismatch'],
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
@ -4919,7 +4927,7 @@ class AgentWizard extends HTML
'id_plugin' => $plugin_id, 'id_plugin' => $plugin_id,
'id_modulo' => MODULE_PLUGIN, 'id_modulo' => MODULE_PLUGIN,
'macros' => json_encode($macros), 'macros' => json_encode($macros),
'default_enabled' => true, 'default_enabled' => (bool) $this->defaultSNMPValues['Bandwidth'],
'module_enabled' => false, 'module_enabled' => false,
'module_unit' => '%', 'module_unit' => '%',
'module_thresholds' => [ 'module_thresholds' => [
@ -4958,7 +4966,7 @@ class AgentWizard extends HTML
'id_plugin' => $plugin_id, 'id_plugin' => $plugin_id,
'id_modulo' => MODULE_PLUGIN, 'id_modulo' => MODULE_PLUGIN,
'macros' => json_encode($macros), 'macros' => json_encode($macros),
'default_enabled' => true, 'default_enabled' => (bool) $this->defaultSNMPValues['inUsage'],
'module_enabled' => false, 'module_enabled' => false,
'module_unit' => '%', 'module_unit' => '%',
'module_thresholds' => [ 'module_thresholds' => [
@ -4997,7 +5005,7 @@ class AgentWizard extends HTML
'id_plugin' => $plugin_id, 'id_plugin' => $plugin_id,
'id_modulo' => MODULE_PLUGIN, 'id_modulo' => MODULE_PLUGIN,
'macros' => json_encode($macros), 'macros' => json_encode($macros),
'default_enabled' => true, 'default_enabled' => (bool) $this->defaultSNMPValues['outUsage'],
'module_enabled' => false, 'module_enabled' => false,
'module_unit' => '%', 'module_unit' => '%',
'module_thresholds' => [ 'module_thresholds' => [
@ -5029,7 +5037,7 @@ class AgentWizard extends HTML
'execution_type' => 'network', 'execution_type' => 'network',
'value' => '1.3.6.1.2.1.2.2.1.7.'.$value, 'value' => '1.3.6.1.2.1.2.2.1.7.'.$value,
'module_unit' => '', 'module_unit' => '',
'default_enabled' => false, 'default_enabled' => (bool) $this->defaultSNMPValues['ifAdminStatus'],
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
@ -5056,7 +5064,7 @@ class AgentWizard extends HTML
'execution_type' => 'network', 'execution_type' => 'network',
'value' => '1.3.6.1.2.1.2.2.1.13.'.$value, 'value' => '1.3.6.1.2.1.2.2.1.13.'.$value,
'module_unit' => 'packets/s', 'module_unit' => 'packets/s',
'default_enabled' => false, 'default_enabled' => (bool) $this->defaultSNMPValues['ifInDiscards'],
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
@ -5083,7 +5091,7 @@ class AgentWizard extends HTML
'execution_type' => 'network', 'execution_type' => 'network',
'value' => '1.3.6.1.2.1.2.2.1.19.'.$value, 'value' => '1.3.6.1.2.1.2.2.1.19.'.$value,
'module_unit' => 'packets/s', 'module_unit' => 'packets/s',
'default_enabled' => false, 'default_enabled' => (bool) $this->defaultSNMPValues['ifOutDiscards'],
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
@ -5110,7 +5118,7 @@ class AgentWizard extends HTML
'execution_type' => 'network', 'execution_type' => 'network',
'value' => '1.3.6.1.2.1.2.2.1.14.'.$value, 'value' => '1.3.6.1.2.1.2.2.1.14.'.$value,
'module_unit' => 'packets/s', 'module_unit' => 'packets/s',
'default_enabled' => false, 'default_enabled' => (bool) $this->defaultSNMPValues['ifInErrors'],
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
@ -5137,7 +5145,7 @@ class AgentWizard extends HTML
'execution_type' => 'network', 'execution_type' => 'network',
'value' => '1.3.6.1.2.1.2.2.1.20.'.$value, 'value' => '1.3.6.1.2.1.2.2.1.20.'.$value,
'module_unit' => 'packets/s', 'module_unit' => 'packets/s',
'default_enabled' => false, 'default_enabled' => (bool) $this->defaultSNMPValues['ifOutErrors'],
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
@ -5207,7 +5215,7 @@ class AgentWizard extends HTML
'execution_type' => 'network', 'execution_type' => 'network',
'value' => '1.3.6.1.2.1.2.2.1.10.'.$value, 'value' => '1.3.6.1.2.1.2.2.1.10.'.$value,
'module_unit' => 'bytes/s', 'module_unit' => 'bytes/s',
'default_enabled' => true, 'default_enabled' => (bool) $this->defaultSNMPValues['ifInOctets'],
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
@ -5235,7 +5243,7 @@ class AgentWizard extends HTML
'execution_type' => 'network', 'execution_type' => 'network',
'value' => '1.3.6.1.2.1.2.2.1.16.'.$value, 'value' => '1.3.6.1.2.1.2.2.1.16.'.$value,
'module_unit' => 'bytes/s', 'module_unit' => 'bytes/s',
'default_enabled' => true, 'default_enabled' => (bool) $this->defaultSNMPValues['ifOutOctets'],
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
@ -5263,7 +5271,7 @@ class AgentWizard extends HTML
'execution_type' => 'network', 'execution_type' => 'network',
'value' => '1.3.6.1.2.1.2.2.1.11.'.$value, 'value' => '1.3.6.1.2.1.2.2.1.11.'.$value,
'module_unit' => 'packets/s', 'module_unit' => 'packets/s',
'default_enabled' => false, 'default_enabled' => (bool) $this->defaultSNMPValues['ifInUcastPkts'],
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
@ -5290,7 +5298,7 @@ class AgentWizard extends HTML
'execution_type' => 'network', 'execution_type' => 'network',
'value' => '1.3.6.1.2.1.2.2.1.17.'.$value, 'value' => '1.3.6.1.2.1.2.2.1.17.'.$value,
'module_unit' => 'packets/s', 'module_unit' => 'packets/s',
'default_enabled' => false, 'default_enabled' => (bool) $this->defaultSNMPValues['ifOutUcastPkts'],
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
@ -5317,7 +5325,7 @@ class AgentWizard extends HTML
'execution_type' => 'network', 'execution_type' => 'network',
'value' => '1.3.6.1.2.1.2.2.1.12.'.$value, 'value' => '1.3.6.1.2.1.2.2.1.12.'.$value,
'module_unit' => 'packets/s', 'module_unit' => 'packets/s',
'default_enabled' => false, 'default_enabled' => (bool) $this->defaultSNMPValues['ifInNUcastPkts'],
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
@ -5344,7 +5352,7 @@ class AgentWizard extends HTML
'execution_type' => 'network', 'execution_type' => 'network',
'value' => '1.3.6.1.2.1.2.2.1.18.'.$value, 'value' => '1.3.6.1.2.1.2.2.1.18.'.$value,
'module_unit' => 'packets/s', 'module_unit' => 'packets/s',
'default_enabled' => false, 'default_enabled' => (bool) $this->defaultSNMPValues['ifOutNUcastPkts'],
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
@ -5414,7 +5422,7 @@ class AgentWizard extends HTML
'execution_type' => 'network', 'execution_type' => 'network',
'value' => '1.3.6.1.2.1.31.1.1.1.6.'.$value, 'value' => '1.3.6.1.2.1.31.1.1.1.6.'.$value,
'module_unit' => 'bytes/s', 'module_unit' => 'bytes/s',
'default_enabled' => true, 'default_enabled' => (bool) $this->defaultSNMPValues['ifHCInOctets'],
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
@ -5442,7 +5450,7 @@ class AgentWizard extends HTML
'execution_type' => 'network', 'execution_type' => 'network',
'value' => '1.3.6.1.2.1.31.1.1.1.10.'.$value, 'value' => '1.3.6.1.2.1.31.1.1.1.10.'.$value,
'module_unit' => 'bytes/s', 'module_unit' => 'bytes/s',
'default_enabled' => true, 'default_enabled' => (bool) $this->defaultSNMPValues['ifHCOutOctets'],
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
@ -5470,7 +5478,7 @@ class AgentWizard extends HTML
'execution_type' => 'network', 'execution_type' => 'network',
'value' => '1.3.6.1.2.1.31.1.1.1.7.'.$value, 'value' => '1.3.6.1.2.1.31.1.1.1.7.'.$value,
'module_unit' => 'packets/s', 'module_unit' => 'packets/s',
'default_enabled' => false, 'default_enabled' => (bool) $this->defaultSNMPValues['ifHCInUcastPkts'],
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
@ -5498,7 +5506,7 @@ class AgentWizard extends HTML
'execution_type' => 'network', 'execution_type' => 'network',
'value' => '1.3.6.1.2.1.31.1.1.1.11.'.$value, 'value' => '1.3.6.1.2.1.31.1.1.1.11.'.$value,
'module_unit' => 'packets/s', 'module_unit' => 'packets/s',
'default_enabled' => false, 'default_enabled' => (bool) $this->defaultSNMPValues['ifHCOutUcastPkts'],
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
@ -5525,7 +5533,7 @@ class AgentWizard extends HTML
'execution_type' => 'network', 'execution_type' => 'network',
'value' => '1.3.6.1.2.1.31.1.1.1.7.'.$value, 'value' => '1.3.6.1.2.1.31.1.1.1.7.'.$value,
'module_unit' => 'packets/s', 'module_unit' => 'packets/s',
'default_enabled' => false, 'default_enabled' => (bool) $this->defaultSNMPValues['ifHCInNUcastPkts'],
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',
@ -5552,7 +5560,7 @@ class AgentWizard extends HTML
'execution_type' => 'network', 'execution_type' => 'network',
'value' => '1.3.6.1.2.1.31.1.1.1.11.'.$value, 'value' => '1.3.6.1.2.1.31.1.1.1.11.'.$value,
'module_unit' => 'packets/s', 'module_unit' => 'packets/s',
'default_enabled' => false, 'default_enabled' => (bool) $this->defaultSNMPValues['ifHCOutNUcastPkts'],
'module_enabled' => false, 'module_enabled' => false,
'module_thresholds' => [ 'module_thresholds' => [
'min_warning' => '0', 'min_warning' => '0',

View File

@ -933,7 +933,13 @@ class HTML
$cb_args = $data['cb_args']; $cb_args = $data['cb_args'];
$output_head = '<form class="discovery" onsubmit="'.$form['onsubmit'].'" enctype="'.$form['enctype'].'" action="'.$form['action'].'" method="'.$form['method']; $output_head = '<form class="discovery" onsubmit="'.$form['onsubmit'].'" enctype="'.$form['enctype'].'" action="'.$form['action'].'" method="'.$form['method'];
$output_head .= '" '.$form['extra'].'>'; $output_head .= '" id="'.$form['id'].'" '.$form['extra'].'>';
if (isset($form['title']) === true && empty($form['title']) === false) {
$output_head .= '<div class="form_title"">';
$output_head .= '<span>'.$form['title'].'</span>';
$output_head .= '</div>';
}
if ($return === false) { if ($return === false) {
echo $output_head; echo $output_head;

View File

@ -139,7 +139,7 @@ class Heatmap
ui_require_css_file('heatmap'); ui_require_css_file('heatmap');
$settings = [ $settings = [
'type' => 'POST', 'type' => 'GET',
'dataType' => 'html', 'dataType' => 'html',
'url' => ui_get_full_url( 'url' => ui_get_full_url(
'ajax.php', 'ajax.php',
@ -169,11 +169,41 @@ class Heatmap
setting['data']['height'] = $(`#div_${randomId}`).height() + 10; setting['data']['height'] = $(`#div_${randomId}`).height() + 10;
setting['data']['width'] = $(`#div_${randomId}`).width(); setting['data']['width'] = $(`#div_${randomId}`).width();
var totalModules = 0;
// Initial charge. // Initial charge.
ajaxRequest( $.ajax({
`div_${randomId}`, type: setting.type,
setting dataType: setting.dataType,
); url: setting.url,
data: setting.data,
success: function(data) {
$(`#div_${randomId}`).append(data);
totalModules = $('rect').length;
let cont = 0;
while (cont < Math.ceil(totalModules / 10)) {
oneSquare(getRandomInteger(1, 10), getRandomInteger(100, 900));
cont ++;
}
}
});
function getRandomInteger(min, max) {
return Math.floor(Math.random() * max) + min;
}
function oneSquare(solid, time) {
var randomPoint = getRandomInteger(1, totalModules);
let target = $(`#${randomId}_${randomPoint}`);
setTimeout(function() {
let class_name = target.attr('class');
class_name = class_name.split(' ')[0];
const newClassName = class_name.split('_')[0];
target.removeClass(`${class_name} hover`);
target.addClass(`${newClassName}_${solid} hover`);
oneSquare(getRandomInteger(1, 10), getRandomInteger(100, 900));
}, time);
}
// Refresh. // Refresh.
setInterval( setInterval(
@ -206,23 +236,29 @@ class Heatmap
// randomly sort. // randomly sort.
lista = lista.sort(function() {return Math.random() - 0.5}); lista = lista.sort(function() {return Math.random() - 0.5});
const countPerSecond = total / refresh; let countPerSecond = total / refresh;
if (countPerSecond < 1) {
countPerSecond = 1;
}
let cont = 0; let cont = 0;
let limit = countPerSecond - 1; let limit = countPerSecond - 1;
const timer = setInterval( const timer = setInterval(
function() { function() {
while (cont <= limit) { while (cont <= limit) {
$(`#${randomId}_${lista[cont]['id']}`).removeClass(); if (typeof lista[cont] !== 'undefined') {
$(`#${randomId}_${lista[cont]['id']}`).addClass(`${lista[cont]['status']} hover`); const rect = document.getElementsByName(`${lista[cont]['id']}`);
$(`#${rect[0].id}`).removeClass();
cont++; $(`#${rect[0].id}`).addClass(`${lista[cont]['status']} hover`);
} }
limit = limit + countPerSecond;
}, cont++;
1000 }
); limit = limit + countPerSecond;
},
1000
);
setTimeout( setTimeout(
function(){ function(){
@ -314,8 +350,10 @@ class Heatmap
// All agents. // All agents.
$sql = sprintf( $sql = sprintf(
'SELECT DISTINCT id_agente as id,alias,id_grupo,normal_count,warning_count,critical_count, unknown_count,notinit_count,total_count,fired_count, 'SELECT DISTINCT id_agente as id,alias,id_grupo,normal_count,warning_count,critical_count,
(SELECT last_status_change FROM tagente_estado WHERE id_agente = tagente.id_agente ORDER BY last_status_change DESC LIMIT 1) AS last_status_change unknown_count,notinit_count,total_count,fired_count,
(SELECT last_status_change FROM tagente_estado WHERE id_agente = tagente.id_agente
ORDER BY last_status_change DESC LIMIT 1) AS last_status_change
FROM tagente WHERE `disabled` = 0 %s %s ORDER BY id_grupo,id_agente ASC', FROM tagente WHERE `disabled` = 0 %s %s ORDER BY id_grupo,id_agente ASC',
$alias, $alias,
$id_grupo $id_grupo
@ -391,7 +429,8 @@ class Heatmap
// All modules. // All modules.
$sql = sprintf( $sql = sprintf(
'SELECT am.id_agente_modulo AS id, ae.known_status AS `status`, am.id_module_group AS id_grupo, ae.last_status_change FROM tagente_modulo am 'SELECT am.id_agente_modulo AS id, ae.estado AS `status`, am.id_module_group AS id_grupo,
ae.last_status_change FROM tagente_modulo am
INNER JOIN tagente_estado ae ON am.id_agente_modulo = ae.id_agente_modulo INNER JOIN tagente_estado ae ON am.id_agente_modulo = ae.id_agente_modulo
WHERE am.disabled = 0 %s %s GROUP BY am.id_module_group, am.id_agente_modulo', WHERE am.disabled = 0 %s %s GROUP BY am.id_module_group, am.id_agente_modulo',
$filter_group, $filter_group,
@ -489,7 +528,8 @@ class Heatmap
// All modules. // All modules.
$sql = sprintf( $sql = sprintf(
'SELECT ae.id_agente_modulo AS id, ae.known_status AS `status`, tm.id_tag AS id_grupo, ae.last_status_change FROM tagente_estado ae 'SELECT ae.id_agente_modulo AS id, ae.estado AS `status`, tm.id_tag AS id_grupo,
ae.last_status_change FROM tagente_estado ae
INNER JOIN ttag_module tm ON tm.id_agente_modulo = ae.id_agente_modulo INNER JOIN ttag_module tm ON tm.id_agente_modulo = ae.id_agente_modulo
WHERE 1=1 %s %s GROUP BY tm.id_tag, ae.id_agente_modulo', WHERE 1=1 %s %s GROUP BY tm.id_tag, ae.id_agente_modulo',
$filter_tag, $filter_tag,
@ -567,6 +607,98 @@ class Heatmap
} }
/**
* Get all modules group by agents
*
* @return array
*/
protected function getAllModulesByAgents()
{
$filter_name = '';
if (empty($this->search) === false) {
$filter_name = 'AND nombre LIKE "%'.$this->search.'%"';
}
// All modules.
$sql = sprintf(
'SELECT am.id_agente_modulo AS id, ae.estado AS `status`, am.id_agente AS id_grupo,
ae.last_status_change FROM tagente_modulo am
INNER JOIN tagente_estado ae ON am.id_agente_modulo = ae.id_agente_modulo
WHERE am.disabled = 0 %s GROUP BY ae.id_agente_modulo ORDER BY id_grupo',
$filter_name
);
$result = db_get_all_rows_sql($sql);
// Module status.
foreach ($result as $key => $module) {
$status = '';
switch ($module['status']) {
case AGENT_MODULE_STATUS_CRITICAL_BAD:
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
case 1:
case 100:
$status = 'critical';
break;
case AGENT_MODULE_STATUS_NORMAL:
case AGENT_MODULE_STATUS_NORMAL_ALERT:
case 0:
case 300:
$status = 'normal';
break;
case AGENT_MODULE_STATUS_WARNING:
case AGENT_MODULE_STATUS_WARNING_ALERT:
case 2:
case 200:
$status = 'warning';
break;
default:
case AGENT_MODULE_STATUS_UNKNOWN:
case 3:
$status = 'unknown';
break;
case AGENT_MODULE_STATUS_NOT_INIT:
case 5:
$status = 'notinit';
break;
}
if ($module['last_status_change'] != 0) {
$seconds = (time() - $module['last_status_change']);
if ($seconds >= SECONDS_1DAY) {
$status .= '_10';
} else if ($seconds >= 77760) {
$status .= '_9';
} else if ($seconds >= 69120) {
$status .= '_8';
} else if ($seconds >= 60480) {
$status .= '_7';
} else if ($seconds >= 51840) {
$status .= '_6';
} else if ($seconds >= 43200) {
$status .= '_5';
} else if ($seconds >= 34560) {
$status .= '_4';
} else if ($seconds >= 25920) {
$status .= '_3';
} else if ($seconds >= 17280) {
$status .= '_2';
} else if ($seconds >= 8640) {
$status .= '_1';
}
}
$result[$key]['status'] = $status;
}
return $result;
}
/** /**
* GetData * GetData
* *
@ -575,6 +707,10 @@ class Heatmap
public function getData() public function getData()
{ {
switch ($this->type) { switch ($this->type) {
case 3:
$data = $this->getAllModulesByAgents();
break;
case 2: case 2:
$data = $this->getAllModulesByGroup(); $data = $this->getAllModulesByGroup();
break; break;
@ -709,9 +845,10 @@ class Heatmap
$groups = []; $groups = [];
$contX = 0; $contX = 0;
$contY = 0; $contY = 0;
$cont = 1;
foreach ($result as $value) { foreach ($result as $value) {
echo '<rect id="'.$this->randomId.'_'.$value['id'].'" class="'.$value['status'].' hover" echo '<rect id="'.$this->randomId.'_'.$cont.'" class="'.$value['status'].' hover"
width="1" height="1" x ="'.$contX.' "y="'.$contY.'" />'; width="1" height="1" x ="'.$contX.' "y="'.$contY.'" name="'.$value['id'].'" />';
$contX++; $contX++;
if ($contX >= $Xaxis) { if ($contX >= $Xaxis) {
@ -724,14 +861,15 @@ class Heatmap
} else { } else {
$groups[$value['id_grupo']] += 1; $groups[$value['id_grupo']] += 1;
} }
$cont++;
} }
?> ?>
<script type="text/javascript"> <script type="text/javascript">
$('rect').click(function() { $('rect').click(function() {
const type = <?php echo $this->type; ?>; const type = <?php echo $this->type; ?>;
const hash = '<?php echo $this->randomId; ?>'; const id = $(`#${this.id}`).attr("name");
const id = this.id.replace(`${hash}_`, '');
$("#info_dialog").dialog({ $("#info_dialog").dialog({
resizable: true, resizable: true,
@ -778,6 +916,10 @@ class Heatmap
foreach ($groups as $key => $group) { foreach ($groups as $key => $group) {
$name = ''; $name = '';
switch ($this->type) { switch ($this->type) {
case 3:
$name = agents_get_alias($key);
break;
case 2: case 2:
$name = modules_get_modulegroup_name($key); $name = modules_get_modulegroup_name($key);
break; break;

View File

@ -223,8 +223,9 @@ class SatelliteAgent extends HTML
echo $modal.$msg.$aux; echo $modal.$msg.$aux;
echo '<div id="satellite_actions" class="action-buttons" style="width: 100%">'; echo '<div style="display: flex;justify-content: space-between;">';
echo '<div class="flex-content-left">';
html_print_select( html_print_select(
[ [
'0' => 'Disable / Enable selected agents', '0' => 'Disable / Enable selected agents',
@ -248,18 +249,18 @@ class SatelliteAgent extends HTML
); );
echo '</div>'; echo '</div>';
echo '</br></br>'; // Create button add host.
echo '<div class="flex-content-right">';
// Create button.
echo '<div class="w100p flex-content-right">';
html_print_submit_button( html_print_submit_button(
__('Add host'), __('Add host'),
'create', 'create',
false, false,
'class="sub next"' 'class="sub next"'
); );
echo '</div>';
echo '</div>'; echo '</div>';
// Load own javascript file. // Load own javascript file.
echo $this->loadJS(); echo $this->loadJS();
} }
@ -1255,6 +1256,8 @@ class SatelliteAgent extends HTML
$(document).ready(function() { $(document).ready(function() {
$('body').append('<div id="dialog"></div>');
$("#submit-create").on('click', function() { $("#submit-create").on('click', function() {
show_form(); show_form();
}); });
@ -1267,61 +1270,140 @@ class SatelliteAgent extends HTML
$('#submit-submit_satellite_action').click(function() { $('#submit-submit_satellite_action').click(function() {
const checks = $('input[name*=check_]:checked'); const checks = $('input[name*=check_]:checked');
const action = $('#satellite_action').val(); const action = $('#satellite_action').val();
$.each(checks, function(i, val) { let agent_delete_error = [];
const params = val.value.split(","); let agent_disable_error = [];
if (action === '0') { $('#aux').empty();
if (params[2] === '0') { $('#aux').text('<?php echo __('Are you sure?'); ?>');
$.ajax({ $('#aux').dialog({
method: 'post', title: (action === '0') ? '<?php echo __('Disable / Enable Agents'); ?>' : '<?php echo __('Delete / create Agents'); ?>',
async: false, buttons: [
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>', {
data: { class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel',
page: 'enterprise/godmode/servers/agents_satellite', text: '<?php echo __('Cancel'); ?>',
method: 'disableAgent', click: function(e) {
address: params[0], $(this).dialog('close');
disable: params[3], cleanupDOM();
id: params[4],
name: params[1],
no_msg: 1,
server_remote: <?php echo $this->satellite_server; ?>,
},
datatype: "json",
success: function (data) {
},
error: function(e) {
console.error(e);
}
});
}
} else {
if (params[3] === '0') {
$.ajax({
method: 'post',
async: false,
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
data: {
page: 'enterprise/godmode/servers/agents_satellite',
method: 'deleteAgent',
address: params[0],
name: params[1],
id: params[4],
delete: params[2],
no_msg: 1,
server_remote: <?php echo $this->satellite_server; ?>,
},
datatype: "json",
success: function (data) {
},
error: function(e) {
console.error(e);
}
});
}
}
});
var dt_satellite_agents = $("#satellite_agents").DataTable(); }
dt_satellite_agents.draw(); },
{
text: '<?php echo __('Ok'); ?>',
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next',
click: function(e) {
$(this).dialog('close');
$.each(checks, function(i, val) {
const params = val.value.split(",");
if (action === '0') {
if (params[2] === '0') {
$.ajax({
method: 'post',
async: false,
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
data: {
page: 'enterprise/godmode/servers/agents_satellite',
method: 'disableAgent',
address: params[0],
disable: params[3],
id: params[4],
name: params[1],
no_msg: 1,
server_remote: <?php echo $this->satellite_server; ?>,
},
datatype: "json",
success: function (data) {
},
error: function(e) {
console.error(e);
}
});
} else {
agent_disable_error.push(params[0]);
}
} else {
if (params[3] === '0') {
$.ajax({
method: 'post',
async: false,
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
data: {
page: 'enterprise/godmode/servers/agents_satellite',
method: 'deleteAgent',
address: params[0],
name: params[1],
id: params[4],
delete: params[2],
no_msg: 1,
server_remote: <?php echo $this->satellite_server; ?>,
},
datatype: "json",
success: function (data) {
},
error: function(e) {
console.error(e);
}
});
} else {
agent_delete_error.push(params[0]);
}
}
});
if (agent_delete_error.length > 0) {
$("#dialog").dialog({
resizable: true,
draggable: true,
modal: true,
height: 240,
width: 600,
title: '<?php echo __('Warning'); ?>',
open: function(){
let text = '<?php echo __('These agents could not be deleted. They must first be enabled'); ?>';
text += ` (${agent_delete_error.join()})`;
$('#dialog').html(`<br><table><tr><td><img src="images/icono-warning-triangulo.png" class="float-left mrgn_lft_25px"></td><td><p id="p_configurar_agente" >${text}</p></td></tr></table>`);
},
buttons: [
{
text: "Ok",
click: function() {
$( this ).dialog( "close" );
return false;
}
}
]
});
}
if (agent_disable_error.length > 0) {
$("#dialog").dialog({
resizable: true,
draggable: true,
modal: true,
height: 240,
width: 600,
title: '<?php echo __('Warning'); ?>',
open: function(){
let text = '<?php echo __('These agents could not be disabled. They must first be created'); ?>';
text += ` (${agent_disable_error.join()})`;
$('#dialog').html(`<br><table><tr><td><img src="images/icono-warning-triangulo.png" class="float-left mrgn_lft_25px"></td><td><p id="p_configurar_agente" >${text}</p></td></tr></table>`);
},
buttons: [
{
text: "Ok",
click: function() {
$( this ).dialog( "close" );
return false;
}
}
]
});
}
var dt_satellite_agents = $("#satellite_agents").DataTable();
dt_satellite_agents.draw();
}
}
]
});
}); });
}); });

View File

@ -537,7 +537,7 @@ class TreeService extends Tree
if (empty($title) === true) { if (empty($title) === true) {
$tmp['title'] = ''; $tmp['title'] = '';
} else { } else {
$tmp['title'] = $title.'/'; $tmp['title'] = io_safe_output($title).'/';
} }
$tmp['title'] .= $service->name(); $tmp['title'] .= $service->name();

View File

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

View File

@ -45,6 +45,11 @@ define('EVENT_VALIDATE', 1);
define('EVENT_PROCESS', 2); define('EVENT_PROCESS', 2);
define('EVENT_NO_VALIDATED', 3); define('EVENT_NO_VALIDATED', 3);
// Events group by constants.
define('EVENT_GROUP_REP_ALL', 0);
define('EVENT_GROUP_REP_EVENTS', 1);
define('EVENT_GROUP_REP_AGENTS', 2);
define('EVENT_GROUP_REP_EXTRAIDS', 3);
// Agents disabled status. // Agents disabled status.
define('AGENT_ENABLED', 0); define('AGENT_ENABLED', 0);

View File

@ -3487,12 +3487,13 @@ function agents_get_agent_custom_field($agent_id, $custom_field_name)
/** /**
* Unverified documentation. * Unverified documentation.
* *
* @param integer $id_group Module group. * @param integer $id_group Module group.
* @param array $id_agents Array of agent ids. * @param array $id_agents Array of agent ids.
* @param boolean $selection Show common (false) or all modules (true). * @param boolean $selection Show common (false) or all modules (true).
* @param boolean $return Return (false) or dump to output (true). * @param boolean $return Return (false) or dump to output (true).
* @param boolean $index_by_name Use module name as key. * @param boolean $index_by_name Use module name as key.
* @param boolean $pure_return Return as retrieved from DB. * @param boolean $pure_return Return as retrieved from DB.
* @param boolean $notStringModules Not string modules.
* *
* @return array With modules or null if error. * @return array With modules or null if error.
*/ */
@ -3502,7 +3503,8 @@ function select_modules_for_agent_group(
$selection, $selection,
$return=true, $return=true,
$index_by_name=false, $index_by_name=false,
$pure_return=false $pure_return=false,
$notStringModules=false
) { ) {
global $config; global $config;
$agents = (empty($id_agents)) ? [] : implode(',', $id_agents); $agents = (empty($id_agents)) ? [] : implode(',', $id_agents);
@ -3510,6 +3512,7 @@ function select_modules_for_agent_group(
$filter_agent_group = ''; $filter_agent_group = '';
$filter_group = ''; $filter_group = '';
$filter_agent = ''; $filter_agent = '';
$filter_not_string_modules = '';
$selection_filter = ''; $selection_filter = '';
$sql_conditions_tags = ''; $sql_conditions_tags = '';
$sql_tags_inner = ''; $sql_tags_inner = '';
@ -3524,6 +3527,23 @@ function select_modules_for_agent_group(
$filter_agent = ' AND tagente.id_agente IN ('.$agents.')'; $filter_agent = ' AND tagente.id_agente IN ('.$agents.')';
} }
if ($notStringModules === true) {
$filter_not_string_modules = sprintf(
' AND (tagente_modulo.id_tipo_modulo <> %d AND
tagente_modulo.id_tipo_modulo <> %d AND
tagente_modulo.id_tipo_modulo <> %d AND
tagente_modulo.id_tipo_modulo <> %d AND
tagente_modulo.id_tipo_modulo <> %d AND
tagente_modulo.id_tipo_modulo <> %d)',
MODULE_TYPE_GENERIC_DATA_STRING,
MODULE_TYPE_REMOTE_TCP_STRING,
MODULE_TYPE_REMOTE_SNMP_STRING,
MODULE_TYPE_ASYNC_STRING,
MODULE_TYPE_WEB_CONTENT_STRING,
MODULE_TYPE_REMOTE_CMD_STRING
);
}
if (!users_can_manage_group_all('AR')) { if (!users_can_manage_group_all('AR')) {
$group_string = implode(',', $groups); $group_string = implode(',', $groups);
$filter_agent_group = " AND ( $filter_agent_group = " AND (
@ -3567,6 +3587,7 @@ function select_modules_for_agent_group(
$filter_agent_group $filter_agent_group
$filter_group $filter_group
$filter_agent $filter_agent
$filter_not_string_modules
$sql_conditions_tags $sql_conditions_tags
) x ) x
GROUP BY nombre GROUP BY nombre

View File

@ -7673,8 +7673,7 @@ function api_set_planned_downtimes_delete_agents($id, $thrash1, $other, $thrash3
} }
if (!empty($other['data'][0])) { if (!empty($other['data'][0])) {
$agents = io_safe_input($other['data']); $agents = $other['data'];
$agents = explode(';', $agents);
$results = false; $results = false;
foreach ($agents as $agent) { foreach ($agents as $agent) {
if (db_get_value_sql(sprintf('SELECT id from tplanned_downtime_agents WHERE id_agent = %d AND id_downtime = %d', $agent, $id)) !== false) { if (db_get_value_sql(sprintf('SELECT id from tplanned_downtime_agents WHERE id_agent = %d AND id_downtime = %d', $agent, $id)) !== false) {
@ -7750,8 +7749,7 @@ function api_set_planned_downtimes_add_agents($id, $thrash1, $other, $thrash3)
} }
if (!empty($other['data'][0])) { if (!empty($other['data'][0])) {
$agents = io_safe_input($other['data']); $agents = $other['data'];
$agents = explode(';', $agents);
$results = false; $results = false;
foreach ($agents as $agent) { foreach ($agents as $agent) {
if (db_get_value_sql(sprintf('SELECT id from tplanned_downtime_agents tpd WHERE tpd.id_agent = %d AND id_downtime = %d', $agent, $id)) === false) { if (db_get_value_sql(sprintf('SELECT id from tplanned_downtime_agents tpd WHERE tpd.id_agent = %d AND id_downtime = %d', $agent, $id)) === false) {
@ -10137,7 +10135,7 @@ function api_set_module_data($id, $thrash2, $other, $trash1)
} }
if ($other['type'] == 'array') { if ($other['type'] == 'array') {
if (!util_api_check_agent_and_print_error(modules_get_agentmodule_agent($id), 'string', 'AW')) { if (!util_api_check_agent_and_print_error(modules_get_agentmodule_agent($id), 'string')) {
return; return;
} }
@ -11248,7 +11246,7 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
$id_user_ack = 0; $id_user_ack = 0;
$event_view_hr = 0; $event_view_hr = 0;
$tag = ''; $tag = '';
$group_rep = 0; $group_rep = EVENT_GROUP_REP_ALL;
$utimestamp_upper = 0; $utimestamp_upper = 0;
$utimestamp_bottom = 0; $utimestamp_bottom = 0;
$id_alert_template = -1; $id_alert_template = -1;
@ -11451,7 +11449,7 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
$alert_join = ' INNER JOIN talert_template_modules ON '.$table_events.'.id_alert_am=talert_template_modules.id'; $alert_join = ' INNER JOIN talert_template_modules ON '.$table_events.'.id_alert_am=talert_template_modules.id';
} }
if ($group_rep == 0) { if ($group_rep == EVENT_GROUP_REP_ALL) {
if ($filter['total']) { if ($filter['total']) {
$sql = 'SELECT COUNT(*) $sql = 'SELECT COUNT(*)
FROM '.$table_events.' FROM '.$table_events.'
@ -15924,7 +15922,7 @@ function api_set_create_event_filter($name, $thrash1, $other, $thrash3)
$id_user_ack = (in_array($other['data'][9], $users)) ? $other['data'][9] : 0; $id_user_ack = (in_array($other['data'][9], $users)) ? $other['data'][9] : 0;
$group_rep = ($other['data'][10] == 0 || $other['data'][10] == 1) ? $other['data'][10] : 0; $group_rep = ($other['data'][10] == EVENT_GROUP_REP_ALL || $other['data'][10] == EVENT_GROUP_REP_EVENTS) ? $other['data'][10] : EVENT_GROUP_REP_ALL;
$date_from = (preg_match('/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/', $other['data'][11])) ? $other['data'][11] : '0000-00-00'; $date_from = (preg_match('/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/', $other['data'][11])) ? $other['data'][11] : '0000-00-00';
@ -16151,7 +16149,7 @@ function api_set_update_event_filter($id_event_filter, $thrash1, $other, $thrash
break; break;
case 11: case 11:
$values['group_rep'] = ($other['data'][11] == 0 || $other['data'][11] == 1) ? $other['data'][11] : 0; $values['group_rep'] = ($other['data'][11] == EVENT_GROUP_REP_ALL || $other['data'][11] == EVENT_GROUP_REP_EVENTS) ? $other['data'][11] : EVENT_GROUP_REP_ALL;
break; break;
case 12: case 12:

View File

@ -467,7 +467,7 @@ function config_update_config()
break; break;
case 'pass': case 'pass':
if (isset($config['enterprise_installed']) === true && (bool) $config['enterprise_installed'] === 1) { if (isset($config['enterprise_installed']) === true && (bool) $config['enterprise_installed'] === true) {
if (config_update_value('enable_pass_policy', get_parameter('enable_pass_policy'), true) === false) { if (config_update_value('enable_pass_policy', get_parameter('enable_pass_policy'), true) === false) {
$error_update[] = __('Enable password policy'); $error_update[] = __('Enable password policy');
} }
@ -515,6 +515,10 @@ function config_update_config()
if (config_update_value('reset_pass_option', (bool) get_parameter('reset_pass_option'), true) === false) { if (config_update_value('reset_pass_option', (bool) get_parameter('reset_pass_option'), true) === false) {
$error_update[] = __('Activate reset password'); $error_update[] = __('Activate reset password');
} }
if (config_update_value('exclusion_word_list', (string) get_parameter('exclusion_word_list'), true) === false) {
$error_update[] = __('Exclusion word list for passwords');
}
} }
break; break;
@ -608,10 +612,14 @@ function config_update_config()
$error_update[] = __('Admin LDAP login'); $error_update[] = __('Admin LDAP login');
} }
if (config_update_value('ldap_admin_pass', io_input_password(io_safe_output(get_parameter('ldap_admin_pass'))), true) === false) { if (config_update_value('ldap_admin_pass', io_input_password(get_parameter('ldap_admin_pass')), true) === false) {
$error_update[] = __('Admin LDAP password'); $error_update[] = __('Admin LDAP password');
} }
if (config_update_value('ldap_search_timeout', (int) get_parameter('ldap_search_timeout', 5), true) === false) {
$error_update[] = __('Ldap search timeout');
}
if (config_update_value('ldap_server_secondary', get_parameter('ldap_server_secondary'), true) === false) { if (config_update_value('ldap_server_secondary', get_parameter('ldap_server_secondary'), true) === false) {
$error_update[] = __('Secondary LDAP server'); $error_update[] = __('Secondary LDAP server');
} }
@ -640,7 +648,7 @@ function config_update_config()
$error_update[] = __('Admin secondary LDAP login'); $error_update[] = __('Admin secondary LDAP login');
} }
if (config_update_value('ldap_admin_pass_secondary', io_input_password(io_safe_output(get_parameter('ldap_admin_pass_secondary'))), true) === false) { if (config_update_value('ldap_admin_pass_secondary', io_input_password(get_parameter('ldap_admin_pass_secondary')), true) === false) {
$error_update[] = __('Admin secondary LDAP password'); $error_update[] = __('Admin secondary LDAP password');
} }
@ -909,6 +917,16 @@ function config_update_config()
$error_update[] = __('Default WMI Binary'); $error_update[] = __('Default WMI Binary');
} }
// Walk the array with defaults.
$defaultAgentWizardOptions = json_decode(io_safe_output($config['agent_wizard_defaults']));
foreach ($defaultAgentWizardOptions as $key => $value) {
$selectedAgentWizardOptions[$key] = get_parameter_switch('agent_wizard_defaults_'.$key);
}
if (config_update_value('agent_wizard_defaults', json_encode($selectedAgentWizardOptions), true) === false) {
$error_update[] = __('SNMP Interface Agent Wizard');
}
$pjs = get_parameter('phantomjs_cache_interval'); $pjs = get_parameter('phantomjs_cache_interval');
switch ($pjs) { switch ($pjs) {
case $config['phantomjs_cache_interval']: case $config['phantomjs_cache_interval']:
@ -1570,9 +1588,10 @@ function config_update_config()
} }
$history_db_string_days = get_parameter('history_db_string_days'); $history_db_string_days = get_parameter('history_db_string_days');
if (is_numeric($history_db_string_days) === false if ((is_numeric($history_db_string_days) === false
|| $history_db_string_days <= 0 || $history_db_string_days <= 0
|| config_update_value('history_db_string_days', $history_db_string_days) === false || config_update_value('history_db_string_days', $history_db_string_days) === false)
&& get_parameter_switch('history_db_adv', 0) === 1
) { ) {
$error_update[] = __('String Days'); $error_update[] = __('String Days');
} }
@ -1836,7 +1855,7 @@ function config_update_config()
$config['error_config_update_config']['correct'] = false; $config['error_config_update_config']['correct'] = false;
$values = implode('<br> -', $error_update); $values = implode('<br> -', $error_update);
$config['error_config_update_config']['message'] = sprintf( $config['error_config_update_config']['message'] = sprintf(
__('Failed updated: the next values cannot update: <br> -%s'), __('Update failed. The next values could not be updated: <br> -%s'),
$values $values
); );
@ -2184,6 +2203,10 @@ function config_process_config()
config_update_value('reset_pass_option', 0); config_update_value('reset_pass_option', 0);
} }
if (isset($config['exclusion_word_list']) === false) {
config_update_value('exclusion_word_list', '');
}
if (!isset($config['include_agents'])) { if (!isset($config['include_agents'])) {
config_update_value('include_agents', 0); config_update_value('include_agents', 0);
} }
@ -2244,6 +2267,32 @@ function config_process_config()
config_update_value('2Fa_auth', ''); config_update_value('2Fa_auth', '');
} }
if (isset($config['agent_wizard_defaults']) === false) {
config_update_value(
'agent_wizard_defaults',
json_encode(
[
'ifOperStatus' => 1,
'ifInOctets' => 1,
'ifOutOctets' => 1,
'ifInUcastPkts' => 0,
'ifOutUcastPkts' => 0,
'ifInNUcastPkts' => 0,
'ifOutNUcastPkts' => 0,
'locIfInCRC' => 1,
'Bandwidth' => 1,
'inUsage' => 1,
'outUsage' => 1,
'ifAdminStatus' => 0,
'ifInDiscards' => 0,
'ifOutDiscards' => 0,
'ifInErrors' => 0,
'ifOutErrors' => 0,
]
)
);
}
/* /*
* Parse the ACL IP list for access API * Parse the ACL IP list for access API
*/ */
@ -2660,6 +2709,10 @@ function config_process_config()
config_update_value('ldap_admin_pass', ''); config_update_value('ldap_admin_pass', '');
} }
if (!isset($config['ldap_search_timeout'])) {
config_update_value('ldap_search_timeout', 5);
}
if (!isset($config['ldap_server_secondary'])) { if (!isset($config['ldap_server_secondary'])) {
config_update_value('ldap_server_secondary', 'localhost'); config_update_value('ldap_server_secondary', 'localhost');
} }

View File

@ -382,14 +382,14 @@ function events_delete($id_evento, $filter=null, $history=false, $force_node=fal
} }
if (isset($filter) === false if (isset($filter) === false
|| is_array($filter) === true || is_array($filter) === false
) { ) {
$filter = ['group_rep' => 0]; $filter = ['group_rep' => EVENT_GROUP_REP_ALL];
} }
switch ($filter['group_rep']) { switch ($filter['group_rep']) {
case '0': case EVENT_GROUP_REP_ALL:
case '2': case EVENT_GROUP_REP_AGENTS:
default: default:
// No groups option direct update. // No groups option direct update.
$delete_sql = sprintf( $delete_sql = sprintf(
@ -399,7 +399,8 @@ function events_delete($id_evento, $filter=null, $history=false, $force_node=fal
); );
break; break;
case '1': case EVENT_GROUP_REP_EVENTS:
case EVENT_GROUP_REP_EXTRAIDS:
// Group by events. // Group by events.
$sql = events_get_all( $sql = events_get_all(
['te.*'], ['te.*'],
@ -418,8 +419,16 @@ function events_delete($id_evento, $filter=null, $history=false, $force_node=fal
true true
); );
$target_ids = db_get_all_rows_sql( if ((int) $filter['group_rep'] === EVENT_GROUP_REP_EXTRAIDS) {
sprintf( $sql = sprintf(
'SELECT tu.id_evento FROM tevento tu INNER JOIN ( %s ) tf
ON tu.id_extra = tf.id_extra
AND tf.max_id_evento = %d',
$sql,
$id_evento
);
} else {
$sql = sprintf(
'SELECT tu.id_evento FROM tevento tu INNER JOIN ( %s ) tf 'SELECT tu.id_evento FROM tevento tu INNER JOIN ( %s ) tf
ON tu.estado = tf.estado ON tu.estado = tf.estado
AND tu.evento = tf.evento AND tu.evento = tf.evento
@ -428,8 +437,10 @@ function events_delete($id_evento, $filter=null, $history=false, $force_node=fal
AND tf.max_id_evento = %d', AND tf.max_id_evento = %d',
$sql, $sql,
$id_evento $id_evento
) );
); }
$target_ids = db_get_all_rows_sql($sql);
// Try to avoid deadlock while updating full set. // Try to avoid deadlock while updating full set.
if ($target_ids !== false && count($target_ids) > 0) { if ($target_ids !== false && count($target_ids) > 0) {
@ -475,12 +486,12 @@ function events_update_status($id_evento, $status, $filter=null)
} }
if (isset($filter) === false || is_array($filter) === false) { if (isset($filter) === false || is_array($filter) === false) {
$filter = ['group_rep' => 0]; $filter = ['group_rep' => EVENT_GROUP_REP_ALL];
} }
switch ($filter['group_rep']) { switch ($filter['group_rep']) {
case '0': case EVENT_GROUP_REP_ALL:
case '2': case EVENT_GROUP_REP_AGENTS:
default: default:
// No groups option direct update. // No groups option direct update.
$update_sql = sprintf( $update_sql = sprintf(
@ -492,7 +503,8 @@ function events_update_status($id_evento, $status, $filter=null)
); );
break; break;
case '1': case EVENT_GROUP_REP_EVENTS:
case EVENT_GROUP_REP_EXTRAIDS:
// Group by events. // Group by events.
$sql = events_get_all( $sql = events_get_all(
['te.*'], ['te.*'],
@ -511,8 +523,16 @@ function events_update_status($id_evento, $status, $filter=null)
true true
); );
$target_ids = db_get_all_rows_sql( if ((int) $filter['group_rep'] === EVENT_GROUP_REP_EXTRAIDS) {
sprintf( $sql = sprintf(
'SELECT tu.id_evento FROM tevento tu INNER JOIN ( %s ) tf
ON tu.id_extra = tf.id_extra
AND tf.max_id_evento = %d',
$sql,
$id_evento
);
} else {
$sql = sprintf(
'SELECT tu.id_evento FROM tevento tu INNER JOIN ( %s ) tf 'SELECT tu.id_evento FROM tevento tu INNER JOIN ( %s ) tf
ON tu.estado = tf.estado ON tu.estado = tf.estado
AND tu.evento = tf.evento AND tu.evento = tf.evento
@ -521,8 +541,10 @@ function events_update_status($id_evento, $status, $filter=null)
AND tf.max_id_evento = %d', AND tf.max_id_evento = %d',
$sql, $sql,
$id_evento $id_evento
) );
); }
$target_ids = db_get_all_rows_sql($sql);
// Try to avoid deadlock while updating full set. // Try to avoid deadlock while updating full set.
if ($target_ids !== false && count($target_ids) > 0) { if ($target_ids !== false && count($target_ids) > 0) {
@ -627,6 +649,7 @@ function events_update_status($id_evento, $status, $filter=null)
* 'tag_without' * 'tag_without'
* 'filter_only_alert' * 'filter_only_alert'
* 'search_secondary_groups' * 'search_secondary_groups'
* 'search_recursive_groups'
* 'module_search' * 'module_search'
* 'group_rep' * 'group_rep'
* 'server_id' * 'server_id'
@ -864,7 +887,10 @@ function events_get_all(
if (isset($groups) === true if (isset($groups) === true
&& (is_array($groups) === true || ($groups > 0)) && (is_array($groups) === true || ($groups > 0))
) { ) {
if ($recursiveGroups === true) { if ($recursiveGroups === true
|| (isset($filter['search_recursive_groups']) === true
&& (bool) $filter['search_recursive_groups'] === true)
) {
// Add children groups. // Add children groups.
$children = []; $children = [];
if (is_array($groups) === true) { if (is_array($groups) === true) {
@ -1363,7 +1389,10 @@ function events_get_all(
// Order. // Order.
$order_by = ''; $order_by = '';
if (isset($order, $sort_field) === true) { if (isset($order, $sort_field) === true) {
if (isset($filter['group_rep']) === true && $filter['group_rep'] == 1) { if (isset($filter['group_rep']) === true
&& $filter['group_rep'] === EVENT_GROUP_REP_EVENTS
&& $filter['group_rep'] === EVENT_GROUP_REP_EXTRAIDS
) {
$order_by = events_get_sql_order('MAX('.$sort_field.')', $order); $order_by = events_get_sql_order('MAX('.$sort_field.')', $order);
} else { } else {
$order_by = events_get_sql_order($sort_field, $order); $order_by = events_get_sql_order($sort_field, $order);
@ -1397,22 +1426,22 @@ function events_get_all(
$group_by = 'GROUP BY '; $group_by = 'GROUP BY ';
$tagente_join = 'LEFT'; $tagente_join = 'LEFT';
if (isset($filter['group_rep']) === false) { if (isset($filter['group_rep']) === false) {
$filter['group_rep'] = 0; $filter['group_rep'] = EVENT_GROUP_REP_ALL;
} }
switch ($filter['group_rep']) { switch ($filter['group_rep']) {
case '0': case EVENT_GROUP_REP_ALL:
default: default:
// All events. // All events.
$group_by = ''; $group_by = '';
break; break;
case '1': case EVENT_GROUP_REP_EVENTS:
// Group by events. // Group by events.
$group_by .= 'te.evento, te.id_agente, te.id_agentmodule'; $group_by .= 'te.evento, te.id_agente, te.id_agentmodule';
break; break;
case '2': case EVENT_GROUP_REP_AGENTS:
// Group by agents. // Group by agents.
$tagente_join = 'INNER'; $tagente_join = 'INNER';
$group_by = ''; $group_by = '';
@ -1426,6 +1455,11 @@ function events_get_all(
); );
} }
break; break;
case EVENT_GROUP_REP_EXTRAIDS:
// Group by events.
$group_by .= 'te.id_extra';
break;
} }
$tgrupo_join = 'LEFT'; $tgrupo_join = 'LEFT';
@ -1512,7 +1546,9 @@ function events_get_all(
} }
} }
if ((int) $filter['group_rep'] === 1 && $count === false) { if (((int) $filter['group_rep'] === EVENT_GROUP_REP_EVENTS
|| (int) $filter['group_rep'] === EVENT_GROUP_REP_EXTRAIDS) && $count === false
) {
$sql = sprintf( $sql = sprintf(
'SELECT %s 'SELECT %s
%s %s
@ -1543,7 +1579,9 @@ function events_get_all(
%s %s
%s %s
%s JOIN tgrupo tg %s JOIN tgrupo tg
ON %s', ON %s
%s
%s',
join(',', $fields), join(',', $fields),
$group_selects_trans, $group_selects_trans,
$tevento, $tevento,
@ -1572,7 +1610,8 @@ function events_get_all(
join(' ', $agent_join_filters), join(' ', $agent_join_filters),
$tgrupo_join, $tgrupo_join,
join(' ', $tgrupo_join_filters), join(' ', $tgrupo_join_filters),
join(' ', $sql_filters) join(' ', $sql_filters),
$order_by
); );
} else { } else {
$sql = sprintf( $sql = sprintf(
@ -2896,9 +2935,9 @@ function events_get_agent(
// Group by agent. // Group by agent.
if ((bool) $show_summary_group === true) { if ((bool) $show_summary_group === true) {
$filters['group_rep'] = 1; $filters['group_rep'] = EVENT_GROUP_REP_EVENTS;
} else { } else {
$filters['group_rep'] = 2; $filters['group_rep'] = EVENT_GROUP_REP_AGENTS;
} }
$events = Event::search( $events = Event::search(
@ -3510,7 +3549,7 @@ function events_page_responses($event)
__('Execute'), __('Execute'),
'custom_response_button', 'custom_response_button',
false, false,
'execute_response('.$event['id_evento'].','.$server_id.')', 'execute_response('.$event['id_evento'].','.$server_id.',0)',
"class='sub next w70p'", "class='sub next w70p'",
true true
); );
@ -3521,27 +3560,15 @@ function events_page_responses($event)
$responses_js = "<script> $responses_js = "<script>
$('#select_custom_response').change(function() { $('#select_custom_response').change(function() {
var id_response = $('#select_custom_response').val(); var id_response = $('#select_custom_response').val();
var params = get_response_params(id_response); table_info_response_event(id_response,".$event['id_evento'].','.$event['server_id'].");
var description = get_response_description(id_response);
$('.params_rows').remove();
$('#responses_table')
.append('<tr class=\"params_rows\"><td>".__('Description')."</td><td class=\"height_30px\" colspan=\"2\">'+description+'</td></tr>');
if (params.length == 1 && params[0] == '') {
return;
}
$('#responses_table')
.append('<tr class=\"params_rows\"><td class=\"left pdd_l_20px height_30px\" colspan=\"3\">".__('Parameters')."</td></tr>');
for (i = 0; i < params.length; i++) {
add_row_param('responses_table',params[i]);
}
}); });
$('#select_custom_response').trigger('change'); $('#select_custom_response').trigger('change');
</script>"; </script>";
$responses = '<div id="extended_event_responses_page" class="extended_event_pages">'.html_print_table($table_responses, true).$responses_js.'</div>'; $responses = '<div id="extended_event_responses_page" class="extended_event_pages">';
$responses .= html_print_table($table_responses, true);
$responses .= $responses_js;
$responses .= '</div>';
return $responses; return $responses;
} }
@ -3550,14 +3577,20 @@ function events_page_responses($event)
/** /**
* Replace macros in the target of a response and return it. * Replace macros in the target of a response and return it.
* *
* @param integer $event_id Event identifier. * @param integer $event_id Event identifier.
* @param integer $response_id Event response identifier. * @param array $event_response Event Response.
* @param array|null $response_parameters If parameters response values.
* @param integer|null $server_id Server Id.
* @param string|null $server_name Name server.
* *
* @return string The response text with the macros applied. * @return string The response text with the macros applied.
*/ */
function events_get_response_target( function events_get_response_target(
int $event_id, int $event_id,
int $response_id array $event_response,
?array $response_parameters=null,
?int $server_id=0,
?string $server_name=''
) { ) {
global $config; global $config;
@ -3570,9 +3603,36 @@ function events_get_response_target(
} }
$event = db_get_row('tevento', 'id_evento', $event_id); $event = db_get_row('tevento', 'id_evento', $event_id);
$event_response = db_get_row('tevent_response', 'id', $response_id);
$target = io_safe_output($event_response['target']); $target = io_safe_output($event_response['target']);
// Replace parameters response.
if (isset($response_parameters) === true
&& empty($response_parameters) === false
) {
$response_parameters = array_reduce(
$response_parameters,
function ($carry, $item) {
$carry[$item['name']] = $item['value'];
return $carry;
}
);
}
if (empty($event_response['params']) === false) {
$response_params = explode(',', $event_response['params']);
if (is_array($response_params) === true) {
foreach ($response_params as $param) {
$param = trim(io_safe_output($param));
$target = str_replace(
'_'.$param.'_',
$response_parameters['values_params_'.$param],
$target
);
}
}
}
// Replace macros.
if (strpos($target, '_agent_alias_') !== false) { if (strpos($target, '_agent_alias_') !== false) {
$agente_table_name = 'tagente'; $agente_table_name = 'tagente';
$filter = ['id_agente' => $event['id_agente']]; $filter = ['id_agente' => $event['id_agente']];
@ -3898,6 +3958,26 @@ function events_get_response_target(
); );
} }
if (is_metaconsole() === true
&& strpos($target, '_node_id_') !== false
) {
$target = str_replace(
'_node_id_',
$server_id,
$target
);
}
if (is_metaconsole() === true
&& strpos($target, '_node_name_') !== false
) {
$target = str_replace(
'_node_name_',
$server_name,
$target
);
}
return $target; return $target;
} }
@ -5108,7 +5188,7 @@ function events_get_count_events_validated_by_user($data)
* *
* @return string SQL. * @return string SQL.
*/ */
function events_get_sql_order($sort_field='timestamp', $sort='DESC', $group_rep=0, $only_fields=false) function events_get_sql_order($sort_field='timestamp', $sort='DESC', $group_rep=EVENT_GROUP_REP_ALL, $only_fields=false)
{ {
$sort_field_translated = $sort_field; $sort_field_translated = $sort_field;
switch ($sort_field) { switch ($sort_field) {
@ -5129,7 +5209,7 @@ function events_get_sql_order($sort_field='timestamp', $sort='DESC', $group_rep=
break; break;
case 'timestamp': case 'timestamp':
$sort_field_translated = ($group_rep == 0) ? 'timestamp' : 'timestamp_last'; $sort_field_translated = ($group_rep == EVENT_GROUP_REP_ALL) ? 'timestamp' : 'timestamp_last';
break; break;
case 'user_id': case 'user_id':
@ -5156,6 +5236,14 @@ function events_get_sql_order($sort_field='timestamp', $sort='DESC', $group_rep=
$sort_field_translated = 'id_extra'; $sort_field_translated = 'id_extra';
break; break;
case 'agent_name':
$sort_field_translated = 'ta.nombre';
break;
case 'module_custom_id':
$sort_field_translated = 'am.custom_id';
break;
default: default:
$sort_field_translated = $sort_field; $sort_field_translated = $sort_field;
break; break;
@ -5544,3 +5632,114 @@ function events_get_criticity_class($criticity)
return 'datos_blue'; return 'datos_blue';
} }
} }
/**
* Draw row response events.
*
* @param array $event_response Response.
* @param integer|null $response_id Id .
* @param boolean $end End block.
* @param integer|null $index Index block.
*
* @return string Html output.
*/
function get_row_response_action(
array $event_response,
?int $response_id,
$end=false,
$index=null
) {
$output = '<div class="container-massive-events-response-cell">';
$display_command = (bool) $event_response['display_command'];
$command_str = ($display_command === true) ? $event_response['target'] : '';
// String command.
$output .= '<div class="container-massive-events-response-command">';
$output .= '<b>';
$output .= __('Event # %d', $event_response['event_id']);
if (empty($command_str) === false) {
$output .= ' ';
$output .= __('Executing command: ');
}
$output .= '</b>';
$output .= '<span>'.$command_str.'</span>';
$output .= '</div>';
// Spinner.
$output .= '<div id="response_loading_command'.$index.'" style="display:none">';
$output .= html_print_image(
'images/spinner.gif',
true
);
$output .= '</div>';
// Output.
$output .= '<div id="response_out'.$index.'" class="container-massive-events-response-output"></div>';
// Butom.
$output .= '<div id="re_exec_command'.$index.'" style="display:none" class="container-massive-events-response-execute">';
$output .= html_print_button(
__('Execute again'),
'btn_str',
false,
'perform_response(\''.base64_encode(json_encode($event_response)).'\','.$response_id.',\''.trim($index).'\')',
"class='sub next'",
true
);
$output .= '</div>';
$output .= '</div>';
return $output;
}
/**
* Get evet get response target.
*
* @param integer $event_id Id event.
* @param array $event_response Response.
* @param integer $server_id Server id.
*
* @return string
*/
function get_events_get_response_target(
$event_id,
$event_response,
$server_id=0,
$response_parameters=[]
) {
try {
if (is_metaconsole() === true
&& $server_id > 0
) {
$node = new Node($server_id);
$node->connect();
}
return events_get_response_target(
$event_id,
$event_response,
$response_parameters,
$server_id,
($server_id !== 0) ? $node->server_name() : 'Metaconsole'
);
} catch (\Exception $e) {
// Unexistent agent.
if (is_metaconsole() === true
&& $server_id > 0
) {
$node->disconnect();
}
return '';
} finally {
if (is_metaconsole() === true
&& $server_id > 0
) {
$node->disconnect();
}
}
}

View File

@ -5601,7 +5601,9 @@ function html_print_input($data, $wrapper='div', $input_only=false)
0, 0,
$data['agent_ids'], $data['agent_ids'],
$data['selectionModules'], $data['selectionModules'],
true true,
false,
(isset($data['notStringModules']) === true && $data['notStringModules'] === true) ? true : false
); );
} }

View File

@ -3607,8 +3607,26 @@ function modules_get_agentmodule_mininterval_no_async($id_agent)
} }
function get_modules_agents($id_module_group, $id_agents, $selection, $select_mode=true, $useName=false) /**
{ * Get modules agents.
*
* @param integer $id_module_group ID module group.
* @param array $id_agents Array agents.
* @param boolean $selection Selection.
* @param boolean $select_mode Mode.
* @param boolean $useName Use name.
* @param boolean $notStringModules Not string modules.
*
* @return array Modules for this agents.
*/
function get_modules_agents(
$id_module_group,
$id_agents,
$selection,
$select_mode=true,
$useName=false,
$notStringModules=false
) {
if ((bool) is_metaconsole() === true) { if ((bool) is_metaconsole() === true) {
if ($select_mode === true) { if ($select_mode === true) {
$agents = array_reduce( $agents = array_reduce(
@ -3657,7 +3675,8 @@ function get_modules_agents($id_module_group, $id_agents, $selection, $select_mo
$selection, $selection,
false, false,
$useName, $useName,
true true,
$notStringModules
); );
metaconsole_restore_db(); metaconsole_restore_db();
@ -3746,7 +3765,8 @@ function get_modules_agents($id_module_group, $id_agents, $selection, $select_mo
$selection, $selection,
false, false,
$useName, $useName,
false false,
$notStringModules
); );
} }
@ -4193,6 +4213,11 @@ function modules_get_counter_by_states($state)
function modules_get_state_condition($state, $prefix='tae') function modules_get_state_condition($state, $prefix='tae')
{ {
// Not use empty state 0 -> AGENT_MODULE_STATUS_NORMAL.
if ($state === '') {
return '1=1';
}
switch ($state) { switch ($state) {
case AGENT_MODULE_STATUS_CRITICAL_ALERT: case AGENT_MODULE_STATUS_CRITICAL_ALERT:
case AGENT_MODULE_STATUS_CRITICAL_BAD: case AGENT_MODULE_STATUS_CRITICAL_BAD:

View File

@ -181,7 +181,7 @@ function profile_delete_profile_and_clean_users($id_profile)
* @param int User id * @param int User id
* @param bool Show the tags select or not * @param bool Show the tags select or not
*/ */
function profile_print_profile_table($id) function profile_print_profile_table($id, $json_profile=false, $return=false)
{ {
global $config; global $config;
@ -243,7 +243,23 @@ function profile_print_profile_table($id)
} }
if ($result === false) { if ($result === false) {
$result = []; if ($json_profile !== false && empty($json_profile) !== true) {
$profile_decoded = json_decode($json_profile);
foreach ($profile_decoded as $profile) {
if (is_object($profile) === false) {
$profile = json_decode($profile);
}
$result[] = [
'id_grupo' => $profile->group,
'id_perfil' => $profile->profile,
'tags' => $profile->tags,
'hierarchy' => $profile->hierarchy,
];
}
} else {
$result = [];
}
} }
foreach ($result as $profile) { foreach ($result as $profile) {
@ -268,7 +284,12 @@ function profile_print_profile_table($id)
if (empty($profile['tags'])) { if (empty($profile['tags'])) {
$data['tags'] = ''; $data['tags'] = '';
} else { } else {
$tags_ids = explode(',', $profile['tags']); if (is_array($profile['tags'] === false)) {
$tags_ids = explode(',', $profile['tags']);
} else {
$tags_ids = $profile['tags'];
}
$tags = tags_get_tags($tags_ids); $tags = tags_get_tags($tags_ids);
$data['tags'] = tags_get_tags_formatted($tags); $data['tags'] = tags_get_tags_formatted($tags);
} }
@ -276,10 +297,10 @@ function profile_print_profile_table($id)
$data['hierarchy'] = $profile['no_hierarchy'] ? __('Yes') : __('No'); $data['hierarchy'] = $profile['no_hierarchy'] ? __('Yes') : __('No');
$data['actions'] = '<form method="post" onsubmit="if (!confirm (\''.__('Are you sure?').'\')) return false">'; $data['actions'] = '<form method="post" onsubmit="if (!confirm (\''.__('Are you sure?').'\')) return false">';
$data['actions'] .= html_print_input_image('del', 'images/cross.png', 1, ['class' => 'invert_filter'], true);
$data['actions'] .= html_print_input_hidden('delete_profile', 1, true); $data['actions'] .= html_print_input_hidden('delete_profile', 1, true);
$data['actions'] .= html_print_input_hidden('id_user_profile', $profile['id_up'], true); $data['actions'] .= html_print_input_hidden('id_user_profile', $profile['id_up'], true);
$data['actions'] .= html_print_input_hidden('id_user', $id, true); $data['actions'] .= html_print_input_hidden('id_user', $id, true);
$data['actions'] .= html_print_input_image('del', 'images/cross.png', 1, ['class' => 'invert_filter'], true);
$data['actions'] .= '</form>'; $data['actions'] .= '</form>';
array_push($table->data, $data); array_push($table->data, $data);
@ -345,8 +366,7 @@ function profile_print_profile_table($id)
$data['actions'] .= '</form>'; $data['actions'] .= '</form>';
array_push($table->data, $data); array_push($table->data, $data);
html_print_table($table, $return);
html_print_table($table);
if (!is_metaconsole()) { if (!is_metaconsole()) {
echo '</div>'; echo '</div>';
} }

View File

@ -4011,7 +4011,7 @@ function reporting_groups_nodes($content)
} }
// Grouped. // Grouped.
$filters['group_rep'] = 1; $filters['group_rep'] = EVENT_GROUP_REP_EVENTS;
$events = Event::search( $events = Event::search(
[ [

View File

@ -1944,7 +1944,16 @@ function reporting_html_inventory($table, $item, $pdf=0)
$table1->head[$k] = $k; $table1->head[$k] = $k;
$table1->headstyle[$k] = 'text-align: left'; $table1->headstyle[$k] = 'text-align: left';
$table1->cellstyle[$str_key][$k] = 'text-align: left;'; $table1->cellstyle[$str_key][$k] = 'text-align: left;';
$table1->data[$str_key][$k] = $v; if ($pdf === 0) {
$table1->data[$str_key][$k] = $v;
} else {
// Workaround to prevent table columns from growing indefinitely in PDFs.
$table1->data[$str_key][$k] = preg_replace(
'/([^\s]{30})(?=[^\s])/',
'$1'.'<br>',
$v
);
}
} }
} }
} }

View File

@ -3402,7 +3402,7 @@ function ui_print_datatable(array $parameters)
$filter .= '</li>'; $filter .= '</li>';
$filter .= '</ul><div id="both"></div></form>'; $filter .= '</ul><div id="both"></div></form>';
if (isset($parameters['form']['no_toggle']) === false && ($parameters['form']['no_toggle'] !== true)) { if (isset($parameters['form']['no_toggle']) === false) {
$filter = ui_toggle( $filter = ui_toggle(
$filter, $filter,
__('Filter'), __('Filter'),
@ -3466,7 +3466,10 @@ function ui_print_datatable(array $parameters)
foreach ($names as $column) { foreach ($names as $column) {
if (is_array($column)) { if (is_array($column)) {
$table .= '<th id="'.$column['id'].'" class="'.$column['class'].'" '; $table .= '<th id="'.$column['id'].'" class="'.$column['class'].'" ';
$table .= 'title="'.__($column['title']).'" '; if (isset($column['title']) === true) {
$table .= 'title="'.__($column['title']).'" ';
}
$table .= ' style="'.$column['style'].'">'.__($column['text']); $table .= ' style="'.$column['style'].'">'.__($column['text']);
$table .= $column['extra']; $table .= $column['extra'];
$table .= '</th>'; $table .= '</th>';
@ -6510,7 +6513,7 @@ function ui_print_breadcrums($tab_name)
/** /**
* Show last comment * Show last comment
* *
* @param array $comments array with comments * @param string $comments String with comments.
* *
* @return string HTML string with the last comment of the events. * @return string HTML string with the last comment of the events.
*/ */
@ -6534,31 +6537,45 @@ function ui_print_comments($comments)
foreach ($comments_array as $comm) { foreach ($comments_array as $comm) {
// Show the comments more recent first. // Show the comments more recent first.
if (is_array($comm)) { if (is_array($comm)) {
$last_comment[] = array_reverse($comm); $order_utimestamp = array_reduce(
$comm,
function ($carry, $item) {
$carry[$item['utimestamp']] = $item;
return $carry;
}
);
$key_max_utimestamp = max(array_keys($order_utimestamp));
$last_comment = $order_utimestamp[$key_max_utimestamp];
} }
} }
if (empty($last_comment) === true) {
return '';
}
// Only show the last comment. If commment its too long,the comment will short with ... // 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. // If $config['prominent_time'] is timestamp the date show Month, day, hour and minutes.
// Else show comments hours ago // Else show comments hours ago
if ($last_comment[0][0]['action'] != 'Added comment') { if ($last_comment['action'] != 'Added comment') {
$last_comment[0][0]['comment'] = $last_comment[0][0]['action']; $last_comment['comment'] = $last_comment['action'];
} }
$short_comment = substr($last_comment[0][0]['comment'], 0, 20); $short_comment = substr($last_comment['comment'], 0, 20);
if ($config['prominent_time'] == 'timestamp') { if ($config['prominent_time'] == 'timestamp') {
$comentario = '<i>'.date($config['date_format'], $last_comment[0][0]['utimestamp']).'&nbsp;('.$last_comment[0][0]['id_user'].'):&nbsp;'.$last_comment[0][0]['comment'].''; $comentario = '<i>'.date($config['date_format'], $last_comment['utimestamp']).'&nbsp;('.$last_comment['id_user'].'):&nbsp;'.$last_comment['comment'].'';
if (strlen($comentario) > '200px') { if (strlen($comentario) > '200px') {
$comentario = '<i>'.date($config['date_format'], $last_comment[0][0]['utimestamp']).'&nbsp;('.$last_comment[0][0]['id_user'].'):&nbsp;'.$short_comment.'...'; $comentario = '<i>'.date($config['date_format'], $last_comment['utimestamp']).'&nbsp;('.$last_comment['id_user'].'):&nbsp;'.$short_comment.'...';
} }
} else { } else {
$rest_time = (time() - $last_comment[0][0]['utimestamp']); $rest_time = (time() - $last_comment['utimestamp']);
$time_last = (($rest_time / 60) / 60); $time_last = (($rest_time / 60) / 60);
$comentario = '<i>'.number_format($time_last, 0).'&nbsp; Hours &nbsp;('.$last_comment[0][0]['id_user'].'):&nbsp;'.$last_comment[0][0]['comment'].''; $comentario = '<i>'.number_format($time_last, 0).'&nbsp; Hours &nbsp;('.$last_comment['id_user'].'):&nbsp;'.$last_comment['comment'].'';
if (strlen($comentario) > '200px') { if (strlen($comentario) > '200px') {
$comentario = '<i>'.number_format($time_last, 0).'&nbsp; Hours &nbsp;('.$last_comment[0][0]['id_user'].'):&nbsp;'.$short_comment.'...'; $comentario = '<i>'.number_format($time_last, 0).'&nbsp; Hours &nbsp;('.$last_comment['id_user'].'):&nbsp;'.$short_comment.'...';
} }
} }

View File

@ -235,27 +235,31 @@ function groups_combine_acl($acl_group_a, $acl_group_b)
} }
$acl_list = [ $acl_list = [
'agent_view' => 1, 'agent_view' => 1,
'agent_edit' => 1, 'agent_edit' => 1,
'agent_disable' => 1, 'agent_disable' => 1,
'alert_edit' => 1, 'alert_edit' => 1,
'alert_management' => 1, 'alert_management' => 1,
'pandora_management' => 1, 'pandora_management' => 1,
'db_management' => 1, 'db_management' => 1,
'user_management' => 1, 'user_management' => 1,
'report_view' => 1, 'report_view' => 1,
'report_edit' => 1, 'report_edit' => 1,
'report_management' => 1, 'report_management' => 1,
'event_view' => 1, 'event_view' => 1,
'event_edit' => 1, 'event_edit' => 1,
'event_management' => 1, 'event_management' => 1,
'map_view' => 1, 'map_view' => 1,
'map_edit' => 1, 'map_edit' => 1,
'map_management' => 1, 'map_management' => 1,
'vconsole_view' => 1, 'vconsole_view' => 1,
'vconsole_edit' => 1, 'vconsole_edit' => 1,
'vconsole_management' => 1, 'vconsole_management' => 1,
'tags' => 1, 'tags' => 1,
'network_config_view' => 1,
'network_config_edit' => 1,
'network_config_management' => 1,
]; ];
foreach ($acl_group_a['tags'] as $key => $value) { foreach ($acl_group_a['tags'] as $key => $value) {
@ -838,13 +842,14 @@ function users_has_profile_without_UM($id_user, $id_groups)
} }
function users_get_user_profile($id_user) function users_get_user_profile($id_user, $limit='')
{ {
$sql = sprintf( $sql = sprintf(
"SELECT * FROM tusuario_perfil "SELECT * FROM tusuario_perfil
INNER JOIN tperfil ON tperfil.id_perfil = tusuario_perfil.id_perfil INNER JOIN tperfil ON tperfil.id_perfil = tusuario_perfil.id_perfil
WHERE tusuario_perfil.id_usuario like '%s'", WHERE tusuario_perfil.id_usuario like '%s' %s",
$id_user $id_user,
$limit
); );
$aux = db_get_all_rows_sql($sql); $aux = db_get_all_rows_sql($sql);

View File

@ -196,6 +196,13 @@ function agent_changed_by_multiple_agents(event, id_agent, selected) {
serialized = ""; serialized = "";
} }
var id_group = null;
if (typeof $("#filter_group") !== "undefined") {
try {
id_group = $("#filter_group").val();
} catch (error) {}
}
$("#module") $("#module")
.prop("disabled", true) .prop("disabled", true)
.empty() .empty()
@ -238,7 +245,8 @@ function agent_changed_by_multiple_agents(event, id_agent, selected) {
selection_mode: selection_mode, selection_mode: selection_mode,
serialized: serialized, serialized: serialized,
id_server: id_server, id_server: id_server,
status_module: module_status status_module: module_status,
id_group: id_group
}, },
function(data) { function(data) {
$("#module").empty(); $("#module").empty();
@ -575,7 +583,8 @@ function module_changed_by_multiple_modules(event, id_module, selected) {
status_module: status_module, status_module: status_module,
"module_name[]": idModules, "module_name[]": idModules,
selection_mode: selection_mode, selection_mode: selection_mode,
tags: tags_selected tags: tags_selected,
id_group: id_group
}, },
function(data) { function(data) {
$("#agents").append( $("#agents").append(
@ -2175,3 +2184,19 @@ $.fn.filterByText = function(textbox) {
}); });
}); });
}; };
function loadPasswordConfig(id, value) {
$.ajax({
url: "ajax.php",
data: {
page: "include/ajax/config.ajax",
token_name: `${value}`,
no_boolean: 1
},
type: "GET",
dataType: "json",
success: function(data) {
$(`#${id}`).val(data);
}
});
}

View File

@ -1542,3 +1542,18 @@ function loadSliceWidget(settings) {
} }
}); });
} }
// eslint-disable-next-line no-unused-vars
function showManualThresholds(element) {
$("#min_warning").val(null);
$("#max_warning").val(null);
$("#min_critical").val(null);
$("#max_critical").val(null);
if ($(element).is(":checked") === true) {
$(".dashboard-input-threshold-warning").removeClass("invisible_important");
$(".dashboard-input-threshold-critical").removeClass("invisible_important");
} else {
$(".dashboard-input-threshold-warning").addClass("invisible_important");
$(".dashboard-input-threshold-critical").addClass("invisible_important");
}
}

View File

@ -85,29 +85,6 @@ function show_event_dialog(event, dialog_page) {
$("#refrcounter").countdown("pause"); $("#refrcounter").countdown("pause");
$("div.vc-countdown").countdown("pause"); $("div.vc-countdown").countdown("pause");
/*
switch (result) {
case "comment_ok":
$("#notification_comment_success").show();
break;
case "comment_error":
$("#notification_comment_error").show();
break;
case "status_ok":
$("#notification_status_success").show();
break;
case "status_error":
$("#notification_status_error").show();
break;
case "owner_ok":
$("#notification_owner_success").show();
break;
case "owner_error":
$("#notification_owner_error").show();
break;
}
*/
forced_title_callback(); forced_title_callback();
}, },
"html" "html"
@ -119,37 +96,152 @@ function show_event_dialog(event, dialog_page) {
function execute_response(event_id, server_id) { function execute_response(event_id, server_id) {
var response_id = $("#select_custom_response option:selected").val(); var response_id = $("#select_custom_response option:selected").val();
var response = get_response(response_id, server_id); var response_parameters_list = $('input[name^="values_params_"]');
var response_parameters = [];
// If cannot get response abort it if (response_parameters_list.length > 0) {
if (response == null) { response_parameters_list.each(function() {
return; var acum = {
name: $(this).attr("name"),
value: $(this).val()
};
response_parameters.push(acum);
});
} }
response["target"] = get_response_target(event_id, response_id, server_id); var params = [];
response["event_id"] = event_id; params.push({ name: "page", value: "include/ajax/events" });
response["server_id"] = server_id; params.push({ name: "get_response", value: 1 });
params.push({ name: "response_id", value: response_id });
params.push({ name: "server_id", value: server_id });
params.push({ name: "event_id", value: event_id });
params.push({
name: "response_parameters",
value: JSON.stringify(response_parameters)
});
if (response["type"] == "url" && response["new_window"] == 1) { jQuery.ajax({
window.open(response["target"], "_blank"); data: params,
} else { type: "POST",
show_response_dialog(response_id, response); url: $("#hidden-ajax_file").val(),
} dataType: "json",
success: function(response) {
// If cannot get response abort it
if (response == null) {
return [];
}
response["event_id"] = event_id;
response["server_id"] = server_id;
if (response["type"] == "url" && response["new_window"] == 1) {
window.open(response["target"], "_blank");
} else {
show_response_dialog(response_id, response);
}
}
});
}
// Check the response type and open it in a modal dialog or new window
function execute_response_massive(events, response_id, response_parameters) {
var params = [];
params.push({ name: "page", value: "include/ajax/events" });
params.push({ name: "get_response_massive", value: 1 });
params.push({ name: "response_id", value: response_id });
params.push({ name: "events", value: JSON.stringify(events) });
params.push({ name: "response_parameters", value: response_parameters });
jQuery.ajax({
data: params,
type: "POST",
url: $("#hidden-ajax_file").val(),
dataType: "json",
success: function(data) {
// If cannot get response abort it
if (data == null) {
return [];
}
$(".container-massive-events-response").empty();
// Convert to array.
var array_data = Object.entries(data.event_response_targets);
var total_count = array_data.length;
// Each input checkeds.
array_data.forEach(function(element, index) {
var id = element[0];
var target = element[1].target;
var meta = $("#hidden-meta").val();
var event_id = id;
var server_id = 0;
if (meta != 0) {
var split_id = id.split("|");
event_id = split_id[0];
server_id = split_id[1];
}
var end = 0;
if (total_count - 1 === index) {
end = 1;
}
var response = data.event_response;
response["event_id"] = event_id;
response["server_id"] = server_id;
response["target"] = target;
if (response["type"] == "url" && response["new_window"] == 1) {
window.open(response["target"], "_blank");
} else {
var params = [];
params.push({ name: "page", value: "include/ajax/events" });
params.push({ name: "get_row_response_action", value: 1 });
params.push({ name: "response_id", value: response_id });
params.push({ name: "server_id", value: response.server_id });
params.push({ name: "end", value: end });
params.push({ name: "response", value: JSON.stringify(response) });
jQuery.ajax({
data: params,
type: "POST",
url: $("#hidden-ajax_file").val(),
dataType: "html",
success: function(data) {
$(".container-massive-events-response").append(data);
response["event_id"] = event_id;
response["server_id"] = server_id;
response["target"] = target;
var indexstr = event_id;
if (meta != 0) {
indexstr += "-" + server_id;
}
perform_response(
btoa(JSON.stringify(response)),
response_id,
indexstr
);
}
});
}
});
}
});
} }
//Show the modal window of an event response //Show the modal window of an event response
function show_response_dialog(response_id, response) { function show_response_dialog(response_id, response) {
var params = []; var params = [];
params.push("page=include/ajax/events"); params.push({ name: "page", value: "include/ajax/events" });
params.push("dialogue_event_response=1"); params.push({ name: "dialogue_event_response", value: 1 });
params.push("massive=0"); params.push({ name: "event_id", value: response.event_id });
params.push("event_id=" + response["event_id"]); params.push({ name: "target", value: response.target });
params.push("target=" + encodeURIComponent(response["target"])); params.push({ name: "response_id", value: response_id });
params.push("response_id=" + response_id); params.push({ name: "server_id", value: response.server_id });
params.push("server_id=" + response["server_id"]); params.push({ name: "response", value: JSON.stringify(response) });
jQuery.ajax({ jQuery.ajax({
data: params.join("&"), data: params,
type: "POST", type: "POST",
url: $("#hidden-ajax_file").val(), url: $("#hidden-ajax_file").val(),
dataType: "html", dataType: "html",
@ -164,271 +256,49 @@ function show_response_dialog(response_id, response) {
draggable: true, draggable: true,
modal: false, modal: false,
open: function() { open: function() {
perform_response(response, response_id); perform_response(btoa(JSON.stringify(response)), response_id, "");
}, },
width: response["modal_width"], width: response["modal_width"],
height: response["modal_height"] height: response["modal_height"],
buttons: []
}) })
.show(); .show();
} }
}); });
} }
//Show the modal window of event responses when multiple events are selected // Perform a response and put the output into a div
function show_massive_response_dialog( function perform_response(response, response_id, index) {
response_id, $("#re_exec_command" + index).hide();
response, $("#response_loading_command" + index).show();
out_iterator, $("#response_out" + index).html("");
end
) {
var params = [];
params.push("page=include/ajax/events");
params.push("dialogue_event_response=1");
params.push("massive=1");
params.push("end=" + end);
params.push("out_iterator=" + out_iterator);
params.push("event_id=" + response["event_id"]);
params.push("target=" + response["target"]);
params.push("response_id=" + response_id);
params.push("server_id=" + response["server_id"]);
jQuery.ajax({ try {
data: params.join("&"), response = JSON.parse(atob(response));
response_tg: response, } catch (e) {
response_id: response_id, console.error(e);
out_iterator: out_iterator, return;
type: "POST",
url: $("#hidden-ajax_file").val(),
dataType: "html",
success: function(data) {
if (out_iterator === 0) $("#event_response_window").empty();
$("#event_response_window")
.hide()
.append(data)
.dialog({
title: $("#select_custom_response option:selected").html(),
resizable: true,
draggable: true,
modal: false,
open: function() {
$("#response_loading_dialog").hide();
$("#button-submit_event_response").show();
},
close: function() {
$("#checkbox-all_validate_box").prop("checked", false);
$(".chk_val").prop("checked", false);
},
width: response["modal_width"],
height: response["modal_height"]
})
.show();
perform_response_massive(
this.response_tg,
this.response_id,
this.out_iterator
);
}
});
}
// Get an event response from db
function get_response(response_id, server_id) {
var response = "";
var params = [];
params.push("page=include/ajax/events");
params.push("get_response=1");
params.push("response_id=" + response_id);
params.push("server_id=" + server_id);
jQuery.ajax({
data: params.join("&"),
type: "POST",
url: $("#hidden-ajax_file").val(),
async: false,
dataType: "json",
success: function(data) {
response = data;
}
});
return response;
}
// Get an event response params from db
function get_response_params(response_id) {
var response_params;
var params = [];
params.push("page=include/ajax/events");
params.push("get_response_params=1");
params.push("response_id=" + response_id);
jQuery.ajax({
data: params.join("&"),
type: "POST",
url: $("#hidden-ajax_file").val(),
async: false,
dataType: "json",
success: function(data) {
response_params = data;
}
});
return response_params;
}
// Get an event response description from db
function get_response_description(response_id) {
var response_description = "";
var params = [];
params.push("page=include/ajax/events");
params.push("get_response_description=1");
params.push("response_id=" + response_id);
jQuery.ajax({
data: params.join("&"),
type: "POST",
url: $("#hidden-ajax_file").val(),
async: false,
dataType: "html",
success: function(data) {
response_description = data;
}
});
return response_description;
}
function add_row_param(id_table, param) {
$("#" + id_table).append(
'<tr class="params_rows"><td style="text-align:left; padding-left:40px; font-weight: normal; font-style: italic;">' +
param +
'</td><td style="text-align:left" colspan="2"><input type="text" name="' +
param +
'" id="' +
param +
'"></td></tr>'
);
}
// Get an event response from db
function get_response_target(
event_id,
response_id,
server_id,
response_command
) {
var target = "";
// Replace the main macros
var params = [];
params.push("page=include/ajax/events");
params.push("get_response_target=1");
params.push("event_id=" + event_id);
params.push("response_id=" + response_id);
params.push("server_id=" + server_id);
jQuery.ajax({
data: params.join("&"),
type: "POST",
url: $("#hidden-ajax_file").val(),
async: false,
dataType: "html",
success: function(data) {
target = data;
}
});
// Replace the custom params macros.
var response_params = get_response_params(response_id);
if (response_params.length > 1 || response_params[0] != "") {
for (var i = 0; i < response_params.length; i++) {
if (!response_command) {
var response_param = "_" + response_params[i] + "_";
if (
response_params[i].startsWith("_") &&
response_params[i].endsWith("_")
) {
response_param = response_params[i];
}
target = target.replace(
response_param,
$("#" + response_params[i]).val()
);
} else {
target = target.replace(
"_" + response_params[i] + "_",
response_command[response_params[i] + "-" + i]
);
}
}
} }
return target;
}
// Perform a response and put the output into a div
function perform_response(response, response_id) {
$("#re_exec_command").hide();
$("#response_loading_command").show();
$("#response_out").html("");
var params = []; var params = [];
params.push("page=include/ajax/events"); params.push({ name: "page", value: "include/ajax/events" });
params.push("perform_event_response=1"); params.push({ name: "perform_event_response", value: 1 });
params.push("target=" + encodeURIComponent(response["target"])); params.push({ name: "target", value: response["target"] });
params.push("response_id=" + response_id); params.push({ name: "response_id", value: response_id });
params.push("event_id=" + response["event_id"]); params.push({ name: "event_id", value: response["event_id"] });
params.push("server_id=" + response["server_id"]); params.push({ name: "server_id", value: response["server_id"] });
params.push({ name: "response", value: JSON.stringify(response) });
jQuery.ajax({ jQuery.ajax({
data: params.join("&"), data: params,
type: "POST", type: "POST",
url: $("#hidden-ajax_file").val(), url: $("#hidden-ajax_file").val(),
async: true,
dataType: "html", dataType: "html",
success: function(data) { success: function(data) {
var out = data.replace(/[\n|\r]/g, "<br>"); var out = data.replace(/[\n|\r]/g, "<br>");
$("#response_out").html(out); $("#response_out" + index).html(out);
$("#response_loading_command").hide(); $("#response_loading_command" + index).hide();
$("#re_exec_command").show(); $("#re_exec_command" + index).show();
}
});
return false;
}
// Perform a response and put the output into a div
function perform_response_massive(response, response_id, out_iterator) {
$("#re_exec_command").hide();
$("#response_loading_command_" + out_iterator).show();
$("#response_out_" + out_iterator).html("");
var params = [];
params.push("page=include/ajax/events");
params.push("perform_event_response=1");
params.push("target=" + response["target"]);
params.push("response_id=" + response_id);
params.push("event_id=" + response["event_id"]);
params.push("server_id=" + response["server_id"]);
jQuery.ajax({
data: params.join("&"),
type: "POST",
url: $("#hidden-ajax_file").val(),
async: true,
dataType: "html",
success: function(data) {
var out = data.replace(/[\n|\r]/g, "<br>");
$("#response_out_" + out_iterator).html(out);
$("#response_loading_command_" + out_iterator).hide();
$("#re_exec_command_" + out_iterator).show();
} }
}); });
@ -600,54 +470,6 @@ function event_comment(current_event) {
return false; return false;
} }
function show_event_response_command_dialog(id, response, total_checked) {
var params = [];
params.push("page=include/ajax/events");
params.push("get_table_response_command=1");
params.push("event_response_id=" + id);
jQuery.ajax({
data: params.join("&"),
type: "POST",
url: $("#hidden-ajax_file").val(),
dataType: "html",
success: function(data) {
$("#event_response_command_window")
.hide()
.empty()
.append(data)
.dialog({
resizable: true,
draggable: true,
modal: false,
open: function() {
$("#response_loading_dialog").hide();
$("#button-submit_event_response").show();
},
width: 600,
height: 300
})
.show();
$("#submit-enter_command").on("click", function(e) {
e.preventDefault();
var response_command = [];
$(".response_command_input").each(function() {
response_command[$(this).attr("name")] = $(this).val();
});
check_massive_response_event(
id,
response,
total_checked,
response_command
);
});
}
});
}
var processed = 0; var processed = 0;
function update_event(table, id_evento, type, event_rep, row, server_id) { function update_event(table, id_evento, type, event_rep, row, server_id) {
var inputs = $("#events_form :input"); var inputs = $("#events_form :input");
@ -820,8 +642,13 @@ function execute_delete_event_reponse(
// Imported from old files. // Imported from old files.
function execute_event_response(event_list_btn) { function execute_event_response(event_list_btn) {
var response_id = $("select[name=response_id]").val();
if (!isNaN(response_id)) {
table_info_response_event(response_id, 0, 0, true);
}
var message = var message =
"<h4 style = 'text-align: center; color:black' > Are you sure?</h4> "; "<h4 style = 'text-align: center; color:black' > Are you sure?</h4> <div id='massive-parameters-response'></div> ";
confirmDialog({ confirmDialog({
title: "ATTENTION", title: "ATTENTION",
message: message, message: message,
@ -833,8 +660,6 @@ function execute_event_response(event_list_btn) {
$("#max_custom_event_resp_msg").hide(); $("#max_custom_event_resp_msg").hide();
$("#max_custom_selected").hide(); $("#max_custom_selected").hide();
var response_id = $("select[name=response_id]").val();
var total_checked = $(".chk_val:checked").length; var total_checked = $(".chk_val:checked").length;
// Check select an event. // Check select an event.
@ -844,58 +669,28 @@ function execute_event_response(event_list_btn) {
} }
if (!isNaN(response_id)) { if (!isNaN(response_id)) {
// It is a custom response var response_parameters_list = $('input[name^="values_params_"]');
var response = get_response(response_id); var response_parameters = [];
if (response_parameters_list.length > 0) {
// If cannot get response abort it response_parameters_list.each(function() {
if (response == null) { var acum = {
return; name: $(this).attr("name"),
value: $(this).val()
};
response_parameters.push(acum);
});
} }
// Limit number of events to apply custom responses response_parameters = JSON.stringify(response_parameters);
// due performance reasons.
if (total_checked > $("#max_execution_event_response").val()) {
$("#max_custom_event_resp_msg").show();
return;
}
var response_command = [];
$(".response_command_input").each(function() {
response_command[$(this).attr("name")] = $(this).val();
});
if (event_list_btn) { if (event_list_btn) {
$("#button-submit_event_response").hide(function() { $("#button-submit_event_response").hide(function() {
$("#response_loading_dialog").show(function() { $("#response_loading_dialog").show(function() {
var check_params = get_response_params(response_id); show_response_dialog_massive(response_id, response_parameters);
if (check_params[0] !== "") {
show_event_response_command_dialog(
response_id,
response,
total_checked
);
} else {
check_massive_response_event(
response_id,
response,
total_checked,
response_command
);
}
}); });
}); });
} else { } else {
$("#button-btn_str").hide(function() { check_execute_response_massive(response_id, response_parameters);
$("#execute_again_loading").show(function() {
check_massive_response_event(
response_id,
response,
total_checked,
response_command
);
});
});
} }
} else { } else {
// It is not a custom response // It is not a custom response
@ -912,7 +707,7 @@ function execute_event_response(event_list_btn) {
} }
in_process_event( in_process_event(
"events", "table_events",
event_id, event_id,
$(this).attr("event_rep"), $(this).attr("event_rep"),
this.parentElement.parentElement, this.parentElement.parentElement,
@ -932,7 +727,7 @@ function execute_event_response(event_list_btn) {
} }
validate_event( validate_event(
"events", "table_events",
event_id, event_id,
$(this).attr("event_rep"), $(this).attr("event_rep"),
this.parentElement.parentElement, this.parentElement.parentElement,
@ -952,7 +747,7 @@ function execute_event_response(event_list_btn) {
} }
execute_delete_event_reponse( execute_delete_event_reponse(
"events", "table_events",
event_id, event_id,
$(this).attr("event_rep"), $(this).attr("event_rep"),
this.parentElement.parentElement, this.parentElement.parentElement,
@ -970,15 +765,63 @@ function execute_event_response(event_list_btn) {
}); });
} }
function check_massive_response_event( function show_response_dialog_massive(response_id, response_parameters) {
response_id, var params = [];
response, params.push({ name: "page", value: "include/ajax/events" });
total_checked, params.push({ name: "get_response", value: 1 });
response_command params.push({ name: "response_id", value: response_id });
) {
var counter = 0;
var end = 0;
jQuery.ajax({
data: params,
type: "POST",
url: $("#hidden-ajax_file").val(),
dataType: "json",
success: function(response) {
// If cannot get response abort it
if (response == null) {
return [];
}
$("#event_response_window")
.hide()
.empty()
.append('<div class="container-massive-events-response"></div>')
.dialog({
title: $("#response_id option:selected").html(),
resizable: true,
draggable: true,
modal: false,
open: function() {
check_execute_response_massive(response_id, response_parameters);
},
close: function() {
$("#checkbox-all_validate_box").prop("checked", false);
$(".chk_val").prop("checked", false);
$("#response_loading_dialog").hide();
$("#button-submit_event_response").show();
},
buttons: [
{
text: "Execute All",
id: "execute-again-all",
class:
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
click: function() {
execute_event_response(false);
}
}
],
width: response["modal_width"],
height: response["modal_height"]
})
.show();
}
});
}
function check_execute_response_massive(response_id, response_parameters) {
var events = [];
$(".container-massive-events-response").empty();
$(".chk_val:checked").each(function() { $(".chk_val:checked").each(function() {
var event_id = $(this).val(); var event_id = $(this).val();
var meta = $("#hidden-meta").val(); var meta = $("#hidden-meta").val();
@ -987,23 +830,18 @@ function check_massive_response_event(
var split_id = event_id.split("|"); var split_id = event_id.split("|");
event_id = split_id[0]; event_id = split_id[0];
server_id = split_id[1]; server_id = split_id[1];
if (events[server_id] === undefined) {
events[server_id] = [];
}
events[server_id].push(event_id);
} else {
events.push(event_id);
} }
response["target"] = get_response_target(
event_id,
response_id,
server_id,
response_command
);
response["server_id"] = server_id;
response["event_id"] = event_id;
if (total_checked - 1 === counter) end = 1;
show_massive_response_dialog(response_id, response, counter, end);
counter++;
}); });
execute_response_massive(events, response_id, response_parameters);
} }
function event_widget_options() { function event_widget_options() {
@ -1287,3 +1125,43 @@ function check_event_sound(settings) {
"json" "json"
); );
} }
function table_info_response_event(response_id, event_id, server_id, massive) {
var params = [];
params.push({ name: "page", value: "include/ajax/events" });
params.push({ name: "get_response", value: 1 });
params.push({ name: "response_id", value: response_id });
params.push({ name: "server_id", value: server_id });
params.push({ name: "event_id", value: event_id });
jQuery.ajax({
data: params,
type: "POST",
url: $("#hidden-ajax_file").val(),
dataType: "json",
success: function(response) {
if (response) {
var params = [];
params.push({ name: "page", value: "include/ajax/events" });
params.push({ name: "draw_row_response_info", value: 1 });
params.push({ name: "massive", value: massive === true ? 1 : 0 });
params.push({ name: "response", value: JSON.stringify(response) });
jQuery.ajax({
data: params,
type: "POST",
url: $("#hidden-ajax_file").val(),
dataType: "html",
success: function(output) {
if (massive === true) {
$("#massive-parameters-response").append(output);
} else {
$(".params_rows").remove();
$("#responses_table").append(output);
}
}
});
}
}
});
}

View File

@ -740,3 +740,26 @@ function reveal_password(name) {
revealElement.attr("src", imagesPath + "eye_show.png"); revealElement.attr("src", imagesPath + "eye_show.png");
} }
} }
/**
* Returns html img group icon.
* @param {int} $id_group
*/
function getGroupIcon(id_group, img_container) {
$.ajax({
type: "POST",
url: "ajax.php",
dataType: "json",
data: {
page: "godmode/groups/group_list",
get_group_json: 1,
id_group: id_group
},
success: function(data) {
img_container.attr("src", "images/groups_small/" + data["icon"] + ".png");
},
error: function() {
img_container.attr("src", "");
}
});
}

View File

@ -858,11 +858,12 @@ var TreeController = {
$content.append($statusImage); $content.append($statusImage);
} }
var image_tooltip = var image_tooltip =
'<span><img class="invert_filter" src="' + '<span><img class="invert_filter forced_title" data-title="' +
(controller.baseURL.length > 0 ? controller.baseURL : "") +
'images/help.png" class="img_help" title="' +
(element.title ? element.title : element.name) + (element.title ? element.title : element.name) +
'" alt="' + '" data-use_title_for_force_title="1" src="' +
(controller.baseURL.length > 0 ? controller.baseURL : "") +
'images/help.png" class="img_help" ' +
' alt="' +
element.name + element.name +
'"/></span> '; '"/></span> ';
@ -883,7 +884,6 @@ var TreeController = {
window.location.href = element.serviceDetail; window.location.href = element.serviceDetail;
}) })
.css("cursor", "pointer"); .css("cursor", "pointer");
$content.append($serviceDetailImage); $content.append($serviceDetailImage);
$content.append(" " + image_tooltip); $content.append(" " + image_tooltip);

View File

@ -69,7 +69,7 @@ final class Config
$link->options(MYSQLI_OPT_CONNECT_TIMEOUT, 2); $link->options(MYSQLI_OPT_CONNECT_TIMEOUT, 2);
$rc = mysqli_real_connect( $rc = mysqli_real_connect(
$link, $link,
$$config['history_db_host'], $config['history_db_host'],
$config['history_db_user'], $config['history_db_user'],
io_output_password($config['history_db_pass']), io_output_password($config['history_db_pass']),
$config['history_db_name'], $config['history_db_name'],
@ -90,29 +90,31 @@ final class Config
} }
ob_get_clean(); ob_get_clean();
}
if ($config['history_db_connection'] !== false) { if (isset($config['history_db_connection']) === true
$data = \db_get_all_rows_sql( && $config['history_db_connection'] !== false
'SELECT * FROM `tconfig`', ) {
false, $data = \db_get_all_rows_sql(
false, 'SELECT * FROM `tconfig`',
$config['history_db_connection'] false,
); false,
} $config['history_db_connection']
if (is_array($data) !== true) {
return [];
}
self::$settings = array_reduce(
$data,
function ($carry, $item) {
$carry[$item['token']] = $item['value'];
return $carry;
},
[]
); );
} }
if (is_array($data) !== true) {
return [];
}
self::$settings = array_reduce(
$data,
function ($carry, $item) {
$carry[$item['token']] = $item['value'];
return $carry;
},
[]
);
} }

View File

@ -416,6 +416,7 @@ class Widget
$className .= '\OsQuickReportWidget'; $className .= '\OsQuickReportWidget';
break; break;
case 'GroupedMeterGraphs':
case 'ColorModuleTabs': case 'ColorModuleTabs':
case 'BlockHistogram': case 'BlockHistogram':
$className .= '\\'.$name; $className .= '\\'.$name;

File diff suppressed because it is too large Load Diff

View File

@ -710,9 +710,13 @@ class AgentModuleWidget extends Widget
if (empty($allModules) === false) { if (empty($allModules) === false) {
if (is_metaconsole() === true && $this->values['mShowCommonModules'] !== 'on') { if (is_metaconsole() === true && $this->values['mShowCommonModules'] !== 'on') {
$modules = $agent->searchModules( if (isset($reduceAllModules['modules_selected'][$tserver]) === true) {
['nombre' => array_keys($reduceAllModules['modules_selected'][$tserver])] $modules = $agent->searchModules(
); ['nombre' => array_keys($reduceAllModules['modules_selected'][$tserver])]
);
} else {
$modules = null;
}
} else { } else {
$modules = $agent->searchModules( $modules = $agent->searchModules(
['nombre' => array_keys($allModules)] ['nombre' => array_keys($allModules)]

View File

@ -328,7 +328,7 @@ class ServiceMapWidget extends Widget
]; ];
$inputs[] = [ $inputs[] = [
'label' => __('Enable sunburst'), 'label' => __('Show sunburst by default'),
'arguments' => [ 'arguments' => [
'type' => 'switch', 'type' => 'switch',
'name' => 'sunburst', 'name' => 'sunburst',

View File

@ -128,7 +128,7 @@ class User implements PublicLogin
{ {
$user = new self($data); $user = new self($data);
if ($user === null) { if ($user->idUser === null) {
return false; return false;
} }
@ -188,6 +188,14 @@ class User implements PublicLogin
$config['public_access'] = false; $config['public_access'] = false;
} }
if (empty($other_secret) === true) {
$auth_token_secret = db_get_value('auth_token_secret', 'tusuario', 'id_user', $config['id_user']);
if (empty($auth_token_secret) === false) {
$other_secret = $auth_token_secret;
}
}
// Build a hash to check. // Build a hash to check.
$hashCheck = self::generatePublicHash($other_secret); $hashCheck = self::generatePublicHash($other_secret);
if ($hashCheck === $hash) { if ($hashCheck === $hash) {

View File

@ -66,7 +66,19 @@ if ($doLogin === true) {
] ]
) === true ) === true
) { ) {
echo json_encode(['auth_hash' => User::generatePublicHash()]); $newGeneratedSecret = bin2hex(openssl_random_pseudo_bytes(15));
$res_update = update_user(
$id_user,
['auth_token_secret' => $newGeneratedSecret]
);
if ($res_update === false) {
http_response_code(404);
return;
}
echo json_encode(['auth_hash' => User::generatePublicHash($newGeneratedSecret)]);
} else { } else {
db_pandora_audit( db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION, AUDIT_LOG_ACL_VIOLATION,

View File

@ -677,6 +677,128 @@ form.modal-dashboard
text-align: initial; text-align: initial;
} }
.container-grouped-meter {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 98%;
margin-top: 10px;
}
.container-grouped-meter .container-info-module-meter {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
width: 100%;
height: 30px;
}
.container-grouped-meter
.container-info-module-meter
.container-info-module-meter-title {
flex: 1 1 20%;
font-size: 100%;
font-weight: bolder;
text-align: right;
padding-right: 10px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.container-grouped-meter
.container-info-module-meter
.container-info-module-meter-graphs {
flex: 1 1 65%;
display: flex;
flex-direction: row;
justify-content: space-around;
align-items: center;
height: 100%;
}
.container-grouped-meter
.container-info-module-meter
.container-info-module-meter-graphs
div {
border-radius: 2px;
width: 17px;
height: 90%;
opacity: 0.4;
}
.container-grouped-meter
.container-info-module-meter
.container-info-module-meter-graphs
div.meter-graph-critical {
background-color: #e63c52;
}
.container-grouped-meter
.container-info-module-meter
.container-info-module-meter-graphs
div.meter-graph-warning {
background-color: #f3b200;
}
.container-grouped-meter
.container-info-module-meter
.container-info-module-meter-graphs
div.meter-graph-normal {
background-color: #82b92e;
}
.container-grouped-meter
.container-info-module-meter
.container-info-module-meter-graphs
div.meter-graph-opacity {
opacity: 1;
}
.container-grouped-meter
.container-info-module-meter
.container-info-module-meter-data {
flex: 1 1 15%;
font-size: 150%;
font-weight: bolder;
text-align: right;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.container-grouped-meter
.container-info-module-meter
.container-info-module-meter-data.meter-data-critical {
color: #e63c52;
}
.container-grouped-meter
.container-info-module-meter
.container-info-module-meter-data.meter-data-warning {
color: #f3b200;
}
.container-grouped-meter
.container-info-module-meter
.container-info-module-meter-data.meter-data-normal {
color: #82b92e;
}
.dashboard-input-threshold {
align-items: center;
justify-content: space-between;
}
.dashboard-input-threshold input {
max-width: 20% !important;
}
.dashboard-input-threshold label:not(:first-child) {
flex: 0 !important;
}
.content-widget .dataTables_wrapper { .content-widget .dataTables_wrapper {
width: 98%; width: 98%;
margin-top: 5px; margin-top: 5px;

View File

@ -396,3 +396,59 @@ div.multi-response-buttons {
.white_table_graph_header { .white_table_graph_header {
align-items: center; align-items: center;
} }
.container-massive-events-response {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: flex-start;
}
.container-massive-events-response-cell {
margin-bottom: 10px;
width: 100%;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-content: flex-start;
}
.container-massive-events-response-command > span {
font-style: italic;
}
.container-massive-events-response-output {
/*border: 2px dashed #ddd;*/
/*padding: 10px;*/
margin: 10px;
}
.container-massive-events-response-execute {
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
}
#massive-parameters-response {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
#massive-parameters-response > div {
width: 80%;
}
#massive-parameters-response > div h5 {
text-align: center;
}
#massive-parameters-response > div div {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
margin-bottom: 5px;
}

View File

@ -398,7 +398,6 @@ li > input[type="email"],
border: none; border: none;
border-radius: 0; border-radius: 0;
border-bottom: 1px solid #ccc; border-bottom: 1px solid #ccc;
font-weight: lighter;
padding: 0px 0px 2px 0px; padding: 0px 0px 2px 0px;
box-sizing: border-box; box-sizing: border-box;
margin-bottom: 4px; margin-bottom: 4px;

View File

@ -9119,3 +9119,37 @@ div#err_msg_centralised {
margin-right: -110px; margin-right: -110px;
margin-top: 13px; margin-top: 13px;
} }
.tag-editor {
padding: 0.5em !important;
}
.tag-editor div {
float: right !important;
}
.tag-editor .tag-editor-tag {
padding: 5px !important;
color: #fff !important;
background: #82b92e !important;
border-radius: 0 2px 2px 0 !important;
}
.tag-editor .tag-editor-delete {
padding: 5px !important;
line-height: 16px !important;
background: #82b92e !important;
border-radius: 2px 0 0 2px !important;
}
.tag-editor .tag-editor-delete i {
line-height: 16pt !important;
}
.tag-editor .tag-editor-delete i:before {
color: #fff !important;
}
.tag-editor .tag-editor-delete:hover i:before {
color: #ccc !important;
}

View File

@ -129,7 +129,7 @@
<div style='height: 10px'> <div style='height: 10px'>
<?php <?php
$version = '7.0NG.765'; $version = '7.0NG.765';
$build = '221014'; $build = '221026';
$banner = "v$version Build $build"; $banner = "v$version Build $build";
error_reporting(0); error_reporting(0);

View File

@ -357,10 +357,10 @@ class Events
); );
if (isset($group_rep) === false) { if (isset($group_rep) === false) {
$group_rep = 0; $group_rep = EVENT_GROUP_REP_ALL;
} }
if ((int) $group_rep !== 0) { if ((int) $group_rep !== EVENT_GROUP_REP_ALL) {
if ($event['event_rep'] <= 1) { if ($event['event_rep'] <= 1) {
$event['event_repeated'] = '<i>'.__('No').'</i>'; $event['event_repeated'] = '<i>'.__('No').'</i>';
} else { } else {
@ -1068,7 +1068,7 @@ class Events
$filters['id_agent'] = $this->id_agent; $filters['id_agent'] = $this->id_agent;
} }
$filters['group_rep'] = 1; $filters['group_rep'] = EVENT_GROUP_REP_EVENTS;
if (isset($this->limit) === true if (isset($this->limit) === true
&& $this->limit !== -1 && $this->limit !== -1

View File

@ -564,7 +564,10 @@ for ($i = 0; $i < $custom_fields_count; $i++) {
$columns = array_merge($first_column, $second_column); $columns = array_merge($first_column, $second_column);
} else { } else {
$columns = $first_column; $columns = $first_column;
$filas = count($table_data->data); if ($table_data->data !== null) {
$filas = count($table_data->data);
}
$table_data->colspan[$filas][1] = 3; $table_data->colspan[$filas][1] = 3;
} }

View File

@ -223,7 +223,7 @@ if (is_ajax()) {
$id_agents, $id_agents,
$selection, $selection,
$select_mode, $select_mode,
true (bool) !$select_mode
); );
// Clean double safe input. // Clean double safe input.
@ -480,6 +480,7 @@ if (is_ajax()) {
$serialized = get_parameter('serialized', ''); $serialized = get_parameter('serialized', '');
$id_server = (int) get_parameter('id_server', 0); $id_server = (int) get_parameter('id_server', 0);
$status_modulo = (int) get_parameter('status_module', -1); $status_modulo = (int) get_parameter('status_module', -1);
$id_group_selected = (int) get_parameter('id_group', 0);
$metaconsole_server_name = null; $metaconsole_server_name = null;
if (!empty($id_server)) { if (!empty($id_server)) {
$metaconsole_server_name = db_get_value( $metaconsole_server_name = db_get_value(
@ -707,14 +708,18 @@ if (is_ajax()) {
// Get all user's groups. // Get all user's groups.
$id_group = array_keys(users_get_groups($config['id_user'])); $id_group = array_keys(users_get_groups($config['id_user']));
if (is_array($id_group)) { if (is_array($id_group) && empty($id_group_selected) === true) {
$id_group = implode(',', $id_group); $id_group = implode(',', $id_group);
} else {
if (in_array($id_group_selected, $id_group) === true) {
$id_group = $id_group_selected;
}
} }
$where_tags .= ' AND tagente.id_grupo IN ('.$id_group.')'; $where_tags .= ' AND tagente.id_grupo IN ('.$id_group.')';
if ($selection_mode == 'common') { if ($selection_mode == 'common') {
$sql_agent_total = 'SELECT count(*) FROM tagente WHERE disabled=0'; $sql_agent_total = 'SELECT count(*) FROM tagente WHERE disabled=0'.$where_tags;
$agent_total = db_get_value_sql($sql_agent_total); $agent_total = db_get_value_sql($sql_agent_total);
$sql = sprintf( $sql = sprintf(
"SELECT t1.nombre, t1.id_agente_modulo FROM tagente_modulo t1 "SELECT t1.nombre, t1.id_agente_modulo FROM tagente_modulo t1

View File

@ -84,7 +84,7 @@ ui_require_javascript_file('pandora_events');
$default_filter = [ $default_filter = [
'status' => EVENT_NO_VALIDATED, 'status' => EVENT_NO_VALIDATED,
'event_view_hr' => $config['event_view_hr'], 'event_view_hr' => $config['event_view_hr'],
'group_rep' => 1, 'group_rep' => EVENT_GROUP_REP_EVENTS,
'tag_with' => [], 'tag_with' => [],
'tag_without' => [], 'tag_without' => [],
'history' => false, 'history' => false,
@ -173,6 +173,10 @@ $search_secondary_groups = get_parameter(
'filter[search_secondary_groups]', 'filter[search_secondary_groups]',
0 0
); );
$search_recursive_groups = get_parameter(
'filter[search_recursive_groups]',
0
);
$id_group_filter = get_parameter( $id_group_filter = get_parameter(
'filter[id_group_filter]', 'filter[id_group_filter]',
($filter['id_group'] ?? '') ($filter['id_group'] ?? '')
@ -356,6 +360,10 @@ if (is_ajax() === true) {
$order['field'] = 'agent_name'; $order['field'] = 'agent_name';
break; break;
case 'if(te.ack_utimestamp > 0, from_unixtime(te.ack_utimestamp),"") as ack_utimestamp':
$order['field'] = 'ack_utimestamp';
break;
default: default:
$order['field'] = $field; $order['field'] = $field;
break; break;
@ -1090,6 +1098,7 @@ if ($loaded_filter !== false && $from_event_graph != 1 && isset($fb64) === false
$filter_only_alert = $filter['filter_only_alert']; $filter_only_alert = $filter['filter_only_alert'];
$search_secondary_groups = ($filter['search_secondary_groups'] ?? 0); $search_secondary_groups = ($filter['search_secondary_groups'] ?? 0);
$search_recursive_groups = ($filter['search_recursive_groups'] ?? 0);
$id_group_filter = $filter['id_group_filter']; $id_group_filter = $filter['id_group_filter'];
$date_from = $filter['date_from']; $date_from = $filter['date_from'];
$time_from = $filter['time_from']; $time_from = $filter['time_from'];
@ -1440,7 +1449,7 @@ if ($pure) {
).'</a>'; ).'</a>';
// If the user has administrator permission display manage tab. // If the user has administrator permission display manage tab.
if ($event_w || $event_m) { if ($event_w === true || $event_m === true) {
// Manage events. // Manage events.
$manage_events['active'] = false; $manage_events['active'] = false;
$manage_events['text'] = '<a href="index.php?sec=eventos&sec2=godmode/events/events&amp;section=filter&amp;pure='.$config['pure'].'">'.html_print_image( $manage_events['text'] = '<a href="index.php?sec=eventos&sec2=godmode/events/events&amp;section=filter&amp;pure='.$config['pure'].'">'.html_print_image(
@ -1660,9 +1669,10 @@ $inputs[] = $in;
// Duplicates group { events | agents }. // Duplicates group { events | agents }.
$data = html_print_select( $data = html_print_select(
[ [
0 => __('All events'), EVENT_GROUP_REP_ALL => __('All events'),
1 => __('Group events'), EVENT_GROUP_REP_EVENTS => __('Group events'),
2 => __('Group agents'), EVENT_GROUP_REP_AGENTS => __('Group agents'),
EVENT_GROUP_REP_EXTRAIDS => __('Group extra id'),
], ],
'group_rep', 'group_rep',
$group_rep, $group_rep,
@ -1710,6 +1720,28 @@ $in = '<div class="filter_input"><label>'.__('Severity').'</label>';
$in .= $data.'</div>'; $in .= $data.'</div>';
$inputs[] = $in; $inputs[] = $in;
// Search recursive groups.
$data = html_print_checkbox_switch(
'search_recursive_groups',
$search_recursive_groups,
$search_recursive_groups,
true,
false,
'search_in_secondary_groups(this);',
true
);
$in = '<div class="filter_input filter_input_switch"><label>';
$in .= __('Group recursion');
$in .= ui_print_help_tip(
__('WARNING: This could cause a performace impact.'),
true
);
$in .= '</label>';
$in .= $data;
$in .= '</div>';
$inputs[] = $in;
// Search secondary groups. // Search secondary groups.
$data = html_print_checkbox_switch( $data = html_print_checkbox_switch(
'search_secondary_groups', 'search_secondary_groups',
@ -1721,8 +1753,15 @@ $data = html_print_checkbox_switch(
true true
); );
$in = '<div class="filter_input filter_input_switch"><label>'.__('Search in secondary groups').'</label>'; $in = '<div class="filter_input filter_input_switch"><label>';
$in .= $data.'</div>'; $in .= __('Search in secondary groups');
$in .= ui_print_help_tip(
__('WARNING: This could cause a performace impact.'),
true
);
$in .= '</label>';
$in .= $data;
$in .= '</div>';
$inputs[] = $in; $inputs[] = $in;
// Trick view in table. // Trick view in table.
@ -1737,7 +1776,7 @@ $buttons[] = [
'onclick' => '', 'onclick' => '',
]; ];
if ($event_w || $event_m) { if ($event_w === true || $event_m === true) {
$buttons[] = [ $buttons[] = [
'id' => 'save-filter', 'id' => 'save-filter',
'class' => 'float-left margin-right-2 sub wand', 'class' => 'float-left margin-right-2 sub wand',
@ -2266,12 +2305,14 @@ try {
$active_filters_div .= '<div>'; $active_filters_div .= '<div>';
$active_filters_div .= '<div class="label box-shadow">'.__('Duplicated').'</div>'; $active_filters_div .= '<div class="label box-shadow">'.__('Duplicated').'</div>';
$active_filters_div .= '<div id="summary_duplicates" class="content">'; $active_filters_div .= '<div id="summary_duplicates" class="content">';
if ($group_rep == 0) { if ($group_rep == EVENT_GROUP_REP_ALL) {
$active_filters_div .= __('All events.'); $active_filters_div .= __('All events.');
} else if ($group_rep == 1) { } else if ($group_rep == EVENT_GROUP_REP_EVENTS) {
$active_filters_div .= __('Group events'); $active_filters_div .= __('Group events');
} else if ($group_rep == 2) { } else if ($group_rep == EVENT_GROUP_REP_AGENTS) {
$active_filters_div .= __('Group agents.'); $active_filters_div .= __('Group agents.');
} else if ($group_rep == EVENT_GROUP_REP_EXTRAIDS) {
$active_filters_div .= __('Group extra id.');
} }
$active_filters_div .= '</div>'; $active_filters_div .= '</div>';
@ -2361,6 +2402,16 @@ if (is_user_admin($config['id_user'])) {
); );
} }
$array_events_actions = [];
if ($event_w === true && $readonly === false) {
$array_events_actions['in_progress_selected'] = __('In progress selected');
$array_events_actions['validate_selected'] = __('Validate selected');
}
if ($event_m === true && $readonly === false) {
$array_events_actions['delete_selected'] = __('Delete selected');
}
foreach ($event_responses as $val) { foreach ($event_responses as $val) {
$array_events_actions[$val['id']] = $val['name']; $array_events_actions[$val['id']] = $val['name'];
} }

View File

@ -91,6 +91,10 @@ if ($is_ajax === false && $pure === false) {
$header_name = __('Heatmap view'); $header_name = __('Heatmap view');
switch ($type) { switch ($type) {
case 3:
$header_name .= ' - '.__('Agents');
break;
case 2: case 2:
if (current($filter) == 0) { if (current($filter) == 0) {
$header_name .= ' - '.__('Module group').': '.__('Not assigned'); $header_name .= ' - '.__('Module group').': '.__('Not assigned');

View File

@ -410,7 +410,7 @@ if ($access_console_node === true) {
$user_event_filter = [ $user_event_filter = [
'status' => EVENT_NO_VALIDATED, 'status' => EVENT_NO_VALIDATED,
'event_view_hr' => $config['event_view_hr'], 'event_view_hr' => $config['event_view_hr'],
'group_rep' => 1, 'group_rep' => EVENT_GROUP_REP_EVENTS,
'tag_with' => [], 'tag_with' => [],
'tag_without' => [], 'tag_without' => [],
'history' => false, 'history' => false,

View File

@ -211,7 +211,7 @@ if (isset($_GET['modified']) && !$view_mode) {
$user_info = $upd_info; $user_info = $upd_info;
} else { } else {
if (!$error_msg) { if (!$error_msg) {
$error_msg = __('Error updating passwords: '); $error_msg = __('Error updating passwords: ').($config['auth_error'] ?? '');
} }
$user_auth_error = $config['auth_error']; $user_auth_error = $config['auth_error'];

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.765 %define version 7.0NG.765
%define release 221014 %define release 221026
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.765 %define version 7.0NG.765
%define release 221014 %define release 221026
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.765 %define version 7.0NG.765
%define release 221014 %define release 221026
%define httpd_name httpd %define httpd_name httpd
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name apache2 %define httpd_name apache2

View File

@ -1245,6 +1245,7 @@ CREATE TABLE IF NOT EXISTS `tevent_filter` (
`tag_without` TEXT, `tag_without` TEXT,
`filter_only_alert` INT NOT NULL DEFAULT -1, `filter_only_alert` INT NOT NULL DEFAULT -1,
`search_secondary_groups` INT NOT NULL DEFAULT 0, `search_secondary_groups` INT NOT NULL DEFAULT 0,
`search_recursive_groups` INT NOT NULL DEFAULT 0,
`date_from` date DEFAULT NULL, `date_from` date DEFAULT NULL,
`date_to` date DEFAULT NULL, `date_to` date DEFAULT NULL,
`source` TINYTEXT, `source` TINYTEXT,
@ -1308,6 +1309,7 @@ CREATE TABLE IF NOT EXISTS `tusuario` (
`integria_user_level_pass` VARCHAR(45), `integria_user_level_pass` VARCHAR(45),
`allowed_ip_active` TINYINT UNSIGNED DEFAULT 0, `allowed_ip_active` TINYINT UNSIGNED DEFAULT 0,
`allowed_ip_list` TEXT, `allowed_ip_list` TEXT,
`auth_token_secret` VARCHAR(45) DEFAULT NULL,
CONSTRAINT `fk_filter_id` FOREIGN KEY (`id_filter`) REFERENCES tevent_filter (`id_filter`) ON DELETE SET NULL, CONSTRAINT `fk_filter_id` FOREIGN KEY (`id_filter`) REFERENCES tevent_filter (`id_filter`) ON DELETE SET NULL,
UNIQUE KEY `id_user` (`id_user`) UNIQUE KEY `id_user` (`id_user`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;

View File

@ -1,5 +1,5 @@
package: pandorafms-server package: pandorafms-server
Version: 7.0NG.765-221014 Version: 7.0NG.765-221026
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

@ -5,7 +5,7 @@
# Tentacle have IANA assigned port tpc/41121 as official port. # Tentacle have IANA assigned port tpc/41121 as official port.
########################################################################## ##########################################################################
# Copyright (c) 2007-2008 Ramon Novoa <rnovoa@artica.es> # Copyright (c) 2007-2008 Ramon Novoa <rnovoa@artica.es>
# Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L # Copyright (c) 2005-2022 Artica Soluciones Tecnologicas S.L
# #
# tentacle_server.pl Tentacle Server. See https://pandorafms.com/docs/ for # tentacle_server.pl Tentacle Server. See https://pandorafms.com/docs/ for
# protocol description. # protocol description.
@ -1740,6 +1740,19 @@ sub callback_stop {
Win32::Daemon::StopService(); Win32::Daemon::StopService();
} }
################################################################################
## SUB check_ssleay_version
## Print a message if the installed version of Net::SSLeay may leak memory.
################################################################################
sub check_ssleay_version {
eval {
require Net::SSLeay;
return unless defined($Net::SSLeay::VERSION) && $Net::SSLeay::VERSION =~ m/^(\d+)\.(\d+)/ && $1 <= 1 && $2 < 88;
print_log ("Net::SSLeay version $Net::SSLeay::VERSION detected. Versions prior to 1.88 may leak memory. To upgrade it see: https://metacpan.org/pod/Net::SSLeay");
};
}
################################################################################ ################################################################################
# Main # Main
################################################################################ ################################################################################
@ -1753,12 +1766,20 @@ if ($> == 0 && $^O ne 'MSWin32') {
# Parse command line options # Parse command line options
parse_options (); parse_options ();
# Try to open the log file.
if (defined($log_file)) {
open(my $fh, ">>", $log_file) || die("Error opening the log file '$log_file': $!.\n");
close($fh);
}
# Check command line arguments # Check command line arguments
if ($#ARGV != -1) { if ($#ARGV != -1) {
print_help (); print_help ();
exit 1; exit 1;
} }
check_ssleay_version() if $t_ssl == 1;
# Show IPv6 status # Show IPv6 status
if ($SOCKET_MODULE eq 'IO::Socket::INET') { if ($SOCKET_MODULE eq 'IO::Socket::INET') {
print_log ("IO::Socket::INET6 is not found. IPv6 is disabled."); print_log ("IO::Socket::INET6 is not found. IPv6 is disabled.");

View File

@ -5,7 +5,7 @@
# Tentacle have IANA assigned port tpc/41121 as official port. # Tentacle have IANA assigned port tpc/41121 as official port.
########################################################################## ##########################################################################
# Copyright (c) 2007-2008 Ramon Novoa <rnovoa@artica.es> # Copyright (c) 2007-2008 Ramon Novoa <rnovoa@artica.es>
# Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L # Copyright (c) 2005-2022 Artica Soluciones Tecnologicas S.L
# #
# tentacle_server.pl Tentacle Server. See https://pandorafms.com/docs/ for # tentacle_server.pl Tentacle Server. See https://pandorafms.com/docs/ for
# protocol description. # protocol description.
@ -1766,6 +1766,12 @@ if ($> == 0 && $^O ne 'MSWin32') {
# Parse command line options # Parse command line options
parse_options (); parse_options ();
# Try to open the log file.
if (defined($log_file)) {
open(my $fh, ">>", $log_file) || die("Error opening the log file '$log_file': $!.\n");
close($fh);
}
# Check command line arguments # Check command line arguments
if ($#ARGV != -1) { if ($#ARGV != -1) {
print_help (); print_help ();

View File

@ -46,7 +46,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.765"; my $pandora_version = "7.0NG.765";
my $pandora_build = "221014"; my $pandora_build = "221026";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash # Setup hash

View File

@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.765"; my $pandora_version = "7.0NG.765";
my $pandora_build = "221014"; my $pandora_build = "221026";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] ); our %EXPORT_TAGS = ( 'all' => [ qw() ] );

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.765 %define version 7.0NG.765
%define release 221014 %define release 221026
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.765 %define version 7.0NG.765
%define release 221014 %define release 221026
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -9,7 +9,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.765" PI_VERSION="7.0NG.765"
PI_BUILD="221014" PI_BUILD="221026"
MODE=$1 MODE=$1
if [ $# -gt 1 ]; then if [ $# -gt 1 ]; then

View File

@ -35,7 +35,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB; use PandoraFMS::DB;
# version: define current version # version: define current version
my $version = "7.0NG.765 Build 221014"; my $version = "7.0NG.765 Build 221026";
# Pandora server configuration # Pandora server configuration
my %conf; my %conf;

View File

@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv; Encode::Locale::decode_argv;
# version: define current version # version: define current version
my $version = "7.0NG.765 Build 221014"; my $version = "7.0NG.765 Build 221026";
# save program name for logging # save program name for logging
my $progname = basename($0); my $progname = basename($0);
@ -251,6 +251,11 @@ sub help_screen{
print "\nEVENTS\n\n" unless $param ne ''; print "\nEVENTS\n\n" unless $param ne '';
help_screen_line('--event_in_progress', '<id_event> ', 'Set event in progress'); help_screen_line('--event_in_progress', '<id_event> ', 'Set event in progress');
print "\nGIS\n\n" unless $param ne '';
help_screen_line('--get_gis_agent', '<agent_id> ', 'Gets agent GIS information');
help_screen_line('--insert_gis_data', '<agent_id> [<latitude>] [<longitude>] [<altitude>]', 'Sets new GIS data for specified agent');
print "\n"; print "\n";
exit; exit;
} }
@ -261,7 +266,7 @@ sub help_screen{
sub api_call($$$;$$$$) { sub api_call($$$;$$$$) {
my ($pa_config, $op, $op2, $id, $id2, $other, $return_type) = @_; my ($pa_config, $op, $op2, $id, $id2, $other, $return_type) = @_;
my $content = undef; my $content = undef;
eval { eval {
# Set the parameters for the POST request. # Set the parameters for the POST request.
my $params = {}; my $params = {};
@ -275,10 +280,11 @@ sub api_call($$$;$$$$) {
$params->{"other"} = $other; $params->{"other"} = $other;
$params->{"return_type"} = $return_type; $params->{"return_type"} = $return_type;
$params->{"other_mode"} = "url_encode_separator_|"; $params->{"other_mode"} = "url_encode_separator_|";
# Call the API. # Call the API.
my $ua = new LWP::UserAgent; my $ua = new LWP::UserAgent;
my $url = $pa_config->{"console_api_url"}; my $url = $pa_config->{"console_api_url"};
my $response = $ua->post($url, $params); my $response = $ua->post($url, $params);
if ($response->is_success) { if ($response->is_success) {
@ -288,7 +294,7 @@ sub api_call($$$;$$$$) {
$content = $response->decoded_content(); $content = $response->decoded_content();
} }
}; };
return $content; return $content;
} }
@ -567,8 +573,8 @@ sub pandora_create_user ($$$$$) {
exit; exit;
} }
return db_insert ($dbh, 'id_user', 'INSERT INTO tusuario (id_user, fullname, password, comments, is_admin) return db_insert ($dbh, 'id_user', 'INSERT INTO tusuario (id_user, fullname, password, is_admin, comments)
VALUES (?, ?, ?, ?, ?)', safe_input($name), safe_input($name), $password, safe_input($comments), $is_admin); VALUES (?, ?, ?, ?, ?)', safe_input($name), safe_input($name), $password, $is_admin ? '1' : '0', decode_entities($comments));
} }
########################################################################## ##########################################################################
@ -8045,6 +8051,14 @@ sub pandora_manage_main ($$$) {
param_check($ltotal, 4, 5); param_check($ltotal, 4, 5);
cli_agent_update_custom_fields(); cli_agent_update_custom_fields();
} }
elsif ($param eq '--get_gis_agent') {
param_check($ltotal, 1, 0);
cli_get_gis_agent();
}
elsif ($param eq '--insert_gis_data'){
param_check($ltotal, 4, 0);
cli_insert_gis_data();
}
else { else {
print_log "[ERROR] Invalid option '$param'.\n\n"; print_log "[ERROR] Invalid option '$param'.\n\n";
$param = ''; $param = '';
@ -8765,3 +8779,32 @@ sub pandora_validate_alert_id($$$$) {
return 1; return 1;
} }
##############################################################################
# Get GIS data from agent
##############################################################################
sub cli_get_gis_agent(){
my $agent_id = @ARGV[2];
my $result = api_call(\%conf,'get', 'gis_agent', $agent_id);
print "$result \n\n ";
}
##############################################################################
# Set GIS data for specified agent
##############################################################################
sub cli_insert_gis_data(){
my ($agent_id, $latitude, $longitude, $altitude) = @ARGV[2..5];
my $agent_id = @ARGV[2];
my @position = @ARGV[3..5];
my $other = join('|', @position);
my $result = api_call(\%conf,'set', 'gis_agent_only_position', $agent_id, undef, "$other");
print "$result \n\n ";
}

View File

@ -119,7 +119,6 @@ case "$1" in
rc_status -v rc_status -v
else else
echo "Tentacle Server could not be started." echo "Tentacle Server could not be started."
echo "Verify that Tentacle port is not used."
rc_failed 7 # program not running rc_failed 7 # program not running
fi fi

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
# Tentacle have IANA assigned port tpc/41121 as official port. # Tentacle have IANA assigned port tpc/41121 as official port.
########################################################################## ##########################################################################
# Copyright (c) 2007-2008 Ramon Novoa <rnovoa@artica.es> # Copyright (c) 2007-2008 Ramon Novoa <rnovoa@artica.es>
# Copyright (c) 2005-2021 Artica Soluciones Tecnologicas S.L # Copyright (c) 2005-2022 Artica Soluciones Tecnologicas S.L
# #
# tentacle_server.pl Tentacle Server. See https://pandorafms.com/docs/ for # tentacle_server.pl Tentacle Server. See https://pandorafms.com/docs/ for
# protocol description. # protocol description.
@ -230,7 +230,6 @@ sub print_help {
print ("\t-p port\t\tPort to listen on (default $t_port).\n"); print ("\t-p port\t\tPort to listen on (default $t_port).\n");
print ("\t-q\t\tQuiet. Do now print error messages.\n"); print ("\t-q\t\tQuiet. Do now print error messages.\n");
print ("\t-r number\tNumber of retries for network opertions (default $t_retries).\n"); print ("\t-r number\tNumber of retries for network opertions (default $t_retries).\n");
print ("\t-s Storage directory\n");
print ("\t-S (install|uninstall|run) Manage the win32 service.\n"); print ("\t-S (install|uninstall|run) Manage the win32 service.\n");
print ("\t-t time\t\tTime-out for network operations in seconds (default ${t_timeout}s).\n"); print ("\t-t time\t\tTime-out for network operations in seconds (default ${t_timeout}s).\n");
print ("\t-v\t\tBe verbose (display errors).\n"); print ("\t-v\t\tBe verbose (display errors).\n");
@ -1767,6 +1766,12 @@ if ($> == 0 && $^O ne 'MSWin32') {
# Parse command line options # Parse command line options
parse_options (); parse_options ();
# Try to open the log file.
if (defined($log_file)) {
open(my $fh, ">>", $log_file) || die("Error opening the log file '$log_file': $!.\n");
close($fh);
}
# Check command line arguments # Check command line arguments
if ($#ARGV != -1) { if ($#ARGV != -1) {
print_help (); print_help ();

View File

@ -119,7 +119,6 @@ case "$1" in
rc_status -v rc_status -v
else else
echo "Tentacle Server could not be started." echo "Tentacle Server could not be started."
echo "Verify that Tentacle port is not used."
rc_failed 7 # program not running rc_failed 7 # program not running
fi fi