mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-09-26 03:19:05 +02:00
Merge remote-tracking branch 'origin' into ent-9662-Restyling-fuentes-colores-botones
This commit is contained in:
commit
a688182062
@ -170,7 +170,7 @@ http://rpms.remirepo.net/enterprise/remi-release-7.rpm \
|
||||
https://repo.percona.com/yum/percona-release-latest.noarch.rpm"
|
||||
|
||||
execute_cmd "yum install -y $extra_repos" "Installing extra repositories"
|
||||
execute_cmd "yum-config-manager --enable remi-php74" "Configuring PHP"
|
||||
execute_cmd "yum-config-manager --enable remi-php80" "Configuring PHP"
|
||||
|
||||
# Install percona Database
|
||||
#[ -f /etc/my.cnf ] && rm -rf /etc/my.cnf
|
||||
|
@ -20,7 +20,7 @@ LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log"
|
||||
# define default variables
|
||||
[ "$TZ" ] || TZ="Europe/Madrid"
|
||||
[ "$MYVER" ] || MYVER=57
|
||||
[ "$PHPVER" ] || PHPVER=7
|
||||
[ "$PHPVER" ] || PHPVER=8
|
||||
[ "$DBHOST" ] || DBHOST=127.0.0.1
|
||||
[ "$DBNAME" ] || DBNAME=pandora
|
||||
[ "$DBUSER" ] || DBUSER=pandora
|
||||
|
@ -21,7 +21,7 @@ LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log"
|
||||
|
||||
# define default variables
|
||||
[ "$TZ" ] || TZ="Europe/Madrid"
|
||||
[ "$PHPVER" ] || PHPVER=7.4
|
||||
[ "$PHPVER" ] || PHPVER=8.0
|
||||
[ "$DBHOST" ] || DBHOST=127.0.0.1
|
||||
[ "$DBNAME" ] || DBNAME=pandora
|
||||
[ "$DBUSER" ] || DBUSER=pandora
|
||||
@ -138,6 +138,9 @@ check_root_permissions
|
||||
# Connectivity
|
||||
check_repo_connection
|
||||
|
||||
#Install awk, sed, grep if not present
|
||||
execute_cmd "apt install -y gawk sed grep" 'Installing needed tools'
|
||||
|
||||
# Systemd
|
||||
execute_cmd "systemctl --version" "Checking SystemD" 'This is not a SystemD enable system, if tryng to use in a docker env please check: https://github.com/pandorafms/pandorafms/tree/develop/extras/docker/centos8'
|
||||
|
||||
@ -155,7 +158,7 @@ execute_cmd "timedatectl set-timezone $TZ" "Setting Timezone $TZ"
|
||||
execute_cmd "awk --version" 'Checking needed tools: awk'
|
||||
execute_cmd "grep --version" 'Checking needed tools: grep'
|
||||
execute_cmd "sed --version" 'Checking needed tools: sed'
|
||||
execute_cmd "apt --version" 'Checking needed tools: dnf'
|
||||
execute_cmd "apt --version" 'Checking needed tools: apt'
|
||||
|
||||
# Creating working directory
|
||||
rm -rf "$WORKDIR" &>> "$LOGFILE"
|
||||
|
@ -5,7 +5,7 @@
|
||||
# Tentacle have IANA assigned port tpc/41121 as official port.
|
||||
##########################################################################
|
||||
# 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
|
||||
# protocol description.
|
||||
@ -1740,6 +1740,19 @@ sub callback_stop {
|
||||
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
|
||||
################################################################################
|
||||
@ -1753,12 +1766,20 @@ if ($> == 0 && $^O ne 'MSWin32') {
|
||||
# Parse command line 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
|
||||
if ($#ARGV != -1) {
|
||||
print_help ();
|
||||
exit 1;
|
||||
}
|
||||
|
||||
check_ssleay_version() if $t_ssl == 1;
|
||||
|
||||
# Show IPv6 status
|
||||
if ($SOCKET_MODULE eq 'IO::Socket::INET') {
|
||||
print_log ("IO::Socket::INET6 is not found. IPv6 is disabled.");
|
||||
|
@ -1,5 +1,5 @@
|
||||
package: pandorafms-agent-unix
|
||||
Version: 7.0NG.765-221017
|
||||
Version: 7.0NG.765-221103
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
@ -14,7 +14,7 @@
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.765-221017"
|
||||
pandora_version="7.0NG.765-221103"
|
||||
|
||||
echo "Test if you has the tools for to make the packages."
|
||||
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
||||
|
@ -1015,7 +1015,7 @@ my $Sem = undef;
|
||||
my $ThreadSem = undef;
|
||||
|
||||
use constant AGENT_VERSION => '7.0NG.765';
|
||||
use constant AGENT_BUILD => '221017';
|
||||
use constant AGENT_BUILD => '221103';
|
||||
|
||||
# Agent log default file size maximum and instances
|
||||
use constant DEFAULT_MAX_LOG_SIZE => 600000;
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.765
|
||||
%define release 221017
|
||||
%define release 221103
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.765
|
||||
%define release 221017
|
||||
%define release 221103
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
@ -10,7 +10,7 @@
|
||||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.765"
|
||||
PI_BUILD="221017"
|
||||
PI_BUILD="221103"
|
||||
OS_NAME=`uname -s`
|
||||
|
||||
FORCE=0
|
||||
|
@ -5,7 +5,7 @@
|
||||
# Tentacle have IANA assigned port tpc/41121 as official port.
|
||||
##########################################################################
|
||||
# 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
|
||||
# protocol description.
|
||||
@ -1740,6 +1740,19 @@ sub callback_stop {
|
||||
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
|
||||
################################################################################
|
||||
@ -1753,12 +1766,20 @@ if ($> == 0 && $^O ne 'MSWin32') {
|
||||
# Parse command line 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
|
||||
if ($#ARGV != -1) {
|
||||
print_help ();
|
||||
exit 1;
|
||||
}
|
||||
|
||||
check_ssleay_version() if $t_ssl == 1;
|
||||
|
||||
# Show IPv6 status
|
||||
if ($SOCKET_MODULE eq 'IO::Socket::INET') {
|
||||
print_log ("IO::Socket::INET6 is not found. IPv6 is disabled.");
|
||||
|
@ -186,7 +186,7 @@ UpgradeApplicationID
|
||||
{}
|
||||
|
||||
Version
|
||||
{221017}
|
||||
{221103}
|
||||
|
||||
ViewReadme
|
||||
{Yes}
|
||||
|
@ -30,7 +30,7 @@ using namespace Pandora;
|
||||
using namespace Pandora_Strutils;
|
||||
|
||||
#define PATH_SIZE _MAX_PATH+1
|
||||
#define PANDORA_VERSION ("7.0NG.765 Build 221017")
|
||||
#define PANDORA_VERSION ("7.0NG.765 Build 221103")
|
||||
|
||||
string pandora_path;
|
||||
string pandora_dir;
|
||||
|
@ -11,7 +11,7 @@ BEGIN
|
||||
VALUE "LegalCopyright", "Artica ST"
|
||||
VALUE "OriginalFilename", "PandoraAgent.exe"
|
||||
VALUE "ProductName", "Pandora FMS Windows Agent"
|
||||
VALUE "ProductVersion", "(7.0NG.765(Build 221017))"
|
||||
VALUE "ProductVersion", "(7.0NG.765(Build 221103))"
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
END
|
||||
END
|
||||
|
@ -1,5 +1,5 @@
|
||||
package: pandorafms-console
|
||||
Version: 7.0NG.765-221017
|
||||
Version: 7.0NG.765-221103
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
@ -14,7 +14,7 @@
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.765-221017"
|
||||
pandora_version="7.0NG.765-221103"
|
||||
|
||||
package_pear=0
|
||||
package_pandora=1
|
||||
|
@ -110,12 +110,13 @@ $auth_class = io_safe_output(
|
||||
$page = (string) get_parameter('page');
|
||||
$page = safe_url_extraclean($page);
|
||||
$page .= '.php';
|
||||
$page = realpath($page);
|
||||
$public_hash = get_parameter('auth_hash', false);
|
||||
$public_login = false;
|
||||
|
||||
|
||||
if (false === ((bool) get_parameter('doLogin', false) === true
|
||||
&& $page === 'include/rest-api/index.php')
|
||||
&& $page === realpath('include/rest-api/index.php'))
|
||||
) {
|
||||
// Check user.
|
||||
if (class_exists($auth_class) === false || $public_hash === false) {
|
||||
|
@ -1666,3 +1666,4 @@ godmode/um_client/vendor/sebastian/object-enumerator
|
||||
godmode/um_client/vendor/sebastian
|
||||
godmode/um_client/vendor
|
||||
update_manager_client/resources/styles/pandora.css
|
||||
enterprise/meta/general/upload_head_image.php
|
||||
|
@ -1,6 +1,16 @@
|
||||
START TRANSACTION;
|
||||
|
||||
ALTER TABLE `trecon_task` ADD COLUMN `snmp_skip_non_enabled_ifs` TINYINT UNSIGNED DEFAULT 1;
|
||||
|
||||
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_path` VARCHAR(1000) DEFAULT '';
|
||||
|
||||
ALTER TABLE `tevent_filter` ADD COLUMN `search_recursive_groups` INT NOT NULL DEFAULT 0;
|
||||
|
||||
ALTER TABLE `tcredential_store` MODIFY COLUMN `product` ENUM('CUSTOM', 'AWS', 'AZURE', 'GOOGLE', 'SAP', 'WMI', 'SNMP') DEFAULT 'CUSTOM';
|
||||
|
||||
COMMIT;
|
||||
|
@ -167,7 +167,7 @@ if (!$double_auth_enabled
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
title: "<?php echo __('Double autentication activation'); ?>",
|
||||
title: "<?php echo __('Double authentication activation'); ?>",
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
|
@ -181,7 +181,7 @@ $module_macros = [];
|
||||
// Create agent.
|
||||
if ($create_agent) {
|
||||
$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_as_name = (int) get_parameter_post('alias_as_name', 0);
|
||||
$direccion_agente = (string) get_parameter_post('direccion', '');
|
||||
@ -926,7 +926,7 @@ if ($update_agent) {
|
||||
$mssg_warning = 0;
|
||||
$id_agente = (int) get_parameter_post('id_agente');
|
||||
$nombre_agente = str_replace('`', '‘', (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_as_name = (int) get_parameter_post('alias_as_name', 0);
|
||||
$direccion_agente = (string) get_parameter_post('direccion', '');
|
||||
|
@ -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_servers.php';
|
||||
|
||||
$search_string = io_safe_output(
|
||||
urldecode(
|
||||
trim(
|
||||
get_parameter(
|
||||
'search_string',
|
||||
''
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
$search_string = get_parameter('search_string');
|
||||
|
||||
global $policy_page;
|
||||
|
||||
|
@ -140,6 +140,49 @@ if ($id_module_type >= 6 && $id_module_type <= 7) {
|
||||
|
||||
push_table_simple($data, 'target_ip');
|
||||
|
||||
$user_groups = users_get_groups(false, 'AR');
|
||||
if (users_is_admin() === true || isset($user_groups[0]) === true) {
|
||||
$credentials = db_get_all_rows_sql(
|
||||
'SELECT identifier FROM tcredential_store WHERE product LIKE "SNMP"'
|
||||
);
|
||||
} else {
|
||||
$credentials = db_get_all_rows_sql(
|
||||
sprintf(
|
||||
'SELECT identifier FROM tcredential_store WHERE product LIKE "SNMP" AND id_group IN (%s)',
|
||||
implode(',', array_keys($user_groups))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($credentials) === false) {
|
||||
$fields = [];
|
||||
foreach ($credentials as $key => $value) {
|
||||
$fields[$value['identifier']] = $value['identifier'];
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data[0] = __('Credential store');
|
||||
$data[1] = html_print_select(
|
||||
$fields,
|
||||
'credentials',
|
||||
0,
|
||||
'',
|
||||
__('None'),
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
false
|
||||
);
|
||||
|
||||
push_table_simple($data, 'snmp_credentials');
|
||||
}
|
||||
|
||||
|
||||
$snmp_versions['1'] = 'v. 1';
|
||||
$snmp_versions['2'] = 'v. 2';
|
||||
$snmp_versions['2c'] = 'v. 2c';
|
||||
@ -316,6 +359,7 @@ if ($id_module_type < 15 || $id_module_type > 18) {
|
||||
// NOT SNMP.
|
||||
$table_simple->rowstyle['snmp_1'] = 'display: none';
|
||||
$table_simple->rowstyle['snmp_2'] = 'display: none';
|
||||
$table_simple->rowstyle['snmp_credentials'] = 'display: none';
|
||||
}
|
||||
|
||||
// For a policy.
|
||||
@ -569,6 +613,49 @@ $(document).ready (function () {
|
||||
$(this).css ("width", "180px");
|
||||
});
|
||||
|
||||
$("#credentials").change (function() {
|
||||
if ($('#credentials').val() !== '0') {
|
||||
$.ajax({
|
||||
method: "post",
|
||||
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
data: {
|
||||
page: "godmode/agentes/agent_wizard",
|
||||
method: "getCredentials",
|
||||
identifier: $('#credentials').val()
|
||||
},
|
||||
datatype: "json",
|
||||
success: function(data) {
|
||||
data = JSON.parse(data);
|
||||
extra = JSON.parse(data['extra_1']);
|
||||
$('#snmp_version').val(extra['version']);
|
||||
$('#snmp_version').trigger('change');
|
||||
$('#text-snmp_community').val(extra['community']);
|
||||
|
||||
if (extra['version'] === '3') {
|
||||
$('#snmp3_security_level').val(extra['securityLevelV3']);
|
||||
$('#snmp3_security_level').trigger('change');
|
||||
$('#text-snmp3_auth_user').val(extra['authUserV3']);
|
||||
|
||||
if (extra['securityLevelV3'] === 'authNoPriv' || extra['securityLevelV3'] === 'authPriv') {
|
||||
$('#snmp3_auth_method').val(extra['authMethodV3']);
|
||||
$('#snmp3_auth_method').trigger('change');
|
||||
$('#password-snmp3_auth_pass').val(extra['authPassV3']);
|
||||
|
||||
if (extra['securityLevelV3'] === 'authPriv') {
|
||||
$('#snmp3_privacy_method').val(extra['privacyMethodV3']);
|
||||
$('#snmp3_privacy_method').trigger('change');
|
||||
$('#password-snmp3_privacy_pass').val(extra['privacyPassV3']);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function(e) {
|
||||
console.error(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$("#id_module_type").click (
|
||||
function () {
|
||||
$(this).css ("width", "auto");
|
||||
|
@ -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%;');
|
||||
|
||||
|
||||
if ($type_downtime != 'quiet') {
|
||||
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->rowid[2] = 'available_modules_selection_mode';
|
||||
|
||||
$table->data[2][1] = html_print_select(
|
||||
[
|
||||
@ -1128,19 +1124,13 @@ $table->data[2][1] = html_print_select(
|
||||
'min-width:180px;'
|
||||
);
|
||||
|
||||
echo '</div>';
|
||||
|
||||
$table->rowid[3] = 'available_modules';
|
||||
$table->data[3][0] = __('Available modules:').ui_print_help_tip(
|
||||
__('Only for type Quiet for downtimes.'),
|
||||
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(
|
||||
[],
|
||||
'module[]',
|
||||
@ -1155,7 +1145,6 @@ $table->data[3][1] = html_print_select(
|
||||
false,
|
||||
'min-width: 250px;width: 70%;'
|
||||
);
|
||||
echo '</div>';
|
||||
|
||||
// Print agent table.
|
||||
html_print_table($table);
|
||||
@ -1184,7 +1173,6 @@ if ($id_downtime > 0) {
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
html_print_input_hidden('all_agents', implode(',', array_keys($agents)));
|
||||
html_print_input_hidden('all_common_modules', '');
|
||||
echo '</form>';
|
||||
|
||||
@ -1405,12 +1393,19 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
|
||||
}
|
||||
|
||||
$agents = (array) get_parameter('id_agents');
|
||||
$filter_group = (int) get_parameter('filter_group', 0);
|
||||
$module_names = (array) get_parameter('module');
|
||||
$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_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) {
|
||||
$module_names = explode(',', get_parameter('all_common_modules'));
|
||||
}
|
||||
@ -1429,11 +1424,33 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
|
||||
} else {
|
||||
// If is selected 'Any', get all the agents.
|
||||
if (count($agents) === 1 && (int) $agents[0] === -2) {
|
||||
$all_agents = get_parameter('all_agents');
|
||||
$agents = explode(',', $all_agents);
|
||||
if ($recursion === true) {
|
||||
$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) {
|
||||
$agent_id = (int) $agent_id;
|
||||
// Check module belongs to the agent.
|
||||
if ($modules_selection_mode == 'all' && $all_modules === false) {
|
||||
$check = false;
|
||||
@ -1466,17 +1483,40 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
|
||||
continue;
|
||||
}
|
||||
|
||||
$values = [
|
||||
'id_downtime' => $id_downtime,
|
||||
'id_agent' => $agent_id,
|
||||
'all_modules' => $all_modules,
|
||||
];
|
||||
$result = db_process_sql_insert(
|
||||
// Check if agent is already in downtime.
|
||||
$agent_in_downtime = db_get_value_filter(
|
||||
'id_downtime',
|
||||
'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) {
|
||||
$module = modules_get_agentmodule_id(
|
||||
$module_name,
|
||||
@ -1487,17 +1527,32 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
|
||||
continue;
|
||||
}
|
||||
|
||||
$values = [
|
||||
'id_downtime' => $id_downtime,
|
||||
'id_agent' => $agent_id,
|
||||
'id_agent_module' => $module['id_agente_modulo'],
|
||||
];
|
||||
$result = db_process_sql_insert(
|
||||
// Check if modules are already in downtime.
|
||||
$module_in_downtime = db_get_value_filter(
|
||||
'id_downtime',
|
||||
'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']];
|
||||
$result = db_process_sql_update(
|
||||
'tplanned_downtime',
|
||||
@ -1526,6 +1581,7 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
|
||||
$("#available_modules_selection_mode").hide();
|
||||
break;
|
||||
case 'quiet':
|
||||
case 'disable_agent_modules':
|
||||
$("#available_modules_selection_mode").show();
|
||||
$("#available_modules").show();
|
||||
break;
|
||||
@ -1840,7 +1896,6 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
|
||||
$('input.hasDatepicker[readonly]').disable();
|
||||
|
||||
$("#checkbox-recursion").click(function() {
|
||||
recursion = this.checked;
|
||||
$("#filter_group").trigger("change");
|
||||
});
|
||||
|
||||
@ -1850,6 +1905,7 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
|
||||
});
|
||||
|
||||
function populate_agents_selector() {
|
||||
recursion = $("#checkbox-recursion").prop('checked');
|
||||
jQuery.post ("ajax.php",
|
||||
{"page": "operation/agentes/ver_agente",
|
||||
"get_agents_group_json": 1,
|
||||
|
@ -137,12 +137,49 @@ if (is_ajax() === true) {
|
||||
'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);
|
||||
|
||||
echo json_encode(
|
||||
[
|
||||
'data' => $modules,
|
||||
'data' => $data,
|
||||
'recordsTotal' => $count[0]['total'],
|
||||
'recordsFiltered' => $count[0]['total'],
|
||||
]
|
||||
|
@ -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.
|
||||
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(
|
||||
$config['id_user
|
||||
']
|
||||
)
|
||||
) {
|
||||
if (is_user_admin($config['id_user']) === true) {
|
||||
$data['action'] = '<span class="inline_flex">';
|
||||
$data['action'] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_commands&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>';
|
||||
@ -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 '<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"');
|
||||
|
@ -90,6 +90,7 @@ if ($id) {
|
||||
|
||||
$filter_only_alert = $filter['filter_only_alert'];
|
||||
$search_secondary_groups = $filter['search_secondary_groups'];
|
||||
$search_recursive_groups = $filter['search_recursive_groups'];
|
||||
$custom_data = $filter['custom_data'];
|
||||
$custom_data_filter_type = $filter['custom_data_filter_type'];
|
||||
|
||||
@ -128,6 +129,7 @@ if ($id) {
|
||||
$tag_without_base64 = base64_encode($tag_without_json);
|
||||
$filter_only_alert = '';
|
||||
$search_secondary_groups = 0;
|
||||
$search_recursive_groups = 0;
|
||||
}
|
||||
|
||||
if ($update || $create) {
|
||||
@ -170,6 +172,7 @@ if ($update || $create) {
|
||||
|
||||
$filter_only_alert = get_parameter('filter_only_alert', '');
|
||||
$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_filter_type = get_parameter('custom_data_filter_type', '');
|
||||
@ -198,6 +201,7 @@ if ($update || $create) {
|
||||
'user_comment' => $user_comment,
|
||||
'filter_only_alert' => $filter_only_alert,
|
||||
'search_secondary_groups' => $search_secondary_groups,
|
||||
'search_recursive_groups' => $search_recursive_groups,
|
||||
'custom_data' => $custom_data,
|
||||
'custom_data_filter_type' => $custom_data_filter_type,
|
||||
];
|
||||
@ -438,8 +442,12 @@ $table->data[10][1] = html_print_select(
|
||||
true
|
||||
);
|
||||
|
||||
$repeated_sel[0] = __('All events');
|
||||
$repeated_sel[1] = __('Group events');
|
||||
$repeated_sel = [
|
||||
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][1] = html_print_select(
|
||||
$repeated_sel,
|
||||
|
@ -59,7 +59,7 @@ if ($id_group) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$table = new stdClass();
|
||||
$table->width = '100%';
|
||||
$table->class = 'databox filters';
|
||||
$table->style[0] = 'font-weight: bold';
|
||||
|
@ -141,6 +141,7 @@ if ($table !== null) {
|
||||
|
||||
unset($table);
|
||||
|
||||
$table = new stdClass();
|
||||
$table->width = '100%';
|
||||
$table->class = 'databox filters';
|
||||
$table->data = [];
|
||||
|
717
pandora_console/godmode/massive/massive_edit_users.php
Normal file
717
pandora_console/godmode/massive/massive_edit_users.php
Normal file
@ -0,0 +1,717 @@
|
||||
<?php
|
||||
/**
|
||||
* View for edit users in Massive Operations
|
||||
*
|
||||
* @category Configuration
|
||||
* @package Pandora FMS
|
||||
* @subpackage Massive Operations
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* 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.
|
||||
check_login();
|
||||
|
||||
global $config;
|
||||
|
||||
if (users_is_admin() === false) {
|
||||
db_pandora_audit(
|
||||
AUDIT_LOG_ACL_VIOLATION,
|
||||
'Trying to access massive edit users'
|
||||
);
|
||||
include 'general/noaccess.php';
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_management_allowed() === false) {
|
||||
if (is_metaconsole() === false) {
|
||||
$url = '<a target="_blank" href="'.ui_get_meta_url(
|
||||
'index.php?sec=advanced&sec2=advanced/users_setup&tab=profile&pure='.(int) $config['pure']
|
||||
).'">'.__('metaconsole').'</a>';
|
||||
} else {
|
||||
$url = __('any node');
|
||||
}
|
||||
|
||||
ui_print_warning_message(
|
||||
__(
|
||||
'This node is configured with centralized mode. All profiles user information is read only. Go to %s to manage it.',
|
||||
$url
|
||||
)
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
include_once $config['homedir'].'/include/functions_visual_map.php';
|
||||
open_meta_frame();
|
||||
}
|
||||
|
||||
$edit_users = (int) get_parameter('edit_users');
|
||||
if ($edit_users === 1) {
|
||||
$users = get_parameter('id_users', false, false);
|
||||
if ($users !== false) {
|
||||
$update = [];
|
||||
|
||||
$language = (string) get_parameter('language', '-1');
|
||||
if ($language !== '-1') {
|
||||
$update['language'] = $language;
|
||||
}
|
||||
|
||||
$block_size_change = (int) get_parameter('block_size_change');
|
||||
if ($block_size_change === 0) {
|
||||
$block_size = (int) get_parameter('block_size', -1);
|
||||
if ($block_size !== -1) {
|
||||
$update['block_size'] = $block_size;
|
||||
}
|
||||
}
|
||||
|
||||
$section = get_parameter('section', '-1');
|
||||
if ($section !== '-1') {
|
||||
$update['section'] = $section;
|
||||
}
|
||||
|
||||
$data_section = get_parameter('data_section', '');
|
||||
$dashboard = get_parameter('dashboard', '');
|
||||
$visual_console = get_parameter('visual_console', '');
|
||||
$section = io_safe_output($section);
|
||||
|
||||
if (($section === 'Event list') || ($section === 'Group view')
|
||||
|| ($section === 'Alert detail') || ($section === 'Tactical view')
|
||||
|| ($section === 'Default')
|
||||
) {
|
||||
$update['data_section'] = '';
|
||||
} else if ($section === 'Dashboard') {
|
||||
$update['data_section'] = $dashboard;
|
||||
} else if ($section === 'Visual console') {
|
||||
$update['data_section'] = $visual_console;
|
||||
}
|
||||
|
||||
$event = (int) get_parameter('event_filter', -1);
|
||||
if ($event !== -1) {
|
||||
$update['default_event_filter'] = $event;
|
||||
}
|
||||
|
||||
$autorefresh_list = get_parameter_post('autorefresh_list', [0 => '-1']);
|
||||
if ($autorefresh_list[0] !== '-1') {
|
||||
if (($autorefresh_list[0] === '') || ($autorefresh_list[0] === '0')) {
|
||||
$update['autorefresh_white_list'] = '';
|
||||
} else {
|
||||
$update['autorefresh_white_list'] = json_encode($autorefresh_list);
|
||||
}
|
||||
}
|
||||
|
||||
$time_autorefresh = (int) get_parameter('time_autorefresh', -1);
|
||||
if ($time_autorefresh !== -1) {
|
||||
$update['time_autorefresh'] = $time_autorefresh;
|
||||
}
|
||||
|
||||
$timezone = (string) get_parameter('timezone', '-1');
|
||||
if ($timezone !== '-1') {
|
||||
$update['timezone'] = $timezone;
|
||||
}
|
||||
|
||||
$disabled = (int) get_parameter('disabled', -1);
|
||||
if ($disabled !== -1) {
|
||||
$update['disabled'] = $disabled;
|
||||
}
|
||||
|
||||
$error = [];
|
||||
$success = [];
|
||||
foreach ($users as $key => $user) {
|
||||
if (empty($update) === false) {
|
||||
$result = update_user($user, $update);
|
||||
if ($result === false) {
|
||||
$error[] = $user;
|
||||
} else {
|
||||
$success[] = $user;
|
||||
}
|
||||
} else {
|
||||
$error[] = $user;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($success) === false) {
|
||||
ui_print_success_message(
|
||||
__(
|
||||
'Users updated successfully (%s)',
|
||||
implode(
|
||||
',',
|
||||
$success
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($error) === false) {
|
||||
ui_print_error_message(
|
||||
__(
|
||||
'Users cannot be updated (%s)',
|
||||
implode(',', $error)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (is_metaconsole() === false) {
|
||||
include 'include/javascript/timezonepicker/includes/parser.inc';
|
||||
|
||||
// Read in options for map builder.
|
||||
$bases = [
|
||||
'gray' => 'Gray',
|
||||
'blue-marble' => 'Blue marble',
|
||||
'night-electric' => 'Night Electric',
|
||||
'living' => 'Living Earth',
|
||||
];
|
||||
|
||||
$local_file = 'include/javascript/timezonepicker/images/gray-400.png';
|
||||
|
||||
// Dimensions must always be exact since the imagemap does not scale.
|
||||
$array_size = getimagesize($local_file);
|
||||
|
||||
$map_width = $array_size[0];
|
||||
$map_height = $array_size[1];
|
||||
|
||||
$timezones = timezone_picker_parse_files(
|
||||
$map_width,
|
||||
$map_height,
|
||||
'include/javascript/timezonepicker/tz_world.txt',
|
||||
'include/javascript/timezonepicker/tz_islands.txt'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$get_users = get_users();
|
||||
$users = [];
|
||||
if (empty($get_users) === false) {
|
||||
foreach ($get_users as $key => $value) {
|
||||
$users[$key] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
$users_div = '<div class="label_select"><p class="edit_user_labels">'.__('Users').'</p>';
|
||||
$users_div .= html_print_select(
|
||||
$users,
|
||||
'id_users[]',
|
||||
0,
|
||||
false,
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
'',
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
true
|
||||
).'</div>';
|
||||
echo '<form method="post" id="form_profiles" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_users&option=edit_users">';
|
||||
echo '<div class="user_edit_second_row white_box">';
|
||||
echo '<div class="" style="width:65%">'.$users_div.'</div>';
|
||||
echo '</div>';
|
||||
|
||||
// Language.
|
||||
$language_db = db_get_all_rows_sql('SELECT id_language, name FROM tlanguage');
|
||||
array_unshift($language_db, ['id_language' => 'default', 'name' => __('Default')]);
|
||||
$language_list = [];
|
||||
foreach ($language_db as $key => $value) {
|
||||
$language_list[$value['id_language']] = $value['name'];
|
||||
}
|
||||
|
||||
$language = '<div class="label_select"><p class="edit_user_labels">'.__('Language').'</p>';
|
||||
$language .= html_print_select(
|
||||
$language_list,
|
||||
'language',
|
||||
'',
|
||||
'',
|
||||
__('No change'),
|
||||
-1,
|
||||
true,
|
||||
false,
|
||||
false
|
||||
).'</div>';
|
||||
|
||||
// Pagination.
|
||||
$block_size = $config['global_block_size'];
|
||||
$size_pagination = '<div class="label_select_simple"><p class="edit_user_labels">'.__('Block size for pagination').'</p>';
|
||||
$size_pagination .= html_print_input_text('block_size', $block_size, '', 5, 5, true);
|
||||
$size_pagination .= html_print_checkbox_switch('block_size_change', 1, 1, true);
|
||||
$size_pagination .= '<span>'.__('No change').'</span>';
|
||||
$size_pagination .= '</div>';
|
||||
|
||||
// Home screen.
|
||||
$home_screen = '<div class="label_select"><p class="edit_user_labels">'.__('Home screen').ui_print_help_tip(__('User can customize the home page. By default, will display \'Agent Detail\'. Example: Select \'Other\' and type index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=1 to show agent detail view'), true).'</p>';
|
||||
$values = [
|
||||
'-1' => __('No change'),
|
||||
'Default' => __('Default'),
|
||||
'Visual console' => __('Visual console'),
|
||||
'Event list' => __('Event list'),
|
||||
'Group view' => __('Group view'),
|
||||
'Tactical view' => __('Tactical view'),
|
||||
'Alert detail' => __('Alert detail'),
|
||||
'Other' => __('Other'),
|
||||
'Dashboard' => __('Dashboard'),
|
||||
];
|
||||
|
||||
$home_screen .= html_print_select(
|
||||
$values,
|
||||
'section',
|
||||
'',
|
||||
'show_data_section();',
|
||||
'',
|
||||
-1,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
'',
|
||||
'',
|
||||
10
|
||||
).'</div>';
|
||||
|
||||
$dashboards = get_user_dashboards($config['id_user']);
|
||||
|
||||
$dashboards_aux = [];
|
||||
if ($dashboards === false) {
|
||||
$dashboards = ['None' => 'None'];
|
||||
} else {
|
||||
foreach ($dashboards as $key => $dashboard) {
|
||||
$dashboards_aux[$dashboard['id']] = $dashboard['name'];
|
||||
}
|
||||
}
|
||||
|
||||
$home_screen .= '<div id="show_db" style="display: none; width: 100%;">';
|
||||
$home_screen .= html_print_select($dashboards_aux, 'dashboard', '', '', '', '', true, false, false, '');
|
||||
$home_screen .= '</div>';
|
||||
|
||||
$layouts = visual_map_get_user_layouts($config['id_user'], true);
|
||||
$layouts_aux = [];
|
||||
if (empty($layouts) === true) {
|
||||
$layouts_aux = ['None' => 'None'];
|
||||
} else {
|
||||
foreach ($layouts as $layout) {
|
||||
$layouts_aux[$layout] = $layout;
|
||||
}
|
||||
}
|
||||
|
||||
$home_screen .= '<div id="show_vc" style="display: none; width: 100%;">';
|
||||
$home_screen .= html_print_select($layouts_aux, 'visual_console', '', '', '', '', true);
|
||||
$home_screen .= '</div>';
|
||||
$home_screen .= html_print_input_text('data_section', '', '', 60, 255, true, false);
|
||||
|
||||
|
||||
// Event filter.
|
||||
$user_groups = implode(',', array_keys((users_get_groups($config['id_user'], 'AR', true))));
|
||||
$event_list = db_get_all_rows_sql('SELECT id_filter, id_name AS name FROM tevent_filter WHERE id_group_filter IN ('.$user_groups.')');
|
||||
if (empty($event_list) === true) {
|
||||
$event_list = [];
|
||||
}
|
||||
|
||||
array_unshift($event_list, ['id_filter' => 'none', 'name' => __('None')]);
|
||||
|
||||
$event_filter = '<div class="label_select"><p class="edit_user_labels">'.__('Event filter').'</p>';
|
||||
$event_filter .= html_print_select(
|
||||
$event_list,
|
||||
'event_filter',
|
||||
'',
|
||||
'',
|
||||
__('No change'),
|
||||
-1,
|
||||
true,
|
||||
false,
|
||||
false
|
||||
).'</div>';
|
||||
|
||||
// Autorefresh.
|
||||
$autorefresh_list_out = [];
|
||||
if (is_metaconsole() === false || is_centralized() === true) {
|
||||
$autorefresh_list_out['operation/agentes/estado_agente'] = 'Agent detail';
|
||||
$autorefresh_list_out['operation/agentes/alerts_status'] = 'Alert detail';
|
||||
$autorefresh_list_out['enterprise/operation/cluster/cluster'] = 'Cluster view';
|
||||
$autorefresh_list_out['operation/gis_maps/render_view'] = 'Gis Map';
|
||||
$autorefresh_list_out['operation/reporting/graph_viewer'] = 'Graph Viewer';
|
||||
$autorefresh_list_out['operation/snmpconsole/snmp_view'] = 'SNMP console';
|
||||
|
||||
if (enterprise_installed()) {
|
||||
$autorefresh_list_out['general/sap_view'] = 'SAP view';
|
||||
}
|
||||
}
|
||||
|
||||
$autorefresh_list_out['operation/agentes/tactical'] = 'Tactical view';
|
||||
$autorefresh_list_out['operation/agentes/group_view'] = 'Group view';
|
||||
$autorefresh_list_out['operation/agentes/status_monitor'] = 'Monitor detail';
|
||||
$autorefresh_list_out['enterprise/operation/services/services'] = 'Services';
|
||||
$autorefresh_list_out['operation/dashboard/dashboard'] = 'Dashboard';
|
||||
|
||||
$autorefresh_list_out['operation/agentes/pandora_networkmap'] = 'Network map';
|
||||
$autorefresh_list_out['operation/visual_console/render_view'] = 'Visual console';
|
||||
$autorefresh_list_out['operation/events/events'] = 'Events';
|
||||
|
||||
$autorefresh_show = '<p class="edit_user_labels">'._('Autorefresh').ui_print_help_tip(
|
||||
__('This will activate autorefresh in selected pages'),
|
||||
true
|
||||
).'</p>';
|
||||
$select_out = html_print_select(
|
||||
$autorefresh_list_out,
|
||||
'autorefresh_list_out[]',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
'',
|
||||
false,
|
||||
'width:100%;min-height: 150px;'
|
||||
);
|
||||
$arrows = ' ';
|
||||
$autorefresh_list = [];
|
||||
$autorefresh_list['-1'] = __('No change');
|
||||
$autorefresh_list[] = __('None');
|
||||
|
||||
$select_in = html_print_select(
|
||||
$autorefresh_list,
|
||||
'autorefresh_list[]',
|
||||
'-1',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
'',
|
||||
false,
|
||||
'width:100%;min-height: 150px;'
|
||||
);
|
||||
|
||||
$table_ichanges = '<div class="autorefresh_select">
|
||||
<div class="autorefresh_select_list_out">
|
||||
<p class="autorefresh_select_text">'.__('Full list of pages').': </p>
|
||||
<div>'.$select_out.'</div>
|
||||
</div>
|
||||
<div class="autorefresh_select_arrows" style="display:grid">
|
||||
<a href="javascript:">'.html_print_image(
|
||||
'images/darrowright_green.png',
|
||||
true,
|
||||
[
|
||||
'id' => 'right_autorefreshlist',
|
||||
'alt' => __('Push selected pages into autorefresh list'),
|
||||
'title' => __('Push selected pages into autorefresh list'),
|
||||
]
|
||||
).'</a>
|
||||
|
||||
<a href="javascript:">'.html_print_image(
|
||||
'images/darrowleft_green.png',
|
||||
true,
|
||||
[
|
||||
'id' => 'left_autorefreshlist',
|
||||
'alt' => __('Pop selected pages out of autorefresh list'),
|
||||
'title' => __('Pop selected pages out of autorefresh list'),
|
||||
]
|
||||
).'</a>
|
||||
</div>
|
||||
<div class="autorefresh_select_list">
|
||||
<p class="autorefresh_select_text">'.__('List of pages with autorefresh').': </p>
|
||||
<div>'.$select_in.'</div>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
$autorefresh_show .= $table_ichanges;
|
||||
|
||||
// Time autorefresh.
|
||||
$times = get_refresh_time_array();
|
||||
$time_autorefresh = '<div class="label_select"><p class="edit_user_labels">'.__('Time autorefresh');
|
||||
$time_autorefresh .= ui_print_help_tip(
|
||||
__('Interval of autorefresh of the elements, by default they are 30 seconds, needing to enable the autorefresh first'),
|
||||
true
|
||||
).'</p>';
|
||||
$time_autorefresh .= html_print_select(
|
||||
$times,
|
||||
'time_autorefresh',
|
||||
'',
|
||||
'',
|
||||
__('No change'),
|
||||
'-1',
|
||||
true,
|
||||
false,
|
||||
false
|
||||
).'</div>';
|
||||
|
||||
$timezone = '<div class="label_select"><p class="edit_user_labels">'.__('Timezone').ui_print_help_tip(__('The timezone must be that of the associated server.'), true).'</p>';
|
||||
$timezone .= html_print_timezone_select('timezone', '-1', __('No change'), '-1').'</div>';
|
||||
$timezone_map = '';
|
||||
|
||||
if (is_metaconsole() === false) {
|
||||
foreach ($timezones as $timezone_name => $tz) {
|
||||
if ($timezone_name == 'America/Montreal') {
|
||||
$timezone_name = 'America/Toronto';
|
||||
} else if ($timezone_name == 'Asia/Chongqing') {
|
||||
$timezone_name = 'Asia/Shanghai';
|
||||
}
|
||||
|
||||
$area_data_timezone_polys .= '';
|
||||
foreach ($tz['polys'] as $coords) {
|
||||
$area_data_timezone_polys .= '<area data-timezone="'.$timezone_name.'" data-country="'.$tz['country'].'" data-pin="'.implode(',', $tz['pin']).'" data-offset="'.$tz['offset'].'" shape="poly" coords="'.implode(',', $coords).'" />';
|
||||
}
|
||||
|
||||
$area_data_timezone_rects .= '';
|
||||
foreach ($tz['rects'] as $coords) {
|
||||
$area_data_timezone_rects .= '<area data-timezone="'.$timezone_name.'" data-country="'.$tz['country'].'" data-pin="'.implode(',', $tz['pin']).'" data-offset="'.$tz['offset'].'" shape="rect" coords="'.implode(',', $coords).'" />';
|
||||
}
|
||||
}
|
||||
|
||||
$timezone_map = '<div id="timezone-picker" style="width:0px">
|
||||
<img id="timezone-image" src="'.$local_file.'" width="'.$map_width.'" height="'.$map_height.'" usemap="#timezone-map" />
|
||||
<img class="timezone-pin pdd_t_4px" src="include/javascript/timezonepicker/images/pin.png" />
|
||||
<map name="timezone-map" id="timezone-map">'.$area_data_timezone_polys.$area_data_timezone_rects.'</map>
|
||||
</div>';
|
||||
}
|
||||
|
||||
// Status (Disable / Enable).
|
||||
$status = '</br>';
|
||||
$status .= '<div class="label_select"><p class="edit_user_labels">'.__('Status').'</p>';
|
||||
|
||||
$table = new StdClass();
|
||||
$table->width = '100%';
|
||||
$table->class = 'databox filters';
|
||||
|
||||
$table->data[0][0] = __('No change');
|
||||
$table->data[0][0] .= html_print_radio_button_extended(
|
||||
'disabled',
|
||||
-1,
|
||||
'',
|
||||
-1,
|
||||
false,
|
||||
'',
|
||||
'class="mrgn_right_40px"',
|
||||
true
|
||||
);
|
||||
$table->data[0][0] .= __('Disable');
|
||||
$table->data[0][0] .= html_print_radio_button_extended(
|
||||
'disabled',
|
||||
1,
|
||||
'',
|
||||
'',
|
||||
false,
|
||||
'',
|
||||
'class="mrgn_right_40px"',
|
||||
true
|
||||
);
|
||||
$table->data[0][0] .= __('Enable');
|
||||
$table->data[0][0] .= html_print_radio_button_extended(
|
||||
'disabled',
|
||||
0,
|
||||
'',
|
||||
'',
|
||||
false,
|
||||
'',
|
||||
'class="mrgn_right_40px"',
|
||||
true
|
||||
);
|
||||
|
||||
$status .= html_print_table($table, true);
|
||||
|
||||
echo '<div id="users_options" class="user_edit_second_row white_box" style="display: none">';
|
||||
echo sprintf(
|
||||
'<div class="edit_user_options">%s %s %s %s %s %s %s %s %s %s</div>',
|
||||
$language,
|
||||
$size_pagination,
|
||||
$skin,
|
||||
$home_screen,
|
||||
$event_filter,
|
||||
$autorefresh_show,
|
||||
$time_autorefresh,
|
||||
$timezone,
|
||||
$timezone_map,
|
||||
$status
|
||||
);
|
||||
echo '</div>';
|
||||
|
||||
attachActionButton('edit_users', 'update', '100%');
|
||||
|
||||
echo '</form>';
|
||||
|
||||
if (is_metaconsole() === false) {
|
||||
// Include OpenLayers and timezone user map library.
|
||||
echo '<script type="text/javascript" src="'.ui_get_full_url('include/javascript/timezonepicker/lib/jquery.timezone-picker.min.js').'"></script>'."\n\t";
|
||||
echo '<script type="text/javascript" src="'.ui_get_full_url('include/javascript/timezonepicker/lib/jquery.maphilight.min.js').'"></script>'."\n\t";
|
||||
// Closes no meta condition.
|
||||
?>
|
||||
|
||||
<style>
|
||||
/* Styles for timezone map */
|
||||
#timezone-picker div.timezone-picker {
|
||||
margin: 0 auto;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script language="javascript" type="text/javascript">
|
||||
$(document).ready (function () {
|
||||
// Set up the picker to update target timezone and country select lists.
|
||||
$('#timezone-image').timezonePicker({
|
||||
target: '#timezone',
|
||||
});
|
||||
|
||||
// Optionally an auto-detect button to trigger JavaScript geolocation.
|
||||
$('#timezone-detect').click(function() {
|
||||
$('#timezone-image').timezonePicker('detectLocation');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
} else {
|
||||
close_meta_frame();
|
||||
}
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
show_data_section();
|
||||
$('#id_users').change(function() {
|
||||
const users = $("#id_users option:selected").length;
|
||||
if (users === 0) {
|
||||
$('#users_options').hide();
|
||||
} else {
|
||||
$('#users_options').show();
|
||||
}
|
||||
});
|
||||
|
||||
$("#right_autorefreshlist").click (function () {
|
||||
jQuery.each($("select[name='autorefresh_list_out[]'] option:selected"), function (key, value) {
|
||||
imodule_name = $(value).html();
|
||||
if (imodule_name != <?php echo "'".__('None')."'"; ?> || imodule_name != <?php echo "'".__('No change')."'"; ?>) {
|
||||
id_imodule = $(value).attr('value');
|
||||
$("select[name='autorefresh_list[]']").append($("<option></option>").val(id_imodule).html('<i>' + imodule_name + '</i>'));
|
||||
// $("select[name='autorefresh_list[]']").val(id_imodule).prop("selected", "selected");
|
||||
$("#autorefresh_list_out").find("option[value='" + id_imodule + "']").remove();
|
||||
$("#autorefresh_list").find("option[value='-1']").remove();
|
||||
$("#autorefresh_list").find("option[value='0']").remove();
|
||||
if($("#autorefresh_list_out option").length == 0) {
|
||||
$("select[name='autorefresh_list_out[]']").append($("<option></option>").val('0').html('<i><?php echo __('None'); ?></i>'));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('#autorefresh_list option').prop('selected', true);
|
||||
});
|
||||
|
||||
$("#left_autorefreshlist").click (function () {
|
||||
jQuery.each($("select[name='autorefresh_list[]'] option:selected"), function (key, value) {
|
||||
imodule_name = $(value).html();
|
||||
if (imodule_name != <?php echo "'".__('None')."'"; ?> || imodule_name != <?php echo "'".__('No change')."'"; ?>) {
|
||||
id_imodule = $(value).attr('value');
|
||||
$("#autorefresh_list").find("option[value='" + id_imodule + "']").remove();
|
||||
$("#autorefresh_list_out").find("option[value='0']").remove();
|
||||
$("select[name='autorefresh_list_out[]']").append($("<option><option>").val(id_imodule).html('<i>' + imodule_name + '</i>'));
|
||||
$("#autorefresh_list_out option").last().remove();
|
||||
if($("#autorefresh_list option").length == 0) {
|
||||
$("select[name='autorefresh_list[]']").append($("<option></option>").val('-1').html('<i><?php echo __('No change'); ?></i>'));
|
||||
$("select[name='autorefresh_list[]']").append($("<option></option>").val('0').html('<i><?php echo __('None'); ?></i>'));
|
||||
$('#autorefresh_list').val('-1').prop('selected', true);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function show_data_section () {
|
||||
section = $("#section").val();
|
||||
|
||||
switch (section) {
|
||||
case <?php echo "'".'Dashboard'."'"; ?>:
|
||||
$("#text-data_section").css("display", "none");
|
||||
$("#dashboard").css("display", "");
|
||||
$("#visual_console").css("display", "none");
|
||||
$("#show_vc").css("display", "none");
|
||||
$("#show_db").css("display", "inline-grid");
|
||||
|
||||
break;
|
||||
case <?php echo "'".'Visual console'."'"; ?>:
|
||||
$("#text-data_section").css("display", "none");
|
||||
$("#dashboard").css("display", "none");
|
||||
$("#visual_console").css("display", "");
|
||||
$("#show_vc").css("display", "inline-grid");
|
||||
$("#show_db").css("display", "none");
|
||||
|
||||
break;
|
||||
case <?php echo "'".'Event list'."'"; ?>:
|
||||
$("#text-data_section").css("display", "none");
|
||||
$("#dashboard").css("display", "none");
|
||||
$("#visual_console").css("display", "none");
|
||||
$("#show_vc").css("display", "none");
|
||||
$("#show_db").css("display", "none");
|
||||
|
||||
break;
|
||||
case <?php echo "'".'Group view'."'"; ?>:
|
||||
$("#text-data_section").css("display", "none");
|
||||
$("#dashboard").css("display", "none");
|
||||
$("#visual_console").css("display", "none");
|
||||
$("#show_vc").css("display", "none");
|
||||
$("#show_db").css("display", "none");
|
||||
|
||||
break;
|
||||
case <?php echo "'".'Tactical view'."'"; ?>:
|
||||
$("#text-data_section").css("display", "none");
|
||||
$("#dashboard").css("display", "none");
|
||||
$("#visual_console").css("display", "none");
|
||||
$("#show_vc").css("display", "none");
|
||||
$("#show_db").css("display", "none");
|
||||
|
||||
break;
|
||||
case <?php echo "'".'Alert detail'."'"; ?>:
|
||||
$("#text-data_section").css("display", "none");
|
||||
$("#dashboard").css("display", "none");
|
||||
$("#visual_console").css("display", "none");
|
||||
$("#show_vc").css("display", "none");
|
||||
$("#show_db").css("display", "none");
|
||||
|
||||
break;
|
||||
case <?php echo "'".'Other'."'"; ?>:
|
||||
$("#text-data_section").css("display", "");
|
||||
$("#dashboard").css("display", "none");
|
||||
$("#visual_console").css("display", "none");
|
||||
$("#show_vc").css("display", "none");
|
||||
$("#show_db").css("display", "none");
|
||||
|
||||
break;
|
||||
default:
|
||||
$("#text-data_section").css("display", "none");
|
||||
$("#dashboard").css("display", "none");
|
||||
$("#visual_console").css("display", "none");
|
||||
$("#show_vc").css("display", "none");
|
||||
$("#show_db").css("display", "none");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
</script>
|
@ -70,10 +70,16 @@ $options_agents = [
|
||||
];
|
||||
|
||||
if (check_acl($config['id_user'], 0, 'UM')) {
|
||||
$options_users = [
|
||||
'add_profiles' => __('Bulk profile add'),
|
||||
'delete_profiles' => __('Bulk profile delete'),
|
||||
];
|
||||
if (is_metaconsole() === false) {
|
||||
$options_users = [
|
||||
'add_profiles' => __('Bulk profile add'),
|
||||
'delete_profiles' => __('Bulk profile delete'),
|
||||
];
|
||||
}
|
||||
|
||||
if (users_is_admin() === true) {
|
||||
$options_users['edit_users'] = __('Edit users in bulk');
|
||||
}
|
||||
} else {
|
||||
$options_users = [];
|
||||
}
|
||||
@ -479,6 +485,10 @@ switch ($option) {
|
||||
include_once $config['homedir'].'/godmode/massive/massive_edit_plugins.php';
|
||||
break;
|
||||
|
||||
case 'edit_users':
|
||||
include_once $config['homedir'].'/godmode/massive/massive_edit_users.php';
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!enterprise_hook('massive_operations', [$option])) {
|
||||
include_once $config['homedir'].'/godmode/massive/massive_config.php';
|
||||
|
@ -150,7 +150,13 @@ if (isset($_GET['server'])) {
|
||||
if ($server_type === SERVER_TYPE_ENTERPRISE_SATELLITE) {
|
||||
$buttons['agent_editor'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="index.php?sec=gservers&sec2=godmode/servers/modificar_server&server_remote='.$id_server.'&ext='.$ext.'&tab=agent_editor&pure='.$pure.'">'.html_print_image('images/agent.png', true, ['title' => __('Advanced editor')]).'</a>',
|
||||
'text' => '<a href="index.php?sec=gservers&sec2=godmode/servers/modificar_server&server_remote='.$id_server.'&ext='.$ext.'&tab=agent_editor&pure='.$pure.'">'.html_print_image('images/agent.png', true, ['title' => __('Manage agents')]).'</a>',
|
||||
|
||||
];
|
||||
|
||||
$buttons['collections'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="index.php?sec=gservers&sec2=godmode/servers/modificar_server&server_remote='.$id_server.'&ext='.$ext.'&tab=collections&pure='.$pure.'">'.html_print_image('images/collection.png', true, ['title' => __('Collections')]).'</a>',
|
||||
|
||||
];
|
||||
}
|
||||
@ -173,6 +179,8 @@ if (isset($_GET['server'])) {
|
||||
}
|
||||
} else if ($tab === 'agent_editor' && $server_type === SERVER_TYPE_ENTERPRISE_SATELLITE) {
|
||||
$advanced_editor = 'agent_editor';
|
||||
} else if ($tab === 'collections' && $server_type === SERVER_TYPE_ENTERPRISE_SATELLITE) {
|
||||
$advanced_editor = 'collections';
|
||||
}
|
||||
|
||||
enterprise_include('godmode/servers/server_disk_conf_editor.php');
|
||||
|
@ -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 '<fieldset class="full-column">';
|
||||
@ -725,6 +747,12 @@ echo '<fieldset>';
|
||||
html_print_table($table_other);
|
||||
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.'">';
|
||||
html_print_input_hidden('update_config', 1);
|
||||
html_print_div(
|
||||
[
|
||||
|
@ -196,6 +196,21 @@ if (is_ajax() === true) {
|
||||
);
|
||||
$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.
|
||||
// Set default value.
|
||||
set_unless_defined($config['secondary_ldap_enabled'], false);
|
||||
|
@ -76,6 +76,7 @@ if ($generate_trap) {
|
||||
);
|
||||
}
|
||||
|
||||
$table = new stdClass();
|
||||
$traps_generator = '<form method="POST" action="index.php?sec=snmpconsole&sec2=godmode/snmpconsole/snmp_trap_generator">';
|
||||
$table->width = '100%';
|
||||
$table->class = 'databox filters';
|
||||
|
@ -442,6 +442,13 @@ if ($create_user) {
|
||||
$password_new = '';
|
||||
$password_confirm = '';
|
||||
$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 {
|
||||
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);
|
||||
@ -509,6 +516,10 @@ if ($create_user) {
|
||||
if (!empty($json_profile)) {
|
||||
$json_profile = json_decode(io_safe_output($json_profile), true);
|
||||
foreach ($json_profile as $key => $profile) {
|
||||
if (is_array($profile) === false) {
|
||||
$profile = json_decode($profile, true);
|
||||
}
|
||||
|
||||
if (!empty($profile)) {
|
||||
$group2 = $profile['group'];
|
||||
$profile2 = $profile['profile'];
|
||||
@ -532,6 +543,14 @@ if ($create_user) {
|
||||
|
||||
$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(
|
||||
$result_profile,
|
||||
__('Profile added successfully'),
|
||||
@ -824,6 +843,10 @@ if ($add_profile && empty($json_profile)) {
|
||||
'Profile: '.$profile2.' Group: '.$group2.' Tags: '.$tags
|
||||
);
|
||||
$return = profile_create_user_profile($id2, $profile2, $group2, false, $tags, $no_hierarchy);
|
||||
if ($return === false) {
|
||||
$is_err = true;
|
||||
}
|
||||
|
||||
ui_print_result_message(
|
||||
$return,
|
||||
__('Profile added successfully'),
|
||||
@ -1492,12 +1515,12 @@ if ($config['admin_can_add_user']) {
|
||||
|
||||
echo '</div>';
|
||||
|
||||
html_print_input_hidden('json_profile', '');
|
||||
html_print_input_hidden('json_profile', $json_profile);
|
||||
|
||||
echo '</form>';
|
||||
|
||||
|
||||
profile_print_profile_table($id);
|
||||
profile_print_profile_table($id, io_safe_output($json_profile));
|
||||
|
||||
echo '<br />';
|
||||
|
||||
@ -1619,13 +1642,18 @@ $(document).ready (function () {
|
||||
switch_ehorus_conf();
|
||||
});
|
||||
$('#checkbox-ehorus_user_level_enabled').trigger('change');
|
||||
|
||||
var img_delete = '<?php echo $delete_image; ?>';
|
||||
var id_user = '<?php echo io_safe_output($id); ?>';
|
||||
var is_metaconsole = '<?php echo $meta; ?>';
|
||||
var user_is_global_admin = '<?php echo users_is_admin($id); ?>';
|
||||
var is_err = '<?php echo $is_err; ?>';
|
||||
var data = [];
|
||||
var aux = 0;
|
||||
|
||||
if(json_profile.val() != '') {
|
||||
var data = JSON.parse(json_profile.val());
|
||||
}
|
||||
|
||||
$('input:image[name="add"]').click(function (e) {
|
||||
e.preventDefault();
|
||||
var profile = $('#assign_profile').val();
|
||||
@ -1647,10 +1675,14 @@ $(document).ready (function () {
|
||||
return;
|
||||
}
|
||||
|
||||
if (id_user === '') {
|
||||
if (id_user == '' || is_err == 1) {
|
||||
let new_json = `{"profile":${profile},"group":${group},"tags":[${tags}],"hierarchy":${hierarchy}}`;
|
||||
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(
|
||||
`<tr>
|
||||
<td>${profile_text}</td>
|
||||
@ -1660,6 +1692,10 @@ $(document).ready (function () {
|
||||
<td>${img_delete}</td>
|
||||
</tr>`
|
||||
);
|
||||
|
||||
getGroupIcon(group, $(`#img_group_${aux}`));
|
||||
aux++;
|
||||
|
||||
} else {
|
||||
this.form.submit();
|
||||
}
|
||||
@ -1941,7 +1977,7 @@ function show_double_auth_activation () {
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
title: "<?php echo __('Double autentication activation'); ?>",
|
||||
title: "<?php echo __('Double authentication activation'); ?>",
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
@ -2019,7 +2055,7 @@ function show_double_auth_deactivation () {
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
title: "<?php echo __('Double autentication activation'); ?>",
|
||||
title: "<?php echo __('Double authentication activation'); ?>",
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
|
@ -509,6 +509,7 @@ class HostDevices extends Wizard
|
||||
$snmp_privacy_pass = get_parameter('snmp_privacy_pass', null);
|
||||
$snmp_auth_method = get_parameter('snmp_auth_method', null);
|
||||
$snmp_security_level = get_parameter('snmp_security_level', null);
|
||||
$snmp_skip_non_enabled_ifs = get_parameter_switch('snmp_skip_non_enabled_ifs');
|
||||
$auth_strings = get_parameter('auth_strings', []);
|
||||
|
||||
if ($snmp_version == 3) {
|
||||
@ -556,6 +557,7 @@ class HostDevices extends Wizard
|
||||
$this->task['snmp_privacy_pass'] = $snmp_privacy_pass;
|
||||
$this->task['snmp_auth_method'] = $snmp_auth_method;
|
||||
$this->task['snmp_security_level'] = $snmp_security_level;
|
||||
$this->task['snmp_skip_non_enabled_ifs'] = $snmp_skip_non_enabled_ifs;
|
||||
$this->task['auth_strings'] = '';
|
||||
if (is_array($auth_strings) === true) {
|
||||
$this->task['auth_strings'] = join(
|
||||
@ -1215,6 +1217,24 @@ class HostDevices extends Wizard
|
||||
],
|
||||
];
|
||||
|
||||
$form['inputs'][] = [
|
||||
'hidden' => 1,
|
||||
'block_id' => 'snmp_options_skip_non_enabled_ifs',
|
||||
'class' => 'indented',
|
||||
'block_content' => [
|
||||
[
|
||||
'label' => __('Skip non-enabled interfaces'),
|
||||
'arguments' => [
|
||||
'name' => 'snmp_skip_non_enabled_ifs',
|
||||
'type' => 'switch',
|
||||
'value' => (isset($this->task['snmp_enabled']) === true) ? $this->task['snmp_skip_non_enabled_ifs'] : 1,
|
||||
'size' => 25,
|
||||
'return' => true,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// SNMP Options pack v1.
|
||||
$form['inputs'][] = [
|
||||
'hidden' => 1,
|
||||
@ -1487,6 +1507,7 @@ class HostDevices extends Wizard
|
||||
|
||||
function SNMPExtraShow(target) {
|
||||
$("#snmp_options_basic").hide();
|
||||
$("#snmp_options_skip_non_enabled_ifs").hide();
|
||||
$("#snmp_options_v3").hide();
|
||||
if (document.getElementsByName("snmp_enabled")[0].checked) {
|
||||
$("#snmp_extra").show();
|
||||
@ -1494,6 +1515,7 @@ class HostDevices extends Wizard
|
||||
$("#snmp_options_v3").show();
|
||||
} else {
|
||||
$("#snmp_options_basic").show();
|
||||
$("#snmp_options_skip_non_enabled_ifs").show();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1519,6 +1541,7 @@ class HostDevices extends Wizard
|
||||
// Hide unusable sections
|
||||
$("#snmp_extra").hide();
|
||||
$("#snmp_options_basic").hide();
|
||||
$("#snmp_options_skip_non_enabled_ifs").hide();
|
||||
$("#snmp_options_v3").hide();
|
||||
|
||||
// Disable snmp dependant checks
|
||||
|
BIN
pandora_console/images/widgets/GroupedMeterGraphs.png
Normal file
BIN
pandora_console/images/widgets/GroupedMeterGraphs.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
$token_name = get_parameter('token_name', 0);
|
||||
$no_boolean = (bool) get_parameter('no_boolean', 0);
|
||||
|
||||
$value_token = db_get_value(
|
||||
'value',
|
||||
@ -9,4 +10,8 @@ $value_token = db_get_value(
|
||||
$token_name
|
||||
);
|
||||
|
||||
echo (bool) $value_token;
|
||||
if ($no_boolean === true) {
|
||||
echo json_encode(io_safe_output($value_token));
|
||||
} else {
|
||||
echo (bool) $value_token;
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ $node_id = (int) get_parameter('node_id', 0);
|
||||
|
||||
if ($get_comments === true) {
|
||||
$event = get_parameter('event', false);
|
||||
$event_rep = get_parameter('event_rep', false);
|
||||
$event_rep = (int) get_parameter('event_rep', 0);
|
||||
if ($event === false) {
|
||||
return __('Failed to retrieve comments');
|
||||
}
|
||||
@ -98,7 +98,7 @@ if ($get_comments === true) {
|
||||
$eventsGrouped = [];
|
||||
// Consider if the event is grouped.
|
||||
$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).
|
||||
$whereGrouped = sprintf(
|
||||
'`evento` = "%s"',
|
||||
@ -119,6 +119,11 @@ if ($get_comments === true) {
|
||||
(int) $event['id_agentmodule']
|
||||
);
|
||||
}
|
||||
} else if ($event_rep === EVENT_GROUP_REP_EXTRAIDS) {
|
||||
$whereGrouped = sprintf(
|
||||
'`id_extra` = "%s"',
|
||||
$event['id_extra']
|
||||
);
|
||||
} else {
|
||||
$whereGrouped = sprintf('`id_evento` = %d', $event['id_evento']);
|
||||
}
|
||||
@ -175,7 +180,7 @@ if ($delete_event === true) {
|
||||
$filter = get_parameter('filter', []);
|
||||
$id_evento = (int) get_parameter('id_evento', 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 {
|
||||
if (is_metaconsole() === true
|
||||
@ -228,7 +233,7 @@ if ($validate_event === true) {
|
||||
$filter = get_parameter('filter', []);
|
||||
$id_evento = (int) get_parameter('id_evento', 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 {
|
||||
if (is_metaconsole() === true
|
||||
@ -240,7 +245,7 @@ if ($validate_event === true) {
|
||||
|
||||
if ($event_rep === 0) {
|
||||
// Disable group by when there're result is unique.
|
||||
$filter['group_rep'] = 0;
|
||||
$filter['group_rep'] = EVENT_GROUP_REP_ALL;
|
||||
}
|
||||
|
||||
// Check acl.
|
||||
@ -285,7 +290,7 @@ if ($in_process_event === true) {
|
||||
$filter = get_parameter('filter', []);
|
||||
$id_evento = (int) get_parameter('id_evento', 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 {
|
||||
if (is_metaconsole() === true
|
||||
@ -297,7 +302,7 @@ if ($in_process_event === true) {
|
||||
|
||||
if ($event_rep === 0) {
|
||||
// Disable group by when there're result is unique.
|
||||
$filter['group_rep'] = 0;
|
||||
$filter['group_rep'] = EVENT_GROUP_REP_ALL;
|
||||
}
|
||||
|
||||
// Check acl.
|
||||
@ -360,10 +365,11 @@ if ($save_event_filter) {
|
||||
);
|
||||
$values['filter_only_alert'] = get_parameter('filter_only_alert');
|
||||
$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['date_from'] = get_parameter('date_from');
|
||||
$values['date_from'] = get_parameter('date_from', null);
|
||||
$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['source'] = get_parameter('source');
|
||||
$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['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['date_from'] = get_parameter('date_from');
|
||||
$values['time_from'] = get_parameter('time_from');
|
||||
@ -464,13 +471,13 @@ if ($get_filter_values) {
|
||||
$event_filter = [
|
||||
'status' => EVENT_NO_VALIDATED,
|
||||
'event_view_hr' => $config['event_view_hr'],
|
||||
'group_rep' => 1,
|
||||
'tag_with' => [],
|
||||
'tag_without' => [],
|
||||
'history' => false,
|
||||
'module_search' => '',
|
||||
'filter_only_alert' => '-1',
|
||||
'search_secondary_groups' => 0,
|
||||
'search_recursive_groups' => 0,
|
||||
'user_comment' => '',
|
||||
'id_extra' => '',
|
||||
'id_user_ack' => '',
|
||||
@ -480,7 +487,7 @@ if ($get_filter_values) {
|
||||
'time_to' => '',
|
||||
'severity' => '',
|
||||
'event_type' => '',
|
||||
'group_rep' => 0,
|
||||
'group_rep' => EVENT_GROUP_REP_ALL,
|
||||
'id_group' => 0,
|
||||
'id_group_filter' => 0,
|
||||
'group_name' => 'All',
|
||||
@ -657,6 +664,8 @@ function load_form_filter() {
|
||||
$("#filter_only_alert").val(val);
|
||||
if (i == 'search_secondary_groups')
|
||||
$("#checkbox-search_secondary_groups").val(val);
|
||||
if (i == 'search_recursive_groups')
|
||||
$("#checkbox-search_recursive_groups").val(val);
|
||||
if (i == 'id_group_filter')
|
||||
$("#id_group_filter").val(val);
|
||||
if (i == 'source')
|
||||
@ -908,6 +917,7 @@ function save_new_filter() {
|
||||
"tag_without": Base64.decode($("#hidden-tag_without").val()),
|
||||
"filter_only_alert" : $("#filter_only_alert").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(),
|
||||
"date_from": $("#text-date_from").val(),
|
||||
"time_from": $("#text-time_from").val(),
|
||||
@ -984,6 +994,7 @@ function save_update_filter() {
|
||||
"tag_without" : Base64.decode($("#hidden-tag_without").val()),
|
||||
"filter_only_alert" : $("#filter_only_alert").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(),
|
||||
"date_from": $("#text-date_from").val(),
|
||||
"time_from": $("#text-time_from").val(),
|
||||
@ -2419,11 +2430,12 @@ if ($get_events_fired) {
|
||||
'id_agent_module' => 0,
|
||||
'pagination' => 0,
|
||||
'id_user_ack' => 0,
|
||||
'group_rep' => 0,
|
||||
'group_rep' => EVENT_GROUP_REP_ALL,
|
||||
'tag_with' => [],
|
||||
'tag_without' => [],
|
||||
'filter_only_alert' => -1,
|
||||
'search_secondary_groups' => 0,
|
||||
'search_recursive_groups' => 0,
|
||||
'source' => '',
|
||||
'id_extra' => '',
|
||||
'user_comment' => '',
|
||||
|
@ -78,6 +78,7 @@ if (is_ajax() === true) {
|
||||
0 => __('Group agents'),
|
||||
1 => __('Group modules by tag'),
|
||||
2 => __('Group modules by module group'),
|
||||
3 => __('Group modules by agents'),
|
||||
],
|
||||
'type',
|
||||
$type,
|
||||
@ -203,6 +204,10 @@ if (is_ajax() === true) {
|
||||
'5'
|
||||
);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// Empty.
|
||||
break;
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
@ -212,6 +217,7 @@ if (is_ajax() === true) {
|
||||
enterprise_include_once('include/functions_agents.php');
|
||||
$id = get_parameter('id', 0);
|
||||
switch ($type) {
|
||||
case 3:
|
||||
case 2:
|
||||
$data = db_get_row('tagente_modulo', 'id_agente_modulo', $id);
|
||||
|
||||
|
@ -37,6 +37,7 @@ $ajax = true;
|
||||
$render_map = (bool) get_parameter('render_map', false);
|
||||
$graph_javascript = (bool) get_parameter('graph_javascript', false);
|
||||
$force_remote_check = (bool) get_parameter('force_remote_check', false);
|
||||
$update_maintanance_mode = (bool) get_parameter('update_maintanance_mode', false);
|
||||
$load_css_cv = (bool) get_parameter('load_css_cv', false);
|
||||
|
||||
if ($render_map) {
|
||||
@ -99,3 +100,29 @@ if ($load_css_cv === true) {
|
||||
echo $output;
|
||||
return;
|
||||
}
|
||||
|
||||
if ($update_maintanance_mode === true) {
|
||||
$idVisualConsole = (int) get_parameter('idVisualConsole', 0);
|
||||
$mode = (bool) get_parameter('mode', false);
|
||||
|
||||
$values = [];
|
||||
if ($mode === true) {
|
||||
$values['maintenance_mode'] = json_encode(
|
||||
[
|
||||
'user' => $config['id_user'],
|
||||
'timestamp' => time(),
|
||||
]
|
||||
);
|
||||
} else {
|
||||
$values['maintenance_mode'] = null;
|
||||
}
|
||||
|
||||
$result = db_process_sql_update(
|
||||
'tlayout',
|
||||
$values,
|
||||
['id' => $idVisualConsole]
|
||||
);
|
||||
|
||||
echo json_encode(['result' => $result]);
|
||||
return;
|
||||
}
|
||||
|
@ -1,22 +1,38 @@
|
||||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2021 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 Lesser General Public License
|
||||
// as published by the Free Software Foundation; 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.
|
||||
/**
|
||||
* MySQL Authentication functions.
|
||||
*
|
||||
* @category Functions.
|
||||
* @package Pandora FMS
|
||||
* @subpackage Login.
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* 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
|
||||
*/
|
||||
|
||||
if (!isset($config)) {
|
||||
if (isset($config) === false) {
|
||||
die(
|
||||
'
|
||||
<!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_delete_user'] = true;
|
||||
$config['admin_can_disable_user'] = false;
|
||||
// currently not implemented
|
||||
// Currently not implemented.
|
||||
$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
|
||||
if (is_user($login)) {
|
||||
if (!user_can_login($login)) {
|
||||
if (!user_can_login($login) && $api === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -544,7 +560,7 @@ function get_user_fullname($user)
|
||||
/**
|
||||
* Gets the users email
|
||||
*
|
||||
* @param mixed User id.
|
||||
* @param mixed $user User id.
|
||||
*
|
||||
* @return string The users email address
|
||||
*/
|
||||
@ -557,14 +573,14 @@ function get_user_email($user)
|
||||
/**
|
||||
* Gets a Users info
|
||||
*
|
||||
* @param mixed User id
|
||||
* @param mixed $user User id.
|
||||
*
|
||||
* @return mixed An array of users
|
||||
*/
|
||||
function get_user_info($user)
|
||||
{
|
||||
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];
|
||||
} else {
|
||||
$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
|
||||
* 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
|
||||
*/
|
||||
function get_users($order='fullname', $filter=false, $fields=false)
|
||||
{
|
||||
if (is_array($order)) {
|
||||
if (is_array($order) === true) {
|
||||
$filter['order'] = $order['field'].' '.$order['order'];
|
||||
} else {
|
||||
switch ($order) {
|
||||
case 'registered':
|
||||
case 'last_connect':
|
||||
case 'fullname':
|
||||
break;
|
||||
|
||||
default:
|
||||
$order = 'fullname';
|
||||
break;
|
||||
if ($order !== 'registered' || $order !== 'last_connect' || $order !== 'fullname') {
|
||||
$order = 'fullname';
|
||||
}
|
||||
|
||||
$filter['order'] = $order.' ASC';
|
||||
@ -618,9 +629,11 @@ function get_users($order='fullname', $filter=false, $fields=false)
|
||||
/**
|
||||
* 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(
|
||||
'tusuario',
|
||||
@ -633,6 +646,10 @@ function process_user_contact($id_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
|
||||
*/
|
||||
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['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
|
||||
*
|
||||
* @param string $id_user Id User.
|
||||
* @param string $password Password of user.
|
||||
*
|
||||
* @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['password'] = md5($password);
|
||||
@ -665,9 +714,11 @@ function save_pass_history($id_user, $password)
|
||||
/**
|
||||
* 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(
|
||||
'tusuario_perfil',
|
||||
@ -685,6 +736,12 @@ function delete_user($id_user)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove from notification list as well.
|
||||
$result = db_process_sql_delete(
|
||||
'tnotification_source_user',
|
||||
['id_user' => $id_user]
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -693,15 +750,21 @@ function delete_user($id_user)
|
||||
* Update the password in MD5 for user pass as id_user with
|
||||
* password in plain text.
|
||||
*
|
||||
* @param string user User ID
|
||||
* @param string password Password in plain text.
|
||||
* @param string $user User ID.
|
||||
* @param string $password_new Password in plain text.
|
||||
*
|
||||
* @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;
|
||||
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(
|
||||
"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);
|
||||
|
||||
if (!$remote_pass_update) {
|
||||
if ((bool) $remote_pass_update === false) {
|
||||
$config['auth_error'] = __('Could not changes password on remote pandora');
|
||||
return false;
|
||||
}
|
||||
@ -735,14 +798,14 @@ function update_user_password($user, $password_new)
|
||||
* Update the data of a user that user is choose with
|
||||
* id_user.
|
||||
*
|
||||
* @param string user User ID
|
||||
* @param array values Associative array with index as name of field and content.
|
||||
* @param string $id_user User ID.
|
||||
* @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
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
@ -783,6 +846,9 @@ function ldap_process_user_login($login, $password, $secondary_server=false)
|
||||
$ldap[$token] = $secondary_server === true ? $config[$token.'_secondary'] : $config[$token];
|
||||
}
|
||||
|
||||
// Remove entities ldap admin pass.
|
||||
$ldap['ldap_admin_pass'] = io_safe_output($ldap['ldap_admin_pass']);
|
||||
|
||||
// Connect to the LDAP server
|
||||
if (stripos($ldap['ldap_server'], 'ldap://') !== false
|
||||
|| stripos($ldap['ldap_server'], 'ldaps://') !== false
|
||||
@ -799,8 +865,16 @@ function ldap_process_user_login($login, $password, $secondary_server=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_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_start_tls($ds)) {
|
||||
@ -821,7 +895,8 @@ function ldap_process_user_login($login, $password, $secondary_server=false)
|
||||
io_safe_output($ldap['ldap_admin_login']),
|
||||
io_output_password($ldap['ldap_admin_pass']),
|
||||
io_safe_output($login),
|
||||
$ldap['ldap_start_tls']
|
||||
$ldap['ldap_start_tls'],
|
||||
$config['ldap_search_timeout']
|
||||
);
|
||||
|
||||
if ($sr) {
|
||||
@ -1430,7 +1505,8 @@ function local_ldap_search(
|
||||
$ldap_admin_user=null,
|
||||
$ldap_admin_pass=null,
|
||||
$user=null,
|
||||
$ldap_start_tls=null
|
||||
$ldap_start_tls=null,
|
||||
$ldap_search_time=5
|
||||
) {
|
||||
global $config;
|
||||
|
||||
@ -1463,8 +1539,8 @@ function local_ldap_search(
|
||||
}
|
||||
|
||||
$dn = " -b '".$dn."'";
|
||||
|
||||
$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"'));
|
||||
$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_command));
|
||||
foreach ($shell_ldap_search as $line) {
|
||||
$values = explode('=>', $line);
|
||||
if (!empty($values[0]) && !empty($values[1])) {
|
||||
|
@ -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
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -33,6 +33,7 @@ global $config;
|
||||
require_once $config['homedir'].'/include/class/HTML.class.php';
|
||||
require_once $config['homedir'].'/include/functions_snmp_browser.php';
|
||||
require_once $config['homedir'].'/include/functions_wmi.php';
|
||||
require_once $config['homedir'].'/include/class/CredentialStore.class.php';
|
||||
|
||||
|
||||
use PandoraFMS\Module;
|
||||
@ -285,6 +286,13 @@ class AgentWizard extends HTML
|
||||
*/
|
||||
private $wmiBinary = '';
|
||||
|
||||
/**
|
||||
* Default values for SNMP Interfaces.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $defaultSNMPValues = [];
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -319,6 +327,7 @@ class AgentWizard extends HTML
|
||||
$this->idPolicy = get_parameter('id', '');
|
||||
$this->targetIp = get_parameter('targetIp', '');
|
||||
$this->wmiBinary = $config['wmiBinary'];
|
||||
$this->defaultSNMPValues = (array) json_decode(io_safe_output($config['agent_wizard_defaults']));
|
||||
|
||||
if (empty($this->idAgent) === false) {
|
||||
$array_aux = db_get_all_rows_sql(
|
||||
@ -330,7 +339,7 @@ class AgentWizard extends HTML
|
||||
)
|
||||
);
|
||||
|
||||
if (!empty($array_aux)) {
|
||||
if (empty($array_aux) === false) {
|
||||
$this->datalist = [];
|
||||
foreach ($array_aux as $key => $value) {
|
||||
$this->datalist[] = $value['ip'];
|
||||
@ -547,7 +556,7 @@ class AgentWizard extends HTML
|
||||
// Fill with servers to perform the discover.
|
||||
$fieldsServers = [];
|
||||
$fieldsServers[0] = __('Local console');
|
||||
if (enterprise_installed()) {
|
||||
if (enterprise_installed() === true) {
|
||||
enterprise_include_once('include/functions_satellite.php');
|
||||
// Get the servers.
|
||||
$rows = get_proxy_servers();
|
||||
@ -607,7 +616,7 @@ class AgentWizard extends HTML
|
||||
],
|
||||
];
|
||||
|
||||
if (!empty($this->datalist)) {
|
||||
if (empty($this->datalist) === false) {
|
||||
$inputs[] = [
|
||||
'id' => 'li_address_list',
|
||||
'arguments' => [
|
||||
@ -688,6 +697,43 @@ class AgentWizard extends HTML
|
||||
'return' => true,
|
||||
],
|
||||
];
|
||||
|
||||
$user_groups = users_get_groups(false, 'AR');
|
||||
if (users_is_admin() === true || isset($user_groups[0]) === true) {
|
||||
$credentials = db_get_all_rows_sql(
|
||||
'SELECT identifier FROM tcredential_store WHERE product LIKE "WMI"'
|
||||
);
|
||||
} else {
|
||||
$credentials = db_get_all_rows_sql(
|
||||
sprintf(
|
||||
'SELECT identifier FROM tcredential_store WHERE product LIKE "WMI" AND id_group IN (%s)',
|
||||
implode(',', array_keys($user_groups))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($credentials) === false) {
|
||||
$fields = [];
|
||||
foreach ($credentials as $key => $value) {
|
||||
$fields[$value['identifier']] = $value['identifier'];
|
||||
}
|
||||
|
||||
$inputs[] = [
|
||||
'label' => __('Credential store'),
|
||||
'id' => 'slc-credential',
|
||||
'arguments' => [
|
||||
'name' => 'credential',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'select',
|
||||
'nothing' => __('None'),
|
||||
'nothing_value' => 0,
|
||||
'fields' => $fields,
|
||||
'class' => '',
|
||||
'return' => true,
|
||||
'sort' => true,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$hint_server = ' ';
|
||||
@ -708,6 +754,43 @@ class AgentWizard extends HTML
|
||||
];
|
||||
|
||||
if ($this->actionType === 'snmp') {
|
||||
$user_groups = users_get_groups(false, 'AR');
|
||||
if (users_is_admin() === true || isset($user_groups[0]) === true) {
|
||||
$credentials = db_get_all_rows_sql(
|
||||
'SELECT identifier FROM tcredential_store WHERE product LIKE "SNMP"'
|
||||
);
|
||||
} else {
|
||||
$credentials = db_get_all_rows_sql(
|
||||
sprintf(
|
||||
'SELECT identifier FROM tcredential_store WHERE product LIKE "SNMP" AND id_group IN (%s)',
|
||||
implode(',', array_keys($user_groups))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($credentials) === false) {
|
||||
$fields = [];
|
||||
foreach ($credentials as $key => $value) {
|
||||
$fields[$value['identifier']] = $value['identifier'];
|
||||
}
|
||||
|
||||
$inputs[] = [
|
||||
'label' => __('Credential store'),
|
||||
'id' => 'slc-credential',
|
||||
'arguments' => [
|
||||
'name' => 'credential',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'select',
|
||||
'nothing' => __('None'),
|
||||
'nothing_value' => 0,
|
||||
'fields' => $fields,
|
||||
'class' => '',
|
||||
'return' => true,
|
||||
'sort' => true,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
$inputs[] = [
|
||||
'label' => __('SNMP community'),
|
||||
'id' => 'txt-community',
|
||||
@ -1331,6 +1414,21 @@ class AgentWizard extends HTML
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Build an array with Product credentials.
|
||||
*
|
||||
* @return array with credentials (pass and id).
|
||||
*/
|
||||
public function getCredentials(string $identifier='')
|
||||
{
|
||||
if (empty($identifier) === true) {
|
||||
$identifier = get_parameter('identifier', '');
|
||||
}
|
||||
|
||||
echo json_encode(credentialStore::getKey($identifier));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepare data module to create.
|
||||
*
|
||||
@ -4722,7 +4820,7 @@ class AgentWizard extends HTML
|
||||
'execution_type' => 'network',
|
||||
'value' => '1.3.6.1.2.1.2.2.1.8.'.$value,
|
||||
'module_unit' => '',
|
||||
'default_enabled' => true,
|
||||
'default_enabled' => (bool) $this->defaultSNMPValues['ifOperStatus'],
|
||||
'module_enabled' => false,
|
||||
'module_thresholds' => [
|
||||
'min_warning' => $min_warning,
|
||||
@ -4779,7 +4877,7 @@ class AgentWizard extends HTML
|
||||
'execution_type' => 'network',
|
||||
'value' => '1.3.6.1.4.1.9.2.2.1.1.12.'.$value,
|
||||
'module_unit' => 'packets/s',
|
||||
'default_enabled' => true,
|
||||
'default_enabled' => (bool) $this->defaultSNMPValues['locIfInCRC'],
|
||||
'module_enabled' => false,
|
||||
'module_thresholds' => [
|
||||
'min_warning' => '0',
|
||||
@ -4833,7 +4931,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.',
|
||||
'execution_type' => 'network',
|
||||
'value' => $duplexMismatchOID,
|
||||
'default_enabled' => true,
|
||||
'default_enabled' => (bool) $this->defaultSNMPValues['DuplexMismatch'],
|
||||
'module_enabled' => false,
|
||||
'module_thresholds' => [
|
||||
'min_warning' => '0',
|
||||
@ -4922,7 +5020,7 @@ class AgentWizard extends HTML
|
||||
'id_plugin' => $plugin_id,
|
||||
'id_modulo' => MODULE_PLUGIN,
|
||||
'macros' => json_encode($macros),
|
||||
'default_enabled' => true,
|
||||
'default_enabled' => (bool) $this->defaultSNMPValues['Bandwidth'],
|
||||
'module_enabled' => false,
|
||||
'module_unit' => '%',
|
||||
'module_thresholds' => [
|
||||
@ -4961,7 +5059,7 @@ class AgentWizard extends HTML
|
||||
'id_plugin' => $plugin_id,
|
||||
'id_modulo' => MODULE_PLUGIN,
|
||||
'macros' => json_encode($macros),
|
||||
'default_enabled' => true,
|
||||
'default_enabled' => (bool) $this->defaultSNMPValues['inUsage'],
|
||||
'module_enabled' => false,
|
||||
'module_unit' => '%',
|
||||
'module_thresholds' => [
|
||||
@ -5000,7 +5098,7 @@ class AgentWizard extends HTML
|
||||
'id_plugin' => $plugin_id,
|
||||
'id_modulo' => MODULE_PLUGIN,
|
||||
'macros' => json_encode($macros),
|
||||
'default_enabled' => true,
|
||||
'default_enabled' => (bool) $this->defaultSNMPValues['outUsage'],
|
||||
'module_enabled' => false,
|
||||
'module_unit' => '%',
|
||||
'module_thresholds' => [
|
||||
@ -5032,7 +5130,7 @@ class AgentWizard extends HTML
|
||||
'execution_type' => 'network',
|
||||
'value' => '1.3.6.1.2.1.2.2.1.7.'.$value,
|
||||
'module_unit' => '',
|
||||
'default_enabled' => false,
|
||||
'default_enabled' => (bool) $this->defaultSNMPValues['ifAdminStatus'],
|
||||
'module_enabled' => false,
|
||||
'module_thresholds' => [
|
||||
'min_warning' => '0',
|
||||
@ -5059,7 +5157,7 @@ class AgentWizard extends HTML
|
||||
'execution_type' => 'network',
|
||||
'value' => '1.3.6.1.2.1.2.2.1.13.'.$value,
|
||||
'module_unit' => 'packets/s',
|
||||
'default_enabled' => false,
|
||||
'default_enabled' => (bool) $this->defaultSNMPValues['ifInDiscards'],
|
||||
'module_enabled' => false,
|
||||
'module_thresholds' => [
|
||||
'min_warning' => '0',
|
||||
@ -5086,7 +5184,7 @@ class AgentWizard extends HTML
|
||||
'execution_type' => 'network',
|
||||
'value' => '1.3.6.1.2.1.2.2.1.19.'.$value,
|
||||
'module_unit' => 'packets/s',
|
||||
'default_enabled' => false,
|
||||
'default_enabled' => (bool) $this->defaultSNMPValues['ifOutDiscards'],
|
||||
'module_enabled' => false,
|
||||
'module_thresholds' => [
|
||||
'min_warning' => '0',
|
||||
@ -5113,7 +5211,7 @@ class AgentWizard extends HTML
|
||||
'execution_type' => 'network',
|
||||
'value' => '1.3.6.1.2.1.2.2.1.14.'.$value,
|
||||
'module_unit' => 'packets/s',
|
||||
'default_enabled' => false,
|
||||
'default_enabled' => (bool) $this->defaultSNMPValues['ifInErrors'],
|
||||
'module_enabled' => false,
|
||||
'module_thresholds' => [
|
||||
'min_warning' => '0',
|
||||
@ -5140,7 +5238,7 @@ class AgentWizard extends HTML
|
||||
'execution_type' => 'network',
|
||||
'value' => '1.3.6.1.2.1.2.2.1.20.'.$value,
|
||||
'module_unit' => 'packets/s',
|
||||
'default_enabled' => false,
|
||||
'default_enabled' => (bool) $this->defaultSNMPValues['ifOutErrors'],
|
||||
'module_enabled' => false,
|
||||
'module_thresholds' => [
|
||||
'min_warning' => '0',
|
||||
@ -5210,7 +5308,7 @@ class AgentWizard extends HTML
|
||||
'execution_type' => 'network',
|
||||
'value' => '1.3.6.1.2.1.2.2.1.10.'.$value,
|
||||
'module_unit' => 'bytes/s',
|
||||
'default_enabled' => true,
|
||||
'default_enabled' => (bool) $this->defaultSNMPValues['ifInOctets'],
|
||||
'module_enabled' => false,
|
||||
'module_thresholds' => [
|
||||
'min_warning' => '0',
|
||||
@ -5238,7 +5336,7 @@ class AgentWizard extends HTML
|
||||
'execution_type' => 'network',
|
||||
'value' => '1.3.6.1.2.1.2.2.1.16.'.$value,
|
||||
'module_unit' => 'bytes/s',
|
||||
'default_enabled' => true,
|
||||
'default_enabled' => (bool) $this->defaultSNMPValues['ifOutOctets'],
|
||||
'module_enabled' => false,
|
||||
'module_thresholds' => [
|
||||
'min_warning' => '0',
|
||||
@ -5266,7 +5364,7 @@ class AgentWizard extends HTML
|
||||
'execution_type' => 'network',
|
||||
'value' => '1.3.6.1.2.1.2.2.1.11.'.$value,
|
||||
'module_unit' => 'packets/s',
|
||||
'default_enabled' => false,
|
||||
'default_enabled' => (bool) $this->defaultSNMPValues['ifInUcastPkts'],
|
||||
'module_enabled' => false,
|
||||
'module_thresholds' => [
|
||||
'min_warning' => '0',
|
||||
@ -5293,7 +5391,7 @@ class AgentWizard extends HTML
|
||||
'execution_type' => 'network',
|
||||
'value' => '1.3.6.1.2.1.2.2.1.17.'.$value,
|
||||
'module_unit' => 'packets/s',
|
||||
'default_enabled' => false,
|
||||
'default_enabled' => (bool) $this->defaultSNMPValues['ifOutUcastPkts'],
|
||||
'module_enabled' => false,
|
||||
'module_thresholds' => [
|
||||
'min_warning' => '0',
|
||||
@ -5320,7 +5418,7 @@ class AgentWizard extends HTML
|
||||
'execution_type' => 'network',
|
||||
'value' => '1.3.6.1.2.1.2.2.1.12.'.$value,
|
||||
'module_unit' => 'packets/s',
|
||||
'default_enabled' => false,
|
||||
'default_enabled' => (bool) $this->defaultSNMPValues['ifInNUcastPkts'],
|
||||
'module_enabled' => false,
|
||||
'module_thresholds' => [
|
||||
'min_warning' => '0',
|
||||
@ -5347,7 +5445,7 @@ class AgentWizard extends HTML
|
||||
'execution_type' => 'network',
|
||||
'value' => '1.3.6.1.2.1.2.2.1.18.'.$value,
|
||||
'module_unit' => 'packets/s',
|
||||
'default_enabled' => false,
|
||||
'default_enabled' => (bool) $this->defaultSNMPValues['ifOutNUcastPkts'],
|
||||
'module_enabled' => false,
|
||||
'module_thresholds' => [
|
||||
'min_warning' => '0',
|
||||
@ -5417,7 +5515,7 @@ class AgentWizard extends HTML
|
||||
'execution_type' => 'network',
|
||||
'value' => '1.3.6.1.2.1.31.1.1.1.6.'.$value,
|
||||
'module_unit' => 'bytes/s',
|
||||
'default_enabled' => true,
|
||||
'default_enabled' => (bool) $this->defaultSNMPValues['ifHCInOctets'],
|
||||
'module_enabled' => false,
|
||||
'module_thresholds' => [
|
||||
'min_warning' => '0',
|
||||
@ -5445,7 +5543,7 @@ class AgentWizard extends HTML
|
||||
'execution_type' => 'network',
|
||||
'value' => '1.3.6.1.2.1.31.1.1.1.10.'.$value,
|
||||
'module_unit' => 'bytes/s',
|
||||
'default_enabled' => true,
|
||||
'default_enabled' => (bool) $this->defaultSNMPValues['ifHCOutOctets'],
|
||||
'module_enabled' => false,
|
||||
'module_thresholds' => [
|
||||
'min_warning' => '0',
|
||||
@ -5473,7 +5571,7 @@ class AgentWizard extends HTML
|
||||
'execution_type' => 'network',
|
||||
'value' => '1.3.6.1.2.1.31.1.1.1.7.'.$value,
|
||||
'module_unit' => 'packets/s',
|
||||
'default_enabled' => false,
|
||||
'default_enabled' => (bool) $this->defaultSNMPValues['ifHCInUcastPkts'],
|
||||
'module_enabled' => false,
|
||||
'module_thresholds' => [
|
||||
'min_warning' => '0',
|
||||
@ -5501,7 +5599,7 @@ class AgentWizard extends HTML
|
||||
'execution_type' => 'network',
|
||||
'value' => '1.3.6.1.2.1.31.1.1.1.11.'.$value,
|
||||
'module_unit' => 'packets/s',
|
||||
'default_enabled' => false,
|
||||
'default_enabled' => (bool) $this->defaultSNMPValues['ifHCOutUcastPkts'],
|
||||
'module_enabled' => false,
|
||||
'module_thresholds' => [
|
||||
'min_warning' => '0',
|
||||
@ -5528,7 +5626,7 @@ class AgentWizard extends HTML
|
||||
'execution_type' => 'network',
|
||||
'value' => '1.3.6.1.2.1.31.1.1.1.7.'.$value,
|
||||
'module_unit' => 'packets/s',
|
||||
'default_enabled' => false,
|
||||
'default_enabled' => (bool) $this->defaultSNMPValues['ifHCInNUcastPkts'],
|
||||
'module_enabled' => false,
|
||||
'module_thresholds' => [
|
||||
'min_warning' => '0',
|
||||
@ -5555,7 +5653,7 @@ class AgentWizard extends HTML
|
||||
'execution_type' => 'network',
|
||||
'value' => '1.3.6.1.2.1.31.1.1.1.11.'.$value,
|
||||
'module_unit' => 'packets/s',
|
||||
'default_enabled' => false,
|
||||
'default_enabled' => (bool) $this->defaultSNMPValues['ifHCOutNUcastPkts'],
|
||||
'module_enabled' => false,
|
||||
'module_thresholds' => [
|
||||
'min_warning' => '0',
|
||||
@ -5808,6 +5906,58 @@ class AgentWizard extends HTML
|
||||
filterInterfaces();
|
||||
});
|
||||
|
||||
$('#credential').change(function() {
|
||||
if ($('#credential').val() !== '0') {
|
||||
$.ajax({
|
||||
method: "post",
|
||||
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
data: {
|
||||
page: "<?php echo $this->ajaxController; ?>",
|
||||
method: "getCredentials",
|
||||
identifier: $('#credential').val()
|
||||
},
|
||||
datatype: "json",
|
||||
success: function(data) {
|
||||
data = JSON.parse(data);
|
||||
|
||||
if ($('#text-namespaceWMI').length > 0) {
|
||||
// WMI.
|
||||
$('#text-namespaceWMI').val(data['extra_1']);
|
||||
$('#text-usernameWMI').val(data['username']);
|
||||
$('#password-passwordWMI').val(data['password']);
|
||||
} else {
|
||||
// SNMP.
|
||||
extra = JSON.parse(data['extra_1']);
|
||||
$('#version').val(extra['version']);
|
||||
$('#version').trigger('change');
|
||||
$('#text-community').val(extra['community']);
|
||||
|
||||
if (extra['version'] === '3') {
|
||||
$('#securityLevelV3').val(extra['securityLevelV3']);
|
||||
$('#securityLevelV3').trigger('change');
|
||||
$('#text-authUserV3').val(extra['authUserV3']);
|
||||
|
||||
if (extra['securityLevelV3'] === 'authNoPriv' || extra['securityLevelV3'] === 'authPriv') {
|
||||
$('#authMethodV3').val(extra['authMethodV3']);
|
||||
$('#authMethodV3').trigger('change');
|
||||
$('#password-authPassV3').val(extra['authPassV3']);
|
||||
|
||||
if (extra['securityLevelV3'] === 'authPriv') {
|
||||
$('#privacyMethodV3').val(extra['privacyMethodV3']);
|
||||
$('#privacyMethodV3').trigger('change');
|
||||
$('#password-privacyPassV3').val(extra['privacyPassV3']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function(e) {
|
||||
showMsg(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Loading.
|
||||
$('#submit-sub-protocol').click(function() {
|
||||
$('.wizard-result').remove();
|
||||
|
@ -617,33 +617,71 @@ class CredentialStore extends Wizard
|
||||
$password = $google_creds->private_key_id;
|
||||
}
|
||||
|
||||
if (empty($identifier) === true) {
|
||||
$error = __('Key identifier is required');
|
||||
} else if ($id_group === null) {
|
||||
$error = __('You must select a group where store this key!');
|
||||
} else if (empty($product) === true) {
|
||||
$error = __('You must specify a product type');
|
||||
} else if (empty($username) === true || (empty($password) === true)) {
|
||||
$error = __('You must specify a username and/or password');
|
||||
} else if (evaluate_ascii_valid_string(io_safe_output($identifier)) === false) {
|
||||
$error = __('Identifier with forbidden characters. Check the documentation.');
|
||||
}
|
||||
if ($product !== 'SNMP') {
|
||||
if (empty($identifier) === true) {
|
||||
$error = __('Key identifier is required');
|
||||
} else if ($id_group === null) {
|
||||
$error = __('You must select a group where store this key!');
|
||||
} else if (empty($product) === true) {
|
||||
$error = __('You must specify a product type');
|
||||
} else if (empty($username) === true || (empty($password) === true)) {
|
||||
$error = __('You must specify a username and/or password');
|
||||
} else if (evaluate_ascii_valid_string(io_safe_output($identifier)) === false) {
|
||||
$error = __('Identifier with forbidden characters. Check the documentation.');
|
||||
}
|
||||
|
||||
if (isset($error) === true) {
|
||||
$this->ajaxMsg('error', $error);
|
||||
exit;
|
||||
}
|
||||
if (isset($error) === true) {
|
||||
$this->ajaxMsg('error', $error);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Encrypt content (if needed).
|
||||
$values = [
|
||||
'identifier' => $identifier,
|
||||
'id_group' => $id_group,
|
||||
'product' => $product,
|
||||
'username' => io_input_password(io_safe_output($username)),
|
||||
'password' => io_input_password(io_safe_output($password)),
|
||||
'extra_1' => io_input_password(io_safe_output($extra_1)),
|
||||
'extra_2' => io_input_password(io_safe_output($extra_2)),
|
||||
];
|
||||
// Encrypt content (if needed).
|
||||
$values = [
|
||||
'identifier' => $identifier,
|
||||
'id_group' => $id_group,
|
||||
'product' => $product,
|
||||
'username' => io_input_password(io_safe_output($username)),
|
||||
'password' => io_input_password(io_safe_output($password)),
|
||||
'extra_1' => io_input_password(io_safe_output($extra_1)),
|
||||
'extra_2' => io_input_password(io_safe_output($extra_2)),
|
||||
];
|
||||
} else {
|
||||
$values = [
|
||||
'identifier' => $identifier,
|
||||
'id_group' => $id_group,
|
||||
'product' => $product,
|
||||
];
|
||||
|
||||
$community = (string) get_parameter('community', '');
|
||||
$version = (string) get_parameter('version', '1');
|
||||
$extra_json = [
|
||||
'community' => $community,
|
||||
'version' => $version,
|
||||
];
|
||||
if ($version === '3') {
|
||||
$securityLevelV3 = (string) get_parameter('securityLevelV3', 'authNoPriv');
|
||||
$extra_json['securityLevelV3'] = $securityLevelV3;
|
||||
$authUserV3 = (string) get_parameter('authUserV3', '');
|
||||
$extra_json['authUserV3'] = $authUserV3;
|
||||
if ($securityLevelV3 === 'authNoPriv' || $securityLevelV3 === 'authPriv') {
|
||||
$authUserV3 = (string) get_parameter('authUserV3', '');
|
||||
$extra_json['authUserV3'] = $authUserV3;
|
||||
$authMethodV3 = (string) get_parameter('authMethodV3', 'MD5');
|
||||
$extra_json['authMethodV3'] = $authMethodV3;
|
||||
$authPassV3 = (string) get_parameter('authPassV3', '');
|
||||
$extra_json['authPassV3'] = $authPassV3;
|
||||
|
||||
if ($securityLevelV3 === 'authPriv') {
|
||||
$privacyMethodV3 = (string) get_parameter('privacyMethodV3', 'AES');
|
||||
$extra_json['privacyMethodV3'] = $privacyMethodV3;
|
||||
$privacyPassV3 = (string) get_parameter('privacyPassV3', '');
|
||||
$extra_json['privacyPassV3'] = $privacyPassV3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$values['extra_1'] = json_encode($extra_json);
|
||||
}
|
||||
|
||||
// Spaces are not allowed.
|
||||
$values['identifier'] = \io_safe_input(
|
||||
@ -947,6 +985,8 @@ class CredentialStore extends Wizard
|
||||
'AZURE' => __('Azure'),
|
||||
'SAP' => __('SAP'),
|
||||
'GOOGLE' => __('Google'),
|
||||
'WMI' => __('WMI'),
|
||||
'SNMP' => __('SNMP'),
|
||||
],
|
||||
'selected' => (isset($values['product']) ? $values['product'] : 'CUSTOM'),
|
||||
'disabled' => (bool) $values['product'],
|
||||
@ -989,6 +1029,19 @@ class CredentialStore extends Wizard
|
||||
$extra1_type = 'textarea';
|
||||
break;
|
||||
|
||||
case 'WMI':
|
||||
$extra_1_label = __('Namespace');
|
||||
$extra1 = true;
|
||||
$extra2 = false;
|
||||
break;
|
||||
|
||||
case 'SNMP':
|
||||
$user = false;
|
||||
$pass = false;
|
||||
$extra1 = false;
|
||||
$extra2 = false;
|
||||
break;
|
||||
|
||||
case 'CUSTOM':
|
||||
case 'SAP':
|
||||
$user_label = __('Account ID');
|
||||
@ -1059,6 +1112,141 @@ class CredentialStore extends Wizard
|
||||
];
|
||||
}
|
||||
|
||||
if ($values['product'] === 'SNMP') {
|
||||
$json_values = json_decode($values['extra_1'], true);
|
||||
$inputs[] = [
|
||||
'label' => __('SNMP community'),
|
||||
'id' => 'li_snmp_1',
|
||||
'arguments' => [
|
||||
'name' => 'community',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'text',
|
||||
'value' => $json_values['community'],
|
||||
'return' => true,
|
||||
],
|
||||
];
|
||||
|
||||
$inputs[] = [
|
||||
'label' => __('SNMP version'),
|
||||
'id' => 'li_snmp_2',
|
||||
'arguments' => [
|
||||
'name' => 'version',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'select',
|
||||
'script' => 'showVersion()',
|
||||
'fields' => [
|
||||
'1' => __('1'),
|
||||
'2' => __('2'),
|
||||
'2c' => __('2c'),
|
||||
'3' => __('3'),
|
||||
],
|
||||
'selected' => (isset($json_values['version']) ? $json_values['version'] : '1'),
|
||||
'return' => true,
|
||||
],
|
||||
];
|
||||
|
||||
$inputs[] = [
|
||||
'label' => __('Security level'),
|
||||
'id' => 'li_snmp_3',
|
||||
'style' => ($json_values['version'] !== '3') ? 'display: none;' : '',
|
||||
'arguments' => [
|
||||
'name' => 'securityLevelV3',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'select',
|
||||
'script' => 'showSecurity()',
|
||||
'fields' => [
|
||||
'authNoPriv' => __('Authenticated and non-private method'),
|
||||
'authPriv' => __('Authenticated and private method'),
|
||||
'noAuthNoPriv' => __('Non-authenticated and non-private method'),
|
||||
],
|
||||
'selected' => (isset($json_values['securityLevelV3']) ? $json_values['securityLevelV3'] : 'authNoPriv'),
|
||||
'return' => true,
|
||||
],
|
||||
];
|
||||
|
||||
$inputs[] = [
|
||||
'label' => __('User authentication'),
|
||||
'id' => 'li_snmp_4',
|
||||
'style' => ($json_values['version'] !== '3') ? 'display: none;' : '',
|
||||
'arguments' => [
|
||||
'name' => 'authUserV3',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'text',
|
||||
'value' => $json_values['authUserV3'],
|
||||
'return' => true,
|
||||
],
|
||||
];
|
||||
|
||||
$authNoPrivate = (
|
||||
isset($json_values['securityLevelV3']) &&
|
||||
($json_values['securityLevelV3'] === 'authNoPriv' || $json_values['securityLevelV3'] === 'authPriv')
|
||||
) ? '' : 'display: none;';
|
||||
|
||||
$inputs[] = [
|
||||
'label' => __('Authentication method'),
|
||||
'id' => 'li_snmp_5',
|
||||
'style' => $authNoPrivate,
|
||||
'arguments' => [
|
||||
'name' => 'authMethodV3',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'select',
|
||||
'fields' => [
|
||||
'MD5' => __('MD5'),
|
||||
'SHA' => __('SHA'),
|
||||
],
|
||||
'selected' => (isset($json_values['authMethodV3']) ? $json_values['authMethodV3'] : 'MD5'),
|
||||
'return' => true,
|
||||
],
|
||||
];
|
||||
|
||||
$inputs[] = [
|
||||
'label' => __('Password authentication'),
|
||||
'id' => 'li_snmp_6',
|
||||
'style' => $authNoPrivate,
|
||||
'arguments' => [
|
||||
'name' => 'authPassV3',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'password',
|
||||
'value' => $json_values['authPassV3'],
|
||||
'return' => true,
|
||||
],
|
||||
];
|
||||
|
||||
$authPrivate = (isset($json_values['securityLevelV3']) && $json_values['securityLevelV3'] === 'authPriv')
|
||||
? ''
|
||||
: 'display: none;';
|
||||
|
||||
$inputs[] = [
|
||||
'label' => __('Privacy method'),
|
||||
'id' => 'li_snmp_7',
|
||||
'style' => $authPrivate,
|
||||
'arguments' => [
|
||||
'name' => 'privacyMethodV3',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'select',
|
||||
'fields' => [
|
||||
'AES' => __('AES'),
|
||||
'DES' => __('DES'),
|
||||
],
|
||||
'selected' => (isset($json_values['privacyMethodV3']) ? $json_values['privacyMethodV3'] : 'AES'),
|
||||
'return' => true,
|
||||
],
|
||||
];
|
||||
|
||||
$inputs[] = [
|
||||
'label' => __('Privacy pass'),
|
||||
'id' => 'li_snmp_8',
|
||||
'style' => $authPrivate,
|
||||
'arguments' => [
|
||||
'name' => 'privacyPassV3',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'password',
|
||||
'value' => $json_values['privacyPassV3'],
|
||||
'return' => true,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
return $this->printForm(
|
||||
[
|
||||
'form' => $form,
|
||||
@ -1175,9 +1363,248 @@ class CredentialStore extends Wizard
|
||||
$('<textarea name="extra_1" id="text-extra_1">'+val+'</textarea>')
|
||||
);
|
||||
$('#div-extra_1').show();
|
||||
} else if ($('#product :selected').val() == "WMI") {
|
||||
$('#div-username label').text('<?php echo __('Username'); ?>');
|
||||
$('#div-password label').text('<?php echo __('Password'); ?>');
|
||||
$('#div-extra_1 label').text('<?php echo __('Namespace'); ?>');
|
||||
$('#div-username').show();
|
||||
$('#div-password').show();
|
||||
$('#div-extra_1').show();
|
||||
$('#div-extra_2').hide();
|
||||
} else if ($('#product :selected').val() == "SNMP") {
|
||||
$('#div-username').hide();
|
||||
$('#div-password').hide();
|
||||
$('#div-extra_1').hide();
|
||||
$('#div-extra_2').hide();
|
||||
|
||||
if ($('#li_snmp_1').length > 0) {
|
||||
console.log($('#li_snmp_1').length);
|
||||
const test = '<?php echo $json_values; ?>';
|
||||
console.log(test);
|
||||
} else {
|
||||
const ul = $('#modal_form').children('ul')[0];
|
||||
|
||||
// SNMP community.
|
||||
const li_community = document.createElement("li");
|
||||
li_community.id = 'li_snmp_1';
|
||||
const label_community = document.createElement("label");
|
||||
label_community.textContent = '<?php echo __('SNMP community'); ?>';
|
||||
const input_community = document.createElement("input");
|
||||
input_community.type = 'text';
|
||||
input_community.className = 'text_input';
|
||||
input_community.name = 'community';
|
||||
li_community.append(label_community);
|
||||
li_community.append(input_community);
|
||||
ul.append(li_community);
|
||||
|
||||
// SNMP version.
|
||||
const li_version = document.createElement("li");
|
||||
li_version.id = 'li_snmp_2';
|
||||
const label_version = document.createElement("label");
|
||||
label_version.textContent = '<?php echo __('SNMP version'); ?>';
|
||||
const select_version = document.createElement("select");
|
||||
select_version.name = 'version';
|
||||
select_version.id = 'version';
|
||||
select_version.onchange = function() {
|
||||
showVersion();
|
||||
};
|
||||
let option1 = document.createElement("option");
|
||||
let option2 = document.createElement("option");
|
||||
let option2c = document.createElement("option");
|
||||
let option3 = document.createElement("option");
|
||||
option1.value = '1';
|
||||
option1.text = '1';
|
||||
option2.value = '2';
|
||||
option2.text = '2';
|
||||
option2c.value = '2c';
|
||||
option2c.text = '2c';
|
||||
option3.value = '3';
|
||||
option3.text = '3';
|
||||
select_version.appendChild(option1);
|
||||
select_version.appendChild(option2);
|
||||
select_version.appendChild(option2c);
|
||||
select_version.appendChild(option3);
|
||||
li_version.append(label_version);
|
||||
li_version.append(select_version);
|
||||
ul.append(li_version);
|
||||
$("#version").select2();
|
||||
|
||||
// Security.
|
||||
const li_security = document.createElement("li");
|
||||
li_security.id = 'li_snmp_3';
|
||||
const label_security = document.createElement("label");
|
||||
label_security.textContent = '<?php echo __('Security level'); ?>';
|
||||
const select_security = document.createElement("select");
|
||||
select_security.name = 'securityLevelV3';
|
||||
select_security.id = 'securityLevelV3';
|
||||
select_security.onchange = function() {
|
||||
showSecurity();
|
||||
}
|
||||
option1 = document.createElement("option");
|
||||
option2 = document.createElement("option");
|
||||
option3 = document.createElement("option");
|
||||
option1.value = 'authNoPriv';
|
||||
option1.text = '<?php echo __('Authenticated and non-private method'); ?>';
|
||||
option2.value = 'authPriv';
|
||||
option2.text = '<?php echo __('Authenticated and private method'); ?>';
|
||||
option3.value = 'noAuthNoPriv';
|
||||
option3.text = '<?php echo __('Non-authenticated and non-private method'); ?>';
|
||||
select_security.appendChild(option1);
|
||||
select_security.appendChild(option2);
|
||||
select_security.appendChild(option3);
|
||||
li_security.append(label_security);
|
||||
li_security.append(select_security);
|
||||
ul.append(li_security);
|
||||
$("#securityLevelV3").select2();
|
||||
|
||||
// User.
|
||||
const li_user = document.createElement("li");
|
||||
li_user.id = 'li_snmp_4';
|
||||
const label_user = document.createElement("label");
|
||||
label_user.textContent = '<?php echo __('User authentication'); ?>';
|
||||
const input_user = document.createElement("input");
|
||||
input_user.type = 'text';
|
||||
input_user.className = 'text_input';
|
||||
input_user.name = 'authUserV3';
|
||||
li_user.append(label_user);
|
||||
li_user.append(input_user);
|
||||
ul.append(li_user);
|
||||
|
||||
// Authentication method.
|
||||
const li_method = document.createElement("li");
|
||||
li_method.id = 'li_snmp_5';
|
||||
const label_method = document.createElement("label");
|
||||
label_method.textContent = '<?php echo __('Authentication method'); ?>';
|
||||
const select_method = document.createElement("select");
|
||||
select_method.name = 'authMethodV3';
|
||||
select_method.id = 'method';
|
||||
option1 = document.createElement("option");
|
||||
option2 = document.createElement("option");
|
||||
option1.value = 'MD5';
|
||||
option1.text = '<?php echo __('MD5'); ?>';
|
||||
option2.value = 'SHA';
|
||||
option2.text = '<?php echo __('SHA'); ?>';
|
||||
select_method.appendChild(option1);
|
||||
select_method.appendChild(option2);
|
||||
li_method.append(label_method);
|
||||
li_method.append(select_method);
|
||||
ul.append(li_method);
|
||||
$("#method").select2();
|
||||
|
||||
// Password.
|
||||
const li_password = document.createElement("li");
|
||||
li_password.id = 'li_snmp_6';
|
||||
const label_password = document.createElement("label");
|
||||
label_password.textContent = '<?php echo __('Password authentication'); ?>';
|
||||
const input_password = document.createElement("input");
|
||||
input_password.type = 'password';
|
||||
input_password.className = 'text_input';
|
||||
input_password.name = 'authPassV3';
|
||||
li_password.append(label_password);
|
||||
li_password.append(input_password);
|
||||
ul.append(li_password);
|
||||
|
||||
// Privacy method.
|
||||
const li_privacy = document.createElement("li");
|
||||
li_privacy.id = 'li_snmp_7';
|
||||
const label_privacy = document.createElement("label");
|
||||
label_privacy.textContent = '<?php echo __('Privacy method'); ?>';
|
||||
const select_privacy = document.createElement("select");
|
||||
select_privacy.name = 'privacyMethodV3';
|
||||
select_privacy.id = 'privacy';
|
||||
option1 = document.createElement("option");
|
||||
option2 = document.createElement("option");
|
||||
option1.value = 'AES';
|
||||
option1.text = '<?php echo __('AES'); ?>';
|
||||
option2.value = 'DES';
|
||||
option2.text = '<?php echo __('DES'); ?>';
|
||||
select_privacy.appendChild(option1);
|
||||
select_privacy.appendChild(option2);
|
||||
li_privacy.append(label_privacy);
|
||||
li_privacy.append(select_privacy);
|
||||
ul.append(li_privacy);
|
||||
$("#privacy").select2();
|
||||
|
||||
// Privacy pass.
|
||||
const li_privacyPassV3 = document.createElement("li");
|
||||
li_privacyPassV3.id = 'li_snmp_8';
|
||||
const label_privacyPassV3 = document.createElement("label");
|
||||
label_privacyPassV3.textContent = '<?php echo __('Privacy pass'); ?>';
|
||||
const input_privacyPassV3 = document.createElement("input");
|
||||
input_privacyPassV3.type = 'password';
|
||||
input_privacyPassV3.className = 'text_input';
|
||||
input_privacyPassV3.name = 'privacyPassV3';
|
||||
li_privacyPassV3.append(label_privacyPassV3);
|
||||
li_privacyPassV3.append(input_privacyPassV3);
|
||||
ul.append(li_privacyPassV3);
|
||||
|
||||
$('#li_snmp_3').hide();
|
||||
$('#li_snmp_4').hide();
|
||||
$('#li_snmp_5').hide();
|
||||
$('#li_snmp_6').hide();
|
||||
$('#li_snmp_7').hide();
|
||||
$('#li_snmp_8').hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function showVersion() {
|
||||
if ($('#version').val() === '3') {
|
||||
$('#li_snmp_3').show();
|
||||
$('#li_snmp_4').show();
|
||||
$('#li_snmp_5').show();
|
||||
$('#li_snmp_6').show();
|
||||
} else {
|
||||
$('#li_snmp_3').hide();
|
||||
$('#li_snmp_4').hide();
|
||||
$('#li_snmp_5').hide();
|
||||
$('#li_snmp_6').hide();
|
||||
$('#li_snmp_7').hide();
|
||||
$('#li_snmp_8').hide();
|
||||
}
|
||||
}
|
||||
|
||||
function showSecurity() {
|
||||
const value = $('#securityLevelV3').val();
|
||||
switch (value) {
|
||||
case 'noAuthNoPriv':
|
||||
$('#li_snmp_4').show();
|
||||
$('#li_snmp_5').hide();
|
||||
$('#li_snmp_6').hide();
|
||||
$('#li_snmp_7').hide();
|
||||
$('#li_snmp_8').hide();
|
||||
break;
|
||||
|
||||
case 'authPriv':
|
||||
$('#li_snmp_4').show();
|
||||
$('#li_snmp_5').show();
|
||||
$('#li_snmp_6').show();
|
||||
$('#li_snmp_7').show();
|
||||
$('#li_snmp_8').show();
|
||||
break;
|
||||
|
||||
case 'authNoPriv':
|
||||
default:
|
||||
$('#li_snmp_4').show();
|
||||
$('#li_snmp_5').show();
|
||||
$('#li_snmp_6').show();
|
||||
$('#li_snmp_7').hide();
|
||||
$('#li_snmp_8').hide();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function hideSNMP() {
|
||||
$('#li_snmp_1').hide();
|
||||
$('#li_snmp_2').hide();
|
||||
$('#li_snmp_3').hide();
|
||||
$('#li_snmp_4').hide();
|
||||
$('#li_snmp_5').hide();
|
||||
$('#li_snmp_6').hide();
|
||||
$('#li_snmp_7').hide();
|
||||
$('#li_snmp_8').hide();
|
||||
}
|
||||
|
||||
/**
|
||||
* Process ajax responses and shows a dialog with results.
|
||||
*/
|
||||
|
@ -485,6 +485,10 @@ class HTML
|
||||
$class = '';
|
||||
}
|
||||
|
||||
if (empty($input['style']) === false) {
|
||||
$style_li = $input['style'];
|
||||
}
|
||||
|
||||
if (isset($input['class']) === true) {
|
||||
$class = $input['class'].$class;
|
||||
}
|
||||
@ -498,7 +502,7 @@ class HTML
|
||||
}
|
||||
|
||||
// Print independent block of inputs.
|
||||
$output .= '<li id="li-'.($input['block_id'] ?? '').'" class="'.$class.'">';
|
||||
$output .= '<li id="li-'.($input['block_id'] ?? '').'" class="'.$class.'" style="'.$style_li.'">';
|
||||
|
||||
if (isset($input['wrapper']) === true) {
|
||||
$output .= '<'.$input['wrapper'].' id="'.($input['block_id'] ?? '').'" class="'.$class.'">';
|
||||
@ -562,7 +566,7 @@ class HTML
|
||||
}
|
||||
|
||||
if (!$direct) {
|
||||
$output .= '<li id="'.($input['id'] ?? '').'" class="'.$class.'">';
|
||||
$output .= '<li id="'.($input['id'] ?? '').'" class="'.$class.'" style="'.$style_li.'">';
|
||||
}
|
||||
|
||||
if (isset($input['label']) === true) {
|
||||
@ -933,7 +937,13 @@ class HTML
|
||||
$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['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) {
|
||||
echo $output_head;
|
||||
|
@ -139,7 +139,7 @@ class Heatmap
|
||||
ui_require_css_file('heatmap');
|
||||
|
||||
$settings = [
|
||||
'type' => 'POST',
|
||||
'type' => 'GET',
|
||||
'dataType' => 'html',
|
||||
'url' => ui_get_full_url(
|
||||
'ajax.php',
|
||||
@ -169,11 +169,41 @@ class Heatmap
|
||||
setting['data']['height'] = $(`#div_${randomId}`).height() + 10;
|
||||
setting['data']['width'] = $(`#div_${randomId}`).width();
|
||||
|
||||
var totalModules = 0;
|
||||
|
||||
// Initial charge.
|
||||
ajaxRequest(
|
||||
`div_${randomId}`,
|
||||
setting
|
||||
);
|
||||
$.ajax({
|
||||
type: setting.type,
|
||||
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.
|
||||
setInterval(
|
||||
@ -206,23 +236,29 @@ class Heatmap
|
||||
// randomly sort.
|
||||
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 limit = countPerSecond - 1;
|
||||
|
||||
const timer = setInterval(
|
||||
function() {
|
||||
while (cont <= limit) {
|
||||
$(`#${randomId}_${lista[cont]['id']}`).removeClass();
|
||||
$(`#${randomId}_${lista[cont]['id']}`).addClass(`${lista[cont]['status']} hover`);
|
||||
|
||||
cont++;
|
||||
function() {
|
||||
while (cont <= limit) {
|
||||
if (typeof lista[cont] !== 'undefined') {
|
||||
const rect = document.getElementsByName(`${lista[cont]['id']}`);
|
||||
$(`#${rect[0].id}`).removeClass();
|
||||
$(`#${rect[0].id}`).addClass(`${lista[cont]['status']} hover`);
|
||||
}
|
||||
limit = limit + countPerSecond;
|
||||
},
|
||||
1000
|
||||
);
|
||||
|
||||
cont++;
|
||||
}
|
||||
limit = limit + countPerSecond;
|
||||
},
|
||||
1000
|
||||
);
|
||||
|
||||
setTimeout(
|
||||
function(){
|
||||
@ -314,8 +350,10 @@ class Heatmap
|
||||
|
||||
// All agents.
|
||||
$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 last_status_change FROM tagente_estado WHERE id_agente = tagente.id_agente ORDER BY last_status_change DESC LIMIT 1) AS last_status_change
|
||||
'SELECT DISTINCT id_agente as id,alias,id_grupo,normal_count,warning_count,critical_count,
|
||||
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',
|
||||
$alias,
|
||||
$id_grupo
|
||||
@ -391,7 +429,8 @@ class Heatmap
|
||||
|
||||
// All modules.
|
||||
$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
|
||||
WHERE am.disabled = 0 %s %s GROUP BY am.id_module_group, am.id_agente_modulo',
|
||||
$filter_group,
|
||||
@ -489,7 +528,8 @@ class Heatmap
|
||||
|
||||
// All modules.
|
||||
$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
|
||||
WHERE 1=1 %s %s GROUP BY tm.id_tag, ae.id_agente_modulo',
|
||||
$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
|
||||
*
|
||||
@ -575,6 +707,10 @@ class Heatmap
|
||||
public function getData()
|
||||
{
|
||||
switch ($this->type) {
|
||||
case 3:
|
||||
$data = $this->getAllModulesByAgents();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$data = $this->getAllModulesByGroup();
|
||||
break;
|
||||
@ -709,9 +845,10 @@ class Heatmap
|
||||
$groups = [];
|
||||
$contX = 0;
|
||||
$contY = 0;
|
||||
$cont = 1;
|
||||
foreach ($result as $value) {
|
||||
echo '<rect id="'.$this->randomId.'_'.$value['id'].'" class="'.$value['status'].' hover"
|
||||
width="1" height="1" x ="'.$contX.' "y="'.$contY.'" />';
|
||||
echo '<rect id="'.$this->randomId.'_'.$cont.'" class="'.$value['status'].' hover"
|
||||
width="1" height="1" x ="'.$contX.' "y="'.$contY.'" name="'.$value['id'].'" />';
|
||||
|
||||
$contX++;
|
||||
if ($contX >= $Xaxis) {
|
||||
@ -724,14 +861,15 @@ class Heatmap
|
||||
} else {
|
||||
$groups[$value['id_grupo']] += 1;
|
||||
}
|
||||
|
||||
$cont++;
|
||||
}
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$('rect').click(function() {
|
||||
const type = <?php echo $this->type; ?>;
|
||||
const hash = '<?php echo $this->randomId; ?>';
|
||||
const id = this.id.replace(`${hash}_`, '');
|
||||
const id = $(`#${this.id}`).attr("name");
|
||||
|
||||
$("#info_dialog").dialog({
|
||||
resizable: true,
|
||||
@ -778,6 +916,10 @@ class Heatmap
|
||||
foreach ($groups as $key => $group) {
|
||||
$name = '';
|
||||
switch ($this->type) {
|
||||
case 3:
|
||||
$name = agents_get_alias($key);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$name = modules_get_modulegroup_name($key);
|
||||
break;
|
||||
|
@ -223,8 +223,9 @@ class SatelliteAgent extends HTML
|
||||
|
||||
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(
|
||||
[
|
||||
'0' => 'Disable / Enable selected agents',
|
||||
@ -248,18 +249,18 @@ class SatelliteAgent extends HTML
|
||||
);
|
||||
echo '</div>';
|
||||
|
||||
echo '</br></br>';
|
||||
|
||||
// Create button.
|
||||
echo '<div class="w100p flex-content-right">';
|
||||
// Create button add host.
|
||||
echo '<div class="flex-content-right">';
|
||||
html_print_submit_button(
|
||||
__('Add host'),
|
||||
'create',
|
||||
false,
|
||||
'class="sub next"'
|
||||
);
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
// Load own javascript file.
|
||||
echo $this->loadJS();
|
||||
}
|
||||
@ -1255,6 +1256,8 @@ class SatelliteAgent extends HTML
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('body').append('<div id="dialog"></div>');
|
||||
|
||||
$("#submit-create").on('click', function() {
|
||||
show_form();
|
||||
});
|
||||
@ -1267,61 +1270,140 @@ class SatelliteAgent extends HTML
|
||||
$('#submit-submit_satellite_action').click(function() {
|
||||
const checks = $('input[name*=check_]:checked');
|
||||
const action = $('#satellite_action').val();
|
||||
$.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 {
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
let agent_delete_error = [];
|
||||
let agent_disable_error = [];
|
||||
$('#aux').empty();
|
||||
$('#aux').text('<?php echo __('Are you sure?'); ?>');
|
||||
$('#aux').dialog({
|
||||
title: (action === '0') ? '<?php echo __('Disable / Enable Agents'); ?>' : '<?php echo __('Delete / create Agents'); ?>',
|
||||
buttons: [
|
||||
{
|
||||
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel',
|
||||
text: '<?php echo __('Cancel'); ?>',
|
||||
click: function(e) {
|
||||
$(this).dialog('close');
|
||||
cleanupDOM();
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
689
pandora_console/include/class/SatelliteCollection.class.php
Normal file
689
pandora_console/include/class/SatelliteCollection.class.php
Normal file
@ -0,0 +1,689 @@
|
||||
<?php
|
||||
// phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
|
||||
/**
|
||||
* Controller for collections
|
||||
*
|
||||
* @category Controller
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* 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.
|
||||
global $config;
|
||||
|
||||
// Necessary classes for extends.
|
||||
require_once $config['homedir'].'/include/class/HTML.class.php';
|
||||
require_once $config['homedir'].'/include/functions_servers.php';
|
||||
enterprise_include_once('include/functions_satellite.php');
|
||||
enterprise_include_once('include/functions_collection.php');
|
||||
|
||||
/**
|
||||
* Class SatelliteCollection
|
||||
*/
|
||||
class SatelliteCollection extends HTML
|
||||
{
|
||||
|
||||
/**
|
||||
* Allowed methods to be called using AJAX request.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $AJAXMethods = [
|
||||
'draw',
|
||||
'addCollection',
|
||||
'deleteCollection',
|
||||
'loadModal',
|
||||
];
|
||||
|
||||
/**
|
||||
* Ajax page.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $ajaxController;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param string $ajaxController Ajax controller.
|
||||
*/
|
||||
public function __construct(string $ajaxController)
|
||||
{
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
|
||||
if (check_acl($config['id_user'], 0, 'PM') === false
|
||||
&& is_user_admin($config['id_user']) === true
|
||||
) {
|
||||
db_pandora_audit(
|
||||
AUDIT_LOG_ACL_VIOLATION,
|
||||
'Trying to access Satellite agents'
|
||||
);
|
||||
include 'general/noaccess.php';
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the ajax controller.
|
||||
$this->ajaxController = $ajaxController;
|
||||
// Capture all parameters before start.
|
||||
$this->satellite_server = (int) get_parameter('server_remote');
|
||||
if ($this->satellite_server !== 0) {
|
||||
$this->satellite_name = servers_get_name($this->satellite_server);
|
||||
$this->satellite_config = (array) config_satellite_get_config_file($this->satellite_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run view
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// Javascript.
|
||||
ui_require_jquery_file('pandora');
|
||||
// CSS.
|
||||
ui_require_css_file('wizard');
|
||||
ui_require_css_file('discovery');
|
||||
|
||||
$this->createBlock();
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
// Only in case of Metaconsole, format the frame.
|
||||
open_meta_frame();
|
||||
}
|
||||
|
||||
// Datatables list.
|
||||
try {
|
||||
$columns = [
|
||||
'name',
|
||||
'dir',
|
||||
'description',
|
||||
'actions',
|
||||
];
|
||||
|
||||
$column_names = [
|
||||
__('Name'),
|
||||
__('Dir'),
|
||||
__('Description'),
|
||||
__('Actions'),
|
||||
];
|
||||
|
||||
$this->tableId = 'satellite_collections';
|
||||
|
||||
// Load datatables user interface.
|
||||
ui_print_datatable(
|
||||
[
|
||||
'id' => $this->tableId,
|
||||
'class' => 'info_table',
|
||||
'style' => 'width: 100%',
|
||||
'columns' => $columns,
|
||||
'column_names' => $column_names,
|
||||
'ajax_url' => $this->ajaxController,
|
||||
'ajax_data' => [
|
||||
'method' => 'draw',
|
||||
'server_remote' => $this->satellite_server,
|
||||
],
|
||||
'ajax_postprocces' => 'process_datatables_item(item)',
|
||||
'no_sortable_columns' => [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
],
|
||||
'search_button_class' => 'sub filter float-right',
|
||||
'form' => [
|
||||
'inputs' => [
|
||||
[
|
||||
'label' => __('Search'),
|
||||
'type' => 'text',
|
||||
'name' => 'filter_search',
|
||||
'size' => 12,
|
||||
],
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
// Close the frame.
|
||||
close_meta_frame();
|
||||
}
|
||||
|
||||
echo '<div id="aux" class="invisible"></div>';
|
||||
echo '<div id="msg" class="invisible"></div>';
|
||||
|
||||
// Load own javascript file.
|
||||
echo $this->loadJS();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the data for draw the table.
|
||||
*
|
||||
* @return void.
|
||||
*/
|
||||
public function draw()
|
||||
{
|
||||
global $config;
|
||||
|
||||
// Init data.
|
||||
$data = [];
|
||||
// Count of total records.
|
||||
$count = 0;
|
||||
// Catch post parameters.
|
||||
$start = get_parameter('start', 0);
|
||||
$length = get_parameter('length', $config['block_size']);
|
||||
$order = get_datatable_order(true);
|
||||
$filters = get_parameter('filter', []);
|
||||
|
||||
try {
|
||||
ob_start();
|
||||
|
||||
// Gets all collections (database).
|
||||
$collections = collection_get_collections(null, $filters['filter_search']);
|
||||
if (empty($collections) === false) {
|
||||
$data = $collections;
|
||||
}
|
||||
|
||||
// All satellite conf collections.
|
||||
foreach ($this->satellite_config as $line) {
|
||||
$regex = '/^file_collection\s(\S+)/m';
|
||||
|
||||
if (preg_match($regex, $line, $matches, PREG_OFFSET_CAPTURE, 0) > 0) {
|
||||
$key = array_search($matches[1][0], array_column($data, 'short_name'));
|
||||
if ($key !== false) {
|
||||
$data[$key]['delete'] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($data) === false) {
|
||||
$data = array_reduce(
|
||||
$data,
|
||||
function ($carry, $item) {
|
||||
// Transforms array of arrays $data into an array
|
||||
// of objects, making a post-process of certain fields.
|
||||
$tmp = (object) $item;
|
||||
|
||||
$delete = (int) isset($tmp->delete);
|
||||
|
||||
$tmp->dir = $tmp->short_name;
|
||||
|
||||
$tmp->actions = '';
|
||||
$tmp->actions .= html_print_image(
|
||||
($delete === 0) ? 'images/add.png' : 'images/cross.png',
|
||||
true,
|
||||
[
|
||||
'border' => '0',
|
||||
'class' => 'action_button_img mrgn_lft_05em invert_filter',
|
||||
'onclick' => ($delete === 0)
|
||||
? 'add_collection(\''.$tmp->short_name.'\')'
|
||||
: 'delete_collection(\''.$tmp->short_name.'\')',
|
||||
]
|
||||
);
|
||||
|
||||
$carry[] = $tmp;
|
||||
return $carry;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($data) === true) {
|
||||
$total = 0;
|
||||
$data = [];
|
||||
} else {
|
||||
$total = count($data);
|
||||
$data = array_slice($data, $start, $length, false);
|
||||
}
|
||||
|
||||
echo json_encode(
|
||||
[
|
||||
'data' => $data,
|
||||
'recordsTotal' => $total,
|
||||
'recordsFiltered' => $total,
|
||||
]
|
||||
);
|
||||
// Capture output.
|
||||
$response = ob_get_clean();
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['error' => $e->getMessage()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// If not valid, show error with issue.
|
||||
json_decode($response);
|
||||
if (json_last_error() === JSON_ERROR_NONE) {
|
||||
// If valid dump.
|
||||
echo $response;
|
||||
} else {
|
||||
echo json_encode(
|
||||
['error' => $response]
|
||||
);
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add collection to satellite conf.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addCollection()
|
||||
{
|
||||
$short_name = get_parameter('short_name');
|
||||
|
||||
if ($this->parseSatelliteConf('add', $short_name) === false) {
|
||||
$this->ajaxMsg('error', __('Error adding collection'));
|
||||
} else {
|
||||
$this->ajaxMsg('result', _('Collection '.$short_name.' added.'));
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete collection to satellite conf.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteCollection()
|
||||
{
|
||||
$short_name = get_parameter('short_name');
|
||||
|
||||
if ($this->parseSatelliteConf('delete', $short_name) === false) {
|
||||
$this->ajaxMsg('error', __('Error deleting collection'));
|
||||
} else {
|
||||
$this->ajaxMsg('result', _('Collection '.$short_name.' deleted.'));
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse satellite configuration .
|
||||
*
|
||||
* @param string $action Action to perform (add, delete).
|
||||
* @param string $short_name Short name.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
private function parseSatelliteConf(string $action, string $short_name)
|
||||
{
|
||||
switch ($action) {
|
||||
case 'delete':
|
||||
$pos = preg_grep('/^file_collection '.$short_name.'/', $this->satellite_config);
|
||||
if (empty($pos) === false) {
|
||||
$key_pos = 0;
|
||||
foreach ($pos as $key => $value) {
|
||||
$key_pos = $key;
|
||||
break;
|
||||
}
|
||||
|
||||
unset($this->satellite_config[$key_pos]);
|
||||
}
|
||||
|
||||
$conf = implode('', $this->satellite_config);
|
||||
break;
|
||||
|
||||
default:
|
||||
case 'add':
|
||||
$pos = preg_grep('/^file_collection/', $this->satellite_config);
|
||||
if (empty($pos) === false) {
|
||||
$string_collection = 'file_collection '.$short_name."\n";
|
||||
|
||||
$key_pos = array_keys($pos)[(count($pos) - 1)];
|
||||
$array1 = array_slice($this->satellite_config, 0, ($key_pos + 1));
|
||||
$array2 = array_slice($this->satellite_config, ($key_pos + 1));
|
||||
$array_merge = array_merge($array1, [$string_collection], $array2);
|
||||
$this->satellite_config = $array_merge;
|
||||
|
||||
// Check config.
|
||||
if (empty($this->satellite_config) === true) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$pos = preg_grep('/^\#\sFile\scollections/', $this->satellite_config);
|
||||
$string_collection = 'file_collection '.$short_name."\n";
|
||||
|
||||
$key_pos = 0;
|
||||
foreach ($pos as $key => $value) {
|
||||
$key_pos = $key;
|
||||
break;
|
||||
}
|
||||
|
||||
$key_pos++;
|
||||
|
||||
$array1 = array_slice($this->satellite_config, 0, $key_pos);
|
||||
$array2 = array_slice($this->satellite_config, $key_pos);
|
||||
// Add collection to conf.
|
||||
$array_merge = array_merge($array1, [$string_collection], $array2);
|
||||
$this->satellite_config = $array_merge;
|
||||
|
||||
// Check config.
|
||||
if (empty($this->satellite_config) === true) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$conf = implode('', $this->satellite_config);
|
||||
break;
|
||||
}
|
||||
|
||||
return $this->saveAgent($conf);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Saves agent to satellite cofiguration file.
|
||||
*
|
||||
* @param string $new_conf Config file.
|
||||
*
|
||||
* @return boolean|void
|
||||
*/
|
||||
private function saveAgent(string $new_conf)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (empty($new_conf) === true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
db_pandora_audit(
|
||||
AUDIT_LOG_SYSTEM,
|
||||
'Update remote config for server '.$this->satellite_name
|
||||
);
|
||||
|
||||
// Convert to config file encoding.
|
||||
$encoding = config_satellite_get_encoding($new_conf);
|
||||
if ($encoding !== false) {
|
||||
$converted_server_config = mb_convert_encoding($new_conf, $encoding, 'UTF-8');
|
||||
if ($converted_server_config !== false) {
|
||||
$new_conf = $converted_server_config;
|
||||
}
|
||||
}
|
||||
|
||||
// Get filenames.
|
||||
if ($this->satellite_server !== false) {
|
||||
$files = config_satellite_get_satellite_config_filenames($this->satellite_name);
|
||||
} else {
|
||||
$files = [];
|
||||
$files['conf'] = $config['remote_config'].'/conf/'.md5($this->satellite_name).'.srv.conf';
|
||||
$files['md5'] = $config['remote_config'].'/md5/'.md5($this->satellite_name).'.srv.md5';
|
||||
}
|
||||
|
||||
// Save configuration.
|
||||
$result = file_put_contents($files['conf'], $new_conf);
|
||||
|
||||
if ($result === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Save configuration md5.
|
||||
$result = file_put_contents($files['md5'], md5($new_conf));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if target method is available to be called using AJAX.
|
||||
*
|
||||
* @param string $method Target method.
|
||||
*
|
||||
* @return boolean True allowed, false not.
|
||||
*/
|
||||
public function ajaxMethod(string $method)
|
||||
{
|
||||
return in_array($method, $this->AJAXMethods);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Minor function to dump json message as ajax response.
|
||||
*
|
||||
* @param string $type Type: result || error.
|
||||
* @param string $msg Message.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function ajaxMsg(string $type, string $msg)
|
||||
{
|
||||
if ($type === 'error') {
|
||||
echo json_encode(
|
||||
[
|
||||
$type => ui_print_error_message(
|
||||
__($msg),
|
||||
'',
|
||||
true
|
||||
),
|
||||
]
|
||||
);
|
||||
} else {
|
||||
echo json_encode(
|
||||
[
|
||||
$type => ui_print_success_message(
|
||||
__($msg),
|
||||
'',
|
||||
true
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create file_collections blocks
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function createBlock()
|
||||
{
|
||||
$init = preg_grep('/^\#\sFile\scollections/', $this->satellite_config);
|
||||
|
||||
if (empty($init) === true) {
|
||||
$collection = "# File collections\n";
|
||||
|
||||
array_push($this->satellite_config, "\n");
|
||||
array_push($this->satellite_config, $collection);
|
||||
array_push($this->satellite_config, "\n");
|
||||
|
||||
$conf = implode('', $this->satellite_config);
|
||||
$this->saveAgent($conf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load Javascript code.
|
||||
*
|
||||
* @return string.
|
||||
*/
|
||||
public function loadJS()
|
||||
{
|
||||
// Nothing for this moment.
|
||||
ob_start();
|
||||
|
||||
// Javascript content.
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
/**
|
||||
* Add collection.
|
||||
*/
|
||||
function add_collection(short_name) {
|
||||
$('#aux').empty();
|
||||
$('#aux').text('<?php echo __('Are you sure?'); ?>');
|
||||
$('#aux').dialog({
|
||||
title: '<?php echo __('Add collection'); ?>',
|
||||
buttons: [{
|
||||
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel',
|
||||
text: '<?php echo __('Cancel'); ?>',
|
||||
click: function(e) {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Add',
|
||||
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next',
|
||||
click: function(e) {
|
||||
$.ajax({
|
||||
method: 'post',
|
||||
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
|
||||
data: {
|
||||
page: 'enterprise/godmode/servers/collections_satellite',
|
||||
method: 'addCollection',
|
||||
short_name: short_name,
|
||||
server_remote: <?php echo $this->satellite_server; ?>,
|
||||
},
|
||||
datatype: "json",
|
||||
success: function(data) {
|
||||
console.log(data);
|
||||
showMsg(data);
|
||||
},
|
||||
error: function(e) {
|
||||
showMsg(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete collection.
|
||||
*/
|
||||
function delete_collection(short_name) {
|
||||
$('#aux').empty();
|
||||
$('#aux').text('<?php echo __('Are you sure?'); ?>');
|
||||
$('#aux').dialog({
|
||||
title: '<?php echo __('Delete collection'); ?>',
|
||||
buttons: [{
|
||||
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel',
|
||||
text: '<?php echo __('Cancel'); ?>',
|
||||
click: function(e) {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Delete',
|
||||
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next',
|
||||
click: function(e) {
|
||||
$.ajax({
|
||||
method: 'post',
|
||||
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
|
||||
data: {
|
||||
page: 'enterprise/godmode/servers/collections_satellite',
|
||||
method: 'deleteCollection',
|
||||
short_name: short_name,
|
||||
server_remote: <?php echo $this->satellite_server; ?>,
|
||||
},
|
||||
datatype: "json",
|
||||
success: function(data) {
|
||||
console.log(data);
|
||||
showMsg(data);
|
||||
},
|
||||
error: function(e) {
|
||||
showMsg(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Process ajax responses and shows a dialog with results.
|
||||
*/
|
||||
function showMsg(data) {
|
||||
var title = "<?php echo __('Success'); ?>";
|
||||
var dt_satellite_agents = $("#satellite_collections").DataTable();
|
||||
dt_<?php echo $this->tableId; ?>.draw(false);
|
||||
|
||||
var text = '';
|
||||
var failed = 0;
|
||||
try {
|
||||
data = JSON.parse(data);
|
||||
text = data['result'];
|
||||
} catch (err) {
|
||||
title = "<?php echo __('Failed'); ?>";
|
||||
text = err.message;
|
||||
failed = 1;
|
||||
}
|
||||
if (!failed && data['error'] != undefined) {
|
||||
title = "<?php echo __('Failed'); ?>";
|
||||
text = data['error'];
|
||||
failed = 1;
|
||||
}
|
||||
if (data['report'] != undefined) {
|
||||
data['report'].forEach(function (item){
|
||||
text += '<br>'+item;
|
||||
});
|
||||
}
|
||||
|
||||
$('#msg').empty();
|
||||
$('#msg').html(text);
|
||||
$('#msg').dialog({
|
||||
width: 450,
|
||||
position: {
|
||||
my: 'center',
|
||||
at: 'center',
|
||||
of: window,
|
||||
collision: 'fit'
|
||||
},
|
||||
title: title,
|
||||
buttons: [
|
||||
{
|
||||
class: "ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
|
||||
text: 'OK',
|
||||
click: function(e) {
|
||||
if (!failed) {
|
||||
$(".ui-dialog-content").dialog("close");
|
||||
$('.info').hide();
|
||||
} else {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
// EOF Javascript content.
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -537,7 +537,7 @@ class TreeService extends Tree
|
||||
if (empty($title) === true) {
|
||||
$tmp['title'] = '';
|
||||
} else {
|
||||
$tmp['title'] = $title.'/';
|
||||
$tmp['title'] = io_safe_output($title).'/';
|
||||
}
|
||||
|
||||
$tmp['title'] .= $service->name();
|
||||
|
@ -20,7 +20,7 @@
|
||||
/**
|
||||
* Pandora build version and version
|
||||
*/
|
||||
$build_version = 'PC221017';
|
||||
$build_version = 'PC221103';
|
||||
$pandora_version = 'v7.0NG.765';
|
||||
|
||||
// Do not overwrite default timezone set if defined.
|
||||
|
@ -45,6 +45,11 @@ define('EVENT_VALIDATE', 1);
|
||||
define('EVENT_PROCESS', 2);
|
||||
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.
|
||||
define('AGENT_ENABLED', 0);
|
||||
|
@ -359,10 +359,12 @@ function mysql_db_get_all_rows_in_table($table, $order_field='', $order='ASC')
|
||||
*
|
||||
* @return mixed False in case of error or invalid values passed. Affected rows otherwise
|
||||
*/
|
||||
function mysql_db_process_sql_insert($table, $values)
|
||||
function mysql_db_process_sql_insert($table, $values, $sqltostring=false)
|
||||
{
|
||||
// Empty rows or values not processed
|
||||
if (empty($values)) {
|
||||
global $config;
|
||||
|
||||
// Empty rows or values not processed.
|
||||
if (empty($values) === true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -374,7 +376,7 @@ function mysql_db_process_sql_insert($table, $values)
|
||||
$i = 1;
|
||||
$max = count($values);
|
||||
foreach ($values as $field => $value) {
|
||||
// Add the correct escaping to values
|
||||
// Add the correct escaping to values.
|
||||
if ($field[0] != '`') {
|
||||
$field = '`'.$field.'`';
|
||||
}
|
||||
@ -402,7 +404,30 @@ function mysql_db_process_sql_insert($table, $values)
|
||||
|
||||
$query .= ' VALUES ('.$values_str.')';
|
||||
|
||||
return db_process_sql($query, 'insert_id');
|
||||
$values_insert = [];
|
||||
if (enterprise_hook('is_metaconsole') === true
|
||||
&& isset($config['centralized_management']) === true
|
||||
&& (bool) $config['centralized_management'] === true
|
||||
) {
|
||||
$values_insert = [
|
||||
'table' => $table,
|
||||
'values' => $values,
|
||||
];
|
||||
}
|
||||
|
||||
if ($sqltostring === true) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
return db_process_sql(
|
||||
$query,
|
||||
'insert_id',
|
||||
'',
|
||||
true,
|
||||
$status,
|
||||
true,
|
||||
$values_insert
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3487,12 +3487,13 @@ function agents_get_agent_custom_field($agent_id, $custom_field_name)
|
||||
/**
|
||||
* Unverified documentation.
|
||||
*
|
||||
* @param integer $id_group Module group.
|
||||
* @param array $id_agents Array of agent ids.
|
||||
* @param boolean $selection Show common (false) or all modules (true).
|
||||
* @param boolean $return Return (false) or dump to output (true).
|
||||
* @param boolean $index_by_name Use module name as key.
|
||||
* @param boolean $pure_return Return as retrieved from DB.
|
||||
* @param integer $id_group Module group.
|
||||
* @param array $id_agents Array of agent ids.
|
||||
* @param boolean $selection Show common (false) or all modules (true).
|
||||
* @param boolean $return Return (false) or dump to output (true).
|
||||
* @param boolean $index_by_name Use module name as key.
|
||||
* @param boolean $pure_return Return as retrieved from DB.
|
||||
* @param boolean $notStringModules Not string modules.
|
||||
*
|
||||
* @return array With modules or null if error.
|
||||
*/
|
||||
@ -3502,7 +3503,8 @@ function select_modules_for_agent_group(
|
||||
$selection,
|
||||
$return=true,
|
||||
$index_by_name=false,
|
||||
$pure_return=false
|
||||
$pure_return=false,
|
||||
$notStringModules=false
|
||||
) {
|
||||
global $config;
|
||||
$agents = (empty($id_agents)) ? [] : implode(',', $id_agents);
|
||||
@ -3510,6 +3512,7 @@ function select_modules_for_agent_group(
|
||||
$filter_agent_group = '';
|
||||
$filter_group = '';
|
||||
$filter_agent = '';
|
||||
$filter_not_string_modules = '';
|
||||
$selection_filter = '';
|
||||
$sql_conditions_tags = '';
|
||||
$sql_tags_inner = '';
|
||||
@ -3524,6 +3527,23 @@ function select_modules_for_agent_group(
|
||||
$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')) {
|
||||
$group_string = implode(',', $groups);
|
||||
$filter_agent_group = " AND (
|
||||
@ -3567,6 +3587,7 @@ function select_modules_for_agent_group(
|
||||
$filter_agent_group
|
||||
$filter_group
|
||||
$filter_agent
|
||||
$filter_not_string_modules
|
||||
$sql_conditions_tags
|
||||
) x
|
||||
GROUP BY nombre
|
||||
|
@ -7673,8 +7673,7 @@ function api_set_planned_downtimes_delete_agents($id, $thrash1, $other, $thrash3
|
||||
}
|
||||
|
||||
if (!empty($other['data'][0])) {
|
||||
$agents = io_safe_input($other['data']);
|
||||
$agents = explode(';', $agents);
|
||||
$agents = $other['data'];
|
||||
$results = false;
|
||||
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) {
|
||||
@ -7750,8 +7749,7 @@ function api_set_planned_downtimes_add_agents($id, $thrash1, $other, $thrash3)
|
||||
}
|
||||
|
||||
if (!empty($other['data'][0])) {
|
||||
$agents = io_safe_input($other['data']);
|
||||
$agents = explode(';', $agents);
|
||||
$agents = $other['data'];
|
||||
$results = false;
|
||||
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) {
|
||||
@ -10137,7 +10135,7 @@ function api_set_module_data($id, $thrash2, $other, $trash1)
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -11248,7 +11246,7 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
|
||||
$id_user_ack = 0;
|
||||
$event_view_hr = 0;
|
||||
$tag = '';
|
||||
$group_rep = 0;
|
||||
$group_rep = EVENT_GROUP_REP_ALL;
|
||||
$utimestamp_upper = 0;
|
||||
$utimestamp_bottom = 0;
|
||||
$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';
|
||||
}
|
||||
|
||||
if ($group_rep == 0) {
|
||||
if ($group_rep == EVENT_GROUP_REP_ALL) {
|
||||
if ($filter['total']) {
|
||||
$sql = 'SELECT COUNT(*)
|
||||
FROM '.$table_events.'
|
||||
@ -13173,7 +13171,7 @@ function api_set_create_event($id, $trash1, $other, $returnType)
|
||||
if ($other['data'][7] != '') {
|
||||
$values['id_agentmodule'] = $other['data'][7];
|
||||
} else {
|
||||
$value['id_agentmodule'] = 0;
|
||||
$values['id_agentmodule'] = 0;
|
||||
}
|
||||
|
||||
if ($other['data'][8] != '') {
|
||||
@ -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;
|
||||
|
||||
$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';
|
||||
|
||||
@ -16151,7 +16149,7 @@ function api_set_update_event_filter($id_event_filter, $thrash1, $other, $thrash
|
||||
break;
|
||||
|
||||
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;
|
||||
|
||||
case 12:
|
||||
|
@ -515,6 +515,10 @@ function config_update_config()
|
||||
if (config_update_value('reset_pass_option', (bool) get_parameter('reset_pass_option'), true) === false) {
|
||||
$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;
|
||||
|
||||
@ -608,10 +612,14 @@ function config_update_config()
|
||||
$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');
|
||||
}
|
||||
|
||||
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) {
|
||||
$error_update[] = __('Secondary LDAP server');
|
||||
}
|
||||
@ -640,7 +648,7 @@ function config_update_config()
|
||||
$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');
|
||||
}
|
||||
|
||||
@ -909,6 +917,16 @@ function config_update_config()
|
||||
$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');
|
||||
switch ($pjs) {
|
||||
case $config['phantomjs_cache_interval']:
|
||||
@ -1549,6 +1567,10 @@ function config_update_config()
|
||||
$error_update[] = __('Enable history event');
|
||||
}
|
||||
|
||||
if (config_update_value('history_trap_enabled', get_parameter('history_trap_enabled'), true) === false) {
|
||||
$error_update[] = __('Enable history trap');
|
||||
}
|
||||
|
||||
if (config_update_value('history_db_user', get_parameter('history_db_user'), true) === false) {
|
||||
$error_update[] = __('Database user');
|
||||
}
|
||||
@ -1570,9 +1592,10 @@ function config_update_config()
|
||||
}
|
||||
|
||||
$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
|
||||
|| 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');
|
||||
}
|
||||
@ -1585,6 +1608,22 @@ function config_update_config()
|
||||
$error_update[] = __('Event Days');
|
||||
}
|
||||
|
||||
$history_trap_days = get_parameter('history_trap_days');
|
||||
if (is_numeric($history_trap_days) === false
|
||||
|| $history_trap_days <= 0
|
||||
|| config_update_value('history_trap_days', $history_trap_days) === false
|
||||
) {
|
||||
$error_update[] = __('Trap Days');
|
||||
}
|
||||
|
||||
$trap_history_purge = get_parameter('history_traps_days_purge');
|
||||
if (is_numeric($trap_history_purge) === false
|
||||
|| $trap_history_purge <= 0
|
||||
|| config_update_value('trap_history_purge', $trap_history_purge) === false
|
||||
) {
|
||||
$error_update[] = __('Trap history purge');
|
||||
}
|
||||
|
||||
$history_db_step = get_parameter('history_db_step');
|
||||
if (!is_numeric($history_db_step)
|
||||
|| $history_db_step <= 0
|
||||
@ -1649,6 +1688,14 @@ function config_update_config()
|
||||
$error_update[] = __('Historical database events purge');
|
||||
}
|
||||
|
||||
if ($dbm->setConfigToken(
|
||||
'trap_history_purge',
|
||||
get_parameter('history_traps_days_purge')
|
||||
) !== true
|
||||
) {
|
||||
$error_update[] = __('Historical database traps purge');
|
||||
}
|
||||
|
||||
if ($dbm->setConfigToken(
|
||||
'string_purge',
|
||||
get_parameter('history_dbh_string_purge')
|
||||
@ -1836,7 +1883,7 @@ function config_update_config()
|
||||
$config['error_config_update_config']['correct'] = false;
|
||||
$values = implode('<br> -', $error_update);
|
||||
$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
|
||||
);
|
||||
|
||||
@ -2184,6 +2231,10 @@ function config_process_config()
|
||||
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'])) {
|
||||
config_update_value('include_agents', 0);
|
||||
}
|
||||
@ -2244,6 +2295,32 @@ function config_process_config()
|
||||
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
|
||||
*/
|
||||
@ -2479,6 +2556,10 @@ function config_process_config()
|
||||
config_update_value('history_event_enabled', false);
|
||||
}
|
||||
|
||||
if (!isset($config['history_trap_enabled'])) {
|
||||
config_update_value('history_trap_enabled', false);
|
||||
}
|
||||
|
||||
if (!isset($config['history_db_host'])) {
|
||||
config_update_value('history_db_host', '');
|
||||
}
|
||||
@ -2515,6 +2596,14 @@ function config_process_config()
|
||||
config_update_value('history_event_days', 90);
|
||||
}
|
||||
|
||||
if (!isset($config['history_trap_days'])) {
|
||||
config_update_value('history_trap_days', 90);
|
||||
}
|
||||
|
||||
if (!isset($config['trap_history_purge'])) {
|
||||
config_update_value('trap_history_purge', 180);
|
||||
}
|
||||
|
||||
if (!isset($config['history_db_step'])) {
|
||||
config_update_value('history_db_step', 0);
|
||||
}
|
||||
@ -2660,6 +2749,10 @@ function config_process_config()
|
||||
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'])) {
|
||||
config_update_value('ldap_server_secondary', 'localhost');
|
||||
}
|
||||
|
@ -1338,30 +1338,42 @@ function db_get_cached_queries()
|
||||
* This function comes back with an array in case of SELECT
|
||||
* in case of UPDATE, DELETE etc. with affected rows
|
||||
* an empty array in case of SELECT without results
|
||||
* Queries that return data will be cached so queries don't get repeated
|
||||
* Queries that return data will be cached so queries don't get repeated.
|
||||
*
|
||||
* @param string SQL statement to execute
|
||||
* @param string $sql SQL statement to execute.
|
||||
* @param string $rettype What type of info to return in case of INSERT/UPDATE.
|
||||
* 'affected_rows' will return mysql_affected_rows (default value)
|
||||
* 'insert_id' will return the ID of an autoincrement value
|
||||
* 'info' will return the full (debug) information of a query.
|
||||
* @param string $dbconnection Info conecction.
|
||||
* @param boolean $cache Cache.
|
||||
* @param string $status The status and type of query (support only postgreSQL).
|
||||
* @param boolean $autocommit Set autocommit transaction mode true/false (Only oracle).
|
||||
* @param array $values Values (Only type insert).
|
||||
*
|
||||
* @param string What type of info to return in case of INSERT/UPDATE.
|
||||
* 'affected_rows' will return mysql_affected_rows (default value)
|
||||
* 'insert_id' will return the ID of an autoincrement value
|
||||
* 'info' will return the full (debug) information of a query
|
||||
*
|
||||
* @param string $status The status and type of query (support only postgreSQL).
|
||||
*
|
||||
* @param boolean $autocommit (Only oracle) Set autocommit transaction mode true/false
|
||||
*
|
||||
* @return mixed An array with the rows, columns and values in a multidimensional array or false in error
|
||||
* @return mixed An array with the rows, columns and values in a multidimensional array or false in error.
|
||||
*/
|
||||
function db_process_sql($sql, $rettype='affected_rows', $dbconnection='', $cache=true, &$status=null, $autocommit=true)
|
||||
{
|
||||
function db_process_sql(
|
||||
$sql,
|
||||
$rettype='affected_rows',
|
||||
$dbconnection='',
|
||||
$cache=true,
|
||||
&$status=null,
|
||||
$autocommit=true,
|
||||
$values_insert=[]
|
||||
) {
|
||||
global $config;
|
||||
|
||||
$rc = false;
|
||||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
default:
|
||||
$rc = @mysql_db_process_sql($sql, $rettype, $dbconnection, $cache);
|
||||
$rc = @mysql_db_process_sql(
|
||||
$sql,
|
||||
$rettype,
|
||||
$dbconnection,
|
||||
$cache
|
||||
);
|
||||
break;
|
||||
|
||||
case 'postgresql':
|
||||
@ -1373,7 +1385,13 @@ function db_process_sql($sql, $rettype='affected_rows', $dbconnection='', $cache
|
||||
break;
|
||||
}
|
||||
|
||||
db_sync($dbconnection, $sql, $rc);
|
||||
db_sync(
|
||||
$dbconnection,
|
||||
$sql,
|
||||
$rc,
|
||||
$rettype,
|
||||
$values_insert
|
||||
);
|
||||
|
||||
return $rc;
|
||||
}
|
||||
@ -1388,8 +1406,13 @@ function db_process_sql($sql, $rettype='affected_rows', $dbconnection='', $cache
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function db_sync($dbconnection, $sql, $rc)
|
||||
{
|
||||
function db_sync(
|
||||
$dbconnection,
|
||||
$sql,
|
||||
$rc,
|
||||
$rettype='affected_rows',
|
||||
$values_insert=[]
|
||||
) {
|
||||
global $config;
|
||||
if (enterprise_hook('is_metaconsole') === true
|
||||
&& isset($config['centralized_management']) === true
|
||||
@ -1401,6 +1424,16 @@ function db_sync($dbconnection, $sql, $rc)
|
||||
// Synchronize changes to nodes if needed.
|
||||
$sync = new Synchronizer();
|
||||
if ($sync !== null) {
|
||||
if ($rettype === 'insert_id') {
|
||||
$forceSql = $sync->updateInsertQueryAddPrimaryKey(
|
||||
$values_insert,
|
||||
$rc
|
||||
);
|
||||
if (empty($forceSql) === false) {
|
||||
$sql = $forceSql;
|
||||
}
|
||||
}
|
||||
|
||||
if ($sync->queue($sql, $rc) === false) {
|
||||
// Launch events per failed query.
|
||||
$errors = $sync->getLatestErrors();
|
||||
@ -1696,13 +1729,13 @@ function db_process_delete_temp($table, $row, $value, $custom_value=false)
|
||||
*
|
||||
* @return mixed False in case of error or invalid values passed. Affected rows otherwise
|
||||
*/
|
||||
function db_process_sql_insert($table, $values, $autocommit=true)
|
||||
function db_process_sql_insert($table, $values, $autocommit=true, $sqltostring=false)
|
||||
{
|
||||
global $config;
|
||||
|
||||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
return mysql_db_process_sql_insert($table, $values);
|
||||
return mysql_db_process_sql_insert($table, $values, $sqltostring);
|
||||
|
||||
break;
|
||||
case 'postgresql':
|
||||
|
@ -382,14 +382,14 @@ function events_delete($id_evento, $filter=null, $history=false, $force_node=fal
|
||||
}
|
||||
|
||||
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']) {
|
||||
case '0':
|
||||
case '2':
|
||||
case EVENT_GROUP_REP_ALL:
|
||||
case EVENT_GROUP_REP_AGENTS:
|
||||
default:
|
||||
// No groups option direct update.
|
||||
$delete_sql = sprintf(
|
||||
@ -399,7 +399,8 @@ function events_delete($id_evento, $filter=null, $history=false, $force_node=fal
|
||||
);
|
||||
break;
|
||||
|
||||
case '1':
|
||||
case EVENT_GROUP_REP_EVENTS:
|
||||
case EVENT_GROUP_REP_EXTRAIDS:
|
||||
// Group by events.
|
||||
$sql = events_get_all(
|
||||
['te.*'],
|
||||
@ -418,8 +419,16 @@ function events_delete($id_evento, $filter=null, $history=false, $force_node=fal
|
||||
true
|
||||
);
|
||||
|
||||
$target_ids = db_get_all_rows_sql(
|
||||
sprintf(
|
||||
if ((int) $filter['group_rep'] === EVENT_GROUP_REP_EXTRAIDS) {
|
||||
$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
|
||||
ON tu.estado = tf.estado
|
||||
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',
|
||||
$sql,
|
||||
$id_evento
|
||||
)
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
$target_ids = db_get_all_rows_sql($sql);
|
||||
|
||||
// Try to avoid deadlock while updating full set.
|
||||
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) {
|
||||
$filter = ['group_rep' => 0];
|
||||
$filter = ['group_rep' => EVENT_GROUP_REP_ALL];
|
||||
}
|
||||
|
||||
switch ($filter['group_rep']) {
|
||||
case '0':
|
||||
case '2':
|
||||
case EVENT_GROUP_REP_ALL:
|
||||
case EVENT_GROUP_REP_AGENTS:
|
||||
default:
|
||||
// No groups option direct update.
|
||||
$update_sql = sprintf(
|
||||
@ -492,7 +503,8 @@ function events_update_status($id_evento, $status, $filter=null)
|
||||
);
|
||||
break;
|
||||
|
||||
case '1':
|
||||
case EVENT_GROUP_REP_EVENTS:
|
||||
case EVENT_GROUP_REP_EXTRAIDS:
|
||||
// Group by events.
|
||||
$sql = events_get_all(
|
||||
['te.*'],
|
||||
@ -511,8 +523,16 @@ function events_update_status($id_evento, $status, $filter=null)
|
||||
true
|
||||
);
|
||||
|
||||
$target_ids = db_get_all_rows_sql(
|
||||
sprintf(
|
||||
if ((int) $filter['group_rep'] === EVENT_GROUP_REP_EXTRAIDS) {
|
||||
$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
|
||||
ON tu.estado = tf.estado
|
||||
AND tu.evento = tf.evento
|
||||
@ -521,8 +541,10 @@ function events_update_status($id_evento, $status, $filter=null)
|
||||
AND tf.max_id_evento = %d',
|
||||
$sql,
|
||||
$id_evento
|
||||
)
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
$target_ids = db_get_all_rows_sql($sql);
|
||||
|
||||
// Try to avoid deadlock while updating full set.
|
||||
if ($target_ids !== false && count($target_ids) > 0) {
|
||||
@ -627,6 +649,7 @@ function events_update_status($id_evento, $status, $filter=null)
|
||||
* 'tag_without'
|
||||
* 'filter_only_alert'
|
||||
* 'search_secondary_groups'
|
||||
* 'search_recursive_groups'
|
||||
* 'module_search'
|
||||
* 'group_rep'
|
||||
* 'server_id'
|
||||
@ -864,7 +887,10 @@ function events_get_all(
|
||||
if (isset($groups) === true
|
||||
&& (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.
|
||||
$children = [];
|
||||
if (is_array($groups) === true) {
|
||||
@ -1363,7 +1389,10 @@ function events_get_all(
|
||||
// Order.
|
||||
$order_by = '';
|
||||
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);
|
||||
} else {
|
||||
$order_by = events_get_sql_order($sort_field, $order);
|
||||
@ -1397,22 +1426,22 @@ function events_get_all(
|
||||
$group_by = 'GROUP BY ';
|
||||
$tagente_join = 'LEFT';
|
||||
if (isset($filter['group_rep']) === false) {
|
||||
$filter['group_rep'] = 0;
|
||||
$filter['group_rep'] = EVENT_GROUP_REP_ALL;
|
||||
}
|
||||
|
||||
switch ($filter['group_rep']) {
|
||||
case '0':
|
||||
case EVENT_GROUP_REP_ALL:
|
||||
default:
|
||||
// All events.
|
||||
$group_by = '';
|
||||
break;
|
||||
|
||||
case '1':
|
||||
case EVENT_GROUP_REP_EVENTS:
|
||||
// Group by events.
|
||||
$group_by .= 'te.evento, te.id_agente, te.id_agentmodule';
|
||||
break;
|
||||
|
||||
case '2':
|
||||
case EVENT_GROUP_REP_AGENTS:
|
||||
// Group by agents.
|
||||
$tagente_join = 'INNER';
|
||||
$group_by = '';
|
||||
@ -1426,6 +1455,11 @@ function events_get_all(
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
case EVENT_GROUP_REP_EXTRAIDS:
|
||||
// Group by events.
|
||||
$group_by .= 'te.id_extra';
|
||||
break;
|
||||
}
|
||||
|
||||
$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(
|
||||
'SELECT %s
|
||||
%s
|
||||
@ -1543,7 +1579,9 @@ function events_get_all(
|
||||
%s
|
||||
%s
|
||||
%s JOIN tgrupo tg
|
||||
ON %s',
|
||||
ON %s
|
||||
%s
|
||||
%s',
|
||||
join(',', $fields),
|
||||
$group_selects_trans,
|
||||
$tevento,
|
||||
@ -1572,7 +1610,8 @@ function events_get_all(
|
||||
join(' ', $agent_join_filters),
|
||||
$tgrupo_join,
|
||||
join(' ', $tgrupo_join_filters),
|
||||
join(' ', $sql_filters)
|
||||
join(' ', $sql_filters),
|
||||
$order_by
|
||||
);
|
||||
} else {
|
||||
$sql = sprintf(
|
||||
@ -2896,9 +2935,9 @@ function events_get_agent(
|
||||
|
||||
// Group by agent.
|
||||
if ((bool) $show_summary_group === true) {
|
||||
$filters['group_rep'] = 1;
|
||||
$filters['group_rep'] = EVENT_GROUP_REP_EVENTS;
|
||||
} else {
|
||||
$filters['group_rep'] = 2;
|
||||
$filters['group_rep'] = EVENT_GROUP_REP_AGENTS;
|
||||
}
|
||||
|
||||
$events = Event::search(
|
||||
@ -5167,7 +5206,7 @@ function events_get_count_events_validated_by_user($data)
|
||||
*
|
||||
* @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;
|
||||
switch ($sort_field) {
|
||||
@ -5188,7 +5227,7 @@ function events_get_sql_order($sort_field='timestamp', $sort='DESC', $group_rep=
|
||||
break;
|
||||
|
||||
case 'timestamp':
|
||||
$sort_field_translated = ($group_rep == 0) ? 'timestamp' : 'timestamp_last';
|
||||
$sort_field_translated = ($group_rep == EVENT_GROUP_REP_ALL) ? 'timestamp' : 'timestamp_last';
|
||||
break;
|
||||
|
||||
case 'user_id':
|
||||
@ -5215,6 +5254,14 @@ function events_get_sql_order($sort_field='timestamp', $sort='DESC', $group_rep=
|
||||
$sort_field_translated = 'id_extra';
|
||||
break;
|
||||
|
||||
case 'agent_name':
|
||||
$sort_field_translated = 'ta.nombre';
|
||||
break;
|
||||
|
||||
case 'module_custom_id':
|
||||
$sort_field_translated = 'am.custom_id';
|
||||
break;
|
||||
|
||||
default:
|
||||
$sort_field_translated = $sort_field;
|
||||
break;
|
||||
|
@ -4883,12 +4883,12 @@ function html_print_autocomplete_modules(
|
||||
*
|
||||
* @return string HTML code
|
||||
*/
|
||||
function html_print_timezone_select($name, $selected='')
|
||||
function html_print_timezone_select($name, $selected='', $nothing='', $nothing_value='')
|
||||
{
|
||||
$timezones_index = timezone_identifiers_list();
|
||||
$timezones = timezone_identifiers_list();
|
||||
$timezones = array_combine($timezones_index, $timezones);
|
||||
return html_print_select($timezones, $name, $selected, '', __('None'), '', true, false, false);
|
||||
$timezones = array_combine($timezones, $timezones);
|
||||
$timezones = (['' => __('none')] + $timezones);
|
||||
return html_print_select($timezones, $name, $selected, '', $nothing, $nothing_value, true, false, false);
|
||||
}
|
||||
|
||||
|
||||
@ -5749,7 +5749,9 @@ function html_print_input($data, $wrapper='div', $input_only=false)
|
||||
0,
|
||||
$data['agent_ids'],
|
||||
$data['selectionModules'],
|
||||
true
|
||||
true,
|
||||
false,
|
||||
(isset($data['notStringModules']) === true && $data['notStringModules'] === true) ? true : false
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -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 ($select_mode === true) {
|
||||
$agents = array_reduce(
|
||||
@ -3657,7 +3675,8 @@ function get_modules_agents($id_module_group, $id_agents, $selection, $select_mo
|
||||
$selection,
|
||||
false,
|
||||
$useName,
|
||||
true
|
||||
true,
|
||||
$notStringModules
|
||||
);
|
||||
|
||||
metaconsole_restore_db();
|
||||
@ -3746,7 +3765,8 @@ function get_modules_agents($id_module_group, $id_agents, $selection, $select_mo
|
||||
$selection,
|
||||
false,
|
||||
$useName,
|
||||
false
|
||||
false,
|
||||
$notStringModules
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ function profile_delete_profile_and_clean_users($id_profile)
|
||||
* @param int User id
|
||||
* @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;
|
||||
|
||||
@ -243,7 +243,23 @@ function profile_print_profile_table($id)
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -268,7 +284,12 @@ function profile_print_profile_table($id)
|
||||
if (empty($profile['tags'])) {
|
||||
$data['tags'] = '';
|
||||
} 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);
|
||||
$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['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('id_user_profile', $profile['id_up'], 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>';
|
||||
|
||||
array_push($table->data, $data);
|
||||
@ -345,8 +366,7 @@ function profile_print_profile_table($id)
|
||||
$data['actions'] .= '</form>';
|
||||
|
||||
array_push($table->data, $data);
|
||||
|
||||
html_print_table($table);
|
||||
html_print_table($table, $return);
|
||||
if (!is_metaconsole()) {
|
||||
echo '</div>';
|
||||
}
|
||||
|
@ -4011,7 +4011,7 @@ function reporting_groups_nodes($content)
|
||||
}
|
||||
|
||||
// Grouped.
|
||||
$filters['group_rep'] = 1;
|
||||
$filters['group_rep'] = EVENT_GROUP_REP_EVENTS;
|
||||
|
||||
$events = Event::search(
|
||||
[
|
||||
|
@ -1944,7 +1944,16 @@ function reporting_html_inventory($table, $item, $pdf=0)
|
||||
$table1->head[$k] = $k;
|
||||
$table1->headstyle[$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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6535,7 +6535,7 @@ function ui_print_breadcrums($tab_name)
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@ -6559,31 +6559,45 @@ function ui_print_comments($comments)
|
||||
foreach ($comments_array as $comm) {
|
||||
// Show the comments more recent first.
|
||||
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 ...
|
||||
// If $config['prominent_time'] is timestamp the date show Month, day, hour and minutes.
|
||||
// Else show comments hours ago
|
||||
if ($last_comment[0][0]['action'] != 'Added comment') {
|
||||
$last_comment[0][0]['comment'] = $last_comment[0][0]['action'];
|
||||
if ($last_comment['action'] != 'Added comment') {
|
||||
$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') {
|
||||
$comentario = '<i>'.date($config['date_format'], $last_comment[0][0]['utimestamp']).' ('.$last_comment[0][0]['id_user'].'): '.$last_comment[0][0]['comment'].'';
|
||||
$comentario = '<i>'.date($config['date_format'], $last_comment['utimestamp']).' ('.$last_comment['id_user'].'): '.$last_comment['comment'].'';
|
||||
|
||||
if (strlen($comentario) > '200px') {
|
||||
$comentario = '<i>'.date($config['date_format'], $last_comment[0][0]['utimestamp']).' ('.$last_comment[0][0]['id_user'].'): '.$short_comment.'...';
|
||||
$comentario = '<i>'.date($config['date_format'], $last_comment['utimestamp']).' ('.$last_comment['id_user'].'): '.$short_comment.'...';
|
||||
}
|
||||
} else {
|
||||
$rest_time = (time() - $last_comment[0][0]['utimestamp']);
|
||||
$rest_time = (time() - $last_comment['utimestamp']);
|
||||
$time_last = (($rest_time / 60) / 60);
|
||||
$comentario = '<i>'.number_format($time_last, 0).' Hours ('.$last_comment[0][0]['id_user'].'): '.$last_comment[0][0]['comment'].'';
|
||||
$comentario = '<i>'.number_format($time_last, 0).' Hours ('.$last_comment['id_user'].'): '.$last_comment['comment'].'';
|
||||
|
||||
if (strlen($comentario) > '200px') {
|
||||
$comentario = '<i>'.number_format($time_last, 0).' Hours ('.$last_comment[0][0]['id_user'].'): '.$short_comment.'...';
|
||||
$comentario = '<i>'.number_format($time_last, 0).' Hours ('.$last_comment['id_user'].'): '.$short_comment.'...';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -235,27 +235,31 @@ function groups_combine_acl($acl_group_a, $acl_group_b)
|
||||
}
|
||||
|
||||
$acl_list = [
|
||||
'agent_view' => 1,
|
||||
'agent_edit' => 1,
|
||||
'agent_disable' => 1,
|
||||
'alert_edit' => 1,
|
||||
'alert_management' => 1,
|
||||
'pandora_management' => 1,
|
||||
'db_management' => 1,
|
||||
'user_management' => 1,
|
||||
'report_view' => 1,
|
||||
'report_edit' => 1,
|
||||
'report_management' => 1,
|
||||
'event_view' => 1,
|
||||
'event_edit' => 1,
|
||||
'event_management' => 1,
|
||||
'map_view' => 1,
|
||||
'map_edit' => 1,
|
||||
'map_management' => 1,
|
||||
'vconsole_view' => 1,
|
||||
'vconsole_edit' => 1,
|
||||
'vconsole_management' => 1,
|
||||
'tags' => 1,
|
||||
'agent_view' => 1,
|
||||
'agent_edit' => 1,
|
||||
'agent_disable' => 1,
|
||||
'alert_edit' => 1,
|
||||
'alert_management' => 1,
|
||||
'pandora_management' => 1,
|
||||
'db_management' => 1,
|
||||
'user_management' => 1,
|
||||
'report_view' => 1,
|
||||
'report_edit' => 1,
|
||||
'report_management' => 1,
|
||||
'event_view' => 1,
|
||||
'event_edit' => 1,
|
||||
'event_management' => 1,
|
||||
'map_view' => 1,
|
||||
'map_edit' => 1,
|
||||
'map_management' => 1,
|
||||
'vconsole_view' => 1,
|
||||
'vconsole_edit' => 1,
|
||||
'vconsole_management' => 1,
|
||||
'tags' => 1,
|
||||
'network_config_view' => 1,
|
||||
'network_config_edit' => 1,
|
||||
'network_config_management' => 1,
|
||||
|
||||
];
|
||||
|
||||
foreach ($acl_group_a['tags'] as $key => $value) {
|
||||
|
@ -3708,6 +3708,8 @@ function visual_map_print_visual_map(
|
||||
|
||||
// End function
|
||||
// Start function
|
||||
|
||||
|
||||
/**
|
||||
* Get a list with the layouts for a user.
|
||||
*
|
||||
@ -3719,8 +3721,6 @@ function visual_map_print_visual_map(
|
||||
*
|
||||
* @return array A list of layouts the user can see.
|
||||
*/
|
||||
|
||||
|
||||
function visual_map_get_user_layouts(
|
||||
$id_user=0,
|
||||
$only_names=false,
|
||||
@ -3729,6 +3729,7 @@ function visual_map_get_user_layouts(
|
||||
$favourite=false,
|
||||
$check_user_groups=true
|
||||
) {
|
||||
$where = '';
|
||||
if (! is_array($filter)) {
|
||||
$filter = [];
|
||||
} else {
|
||||
@ -3819,17 +3820,19 @@ function visual_map_get_user_layouts(
|
||||
$retval[$layout['id']] = $layout;
|
||||
}
|
||||
|
||||
// add_perms
|
||||
if (isset($groups[$layout['id_group']]['vconsole_view'])) {
|
||||
$retval[$layout['id']]['vr'] = $groups[$layout['id_group']]['vconsole_view'];
|
||||
}
|
||||
if ($only_names === false) {
|
||||
// Aad_perms.
|
||||
if (isset($groups[$layout['id_group']]['vconsole_view'])) {
|
||||
$retval[$layout['id']]['vr'] = $groups[$layout['id_group']]['vconsole_view'];
|
||||
}
|
||||
|
||||
if (isset($groups[$layout['id_group']]['vconsole_edit'])) {
|
||||
$retval[$layout['id']]['vw'] = $groups[$layout['id_group']]['vconsole_edit'];
|
||||
}
|
||||
if (isset($groups[$layout['id_group']]['vconsole_edit'])) {
|
||||
$retval[$layout['id']]['vw'] = $groups[$layout['id_group']]['vconsole_edit'];
|
||||
}
|
||||
|
||||
if (isset($groups[$layout['id_group']]['vconsole_management'])) {
|
||||
$retval[$layout['id']]['vm'] = $groups[$layout['id_group']]['vconsole_management'];
|
||||
if (isset($groups[$layout['id_group']]['vconsole_management'])) {
|
||||
$retval[$layout['id']]['vm'] = $groups[$layout['id_group']]['vconsole_management'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,8 +154,10 @@ $(document).ready(function() {
|
||||
|
||||
if (selector == "search") {
|
||||
$("#search_title_result h2").append(
|
||||
"<span class='pandora_green_text'>" + search_modules + "</span>"
|
||||
"<span class='pandora_green_text' id='search_string'></span>"
|
||||
);
|
||||
|
||||
$("#search_string").text(search_modules);
|
||||
}
|
||||
|
||||
if (total_posts < 1) {
|
||||
|
@ -196,6 +196,13 @@ function agent_changed_by_multiple_agents(event, id_agent, selected) {
|
||||
serialized = "";
|
||||
}
|
||||
|
||||
var id_group = null;
|
||||
if (typeof $("#filter_group") !== "undefined") {
|
||||
try {
|
||||
id_group = $("#filter_group").val();
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
$("#module")
|
||||
.prop("disabled", true)
|
||||
.empty()
|
||||
@ -238,7 +245,8 @@ function agent_changed_by_multiple_agents(event, id_agent, selected) {
|
||||
selection_mode: selection_mode,
|
||||
serialized: serialized,
|
||||
id_server: id_server,
|
||||
status_module: module_status
|
||||
status_module: module_status,
|
||||
id_group: id_group
|
||||
},
|
||||
function(data) {
|
||||
$("#module").empty();
|
||||
@ -575,7 +583,8 @@ function module_changed_by_multiple_modules(event, id_module, selected) {
|
||||
status_module: status_module,
|
||||
"module_name[]": idModules,
|
||||
selection_mode: selection_mode,
|
||||
tags: tags_selected
|
||||
tags: tags_selected,
|
||||
id_group: id_group
|
||||
},
|
||||
function(data) {
|
||||
$("#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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1386,6 +1386,12 @@ function dashboardLoadVC(settings) {
|
||||
: "dashboard"
|
||||
);
|
||||
|
||||
if (settings.props.maintenanceMode != null) {
|
||||
if (settings.props.maintenanceMode.user !== settings.id_user) {
|
||||
visualConsoleManager.visualConsole.enableMaintenanceMode();
|
||||
}
|
||||
}
|
||||
|
||||
if (settings.mobile_view_orientation_vc === true) {
|
||||
$(window).on("orientationchange", function() {
|
||||
$(container).width($(window).height());
|
||||
@ -1536,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");
|
||||
}
|
||||
}
|
||||
|
@ -707,7 +707,7 @@ function execute_event_response(event_list_btn) {
|
||||
}
|
||||
|
||||
in_process_event(
|
||||
"events",
|
||||
"table_events",
|
||||
event_id,
|
||||
$(this).attr("event_rep"),
|
||||
this.parentElement.parentElement,
|
||||
@ -727,7 +727,7 @@ function execute_event_response(event_list_btn) {
|
||||
}
|
||||
|
||||
validate_event(
|
||||
"events",
|
||||
"table_events",
|
||||
event_id,
|
||||
$(this).attr("event_rep"),
|
||||
this.parentElement.parentElement,
|
||||
@ -747,7 +747,7 @@ function execute_event_response(event_list_btn) {
|
||||
}
|
||||
|
||||
execute_delete_event_reponse(
|
||||
"events",
|
||||
"table_events",
|
||||
event_id,
|
||||
$(this).attr("event_rep"),
|
||||
this.parentElement.parentElement,
|
||||
|
@ -13,20 +13,26 @@ function configure_modules_form() {
|
||||
$("#id_module_type").change(function() {
|
||||
if (id_modules_icmp.in_array(this.value)) {
|
||||
$(
|
||||
"tr#simple-snmp_1, tr#simple-snmp_2, tr#simple-tcp_send, tr#simple-tcp_receive"
|
||||
"tr#simple-snmp_1, tr#simple-snmp_2, tr#simple-snmp_credentials, tr#simple-tcp_send, tr#simple-tcp_receive"
|
||||
).hide();
|
||||
$("#text-tcp_port").attr("disabled", "1");
|
||||
} else if (id_modules_snmp.in_array(this.value)) {
|
||||
$("tr#simple-snmp_1, tr#simple-snmp_2").show();
|
||||
$(
|
||||
"tr#simple-snmp_1, tr#simple-snmp_2, tr#simple-snmp_credentials"
|
||||
).show();
|
||||
$("tr#simple-tcp_send, tr#simple-tcp_receive").hide();
|
||||
$("#text-tcp_port").removeAttr("disabled");
|
||||
} else if (id_modules_tcp.in_array(this.value)) {
|
||||
$("tr#simple-snmp_1, tr#simple-snmp_2").hide();
|
||||
$(
|
||||
"tr#simple-snmp_1, tr#simple-snmp_2, tr#simple-snmp_credentials"
|
||||
).hide();
|
||||
$("tr#simple-tcp_send, tr#simple-tcp_receive").show();
|
||||
$("#text-tcp_port").removeAttr("disabled");
|
||||
} else if (id_modules_exec.in_array(this.value)) {
|
||||
$("tr#simple-tcp_send, tr#simple-tcp_receive").hide();
|
||||
$("tr#simple-snmp_1, tr#simple-snmp_2").hide();
|
||||
$(
|
||||
"tr#simple-snmp_1, tr#simple-snmp_2, tr#simple-snmp_credentials"
|
||||
).hide();
|
||||
$("#text-tcp_port").attr("disabled", false);
|
||||
}
|
||||
});
|
||||
|
@ -740,3 +740,26 @@ function reveal_password(name) {
|
||||
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", "");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -117,6 +117,15 @@ function createVisualConsole(
|
||||
visualConsole.updateElements(items);
|
||||
}
|
||||
|
||||
if (
|
||||
visualConsole.props.maintenanceMode != null &&
|
||||
visualConsole.props.maintenanceMode.user !== id_user
|
||||
) {
|
||||
visualConsole.enableMaintenanceMode();
|
||||
} else {
|
||||
visualConsole.disableMaintenanceMode();
|
||||
}
|
||||
|
||||
// Emit the VC update event.
|
||||
if (onUpdate) onUpdate(prevProps, visualConsole.props);
|
||||
} catch (ignored) {} // eslint-disable-line no-empty
|
||||
@ -159,6 +168,7 @@ function createVisualConsole(
|
||||
// Initialize the Visual Console.
|
||||
try {
|
||||
visualConsole = new VisualConsole(container, props, items);
|
||||
|
||||
// VC Item clicked.
|
||||
visualConsole.onItemClick(function(e) {
|
||||
var data = e.item.props || {};
|
||||
@ -357,7 +367,6 @@ function createVisualConsole(
|
||||
})
|
||||
.init();
|
||||
});
|
||||
|
||||
// VC Item resized.
|
||||
visualConsole.onItemResized(function(e) {
|
||||
var item = e.item;
|
||||
@ -473,6 +482,11 @@ function createVisualConsole(
|
||||
updateVisualConsole(visualConsole.props.id, interval, null, dimensions);
|
||||
}
|
||||
},
|
||||
forceUpdateVisualConsole: function() {
|
||||
asyncTaskManager.cancel("visual-console");
|
||||
asyncTaskManager.cancel("visual-console-start");
|
||||
updateVisualConsole(visualConsole.props.id);
|
||||
},
|
||||
createItem: function(typeString) {
|
||||
var type;
|
||||
switch (typeString) {
|
||||
|
@ -858,11 +858,12 @@ var TreeController = {
|
||||
$content.append($statusImage);
|
||||
}
|
||||
var image_tooltip =
|
||||
'<span><img class="invert_filter" src="' +
|
||||
(controller.baseURL.length > 0 ? controller.baseURL : "") +
|
||||
'images/help.png" class="img_help" title="' +
|
||||
'<span><img class="invert_filter forced_title" data-title="' +
|
||||
(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 +
|
||||
'"/></span> ';
|
||||
|
||||
@ -883,7 +884,6 @@ var TreeController = {
|
||||
window.location.href = element.serviceDetail;
|
||||
})
|
||||
.css("cursor", "pointer");
|
||||
|
||||
$content.append($serviceDetailImage);
|
||||
$content.append(" " + image_tooltip);
|
||||
|
||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -69,7 +69,7 @@ final class Config
|
||||
$link->options(MYSQLI_OPT_CONNECT_TIMEOUT, 2);
|
||||
$rc = mysqli_real_connect(
|
||||
$link,
|
||||
$$config['history_db_host'],
|
||||
$config['history_db_host'],
|
||||
$config['history_db_user'],
|
||||
io_output_password($config['history_db_pass']),
|
||||
$config['history_db_name'],
|
||||
@ -90,29 +90,31 @@ final class Config
|
||||
}
|
||||
|
||||
ob_get_clean();
|
||||
}
|
||||
|
||||
if ($config['history_db_connection'] !== false) {
|
||||
$data = \db_get_all_rows_sql(
|
||||
'SELECT * FROM `tconfig`',
|
||||
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 (isset($config['history_db_connection']) === true
|
||||
&& $config['history_db_connection'] !== false
|
||||
) {
|
||||
$data = \db_get_all_rows_sql(
|
||||
'SELECT * FROM `tconfig`',
|
||||
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;
|
||||
},
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
@ -416,6 +416,7 @@ class Widget
|
||||
$className .= '\OsQuickReportWidget';
|
||||
break;
|
||||
|
||||
case 'GroupedMeterGraphs':
|
||||
case 'ColorModuleTabs':
|
||||
case 'BlockHistogram':
|
||||
$className .= '\\'.$name;
|
||||
|
1058
pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php
Normal file
1058
pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php
Normal file
File diff suppressed because it is too large
Load Diff
@ -710,9 +710,13 @@ class AgentModuleWidget extends Widget
|
||||
|
||||
if (empty($allModules) === false) {
|
||||
if (is_metaconsole() === true && $this->values['mShowCommonModules'] !== 'on') {
|
||||
$modules = $agent->searchModules(
|
||||
['nombre' => array_keys($reduceAllModules['modules_selected'][$tserver])]
|
||||
);
|
||||
if (isset($reduceAllModules['modules_selected'][$tserver]) === true) {
|
||||
$modules = $agent->searchModules(
|
||||
['nombre' => array_keys($reduceAllModules['modules_selected'][$tserver])]
|
||||
);
|
||||
} else {
|
||||
$modules = null;
|
||||
}
|
||||
} else {
|
||||
$modules = $agent->searchModules(
|
||||
['nombre' => array_keys($allModules)]
|
||||
|
@ -128,7 +128,7 @@ class User implements PublicLogin
|
||||
{
|
||||
$user = new self($data);
|
||||
|
||||
if ($user === null) {
|
||||
if ($user->idUser === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -188,6 +188,14 @@ class User implements PublicLogin
|
||||
$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.
|
||||
$hashCheck = self::generatePublicHash($other_secret);
|
||||
if ($hashCheck === $hash) {
|
||||
|
@ -66,7 +66,19 @@ if ($doLogin === 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 {
|
||||
db_pandora_audit(
|
||||
AUDIT_LOG_ACL_VIOLATION,
|
||||
|
@ -90,6 +90,7 @@ final class Container extends Model
|
||||
'backgroundURL' => static::extractBackgroundUrl($data),
|
||||
'relationLineWidth' => (int) $data['relationLineWidth'],
|
||||
'hash' => static::extractHash($data),
|
||||
'maintenanceMode' => static::extractMaintenanceMode($data),
|
||||
];
|
||||
}
|
||||
|
||||
@ -238,6 +239,45 @@ final class Container extends Model
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract a background color value.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return mixed String representing the color (not empty) or null.
|
||||
*/
|
||||
private static function extractMaintenanceMode(array $data)
|
||||
{
|
||||
global $config;
|
||||
$maintenance_mode = static::notEmptyStringOr(
|
||||
static::issetInArray(
|
||||
$data,
|
||||
[
|
||||
'maintenanceMode',
|
||||
'maintenance_mode',
|
||||
]
|
||||
),
|
||||
null
|
||||
);
|
||||
|
||||
$result = null;
|
||||
if ($maintenance_mode !== null) {
|
||||
$result = json_decode($maintenance_mode, true);
|
||||
|
||||
$result['date'] = date(
|
||||
$config['date_format'],
|
||||
$result['timestamp']
|
||||
);
|
||||
|
||||
$result['timestamp'] = human_time_description_raw(
|
||||
(time() - $result['timestamp'])
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract the "is favorite" switch value.
|
||||
*
|
||||
|
@ -673,6 +673,128 @@ form.modal-dashboard
|
||||
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 {
|
||||
width: 98%;
|
||||
margin-top: 5px;
|
||||
|
@ -138,6 +138,7 @@ ul.wizard li > textarea {
|
||||
.middle {
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
.edit_discovery_info {
|
||||
padding-top: 0;
|
||||
}
|
||||
@ -164,6 +165,7 @@ ul.wizard {
|
||||
align-content: baseline;
|
||||
margin-left: 2em;
|
||||
}
|
||||
|
||||
.filter_column .edit_discovery_input .label_select {
|
||||
display: inline;
|
||||
margin: 0;
|
||||
@ -204,6 +206,7 @@ li.discovery > a {
|
||||
text-decoration: none;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
li.discovery > a:hover {
|
||||
color: #000;
|
||||
}
|
||||
@ -239,21 +242,26 @@ div.data_container:hover {
|
||||
height: auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h1.wizard {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
h1.wizard a {
|
||||
margin-left: -20px;
|
||||
}
|
||||
|
||||
h1.wizard a:hover {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#text_wizard {
|
||||
font-weight: bolder;
|
||||
text-decoration: none;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
div.arrow_box {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
@ -282,6 +290,7 @@ div.arrow_box:before {
|
||||
border-width: 20px;
|
||||
margin-top: -20px;
|
||||
}
|
||||
|
||||
.arrow_box.selected:before {
|
||||
border-left-color: #424242;
|
||||
}
|
||||
@ -289,6 +298,7 @@ div.arrow_box:before {
|
||||
.arrow_box.selected:hover {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.arrow_box:hover {
|
||||
color: #000;
|
||||
}
|
||||
@ -343,6 +353,7 @@ span.breadcrumb_link {
|
||||
.breadcrumb_link.selected:hover {
|
||||
color: #95b750;
|
||||
}
|
||||
|
||||
.breadcrumb_link:hover {
|
||||
color: #95b750;
|
||||
}
|
||||
@ -387,6 +398,22 @@ label {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
li > input[type="text"],
|
||||
li > input[type="email"],
|
||||
li > input[type="password"],
|
||||
li > input[type="email"],
|
||||
.discovery_text_input > input[type="password"],
|
||||
.discovery_text_input > input[type="text"],
|
||||
#interval_manual > input[type="text"] {
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
border-bottom: 1px solid #ccc;
|
||||
padding: 0px 0px 2px 0px;
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
#interval_manual > input[type="text"] {
|
||||
width: 50px;
|
||||
margin-left: 10px;
|
||||
@ -463,13 +490,16 @@ div.ui-tooltip.ui-corner-all.ui-widget-shadow.ui-widget.ui-widget-content.uitool
|
||||
margin-left: -35px;
|
||||
bottom: -16px;
|
||||
}
|
||||
|
||||
.arrow.top {
|
||||
top: -16px;
|
||||
bottom: auto;
|
||||
}
|
||||
|
||||
.arrow.left {
|
||||
left: 50%;
|
||||
}
|
||||
|
||||
.arrow:after {
|
||||
background: grey;
|
||||
content: "";
|
||||
@ -483,6 +513,7 @@ div.ui-tooltip.ui-corner-all.ui-widget-shadow.ui-widget.ui-widget-content.uitool
|
||||
-ms-transform: rotate(45deg);
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
.arrow.top:after {
|
||||
bottom: -20px;
|
||||
top: auto;
|
||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
After Width: | Height: | Size: 50 KiB |
@ -7,6 +7,14 @@
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.is-maintenance {
|
||||
background-image: url(maintenanceMode.png) !important;
|
||||
}
|
||||
|
||||
.is-maintenance :nth-child(1) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.visual-console-item {
|
||||
position: absolute;
|
||||
display: flex;
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -546,6 +546,7 @@ if (isset($config['id_user']) === false) {
|
||||
if ((!isset($double_auth_success)
|
||||
|| !$double_auth_success)
|
||||
&& is_double_auth_enabled($nick_in_db)
|
||||
&& (bool) $config['double_auth_enabled'] === true
|
||||
) {
|
||||
// Store this values in the session to know if the user login
|
||||
// was correct.
|
||||
|
@ -129,7 +129,7 @@
|
||||
<div style='height: 10px'>
|
||||
<?php
|
||||
$version = '7.0NG.765';
|
||||
$build = '221017';
|
||||
$build = '221103';
|
||||
$banner = "v$version Build $build";
|
||||
|
||||
error_reporting(0);
|
||||
|
@ -357,10 +357,10 @@ class Events
|
||||
);
|
||||
|
||||
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) {
|
||||
$event['event_repeated'] = '<i>'.__('No').'</i>';
|
||||
} else {
|
||||
@ -1068,7 +1068,7 @@ class Events
|
||||
$filters['id_agent'] = $this->id_agent;
|
||||
}
|
||||
|
||||
$filters['group_rep'] = 1;
|
||||
$filters['group_rep'] = EVENT_GROUP_REP_EVENTS;
|
||||
|
||||
if (isset($this->limit) === true
|
||||
&& $this->limit !== -1
|
||||
|
@ -358,6 +358,7 @@ class Visualmap
|
||||
'uniq' => $uniq,
|
||||
'mobile' => true,
|
||||
'vcId' => $visualConsoleId,
|
||||
'id_user' => $config['id_user'],
|
||||
'mobile_view_orientation_vc' => (bool) !$config['mobile_view_orientation_vc'],
|
||||
]
|
||||
);
|
||||
|
@ -122,7 +122,7 @@ if ($flag_alert == 1 && check_acl($config['id_user'], $id_group, 'AW')) {
|
||||
|
||||
$idAgent = get_parameter_get('id_agente', 0);
|
||||
|
||||
// Show alerts for specific agent
|
||||
// Show alerts for specific agent.
|
||||
if ($idAgent != 0) {
|
||||
$url = $url.'&id_agente='.$idAgent;
|
||||
|
||||
@ -179,7 +179,7 @@ if ($idAgent != 0) {
|
||||
);
|
||||
|
||||
$idGroup = $id_group;
|
||||
// If there is no agent defined, it means that it cannot search for the secondary groups
|
||||
// If there is no agent defined, it means that it cannot search for the secondary groups.
|
||||
$all_groups = [$id_group];
|
||||
|
||||
$print_agent = true;
|
||||
@ -335,7 +335,9 @@ if ($free_search != '') {
|
||||
}
|
||||
|
||||
|
||||
$alert_action = empty(alerts_get_alert_actions_filter()) === false ? alerts_get_alert_actions_filter() : ['' => __('No actions')];
|
||||
$alert_action = empty(alerts_get_alert_actions_filter()) === false
|
||||
? alerts_get_alert_actions_filter()
|
||||
: ['' => __('No actions')];
|
||||
|
||||
|
||||
ob_start();
|
||||
@ -352,7 +354,7 @@ if ($free_search != '') {
|
||||
'ajax_url' => 'include/ajax/alert_list.ajax',
|
||||
'ajax_data' => [
|
||||
'get_agent_alerts_datatable' => 1,
|
||||
'id_agent' => $id_agent,
|
||||
'id_agent' => $idAgent,
|
||||
'url' => $url,
|
||||
'agent_view_page' => true,
|
||||
'all_groups' => $all_groups,
|
||||
@ -395,7 +397,7 @@ if ($free_search != '') {
|
||||
'ajax_url' => 'include/ajax/alert_list.ajax',
|
||||
'ajax_data' => [
|
||||
'get_agent_alerts_datatable' => 1,
|
||||
'id_agent' => $id_agent,
|
||||
'id_agent' => $idAgent,
|
||||
'url' => $url,
|
||||
],
|
||||
'drawCallback' => 'alerts_table_controls()',
|
||||
|
@ -97,7 +97,7 @@ if ($edit_networkmap) {
|
||||
return;
|
||||
}
|
||||
|
||||
$name = io_safe_output($values['name']);
|
||||
$name = io_safe_output_html($values['name']);
|
||||
|
||||
// Id group of the map itself, not data source.
|
||||
$id_group_map = $values['id_group_map'];
|
||||
|
@ -222,7 +222,7 @@ if (is_ajax()) {
|
||||
$id_agents,
|
||||
$selection,
|
||||
$select_mode,
|
||||
true
|
||||
(bool) !$select_mode
|
||||
);
|
||||
|
||||
// Clean double safe input.
|
||||
@ -479,6 +479,7 @@ if (is_ajax()) {
|
||||
$serialized = get_parameter('serialized', '');
|
||||
$id_server = (int) get_parameter('id_server', 0);
|
||||
$status_modulo = (int) get_parameter('status_module', -1);
|
||||
$id_group_selected = (int) get_parameter('id_group', 0);
|
||||
$metaconsole_server_name = null;
|
||||
if (!empty($id_server)) {
|
||||
$metaconsole_server_name = db_get_value(
|
||||
@ -706,14 +707,18 @@ if (is_ajax()) {
|
||||
// Get all user's groups.
|
||||
$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);
|
||||
} else {
|
||||
if (in_array($id_group_selected, $id_group) === true) {
|
||||
$id_group = $id_group_selected;
|
||||
}
|
||||
}
|
||||
|
||||
$where_tags .= ' AND tagente.id_grupo IN ('.$id_group.')';
|
||||
|
||||
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);
|
||||
$sql = sprintf(
|
||||
"SELECT t1.nombre, t1.id_agente_modulo FROM tagente_modulo t1
|
||||
|
@ -84,7 +84,7 @@ ui_require_javascript_file('pandora_events');
|
||||
$default_filter = [
|
||||
'status' => EVENT_NO_VALIDATED,
|
||||
'event_view_hr' => $config['event_view_hr'],
|
||||
'group_rep' => 1,
|
||||
'group_rep' => EVENT_GROUP_REP_EVENTS,
|
||||
'tag_with' => [],
|
||||
'tag_without' => [],
|
||||
'history' => false,
|
||||
@ -173,6 +173,10 @@ $search_secondary_groups = get_parameter(
|
||||
'filter[search_secondary_groups]',
|
||||
0
|
||||
);
|
||||
$search_recursive_groups = get_parameter(
|
||||
'filter[search_recursive_groups]',
|
||||
0
|
||||
);
|
||||
$id_group_filter = get_parameter(
|
||||
'filter[id_group_filter]',
|
||||
($filter['id_group'] ?? '')
|
||||
@ -356,6 +360,10 @@ if (is_ajax() === true) {
|
||||
$order['field'] = 'agent_name';
|
||||
break;
|
||||
|
||||
case 'if(te.ack_utimestamp > 0, from_unixtime(te.ack_utimestamp),"") as ack_utimestamp':
|
||||
$order['field'] = 'ack_utimestamp';
|
||||
break;
|
||||
|
||||
default:
|
||||
$order['field'] = $field;
|
||||
break;
|
||||
@ -1090,6 +1098,7 @@ if ($loaded_filter !== false && $from_event_graph != 1 && isset($fb64) === false
|
||||
|
||||
$filter_only_alert = $filter['filter_only_alert'];
|
||||
$search_secondary_groups = ($filter['search_secondary_groups'] ?? 0);
|
||||
$search_recursive_groups = ($filter['search_recursive_groups'] ?? 0);
|
||||
$id_group_filter = $filter['id_group_filter'];
|
||||
$date_from = $filter['date_from'];
|
||||
$time_from = $filter['time_from'];
|
||||
@ -1440,7 +1449,7 @@ if ($pure) {
|
||||
).'</a>';
|
||||
|
||||
// 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['active'] = false;
|
||||
$manage_events['text'] = '<a href="index.php?sec=eventos&sec2=godmode/events/events&section=filter&pure='.$config['pure'].'">'.html_print_image(
|
||||
@ -1660,9 +1669,10 @@ $inputs[] = $in;
|
||||
// Duplicates group { events | agents }.
|
||||
$data = html_print_select(
|
||||
[
|
||||
0 => __('All events'),
|
||||
1 => __('Group events'),
|
||||
2 => __('Group agents'),
|
||||
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'),
|
||||
],
|
||||
'group_rep',
|
||||
$group_rep,
|
||||
@ -1710,6 +1720,28 @@ $in = '<div class="filter_input"><label>'.__('Severity').'</label>';
|
||||
$in .= $data.'</div>';
|
||||
$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.
|
||||
$data = html_print_checkbox_switch(
|
||||
'search_secondary_groups',
|
||||
@ -1721,8 +1753,15 @@ $data = html_print_checkbox_switch(
|
||||
true
|
||||
);
|
||||
|
||||
$in = '<div class="filter_input filter_input_switch"><label>'.__('Search in secondary groups').'</label>';
|
||||
$in .= $data.'</div>';
|
||||
$in = '<div class="filter_input filter_input_switch"><label>';
|
||||
$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;
|
||||
|
||||
// Trick view in table.
|
||||
@ -1737,7 +1776,7 @@ $buttons[] = [
|
||||
'onclick' => '',
|
||||
];
|
||||
|
||||
if ($event_w || $event_m) {
|
||||
if ($event_w === true || $event_m === true) {
|
||||
$buttons[] = [
|
||||
'id' => 'save-filter',
|
||||
'class' => 'float-left margin-right-2',
|
||||
@ -2266,12 +2305,14 @@ try {
|
||||
$active_filters_div .= '<div>';
|
||||
$active_filters_div .= '<div class="label box-shadow">'.__('Duplicated').'</div>';
|
||||
$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.');
|
||||
} else if ($group_rep == 1) {
|
||||
} else if ($group_rep == EVENT_GROUP_REP_EVENTS) {
|
||||
$active_filters_div .= __('Group events');
|
||||
} else if ($group_rep == 2) {
|
||||
} else if ($group_rep == EVENT_GROUP_REP_AGENTS) {
|
||||
$active_filters_div .= __('Group agents.');
|
||||
} else if ($group_rep == EVENT_GROUP_REP_EXTRAIDS) {
|
||||
$active_filters_div .= __('Group extra id.');
|
||||
}
|
||||
|
||||
$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) {
|
||||
$array_events_actions[$val['id']] = $val['name'];
|
||||
}
|
||||
|
@ -91,6 +91,10 @@ if ($is_ajax === false && $pure === false) {
|
||||
|
||||
$header_name = __('Heatmap view');
|
||||
switch ($type) {
|
||||
case 3:
|
||||
$header_name .= ' - '.__('Agents');
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (current($filter) == 0) {
|
||||
$header_name .= ' - '.__('Module group').': '.__('Not assigned');
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user