Merge branch 'develop' into 'ent-9430-2FA-Authentication-sigue-saltando-tras-deshabilitar-en-consola'
# Conflicts: # pandora_console/general/register.php
@ -282,6 +282,8 @@ server_dependencies=" \
|
||||
expect \
|
||||
openssh-clients \
|
||||
java \
|
||||
bind-utils \
|
||||
whois \
|
||||
http://firefly.artica.es/centos7/xprobe2-0.3-12.2.x86_64.rpm \
|
||||
http://firefly.artica.es/centos7/wmic-1.4-1.el7.x86_64.rpm \
|
||||
https://firefly.artica.es/centos7/pandorawmic-1.0.0-1.x86_64.rpm"
|
||||
|
@ -338,6 +338,8 @@ server_dependencies=" \
|
||||
expect \
|
||||
openssh-clients \
|
||||
java \
|
||||
bind-utils \
|
||||
whois \
|
||||
http://firefly.artica.es/centos7/xprobe2-0.3-12.2.x86_64.rpm \
|
||||
http://firefly.artica.es/centos7/wmic-1.4-1.el7.x86_64.rpm \
|
||||
https://firefly.artica.es/centos8/pandorawmic-1.0.0-1.x86_64.rpm"
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.764, AIX version
|
||||
# Version 7.0NG.765, AIX version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.764, FreeBSD Version
|
||||
# Version 7.0NG.765, FreeBSD Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.764, HP-UX Version
|
||||
# Version 7.0NG.765, HP-UX Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.764, GNU/Linux
|
||||
# Version 7.0NG.765, GNU/Linux
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.764, GNU/Linux
|
||||
# Version 7.0NG.765, GNU/Linux
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.764, Solaris Version
|
||||
# Version 7.0NG.765, Solaris Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Base config file for Pandora FMS Windows Agent
|
||||
# (c) 2006-2021 Artica Soluciones Tecnologicas
|
||||
# Version 7.0NG.764
|
||||
# Version 7.0NG.765
|
||||
# This program is Free Software, you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public Licence as published by the Free Software
|
||||
# Foundation; either version 2 of the Licence or any later version
|
||||
|
@ -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,6 +1,6 @@
|
||||
# Fichero de configuracion base de agentes de Pandora
|
||||
# Base config file for Pandora agents
|
||||
# Version 7.0NG.764, AIX version
|
||||
# Version 7.0NG.765, AIX version
|
||||
|
||||
# General Parameters
|
||||
# ==================
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Fichero de configuracion base de agentes de Pandora
|
||||
# Base config file for Pandora agents
|
||||
# Version 7.0NG.764
|
||||
# Version 7.0NG.765
|
||||
# FreeBSD/IPSO version
|
||||
# Licenced under GPL licence, 2003-2007 Sancho Lerena
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Fichero de configuracion base de agentes de Pandora
|
||||
# Base config file for Pandora agents
|
||||
# Version 7.0NG.764, HPUX Version
|
||||
# Version 7.0NG.765, HPUX Version
|
||||
|
||||
# General Parameters
|
||||
# ==================
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.764
|
||||
# Version 7.0NG.765
|
||||
# Licensed under GPL license v2,
|
||||
# (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# please visit http://pandora.sourceforge.net
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.764
|
||||
# Version 7.0NG.765
|
||||
# Licensed under GPL license v2,
|
||||
# (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# please visit http://pandora.sourceforge.net
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.764
|
||||
# Version 7.0NG.765
|
||||
# Licensed under GPL license v2,
|
||||
# please visit http://pandora.sourceforge.net
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Fichero de configuracion base de agentes de Pandora
|
||||
# Base config file for Pandora agents
|
||||
# Version 7.0NG.764, Solaris version
|
||||
# Version 7.0NG.765, Solaris version
|
||||
|
||||
# General Parameters
|
||||
# ==================
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.764, AIX version
|
||||
# Version 7.0NG.765, AIX version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
@ -1,5 +1,5 @@
|
||||
package: pandorafms-agent-unix
|
||||
Version: 7.0NG.764-220922
|
||||
Version: 7.0NG.765-221027
|
||||
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.764-220922"
|
||||
pandora_version="7.0NG.765-221027"
|
||||
|
||||
echo "Test if you has the tools for to make the packages."
|
||||
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
||||
|
@ -31,7 +31,7 @@ fi
|
||||
if [ "$#" -ge 2 ]; then
|
||||
VERSION="$2"
|
||||
else
|
||||
VERSION="7.0NG.764"
|
||||
VERSION="7.0NG.765"
|
||||
fi
|
||||
|
||||
# Path for the generated DMG file
|
||||
|
@ -19,11 +19,11 @@
|
||||
<choice id="com.pandorafms.pandorafms_src" visible="false">
|
||||
<pkg-ref id="com.pandorafms.pandorafms_src"/>
|
||||
</choice>
|
||||
<pkg-ref id="com.pandorafms.pandorafms_src" version="7.0NG.764" onConclusion="none">pandorafms_src.pdk</pkg-ref>
|
||||
<pkg-ref id="com.pandorafms.pandorafms_src" version="7.0NG.765" onConclusion="none">pandorafms_src.pdk</pkg-ref>
|
||||
<choice id="com.pandorafms.pandorafms_uninstall" visible="true" customLocation="/Applications">
|
||||
<pkg-ref id="com.pandorafms.pandorafms_uninstall"/>
|
||||
</choice>
|
||||
<pkg-ref id="com.pandorafms.pandorafms_uninstall" version="7.0NG.764" onConclusion="none">pandorafms_uninstall.pdk</pkg-ref>
|
||||
<pkg-ref id="com.pandorafms.pandorafms_uninstall" version="7.0NG.765" onConclusion="none">pandorafms_uninstall.pdk</pkg-ref>
|
||||
<!-- <installation-check script="check()" />
|
||||
<script>
|
||||
<![CDATA[
|
||||
|
@ -5,9 +5,9 @@
|
||||
<key>CFBundleIconFile</key> <string>pandorafms.icns</string>
|
||||
<key>CFBundleIdentifier</key> <string>com.pandorafms.pandorafms_uninstall</string>
|
||||
|
||||
<key>CFBundleVersion</key> <string>7.0NG.764</string>
|
||||
<key>CFBundleGetInfoString</key> <string>7.0NG.764 Pandora FMS Agent uninstaller for MacOS by Artica ST on Aug 2020</string>
|
||||
<key>CFBundleShortVersionString</key> <string>7.0NG.764</string>
|
||||
<key>CFBundleVersion</key> <string>7.0NG.765</string>
|
||||
<key>CFBundleGetInfoString</key> <string>7.0NG.765 Pandora FMS Agent uninstaller for MacOS by Artica ST on Aug 2020</string>
|
||||
<key>CFBundleShortVersionString</key> <string>7.0NG.765</string>
|
||||
|
||||
<key>NSPrincipalClass</key><string>NSApplication</string>
|
||||
<key>NSMainNibFile</key><string>MainMenu</string>
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.764, GNU/Linux
|
||||
# Version 7.0NG.765, GNU/Linux
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.764, FreeBSD Version
|
||||
# Version 7.0NG.765, FreeBSD Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.764, HP-UX Version
|
||||
# Version 7.0NG.765, HP-UX Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.764, GNU/Linux
|
||||
# Version 7.0NG.765, GNU/Linux
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
@ -165,9 +165,15 @@ remote_config 0
|
||||
# should consider changing the temporal directory, since /tmp is world writable.
|
||||
xml_buffer 1
|
||||
|
||||
# Minimum available bytes in the temporal directory to enable the XML buffer
|
||||
# Minimum available megabytes in the temporal directory to enable the XML buffer
|
||||
temporal_min_size 1024
|
||||
|
||||
# Maximum size (in megabytes) allowed for the XML buffer.
|
||||
temporal_max_size 1024
|
||||
|
||||
# Maximum number of files allowed for the XML buffer.
|
||||
temporal_max_files 1024
|
||||
|
||||
# Agent mode: Learn (default), No-learn, Autodisable
|
||||
# agent_mode autodisable
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.764, GNU/Linux
|
||||
# Version 7.0NG.765, GNU/Linux
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.764, NetBSD Version
|
||||
# Version 7.0NG.765, NetBSD Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.764, Solaris Version
|
||||
# Version 7.0NG.765, Solaris Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
@ -1014,8 +1014,8 @@ my $Sem = undef;
|
||||
# Semaphore used to control the number of threads
|
||||
my $ThreadSem = undef;
|
||||
|
||||
use constant AGENT_VERSION => '7.0NG.764';
|
||||
use constant AGENT_BUILD => '220922';
|
||||
use constant AGENT_VERSION => '7.0NG.765';
|
||||
use constant AGENT_BUILD => '221027';
|
||||
|
||||
# Agent log default file size maximum and instances
|
||||
use constant DEFAULT_MAX_LOG_SIZE => 600000;
|
||||
@ -1145,7 +1145,9 @@ my %DefaultConf = (
|
||||
'secondary_server_opts' => '',
|
||||
'secondary_temporal' => '/var/spool/pandora',
|
||||
'autotime' => 0,
|
||||
'temporal_min_size' => 1,
|
||||
'temporal_min_size' => 1024,
|
||||
'temporal_max_files' => 1024,
|
||||
'temporal_max_size' => 1024,
|
||||
'timezone_offset' => 0,
|
||||
'pandora_exec' => 'pandora_agent_exec',
|
||||
'agent_threads' => 1,
|
||||
@ -2110,13 +2112,13 @@ sub send_xml_file ($) {
|
||||
swap_servers();
|
||||
|
||||
# Secondary buffer.
|
||||
if ($rc_sec != 0 && $Conf{'xml_buffer'} == 1 && temporal_freedisk () > $Conf{'temporal_min_size'}) {
|
||||
if ($rc_sec != 0 && write_to_buffer($Conf{'secondary_temporal'}) == 1) {
|
||||
copy($file, $Conf{'secondary_temporal'}) || die("Error copying file $file to " . $Conf{'secondary_temporal'} . ": $!");
|
||||
}
|
||||
}
|
||||
|
||||
# Primary buffer.
|
||||
if ($rc == 0 || $Conf{'xml_buffer'} == 0 || temporal_freedisk () <= $Conf{'temporal_min_size'}) {
|
||||
if ($rc == 0 || write_to_buffer($Conf{'temporal'}) == 0) {
|
||||
if ($Conf{'debug'} eq '1') {
|
||||
rename($file, $file . "sent");
|
||||
} else {
|
||||
@ -3761,20 +3763,45 @@ sub kill_signal_handler (){
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Get the free disk space in the temporal directory (in bytes).
|
||||
# Get the free disk space in the temporal directory (in megabytes).
|
||||
################################################################################
|
||||
sub temporal_freedisk () {
|
||||
sub temporal_freedisk {
|
||||
my ($temporal) = @_;
|
||||
|
||||
# Call df
|
||||
return 0 unless defined (DF_CMDS->{$OS});
|
||||
my $cmd = DF_CMDS->{$OS} . ' ' . $Conf{'temporal'} . ' | awk \'NR > 1 {print $4}\'';
|
||||
my $cmd = DF_CMDS->{$OS} . ' ' . $temporal . ' | awk \'NR > 1 {print $4}\'';
|
||||
my $temporal_freedisk = `$cmd`;
|
||||
|
||||
# Check for errors
|
||||
return 0 unless ($? eq 0);
|
||||
|
||||
# Convert to bytes
|
||||
return 1024 * int ($temporal_freedisk);
|
||||
# Convert from KB to MB.
|
||||
return $temporal_freedisk / 1024;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Return the number of data files in the temporal directory and their total
|
||||
# size (in megabytes).
|
||||
################################################################################
|
||||
sub temporal_stats {
|
||||
my ($temporal) = @_;
|
||||
|
||||
my $file_count = 0;
|
||||
my $file_size = 0;
|
||||
opendir(my $dir, $temporal) or die($!);
|
||||
while (my $f = readdir($dir)) {
|
||||
if ($f =~ m/.data$/ || $f =~ m/.datasent$/) {
|
||||
$file_count += 1;
|
||||
$file_size += (stat $temporal . '/' . $f)[7];
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
|
||||
# Convert from B to MB.
|
||||
$file_size /= 1048576;
|
||||
|
||||
return ($file_count, $file_size);
|
||||
}
|
||||
|
||||
################################################################################
|
||||
@ -3960,6 +3987,27 @@ sub get_ehkey {
|
||||
return '';
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Return 1 if XML files should be written to the buffer. 0 otherwise.
|
||||
################################################################################
|
||||
sub write_to_buffer {
|
||||
my ($temporal) = @_;
|
||||
|
||||
# The XML buffer is disabled.
|
||||
return 0 if ($Conf{'xml_buffer'} == 0);
|
||||
|
||||
# Check available disk space.
|
||||
return 0 if ($Conf{'temporal_min_size'} != 0 && temporal_freedisk($temporal) < $Conf{'temporal_min_size'});
|
||||
|
||||
# Check buffer file count and size limits.
|
||||
my ($file_count, $file_size) = temporal_stats($temporal);
|
||||
return 0 if ($Conf{'temporal_max_files'} != 0 && $file_count > $Conf{'temporal_max_files'});
|
||||
return 0 if ($Conf{'temporal_max_size'} != 0 && $file_size > $Conf{'temporal_max_size'});
|
||||
|
||||
# It's OK to write to the buffer.
|
||||
return 1;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Main.
|
||||
################################################################################
|
||||
|
@ -2,8 +2,8 @@
|
||||
#Pandora FMS Linux Agent
|
||||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.764
|
||||
%define release 220922
|
||||
%define version 7.0NG.765
|
||||
%define release 221027
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
@ -2,8 +2,8 @@
|
||||
#Pandora FMS Linux Agent
|
||||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.764
|
||||
%define release 220922
|
||||
%define version 7.0NG.765
|
||||
%define release 221027
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
@ -9,8 +9,8 @@
|
||||
# Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license.
|
||||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.764"
|
||||
PI_BUILD="220922"
|
||||
PI_VERSION="7.0NG.765"
|
||||
PI_BUILD="221027"
|
||||
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.");
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Base config file for Pandora FMS Windows Agent
|
||||
# (c) 2006-2021 Artica Soluciones Tecnologicas
|
||||
# Version 7.0NG.764
|
||||
# Version 7.0NG.765
|
||||
# This program is Free Software, you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public Licence as published by the Free Software
|
||||
# Foundation; either version 2 of the Licence or any later version
|
||||
@ -55,9 +55,15 @@ address auto
|
||||
# or setting a fixed IP address, like for example:
|
||||
#address 192.168.36.73
|
||||
|
||||
# This limits operation if temporal dir has not enough free disk.
|
||||
# This limits operation if temporal dir has not enough free disk (in megabytes).
|
||||
#temporal_min_size 1024
|
||||
|
||||
# Maximum size (in megabytes) allowed for the XML buffer.
|
||||
temporal_max_size 1024
|
||||
|
||||
# Maximum number of files allowed for the XML buffer.
|
||||
temporal_max_files 1024
|
||||
|
||||
# Delay start execution X second before start to monitoring nothing
|
||||
#startup_delay 30
|
||||
|
||||
|
@ -3,7 +3,7 @@ AllowLanguageSelection
|
||||
{Yes}
|
||||
|
||||
AppName
|
||||
{Pandora FMS Windows Agent v7.0NG.764}
|
||||
{Pandora FMS Windows Agent v7.0NG.765}
|
||||
|
||||
ApplicationID
|
||||
{17E3D2CF-CA02-406B-8A80-9D31C17BD08F}
|
||||
@ -186,7 +186,7 @@ UpgradeApplicationID
|
||||
{}
|
||||
|
||||
Version
|
||||
{220922}
|
||||
{221027}
|
||||
|
||||
ViewReadme
|
||||
{Yes}
|
||||
|
@ -30,7 +30,7 @@ using namespace Pandora;
|
||||
using namespace Pandora_Strutils;
|
||||
|
||||
#define PATH_SIZE _MAX_PATH+1
|
||||
#define PANDORA_VERSION ("7.0NG.764 Build 220922")
|
||||
#define PANDORA_VERSION ("7.0NG.765 Build 221027")
|
||||
|
||||
string pandora_path;
|
||||
string pandora_dir;
|
||||
|
@ -1696,7 +1696,7 @@ Pandora_Windows_Service::checkConfig (string file) {
|
||||
|
||||
int
|
||||
Pandora_Windows_Service::sendXml (Pandora_Module_List *modules, string extra /* = ""*/) {
|
||||
int rc = 0, rc_sec = 0, xml_buffer;
|
||||
int rc = 0, rc_sec = 0, xml_buffer;
|
||||
string data_xml;
|
||||
string xml_filename, random_integer;
|
||||
string tmp_filename, tmp_filepath;
|
||||
@ -1705,12 +1705,10 @@ Pandora_Windows_Service::sendXml (Pandora_Module_List *modules, string extra /*
|
||||
string ehorus_conf, eh_key;
|
||||
static HANDLE mutex = 0;
|
||||
ULARGE_INTEGER free_bytes;
|
||||
double min_free_bytes = 0;
|
||||
Pandora_Agent_Conf *conf = NULL;
|
||||
FILE *conf_fh = NULL;
|
||||
|
||||
conf = this->getConf ();
|
||||
min_free_bytes = 1024 * atoi (conf->getValue ("temporal_min_size").c_str ());
|
||||
xml_buffer = atoi (conf->getValue ("xml_buffer").c_str ());
|
||||
|
||||
if (mutex == 0) {
|
||||
@ -1814,14 +1812,14 @@ Pandora_Windows_Service::sendXml (Pandora_Module_List *modules, string extra /*
|
||||
rc_sec = this->copyToSecondary (tmp_filename, false);
|
||||
|
||||
/* Secondary buffer. */
|
||||
if (rc_sec != 0 && xml_buffer == 1 && (GetDiskFreeSpaceEx (conf->getValue ("secondary_temporal").c_str (), &free_bytes, NULL, NULL) != 0 && free_bytes.QuadPart >= min_free_bytes)) {
|
||||
if (rc_sec != 0 && this->writeToBuffer(conf->getValue ("secondary_temporal").c_str ())) {
|
||||
secondary_filepath = conf->getValue ("secondary_temporal") + "\\" + tmp_filename;
|
||||
CopyFile (tmp_filepath.c_str(), secondary_filepath.c_str(), false);
|
||||
}
|
||||
}
|
||||
|
||||
/* Primary buffer. Delete the file if successfully copied, buffer disabled or not enough space available. */
|
||||
if (rc == 0 || xml_buffer == 0 || (GetDiskFreeSpaceEx (tmp_filepath.c_str (), &free_bytes, NULL, NULL) != 0 && free_bytes.QuadPart < min_free_bytes)) {
|
||||
if (rc == 0 || !writeToBuffer(conf->getValue ("temporal").c_str ())) {
|
||||
/* Rename the file if debug mode is enabled*/
|
||||
if (getPandoraDebug ()) {
|
||||
string tmp_filepath_sent = tmp_filepath;
|
||||
@ -2218,3 +2216,60 @@ Pandora_Windows_Service::generateAgentName () {
|
||||
sha256(data.str().c_str(), digest);
|
||||
return std::string(digest);
|
||||
}
|
||||
|
||||
bool
|
||||
Pandora_Windows_Service::writeToBuffer (string temporal) {
|
||||
int xml_buffer;
|
||||
long int temporal_max_files;
|
||||
double temporal_min_size, temporal_max_size;
|
||||
string dir, file_name;
|
||||
ULARGE_INTEGER free_bytes;
|
||||
Pandora_Agent_Conf *conf = NULL;
|
||||
|
||||
conf = this->getConf ();
|
||||
|
||||
dir = temporal;
|
||||
if (dir[dir.length () - 1] != '\\') {
|
||||
dir += "\\";
|
||||
}
|
||||
file_name = dir + "*.data";
|
||||
|
||||
// Is the XML buffer disabled?
|
||||
xml_buffer = atoi (conf->getValue ("xml_buffer").c_str ());
|
||||
if (xml_buffer == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check available disk space.
|
||||
temporal_min_size = atoi (conf->getValue ("temporal_min_size").c_str ());
|
||||
if (GetDiskFreeSpaceEx (dir.c_str (), &free_bytes, NULL, NULL) && (free_bytes.QuadPart / 1048576) < temporal_min_size) { // Convert free_bytes.QuadPart from B to MB.
|
||||
pandoraLog ("[writeToBuffer] Disk full.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check buffer file count and size limits.
|
||||
temporal_max_size = atoi (conf->getValue ("temporal_max_size").c_str ());
|
||||
temporal_max_files = atol (conf->getValue ("temporal_max_files").c_str ());
|
||||
if (temporal_max_size != 0 || temporal_max_files != 0) {
|
||||
long int file_count = 0;
|
||||
ULONGLONG file_size = 0;
|
||||
HANDLE hFind;
|
||||
WIN32_FIND_DATA FindFileData;
|
||||
if ((hFind = FindFirstFile(file_name.c_str(), &FindFileData)) != INVALID_HANDLE_VALUE) {
|
||||
do {
|
||||
file_count += 1;
|
||||
file_size += (FindFileData.nFileSizeHigh * (MAXDWORD + 1)) + FindFileData.nFileSizeLow;
|
||||
} while (FindNextFile(hFind, &FindFileData));
|
||||
FindClose(hFind);
|
||||
}
|
||||
|
||||
file_size /= 1048576; // Convert from B to MB.
|
||||
if ((temporal_max_size != 0 && file_size > temporal_max_size) ||
|
||||
(temporal_max_files != 0 && file_count > temporal_max_files)) {
|
||||
pandoraLog ("[writeToBuffer] Too many files or buffer full.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -124,6 +124,7 @@ namespace Pandora {
|
||||
long getInterval ();
|
||||
long getIntensiveInterval ();
|
||||
string generateAgentName ();
|
||||
bool writeToBuffer (string temporal);
|
||||
|
||||
};
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ BEGIN
|
||||
VALUE "LegalCopyright", "Artica ST"
|
||||
VALUE "OriginalFilename", "PandoraAgent.exe"
|
||||
VALUE "ProductName", "Pandora FMS Windows Agent"
|
||||
VALUE "ProductVersion", "(7.0NG.764(Build 220922))"
|
||||
VALUE "ProductVersion", "(7.0NG.765(Build 221027))"
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
END
|
||||
END
|
||||
|
@ -1,5 +1,5 @@
|
||||
package: pandorafms-console
|
||||
Version: 7.0NG.764-220922
|
||||
Version: 7.0NG.765-221027
|
||||
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.764-220922"
|
||||
pandora_version="7.0NG.765-221027"
|
||||
|
||||
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
|
||||
|
10
pandora_console/extras/mr/58.sql
Normal file
@ -0,0 +1,10 @@
|
||||
START TRANSACTION;
|
||||
|
||||
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;
|
||||
|
||||
COMMIT;
|
@ -185,7 +185,9 @@ if (!$double_auth_enabled
|
||||
//document.location.reload();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
.show();
|
||||
// Don't allow close the dialog with X button
|
||||
// $('.ui-dialog-titlebar-close').css('display', 'none');
|
||||
|
||||
</script>
|
||||
<?php
|
||||
|
@ -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', '');
|
||||
@ -935,7 +935,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', '');
|
||||
@ -1047,7 +1047,7 @@ if ($update_agent) {
|
||||
// If there is an agent with the same name, but a different ID.
|
||||
}
|
||||
|
||||
if ($unique_ip && $direccion_agente != '') {
|
||||
if ($direccion_agente !== $address_list && (bool) $unique_ip === true && $direccion_agente != '') {
|
||||
$sql = 'SELECT direccion FROM tagente WHERE direccion = "'.$direccion_agente.'"';
|
||||
$exists_ip = db_get_row_sql($sql);
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -669,13 +669,12 @@ $table_advanced->data[2][3] = __('Max. Value');
|
||||
$table_advanced->data[2][4] = html_print_input_text('max', $max, '', 5, 15, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy);
|
||||
$table_advanced->colspan[2][4] = 3;
|
||||
|
||||
|
||||
$table_advanced->data[3][0] = __('Dynamic Threshold Interval');
|
||||
$table_advanced->data[3][1] = html_print_extended_select_for_time(
|
||||
'dynamic_interval',
|
||||
$dynamic_interval,
|
||||
'',
|
||||
'None',
|
||||
__('None'),
|
||||
'0',
|
||||
10,
|
||||
true,
|
||||
|
@ -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'],
|
||||
]
|
||||
|
@ -15,6 +15,7 @@
|
||||
global $config;
|
||||
|
||||
require_once $config['homedir'].'/include/functions_alerts.php';
|
||||
require_once $config['homedir'].'/include/functions_reports.php';
|
||||
enterprise_include_once('meta/include/functions_alerts_meta.php');
|
||||
|
||||
check_login();
|
||||
@ -349,9 +350,94 @@ if (is_ajax()) {
|
||||
);
|
||||
} else {
|
||||
$fields_value_select = [];
|
||||
$fv = explode(';', $field_value);
|
||||
$force_print_select = false;
|
||||
|
||||
if (count($fv) > 1) {
|
||||
// Exception for dynamically filled select boxes.
|
||||
if (preg_match('/^_reports_$/i', $field_value)) {
|
||||
// Filter normal and metaconsole reports.
|
||||
if (is_metaconsole() === true) {
|
||||
$filter['metaconsole'] = 1;
|
||||
} else {
|
||||
$filter['metaconsole'] = 0;
|
||||
}
|
||||
|
||||
$own_info = get_user_info($config['id_user']);
|
||||
if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'RM') || check_acl($config['id_user'], 0, 'RR')) {
|
||||
$return_all_group = true;
|
||||
} else {
|
||||
$return_all_group = false;
|
||||
}
|
||||
|
||||
if (is_user_admin($config['id_user']) === false) {
|
||||
$filter[] = sprintf(
|
||||
'private = 0 OR (private = 1 AND id_user = "%s")',
|
||||
$config['id_user']
|
||||
);
|
||||
}
|
||||
|
||||
$reports = reports_get_reports(
|
||||
$filter,
|
||||
[
|
||||
'name',
|
||||
'id_report',
|
||||
],
|
||||
$return_all_group,
|
||||
'RR'
|
||||
);
|
||||
|
||||
$fv = array_map(
|
||||
function ($report) {
|
||||
return $report['id_report'].','.$report['name'];
|
||||
},
|
||||
$reports
|
||||
);
|
||||
|
||||
$force_print_select = true;
|
||||
} else if (preg_match('/^_report_templates_$/i', $field_value)) {
|
||||
// Filter normal and metaconsole reports.
|
||||
if (is_metaconsole() === true) {
|
||||
$filter['metaconsole'] = 1;
|
||||
} else {
|
||||
$filter['metaconsole'] = 0;
|
||||
}
|
||||
|
||||
$own_info = get_user_info($config['id_user']);
|
||||
if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'RM') || check_acl($config['id_user'], 0, 'RR')) {
|
||||
$return_all_group = true;
|
||||
} else {
|
||||
$return_all_group = false;
|
||||
}
|
||||
|
||||
if (is_user_admin($config['id_user']) === false) {
|
||||
$filter[] = sprintf(
|
||||
'private = 0 OR (private = 1 AND id_user = "%s")',
|
||||
$config['id_user']
|
||||
);
|
||||
}
|
||||
|
||||
$templates = reports_get_report_templates(
|
||||
$filter,
|
||||
[
|
||||
'name',
|
||||
'id_report',
|
||||
],
|
||||
$return_all_group,
|
||||
'RR'
|
||||
);
|
||||
|
||||
$fv = array_map(
|
||||
function ($template) {
|
||||
return $template['id_report'].','.$template['name'];
|
||||
},
|
||||
$templates
|
||||
);
|
||||
|
||||
$force_print_select = true;
|
||||
} else {
|
||||
$fv = explode(';', $field_value);
|
||||
}
|
||||
|
||||
if (count($fv) > 1 || $force_print_select === true) {
|
||||
if (!empty($fv)) {
|
||||
foreach ($fv as $fv_option) {
|
||||
$fv_option = explode(',', $fv_option);
|
||||
@ -711,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>';
|
||||
@ -742,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"');
|
||||
|
@ -358,7 +358,7 @@ if (!is_user_admin($config['id_user'])) {
|
||||
$filter['id_group'] = array_keys(users_get_groups(false, 'LM'));
|
||||
}
|
||||
|
||||
$total_templates = alerts_get_alert_templates($filter, ['COUNT(*) AS total']);
|
||||
$total_templates = alerts_get_alert_templates($filter, ['COUNT(*) AS total'], true);
|
||||
$total_templates = $total_templates[0]['total'];
|
||||
|
||||
$templates = alerts_get_alert_templates(
|
||||
|
@ -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,
|
||||
|
@ -2335,7 +2335,7 @@ $class = 'databox filters';
|
||||
<td class="bolder">
|
||||
<?php
|
||||
echo __('SQL query').ui_print_help_tip(
|
||||
__('The entities of the fields that contain them must be included.'),
|
||||
__('The entities of the fields that contain them must be included. Also is possible use macros like `_start_date_` or `_end_date_`.'),
|
||||
true
|
||||
);
|
||||
?>
|
||||
|
@ -881,14 +881,16 @@ if (($create != '') || ($view != '')) {
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
).'</a> ';
|
||||
echo "<a href='index.php?sec=$sec&sec2=godmode/servers/plugin&tab=$tab&kill_plugin=".$row['id'].'&tab=plugins&pure='.$config['pure']."' onclick='javascript: if (!confirm(\"".__('All the modules that are using this plugin will be deleted').'. '.__('Are you sure?')."\")) return false;'>".html_print_image(
|
||||
'images/cross.png',
|
||||
true,
|
||||
[
|
||||
'border' => '0',
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
).'</a>';
|
||||
if ((bool) $row['no_delete'] === false) {
|
||||
echo "<a href='index.php?sec=$sec&sec2=godmode/servers/plugin&tab=$tab&kill_plugin=".$row['id'].'&tab=plugins&pure='.$config['pure']."' onclick='javascript: if (!confirm(\"".__('All the modules that are using this plugin will be deleted').'. '.__('Are you sure?')."\")) return false;'>".html_print_image(
|
||||
'images/cross.png',
|
||||
true,
|
||||
[
|
||||
'border' => '0',
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
).'</a>';
|
||||
}
|
||||
|
||||
echo '</td>';
|
||||
}
|
||||
|
@ -238,6 +238,17 @@ foreach ($servers as $server) {
|
||||
$data[8] .= '</a>';
|
||||
|
||||
if (($names_servers[$safe_server_name] === true) && ($server['type'] === 'data' || $server['type'] === 'enterprise satellite')) {
|
||||
$data[8] .= '<a href="'.ui_get_full_url('index.php?sec=gservers&sec2=godmode/servers/modificar_server&server_remote='.$server['id_server'].'&ext='.$ext.'&tab=agent_editor').'">';
|
||||
$data[8] .= html_print_image(
|
||||
'images/agent.png',
|
||||
true,
|
||||
[
|
||||
'title' => __('Manage satellite hosts'),
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
);
|
||||
$data[8] .= '</a>';
|
||||
|
||||
$data[8] .= '<a href="'.ui_get_full_url('index.php?sec=gservers&sec2=godmode/servers/modificar_server&server_remote='.$server['id_server'].'&ext='.$ext).'">';
|
||||
$data[8] .= html_print_image(
|
||||
'images/remote_configuration.png',
|
||||
|
@ -59,6 +59,8 @@ if (is_metaconsole()) {
|
||||
enterprise_include_once('include/functions_license.php');
|
||||
}
|
||||
|
||||
enterprise_include_once('include/functions_crypto.php');
|
||||
|
||||
if ($renew_license_result !== null) {
|
||||
echo $renew_license_result;
|
||||
}
|
||||
@ -74,8 +76,32 @@ if ($update_settings) {
|
||||
);
|
||||
}
|
||||
|
||||
$customer_key = $_POST['keys']['customer_key'];
|
||||
|
||||
$license_encryption_key = get_parameter('license_encryption_key', '');
|
||||
$check = db_get_value_sql('SELECT `key` FROM tupdate_settings WHERE `key` LIKE "license_encryption_key"');
|
||||
if ($check === false) {
|
||||
db_process_sql_insert(
|
||||
'tupdate_settings',
|
||||
[
|
||||
db_escape_key_identifier('value') => $license_encryption_key,
|
||||
db_escape_key_identifier('key') => 'license_encryption_key',
|
||||
]
|
||||
);
|
||||
} else {
|
||||
db_process_sql_update(
|
||||
'tupdate_settings',
|
||||
[db_escape_key_identifier('value') => $license_encryption_key],
|
||||
[db_escape_key_identifier('key') => 'license_encryption_key']
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($license_encryption_key) === false) {
|
||||
$customer_key = openssl_blowfish_encrypt_hex($customer_key, io_safe_output($license_encryption_key));
|
||||
}
|
||||
|
||||
// Update the license file.
|
||||
$result = file_put_contents($config['remote_config'].'/'.LICENSE_FILE, $_POST['keys']['customer_key']);
|
||||
$result = file_put_contents($config['remote_config'].'/'.LICENSE_FILE, $customer_key);
|
||||
if ($result === false) {
|
||||
ui_print_error_message(__('Failed to Update license file'));
|
||||
}
|
||||
@ -153,8 +179,24 @@ $table->data[7][1] = html_print_input_text('expires', ($license['nms'] == 1 ? __
|
||||
$table->data[8][0] = '<strong>'.__('Satellite').'</strong>';
|
||||
$table->data[8][1] = html_print_input_text('expires', ($license['dhpm'] == 1 ? __('enabled') : __('disabled')), '', 10, 255, true, true);
|
||||
|
||||
$table->data[9][0] = '<strong>'.__('Licensed to').'</strong>';
|
||||
$table->data[9][1] = html_print_input_text('licensed_to', $license['licensed_to'], '', 64, 255, true, true);
|
||||
if ($license['dhpm'] == 1) {
|
||||
$table->data[9][0] = '<strong>'.__('License encryption key').'</strong>'.ui_print_help_tip(
|
||||
__('This key is used to encrypt your Pandora FMS license when it is shared with other Pandora FMS components'),
|
||||
true
|
||||
);
|
||||
$table->data[9][1] = html_print_input_password(
|
||||
'license_encryption_key',
|
||||
io_safe_output($settings->license_encryption_key),
|
||||
'',
|
||||
10,
|
||||
255,
|
||||
true,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
$table->data[10][0] = '<strong>'.__('Licensed to').'</strong>';
|
||||
$table->data[10][1] = html_print_input_text('licensed_to', $license['licensed_to'], '', 64, 255, true, true);
|
||||
|
||||
html_print_table($table);
|
||||
|
||||
|
@ -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,11 @@ 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_submit_button(
|
||||
|
@ -199,6 +199,21 @@ if (is_ajax()) {
|
||||
);
|
||||
$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);
|
||||
|
@ -1,17 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* User creation / update.
|
||||
*
|
||||
* @category Users
|
||||
* @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.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// 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 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.
|
||||
// Load global vars
|
||||
// Load global vars.
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
@ -343,6 +358,8 @@ if ($create_user) {
|
||||
$values['email'] = (string) get_parameter('email');
|
||||
$values['phone'] = (string) get_parameter('phone');
|
||||
$values['comments'] = io_safe_input(strip_tags(io_safe_output((string) get_parameter('comments'))));
|
||||
$values['allowed_ip_active'] = ((int) get_parameter_switch('allowed_ip_active', -1) === 0);
|
||||
$values['allowed_ip_list'] = io_safe_input(strip_tags(io_safe_output((string) get_parameter('allowed_ip_list'))));
|
||||
$values['is_admin'] = $user_is_admin;
|
||||
$values['language'] = get_parameter('language', 'default');
|
||||
$values['timezone'] = (string) get_parameter('timezone');
|
||||
@ -358,20 +375,20 @@ if ($create_user) {
|
||||
$values['block_size'] = (int) get_parameter('block_size', $config['block_size']);
|
||||
|
||||
$values['section'] = get_parameter('section');
|
||||
if (($values['section'] == 'Event list') || ($values['section'] == 'Group view') || ($values['section'] == 'Alert detail') || ($values['section'] == 'Tactical view') || ($values['section'] == 'Default')) {
|
||||
if (($values['section'] === 'Event list') || ($values['section'] === 'Group view') || ($values['section'] === 'Alert detail') || ($values['section'] === 'Tactical view') || ($values['section'] === 'Default')) {
|
||||
$values['data_section'] = '';
|
||||
} else if ($values['section'] == 'Dashboard') {
|
||||
} else if ($values['section'] === 'Dashboard') {
|
||||
$values['data_section'] = $dashboard;
|
||||
} else if (io_safe_output($values['section']) == 'Visual console') {
|
||||
} else if (io_safe_output($values['section']) === 'Visual console') {
|
||||
$values['data_section'] = $visual_console;
|
||||
} else if ($values['section'] == 'Other' || io_safe_output($values['section']) == 'External link') {
|
||||
} else if ($values['section'] === 'Other' || io_safe_output($values['section']) === 'External link') {
|
||||
$values['data_section'] = get_parameter('data_section');
|
||||
}
|
||||
|
||||
if (enterprise_installed()) {
|
||||
if (enterprise_installed() === true) {
|
||||
$values['force_change_pass'] = 1;
|
||||
$values['last_pass_change'] = date('Y/m/d H:i:s', get_system_time());
|
||||
if (defined('METACONSOLE')) {
|
||||
if (is_metaconsole() === true) {
|
||||
$values['metaconsole_access'] = get_parameter('metaconsole_access', 'basic');
|
||||
$values['metaconsole_agents_manager'] = ($user_is_admin == 1 ? 1 : get_parameter('metaconsole_agents_manager', '0'));
|
||||
$values['metaconsole_access_node'] = ($user_is_admin == 1 ? 1 : get_parameter('metaconsole_access_node', '0'));
|
||||
@ -384,8 +401,8 @@ if ($create_user) {
|
||||
$values['strict_acl'] = (bool) get_parameter('strict_acl', false);
|
||||
$values['session_time'] = (int) get_parameter('session_time', 0);
|
||||
|
||||
// eHorus user level conf
|
||||
if ($config['ehorus_user_level_conf']) {
|
||||
// eHorus user level conf.
|
||||
if ((bool) $config['ehorus_user_level_conf'] === true) {
|
||||
$values['ehorus_user_level_enabled'] = (bool) get_parameter('ehorus_user_level_enabled', false);
|
||||
if ($values['ehorus_user_level_enabled'] === true) {
|
||||
$values['ehorus_user_level_user'] = (string) get_parameter('ehorus_user_level_user');
|
||||
@ -397,7 +414,7 @@ if ($create_user) {
|
||||
}
|
||||
|
||||
|
||||
if ($id == '') {
|
||||
if (empty($id) === true) {
|
||||
ui_print_error_message(__('User ID cannot be empty'));
|
||||
$is_err = true;
|
||||
$user_info = $values;
|
||||
@ -411,7 +428,7 @@ if ($create_user) {
|
||||
$password_new = '';
|
||||
$password_confirm = '';
|
||||
$new_user = true;
|
||||
} else if ($password_new == '') {
|
||||
} else if (empty($password_new) === true) {
|
||||
$is_err = true;
|
||||
ui_print_error_message(__('Passwords cannot be empty'));
|
||||
$user_info = $values;
|
||||
@ -425,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);
|
||||
@ -438,6 +462,9 @@ if ($create_user) {
|
||||
}
|
||||
|
||||
$info = '{"Id_user":"'.$values['id_user'].'","FullName":"'.$values['fullname'].'","Firstname":"'.$values['firstname'].'","Lastname":"'.$values['lastname'].'","Email":"'.$values['email'].'","Phone":"'.$values['phone'].'","Comments":"'.$values['comments'].'","Is_admin":"'.$values['is_admin'].'","Language":"'.$values['language'].'","Timezone":"'.$values['timezone'].'","Block size":"'.$values['block_size'].'"';
|
||||
if ($values['allowed_ip_active'] === true) {
|
||||
$info .= ',"IPS Allowed":"'.$values['allowed_ip_list'].'"';
|
||||
}
|
||||
|
||||
if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) {
|
||||
$info .= ',"Skin":"'.$values['id_skin'].'"}';
|
||||
@ -489,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'];
|
||||
@ -512,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'),
|
||||
@ -540,6 +579,8 @@ if ($update_user) {
|
||||
$values['email'] = (string) get_parameter('email');
|
||||
$values['phone'] = (string) get_parameter('phone');
|
||||
$values['comments'] = io_safe_input(strip_tags(io_safe_output((string) get_parameter('comments'))));
|
||||
$values['allowed_ip_active'] = ((int) get_parameter('allowed_ip_active', -1) === 0);
|
||||
$values['allowed_ip_list'] = io_safe_input(strip_tags(io_safe_output((string) get_parameter('allowed_ip_list'))));
|
||||
$values['is_admin'] = (get_parameter('is_admin', 0) === 0) ? 0 : 1;
|
||||
$values['language'] = (string) get_parameter('language');
|
||||
$values['timezone'] = (string) get_parameter('timezone');
|
||||
@ -573,17 +614,17 @@ if ($update_user) {
|
||||
$values['block_size'] = get_parameter('block_size', $config['block_size']);
|
||||
|
||||
$values['section'] = get_parameter('section');
|
||||
if (($values['section'] == 'Event list') || ($values['section'] == 'Group view') || ($values['section'] == 'Alert detail') || ($values['section'] == 'Tactical view') || ($values['section'] == 'Default')) {
|
||||
if (($values['section'] === 'Event list') || ($values['section'] === 'Group view') || ($values['section'] === 'Alert detail') || ($values['section'] === 'Tactical view') || ($values['section'] === 'Default')) {
|
||||
$values['data_section'] = '';
|
||||
} else if ($values['section'] == 'Dashboard') {
|
||||
} else if ($values['section'] === 'Dashboard') {
|
||||
$values['data_section'] = $dashboard;
|
||||
} else if (io_safe_output($values['section']) == 'Visual console') {
|
||||
} else if (io_safe_output($values['section']) === 'Visual console') {
|
||||
$values['data_section'] = $visual_console;
|
||||
} else if ($values['section'] == 'Other' || io_safe_output($values['section']) == 'External link') {
|
||||
} else if ($values['section'] === 'Other' || io_safe_output($values['section']) === 'External link') {
|
||||
$values['data_section'] = get_parameter('data_section');
|
||||
}
|
||||
|
||||
if (enterprise_installed() && defined('METACONSOLE')) {
|
||||
if (enterprise_installed() === true && is_metaconsole() === true) {
|
||||
$values['metaconsole_access'] = get_parameter('metaconsole_access');
|
||||
$values['metaconsole_agents_manager'] = get_parameter('metaconsole_agents_manager', '0');
|
||||
$values['metaconsole_access_node'] = get_parameter('metaconsole_access_node', '0');
|
||||
@ -611,9 +652,9 @@ if ($update_user) {
|
||||
$correct_password = true;
|
||||
}
|
||||
|
||||
if ($password_confirm == $password_new) {
|
||||
if ((string) $password_confirm === (string) $password_new) {
|
||||
if ($correct_password === true || is_user_admin($config['id_user'])) {
|
||||
if ((!is_user_admin($config['id_user']) || $config['enable_pass_policy_admin']) && $config['enable_pass_policy']) {
|
||||
if ((is_user_admin($config['id_user']) === false || $config['enable_pass_policy_admin']) && $config['enable_pass_policy']) {
|
||||
$pass_ok = login_validate_pass($password_new, $id, true);
|
||||
if ($pass_ok != 1) {
|
||||
ui_print_error_message($pass_ok);
|
||||
@ -704,19 +745,23 @@ if ($update_user) {
|
||||
"Block size":"'.$values['block_size'].'",
|
||||
"Section":"'.$values['section'].'"';
|
||||
|
||||
if ($values['allowed_ip_active'] === true) {
|
||||
$info .= ',"IPS Allowed":"'.$values['allowed_ip_list'].'"';
|
||||
}
|
||||
|
||||
if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) {
|
||||
$info .= ',"Skin":"'.$values['id_skin'].'"';
|
||||
$has_skin = true;
|
||||
}
|
||||
|
||||
if (enterprise_installed() && defined('METACONSOLE')) {
|
||||
if (enterprise_installed() === true && is_metaconsole() === true) {
|
||||
$info .= ',"Wizard access":"'.$values['metaconsole_access'].'"}';
|
||||
$has_wizard = true;
|
||||
} else if ($has_skin) {
|
||||
} else if ($has_skin === true) {
|
||||
$info .= '}';
|
||||
}
|
||||
|
||||
if (!$has_skin && !$has_wizard) {
|
||||
if ($has_skin === false && $has_wizard === false) {
|
||||
$info .= '}';
|
||||
}
|
||||
|
||||
@ -744,7 +789,7 @@ if ($update_user) {
|
||||
}
|
||||
|
||||
|
||||
if ($values['strict_acl']) {
|
||||
if ((bool) $values['strict_acl'] === true) {
|
||||
$count_groups = 0;
|
||||
$count_tags = 0;
|
||||
|
||||
@ -754,7 +799,7 @@ if ($update_user) {
|
||||
}
|
||||
|
||||
foreach ($profiles as $profile) {
|
||||
$count_groups = ($count_groups + 1);
|
||||
$count_groups++;
|
||||
$arr_tags = explode(',', $profile['tags']);
|
||||
$count_tags = ($count_tags + count($arr_tags));
|
||||
}
|
||||
@ -783,7 +828,7 @@ if ($add_profile && empty($json_profile)) {
|
||||
$no_hierarchy = (int) get_parameter('no_hierarchy', 0);
|
||||
|
||||
foreach ($tags as $k => $tag) {
|
||||
if (empty($tag)) {
|
||||
if (empty($tag) === true) {
|
||||
unset($tags[$k]);
|
||||
}
|
||||
}
|
||||
@ -798,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'),
|
||||
@ -826,7 +875,7 @@ if (!users_is_admin() && $config['id_user'] != $id && !$new_user) {
|
||||
);
|
||||
|
||||
$result = db_get_all_rows_sql($sql);
|
||||
if ($result == false && $user_info['is_admin'] == false) {
|
||||
if ((bool) $result === false && (bool) $user_info['is_admin'] === false) {
|
||||
db_pandora_audit(
|
||||
AUDIT_LOG_ACL_VIOLATION,
|
||||
'Trying to access User Management'
|
||||
@ -837,12 +886,13 @@ if (!users_is_admin() && $config['id_user'] != $id && !$new_user) {
|
||||
}
|
||||
}
|
||||
|
||||
if (defined('METACONSOLE')) {
|
||||
if ($id) {
|
||||
echo '<div class="user_form_title">'.__('Update User').'</div>';
|
||||
} else {
|
||||
echo '<div class="user_form_title">'.__('Create User').'</div>';
|
||||
}
|
||||
if (is_metaconsole() === true) {
|
||||
html_print_div(
|
||||
[
|
||||
'class' => 'user_form_title',
|
||||
'content' => ((bool) $id === true) ? __('Update User') : __('Create User'),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if (!$new_user) {
|
||||
@ -1030,6 +1080,26 @@ $comments .= html_print_textarea(
|
||||
true
|
||||
);
|
||||
|
||||
$allowedIP = '<p class="edit_user_labels">';
|
||||
$allowedIP .= __('Login allowed IP list').' ';
|
||||
$allowedIP .= ui_print_help_tip(__('Add the source IPs that will allow console access. Each IP must be separated only by comma. * allows all.'), true).' ';
|
||||
$allowedIP .= html_print_checkbox_switch(
|
||||
'allowed_ip_active',
|
||||
0,
|
||||
$user_info['allowed_ip_active'],
|
||||
true
|
||||
);
|
||||
$allowedIP .= '</p>';
|
||||
$allowedIP .= html_print_textarea(
|
||||
'allowed_ip_list',
|
||||
2,
|
||||
65,
|
||||
$user_info['allowed_ip_list'],
|
||||
(((bool) $view_mode === true) ? 'readonly="readonly"' : ''),
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
// If we want to create a new user, skins displayed are the skins of the creator's group. If we want to update, skins displayed are the skins of the modified user.
|
||||
$own_info = get_user_info($config['id_user']);
|
||||
if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) {
|
||||
@ -1046,8 +1116,8 @@ if ($new_user) {
|
||||
$id_usr = $id;
|
||||
}
|
||||
|
||||
if (!$meta) {
|
||||
// User only can change skins if has more than one group
|
||||
if ((bool) $meta === false) {
|
||||
// User only can change skins if has more than one group.
|
||||
if (count($usr_groups) > 1) {
|
||||
if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) {
|
||||
$skin = '<div class="label_select"><p class="edit_user_labels">'.__('Skin').'</p>';
|
||||
@ -1056,7 +1126,7 @@ if (!$meta) {
|
||||
}
|
||||
}
|
||||
|
||||
if ($meta) {
|
||||
if ((bool) $meta === true) {
|
||||
$array_filters = get_filters_custom_fields_view(0, true);
|
||||
|
||||
$search_custom_fields_view = '<div class="label_select"><p class="edit_user_labels">'.__('Search custom field view').' '.ui_print_help_tip(__('Load by default the selected view in custom field view'), true).'</p>';
|
||||
@ -1413,6 +1483,20 @@ echo '</div>
|
||||
<div class="user_edit_third_row white_box">
|
||||
<div class="edit_user_comments">'.$comments.'</div>
|
||||
</div>';
|
||||
|
||||
html_print_div(
|
||||
[
|
||||
'class' => 'user_edit_third_row white_box',
|
||||
'content' => html_print_div(
|
||||
[
|
||||
'class' => 'edit_user_allowed_ip',
|
||||
'content' => $allowedIP,
|
||||
],
|
||||
true
|
||||
),
|
||||
]
|
||||
);
|
||||
|
||||
if (!empty($ehorus)) {
|
||||
echo '<div class="user_edit_third_row white_box">'.$ehorus.'</div>';
|
||||
}
|
||||
@ -1431,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 />';
|
||||
|
||||
@ -1552,13 +1636,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();
|
||||
@ -1580,10 +1669,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>
|
||||
@ -1593,6 +1686,10 @@ $(document).ready (function () {
|
||||
<td>${img_delete}</td>
|
||||
</tr>`
|
||||
);
|
||||
|
||||
getGroupIcon(group, $(`#img_group_${aux}`));
|
||||
aux++;
|
||||
|
||||
} else {
|
||||
this.form.submit();
|
||||
}
|
||||
|
@ -31,8 +31,6 @@ global $config;
|
||||
|
||||
check_login();
|
||||
|
||||
enterprise_hook('open_meta_frame');
|
||||
|
||||
require_once $config['homedir'].'/include/functions_profile.php';
|
||||
require_once $config['homedir'].'/include/functions_users.php';
|
||||
require_once $config['homedir'].'/include/functions_groups.php';
|
||||
@ -52,8 +50,47 @@ if (is_ajax()) {
|
||||
$method = get_parameter('method');
|
||||
$group_id = get_parameter('group_id');
|
||||
$group_recursion = (bool) get_parameter('group_recursion', 0);
|
||||
$get_user_profile_group = (bool) get_parameter('get_user_profile_group', false);
|
||||
|
||||
$return_all = false;
|
||||
|
||||
if ($get_user_profile_group === true) {
|
||||
$id_user = get_parameter('id_user');
|
||||
|
||||
$user_is_admin = users_is_admin();
|
||||
|
||||
$user_profiles = [];
|
||||
|
||||
if ($user_is_admin === false) {
|
||||
$group_um = users_get_groups_UM($config['id_user']);
|
||||
}
|
||||
|
||||
// User profiles.
|
||||
if ($user_is_admin || $id_user == $config['id_user'] || isset($group_um[0])) {
|
||||
$user_profiles = db_get_all_rows_field_filter(
|
||||
'tusuario_perfil',
|
||||
'id_usuario',
|
||||
$id_user
|
||||
);
|
||||
} else {
|
||||
$user_profiles_aux = users_get_user_profile($id_user);
|
||||
foreach ($group_um as $key => $value) {
|
||||
if (isset($user_profiles_aux[$key]) === true) {
|
||||
$user_profiles[$key] = $user_profiles_aux[$key];
|
||||
unset($user_profiles_aux[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($user_profiles as $key => $value) {
|
||||
$user_profiles[$key]['id_perfil'] = profile_get_name($value['id_perfil']);
|
||||
$user_profiles[$key]['id_grupo'] = groups_get_name($value['id_grupo'], true);
|
||||
}
|
||||
|
||||
echo json_encode($user_profiles);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($group_id == -1) {
|
||||
$sql = 'SELECT tusuario.id_user FROM tusuario
|
||||
LEFT OUTER JOIN tusuario_perfil
|
||||
@ -95,6 +132,8 @@ if (is_ajax()) {
|
||||
}
|
||||
}
|
||||
|
||||
enterprise_hook('open_meta_frame');
|
||||
|
||||
$sortField = get_parameter('sort_field');
|
||||
$sort = get_parameter('sort', 'none');
|
||||
$tab = get_parameter('tab', 'user');
|
||||
@ -265,71 +304,75 @@ $delete_user = (bool) get_parameter('user_del', false);
|
||||
if ($delete_user === true) {
|
||||
// Delete user.
|
||||
$id_user = get_parameter('delete_user', 0);
|
||||
if (users_is_admin($id_user) === true && users_is_admin() === false) {
|
||||
db_pandora_audit(
|
||||
AUDIT_LOG_ACL_VIOLATION,
|
||||
'Trying to delete admininstrator user by non administrator user '.$config['id_user']
|
||||
);
|
||||
|
||||
include 'general/noaccess.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
// Only allow delete user if is not the actual user.
|
||||
if ($id_user != $config['id_user']) {
|
||||
$user_row = users_get_user_by_id($id_user);
|
||||
|
||||
$result = delete_user($id_user);
|
||||
|
||||
if ($result) {
|
||||
if ($id_user !== 0) {
|
||||
if (users_is_admin($id_user) === true && users_is_admin() === false) {
|
||||
db_pandora_audit(
|
||||
AUDIT_LOG_USER_MANAGEMENT,
|
||||
__('Deleted user %s', io_safe_output($id_user))
|
||||
AUDIT_LOG_ACL_VIOLATION,
|
||||
'Trying to delete admininstrator user by non administrator user '.$config['id_user']
|
||||
);
|
||||
|
||||
include 'general/noaccess.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
ui_print_result_message(
|
||||
$result,
|
||||
__('Successfully deleted'),
|
||||
__('There was a problem deleting the user')
|
||||
);
|
||||
// Only allow delete user if is not the actual user.
|
||||
if ($id_user != $config['id_user']) {
|
||||
$user_row = users_get_user_by_id($id_user);
|
||||
|
||||
// Delete the user in all the consoles.
|
||||
if (is_metaconsole() === true && isset($_GET['delete_all'])) {
|
||||
$servers = metaconsole_get_servers();
|
||||
foreach ($servers as $server) {
|
||||
// Connect to the remote console.
|
||||
if (metaconsole_connect($server) === NOERR) {
|
||||
// Delete the user.
|
||||
$result = delete_user($id_user);
|
||||
$result = delete_user($id_user);
|
||||
|
||||
if ($result) {
|
||||
db_pandora_audit(
|
||||
AUDIT_LOG_USER_MANAGEMENT,
|
||||
__('Deleted user %s', io_safe_output($id_user))
|
||||
);
|
||||
}
|
||||
|
||||
ui_print_result_message(
|
||||
$result,
|
||||
__('Successfully deleted'),
|
||||
__('There was a problem deleting the user')
|
||||
);
|
||||
|
||||
// Delete the user in all the consoles.
|
||||
if (is_metaconsole() === true && isset($_GET['delete_all'])) {
|
||||
$servers = metaconsole_get_servers();
|
||||
foreach ($servers as $server) {
|
||||
// Connect to the remote console.
|
||||
if (metaconsole_connect($server) === NOERR) {
|
||||
// Delete the user.
|
||||
$result = delete_user($id_user);
|
||||
if ($result) {
|
||||
db_pandora_audit(
|
||||
AUDIT_LOG_USER_MANAGEMENT,
|
||||
__('Deleted user %s from metaconsole', io_safe_input($id_user))
|
||||
);
|
||||
}
|
||||
|
||||
// Restore the db connection.
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
|
||||
// Log to the metaconsole too.
|
||||
if ($result) {
|
||||
db_pandora_audit(
|
||||
AUDIT_LOG_USER_MANAGEMENT,
|
||||
__('Deleted user %s from metaconsole', io_safe_input($id_user))
|
||||
__('Deleted user %s from %s', io_safe_input($id_user), io_safe_input($server['server_name']))
|
||||
);
|
||||
}
|
||||
|
||||
// Restore the db connection.
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
|
||||
// Log to the metaconsole too.
|
||||
if ($result) {
|
||||
db_pandora_audit(
|
||||
AUDIT_LOG_USER_MANAGEMENT,
|
||||
__('Deleted user %s from %s', io_safe_input($id_user), io_safe_input($server['server_name']))
|
||||
ui_print_result_message(
|
||||
$result,
|
||||
__('Successfully deleted from %s', io_safe_input($server['server_name'])),
|
||||
__('There was a problem deleting the user from %s', io_safe_input($server['server_name']))
|
||||
);
|
||||
}
|
||||
|
||||
ui_print_result_message(
|
||||
$result,
|
||||
__('Successfully deleted from %s', io_safe_input($server['server_name'])),
|
||||
__('There was a problem deleting the user from %s', io_safe_input($server['server_name']))
|
||||
);
|
||||
}
|
||||
} else {
|
||||
ui_print_error_message(__('There was a problem deleting the user'));
|
||||
}
|
||||
} else {
|
||||
ui_print_error_message(__('There was a problem deleting the user'));
|
||||
ui_print_error_message(__('ID user cannot be empty'));
|
||||
}
|
||||
} else if (isset($_GET['profile_del'])) {
|
||||
// Delete profile.
|
||||
@ -586,15 +629,17 @@ $rowPair = true;
|
||||
$iterator = 0;
|
||||
$cont = 0;
|
||||
foreach ($info as $user_id => $user_info) {
|
||||
if (empty($user_id) === true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// User profiles.
|
||||
if ($user_is_admin || $user_id == $config['id_user'] || isset($group_um[0])) {
|
||||
$user_profiles = db_get_all_rows_field_filter(
|
||||
'tusuario_perfil',
|
||||
'id_usuario',
|
||||
$user_id
|
||||
$user_profiles = db_get_all_rows_sql(
|
||||
'SELECT * FROM tusuario_perfil where id_usuario LIKE "'.$user_id.'" LIMIT 5'
|
||||
);
|
||||
} else {
|
||||
$user_profiles_aux = users_get_user_profile($user_id);
|
||||
$user_profiles_aux = users_get_user_profile($user_id, 'LIMIT 5');
|
||||
$user_profiles = [];
|
||||
foreach ($group_um as $key => $value) {
|
||||
if (isset($user_profiles_aux[$key]) === true) {
|
||||
@ -674,39 +719,35 @@ foreach ($info as $user_id => $user_info) {
|
||||
if ($user_profiles !== false) {
|
||||
$total_profile = 0;
|
||||
|
||||
$data[4] .= '<div class="text_end">';
|
||||
$data[4] .= '<div class="text_end">';
|
||||
foreach ($user_profiles as $row) {
|
||||
if ($total_profile <= 5) {
|
||||
$data[4] .= "<div class='float-left'>";
|
||||
$data[4] .= profile_get_name($row['id_perfil']);
|
||||
$data[4] .= ' / </div>';
|
||||
$data[4] .= "<div class='float-left pdd_l_5px'>";
|
||||
$data[4] .= groups_get_name($row['id_grupo'], true);
|
||||
$data[4] .= '</div>';
|
||||
$data[4] .= "<div class='float-left'>";
|
||||
$data[4] .= profile_get_name($row['id_perfil']);
|
||||
$data[4] .= ' / </div>';
|
||||
$data[4] .= "<div class='float-left pdd_l_5px'>";
|
||||
$data[4] .= groups_get_name($row['id_grupo'], true);
|
||||
$data[4] .= '</div>';
|
||||
|
||||
if ($total_profile == 0 && count($user_profiles) >= 5) {
|
||||
$data[4] .= '<span onclick="showGroups()" class="pdd_l_15px">
|
||||
'.html_print_image(
|
||||
'images/zoom.png',
|
||||
true,
|
||||
[
|
||||
'title' => __('Show'),
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
).'</span>';
|
||||
}
|
||||
if ($total_profile == 0 && count($user_profiles) >= 5) {
|
||||
$data[4] .= '<span onclick="showGroups(`'.$row['id_usuario'].'`)">'.html_print_image(
|
||||
'images/zoom.png',
|
||||
true,
|
||||
[
|
||||
'title' => __('Show profiles'),
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
).'</span>';
|
||||
|
||||
$data[4] .= '<br />';
|
||||
$data[4] .= '<br />';
|
||||
$data[4] .= '</div>';
|
||||
} else {
|
||||
$data[4] .= "<div id='groups_list' class='invisible'>";
|
||||
$data[4] .= '<div >';
|
||||
$data[4] .= profile_get_name($row['id_perfil']);
|
||||
$data[4] .= ' / '.groups_get_name($row['id_grupo'], true).'</div>';
|
||||
$data[4] .= '<br/>';
|
||||
$data[4] .= html_print_input_hidden(
|
||||
'show_groups_'.$row['id_usuario'],
|
||||
-1,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
$data[4] .= '<br/>';
|
||||
$data[4] .= '<br/>';
|
||||
|
||||
$total_profile++;
|
||||
}
|
||||
|
||||
@ -719,6 +760,8 @@ foreach ($info as $user_id => $user_info) {
|
||||
}
|
||||
|
||||
$data[4] .= '</div>';
|
||||
$data[4] .= '<div class="invisible" id="profiles_'.$user_profiles[0]['id_usuario'].'">';
|
||||
$data[4] .= '</div>';
|
||||
} else {
|
||||
$data[4] .= __('The user doesn\'t have any assigned profile/group');
|
||||
}
|
||||
@ -882,16 +925,46 @@ echo '</div>';
|
||||
|
||||
enterprise_hook('close_meta_frame');
|
||||
|
||||
echo '<script type="text/javascript">
|
||||
function showGroups(){
|
||||
var groups_list = document.getElementById("groups_list");
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
function showGroups(id_user) {
|
||||
if ($(`#hidden-show_groups_${id_user}`).val() === '-1') {
|
||||
var request = $.ajax({
|
||||
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
page: 'godmode/users/user_list',
|
||||
get_user_profile_group: 1,
|
||||
id_user: id_user
|
||||
},
|
||||
success: function (data, textStatus, xhr) {
|
||||
let count = 1;
|
||||
data.forEach( function(valor, indice, array) {
|
||||
if (count >= 6) {
|
||||
let main_div = $(`#profiles_${id_user}`);
|
||||
main_div.append(
|
||||
`<div id="left_${id_user}_${count}" class='float-left'>${valor.id_perfil} / </div>`,
|
||||
`<div id="right_${id_user}_${count}" class='float-left pdd_l_5px'>${valor.id_grupo}</div>`,
|
||||
`<br/><br/>`
|
||||
);
|
||||
}
|
||||
count ++;
|
||||
});
|
||||
},
|
||||
error: function (e, textStatus) {
|
||||
console.error(textStatus);
|
||||
}
|
||||
});
|
||||
$(`#hidden-show_groups_${id_user}`).val('1');
|
||||
$(`#profiles_${id_user}`).show();
|
||||
} else if ($(`#hidden-show_groups_${id_user}`).val() === '1') {
|
||||
$(`#hidden-show_groups_${id_user}`).val('0');
|
||||
$(`#profiles_${id_user}`).hide();
|
||||
} else {
|
||||
$(`#hidden-show_groups_${id_user}`).val('1');
|
||||
$(`#profiles_${id_user}`).show();
|
||||
}
|
||||
}
|
||||
|
||||
if(groups_list.style.display == "none"){
|
||||
document.querySelectorAll("[id=groups_list]").forEach(element=>
|
||||
element.style.display = "block");
|
||||
}else{
|
||||
document.querySelectorAll("[id=groups_list]").forEach(element=>
|
||||
element.style.display = "none");
|
||||
};
|
||||
}
|
||||
</script>';
|
||||
</script>
|
||||
|
@ -941,6 +941,7 @@ class HostDevices extends Wizard
|
||||
'return' => true,
|
||||
'class' => 'discovery_list_input',
|
||||
'simple_multiple_options' => true,
|
||||
'required' => true,
|
||||
]
|
||||
);
|
||||
|
||||
@ -1001,6 +1002,7 @@ class HostDevices extends Wizard
|
||||
$("#text-interval_text").val(10);
|
||||
$("#hidden-interval").val('.$interval.');
|
||||
$("#interval_units").val('.$unit.');
|
||||
$("#interval_units").trigger("change");
|
||||
}
|
||||
}).change();
|
||||
|
||||
|
BIN
pandora_console/images/console/icons/europemap_bad.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
pandora_console/images/console/icons/europemap_ok.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
pandora_console/images/console/icons/europemap_warning.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
pandora_console/images/console/icons/spainmap_bad.png
Normal file
After Width: | Height: | Size: 9.0 KiB |
BIN
pandora_console/images/console/icons/spainmap_ok.png
Normal file
After Width: | Height: | Size: 9.1 KiB |
BIN
pandora_console/images/console/icons/spainmap_warning.png
Normal file
After Width: | Height: | Size: 8.9 KiB |
BIN
pandora_console/images/console/icons/worldmap_bad.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
pandora_console/images/console/icons/worldmap_ok.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
pandora_console/images/console/icons/worldmap_warning.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
pandora_console/images/widgets/GroupedMeterGraphs.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
@ -647,7 +647,12 @@ if ($get_agent_alerts_datatable === true) {
|
||||
$order = get_datatable_order(true);
|
||||
$url = get_parameter('url', '#');
|
||||
|
||||
$free_search_alert = $filter_alert['free_search_alert'];
|
||||
if (empty($filter_alert['free_search']) === false) {
|
||||
$free_search_alert = $filter_alert['free_search'];
|
||||
} else {
|
||||
$free_search_alert = $filter_alert['free_search_alert'];
|
||||
}
|
||||
|
||||
$idGroup = $filter_alert['ag_group'];
|
||||
$tag_filter = $filter_alert['tag_filter'];
|
||||
$action_filter = $filter_alert['action'];
|
||||
@ -676,7 +681,7 @@ if ($get_agent_alerts_datatable === true) {
|
||||
$selectLastFiredDown = false;
|
||||
|
||||
switch ($sortField) {
|
||||
case 'module':
|
||||
case 'agent_module_name':
|
||||
switch ($sort) {
|
||||
case 'asc':
|
||||
$selectModuleasc = $selected;
|
||||
@ -696,7 +701,7 @@ if ($get_agent_alerts_datatable === true) {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'template':
|
||||
case 'template_name':
|
||||
switch ($sort) {
|
||||
case 'asc':
|
||||
$selectTemplateasc = $selected;
|
||||
@ -736,7 +741,7 @@ if ($get_agent_alerts_datatable === true) {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'agent':
|
||||
case 'agent_name':
|
||||
switch ($sort) {
|
||||
case 'asc':
|
||||
$selectLastFiredasc = $selected;
|
||||
@ -857,7 +862,7 @@ if ($get_agent_alerts_datatable === true) {
|
||||
if (is_metaconsole() === true) {
|
||||
include_once $config['homedir'].'/enterprise/meta/include/functions_alerts_meta.php';
|
||||
if ($idAgent != 0) {
|
||||
$alerts['alerts_simple'] = alerts_meta_get_alerts($agents, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter);
|
||||
$alerts['alerts_simple'] = alerts_meta_get_alerts($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter);
|
||||
|
||||
$countAlertsSimple = alerts_meta_get_alerts($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter);
|
||||
} else {
|
||||
@ -865,7 +870,7 @@ if ($get_agent_alerts_datatable === true) {
|
||||
users_get_groups($config['id_user'], 'AR', false)
|
||||
);
|
||||
|
||||
$alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter);
|
||||
$alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter);
|
||||
|
||||
$countAlertsSimple = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter);
|
||||
}
|
||||
@ -885,12 +890,32 @@ if ($get_agent_alerts_datatable === true) {
|
||||
}
|
||||
}
|
||||
|
||||
// Order and pagination metacosole.
|
||||
if (is_metaconsole() === true) {
|
||||
// Status order.
|
||||
if ($sortField === 'status') {
|
||||
foreach ($alerts['alerts_simple'] as $i => $alert) {
|
||||
if ($alert['times_fired'] > 0) {
|
||||
$alerts['alerts_simple'][$i]['status'] = '3';
|
||||
} else if ($alert['disabled'] > 0) {
|
||||
$alerts['alerts_simple'][$i]['status'] = '1';
|
||||
} else {
|
||||
$alerts['alerts_simple'][$i]['status'] = '2';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
usort($alerts['alerts_simple'], arrayOutputSorting($sort, $sortField));
|
||||
$alerts['alerts_simple'] = array_slice($alerts['alerts_simple'], $start, $length);
|
||||
}
|
||||
|
||||
$data = [];
|
||||
if ($alerts['alerts_simple']) {
|
||||
foreach ($alerts['alerts_simple'] as $alert) {
|
||||
$data[] = ui_format_alert_row($alert, true, $url, 'font-size: 7pt;');
|
||||
}
|
||||
|
||||
|
||||
$data = array_reduce(
|
||||
$data,
|
||||
function ($carry, $row) {
|
||||
@ -902,11 +927,11 @@ if ($get_agent_alerts_datatable === true) {
|
||||
$tmp->policy = $row[0];
|
||||
$tmp->standby = $row[1];
|
||||
$tmp->force = $row[2];
|
||||
$tmp->agent = $row[3];
|
||||
$tmp->module = $row[4];
|
||||
$tmp->template = $row[5];
|
||||
$tmp->agent_name = $row[3];
|
||||
$tmp->agent_module_name = $row[4];
|
||||
$tmp->template_name = $row[5];
|
||||
$tmp->action = $row[6];
|
||||
$tmp->lastFired = $row[7];
|
||||
$tmp->last_fired = $row[7];
|
||||
$tmp->status = $row[8];
|
||||
$tmp->validate = $row[9];
|
||||
|
||||
@ -916,6 +941,7 @@ if ($get_agent_alerts_datatable === true) {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Datatables format: RecordsTotal && recordsfiltered.
|
||||
echo json_encode(
|
||||
[
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -64,9 +64,9 @@ $add_comment = (bool) get_parameter('add_comment');
|
||||
$dialogue_event_response = (bool) get_parameter('dialogue_event_response');
|
||||
$perform_event_response = (bool) get_parameter('perform_event_response');
|
||||
$get_response = (bool) get_parameter('get_response');
|
||||
$get_response_target = (bool) get_parameter('get_response_target');
|
||||
$get_response_params = (bool) get_parameter('get_response_params');
|
||||
$get_response_description = (bool) get_parameter('get_response_description');
|
||||
$get_response_massive = (bool) get_parameter('get_response_massive');
|
||||
$get_row_response_action = (bool) get_parameter('get_row_response_action');
|
||||
$draw_row_response_info = (bool) get_parameter('draw_row_response_info', false);
|
||||
$meta = get_parameter('meta', 0);
|
||||
$history = get_parameter('history', 0);
|
||||
$table_events = get_parameter('table_events', 0);
|
||||
@ -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');
|
||||
@ -372,8 +378,8 @@ if ($save_event_filter) {
|
||||
$values['custom_data'] = get_parameter('custom_data');
|
||||
$values['custom_data_filter_type'] = get_parameter('custom_data_filter_type');
|
||||
|
||||
if (is_metaconsole()) {
|
||||
$values['server_id'] = get_parameter('server_id');
|
||||
if (is_metaconsole() === true) {
|
||||
$values['server_id'] = implode(',', get_parameter('server_id'));
|
||||
}
|
||||
|
||||
$exists = (bool) db_get_value_filter(
|
||||
@ -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');
|
||||
@ -430,7 +437,7 @@ if ($update_event_filter) {
|
||||
$values['custom_data_filter_type'] = get_parameter('custom_data_filter_type');
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
$values['server_id'] = get_parameter('server_id');
|
||||
$values['server_id'] = implode(',', get_parameter('server_id'));
|
||||
}
|
||||
|
||||
if (io_safe_output($values['tag_with']) == '["0"]') {
|
||||
@ -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')
|
||||
@ -900,6 +909,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(),
|
||||
@ -976,6 +986,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(),
|
||||
@ -1054,87 +1065,6 @@ $(document).ready(function (){
|
||||
}
|
||||
|
||||
|
||||
if ($get_response_description) {
|
||||
$response_id = get_parameter('response_id');
|
||||
|
||||
$description = db_get_value('description', 'tevent_response', 'id', $response_id);
|
||||
|
||||
if ($description === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$description = io_safe_output($description);
|
||||
$description = str_replace("\r\n", '<br>', $description);
|
||||
|
||||
echo $description;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($get_response_params) {
|
||||
if (! check_acl($config['id_user'], 0, 'EW')) {
|
||||
echo 'unauthorized';
|
||||
return;
|
||||
}
|
||||
|
||||
$response_id = get_parameter('response_id');
|
||||
|
||||
$params = db_get_value('params', 'tevent_response', 'id', $response_id);
|
||||
|
||||
if ($params === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo json_encode(explode(',', $params));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($get_response_target === true) {
|
||||
if (! check_acl($config['id_user'], 0, 'EW')) {
|
||||
echo 'unauthorized';
|
||||
return;
|
||||
}
|
||||
|
||||
$response_id = (int) get_parameter('response_id');
|
||||
$event_id = (int) get_parameter('event_id');
|
||||
$server_id = (int) get_parameter('server_id');
|
||||
|
||||
try {
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node = new Node($server_id);
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
$event_response = db_get_row('tevent_response', 'id', $response_id);
|
||||
|
||||
if (empty($event_response) === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo events_get_response_target($event_id, $response_id);
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
||||
return;
|
||||
} finally {
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($get_response === true) {
|
||||
if (! check_acl($config['id_user'], 0, 'EW')) {
|
||||
echo 'unauthorized';
|
||||
@ -1142,62 +1072,27 @@ if ($get_response === true) {
|
||||
}
|
||||
|
||||
$response_id = get_parameter('response_id');
|
||||
$server_id = (int) get_parameter('server_id');
|
||||
$server_id = (int) get_parameter('server_id', 0);
|
||||
$event_id = (int) get_parameter('event_id', 0);
|
||||
$response_parameters = json_decode(
|
||||
io_safe_output(
|
||||
get_parameter('response_parameters', '')
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
try {
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node = new Node($server_id);
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
$event_response = db_get_row(
|
||||
'tevent_response',
|
||||
'id',
|
||||
$response_id
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
||||
return;
|
||||
} finally {
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
$event_response = db_get_row(
|
||||
'tevent_response',
|
||||
'id',
|
||||
$response_id
|
||||
);
|
||||
|
||||
if (empty($event_response) === true) {
|
||||
return;
|
||||
return [];
|
||||
}
|
||||
|
||||
echo json_encode($event_response);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($perform_event_response === true) {
|
||||
global $config;
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'EW')) {
|
||||
echo 'unauthorized';
|
||||
return;
|
||||
}
|
||||
|
||||
$target = get_parameter('target', '');
|
||||
$response_id = get_parameter('response_id');
|
||||
$event_id = (int) get_parameter('event_id');
|
||||
$server_id = (int) get_parameter('server_id', 0);
|
||||
|
||||
$event_response = false;
|
||||
if (empty($target) === true) {
|
||||
if (empty($event_id) === false) {
|
||||
try {
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
@ -1206,20 +1101,12 @@ if ($perform_event_response === true) {
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
$event_response = db_get_row(
|
||||
'tevent_response',
|
||||
'id',
|
||||
$response_id
|
||||
);
|
||||
|
||||
if (empty($event_response) === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
$command = events_get_response_target(
|
||||
$event_response['target'] = events_get_response_target(
|
||||
$event_id,
|
||||
$response_id,
|
||||
$server_id
|
||||
$event_response,
|
||||
$response_parameters,
|
||||
$server_id,
|
||||
($server_id !== 0) ? $node->server_name() : 'Metaconsole'
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
@ -1237,10 +1124,130 @@ if ($perform_event_response === true) {
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$command = $target;
|
||||
}
|
||||
|
||||
echo json_encode($event_response);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ($get_response_massive === true) {
|
||||
if (! check_acl($config['id_user'], 0, 'EW')) {
|
||||
echo 'unauthorized';
|
||||
return;
|
||||
}
|
||||
|
||||
$response_id = get_parameter('response_id');
|
||||
|
||||
$event_response = db_get_row(
|
||||
'tevent_response',
|
||||
'id',
|
||||
$response_id
|
||||
);
|
||||
|
||||
if (empty($event_response) === true) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$events = json_decode(
|
||||
io_safe_output(
|
||||
get_parameter('events', '')
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$response_parameters = json_decode(
|
||||
io_safe_output(
|
||||
get_parameter('response_parameters', '')
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$event_response_targets = [];
|
||||
if (is_metaconsole() === true) {
|
||||
foreach ($events as $server_id => $idEvents) {
|
||||
foreach ($idEvents as $idEvent) {
|
||||
$event_response_targets[$idEvent.'|'.$server_id]['target'] = get_events_get_response_target(
|
||||
$idEvent,
|
||||
$event_response,
|
||||
$server_id,
|
||||
$response_parameters
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($events as $idEvent) {
|
||||
$event_response_targets[$idEvent]['target'] = get_events_get_response_target(
|
||||
$idEvent,
|
||||
$event_response,
|
||||
0,
|
||||
$response_parameters
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$result = [
|
||||
'event_response' => $event_response,
|
||||
'event_response_targets' => $event_response_targets,
|
||||
];
|
||||
|
||||
echo json_encode($result);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($get_row_response_action === true) {
|
||||
$response_id = get_parameter('response_id');
|
||||
$response = json_decode(
|
||||
io_safe_output(
|
||||
get_parameter('response', '')
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$end = (bool) get_parameter('end', false);
|
||||
$index = $response['event_id'];
|
||||
if (is_metaconsole() === true) {
|
||||
$index .= '-'.$response['server_id'];
|
||||
}
|
||||
|
||||
echo get_row_response_action(
|
||||
$response,
|
||||
$response_id,
|
||||
$end,
|
||||
$index
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($perform_event_response === true) {
|
||||
global $config;
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'EW')) {
|
||||
echo __('unauthorized');
|
||||
return;
|
||||
}
|
||||
|
||||
$target = get_parameter('target', '');
|
||||
$response_id = get_parameter('response_id');
|
||||
$event_id = (int) get_parameter('event_id');
|
||||
$server_id = (int) get_parameter('server_id', 0);
|
||||
$response = json_decode(
|
||||
io_safe_output(
|
||||
get_parameter('response', '')
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$event_response = $response;
|
||||
if (empty($event_response) === true) {
|
||||
echo __('No data');
|
||||
return;
|
||||
}
|
||||
|
||||
$command = $event_response['target'];
|
||||
$command_timeout = ($event_response !== false) ? $event_response['command_timeout'] : 90;
|
||||
if (enterprise_installed() === true) {
|
||||
if ($event_response !== false
|
||||
@ -1320,7 +1327,7 @@ if ($perform_event_response === true) {
|
||||
break;
|
||||
}
|
||||
|
||||
system($timeout_bin.' '.$command_timeout.' '.io_safe_output($command).' 2>&1', $ret_val);
|
||||
system($timeout_bin.' '.$command_timeout.' '.io_safe_output($command).' 2>&1', $ret_val);
|
||||
}
|
||||
|
||||
if ($ret_val != 0) {
|
||||
@ -1343,78 +1350,19 @@ if ($dialogue_event_response) {
|
||||
$event_id = get_parameter('event_id');
|
||||
$response_id = get_parameter('response_id');
|
||||
$command = get_parameter('target');
|
||||
$massive = get_parameter('massive');
|
||||
$end = get_parameter('end');
|
||||
$show_execute_again_btn = get_parameter('show_execute_again_btn');
|
||||
$out_iterator = get_parameter('out_iterator');
|
||||
$event_response = db_get_row('tevent_response', 'id', $response_id);
|
||||
$server_id = get_parameter('server_id');
|
||||
$event_response = json_decode(
|
||||
io_safe_output(
|
||||
get_parameter('response', '')
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$event = db_get_row('tevento', 'id_evento', $event_id);
|
||||
|
||||
$prompt = '<br>> ';
|
||||
switch ($event_response['type']) {
|
||||
case 'command':
|
||||
$display_command = (bool) $event_response['display_command'];
|
||||
$command_str = ($display_command === true) ? $command : '';
|
||||
|
||||
if ($massive) {
|
||||
echo "<div class='left'>";
|
||||
echo $prompt.sprintf(
|
||||
'(Event #'.$event_id.') '.__(
|
||||
'Executing command: %s',
|
||||
$command_str
|
||||
)
|
||||
);
|
||||
echo '</div><br>';
|
||||
|
||||
echo "<div id='response_loading_command_".$out_iterator."' style='display: none'>";
|
||||
echo html_print_image(
|
||||
'images/spinner.gif',
|
||||
true
|
||||
);
|
||||
echo '</div><br>';
|
||||
echo "<br><div id='response_out_".$out_iterator."'><br><br></div><br>";
|
||||
|
||||
if ($end) {
|
||||
echo "<br><div id='re_exec_command_".$out_iterator."' style='display: none'><br>";
|
||||
html_print_button(
|
||||
__('Execute again'),
|
||||
'btn_str',
|
||||
false,
|
||||
'execute_event_response(false);',
|
||||
"class='sub next'"
|
||||
);
|
||||
echo "<span id='execute_again_loading' style='display: none'>";
|
||||
echo html_print_image(
|
||||
'images/spinner.gif',
|
||||
true
|
||||
);
|
||||
echo '</span>';
|
||||
echo '</div>';
|
||||
}
|
||||
} else {
|
||||
echo "<div class='left'>";
|
||||
|
||||
echo $prompt.'Executing command: '.$command_str;
|
||||
echo '</div><br>';
|
||||
|
||||
echo "<div id='response_loading_command' style='display:none'>";
|
||||
echo html_print_image('images/spinner.gif', true);
|
||||
echo '</div>';
|
||||
echo "<br><br><br><div id='response_out' class='left'></div>";
|
||||
|
||||
echo "<br><div id='re_exec_command' style='display:none'><br><br>";
|
||||
html_print_button(
|
||||
__('Execute again'),
|
||||
'btn_str',
|
||||
false,
|
||||
"perform_response({'target':'".$command."','event_id':".$event_id.",'server_id':".$server_id.'}, '.$response_id.');',
|
||||
"class='sub next'"
|
||||
);
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
echo get_row_response_action(
|
||||
$event_response,
|
||||
$response_id
|
||||
);
|
||||
break;
|
||||
|
||||
case 'url':
|
||||
@ -2474,11 +2422,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' => '',
|
||||
@ -2534,3 +2483,75 @@ if ($get_events_fired) {
|
||||
echo io_json_mb_encode($return);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($draw_row_response_info === true) {
|
||||
$event_response = json_decode(
|
||||
io_safe_output(
|
||||
get_parameter('response', '')
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$massive = (bool) get_parameter('massive', false);
|
||||
|
||||
$output .= '';
|
||||
if ($massive === true) {
|
||||
$output .= '<div>';
|
||||
$output .= '<h5>';
|
||||
$output .= $event_response['description'];
|
||||
$output .= '</h5>';
|
||||
$output .= '</div>';
|
||||
} else {
|
||||
$output .= '<tr class="params_rows">';
|
||||
$output .= '<td>';
|
||||
$output .= __('Description');
|
||||
$output .= '</td>';
|
||||
$output .= '<td class="height_30px" colspan="2">';
|
||||
$output .= $event_response['description'];
|
||||
$output .= '</td>';
|
||||
$output .= '</tr>';
|
||||
}
|
||||
|
||||
if (empty($event_response['params']) === false) {
|
||||
$response_params = explode(',', $event_response['params']);
|
||||
if (is_array($response_params) === true) {
|
||||
if ($massive === true) {
|
||||
$output .= '<div>';
|
||||
} else {
|
||||
$output .= '<tr class="params_rows">';
|
||||
$output .= '<td class="left pdd_l_20px height_30px" colspan="3">';
|
||||
$output .= __('Parameters');
|
||||
$output .= '</td>';
|
||||
$output .= '</tr>';
|
||||
}
|
||||
|
||||
foreach ($response_params as $param) {
|
||||
$param = trim(io_safe_output($param));
|
||||
if ($massive === true) {
|
||||
$output .= '<div>';
|
||||
$output .= '<label>';
|
||||
$output .= $param;
|
||||
$output .= '</label>';
|
||||
$output .= '<input type="text" name="values_params_'.$param.'" />';
|
||||
$output .= '</div>';
|
||||
} else {
|
||||
$output .= '<tr class="params_rows">';
|
||||
$output .= '<td style="text-align:left; padding-left:40px; font-weight: normal; font-style: italic;">';
|
||||
$output .= $param;
|
||||
$output .= '</td>';
|
||||
$output .= '<td style="text-align:left" colspan="2">';
|
||||
$output .= '<input type="text" name="values_params_'.$param.'" />';
|
||||
$output .= '</td>';
|
||||
$output .= '</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($massive === true) {
|
||||
$output .= '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo $output;
|
||||
return;
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
@ -285,6 +285,13 @@ class AgentWizard extends HTML
|
||||
*/
|
||||
private $wmiBinary = '';
|
||||
|
||||
/**
|
||||
* Default values for SNMP Interfaces.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $defaultSNMPValues = [];
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -319,6 +326,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 +338,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 +555,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 +615,7 @@ class AgentWizard extends HTML
|
||||
],
|
||||
];
|
||||
|
||||
if (!empty($this->datalist)) {
|
||||
if (empty($this->datalist) === false) {
|
||||
$inputs[] = [
|
||||
'id' => 'li_address_list',
|
||||
'arguments' => [
|
||||
@ -1916,12 +1924,21 @@ class AgentWizard extends HTML
|
||||
$values['configuration_data'] = io_safe_input($cfData);
|
||||
} else {
|
||||
$values['id_module'] = MODULE_PLUGIN;
|
||||
$fieldsPlugin = db_get_value_sql(
|
||||
sprintf(
|
||||
'SELECT macros FROM tplugin WHERE id=%d',
|
||||
(int) $infoMacros['server_plugin']
|
||||
)
|
||||
);
|
||||
if ((int) $infoMacros['server_plugin'] === 12) {
|
||||
// Search plugin by execute.
|
||||
$plugin_wmi = db_get_row_sql(
|
||||
'SELECT id, macros FROM tplugin WHERE execute like "%wizard_wmi_module%"'
|
||||
);
|
||||
$fieldsPlugin = $plugin_wmi['macros'];
|
||||
$infoMacros['server_plugin'] = $plugin_wmi['id'];
|
||||
} else {
|
||||
$fieldsPlugin = db_get_value_sql(
|
||||
sprintf(
|
||||
'SELECT macros FROM tplugin WHERE id=%d',
|
||||
(int) $infoMacros['server_plugin']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($fieldsPlugin !== false) {
|
||||
$fieldsPlugin = json_decode($fieldsPlugin, true);
|
||||
@ -2360,12 +2377,21 @@ class AgentWizard extends HTML
|
||||
);
|
||||
} else {
|
||||
$tmp->id_modulo(MODULE_PLUGIN);
|
||||
$fieldsPlugin = db_get_value_sql(
|
||||
sprintf(
|
||||
'SELECT macros FROM tplugin WHERE id=%d',
|
||||
(int) $infoMacros['server_plugin']
|
||||
)
|
||||
);
|
||||
if ((int) $infoMacros['server_plugin'] === 12) {
|
||||
// Search plugin by execute.
|
||||
$plugin_wmi = db_get_row_sql(
|
||||
'SELECT id, macros FROM tplugin WHERE execute like "%wizard_wmi_module%"'
|
||||
);
|
||||
$fieldsPlugin = $plugin_wmi['macros'];
|
||||
$infoMacros['server_plugin'] = $plugin_wmi['id'];
|
||||
} else {
|
||||
$fieldsPlugin = db_get_value_sql(
|
||||
sprintf(
|
||||
'SELECT macros FROM tplugin WHERE id=%d',
|
||||
(int) $infoMacros['server_plugin']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($fieldsPlugin !== false) {
|
||||
$fieldsPlugin = json_decode($fieldsPlugin, true);
|
||||
@ -4701,7 +4727,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,
|
||||
@ -4758,7 +4784,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',
|
||||
@ -4812,7 +4838,7 @@ class AgentWizard extends HTML
|
||||
'module_info' => 'Indicates whether the port is operating in half-duplex, full-duplex, disagree or auto negotiation mode. If the port could not agree with the far end on port duplex, the port will be in disagree(3) mode.',
|
||||
'execution_type' => 'network',
|
||||
'value' => $duplexMismatchOID,
|
||||
'default_enabled' => true,
|
||||
'default_enabled' => (bool) $this->defaultSNMPValues['DuplexMismatch'],
|
||||
'module_enabled' => false,
|
||||
'module_thresholds' => [
|
||||
'min_warning' => '0',
|
||||
@ -4901,7 +4927,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' => [
|
||||
@ -4940,7 +4966,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' => [
|
||||
@ -4979,7 +5005,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' => [
|
||||
@ -5011,7 +5037,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',
|
||||
@ -5038,7 +5064,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',
|
||||
@ -5065,7 +5091,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',
|
||||
@ -5092,7 +5118,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',
|
||||
@ -5119,7 +5145,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',
|
||||
@ -5189,7 +5215,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',
|
||||
@ -5217,7 +5243,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',
|
||||
@ -5245,7 +5271,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',
|
||||
@ -5272,7 +5298,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',
|
||||
@ -5299,7 +5325,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',
|
||||
@ -5326,7 +5352,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',
|
||||
@ -5396,7 +5422,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',
|
||||
@ -5424,7 +5450,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',
|
||||
@ -5452,7 +5478,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',
|
||||
@ -5480,7 +5506,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',
|
||||
@ -5507,7 +5533,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',
|
||||
@ -5534,7 +5560,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',
|
||||
|
@ -44,7 +44,7 @@ class AuditLog extends HTML
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $AJAXMethods = [ 'draw' ];
|
||||
public $AJAXMethods = ['draw'];
|
||||
|
||||
/**
|
||||
* Ajax page.
|
||||
@ -78,7 +78,6 @@ class AuditLog extends HTML
|
||||
|
||||
// Set the ajax controller.
|
||||
$this->ajaxController = $ajaxController;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -232,7 +231,6 @@ class AuditLog extends HTML
|
||||
|
||||
// Load own javascript file.
|
||||
echo $this->loadJS();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -368,39 +366,38 @@ class AuditLog extends HTML
|
||||
|
||||
// Javascript content.
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
function format ( d ) {
|
||||
var output = '';
|
||||
<script type="text/javascript">
|
||||
function format(d) {
|
||||
var output = '';
|
||||
|
||||
if (d.extendedInfo === '') {
|
||||
output = "<?php echo __('There is no additional information to display'); ?>";
|
||||
} else {
|
||||
output = d.extendedInfo;
|
||||
}
|
||||
|
||||
return output;
|
||||
if (d.extendedInfo === '') {
|
||||
output = "<?php echo __('There is no additional information to display'); ?>";
|
||||
} else {
|
||||
output = d.extendedInfo;
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
// Add event listener for opening and closing details
|
||||
$('#audit_logs tbody').on('click', 'td.show_extended_info', function () {
|
||||
var tr = $(this).closest('tr');
|
||||
var table = <?php echo 'dt_'.$this->tableId; ?>;
|
||||
var row = table.row( tr );
|
||||
|
||||
if ( row.child.isShown() ) {
|
||||
// This row is already open - close it
|
||||
row.child.hide();
|
||||
tr.removeClass('shown');
|
||||
}
|
||||
else {
|
||||
// Open this row
|
||||
row.child( format(row.data()) ).show();
|
||||
tr.addClass('shown');
|
||||
}
|
||||
} );
|
||||
} );
|
||||
</script>
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
// Add event listener for opening and closing details
|
||||
$('#audit_logs tbody').on('click', 'td.show_extended_info', function() {
|
||||
var tr = $(this).closest('tr');
|
||||
var table = $("#<?php echo $this->tableId; ?>").DataTable();
|
||||
var row = table.row(tr);
|
||||
|
||||
if (row.child.isShown()) {
|
||||
// This row is already open - close it
|
||||
row.child.hide();
|
||||
tr.removeClass('shown');
|
||||
} else {
|
||||
// Open this row
|
||||
row.child(format(row.data())).show();
|
||||
tr.addClass('shown');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
// EOF Javascript content.
|
||||
return ob_get_clean();
|
||||
|
@ -1466,7 +1466,7 @@ class ConsoleSupervisor
|
||||
[
|
||||
'type' => 'NOTIF.PHP.INPUT_TIME',
|
||||
'title' => sprintf(
|
||||
__("'%s' value in PHP configuration is not recommended"),
|
||||
__('%s value in PHP configuration is not recommended'),
|
||||
'max_input_time'
|
||||
),
|
||||
'message' => sprintf(
|
||||
|
@ -594,6 +594,7 @@ class CustomNetScan extends Wizard
|
||||
$("#text-interval_text").val(10);
|
||||
$("#hidden-interval").val('.$interval.');
|
||||
$("#interval_units").val('.$unit.');
|
||||
$("#interval_units").trigger("change");
|
||||
}
|
||||
}).change();
|
||||
';
|
||||
|
@ -651,6 +651,12 @@ class ExternalTools extends HTML
|
||||
}
|
||||
break;
|
||||
|
||||
case 'whois':
|
||||
if (empty($snmpget_path) === false) {
|
||||
return $snmpget_path;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@ -829,6 +835,7 @@ class ExternalTools extends HTML
|
||||
if (empty($dig) === true) {
|
||||
ui_print_error_message(__('Dig executable does not exist.'));
|
||||
} else {
|
||||
$dig .= ' '.$ip;
|
||||
$this->performExecution($dig);
|
||||
}
|
||||
|
||||
@ -837,6 +844,7 @@ class ExternalTools extends HTML
|
||||
if (empty($whois) === true) {
|
||||
ui_print_error_message(__('Whois executable does not exist.'));
|
||||
} else {
|
||||
$whois .= ' '.$ip;
|
||||
$this->performExecution($whois);
|
||||
}
|
||||
|
||||
|
@ -933,7 +933,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;
|
||||
|
@ -2102,39 +2102,91 @@ class NetworkMap
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (!$this->relations) {
|
||||
// Search for relations.
|
||||
foreach ($this->nodes as $k => $item) {
|
||||
$target = $this->calculateRelations($k);
|
||||
// Search for relations.
|
||||
foreach ($this->nodes as $k => $item) {
|
||||
$target = $this->calculateRelations($k);
|
||||
|
||||
// Adopt all orphan nodes but pandora one.
|
||||
if (empty($target)) {
|
||||
if (isset($this->noPandoraNode) === false
|
||||
|| $this->noPandoraNode == false
|
||||
) {
|
||||
if ($item['id_node'] != 0) {
|
||||
$rel = [];
|
||||
$rel['id_parent'] = 0;
|
||||
$rel['id_child'] = $item['id_node'];
|
||||
$rel['parent_type'] = NODE_PANDORA;
|
||||
$rel['child_type'] = $item['node_type'];
|
||||
$rel['id_child_source_data'] = $item['id_source_data'];
|
||||
// Adopt all orphan nodes but pandora one.
|
||||
if (empty($target) === true) {
|
||||
if (isset($this->noPandoraNode) === false
|
||||
|| $this->noPandoraNode == false
|
||||
) {
|
||||
if ($item['id_node'] != 0) {
|
||||
$rel = [];
|
||||
$rel['id_parent'] = 0;
|
||||
$rel['id_child'] = $item['id_node'];
|
||||
$rel['parent_type'] = NODE_PANDORA;
|
||||
$rel['child_type'] = $item['node_type'];
|
||||
$rel['id_child_source_data'] = $item['id_source_data'];
|
||||
|
||||
$orphans[] = $rel;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Flattern edges.
|
||||
foreach ($target as $rel) {
|
||||
$edges[] = $rel;
|
||||
$orphans[] = $rel;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Flattern edges.
|
||||
foreach ($target as $rel) {
|
||||
$edges[] = $rel;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$edges = $this->relations;
|
||||
}
|
||||
|
||||
if (is_array($edges)) {
|
||||
$array_aux = $edges;
|
||||
$target_aux = $edges;
|
||||
foreach ($edges as $key => $rel) {
|
||||
foreach ($array_aux as $key2 => $rel2) {
|
||||
if ($key2 <= $key) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($rel['child_type'] == 1 && $rel['parent_type'] == 1
|
||||
&& $rel2['child_type'] == 1 && $rel2['parent_type'] == 1
|
||||
) {
|
||||
if ($rel['id_parent'] == $rel2['id_parent'] && $rel['id_child'] == $rel2['id_child']) {
|
||||
if ($rel['id_parent_source_data'] == $rel2['id_parent_source_data']) {
|
||||
if (modules_get_agentmodule_type($rel['id_child_source_data']) === 6) {
|
||||
unset($target_aux[$key]);
|
||||
} else if (modules_get_agentmodule_type($rel2['id_child_source_data']) === 6) {
|
||||
unset($target_aux[$key2]);
|
||||
}
|
||||
} else if ($rel['id_child_source_data'] == $rel2['id_child_source_data']) {
|
||||
if (modules_get_agentmodule_type($rel['id_parent_source_data']) === 6) {
|
||||
unset($target_aux[$key]);
|
||||
} else if (modules_get_agentmodule_type($rel2['id_parent_source_data']) === 6) {
|
||||
unset($target_aux[$key2]);
|
||||
}
|
||||
}
|
||||
} else if ($rel['id_parent'] == $rel2['id_child'] && $rel['id_child'] == $rel2['id_parent']) {
|
||||
if ($rel['id_parent_source_data'] == $rel2['id_child_source_data']
|
||||
&& $rel['id_child_source_data'] == $rel2['id_parent_source_data']
|
||||
) {
|
||||
unset($target_aux[$key2]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($rel['id_parent_source_data'] == $rel2['id_child_source_data']) {
|
||||
if (modules_get_agentmodule_type($rel['id_child_source_data']) === 6) {
|
||||
unset($target_aux[$key]);
|
||||
} else if (modules_get_agentmodule_type($rel2['id_parent_source_data']) === 6) {
|
||||
unset($target_aux[$key2]);
|
||||
}
|
||||
} else if ($rel['id_child_source_data'] == $rel2['id_parent_source_data']) {
|
||||
if (modules_get_agentmodule_type($rel['id_parent_source_data']) === 6) {
|
||||
unset($target_aux[$key]);
|
||||
} else if (modules_get_agentmodule_type($rel2['id_child_source_data']) === 6) {
|
||||
unset($target_aux[$key2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$edges = [];
|
||||
foreach ($target_aux as $key => $value) {
|
||||
$edges[] = $value;
|
||||
}
|
||||
|
||||
foreach ($edges as $rel) {
|
||||
$graph .= $this->createDotEdge(
|
||||
[
|
||||
@ -2628,6 +2680,79 @@ class NetworkMap
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Regenerates a nodes - relationships array using graphviz dot
|
||||
* schema and stores nodes&relations into $this->graph.
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function recalculateCoords()
|
||||
{
|
||||
global $config;
|
||||
|
||||
include_once 'include/functions_os.php';
|
||||
|
||||
$map_filter = $this->mapOptions['map_filter'];
|
||||
|
||||
/*
|
||||
* Let graphviz place the nodes.
|
||||
*/
|
||||
|
||||
if ($map_filter['empty_map']) {
|
||||
$this->generateEmptyDotGraph();
|
||||
} else if (!isset($this->dotGraph)) {
|
||||
$this->generateDotGraph();
|
||||
}
|
||||
|
||||
$graph = $this->calculateCoords();
|
||||
|
||||
if (is_array($graph) === true) {
|
||||
$nodes = $graph['nodes'];
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
|
||||
$nodes_aux = [];
|
||||
|
||||
// Prepare graph nodes.
|
||||
foreach ($nodes as $id => $coords) {
|
||||
$node_tmp['id'] = $id;
|
||||
|
||||
$source = $this->getNodeData($id);
|
||||
|
||||
$node_tmp['type'] = $source['node_type'];
|
||||
$node_tmp['x'] = $coords['x'];
|
||||
$node_tmp['y'] = $coords['y'];
|
||||
|
||||
switch ($node_tmp['type']) {
|
||||
case NODE_AGENT:
|
||||
$node_tmp['source_data'] = $source['id_agente'];
|
||||
break;
|
||||
|
||||
case NODE_MODULE:
|
||||
$node_tmp['source_data'] = $source['id_agente_modulo'];
|
||||
break;
|
||||
|
||||
case NODE_PANDORA:
|
||||
$node_tmp['source_data'] = 0;
|
||||
$node_center['x'] = ($coords['x'] - MAP_X_CORRECTION);
|
||||
$node_center['y'] = ($coords['y'] - MAP_Y_CORRECTION);
|
||||
break;
|
||||
|
||||
case NODE_GENERIC:
|
||||
default:
|
||||
$node_tmp['source_data'] = $source['id_source'];
|
||||
break;
|
||||
}
|
||||
|
||||
$nodes_aux[$index] = $node_tmp;
|
||||
$index++;
|
||||
}
|
||||
|
||||
return $nodes_aux;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Transform node information into JS data.
|
||||
*
|
||||
@ -2799,7 +2924,6 @@ class NetworkMap
|
||||
$output .= "var add_node_menu = '".__('Add node')."';\n";
|
||||
$output .= "var set_center_menu = '".__('Set center')."';\n";
|
||||
$output .= "var refresh_menu = '".__('Refresh')."';\n";
|
||||
$output .= "var refresh_holding_area_menu = '".__('Refresh Holding area')."';\n";
|
||||
$output .= "var ok_button = '".__('Proceed')."';\n";
|
||||
$output .= "var message_to_confirm = '".__('Resetting the map will delete all customizations you have done, including manual relationships between elements, new items, etc.')."';\n";
|
||||
$output .= "var warning_message = '".__('WARNING')."';\n";
|
||||
@ -3066,8 +3190,8 @@ class NetworkMap
|
||||
$table->data['template_row']['node_target'] = '';
|
||||
$table->data['template_row']['edit'] = '';
|
||||
|
||||
$table->data['template_row']['edit'] .= '<span class="edit_icon_correct" style="display: none">'.html_print_image('images/dot_green.png', true).'</span><span class="edit_icon_fail" style="display: none" >'.html_print_image('images/dot_red.png', true).'</span><span class="edit_icon_progress" style="display: none">'.html_print_image('images/spinner.gif', true).'</span><span class="edit_icon"><a class="edit_icon_link" title="'.__('Update').'" href="#">'.html_print_image('images/config.png', true, ['class' => 'invert_filter']).'</a></span>';
|
||||
|
||||
$table->data['template_row']['edit'] .= '<span class="edit_icon_correct" style="display: none">'.html_print_image('images/dot_green.png', true).'</span><span class="edit_icon_fail" style="display: none" >'.html_print_image('images/dot_red.png', true).'</span><span class="edit_icon_progress" style="display: none">'.html_print_image('images/spinner.gif', true).'</span>';
|
||||
// <span class="edit_icon"><a class="edit_icon_link" title="'.__('Update').'" href="#">'.html_print_image('images/config.png', true, ['class' => 'invert_filter']).'</a></span>';
|
||||
$table->data['template_row']['edit'] .= '<a class="delete_icon" href="#">'.html_print_image('images/delete.png', true, ['class' => 'invert_filter']).'</a>';
|
||||
|
||||
$table->colspan['no_relations']['0'] = 5;
|
||||
@ -3278,7 +3402,7 @@ class NetworkMap
|
||||
$table->data[1][1] = html_print_select(
|
||||
$list_networkmaps,
|
||||
'networkmap_to_link',
|
||||
'',
|
||||
0,
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
@ -3318,6 +3442,10 @@ class NetworkMap
|
||||
*/
|
||||
public function loadController(?bool $return=true)
|
||||
{
|
||||
if (isset($this->mapOptions['refresh_time']) === false) {
|
||||
$this->mapOptions['refresh_time'] = 0;
|
||||
}
|
||||
|
||||
$output = '';
|
||||
|
||||
if ($this->useTooltipster
|
||||
@ -3359,13 +3487,34 @@ class NetworkMap
|
||||
node_radius: node_radius,
|
||||
holding_area_dimensions: networkmap_holding_area_dimensions,
|
||||
url_background_grid: url_background_grid,
|
||||
refresh_time: '.$this->mapOptions['refresh_time'].',
|
||||
font_size: '.$this->mapOptions['font_size'].',
|
||||
base_url_homedir: "'.ui_get_full_url(false).'"
|
||||
});
|
||||
init_drag_and_drop();
|
||||
init_minimap();
|
||||
function_open_minimap();
|
||||
|
||||
|
||||
if ('.$this->mapOptions['refresh_time'].' > 0) {
|
||||
var startCountDown = function (duration, cb) {
|
||||
$("div.vc-countdown").countdown("destroy");
|
||||
if (!duration) return;
|
||||
var t = new Date();
|
||||
t.setTime(t.getTime() + duration * 1000);
|
||||
$("div.vc-countdown").countdown({
|
||||
until: t,
|
||||
format: "MS",
|
||||
layout: "(%M%nn%M:%S%nn%S '.__('Until refresh').') ",
|
||||
alwaysExpire: true,
|
||||
onExpiry: function () {
|
||||
refresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
startCountDown('.($this->mapOptions['refresh_time']).', false);
|
||||
}
|
||||
|
||||
$(document.body).on("mouseleave",
|
||||
".context-menu-list",
|
||||
function(e) {
|
||||
@ -3504,6 +3653,10 @@ class NetworkMap
|
||||
$output .= ' style="width: '.$this->mapOptions['width'].'px; height: '.$this->mapOptions['height'].'px;position: relative; overflow: hidden; background: #FAFAFA">';
|
||||
}
|
||||
|
||||
$output .= '<div id="spinner_networkmap" style="position: absolute; width: 100%;height: 100%; z-index:1; justify-content: center; align-items: center; display:none; background-color:rgba(0, 0, 0, 0.2);">';
|
||||
$output .= html_print_image('/images/spinner.gif', true, ['style' => 'width: 22px; height: 22px']);
|
||||
$output .= '</div>';
|
||||
|
||||
$output .= '<div style="display: '.$minimap_display.';">';
|
||||
$output .= '<canvas id="minimap_'.$networkmap['id'].'"';
|
||||
$output .= ' class="minimap">';
|
||||
|
@ -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,8 +20,8 @@
|
||||
/**
|
||||
* Pandora build version and version
|
||||
*/
|
||||
$build_version = 'PC220922';
|
||||
$pandora_version = 'v7.0NG.764';
|
||||
$build_version = 'PC221027';
|
||||
$pandora_version = 'v7.0NG.765';
|
||||
|
||||
// Do not overwrite default timezone set if defined.
|
||||
$script_tz = @date_default_timezone_get();
|
||||
|
@ -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);
|
||||
|
@ -57,11 +57,17 @@ function mysql_connect_db(
|
||||
$port = $config['dbport'];
|
||||
}
|
||||
|
||||
if ($ssl === null && (bool) $config['dbssl'] === true) {
|
||||
if ($ssl === null
|
||||
&& isset($config['dbssl']) === true
|
||||
&& (bool) $config['dbssl'] === true
|
||||
) {
|
||||
$ssl = $config['dbsslcafile'];
|
||||
}
|
||||
|
||||
if ($verify === null && (bool) $config['sslverifyservercert'] === true) {
|
||||
if ($verify === null
|
||||
&& isset($config['sslverifyservercert']) === true
|
||||
&& (bool) $config['sslverifyservercert'] === true
|
||||
) {
|
||||
$verify = 'verified';
|
||||
}
|
||||
|
||||
|
@ -1007,6 +1007,30 @@ function get_parameter_post($name, $default='')
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get header.
|
||||
*
|
||||
* @param string $key Key.
|
||||
* @param string|null $default Default.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
function get_header(string $key, ?string $default=null): ?string
|
||||
{
|
||||
static $headers;
|
||||
if (!isset($headers)) {
|
||||
$headers = getAllHeaders();
|
||||
}
|
||||
|
||||
$adjust_key = ucwords(strtolower($key));
|
||||
if (isset($headers[$adjust_key])) {
|
||||
return $headers[$adjust_key];
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get name of a priority value.
|
||||
*
|
||||
@ -6217,3 +6241,31 @@ function notify_reporting_console_node()
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Auxiliar Ordenation function
|
||||
*
|
||||
* @param string $sort Direction of sort.
|
||||
* @param string $sortField Field for perform the sorting.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function arrayOutputSorting($sort, $sortField)
|
||||
{
|
||||
return function ($a, $b) use ($sort, $sortField) {
|
||||
if ($sort === 'up' || $sort === 'asc') {
|
||||
if (is_string($a[$sortField]) === true) {
|
||||
return strnatcasecmp($a[$sortField], $b[$sortField]);
|
||||
} else {
|
||||
return ($a[$sortField] - $b[$sortField]);
|
||||
}
|
||||
} else {
|
||||
if (is_string($a[$sortField]) === true) {
|
||||
return strnatcasecmp($b[$sortField], $a[$sortField]);
|
||||
} else {
|
||||
return ($a[$sortField] + $b[$sortField]);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -795,7 +795,7 @@ function alerts_delete_alert_template($id_alert_template)
|
||||
*
|
||||
* @return mixed Array with selected alert templates or false if something goes wrong.
|
||||
*/
|
||||
function alerts_get_alert_templates($filter=false, $fields=false)
|
||||
function alerts_get_alert_templates($filter=false, $fields=false, $total=false)
|
||||
{
|
||||
global $config;
|
||||
|
||||
@ -811,32 +811,17 @@ function alerts_get_alert_templates($filter=false, $fields=false)
|
||||
|
||||
$templates_sql = @db_get_all_rows_filter('talert_templates', $filter, $fields, 'AND', false, true);
|
||||
|
||||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
case 'postgresql':
|
||||
$limit_sql = '';
|
||||
if (isset($offset) && isset($limit)) {
|
||||
$limit_sql = " LIMIT $offset, $limit ";
|
||||
} else {
|
||||
$limit_sql = '';
|
||||
}
|
||||
|
||||
$sql = sprintf('%s %s', $templates_sql, $limit_sql);
|
||||
|
||||
$alert_templates = db_get_all_rows_sql($sql);
|
||||
break;
|
||||
|
||||
case 'oracle':
|
||||
$set = [];
|
||||
if (isset($offset) && isset($limit)) {
|
||||
$set['limit'] = $limit;
|
||||
$set['offset'] = $offset;
|
||||
}
|
||||
|
||||
$alert_templates = oracle_recode_query($templates_sql, $set, 'AND', false);
|
||||
break;
|
||||
$limit_sql = '';
|
||||
if (isset($offset) && isset($limit) && $total === false) {
|
||||
$limit_sql = " LIMIT $offset, $limit ";
|
||||
} else {
|
||||
$limit_sql = '';
|
||||
}
|
||||
|
||||
$sql = sprintf('%s %s', $templates_sql, $limit_sql);
|
||||
|
||||
$alert_templates = db_get_all_rows_sql($sql);
|
||||
|
||||
return $alert_templates;
|
||||
}
|
||||
|
||||
|
@ -467,7 +467,7 @@ function config_update_config()
|
||||
break;
|
||||
|
||||
case 'pass':
|
||||
if (isset($config['enterprise_installed']) === true && (bool) $config['enterprise_installed'] === 1) {
|
||||
if (isset($config['enterprise_installed']) === true && (bool) $config['enterprise_installed'] === true) {
|
||||
if (config_update_value('enable_pass_policy', get_parameter('enable_pass_policy'), true) === false) {
|
||||
$error_update[] = __('Enable password policy');
|
||||
}
|
||||
@ -515,6 +515,10 @@ function config_update_config()
|
||||
if (config_update_value('reset_pass_option', (bool) get_parameter('reset_pass_option'), true) === false) {
|
||||
$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');
|
||||
}
|
||||
|
||||
@ -784,14 +792,7 @@ function config_update_config()
|
||||
case 'perf':
|
||||
// PERFORMANCE SETUP.
|
||||
if (config_update_value('event_purge', get_parameter('event_purge'), true) === false) {
|
||||
$check_metaconsole_events_history = get_parameter('metaconsole_events_history', -1);
|
||||
$error_update[] = $check_metaconsole_events_history;
|
||||
}
|
||||
|
||||
if ($check_metaconsole_events_history != -1) {
|
||||
if (config_update_value('metaconsole_events_history', get_parameter('metaconsole_events_history'), true) === false) {
|
||||
$error_update[] = __('Max. days before delete events');
|
||||
}
|
||||
$error_update[] = __('Event purge');
|
||||
}
|
||||
|
||||
if (config_update_value('trap_purge', get_parameter('trap_purge'), true) === false) {
|
||||
@ -916,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']:
|
||||
@ -1572,6 +1583,19 @@ function config_update_config()
|
||||
$error_update[] = __('Days');
|
||||
}
|
||||
|
||||
if (config_update_value('history_db_adv', get_parameter_switch('history_db_adv', 0), true) === false) {
|
||||
$error_update[] = __('Enable history database advanced');
|
||||
}
|
||||
|
||||
$history_db_string_days = get_parameter('history_db_string_days');
|
||||
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)
|
||||
&& get_parameter_switch('history_db_adv', 0) === 1
|
||||
) {
|
||||
$error_update[] = __('String Days');
|
||||
}
|
||||
|
||||
$history_event_days = get_parameter('history_event_days');
|
||||
if (is_numeric($history_event_days) === false
|
||||
|| $history_event_days <= 0
|
||||
@ -1831,7 +1855,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
|
||||
);
|
||||
|
||||
@ -2095,10 +2119,6 @@ function config_process_config()
|
||||
config_update_value('event_purge', 15);
|
||||
}
|
||||
|
||||
if (!isset($config['metaconsole_events_history'])) {
|
||||
config_update_value('metaconsole_events_history', 0);
|
||||
}
|
||||
|
||||
if (!isset($config['realtimestats'])) {
|
||||
config_update_value('realtimestats', 1);
|
||||
}
|
||||
@ -2183,6 +2203,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);
|
||||
}
|
||||
@ -2243,6 +2267,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
|
||||
*/
|
||||
@ -2502,6 +2552,14 @@ function config_process_config()
|
||||
config_update_value('history_db_days', 0);
|
||||
}
|
||||
|
||||
if (!isset($config['history_db_adv'])) {
|
||||
config_update_value('history_db_adv', false);
|
||||
}
|
||||
|
||||
if (!isset($config['history_db_string_days'])) {
|
||||
config_update_value('history_db_string_days', 0);
|
||||
}
|
||||
|
||||
if (!isset($config['history_event_days'])) {
|
||||
config_update_value('history_event_days', 90);
|
||||
}
|
||||
@ -2651,6 +2709,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');
|
||||
}
|
||||
|
@ -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);
|
||||
@ -1381,7 +1410,7 @@ function events_get_all(
|
||||
// Pagination.
|
||||
$pagination = '';
|
||||
if (is_metaconsole() === true
|
||||
&& empty($id_server) === true
|
||||
&& (empty($id_server) === true || is_array($id_server) === true)
|
||||
&& isset($filter['csv_all']) === false
|
||||
) {
|
||||
// TODO: XXX TIP. captura el error.
|
||||
@ -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';
|
||||
@ -1472,7 +1506,6 @@ function events_get_all(
|
||||
// Secondary groups.
|
||||
$event_lj = '';
|
||||
if (!$user_is_admin || ($user_is_admin && isset($groups) === true && $groups > 0)) {
|
||||
db_process_sql('SET group_concat_max_len = 9999999');
|
||||
if ((bool) $filter['search_secondary_groups'] === true) {
|
||||
$event_lj = events_get_secondary_groups_left_join($table);
|
||||
}
|
||||
@ -1486,6 +1519,8 @@ function events_get_all(
|
||||
unset($fields[$idx]);
|
||||
}
|
||||
|
||||
db_process_sql('SET group_concat_max_len = 9999999');
|
||||
|
||||
$group_selects = sprintf(
|
||||
',COUNT(id_evento) AS event_rep,
|
||||
%s
|
||||
@ -1494,6 +1529,15 @@ function events_get_all(
|
||||
MAX(id_evento) as max_id_evento',
|
||||
($idx !== false) ? 'GROUP_CONCAT(DISTINCT user_comment SEPARATOR "<br>") AS comments,' : ''
|
||||
);
|
||||
|
||||
$group_selects_trans = sprintf(
|
||||
',tmax_event.event_rep,
|
||||
%s
|
||||
tmax_event.timestamp_last,
|
||||
tmax_event.timestamp_first,
|
||||
tmax_event.max_id_evento',
|
||||
($idx !== false) ? 'tmax_event.comments,' : ''
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$idx = array_search('te.user_comment', $fields);
|
||||
@ -1502,43 +1546,112 @@ function events_get_all(
|
||||
}
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
'SELECT %s
|
||||
if (((int) $filter['group_rep'] === EVENT_GROUP_REP_EVENTS
|
||||
|| (int) $filter['group_rep'] === EVENT_GROUP_REP_EXTRAIDS) && $count === false
|
||||
) {
|
||||
$sql = sprintf(
|
||||
'SELECT %s
|
||||
%s
|
||||
FROM %s
|
||||
INNER JOIN (
|
||||
SELECT te.id_evento %s
|
||||
FROM %s
|
||||
%s
|
||||
%s
|
||||
%s JOIN %s ta
|
||||
ON ta.%s = te.id_agente
|
||||
%s
|
||||
%s
|
||||
%s JOIN tgrupo tg
|
||||
ON %s
|
||||
WHERE 1=1
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
) tmax_event
|
||||
ON te.id_evento = tmax_event.max_id_evento
|
||||
%s
|
||||
FROM %s
|
||||
%s
|
||||
%s
|
||||
%s JOIN %s ta
|
||||
ON ta.%s = te.id_agente
|
||||
%s
|
||||
%s
|
||||
%s JOIN tgrupo tg
|
||||
ON %s
|
||||
WHERE 1=1
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
',
|
||||
join(',', $fields),
|
||||
$group_selects,
|
||||
$tevento,
|
||||
$event_lj,
|
||||
$agentmodule_join,
|
||||
$tagente_join,
|
||||
$tagente_table,
|
||||
$tagente_field,
|
||||
$conditionMetaconsole,
|
||||
join(' ', $agent_join_filters),
|
||||
$tgrupo_join,
|
||||
join(' ', $tgrupo_join_filters),
|
||||
join(' ', $sql_filters),
|
||||
$group_by,
|
||||
$order_by,
|
||||
$pagination,
|
||||
$having
|
||||
);
|
||||
%s
|
||||
%s JOIN %s ta
|
||||
ON ta.%s = te.id_agente
|
||||
%s
|
||||
%s
|
||||
%s JOIN tgrupo tg
|
||||
ON %s
|
||||
%s
|
||||
%s',
|
||||
join(',', $fields),
|
||||
$group_selects_trans,
|
||||
$tevento,
|
||||
$group_selects,
|
||||
$tevento,
|
||||
$event_lj,
|
||||
$agentmodule_join,
|
||||
$tagente_join,
|
||||
$tagente_table,
|
||||
$tagente_field,
|
||||
$conditionMetaconsole,
|
||||
join(' ', $agent_join_filters),
|
||||
$tgrupo_join,
|
||||
join(' ', $tgrupo_join_filters),
|
||||
join(' ', $sql_filters),
|
||||
$group_by,
|
||||
$order_by,
|
||||
$pagination,
|
||||
$having,
|
||||
$event_lj,
|
||||
$agentmodule_join,
|
||||
$tagente_join,
|
||||
$tagente_table,
|
||||
$tagente_field,
|
||||
$conditionMetaconsole,
|
||||
join(' ', $agent_join_filters),
|
||||
$tgrupo_join,
|
||||
join(' ', $tgrupo_join_filters),
|
||||
join(' ', $sql_filters),
|
||||
$order_by
|
||||
);
|
||||
} else {
|
||||
$sql = sprintf(
|
||||
'SELECT %s
|
||||
%s
|
||||
FROM %s
|
||||
%s
|
||||
%s
|
||||
%s JOIN %s ta
|
||||
ON ta.%s = te.id_agente
|
||||
%s
|
||||
%s
|
||||
%s JOIN tgrupo tg
|
||||
ON %s
|
||||
WHERE 1=1
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
',
|
||||
join(',', $fields),
|
||||
$group_selects,
|
||||
$tevento,
|
||||
$event_lj,
|
||||
$agentmodule_join,
|
||||
$tagente_join,
|
||||
$tagente_table,
|
||||
$tagente_field,
|
||||
$conditionMetaconsole,
|
||||
join(' ', $agent_join_filters),
|
||||
$tgrupo_join,
|
||||
join(' ', $tgrupo_join_filters),
|
||||
join(' ', $sql_filters),
|
||||
$group_by,
|
||||
$order_by,
|
||||
$pagination,
|
||||
$having
|
||||
);
|
||||
}
|
||||
|
||||
if ($return_sql === true) {
|
||||
return $sql;
|
||||
@ -1583,7 +1696,9 @@ function events_get_all(
|
||||
|
||||
if ($count === true
|
||||
&& (is_metaconsole() === false
|
||||
|| (is_metaconsole() === true && empty($filter['server_id']) === false))
|
||||
|| (is_metaconsole() === true
|
||||
&& empty($filter['server_id']) === false
|
||||
&& is_array($filter['server_id']) === false))
|
||||
) {
|
||||
$sql = 'SELECT count(*) as nitems FROM ('.$sql.') tt';
|
||||
}
|
||||
@ -1599,14 +1714,27 @@ function events_get_all(
|
||||
$metaconsole_connections = array_flip($metaconsole_connections);
|
||||
$metaconsole_connections['meta'] = 0;
|
||||
} else {
|
||||
$only_id_server[$metaconsole_connections[$id_server]] = $id_server;
|
||||
$metaconsole_connections = $only_id_server;
|
||||
if (is_array($id_server) === false) {
|
||||
$only_id_server[$metaconsole_connections[$id_server]] = $id_server;
|
||||
$metaconsole_connections = $only_id_server;
|
||||
} else {
|
||||
$metaConnections = [];
|
||||
foreach ($id_server as $idser) {
|
||||
if ((int) $idser === 0) {
|
||||
$metaConnections['meta'] = 0;
|
||||
} else {
|
||||
$metaConnections[$metaconsole_connections[$idser]] = $idser;
|
||||
}
|
||||
}
|
||||
|
||||
$metaconsole_connections = $metaConnections;
|
||||
}
|
||||
}
|
||||
|
||||
$result_meta = Promise\wait(
|
||||
parallelMap(
|
||||
$metaconsole_connections,
|
||||
function ($node_int) use ($sql) {
|
||||
function ($node_int) use ($sql, $history) {
|
||||
try {
|
||||
if (is_metaconsole() === true
|
||||
&& (int) $node_int > 0
|
||||
@ -1615,7 +1743,7 @@ function events_get_all(
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
$res = db_get_all_rows_sql($sql);
|
||||
$res = db_get_all_rows_sql($sql, $history);
|
||||
if ($res === false) {
|
||||
$res = [];
|
||||
}
|
||||
@ -1674,7 +1802,7 @@ function events_get_all(
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($filter['server_id']) === true) {
|
||||
if ($count === false) {
|
||||
if ($sort_field !== 'agent_name'
|
||||
&& $sort_field !== 'server_name'
|
||||
&& $sort_field !== 'timestamp'
|
||||
@ -1746,7 +1874,7 @@ function events_get_all(
|
||||
}
|
||||
}
|
||||
|
||||
return db_get_all_rows_sql($sql);
|
||||
return db_get_all_rows_sql($sql, $history);
|
||||
}
|
||||
|
||||
|
||||
@ -2005,7 +2133,7 @@ function events_change_owner(
|
||||
events_comment(
|
||||
$id_event,
|
||||
'',
|
||||
'Change owner to '.$new_owner
|
||||
'Change owner to '.get_user_fullname($new_owner).' ('.$new_owner.')'
|
||||
);
|
||||
}
|
||||
|
||||
@ -2807,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(
|
||||
@ -3211,18 +3339,9 @@ function events_page_responses($event)
|
||||
|
||||
foreach ($users as $u) {
|
||||
$owners[$u['id_user']] = $u['id_user'];
|
||||
}
|
||||
|
||||
if (empty($event['owner_user']) === true) {
|
||||
$owner_name = __('None');
|
||||
} else {
|
||||
$owner_name = db_get_value(
|
||||
'id_user',
|
||||
'tusuario',
|
||||
'id_user',
|
||||
$event['owner_user']
|
||||
);
|
||||
$owners[$event['owner_user']] = $owner_name;
|
||||
if (empty($u['fullname']) === false) {
|
||||
$owners[$u['id_user']] = $u['fullname'].' ('.$u['id_user'].')';
|
||||
}
|
||||
}
|
||||
|
||||
$data[1] = html_print_select(
|
||||
@ -3430,7 +3549,7 @@ function events_page_responses($event)
|
||||
__('Execute'),
|
||||
'custom_response_button',
|
||||
false,
|
||||
'execute_response('.$event['id_evento'].','.$server_id.')',
|
||||
'execute_response('.$event['id_evento'].','.$server_id.',0)',
|
||||
"class='sub next w70p'",
|
||||
true
|
||||
);
|
||||
@ -3441,27 +3560,15 @@ function events_page_responses($event)
|
||||
$responses_js = "<script>
|
||||
$('#select_custom_response').change(function() {
|
||||
var id_response = $('#select_custom_response').val();
|
||||
var params = get_response_params(id_response);
|
||||
var description = get_response_description(id_response);
|
||||
$('.params_rows').remove();
|
||||
$('#responses_table')
|
||||
.append('<tr class=\"params_rows\"><td>".__('Description')."</td><td class=\"height_30px\" colspan=\"2\">'+description+'</td></tr>');
|
||||
|
||||
if (params.length == 1 && params[0] == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$('#responses_table')
|
||||
.append('<tr class=\"params_rows\"><td class=\"left pdd_l_20px height_30px\" colspan=\"3\">".__('Parameters')."</td></tr>');
|
||||
|
||||
for (i = 0; i < params.length; i++) {
|
||||
add_row_param('responses_table',params[i]);
|
||||
}
|
||||
table_info_response_event(id_response,".$event['id_evento'].','.$event['server_id'].");
|
||||
});
|
||||
$('#select_custom_response').trigger('change');
|
||||
</script>";
|
||||
|
||||
$responses = '<div id="extended_event_responses_page" class="extended_event_pages">'.html_print_table($table_responses, true).$responses_js.'</div>';
|
||||
$responses = '<div id="extended_event_responses_page" class="extended_event_pages">';
|
||||
$responses .= html_print_table($table_responses, true);
|
||||
$responses .= $responses_js;
|
||||
$responses .= '</div>';
|
||||
|
||||
return $responses;
|
||||
}
|
||||
@ -3470,14 +3577,20 @@ function events_page_responses($event)
|
||||
/**
|
||||
* Replace macros in the target of a response and return it.
|
||||
*
|
||||
* @param integer $event_id Event identifier.
|
||||
* @param integer $response_id Event response identifier.
|
||||
* @param integer $event_id Event identifier.
|
||||
* @param array $event_response Event Response.
|
||||
* @param array|null $response_parameters If parameters response values.
|
||||
* @param integer|null $server_id Server Id.
|
||||
* @param string|null $server_name Name server.
|
||||
*
|
||||
* @return string The response text with the macros applied.
|
||||
*/
|
||||
function events_get_response_target(
|
||||
int $event_id,
|
||||
int $response_id
|
||||
array $event_response,
|
||||
?array $response_parameters=null,
|
||||
?int $server_id=0,
|
||||
?string $server_name=''
|
||||
) {
|
||||
global $config;
|
||||
|
||||
@ -3490,9 +3603,36 @@ function events_get_response_target(
|
||||
}
|
||||
|
||||
$event = db_get_row('tevento', 'id_evento', $event_id);
|
||||
$event_response = db_get_row('tevent_response', 'id', $response_id);
|
||||
$target = io_safe_output($event_response['target']);
|
||||
|
||||
// Replace parameters response.
|
||||
if (isset($response_parameters) === true
|
||||
&& empty($response_parameters) === false
|
||||
) {
|
||||
$response_parameters = array_reduce(
|
||||
$response_parameters,
|
||||
function ($carry, $item) {
|
||||
$carry[$item['name']] = $item['value'];
|
||||
return $carry;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($event_response['params']) === false) {
|
||||
$response_params = explode(',', $event_response['params']);
|
||||
if (is_array($response_params) === true) {
|
||||
foreach ($response_params as $param) {
|
||||
$param = trim(io_safe_output($param));
|
||||
$target = str_replace(
|
||||
'_'.$param.'_',
|
||||
$response_parameters['values_params_'.$param],
|
||||
$target
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Replace macros.
|
||||
if (strpos($target, '_agent_alias_') !== false) {
|
||||
$agente_table_name = 'tagente';
|
||||
$filter = ['id_agente' => $event['id_agente']];
|
||||
@ -3818,6 +3958,26 @@ function events_get_response_target(
|
||||
);
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true
|
||||
&& strpos($target, '_node_id_') !== false
|
||||
) {
|
||||
$target = str_replace(
|
||||
'_node_id_',
|
||||
$server_id,
|
||||
$target
|
||||
);
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true
|
||||
&& strpos($target, '_node_name_') !== false
|
||||
) {
|
||||
$target = str_replace(
|
||||
'_node_name_',
|
||||
$server_name,
|
||||
$target
|
||||
);
|
||||
}
|
||||
|
||||
return $target;
|
||||
}
|
||||
|
||||
@ -4831,7 +4991,7 @@ function events_page_comments($event, $ajax=false, $groupedComments=[])
|
||||
'<b>%s %s %s%s</b>',
|
||||
$c['action'],
|
||||
__('by'),
|
||||
$c['id_user'],
|
||||
get_user_fullname($c['id_user']).' ('.$c['id_user'].')',
|
||||
$eventIdExplanation
|
||||
);
|
||||
|
||||
@ -5028,7 +5188,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) {
|
||||
@ -5049,7 +5209,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':
|
||||
@ -5076,6 +5236,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;
|
||||
@ -5464,3 +5632,114 @@ function events_get_criticity_class($criticity)
|
||||
return 'datos_blue';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draw row response events.
|
||||
*
|
||||
* @param array $event_response Response.
|
||||
* @param integer|null $response_id Id .
|
||||
* @param boolean $end End block.
|
||||
* @param integer|null $index Index block.
|
||||
*
|
||||
* @return string Html output.
|
||||
*/
|
||||
function get_row_response_action(
|
||||
array $event_response,
|
||||
?int $response_id,
|
||||
$end=false,
|
||||
$index=null
|
||||
) {
|
||||
$output = '<div class="container-massive-events-response-cell">';
|
||||
$display_command = (bool) $event_response['display_command'];
|
||||
$command_str = ($display_command === true) ? $event_response['target'] : '';
|
||||
|
||||
// String command.
|
||||
$output .= '<div class="container-massive-events-response-command">';
|
||||
$output .= '<b>';
|
||||
$output .= __('Event # %d', $event_response['event_id']);
|
||||
if (empty($command_str) === false) {
|
||||
$output .= ' ';
|
||||
$output .= __('Executing command: ');
|
||||
}
|
||||
|
||||
$output .= '</b>';
|
||||
$output .= '<span>'.$command_str.'</span>';
|
||||
$output .= '</div>';
|
||||
|
||||
// Spinner.
|
||||
$output .= '<div id="response_loading_command'.$index.'" style="display:none">';
|
||||
$output .= html_print_image(
|
||||
'images/spinner.gif',
|
||||
true
|
||||
);
|
||||
$output .= '</div>';
|
||||
|
||||
// Output.
|
||||
$output .= '<div id="response_out'.$index.'" class="container-massive-events-response-output"></div>';
|
||||
|
||||
// Butom.
|
||||
$output .= '<div id="re_exec_command'.$index.'" style="display:none" class="container-massive-events-response-execute">';
|
||||
$output .= html_print_button(
|
||||
__('Execute again'),
|
||||
'btn_str',
|
||||
false,
|
||||
'perform_response(\''.base64_encode(json_encode($event_response)).'\','.$response_id.',\''.trim($index).'\')',
|
||||
"class='sub next'",
|
||||
true
|
||||
);
|
||||
$output .= '</div>';
|
||||
|
||||
$output .= '</div>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get evet get response target.
|
||||
*
|
||||
* @param integer $event_id Id event.
|
||||
* @param array $event_response Response.
|
||||
* @param integer $server_id Server id.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_events_get_response_target(
|
||||
$event_id,
|
||||
$event_response,
|
||||
$server_id=0,
|
||||
$response_parameters=[]
|
||||
) {
|
||||
try {
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node = new Node($server_id);
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
return events_get_response_target(
|
||||
$event_id,
|
||||
$event_response,
|
||||
$response_parameters,
|
||||
$server_id,
|
||||
($server_id !== 0) ? $node->server_name() : 'Metaconsole'
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
||||
return '';
|
||||
} finally {
|
||||
if (is_metaconsole() === true
|
||||
&& $server_id > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,8 @@ function groupview_get_modules_counters($groups_ids=false)
|
||||
WHERE tasg.id_group IN ($groups_ids)
|
||||
GROUP BY tasg.id_group
|
||||
) x GROUP BY g";
|
||||
return db_get_all_rows_sql($sql);
|
||||
$data = db_get_all_rows_sql($sql);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|