Merge remote-tracking branch 'origin/develop' into ent-12178-metaconsola-los-servidores-de-nodo-no-desaparecen-de-la-vista-al-convertilo-en-metaconsola

This commit is contained in:
daniel 2024-02-12 09:51:56 +01:00
commit 639fbcc807
147 changed files with 2529 additions and 816 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.775-240126 Version: 7.0NG.775-240212
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

@ -1039,7 +1039,7 @@ my $Sem = undef;
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.775'; use constant AGENT_VERSION => '7.0NG.775';
use constant AGENT_BUILD => '240126'; use constant AGENT_BUILD => '240212';
# Agent log default file size maximum and instances # Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000; use constant DEFAULT_MAX_LOG_SIZE => 600000;
@ -3678,9 +3678,21 @@ sub write_module_xml ($@) {
return; return;
} }
if ($module->{'func'} == \&module_logger) { # Is it an extraction log module?
$Xml .= $data[0]; if($module->{'type'} eq "log"){
return my $output = join('', @data);
if ($output eq "") {
return;
}
$Xml .="<log_module>\n";
$Xml .= " <source><![CDATA[" . $module->{'name'} . "]]></source>\n";
$Xml .= " <type><![CDATA[" . $module->{'type'} . "]]></type>\n";
$Xml .= " <encoding>base64</encoding>\n";
$Xml .= " <data><![CDATA[" . $output . "]]></data>\n";
$Xml .= "</log_module>\n";
return;
} }
# Critical section # Critical section
@ -3690,7 +3702,7 @@ sub write_module_xml ($@) {
" <name><![CDATA[" . $module->{'name'} . "]]></name>\n" . " <name><![CDATA[" . $module->{'name'} . "]]></name>\n" .
" <description><![CDATA[" . $module->{'description'} . "]]></description>\n" . " <description><![CDATA[" . $module->{'description'} . "]]></description>\n" .
" <type>" . $module->{'type'} . "</type>\n"; " <type>" . $module->{'type'} . "</type>\n";
# Interval # Interval
$Xml .= " <module_interval>" . $module->{'interval'} . "</module_interval>\n"; $Xml .= " <module_interval>" . $module->{'interval'} . "</module_interval>\n";
@ -3889,7 +3901,8 @@ sub module_logger ($) {
my $status = grep_logs( my $status = grep_logs(
$module->{'name'}, $module->{'name'},
$module->{'params'}, $module->{'params'},
$module->{'filter'} $module->{'filter'},
$module->{'type'}
); );
return $status; return $status;
@ -3926,20 +3939,25 @@ my $encode_sub = defined(&MIME::Base64::encode_base64) ? \&MIME::Base64::encode_
}; };
sub grep_logs { sub grep_logs {
my ($str_name, $str_file, $str_regex) = @_; my ($module_name, $log_file, $reg_exp, $module_type) = @_;
if(!$str_name){ if(!$module_name){
log_message("module_logger", "Missing module name"); log_message("module_logger", "Missing module name");
return; return;
} }
if(!$str_file){ if(!$log_file){
log_message("module_logger", "Missing file name"); log_message("module_logger", "Missing file name");
return; return;
} }
if(!$str_regex){ if(!$module_type){
$str_regex = '.*'; log_message("module_logger", "Missing module type");
return;
}
if(!$reg_exp){
$reg_exp = '.*';
} }
my $idx_dir = '/tmp/'; my $idx_dir = '/tmp/';
@ -3947,9 +3965,6 @@ sub grep_logs {
my $idx_pos = 0; my $idx_pos = 0;
my $idx_size = 0; my $idx_size = 0;
my $idx_ino = ''; my $idx_ino = '';
my $module_name = $str_name;
my $log_file = $str_file;
my $reg_exp = $str_regex;
# Check that log file exists # Check that log file exists
if (! -e $log_file) { if (! -e $log_file) {
@ -3975,7 +3990,7 @@ sub grep_logs {
return if load_idx(\$idx_pos, \$idx_ino, \$idx_file, \$idx_size) == 1; return if load_idx(\$idx_pos, \$idx_ino, \$idx_file, \$idx_size) == 1;
my @data = parse_log(\$idx_pos, \$idx_ino, \$idx_file, \$log_file, \$module_name, \$reg_exp, \$idx_size); my @data = parse_log(\$idx_pos, \$idx_ino, \$idx_file, \$log_file, \$module_name, \$reg_exp, \$idx_size);
my $output = create_log($module_name, @data); my $output = create_log($module_name, $module_type, @data);
return $output; return $output;
} }
@ -4090,27 +4105,32 @@ sub grep_logs {
} }
sub create_log { sub create_log {
my ($module_name, @data) = @_; my ($module_name, $module_type, @data) = @_;
# No data my $data_content = process_log_monitoring($module_type, @data);
if ($#data < 0) {
return;
}
# Log module
my $output = "<log_module>\n";
$output .= "<source><![CDATA[" . $module_name . "]]></source>\n";
$output .= "<encoding>base64</encoding>\n";
$output .= "<data><![CDATA[";
$output .= &$encode_sub(join('', @data), '');
$output .= "]]></data>\n";
$output .= "</log_module>\n";
return $output; return $data_content;
} }
} }
sub process_log_monitoring {
my ($module_type, @data) = @_;
my $output = "";
if ($module_type eq "log"){
$output = &$encode_sub(join('', @data), '');
} elsif ($module_type eq "generic_data") {
$output = scalar @data;
} elsif ($module_type eq "generic_proc"){
$output = scalar @data > 0 ? 1 : 0;
} elsif ($module_type eq "generic_data_string" || $module_type eq "async_string"){
$output = join('', @data);
}
return $output;
}
################################################################################ ################################################################################
# TERM Handler # TERM Handler
################################################################################ ################################################################################
@ -4283,6 +4303,10 @@ sub init_module ($) {
$module->{'alert_template'} = undef; $module->{'alert_template'} = undef;
$module->{'filter'} = undef; $module->{'filter'} = undef;
$module->{'absoluteinterval'} = undef; $module->{'absoluteinterval'} = undef;
$module->{'each_ff'} = undef;
$module->{'min_ff_event_normal'} = undef;
$module->{'min_ff_event_warning'} = undef;
$module->{'min_ff_event_critical'} = undef;
} }
################################################################################ ################################################################################

View File

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

View File

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

View File

@ -5,7 +5,7 @@
%define name pandorafms_agent_linux_bin %define name pandorafms_agent_linux_bin
%define source_name pandorafms_agent_linux %define source_name pandorafms_agent_linux
%define version 7.0NG.775 %define version 7.0NG.775
%define release 240126 %define release 240212
%define debug_package %{nil} %define debug_package %{nil}
Summary: Pandora FMS Linux agent, binary version Summary: Pandora FMS Linux agent, binary version
@ -13,23 +13,22 @@ Name: %{name}
Version: %{version} Version: %{version}
Release: %{release} Release: %{release}
License: GPL License: GPL
Vendor: ArticaST <http://www.artica.es> Vendor: PandoraFMS <https://pandorafms.com>
Source0: %{source_name}-%{version}.tar.gz Source0: %{source_name}-%{version}.tar.gz
URL: http://pandorafms.org URL: https://pandorafms.com
Group: System/Monitoring Group: System/Monitoring
Packager: Sancho Lerena <slerena@artica.es> Packager: PandoraFMS <info@pandorafms.com>
Prefix: /usr/share Prefix: /usr/share
BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot
BuildArch: x86_64 BuildArch: x86_64
Requires(pre): shadow-utils Requires(pre): shadow-utils
Requires(post): chkconfig /bin/ln Requires(post): /bin/ln
Requires(preun): chkconfig /bin/rm /usr/sbin/userdel Requires(preun): /bin/rm /usr/sbin/userdel
Requires: coreutils unzip Requires: coreutils unzip
Requires: util-linux procps grep Requires: util-linux procps grep
Requires: /sbin/ip /bin/awk Requires: /sbin/ip /bin/awk
Requires: perl-interpreter Requires: perl-interpreter
Requires: perl-IO-Compress Requires: perl-IO-Compress
Requires: libnsl
Requires: libxcrypt-compat Requires: libxcrypt-compat
AutoReq: 0 AutoReq: 0
Provides: %{name}-%{version} Provides: %{name}-%{version}
@ -50,7 +49,7 @@ mkdir -p $RPM_BUILD_ROOT%{prefix}/pandora_agent/
mkdir -p $RPM_BUILD_ROOT/usr/bin/ mkdir -p $RPM_BUILD_ROOT/usr/bin/
mkdir -p $RPM_BUILD_ROOT/usr/sbin/ mkdir -p $RPM_BUILD_ROOT/usr/sbin/
mkdir -p $RPM_BUILD_ROOT/etc/pandora/ mkdir -p $RPM_BUILD_ROOT/etc/pandora/
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d/ #mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d/
mkdir -p $RPM_BUILD_ROOT/var/log/pandora/ mkdir -p $RPM_BUILD_ROOT/var/log/pandora/
mkdir -p $RPM_BUILD_ROOT/usr/share/man/man1/ mkdir -p $RPM_BUILD_ROOT/usr/share/man/man1/
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/ mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/
@ -58,7 +57,7 @@ cp -aRf * $RPM_BUILD_ROOT%{prefix}/pandora_agent/
cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/tentacle_client $RPM_BUILD_ROOT/usr/bin/ cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/tentacle_client $RPM_BUILD_ROOT/usr/bin/
cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent $RPM_BUILD_ROOT/usr/bin/ cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent $RPM_BUILD_ROOT/usr/bin/
cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent_exec $RPM_BUILD_ROOT/usr/bin/ cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent_exec $RPM_BUILD_ROOT/usr/bin/
cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent_daemon $RPM_BUILD_ROOT/etc/rc.d/init.d/pandora_agent_daemon #cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent_daemon $RPM_BUILD_ROOT/etc/rc.d/init.d/pandora_agent_daemon
cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/man/man1/pandora_agent.1.gz $RPM_BUILD_ROOT/usr/share/man/man1/ cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/man/man1/pandora_agent.1.gz $RPM_BUILD_ROOT/usr/share/man/man1/
cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/man/man1/tentacle_client.1.gz $RPM_BUILD_ROOT/usr/share/man/man1/ cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/man/man1/tentacle_client.1.gz $RPM_BUILD_ROOT/usr/share/man/man1/
@ -119,21 +118,11 @@ then
cp -f /usr/share/pandora_agent/pandora_agent_daemon.service /usr/lib/systemd/system/ cp -f /usr/share/pandora_agent/pandora_agent_daemon.service /usr/lib/systemd/system/
chmod -x /usr/lib/systemd/system/pandora_agent_daemon.service chmod -x /usr/lib/systemd/system/pandora_agent_daemon.service
# Enable the services on SystemD # Enable the services on SystemD
systemctl daemon-reload
systemctl enable pandora_agent_daemon.service systemctl enable pandora_agent_daemon.service
else
/sbin/chkconfig --add pandora_agent_daemon
/sbin/chkconfig pandora_agent_daemon on
fi
if [ "$1" -gt 1 ]
then
echo "If Pandora Agent daemon was running with init.d script,"
echo "please stop it manually and start the service with systemctl"
fi fi
%preun %preun
# Upgrading # Upgrading
@ -141,8 +130,7 @@ if [ "$1" = "1" ]; then
exit 0 exit 0
fi fi
/sbin/chkconfig --del pandora_agent_daemon systemctl stop pandora_agent_daemon.service > /dev/null 2>&1 || :
/etc/rc.d/init.d/pandora_agent_daemon stop >/dev/null 2>&1 || :
# Remove symbolic links # Remove symbolic links
pushd /etc/pandora pushd /etc/pandora
@ -162,7 +150,6 @@ exit 0
%defattr(755,root,root) %defattr(755,root,root)
/usr/bin/pandora_agent_exec /usr/bin/pandora_agent_exec
/usr/bin/tentacle_client /usr/bin/tentacle_client
/etc/rc.d/init.d/pandora_agent_daemon
%defattr(644,root,root) %defattr(644,root,root)
/usr/share/man/man1/pandora_agent.1.gz /usr/share/man/man1/pandora_agent.1.gz

View File

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

View File

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

View File

@ -10,7 +10,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.775" PI_VERSION="7.0NG.775"
PI_BUILD="240126" PI_BUILD="240212"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

@ -1,9 +1,9 @@
bin_PROGRAMS = PandoraAgent bin_PROGRAMS = PandoraAgent
if DEBUG if DEBUG
PandoraAgent_SOURCES = misc/cron.cc misc/pandora_file.cc modules/pandora_data.cc modules/pandora_module_factory.cc modules/pandora_module.cc modules/pandora_module_list.cc modules/pandora_module_plugin.cc modules/pandora_module_inventory.cc modules/pandora_module_freememory.cc modules/pandora_module_exec.cc modules/pandora_module_perfcounter.cc modules/pandora_module_proc.cc modules/pandora_module_tcpcheck.cc modules/pandora_module_freememory_percent.cc modules/pandora_module_freedisk.cc modules/pandora_module_freedisk_percent.cc modules/pandora_module_logevent.cc modules/pandora_module_service.cc modules/pandora_module_cpuusage.cc modules/pandora_module_wmiquery.cc modules/pandora_module_regexp.cc modules/pandora_module_ping.cc modules/pandora_module_snmpget.cc udp_server/udp_server.cc main.cc pandora_strutils.cc pandora.cc windows_service.cc pandora_agent_conf.cc windows/pandora_windows_info.cc windows/pandora_wmi.cc pandora_windows_service.cc misc/md5.c misc/sha256.cc windows/wmi/disphelper.c ssh/libssh2/channel.c ssh/libssh2/mac.c ssh/libssh2/session.c ssh/libssh2/comp.c ssh/libssh2/misc.c ssh/libssh2/sftp.c ssh/libssh2/crypt.c ssh/libssh2/packet.c ssh/libssh2/userauth.c ssh/libssh2/hostkey.c ssh/libssh2/publickey.c ssh/libssh2/kex.c ssh/libssh2/scp.c ssh/pandora_ssh_client.cc ssh/pandora_ssh_test.cc ftp/pandora_ftp_client.cc ftp/pandora_ftp_test.cc debug_new.cpp PandoraAgent_SOURCES = misc/cron.cc misc/pandora_file.cc modules/pandora_data.cc modules/pandora_module_factory.cc modules/pandora_module.cc modules/pandora_module_list.cc modules/pandora_module_plugin.cc modules/pandora_module_inventory.cc modules/pandora_module_freememory.cc modules/pandora_module_exec.cc modules/pandora_module_exec_powershell.cc modules/pandora_module_perfcounter.cc modules/pandora_module_proc.cc modules/pandora_module_tcpcheck.cc modules/pandora_module_freememory_percent.cc modules/pandora_module_freedisk.cc modules/pandora_module_freedisk_percent.cc modules/pandora_module_logevent.cc modules/pandora_module_service.cc modules/pandora_module_cpuusage.cc modules/pandora_module_wmiquery.cc modules/pandora_module_regexp.cc modules/pandora_module_ping.cc modules/pandora_module_snmpget.cc udp_server/udp_server.cc main.cc pandora_strutils.cc pandora.cc windows_service.cc pandora_agent_conf.cc windows/pandora_windows_info.cc windows/pandora_wmi.cc pandora_windows_service.cc misc/md5.c misc/sha256.cc windows/wmi/disphelper.c ssh/libssh2/channel.c ssh/libssh2/mac.c ssh/libssh2/session.c ssh/libssh2/comp.c ssh/libssh2/misc.c ssh/libssh2/sftp.c ssh/libssh2/crypt.c ssh/libssh2/packet.c ssh/libssh2/userauth.c ssh/libssh2/hostkey.c ssh/libssh2/publickey.c ssh/libssh2/kex.c ssh/libssh2/scp.c ssh/pandora_ssh_client.cc ssh/pandora_ssh_test.cc ftp/pandora_ftp_client.cc ftp/pandora_ftp_test.cc debug_new.cpp
PandoraAgent_CXXFLAGS=-g -O0 PandoraAgent_CXXFLAGS=-g -O0
else else
PandoraAgent_SOURCES = misc/cron.cc misc/pandora_file.cc modules/pandora_data.cc modules/pandora_module_factory.cc modules/pandora_module.cc modules/pandora_module_list.cc modules/pandora_module_plugin.cc modules/pandora_module_inventory.cc modules/pandora_module_freememory.cc modules/pandora_module_exec.cc modules/pandora_module_perfcounter.cc modules/pandora_module_proc.cc modules/pandora_module_tcpcheck.cc modules/pandora_module_freememory_percent.cc modules/pandora_module_freedisk.cc modules/pandora_module_freedisk_percent.cc modules/pandora_module_logevent.cc modules/pandora_module_logchannel.cc modules/pandora_module_service.cc modules/pandora_module_cpuusage.cc modules/pandora_module_wmiquery.cc modules/pandora_module_regexp.cc modules/pandora_module_ping.cc modules/pandora_module_snmpget.cc udp_server/udp_server.cc main.cc pandora_strutils.cc pandora.cc windows_service.cc pandora_agent_conf.cc windows/pandora_windows_info.cc windows/pandora_wmi.cc pandora_windows_service.cc misc/md5.c misc/sha256.cc windows/wmi/disphelper.c ssh/libssh2/channel.c ssh/libssh2/mac.c ssh/libssh2/session.c ssh/libssh2/comp.c ssh/libssh2/misc.c ssh/libssh2/sftp.c ssh/libssh2/crypt.c ssh/libssh2/packet.c ssh/libssh2/userauth.c ssh/libssh2/hostkey.c ssh/libssh2/publickey.c ssh/libssh2/kex.c ssh/libssh2/scp.c ssh/pandora_ssh_client.cc ssh/pandora_ssh_test.cc ftp/pandora_ftp_client.cc ftp/pandora_ftp_test.cc PandoraAgent_SOURCES = misc/cron.cc misc/pandora_file.cc modules/pandora_data.cc modules/pandora_module_factory.cc modules/pandora_module.cc modules/pandora_module_list.cc modules/pandora_module_plugin.cc modules/pandora_module_inventory.cc modules/pandora_module_freememory.cc modules/pandora_module_exec.cc modules/pandora_module_exec_powershell.cc modules/pandora_module_perfcounter.cc modules/pandora_module_proc.cc modules/pandora_module_tcpcheck.cc modules/pandora_module_freememory_percent.cc modules/pandora_module_freedisk.cc modules/pandora_module_freedisk_percent.cc modules/pandora_module_logevent.cc modules/pandora_module_logchannel.cc modules/pandora_module_service.cc modules/pandora_module_cpuusage.cc modules/pandora_module_wmiquery.cc modules/pandora_module_regexp.cc modules/pandora_module_ping.cc modules/pandora_module_snmpget.cc udp_server/udp_server.cc main.cc pandora_strutils.cc pandora.cc windows_service.cc pandora_agent_conf.cc windows/pandora_windows_info.cc windows/pandora_wmi.cc pandora_windows_service.cc misc/md5.c misc/sha256.cc windows/wmi/disphelper.c ssh/libssh2/channel.c ssh/libssh2/mac.c ssh/libssh2/session.c ssh/libssh2/comp.c ssh/libssh2/misc.c ssh/libssh2/sftp.c ssh/libssh2/crypt.c ssh/libssh2/packet.c ssh/libssh2/userauth.c ssh/libssh2/hostkey.c ssh/libssh2/publickey.c ssh/libssh2/kex.c ssh/libssh2/scp.c ssh/pandora_ssh_client.cc ssh/pandora_ssh_test.cc ftp/pandora_ftp_client.cc ftp/pandora_ftp_test.cc
PandoraAgent_CXXFLAGS=-O2 PandoraAgent_CXXFLAGS=-O2
endif endif

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{240126} {240212}
ViewReadme ViewReadme
{Yes} {Yes}

View File

@ -236,6 +236,8 @@ Module_Kind
Pandora_Module::parseModuleKindFromString (string kind) { Pandora_Module::parseModuleKindFromString (string kind) {
if (kind == module_exec_str) { if (kind == module_exec_str) {
return MODULE_EXEC; return MODULE_EXEC;
} else if (kind == module_exec_powershell_str) {
return MODULE_EXEC_POWERSHELL;
} else if (kind == module_proc_str) { } else if (kind == module_proc_str) {
return MODULE_PROC; return MODULE_PROC;
} else if (kind == module_service_str) { } else if (kind == module_service_str) {

View File

@ -94,7 +94,8 @@ namespace Pandora_Modules {
MODULE_REGEXP, /**< The module searches a file for matches of a regular expression */ MODULE_REGEXP, /**< The module searches a file for matches of a regular expression */
MODULE_PLUGIN, /**< Plugin */ MODULE_PLUGIN, /**< Plugin */
MODULE_PING, /**< Ping module */ MODULE_PING, /**< Ping module */
MODULE_SNMPGET /**< SNMP get module */ MODULE_SNMPGET, /**< SNMP get module */
MODULE_EXEC_POWERSHELL /**< The module run a custom powershell command */
} Module_Kind; } Module_Kind;
/** /**
@ -109,24 +110,25 @@ namespace Pandora_Modules {
regex_t regexp; regex_t regexp;
} Condition; } Condition;
const string module_exec_str = "module_exec"; const string module_exec_str = "module_exec";
const string module_proc_str = "module_proc"; const string module_proc_str = "module_proc";
const string module_service_str = "module_service"; const string module_service_str = "module_service";
const string module_freedisk_str = "module_freedisk"; const string module_freedisk_str = "module_freedisk";
const string module_freedisk_percent_str = "module_freedisk_percent"; const string module_freedisk_percent_str = "module_freedisk_percent";
const string module_freememory_str = "module_freememory"; const string module_freememory_str = "module_freememory";
const string module_freememory_percent_str = "module_freememory_percent"; const string module_freememory_percent_str = "module_freememory_percent";
const string module_cpuusage_str = "module_cpuusage"; const string module_cpuusage_str = "module_cpuusage";
const string module_inventory_str = "module_inventory"; const string module_inventory_str = "module_inventory";
const string module_logevent_str = "module_logevent"; const string module_logevent_str = "module_logevent";
const string module_logchannel_str = "module_logchannel"; const string module_logchannel_str = "module_logchannel";
const string module_wmiquery_str = "module_wmiquery"; const string module_wmiquery_str = "module_wmiquery";
const string module_perfcounter_str = "module_perfcounter"; const string module_perfcounter_str = "module_perfcounter";
const string module_tcpcheck_str = "module_tcpcheck"; const string module_tcpcheck_str = "module_tcpcheck";
const string module_regexp_str = "module_regexp"; const string module_regexp_str = "module_regexp";
const string module_plugin_str = "module_plugin"; const string module_plugin_str = "module_plugin";
const string module_ping_str = "module_ping"; const string module_ping_str = "module_ping";
const string module_snmpget_str = "module_snmpget"; const string module_snmpget_str = "module_snmpget";
const string module_exec_powershell_str = "module_exec_powershell";
/** /**
* Pandora module super-class exception. * Pandora module super-class exception.

View File

@ -0,0 +1,91 @@
/* Pandora exec module. These modules exec a powershell command.
Copyright (c) 2006-2023 Pandora FMS.
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; either version 2, or (at your option)
any later version.
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.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "pandora_module_exec_powershell.h"
#include "../pandora_strutils.h"
#include <iostream>
#include <stdexcept>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#define EXEC_OK 0
#define EXEC_ERR -1
#define BUFSIZE 4096
using namespace Pandora;
using namespace Pandora_Strutils;
using namespace Pandora_Modules;
/**
* Creates a Pandora_Module_Exec_Powershell object.
*
* @param name Module name
* @param exec Command to be executed.
*/
Pandora_Module_Exec_Powershell::Pandora_Module_Exec_Powershell(string name, string exec)
: Pandora_Module (name) {
string escaped_exec;
for (char c : exec) {
if (c == '"' || c == '\\') {
escaped_exec += '\\';
}
escaped_exec += c;
}
this->module_exec = "powershell -C \"" + escaped_exec + "\"";
this->setKind (module_exec_powershell_str);
}
void Pandora_Module_Exec_Powershell::run() {
string output_result;
this->has_output = false;
FILE* pipe = popen(this->module_exec.c_str(), "r");
if (!pipe) {
pandoraLog ("Error while executing command.", GetLastError ());
return;
}
char buffer[BUFSIZE];
while (fgets(buffer, BUFSIZE, pipe) != NULL) {
output_result += buffer;
}
int result = pclose(pipe);
if (result == EXEC_ERR) {
pandoraLog ("Error while closing command process.", GetLastError ());
return;
}
if (result != EXEC_OK) {
pandoraLog ("Error invalid powershell command.", GetLastError ());
return;
}
this->has_output = true;
this->setOutput (output_result);
}

View File

@ -0,0 +1,43 @@
/* Pandora exec module. These modules exec a powershell command
Copyright (c) 2006-2023 Pandora FMS.
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; either version 2, or (at your option)
any later version.
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.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __PANDORA_MODULE_EXEC_POWERWSHELL_H__
#define __PANDORA_MODULE_EXEC_POWERWSHELL_H__
#include "pandora_module.h"
namespace Pandora_Modules {
/**
* Module to execute a powershell command.
*
* Any custom order that want to be executed can be put in
* the <code>util</code> directory into the Pandora agent path.
*/
class Pandora_Module_Exec_Powershell : public Pandora_Module {
private:
string module_exec;
public:
Pandora_Module_Exec_Powershell (string name, string exec);
void run ();
};
}
#endif

View File

@ -22,6 +22,7 @@
#include "pandora_module_factory.h" #include "pandora_module_factory.h"
#include "pandora_module.h" #include "pandora_module.h"
#include "pandora_module_exec.h" #include "pandora_module_exec.h"
#include "pandora_module_exec_powershell.h"
#include "pandora_module_proc.h" #include "pandora_module_proc.h"
#include "pandora_module_service.h" #include "pandora_module_service.h"
#include "pandora_module_freedisk.h" #include "pandora_module_freedisk.h"
@ -129,6 +130,7 @@ using namespace Pandora_Strutils;
#define TOKEN_ALERT_TEMPLATE ("module_alert_template") #define TOKEN_ALERT_TEMPLATE ("module_alert_template")
#define TOKEN_USER_SESSION ("module_user_session ") #define TOKEN_USER_SESSION ("module_user_session ")
#define TOKEN_WAIT_TIMEOUT ("module_wait_timeout ") #define TOKEN_WAIT_TIMEOUT ("module_wait_timeout ")
#define TOKEN_EXEC_POWERSHELL ("module_exec_powershell ")
string string
parseLine (string line, string token) { parseLine (string line, string token) {
@ -158,7 +160,7 @@ Pandora_Module *
Pandora_Module_Factory::getModuleFromDefinition (string definition) { Pandora_Module_Factory::getModuleFromDefinition (string definition) {
list<string> tokens; list<string> tokens;
list<string>::iterator iter; list<string>::iterator iter;
string module_name, module_type, module_exec; string module_name, module_type, module_exec, module_exec_powershell;
string module_min, module_max, module_description; string module_min, module_max, module_description;
string module_interval, module_absoluteinterval; string module_interval, module_absoluteinterval;
string module_proc, module_service; string module_proc, module_service;
@ -268,6 +270,7 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
module_user_session = ""; module_user_session = "";
macro = ""; macro = "";
module_wait_timeout = ""; module_wait_timeout = "";
module_exec_powershell = "";
stringtok (tokens, definition, "\n"); stringtok (tokens, definition, "\n");
@ -302,6 +305,9 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
if (module_exec == "") { if (module_exec == "") {
module_exec = parseLine (line, TOKEN_EXEC); module_exec = parseLine (line, TOKEN_EXEC);
} }
if (module_exec_powershell == "") {
module_exec_powershell = parseLine (line, TOKEN_EXEC_POWERSHELL);
}
if (module_wait_timeout == "") { if (module_wait_timeout == "") {
module_wait_timeout = parseLine (line, TOKEN_WAIT_TIMEOUT); module_wait_timeout = parseLine (line, TOKEN_WAIT_TIMEOUT);
} }
@ -626,6 +632,13 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
} }
} }
if (module_exec_powershell != "") {
pos_macro = module_exec_powershell.find(macro_name);
if (pos_macro != string::npos){
module_exec_powershell.replace(pos_macro, macro_name.size(), macro_value);
}
}
if (module_proc != "") { if (module_proc != "") {
pos_macro = module_proc.find(macro_name); pos_macro = module_proc.find(macro_name);
if (pos_macro != string::npos){ if (pos_macro != string::npos){
@ -1155,6 +1168,9 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
module->setWaitTimeout (atoi (module_wait_timeout.c_str ())); module->setWaitTimeout (atoi (module_wait_timeout.c_str ()));
} }
} else if (module_exec_powershell != "") {
module = new Pandora_Module_Exec_Powershell (module_name, module_exec_powershell);
} else if (module_proc != "") { } else if (module_proc != "") {
module = new Pandora_Module_Proc (module_name, module = new Pandora_Module_Proc (module_name,
module_proc); module_proc);

View File

@ -48,7 +48,7 @@ Pandora_Module_Freedisk_Percent::Pandora_Module_Freedisk_Percent (string name, s
void void
Pandora_Module_Freedisk_Percent::run () { Pandora_Module_Freedisk_Percent::run () {
long res; double res;
try { try {
Pandora_Module::run (); Pandora_Module::run ();
@ -59,7 +59,7 @@ Pandora_Module_Freedisk_Percent::run () {
try { try {
res = Pandora_Wmi::getDiskFreeSpacePercent (this->disk_id); res = Pandora_Wmi::getDiskFreeSpacePercent (this->disk_id);
this->setOutput (longtostr (res)); this->setOutput(std::to_string(res));
} catch (Pandora_Wmi::Pandora_Wmi_Exception e) { } catch (Pandora_Wmi::Pandora_Wmi_Exception e) {
this->has_output = false; this->has_output = false;
} }

View File

@ -21,6 +21,7 @@
#include "pandora_module_factory.h" #include "pandora_module_factory.h"
#include "pandora_module_list.h" #include "pandora_module_list.h"
#include "pandora_module_exec.h" #include "pandora_module_exec.h"
#include "pandora_module_exec_powershell.h"
#include "pandora_module_proc.h" #include "pandora_module_proc.h"
#include "pandora_module_service.h" #include "pandora_module_service.h"
#include "pandora_module_freedisk.h" #include "pandora_module_freedisk.h"
@ -235,6 +236,7 @@ Pandora_Modules::Pandora_Module_List::parseModuleDefinition (string definition)
Pandora_Module_Plugin *module_plugin; Pandora_Module_Plugin *module_plugin;
Pandora_Module_Ping *module_ping; Pandora_Module_Ping *module_ping;
Pandora_Module_SNMPGet *module_snmpget; Pandora_Module_SNMPGet *module_snmpget;
Pandora_Module_Exec_Powershell *module_exec_powershell;
module = Pandora_Module_Factory::getModuleFromDefinition (definition); module = Pandora_Module_Factory::getModuleFromDefinition (definition);
@ -244,6 +246,11 @@ Pandora_Modules::Pandora_Module_List::parseModuleDefinition (string definition)
module_exec = (Pandora_Module_Exec *) module; module_exec = (Pandora_Module_Exec *) module;
modules->push_back (module_exec); modules->push_back (module_exec);
break;
case MODULE_EXEC_POWERSHELL:
module_exec_powershell = (Pandora_Module_Exec_Powershell *) module;
modules->push_back (module_exec_powershell);
break; break;
case MODULE_PROC: case MODULE_PROC:
module_proc = (Pandora_Module_Proc *) module; module_proc = (Pandora_Module_Proc *) module;

View File

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

View File

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

View File

@ -188,11 +188,11 @@ Pandora_Wmi::getDiskFreeSpace (string disk_id) {
* @exception Pandora_Wmi_Exception Throwd if an error occured when reading * @exception Pandora_Wmi_Exception Throwd if an error occured when reading
* from WMI database. * from WMI database.
*/ */
unsigned long double
Pandora_Wmi::getDiskFreeSpacePercent (string disk_id) { Pandora_Wmi::getDiskFreeSpacePercent (string disk_id) {
CDhInitialize init; CDhInitialize init;
CDispPtr wmi_svc, quickfixes; CDispPtr wmi_svc, quickfixes;
double free_space = 0, size = 0; double free_space = 0, size = 0;
string query; string query;
query = "SELECT Size, FreeSpace FROM Win32_LogicalDisk WHERE DeviceID = \"" + disk_id + "\""; query = "SELECT Size, FreeSpace FROM Win32_LogicalDisk WHERE DeviceID = \"" + disk_id + "\"";
@ -202,7 +202,7 @@ Pandora_Wmi::getDiskFreeSpacePercent (string disk_id) {
dhCheck (dhGetValue (L"%o", &quickfixes, wmi_svc, dhCheck (dhGetValue (L"%o", &quickfixes, wmi_svc,
L".ExecQuery(%T)", L".ExecQuery(%T)",
query.c_str ())); query.c_str ()));
FOR_EACH (quickfix, quickfixes, NULL) { FOR_EACH (quickfix, quickfixes, NULL) {
dhGetValue (L"%e", &free_space, quickfix, dhGetValue (L"%e", &free_space, quickfix,
L".FreeSpace"); L".FreeSpace");
@ -213,7 +213,7 @@ Pandora_Wmi::getDiskFreeSpacePercent (string disk_id) {
return 0; return 0;
} }
return (unsigned long) (free_space * 100 / size); return (free_space * 100 / size);
} NEXT_THROW (quickfix); } NEXT_THROW (quickfix);
} catch (string errstr) { } catch (string errstr) {
pandoraLog ("getDiskFreeSpace error. %s", errstr.c_str ()); pandoraLog ("getDiskFreeSpace error. %s", errstr.c_str ());

View File

@ -44,7 +44,7 @@ namespace Pandora_Wmi {
int isProcessRunning (string process_name); int isProcessRunning (string process_name);
int isServiceRunning (string service_name); int isServiceRunning (string service_name);
unsigned long getDiskFreeSpace (string disk_id); unsigned long getDiskFreeSpace (string disk_id);
unsigned long getDiskFreeSpacePercent (string disk_id); double getDiskFreeSpacePercent (string disk_id);
int getCpuUsagePercentage (int cpu_id); int getCpuUsagePercentage (int cpu_id);
long getFreememory (); long getFreememory ();
long getFreememoryPercent (); long getFreememoryPercent ();

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 7.0NG.775-240126 Version: 7.0NG.775-240212
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

@ -23,6 +23,9 @@ if ($headers['Authorization']) {
list($user, $password) = explode(':', base64_decode($headers['Authorization'])); list($user, $password) = explode(':', base64_decode($headers['Authorization']));
// Prevent sql injection.
$user = mysqli_real_escape_string($config['dbconnection'], $user);
// Check user login // Check user login
$user_in_db = process_user_login($user, $password, true); $user_in_db = process_user_login($user, $password, true);

View File

@ -24,6 +24,9 @@ if ($headers['Authorization']) {
list($user, $password) = explode(':', base64_decode($headers['Authorization'])); list($user, $password) = explode(':', base64_decode($headers['Authorization']));
// Prevent sql injection.
$user = mysqli_real_escape_string($config['dbconnection'], $user);
// Check user login // Check user login
$user_in_db = process_user_login($user, $password, true); $user_in_db = process_user_login($user, $password, true);

View File

@ -223,7 +223,7 @@ function mainInsertData()
'', '',
empty($agent_id) empty($agent_id)
); );
$table->data[1][2] = html_print_input_text('data', ($save === true) ? date(DATE_FORMAT) : $data, __('Data'), 10, 60, true); $table->data[1][2] = html_print_input_text('date', ($save === true) ? date(DATE_FORMAT) : $data, __('Data'), 10, 60, true);
$table->data[1][2] .= '&nbsp;'; $table->data[1][2] .= '&nbsp;';
$table->data[1][2] .= html_print_input_text('time', ($save === true) ? date(TIME_FORMAT) : $time, '', 10, 7, true); $table->data[1][2] .= html_print_input_text('time', ($save === true) ? date(TIME_FORMAT) : $time, '', 10, 7, true);
@ -284,7 +284,7 @@ function mainInsertData()
currentText: '<?php echo __('Now'); ?>', currentText: '<?php echo __('Now'); ?>',
closeText: '<?php echo __('Close'); ?>'}); closeText: '<?php echo __('Close'); ?>'});
$('#text-data').datepicker ({ $('#text-date').datepicker ({
dateFormat: '<?php echo DATE_FORMAT_JS; ?>', dateFormat: '<?php echo DATE_FORMAT_JS; ?>',
changeMonth: true, changeMonth: true,
changeYear: true, changeYear: true,

View File

@ -128,6 +128,6 @@ if (empty($data)) {
} }
echo '{ echo '{
"label": "'.htmlspecialchars($graph_title, ENT_QUOTES).'", "label": "'.htmlspecialchars(($graph_title ?? ''), ENT_QUOTES).'",
"data": [["'.time().'", '.htmlspecialchars($data, ENT_QUOTES).']] "data": [["'.time().'", '.htmlspecialchars(($data ?? ''), ENT_QUOTES).']]
}'; }';

View File

@ -1,14 +1,66 @@
START TRANSACTION; START TRANSACTION;
CREATE TABLE IF NOT EXISTS `tmerge_error` (
`id` int(10) NOT NULL auto_increment,
`id_node` int(10) default 0,
`phase` int(10) default 0,
`step` int(10) default 0,
`msg` LONGTEXT default "",
`action` text default "",
`utimestamp` int(20) unsigned NOT NULL default 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
ALTER TABLE `tmerge_error` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `tmerge_steps` (
`id` int(10) NOT NULL auto_increment,
`id_node` int(10) default 0,
`phase` int(10) default 0,
`total` int(10) default 0,
`step` int(10) default 0,
`debug` varchar(1024) default "",
`action` varchar(100) default "",
`affected` varchar(100) default "",
`query` mediumtext default "",
`utimestamp` int(20) unsigned NOT NULL default 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
ALTER TABLE `tmerge_steps` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `tmerge_queries` (
`steps` int(10) NOT NULL auto_increment,
`action` varchar(100) default "",
`affected` varchar(100) default "",
`utimestamp` int(20) unsigned NOT NULL default 0,
`query` LONGTEXT NOT NULL default "",
PRIMARY KEY (`steps`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
ALTER TABLE `tmerge_queries` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
ALTER TABLE `tevent_sound` MODIFY COLUMN `name` text NULL;
ALTER TABLE `tevent_sound` MODIFY COLUMN `sound` text NULL;
ALTER TABLE `treport_content` MODIFY COLUMN `use_prefix_notation` tinyint unsigned NOT NULL DEFAULT 1;
ALTER TABLE `treport_content_template` MODIFY COLUMN `use_prefix_notation` tinyint unsigned NOT NULL DEFAULT 1;
ALTER TABLE `tsesion_filter` MODIFY COLUMN `id_name` text NULL;
ALTER TABLE `tsesion_filter` MODIFY COLUMN `ip` text NULL;
ALTER TABLE `tsesion_filter` MODIFY COLUMN `type` text NULL;
ALTER TABLE `tsesion_filter` MODIFY COLUMN `user` text NULL;
ALTER TABLE `tncm_agent_data`
ADD COLUMN `id_agent_data` int not null default 0 AFTER `script_type`;
ALTER TABLE `tusuario` CHANGE COLUMN `metaconsole_data_section` `metaconsole_data_section` TEXT NOT NULL DEFAULT '' ;
ALTER TABLE `tmensajes` ADD COLUMN `icon_notification` VARCHAR(250) NULL DEFAULT NULL AFTER `url`;
UPDATE `tncm_template` SET `vendors` = CONCAT('["', TRIM(BOTH '"' FROM TRIM(BOTH ']' FROM TRIM(BOTH '[' FROM vendors))), '"]'), `models` = CONCAT('["', TRIM(BOTH '"' FROM TRIM(BOTH ']' FROM TRIM(BOTH '[' FROM models))), '"]');
UPDATE `tncm_agent_data_template` SET `vendors` = CONCAT('["', TRIM(BOTH '"' FROM TRIM(BOTH ']' FROM TRIM(BOTH '[' FROM vendors))), '"]'), `models` = CONCAT('["', TRIM(BOTH '"' FROM TRIM(BOTH ']' FROM TRIM(BOTH '[' FROM models))), '"]');
-- Update version for plugin oracle -- Update version for plugin oracle
UPDATE `tdiscovery_apps` SET `version` = '1.2' WHERE `short_name` = 'pandorafms.oracle'; UPDATE `tdiscovery_apps` SET `version` = '1.2' WHERE `short_name` = 'pandorafms.oracle';
ALTER TABLE `tncm_agent_data` SET @widget_id = NULL;
ADD COLUMN `id_agent_data` int not null default 0 AFTER `script_type`; SELECT @widget_id := `id` FROM `twidget` WHERE `unique_name` = 'GisMap';
INSERT IGNORE INTO `twidget` (`id`,`class_name`,`unique_name`,`description`,`options`,`page`) VALUES (@widget_id,'GisMap','GisMap','Gis map','','GisMap.php');
ALTER TABLE `tusuario` CHANGE COLUMN `metaconsole_data_section` `metaconsole_data_section` TEXT NOT NULL DEFAULT '' ;
ALTER TABLE `tmensajes` ADD COLUMN `icon_notification` VARCHAR(250) NULL DEFAULT NULL AFTER `url`;
COMMIT; COMMIT;

View File

@ -1021,11 +1021,14 @@ echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
modal: { modal: {
title: "<?php echo __('Welcome to').' '.io_safe_output(get_product_name()); ?>", title: "<?php echo __('Welcome to').' '.io_safe_output(get_product_name()); ?>",
cancel: '<?php echo __('Do not show anymore'); ?>', cancel: '<?php echo __('Do not show anymore'); ?>',
ok: '<?php echo __('Close'); ?>' ok: '<?php echo __('Close'); ?>',
overlay: true,
overlayExtraClass: 'welcome-overlay',
}, },
onshow: { onshow: {
page: 'include/ajax/welcome_window', page: 'include/ajax/welcome_window',
method: 'loadWelcomeWindow', method: 'loadWelcomeWindow',
width: 1000,
}, },
oncancel: { oncancel: {
page: 'include/ajax/welcome_window', page: 'include/ajax/welcome_window',
@ -1043,6 +1046,34 @@ echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
} }
}) })
} }
},
onload: () => {
$(document).ready(function () {
var buttonpane = $("div[aria-describedby='welcome_modal_window'] .ui-dialog-buttonpane.ui-widget-content.ui-helper-clearfix");
$(buttonpane).append(`
<div class="welcome-wizard-buttons">
<label>
<input type="checkbox" class="welcome-wizard-do-not-show" value="1" />
<?php echo __('Do not show anymore'); ?>
</label>
<button class="close-wizard-button"><?php echo __('Close wizard'); ?></button>
</div>
`);
var closeWizard = $("button.close-wizard-button");
$(closeWizard).click(function (e) {
var close = $("div[aria-describedby='welcome_modal_window'] button.sub.ok.submit-next.ui-button");
var cancel = $("div[aria-describedby='welcome_modal_window'] button.sub.upd.submit-cancel.ui-button");
var checkbox = $("div[aria-describedby='welcome_modal_window'] .welcome-wizard-do-not-show:checked").length;
if (checkbox === 1) {
$(cancel).click();
} else {
$(close).click()
}
});
});
} }
}); });
}); });

View File

@ -507,14 +507,16 @@ if (enterprise_installed()) {
// Read configuration file. // Read configuration file.
$files = config_agents_get_agent_config_filenames($id_agente); $files = config_agents_get_agent_config_filenames($id_agente);
$file_name = $files['conf']; $file_name = $files['conf'];
$agent_config = file_get_contents($file_name); if (empty($file_name) === false) {
$encoding = 'UTF-8'; $agent_config = file_get_contents($file_name);
$agent_config_utf8 = mb_convert_encoding($agent_config, 'UTF-8', $encoding); $encoding = 'UTF-8';
if ($agent_config_utf8 !== false) { $agent_config_utf8 = mb_convert_encoding($agent_config, 'UTF-8', $encoding);
$agent_config = $agent_config_utf8; if ($agent_config_utf8 !== false) {
} $agent_config = $agent_config_utf8;
}
$broker = str_contains($agent_config, '#broker active'); $broker = str_contains($agent_config, '#broker active');
}
} }
if ($broker === false) { if ($broker === false) {

View File

@ -575,7 +575,7 @@ $where = sprintf('delete_pending = 0 AND id_agente = %s', $id_agente);
$search_string_entities = io_safe_input($search_string); $search_string_entities = io_safe_input($search_string);
$basic_where = sprintf( $basic_where = sprintf(
"(REPLACE(nombre, '&#x20;', ' ') LIKE '%%%s%%' OR REPLACE(nombre, '&#x20;', ' ') LIKE '%%%s%%' OR REPLACE(descripcion, '&#x20;', ' ') LIKE '%%%s%%' OR REPLACE(descripcion, '&#x20;', ' ') LIKE '%%%s%%') AND", "(nombre LIKE '%%%s%%' OR nombre LIKE '%%%s%%' OR descripcion LIKE '%%%s%%' OR descripcion LIKE '%%%s%%') AND",
$search_string, $search_string,
$search_string_entities, $search_string_entities,
$search_string, $search_string,

View File

@ -150,7 +150,7 @@ if (is_ajax()) {
$component = db_get_row('tlocal_component', 'id', $id_component); $component = db_get_row('tlocal_component', 'id', $id_component);
foreach ($component as $index => $element) { foreach ($component as $index => $element) {
$component[$index] = html_entity_decode( $component[$index] = html_entity_decode(
$element, (isset($element) === true) ? $element : '',
ENT_QUOTES, ENT_QUOTES,
'UTF-8' 'UTF-8'
); );

View File

@ -505,7 +505,7 @@ $tableBasicThresholds->data['caption_switch_warning_inverse_string'][0] = html_p
$tableBasicThresholds->data['caption_warning_threshold'][0] .= '<span class="font_11" id="caption_str_warning">('.__('Str.').')</span>'; $tableBasicThresholds->data['caption_warning_threshold'][0] .= '<span class="font_11" id="caption_str_warning">('.__('Str.').')</span>';
$tableBasicThresholds->data['warning_threshold'][0] .= html_print_input_text( $tableBasicThresholds->data['warning_threshold'][0] .= html_print_input_text(
'str_warning', 'str_warning',
str_replace('"', '', $str_warning), str_replace('"', '', (isset($str_warning) === true) ? $str_warning : ''),
'', '',
10, 10,
1024, 1024,
@ -602,7 +602,7 @@ $tableBasicThresholds->data['switch_critical_threshold'][0] .= html_print_div(
$tableBasicThresholds->data['caption_critical_threshold'][0] .= '<span class="font_11" id="caption_str_critical">('.__('Str.').')</span>'; $tableBasicThresholds->data['caption_critical_threshold'][0] .= '<span class="font_11" id="caption_str_critical">('.__('Str.').')</span>';
$tableBasicThresholds->data['critical_threshold'][0] .= html_print_input_text( $tableBasicThresholds->data['critical_threshold'][0] .= html_print_input_text(
'str_critical', 'str_critical',
str_replace('"', '', $str_critical), str_replace('"', '', (isset($str_critical) === true) ? $str_critical : ''),
'', '',
10, 10,
1024, 1024,

View File

@ -60,7 +60,12 @@ $data[1] = html_print_select_from_sql(
$disabledBecauseInPolicy $disabledBecauseInPolicy
); );
// Store the macros in base64 into a hidden control to move between pages // Store the macros in base64 into a hidden control to move between pages
$data[1] .= html_print_input_hidden('macros', base64_encode($macros), true); $data[1] .= html_print_input_hidden(
'macros',
(isset($macros) === true) ? base64_encode($macros) : '',
true
);
$table_simple->colspan['plugin_1'][2] = 2; $table_simple->colspan['plugin_1'][2] = 2;
if (!empty($id_plugin)) { if (!empty($id_plugin)) {

View File

@ -285,20 +285,25 @@ if (enterprise_installed()) {
$data = []; $data = [];
$data[0] = html_print_label_input_block( $data[0] = html_print_label_input_block(
'<div id="server_to_exec_label" class="labels invisible">'.__('Server to execute command').'</div>', '<div id="server_to_exec_label" class="labels invisible">'.__('Server to execute command').'</div>',
'<div id="server_to_exec_value" class="invisible" >'.html_print_select( '<div id="server_to_exec_value" class="w100p margin-top-10 invisible" >'.html_print_select(
$servers_to_exec, $servers_to_exec,
'server_to_exec', 'server_to_exec',
$event_response['server_to_exec'], $event_response['server_to_exec'],
'', '',
'', '',
'', '',
true true,
false,
true,
'w100p',
false,
'width: 100%'
).'</div>' ).'</div>'
); );
$data[1] = html_print_label_input_block( $data[1] = html_print_label_input_block(
'<div id="command_timeout_label" class="labels invisible">'.__('Command timeout (s)'), '<div id="command_timeout_label" class="labels invisible">'.__('Command timeout (s)'),
'<div id="command_timeout_value" class="invisible">'.html_print_input_text( '<div id="command_timeout_value" class=" w100p margin-top-10 invisible">'.html_print_input_text(
'command_timeout', 'command_timeout',
$event_response['command_timeout'], $event_response['command_timeout'],
'', '',
@ -358,18 +363,18 @@ $('#type').change(function() {
$('#new_window option[value="0"]') $('#new_window option[value="0"]')
.prop('selected', true); .prop('selected', true);
$('#new_window').attr('disabled','disabled'); $('#new_window').attr('disabled','disabled');
$('#server_to_exec_label').css('display',''); $('#server_to_exec_label').show();
$('#server_to_exec_value').css('display',''); $('#server_to_exec_value').show();
$('#command_timeout_label').css('display',''); $('#command_timeout_label').show();
$('#command_timeout_value').css('display',''); $('#command_timeout_value').show();
break; break;
case 'url': case 'url':
$('#new_window').removeAttr('disabled'); $('#new_window').removeAttr('disabled');
$('#server_to_exec_label').css('display','none'); $('#server_to_exec_label').hide();
$('#server_to_exec_value').css('display','none'); $('#server_to_exec_value').hide();
$('#command_timeout_label').css('display','none'); $('#command_timeout_label').hide();
$('#command_timeout_value').css('display','none'); $('#command_timeout_value').hide();
break; break;
} }

View File

@ -319,9 +319,8 @@ if ($update_agents) {
$secondary_groups_removed $secondary_groups_removed
); );
$agents_values = agents_get_agent((int) $array_id[1]); $agents_values = db_get_row_filter('tagente', ['id_agente' => (int) $array_id[1]]);
$node->disconnect(); $node->disconnect();
if (empty($values) === false) { if (empty($values) === false) {
update_agents_in_metaconsole( update_agents_in_metaconsole(
(int) $array_id[1], (int) $array_id[1],

View File

@ -768,7 +768,7 @@ $table_critical->tdid[0][0] = 'edit1-3-min';
$table_critical->data[0][0] = html_print_label_input_block( $table_critical->data[0][0] = html_print_label_input_block(
__('Min.'), __('Min.'),
html_print_input_text( html_print_input_text(
'min_warning', 'min_critical',
'', '',
'', '',
false, false,
@ -781,7 +781,7 @@ $table_critical->tdid[0][1] = 'edit1-3-max';
$table_critical->data[0][1] = html_print_label_input_block( $table_critical->data[0][1] = html_print_label_input_block(
__('Max.'), __('Max.'),
html_print_input_text( html_print_input_text(
'max_warning', 'max_critical',
'', '',
'', '',
false, false,
@ -1500,7 +1500,7 @@ $table->data[39][0] = html_print_label_input_block(
'', '',
'', '',
true true
).html_print_input_hidden('macros', base64_encode($macros), true) ).html_print_input_hidden('macros', base64_encode(($macros ?? '')), true)
); );
require_once $config['homedir'].'/include/class/CredentialStore.class.php'; require_once $config['homedir'].'/include/class/CredentialStore.class.php';

View File

@ -518,7 +518,18 @@ if ($access_console_node === true) {
} }
if ((bool) check_acl($config['id_user'], 0, 'PM') === true || (bool) check_acl($config['id_user'], 0, 'DM') === true) { if ((bool) check_acl($config['id_user'], 0, 'AW') === true) {
$show_ipam = false;
$ipam = db_get_all_rows_sql('SELECT users_operator FROM tipam_network');
foreach ($ipam as $row) {
if (str_contains($row['users_operator'], '-1') || str_contains($row['users_operator'], $config['id_user'])) {
$show_ipam = true;
break;
}
}
}
if ((bool) check_acl($config['id_user'], 0, 'PM') === true || (bool) check_acl($config['id_user'], 0, 'DM') === true || $show_ipam === true) {
$menu_godmode['gextensions']['text'] = __('Admin tools'); $menu_godmode['gextensions']['text'] = __('Admin tools');
$menu_godmode['gextensions']['sec2'] = 'godmode/extensions'; $menu_godmode['gextensions']['sec2'] = 'godmode/extensions';
$menu_godmode['gextensions']['id'] = 'god-extensions'; $menu_godmode['gextensions']['id'] = 'god-extensions';
@ -535,8 +546,6 @@ if ((bool) check_acl($config['id_user'], 0, 'PM') === true || (bool) check_acl($
$sub['tools/diagnostics']['text'] = __('Diagnostic info'); $sub['tools/diagnostics']['text'] = __('Diagnostic info');
$sub['tools/diagnostics']['id'] = 'diagnostic_info'; $sub['tools/diagnostics']['id'] = 'diagnostic_info';
enterprise_hook('omnishell'); enterprise_hook('omnishell');
enterprise_hook('ipam_submenu');
$sub['godmode/setup/news']['text'] = __('Site news'); $sub['godmode/setup/news']['text'] = __('Site news');
$sub['godmode/setup/news']['id'] = 'site_news'; $sub['godmode/setup/news']['id'] = 'site_news';
} }
@ -558,9 +567,15 @@ if ((bool) check_acl($config['id_user'], 0, 'PM') === true || (bool) check_acl($
} }
} }
$sub['godmode/events/configuration_sounds']['text'] = __('Acoustic console setup'); if (((bool) check_acl($config['id_user'], 0, 'PM') === true && $access_console_node === true) || $show_ipam === true) {
$sub['godmode/events/configuration_sounds']['id'] = 'Acoustic console setup'; enterprise_hook('ipam_submenu');
$sub['godmode/events/configuration_sounds']['pages'] = ['godmode/events/configuration_sounds']; }
if ((bool) check_acl($config['id_user'], 0, 'PM') === true || (bool) check_acl($config['id_user'], 0, 'DM') === true) {
$sub['godmode/events/configuration_sounds']['text'] = __('Acoustic console setup');
$sub['godmode/events/configuration_sounds']['id'] = 'Acoustic console setup';
$sub['godmode/events/configuration_sounds']['pages'] = ['godmode/events/configuration_sounds'];
}
$menu_godmode['gextensions']['sub'] = $sub; $menu_godmode['gextensions']['sub'] = $sub;
} }
@ -638,16 +653,18 @@ if ($access_console_node === true) {
} }
// Complete the submenu. // Complete the submenu.
$extension_view = []; if (users_is_admin($config['id_user']) === true) {
$extension_view['godmode/extensions']['id'] = 'extension_manager_view'; $extension_view = [];
$extension_view['godmode/extensions']['text'] = __('Extension manager view'); $extension_view['godmode/extensions']['id'] = 'extension_manager_view';
$extension_submenu = array_merge($extension_view, $sub2); $extension_view['godmode/extensions']['text'] = __('Extension manager view');
$extension_submenu = array_merge($extension_view, $sub2);
$sub['godmode/extensions']['sub2'] = $extension_submenu; $sub['godmode/extensions']['sub2'] = $extension_submenu;
$sub['godmode/extensions']['text'] = __('Extension manager'); $sub['godmode/extensions']['text'] = __('Extension manager');
$sub['godmode/extensions']['id'] = 'extension_manager'; $sub['godmode/extensions']['id'] = 'extension_manager';
$sub['godmode/extensions']['type'] = 'direct'; $sub['godmode/extensions']['type'] = 'direct';
$sub['godmode/extensions']['subtype'] = 'nolink'; $sub['godmode/extensions']['subtype'] = 'nolink';
}
if (is_array($menu_godmode['gextensions']['sub']) === true) { if (is_array($menu_godmode['gextensions']['sub']) === true) {
$submenu = array_merge($menu_godmode['gextensions']['sub'], $sub); $submenu = array_merge($menu_godmode['gextensions']['sub'], $sub);

View File

@ -1058,7 +1058,11 @@ switch ($action) {
$resolution = $item['top_n']; $resolution = $item['top_n'];
// Interval resolution. // Interval resolution.
$max_values = $item['top_n_value']; $max_values = $item['top_n_value'];
// Max values. $es = json_decode($item['external_source'], true);
$top_n_type = $es['top_n_type'];
$display_graph = $es['display_graph'];
$display_summary = $es['display_summary'];
$display_data_table = $es['display_data_table'];
break; break;
case 'permissions_report': case 'permissions_report':
@ -1703,6 +1707,75 @@ if (is_metaconsole() === true) {
</td> </td>
</tr> </tr>
<tr id="row_top_n_type" class="datos">
<td class="bolder"><?php echo __('Type'); ?></td>
<td >
<?php
$types = [
0 => __('Show aggregate by destination port'),
1 => __('Show InBound/Outbound traffic per SrcIP/DestIP'),
];
html_print_select(
$types,
'top_n_type',
$top_n_type,
''
);
?>
</td>
</tr>
<tr id="row_display_graph" class="datos">
<td class="bolder">
<?php
echo __('Display graph');
?>
</td>
<td >
<?php
html_print_checkbox_switch(
'display_graph',
1,
($display_graph ?? true)
);
?>
</td>
</tr>
<tr id="row_display_summary_table" class="datos">
<td class="bolder">
<?php
echo __('Display summary table');
?>
</td>
<td >
<?php
html_print_checkbox_switch(
'display_summary',
1,
($display_summary ?? true)
);
?>
</td>
</tr>
<tr id="row_display_data_table" class="datos">
<td class="bolder">
<?php
echo __('Display data table');
?>
</td>
<td >
<?php
html_print_checkbox_switch(
'display_data_table',
1,
($display_data_table ?? true)
);
?>
</td>
</tr>
<tr id="row_period_service_level" class="datos"> <tr id="row_period_service_level" class="datos">
<td class="bolder"> <td class="bolder">
<?php <?php
@ -7420,6 +7493,10 @@ function chooseType() {
$("#row_alert_templates").hide(); $("#row_alert_templates").hide();
$("#row_alert_actions").hide(); $("#row_alert_actions").hide();
$("#row_servers").hide(); $("#row_servers").hide();
$("#row_top_n_type").hide();
$("#row_display_graph").hide();
$("#row_display_summary_table").hide();
$("#row_display_data_table").hide();
$("#row_servers_all_opt").hide(); $("#row_servers_all_opt").hide();
$("#row_servers_all").hide(); $("#row_servers_all").hide();
$("#row_multiple_servers").hide(); $("#row_multiple_servers").hide();
@ -8374,6 +8451,10 @@ function chooseType() {
$("#row_max_values").show(); $("#row_max_values").show();
$("#row_resolution").show(); $("#row_resolution").show();
$("#row_servers").show(); $("#row_servers").show();
$("#row_top_n_type").show();
$("#row_display_graph").show();
$("#row_display_summary_table").show();
$("#row_display_data_table").show();
$("#row_historical_db_check").hide(); $("#row_historical_db_check").hide();
break; break;

View File

@ -1878,6 +1878,13 @@ switch ($action) {
$values['top_n_value'] = get_parameter( $values['top_n_value'] = get_parameter(
'max_values' 'max_values'
); );
$es['top_n_type'] = get_parameter('top_n_type', '');
$es['display_graph'] = get_parameter('display_graph', '');
$es['display_summary'] = get_parameter('display_summary', '');
$es['display_data_table'] = get_parameter('display_data_table', '');
$values['external_source'] = json_encode($es);
$good_format = true; $good_format = true;
break; break;
@ -2962,6 +2969,12 @@ switch ($action) {
$values['top_n_value'] = get_parameter( $values['top_n_value'] = get_parameter(
'max_values' 'max_values'
); );
$es['top_n_type'] = get_parameter('top_n_type', '');
$es['display_graph'] = get_parameter('display_graph', '');
$es['display_summary'] = get_parameter('display_summary', '');
$es['display_data_table'] = get_parameter('display_data_table', '');
$values['external_source'] = json_encode($es);
$good_format = true; $good_format = true;
break; break;

View File

@ -247,7 +247,7 @@ if ($favorite_array == false) {
$url = 'index.php?sec=network&sec2=operation/visual_console/render_view&id='.$favourite_v['id']; $url = 'index.php?sec=network&sec2=operation/visual_console/render_view&id='.$favourite_v['id'];
} }
echo "<a href='".$url."' title='Visual console".$favourite_v['name']."' alt='".$favourite_v['name']."'><li>"; echo "<a href='".$url."' title='".io_safe_output($favourite_v['name'])."' alt='".io_safe_output($favourite_v['name'])."'><li>";
echo "<div class='icon_img'>"; echo "<div class='icon_img'>";
echo html_print_image( echo html_print_image(
'images/'.groups_get_icon($favourite_v['id_group']), 'images/'.groups_get_icon($favourite_v['id_group']),
@ -256,7 +256,7 @@ if ($favorite_array == false) {
); );
echo '</div>'; echo '</div>';
echo "<div class='text'>"; echo "<div class='text'>";
echo $favourite_v['name']; echo io_safe_output($favourite_v['name']);
echo '</div>'; echo '</div>';
echo '</li></a>'; echo '</li></a>';
} }

View File

@ -215,7 +215,7 @@ if ($create != '') {
// ===================================================================== // =====================================================================
if ($filemanager) { if ($filemanager) {
if ($edit_file) { if ($edit_file) {
$location_file = get_parameter('location_file', ''); $location_file = io_safe_output(get_parameter('location_file', ''));
$filename = array_pop(explode('/', $location_file)); $filename = array_pop(explode('/', $location_file));
$file = file_get_contents($location_file); $file = file_get_contents($location_file);
echo '<h4>'.__('Edit file').' '.$filename.'</h4>'; echo '<h4>'.__('Edit file').' '.$filename.'</h4>';
@ -250,7 +250,7 @@ if ($filemanager) {
echo '</form>'; echo '</form>';
} else { } else {
if ($update_file) { if ($update_file) {
$location_file = get_parameter('location_file', ''); $location_file = io_safe_output(get_parameter('location_file', ''));
$contentFile = io_safe_output(get_parameter('content_file', '')); $contentFile = io_safe_output(get_parameter('content_file', ''));
$compatibility = get_parameter('compatibility', 'unix'); $compatibility = get_parameter('compatibility', 'unix');
$is_win_compatible = strpos($contentFile, "\r\n"); $is_win_compatible = strpos($contentFile, "\r\n");
@ -262,7 +262,12 @@ if ($filemanager) {
$contentFile = str_replace("\n", "\r\n", $contentFile); $contentFile = str_replace("\n", "\r\n", $contentFile);
} }
$result = file_put_contents($location_file, $contentFile); if (empty($location_file) === false
&& strpos($location_file, realpath('attachment/plugin')) !== false
&& file_exists($location_file) === true
) {
$result = file_put_contents($location_file, $contentFile);
}
} }
$id_plugin = (int) get_parameter('id_plugin', 0); $id_plugin = (int) get_parameter('id_plugin', 0);

View File

@ -115,7 +115,7 @@ foreach ($servers as $server) {
$table->cellclass[] = [ $table->cellclass[] = [
3 => 'progress_bar', 3 => 'progress_bar',
8 => 'table_action_buttons', 9 => 'table_action_buttons',
]; ];
$data[0] = '<span title="'.$server['version'].'">'.strip_tags($server['name']).'</span>'; $data[0] = '<span title="'.$server['version'].'">'.strip_tags($server['name']).'</span>';

View File

@ -48,7 +48,7 @@ if ($idOS > 0) {
} else { } else {
$name = io_safe_input(strip_tags(trim(io_safe_output((string) get_parameter('name'))))); $name = io_safe_input(strip_tags(trim(io_safe_output((string) get_parameter('name')))));
$description = io_safe_input(strip_tags(io_safe_output((string) get_parameter('description')))); $description = io_safe_input(strip_tags(io_safe_output((string) get_parameter('description'))));
$icon = get_parameter('icon', 0); $icon = get_parameter('icon', 'os@svg.svg');
} }
$icon_upload = get_parameter('icon_upload', null); $icon_upload = get_parameter('icon_upload', null);
@ -246,7 +246,7 @@ $iconData[] = html_print_select(
'icon', 'icon',
$icon, $icon,
'show_icon_OS();', 'show_icon_OS();',
__('None'), '',
0, 0,
true true
); );
@ -356,6 +356,8 @@ function get_list_os_icons_dir()
} }
} }
$return['os@svg.svg'] = __('None');
return $return; return $return;
} }

View File

@ -88,6 +88,14 @@ switch ($tab) {
break; break;
case 'manage_os': case 'manage_os':
$id_os = get_parameter('id_os', '');
if ($id_os !== '') {
$headerTitle = __('Edit OS');
} else {
$headerTitle = __('Create OS');
}
break;
case 'list': case 'list':
if ($action === 'edit') { if ($action === 'edit') {
$headerTitle = __('Edit OS'); $headerTitle = __('Edit OS');

View File

@ -960,60 +960,6 @@ echo '<legend>'.__('Mail configuration').'</legend>';
); );
echo '</form>'; echo '</form>';
/**
* Print the modal window for the summary of each alerts group
*
* @param string $id Id.
*
* @return void
*/
function print_email_test_modal_window($id)
{
// Email config table.
$table_mail_test = new stdClass();
$table_mail_test->width = '100%';
$table_mail_test->class = 'filter-table-adv';
$table_mail_test->data = [];
$table_mail_test->data[0][] = html_print_label_input_block(
__('Address'),
html_print_input_text(
'email_test_address',
'',
'',
35,
100,
true
)
);
$table_mail_test->data[1][] = '&nbsp&nbsp<span id="email_test_sent_message" class="invisible"><b>Email sent</b></span><span id="email_test_failure_message" class=invisible"><b>Email could not be sent</b></span>';
// $table_mail_test->colspan[2][0] = 2;
$submitButton = html_print_div(
[
'class' => 'action-buttons-right-forced',
'content' => html_print_button(
__('Send'),
'email_test',
false,
'',
[
'icon' => 'cog',
'mode' => 'mini',
],
true
),
],
true
);
echo '<div id="email_test_'.$id.'" title="'.__('Check mail configuration').'" class="invisible">'.html_print_table($table_mail_test, true).$submitButton.'</div>';
}
?> ?>
<script type="text/javascript"> <script type="text/javascript">
function show_timezone () { function show_timezone () {
@ -1033,62 +979,6 @@ function show_timezone () {
}); });
} }
function show_email_test(id) {
$('#email_test_sent_message').hide();
$('#email_test_failure_message').hide();
$("#email_test_"+id).dialog({
resizable: true,
draggable: true,
modal: true,
width: 450,
overlay: {
opacity: 0.5,
background: "black"
}
});
}
function perform_email_test () {
$('#email_test_sent_message').hide();
$('#email_test_failure_message').hide();
var test_address = $('#text-email_test_address').val();
params = {
email_smtpServer : $('#text-email_smtpServer').val(),
email_smtpPort : $('#text-email_smtpPort').val(),
email_username : $('#text-email_username').val(),
email_password : $('#password-email_password').val(),
email_encryption : $( "#email_encryption option:selected" ).val(),
email_from_dir : $('#text-email_from_dir').val(),
email_from_name : $('#text-email_from_name').val()
};
$.ajax({
type: "POST",
url: "ajax.php",
data : {
page: "godmode/setup/setup_general",
test_address: test_address,
params: params
},
dataType: "json",
success: function(data) {
if (parseInt(data) === 1) {
$('#email_test_sent_message').show();
$('#email_test_failure_message').hide();
} else {
$('#email_test_failure_message').show();
$('#email_test_sent_message').hide();
}
},
error: function() {
$('#email_test_failure_message').show();
$('#email_test_sent_message').hide();
},
});
}
$(document).ready (function () { $(document).ready (function () {
$("#zone").attr("hidden", true); $("#zone").attr("hidden", true);
@ -1146,8 +1036,6 @@ $(document).ready (function () {
} }
}) })
$('#button-email_test').click(perform_email_test);
$("#right_iblacklist").click (function () { $("#right_iblacklist").click (function () {
jQuery.each($("select[name='inventory_changes_blacklist_out[]'] option:selected"), function (key, value) { jQuery.each($("select[name='inventory_changes_blacklist_out[]'] option:selected"), function (key, value) {
imodule_name = $(value).html(); imodule_name = $(value).html();

View File

@ -386,7 +386,7 @@ if (empty($result) === false) {
$data[4] = $output; $data[4] = $output;
$phone_large = io_safe_output($tag['phone']); $phone_large = io_safe_output($tag['phone']);
$phone_small = substr($phone_large, 0, 24); $phone_small = substr(($phone_large ?? ''), 0, 24);
if ($phone_large == $phone_small) { if ($phone_large == $phone_small) {
$output = $phone_large; $output = $phone_large;
} else { } else {

View File

@ -770,7 +770,7 @@ if ($update_user) {
$id_user = (string) get_parameter('id_user', ''); $id_user = (string) get_parameter('id_user', '');
if ($password_new != '') { if ($password_new != '') {
if ($config['auth'] !== 'mysql') { if ($config['auth'] !== 'mysql' && $values['local_user'] === false) {
ui_print_error_message(__('It is not possible to change the password because external authentication is being used')); ui_print_error_message(__('It is not possible to change the password because external authentication is being used'));
} else { } else {
$correct_password = false; $correct_password = false;
@ -1581,7 +1581,7 @@ $autorefresh_list_out['operation/events/events'] = 'Events';
if (isset($autorefresh_list) === false || empty($autorefresh_list) === true || empty($autorefresh_list[0]) === true) { if (isset($autorefresh_list) === false || empty($autorefresh_list) === true || empty($autorefresh_list[0]) === true) {
$select = db_process_sql("SELECT autorefresh_white_list FROM tusuario WHERE id_user = '".$id."'"); $select = db_process_sql("SELECT autorefresh_white_list FROM tusuario WHERE id_user = '".$id."'");
$autorefresh_list = json_decode($select[0]['autorefresh_white_list']); $autorefresh_list = json_decode(($select[0]['autorefresh_white_list'] ?? ''));
if ($autorefresh_list === null || $autorefresh_list === 0) { if ($autorefresh_list === null || $autorefresh_list === 0) {
$autorefresh_list = []; $autorefresh_list = [];
$autorefresh_list[0] = __('None'); $autorefresh_list[0] = __('None');

View File

@ -37,6 +37,20 @@ class Applications extends Wizard
*/ */
public $mode; public $mode;
/**
* Task properties.
*
* @var array
*/
public $task;
/**
* Class of styles.
*
* @var string
*/
public $class;
/** /**
* Constructor. * Constructor.

View File

@ -37,6 +37,20 @@ class Custom extends Wizard
*/ */
public $mode; public $mode;
/**
* Task properties.
*
* @var array
*/
public $task;
/**
* Class of styles.
*
* @var string
*/
public $class;
/** /**
* Constructor. * Constructor.

View File

@ -47,6 +47,13 @@ ui_require_javascript_file('simTree');
class DiscoveryTaskList extends HTML class DiscoveryTaskList extends HTML
{ {
/**
* Task properties.
*
* @var array
*/
public $task;
/** /**
* Constructor. * Constructor.

View File

@ -1109,7 +1109,7 @@ class HostDevices extends Wizard
'return' => true, 'return' => true,
'selected' => explode( 'selected' => explode(
',', ',',
$this->task['id_network_profile'] (isset($this->task['id_network_profile']) === true) ? $this->task['id_network_profile'] : ''
), ),
'nothing_value' => 0, 'nothing_value' => 0,
'nothing' => __('None'), 'nothing' => __('None'),

View File

@ -97,6 +97,13 @@ class Wizard
*/ */
public $access = 'AR'; public $access = 'AR';
/**
* Root url.
*
* @var string
*/
public $rootUrl;
/** /**
* Setter for breadcrum * Setter for breadcrum
@ -550,7 +557,7 @@ class Wizard
} }
echo '<ul class="bigbuttonlist">'; echo '<ul class="bigbuttonlist">';
array_map('self::printBigButtonElement', $list_data); array_map(['Wizard', 'printBigButtonElement'], $list_data);
echo '</ul>'; echo '</ul>';
if ($return === true) { if ($return === true) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

View File

@ -2542,15 +2542,12 @@ if ($drawConsoleSound === true) {
$output .= '<div id="progressbar_time"></div>'; $output .= '<div id="progressbar_time"></div>';
$output .= '<div class="buttons-sound-modal">'; $output .= '<div class="buttons-sound-modal">';
$output .= '<div class="container-button-play">'; $output .= '<div class="container-button-play">';
$output .= html_print_input( $output .= html_print_button(
[ __('Start'),
'label' => __('Start'), 'start-search',
'type' => 'button', false,
'name' => 'start-search', '',
'attributes' => [ 'class' => 'play secondary' ], ['icon' => 'play'],
'return' => true,
],
'div',
true true
); );
$output .= '</div>'; $output .= '</div>';

View File

@ -250,6 +250,7 @@ if (is_ajax() === true) {
if ($getInfo === true) { if ($getInfo === true) {
enterprise_include_once('include/functions_agents.php'); enterprise_include_once('include/functions_agents.php');
include_once $config['homedir'].'/include/functions_graph.php';
$id = get_parameter('id', 0); $id = get_parameter('id', 0);
$id_server = get_parameter('id_server', 0); $id_server = get_parameter('id_server', 0);
if (empty($id_server) === false) { if (empty($id_server) === false) {

View File

@ -1875,6 +1875,8 @@ if (check_login()) {
$table_id = get_parameter('table_id', ''); $table_id = get_parameter('table_id', '');
$search = get_parameter('search', ''); $search = get_parameter('search', '');
$search_agent = get_parameter('search_agent', '');
$groupId = (int) get_parameter('groupId', 0);
$module_name = get_parameter('module_name', ''); $module_name = get_parameter('module_name', '');
$status = get_parameter('status', ''); $status = get_parameter('status', '');
$start = get_parameter('start', 0); $start = get_parameter('start', 0);
@ -1886,13 +1888,36 @@ if (check_login()) {
$nodes = get_parameter('nodes', 0); $nodes = get_parameter('nodes', 0);
$disabled_modules = (bool) get_parameter('disabled_modules', false); $disabled_modules = (bool) get_parameter('disabled_modules', false);
$groups_array = [];
if ($groupId === 0) {
if (users_can_manage_group_all('AR') === false) {
$groups_array = users_get_groups(false, 'AR', false);
}
} else {
$groups_array = [$groupId];
}
$where = '1=1'; $where = '1=1';
$recordsTotal = 0; $recordsTotal = 0;
if (empty($groups_array) === false) {
$where .= sprintf(
' AND (tagente.id_grupo IN (%s)
OR tagent_secondary_group.id_group IN(%s))',
implode(',', $groups_array),
implode(',', $groups_array)
);
}
if (empty($search) === false) { if (empty($search) === false) {
$where .= ' AND tagente_modulo.nombre LIKE "%%'.$search.'%%"'; $where .= ' AND tagente_modulo.nombre LIKE "%%'.$search.'%%"';
} }
if (empty($search_agent) === false) {
$where .= ' AND tagente.alias LIKE "%%'.$search_agent.'%%"';
}
if (str_contains($status, '6') === true) { if (str_contains($status, '6') === true) {
$expl = explode(',', $status); $expl = explode(',', $status);
$exist = array_search('6', $expl); $exist = array_search('6', $expl);
@ -1979,6 +2004,8 @@ if (check_login()) {
ON tagente_modulo.id_agente = tagente.id_agente ON tagente_modulo.id_agente = tagente.id_agente
INNER JOIN tagente_estado INNER JOIN tagente_estado
ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
LEFT JOIN tagent_secondary_group
ON tagente.id_agente = tagent_secondary_group.id_agent
WHERE %s WHERE %s
ORDER BY %s ORDER BY %s
LIMIT %d, %d', LIMIT %d, %d',
@ -1996,6 +2023,8 @@ if (check_login()) {
ON tagente_modulo.id_agente = tagente.id_agente ON tagente_modulo.id_agente = tagente.id_agente
INNER JOIN tagente_estado INNER JOIN tagente_estado
ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
LEFT JOIN tagent_secondary_group
ON tagente.id_agente = tagent_secondary_group.id_agent
WHERE %s', WHERE %s',
$where $where
); );
@ -2023,6 +2052,8 @@ if (check_login()) {
ON tagente_modulo.id_agente = tagente.id_agente ON tagente_modulo.id_agente = tagente.id_agente
INNER JOIN tagente_estado INNER JOIN tagente_estado
ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
LEFT JOIN tagent_secondary_group
ON tagente.id_agente = tagent_secondary_group.id_agent
WHERE %s', WHERE %s',
$where $where
); );
@ -2055,6 +2086,8 @@ if (check_login()) {
ON tagente_modulo.id_agente = tagente.id_agente ON tagente_modulo.id_agente = tagente.id_agente
INNER JOIN tagente_estado INNER JOIN tagente_estado
ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
LEFT JOIN tagent_secondary_group
ON tagente.id_agente = tagent_secondary_group.id_agent
WHERE %s', WHERE %s',
$where $where
); );

View File

@ -380,5 +380,7 @@ if (session_status() !== PHP_SESSION_DISABLED) {
// Could give a warning if no session file is created. Ignore. // Could give a warning if no session file is created. Ignore.
@session_destroy(); @session_destroy();
header_remove('Set-Cookie'); header_remove('Set-Cookie');
setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/'); if (isset($_COOKIE[session_name()]) === true) {
setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/');
}
} }

View File

@ -572,10 +572,10 @@ function get_user_info($user)
* *
* @return array An array of user information * @return array An array of user information
*/ */
function get_users($order='fullname', $filter=false, $fields=false) function get_users($order='fullname', $filter=[], $fields=false)
{ {
if (is_array($order) === true) { if (is_array($order) === true) {
$filter['order'] = $order['field'].' '.$order['order']; $filter['order'] = (string) $order['field'].' '.(string) $order['order'];
} else { } else {
if ($order !== 'registered' || $order !== 'last_connect' || $order !== 'fullname') { if ($order !== 'registered' || $order !== 'last_connect' || $order !== 'fullname') {
$order = 'fullname'; $order = 'fullname';

View File

@ -53,6 +53,48 @@ class AuditLog extends HTML
*/ */
private $ajaxController; private $ajaxController;
/**
* TableId
*
* @var integer
*/
public $tableId;
/**
* FilterIp
*
* @var array
*/
public $filterIp;
/**
* FilterPeriod
*
* @var integer
*/
public $filterPeriod;
/**
* FilterText
*
* @var string
*/
public $filterText;
/**
* FilterType
*
* @var string
*/
public $filterType;
/**
* FilterUser
*
* @var string
*/
public $filterUser;
/** /**
* Class constructor * Class constructor

View File

@ -66,6 +66,13 @@ class CalendarManager
*/ */
private $message; private $message;
/**
* Access
*
* @var string
*/
public $access;
/** /**
* Allowed methods to be called using AJAX request. * Allowed methods to be called using AJAX request.
* *

View File

@ -27,6 +27,7 @@
*/ */
use PandoraFMS\Tools\Files; use PandoraFMS\Tools\Files;
use PandoraFMS\Agent;
global $config; global $config;
@ -1214,6 +1215,7 @@ class ConsoleSupervisor
'', '',
$config['num_files_attachment'] $config['num_files_attachment']
); );
if ($filecount > $config['num_files_attachment']) { if ($filecount > $config['num_files_attachment']) {
$this->notify( $this->notify(
[ [
@ -1331,17 +1333,28 @@ class ConsoleSupervisor
$MAX_FILES_DATA_IN = 1000; $MAX_FILES_DATA_IN = 1000;
$MAX_BADXML_FILES_DATA_IN = 150; $MAX_BADXML_FILES_DATA_IN = 150;
$filecount = $this->countFiles( $filecount = 0;
$remote_config_dir,
'', $agentId = db_get_value('id_agente', 'tagente', 'nombre', 'pandora.internals');
$MAX_FILES_DATA_IN if ($agentId !== false) {
); $agent = new Agent($agentId);
$moduleId = $agent->searchModules(
['nombre' => 'Data_in_files'],
1
)->toArray()['id_agente_modulo'];
if ($moduleId > 0) {
$filecount = (int) modules_get_last_value($moduleId);
}
}
// If cannot open directory, count is '-1', skip. // If cannot open directory, count is '-1', skip.
if ($filecount > $MAX_FILES_DATA_IN) { if ($filecount > $MAX_FILES_DATA_IN) {
$this->notify( $this->notify(
[ [
'type' => 'NOTIF.FILES.DATAIN', 'type' => 'NOTIF.FILES.DATAIN',
'title' => __('There are too much files in spool').'.', 'title' => __('There are too many files in spool').'.',
'message' => __( 'message' => __(
'There are more than %d files in %s. Consider checking DataServer performance', 'There are more than %d files in %s. Consider checking DataServer performance',
$MAX_FILES_DATA_IN, $MAX_FILES_DATA_IN,
@ -1671,6 +1684,10 @@ class ConsoleSupervisor
ini_get('upload_max_filesize') ini_get('upload_max_filesize')
); );
$PHPpost_max_size = config_return_in_bytes(
ini_get('post_max_size')
);
// PHP configuration. // PHP configuration.
$PHPmax_input_time = ini_get('max_input_time'); $PHPmax_input_time = ini_get('max_input_time');
$PHPmemory_limit = config_return_in_bytes(ini_get('memory_limit')); $PHPmemory_limit = config_return_in_bytes(ini_get('memory_limit'));
@ -1678,6 +1695,7 @@ class ConsoleSupervisor
$PHPsafe_mode = ini_get('safe_mode'); $PHPsafe_mode = ini_get('safe_mode');
$PHPdisable_functions = ini_get('disable_functions'); $PHPdisable_functions = ini_get('disable_functions');
$PHPupload_max_filesize_min = config_return_in_bytes('800M'); $PHPupload_max_filesize_min = config_return_in_bytes('800M');
$PHPpost_max_size_min = config_return_in_bytes('800M');
$PHPmemory_limit_min = config_return_in_bytes('800M'); $PHPmemory_limit_min = config_return_in_bytes('800M');
$PHPSerialize_precision = ini_get('serialize_precision'); $PHPSerialize_precision = ini_get('serialize_precision');
@ -1728,7 +1746,7 @@ class ConsoleSupervisor
'message' => sprintf( 'message' => sprintf(
__('Recommended value is %s'), __('Recommended value is %s'),
'-1 ('.__('Unlimited').')' '-1 ('.__('Unlimited').')'
).'<br><br>'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Do not forget to restart Apache process after)'), ).'<br>'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Do not forget to restart Apache process after)'),
'url' => $url, 'url' => $url,
'icon_notification' => self::ICON_INFORMATION, 'icon_notification' => self::ICON_INFORMATION,
] ]
@ -1753,7 +1771,7 @@ class ConsoleSupervisor
'message' => sprintf( 'message' => sprintf(
__('Recommended value is: %s'), __('Recommended value is: %s'),
'0 ('.__('Unlimited').')' '0 ('.__('Unlimited').')'
).'<br><br>'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'), ).'<br>'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'),
'url' => $url, 'url' => $url,
'icon_notification' => self::ICON_INFORMATION, 'icon_notification' => self::ICON_INFORMATION,
] ]
@ -1778,7 +1796,7 @@ class ConsoleSupervisor
'message' => sprintf( 'message' => sprintf(
__('Recommended value is: %s'), __('Recommended value is: %s'),
sprintf(__('%s or greater'), '800M') sprintf(__('%s or greater'), '800M')
).'<br><br>'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'), ).'<br>'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'),
'url' => $url, 'url' => $url,
'icon_notification' => self::ICON_INFORMATION, 'icon_notification' => self::ICON_INFORMATION,
] ]
@ -1808,7 +1826,7 @@ class ConsoleSupervisor
'message' => sprintf( 'message' => sprintf(
__('Recommended value is: %s'), __('Recommended value is: %s'),
sprintf(__('%s or greater'), $recommended_memory) sprintf(__('%s or greater'), $recommended_memory)
).'<br><br>'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator'), ).'<br>'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator'),
'url' => $url, 'url' => $url,
'icon_notification' => self::ICON_INFORMATION, 'icon_notification' => self::ICON_INFORMATION,
] ]
@ -1915,6 +1933,25 @@ class ConsoleSupervisor
} else { } else {
$this->cleanNotifications('NOTIF.PHP.VERSION.SUPPORT'); $this->cleanNotifications('NOTIF.PHP.VERSION.SUPPORT');
} }
if ($PHPpost_max_size < $PHPpost_max_size_min && (int) $PHPpost_max_size !== -1) {
$url = 'https://www.php.net/manual/en/ini.core.php#ini.post-max-size';
$this->notify(
[
'type' => 'NOTIF.PHP.POST_MAX_SIZE',
'title' => __('PHP POST MAX SIZE'),
'message' => sprintf(
__('Recommended value is: %s'),
sprintf(__('%sM or greater'), ($PHPpost_max_size_min / 1024 / 1024))
).'<br>'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator'),
'url' => $url,
'icon_notification' => self::ICON_HEADSUP,
]
);
} else {
$this->cleanNotifications('NOTIF.PHP.POST_MAX_SIZE');
}
} }

View File

@ -850,7 +850,7 @@ class CredentialStore extends Wizard
'privilege' => 'AR', 'privilege' => 'AR',
'type' => 'select_groups', 'type' => 'select_groups',
'nothing' => false, 'nothing' => false,
'selected' => (defined($id_group_filter) ? $id_group_filter : 0), 'selected' => ((isset($id_group_filter) === true) ? $id_group_filter : 0),
'return' => true, 'return' => true,
'size' => '80%', 'size' => '80%',
], ],
@ -1637,7 +1637,7 @@ class CredentialStore extends Wizard
$(".ui-dialog-content").dialog("close"); $(".ui-dialog-content").dialog("close");
$('.info').hide(); $('.info').hide();
cleanupDOM(); cleanupDOM();
dt_keystore.draw(false); window.location.reload();
} else { } else {
$(this).dialog('close'); $(this).dialog('close');
} }

View File

@ -54,6 +54,13 @@ class Diagnostics extends Wizard
*/ */
public $pdf; public $pdf;
/**
* Product name.
*
* @var string
*/
public $product_name;
/** /**
* Constructor. * Constructor.
@ -483,7 +490,7 @@ class Diagnostics extends Wizard
], ],
'isEnterprise' => [ 'isEnterprise' => [
'name' => __('Enterprise installed'), 'name' => __('Enterprise installed'),
'value' => (enterprise_installed()) ? __('true') : __('false'), 'value' => $this->getStatusLicense(),
], ],
'customerKey' => [ 'customerKey' => [
'name' => __('Update Key'), 'name' => __('Update Key'),
@ -505,6 +512,29 @@ class Diagnostics extends Wizard
} }
/**
* Return status of license.
*
* @return string
*/
private function getStatusLicense():string
{
global $config;
if (enterprise_installed() === true) {
if (isset($config['license_mode'])
&& (int) $config['license_mode'] === 1
) {
return __('FREE/TRIAL');
} else {
return __('LICENSED');
}
} else {
return __('OpenSource');
}
}
/** /**
* PHP Status. * PHP Status.
* *
@ -517,23 +547,31 @@ class Diagnostics extends Wizard
$result = [ $result = [
'error' => false, 'error' => false,
'data' => [ 'data' => [
'phpVersion' => [ 'phpVersion' => [
'name' => __('PHP Version'), 'name' => __('PHP Version'),
'value' => phpversion(), 'value' => phpversion(),
], ],
'maxExecutionTime' => [ 'maxExecutionTime' => [
'name' => __('PHP Max execution time'), 'name' => __('PHP Max execution time'),
'value' => ini_get('max_execution_time'), 'value' => ini_get('max_execution_time'),
], ],
'maxInputTime' => [ 'maxInputTime' => [
'name' => __('PHP Max input time'), 'name' => __('PHP Max input time'),
'value' => ini_get('max_input_time'), 'value' => ini_get('max_input_time'),
], ],
'memoryLimit' => [ 'memoryLimit' => [
'name' => __('PHP Memory limit'), 'name' => __('PHP Memory limit'),
'value' => ini_get('memory_limit'), 'value' => ini_get('memory_limit'),
], ],
'sessionLifetime' => [ 'postMaxSize' => [
'name' => __('PHP Post max size'),
'value' => ini_get('post_max_size'),
],
'uploadMaxFilesize' => [
'name' => __('PHP Upload max file size'),
'value' => ini_get('upload_max_filesize'),
],
'sessionLifetime' => [
'name' => __('Session cookie lifetime'), 'name' => __('Session cookie lifetime'),
'value' => ini_get('session.cookie_lifetime'), 'value' => ini_get('session.cookie_lifetime'),
], ],

View File

@ -452,6 +452,7 @@ class ExtensionsDiscovery extends Wizard
*/ */
public function run() public function run()
{ {
ui_require_javascript_file('select2.min');
ui_require_javascript_file('extensions_discovery'); ui_require_javascript_file('extensions_discovery');
$_iniFile = $this->loadIni(); $_iniFile = $this->loadIni();
if ($_iniFile === false) { if ($_iniFile === false) {

View File

@ -38,6 +38,62 @@ require_once $config['homedir'].'/include/class/HTML.class.php';
class ExternalTools extends HTML class ExternalTools extends HTML
{ {
/**
* Origin
*
* @var string
*/
public $origin;
/**
* PathCustomComm
*
* @var string
*/
public $pathCustomComm;
/**
* PathDig
*
* @var string
*/
public $pathDig;
/**
* PathNmap
*
* @var string
*/
public $pathNmap;
/**
* PathPing
*
* @var string
*/
public $pathPing;
/**
* PathSnmpget
*
* @var string
*/
public $pathSnmpget;
/**
* PathTraceroute
*
* @var string
*/
public $pathTraceroute;
/**
* UpdatePaths
*
* @var string
*/
public $updatePaths;
/** /**
* Constructor. * Constructor.

View File

@ -706,7 +706,7 @@ class NetworkMap
*/ */
public function setNodes($nodes) public function setNodes($nodes)
{ {
$this->nodes = $nodes; $this->nodes = (array) $nodes;
} }

View File

@ -52,6 +52,13 @@ class OrderInterpreter extends Wizard
*/ */
public $ajaxController; public $ajaxController;
/**
* Pages menu
*
* @var array
*/
public $pages_menu;
/** /**
* Generates a JSON error. * Generates a JSON error.

View File

@ -67,6 +67,34 @@ class SatelliteAgent extends HTML
*/ */
private $ajaxController; private $ajaxController;
/**
* Satellite_name
*
* @var string
*/
public $satellite_name;
/**
* Satellite_server
*
* @var string
*/
public $satellite_server;
/**
* TableId
*
* @var integer
*/
public $tableId;
/**
* Satellite_config
*
* @var string
*/
public $satellite_config;
/** /**
* Class constructor * Class constructor

View File

@ -1257,8 +1257,8 @@ class WelcomeWindow extends Wizard
draggable: true, draggable: true,
modal: true, modal: true,
close: false, close: false,
height: 375, height: 400,
width: 480, width: 500,
overlay: { overlay: {
opacity: 0.5, opacity: 0.5,
background: "black" background: "black"
@ -1274,7 +1274,7 @@ class WelcomeWindow extends Wizard
draggable: true, draggable: true,
modal: true, modal: true,
close: false, close: false,
height: 265, height: 300,
width: 480, width: 480,
overlay: { overlay: {
opacity: 0.5, opacity: 0.5,

View File

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

View File

@ -875,8 +875,6 @@ function get_parameterBetweenListValues($name, $values, $default)
* *
* @return mixed Whatever was in that parameter, cleaned however * @return mixed Whatever was in that parameter, cleaned however
*/ */
function get_parameter_checkbox($name, $default='') function get_parameter_checkbox($name, $default='')
{ {
$sent = get_parameter($name.'_sent', 0); $sent = get_parameter($name.'_sent', 0);
@ -2002,8 +2000,6 @@ function index_array($array, $index='id', $value='name')
* @param int Id of module type * @param int Id of module type
* @return string Graph type, as used in stat_win.php (Graphs launcher) * @return string Graph type, as used in stat_win.php (Graphs launcher)
*/ */
function return_graphtype($id_module_type) function return_graphtype($id_module_type)
{ {
switch ($id_module_type) { switch ($id_module_type) {
@ -2360,8 +2356,6 @@ function string2image(
* @param string SQL code * @param string SQL code
* @return string SQL code validated (it will return empty if SQL is not ok) * @return string SQL code validated (it will return empty if SQL is not ok)
**/ **/
function check_sql($sql) function check_sql($sql)
{ {
// We remove "*" to avoid things like SELECT * FROM tusuario // We remove "*" to avoid things like SELECT * FROM tusuario
@ -2383,8 +2377,6 @@ function check_sql($sql)
* *
* @return boolean 0 on success exit() on no success * @return boolean 0 on success exit() on no success
*/ */
function check_login($output=true) function check_login($output=true)
{ {
global $config; global $config;
@ -2925,6 +2917,10 @@ function delete_dir($dir)
*/ */
function is_image_data($data) function is_image_data($data)
{ {
if (isset($data) === false) {
return false;
}
return (substr($data, 0, 10) == 'data:image'); return (substr($data, 0, 10) == 'data:image');
} }
@ -2947,7 +2943,7 @@ function is_snapshot_data($data)
*/ */
function is_text_to_black_string($data) function is_text_to_black_string($data)
{ {
if (is_image_data($data)) { if (isset($data) === false || is_image_data($data)) {
return false; return false;
} }

View File

@ -541,7 +541,7 @@ function api_get_groups($thrash1, $thrash2, $other, $returnType, $user_in_db)
} }
function api_get_agent_module_name_last_value($agentName, $moduleName, $other=';', $returnType) function api_get_agent_module_name_last_value($agentName, $moduleName, $other=';', $returnType='string')
{ {
$idAgent = agents_get_agent_id($agentName); $idAgent = agents_get_agent_id($agentName);
@ -558,7 +558,7 @@ function api_get_agent_module_name_last_value($agentName, $moduleName, $other=';
} }
function api_get_agent_module_name_last_value_alias($alias, $moduleName, $other=';', $returnType) function api_get_agent_module_name_last_value_alias($alias, $moduleName, $other=';', $returnType='string')
{ {
$sql = sprintf( $sql = sprintf(
'SELECT tagente_modulo.id_agente_modulo FROM tagente_modulo 'SELECT tagente_modulo.id_agente_modulo FROM tagente_modulo
@ -573,7 +573,7 @@ function api_get_agent_module_name_last_value_alias($alias, $moduleName, $other=
} }
function api_get_module_last_value($idAgentModule, $trash1, $other=';', $returnType) function api_get_module_last_value($idAgentModule, $trash1, $other=';', $returnType='string')
{ {
global $config; global $config;
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
@ -3258,8 +3258,6 @@ function api_get_group_agent_by_alias($thrash1, $thrash2, $other, $thrash3)
* *
* @param $thrash3 Don't use. * @param $thrash3 Don't use.
*/ */
function api_get_locate_agent($id, $thrash1, $thrash2, $thrash3) function api_get_locate_agent($id, $thrash1, $thrash2, $thrash3)
{ {
if (!is_metaconsole()) { if (!is_metaconsole()) {
@ -3685,6 +3683,7 @@ function api_set_create_network_module($id, $thrash1, $other, $thrash3)
'warning_inverse' => $other['data'][29], 'warning_inverse' => $other['data'][29],
'ff_type' => $other['data'][30], 'ff_type' => $other['data'][30],
'ignore_unknown' => $other['data'][32], 'ignore_unknown' => $other['data'][32],
'warning_time' => $other['data'][33],
]; ];
if (! $values['descripcion']) { if (! $values['descripcion']) {
@ -3850,6 +3849,7 @@ function api_set_update_network_module($id_module, $thrash1, $other, $thrash3)
'policy_linked', 'policy_linked',
'ff_type', 'ff_type',
'ignore_unknown', 'ignore_unknown',
'warning_time',
]; ];
$values = []; $values = [];
@ -3964,6 +3964,7 @@ function api_set_create_plugin_module($id, $thrash1, $other, $thrash3)
'warning_inverse' => $other['data'][34], 'warning_inverse' => $other['data'][34],
'ff_type' => $other['data'][35], 'ff_type' => $other['data'][35],
'ignore_unknown' => $other['data'][37], 'ignore_unknown' => $other['data'][37],
'warning_time' => $other['data'][38],
]; ];
$plugin = db_get_row('tplugin', 'id', $values['id_plugin']); $plugin = db_get_row('tplugin', 'id', $values['id_plugin']);
@ -4126,6 +4127,7 @@ function api_set_update_plugin_module($id_module, $thrash1, $other, $thrash3)
'policy_linked', 'policy_linked',
'ff_type', 'ff_type',
'ignore_unknown', 'ignore_unknown',
'warning_time',
]; ];
$values = []; $values = [];
@ -4253,6 +4255,7 @@ function api_set_create_data_module($id, $thrash1, $other, $thrash3)
'warning_inverse' => $other['data'][25], 'warning_inverse' => $other['data'][25],
'ff_type' => $other['data'][26], 'ff_type' => $other['data'][26],
'ignore_unknown' => $other['data'][27], 'ignore_unknown' => $other['data'][27],
'warning_time' => $other['data'][28],
]; ];
if (! $values['descripcion']) { if (! $values['descripcion']) {
@ -4776,6 +4779,7 @@ function api_set_update_data_module($id_module, $thrash1, $other, $thrash3)
'policy_linked', 'policy_linked',
'ff_type', 'ff_type',
'ignore_unknown', 'ignore_unknown',
'warning_time',
]; ];
$values = []; $values = [];
@ -4917,6 +4921,7 @@ function api_set_create_snmp_module($id, $thrash1, $other, $thrash3)
'min_ff_event_critical' => $other['data'][33], 'min_ff_event_critical' => $other['data'][33],
'ff_type' => $other['data'][34], 'ff_type' => $other['data'][34],
'ignore_unknown' => $other['data'][36], 'ignore_unknown' => $other['data'][36],
'warning_time' => $other['data'][37],
]; ];
} else { } else {
$values = [ $values = [
@ -4950,6 +4955,7 @@ function api_set_create_snmp_module($id, $thrash1, $other, $thrash3)
'min_ff_event_critical' => $other['data'][27], 'min_ff_event_critical' => $other['data'][27],
'ff_type' => $other['data'][28], 'ff_type' => $other['data'][28],
'ignore_unknown' => $other['data'][29], 'ignore_unknown' => $other['data'][29],
'warning_time' => $other['data'][30],
]; ];
} }
@ -5119,6 +5125,7 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3)
'policy_linked', 'policy_linked',
'ff_type', 'ff_type',
'ignore_unknown', 'ignore_unknown',
'warning_time',
]; ];
} else { } else {
$snmp_module_fields = [ $snmp_module_fields = [
@ -5152,6 +5159,7 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3)
'policy_linked', 'policy_linked',
'ff_type', 'ff_type',
'ignore_unknown', 'ignore_unknown',
'warning_time',
]; ];
} }
@ -7273,8 +7281,6 @@ function api_set_tag($id, $thrash1, $other, $thrash3)
* *
* @param type of return json or csv. * @param type of return json or csv.
*/ */
function api_get_all_planned_downtimes($thrash1, $thrash2, $other, $returnType='json') function api_get_all_planned_downtimes($thrash1, $thrash2, $other, $returnType='json')
{ {
global $config; global $config;
@ -7337,8 +7343,6 @@ function api_get_all_planned_downtimes($thrash1, $thrash2, $other, $returnType='
* *
* @param type of return json or csv. * @param type of return json or csv.
*/ */
function api_get_planned_downtimes_items($thrash1, $thrash2, $other, $returnType='json') function api_get_planned_downtimes_items($thrash1, $thrash2, $other, $returnType='json')
{ {
global $config; global $config;
@ -7430,8 +7434,6 @@ function api_get_planned_downtimes_items($thrash1, $thrash2, $other, $returnType
* *
* @param type of return json or csv. * @param type of return json or csv.
*/ */
function api_set_planned_downtimes_deleted($id, $thrash1, $thrash2, $returnType) function api_set_planned_downtimes_deleted($id, $thrash1, $thrash2, $returnType)
{ {
global $config; global $config;
@ -8000,6 +8002,7 @@ function api_set_update_data_module_policy($id, $thrash1, $other, $thrash3)
'disabled_types_event', 'disabled_types_event',
'module_macros', 'module_macros',
'ignore_unknown', 'ignore_unknown',
'warning_time',
]; ];
$cont = 0; $cont = 0;
@ -8242,6 +8245,7 @@ function api_set_update_network_module_policy($id, $thrash1, $other, $thrash3)
'disabled_types_event', 'disabled_types_event',
'module_macros', 'module_macros',
'ignore_unknown', 'ignore_unknown',
'warning_time',
]; ];
$cont = 0; $cont = 0;
@ -8486,6 +8490,7 @@ function api_set_update_plugin_module_policy($id, $thrash1, $other, $thrash3)
'macros', 'macros',
'module_macros', 'module_macros',
'ignore_unknown', 'ignore_unknown',
'warning_time',
]; ];
$cont = 0; $cont = 0;
@ -8969,6 +8974,7 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3)
'plugin_user', 'plugin_user',
'plugin_pass', 'plugin_pass',
'ignore_unknown', 'ignore_unknown',
'warning_time',
]; ];
} else { } else {
$fields_snmp_module = [ $fields_snmp_module = [
@ -8994,6 +9000,7 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3)
'custom_id', 'custom_id',
'description', 'description',
'ignore_unknown', 'ignore_unknown',
'warning_time',
]; ];
} }
@ -12101,8 +12108,6 @@ function api_set_disable_module($agent_name, $module_name, $other, $thrash4)
* @param $thrash3 Don't use. * @param $thrash3 Don't use.
* @param $thrash4 Don't use. * @param $thrash4 Don't use.
*/ */
function api_set_enable_module($agent_name, $module_name, $other, $thrash4) function api_set_enable_module($agent_name, $module_name, $other, $thrash4)
{ {
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
@ -12169,8 +12174,6 @@ function api_set_enable_module($agent_name, $module_name, $other, $thrash4)
// http://localhost/pandora_console/include/api.php?op=set&op2=disable_alert&id=c2cea5860613e363e25f4ba185b54fe28f869ff8a5e8bb46343288337c903531&id2=Status&other=Warning%20condition // http://localhost/pandora_console/include/api.php?op=set&op2=disable_alert&id=c2cea5860613e363e25f4ba185b54fe28f869ff8a5e8bb46343288337c903531&id2=Status&other=Warning%20condition
*/ */
function api_set_disable_alert($agent_name, $module_name, $template_name, $thrash4) function api_set_disable_alert($agent_name, $module_name, $template_name, $thrash4)
{ {
global $config; global $config;
@ -12216,8 +12219,6 @@ function api_set_disable_alert($agent_name, $module_name, $template_name, $thras
// http://localhost/pandora_console/include/api.php?op=set&op2=disable_alert_alias&id=garfio&id2=Status&other=Warning%20condition // http://localhost/pandora_console/include/api.php?op=set&op2=disable_alert_alias&id=garfio&id2=Status&other=Warning%20condition
*/ */
function api_set_disable_alert_alias($agent_alias, $module_name, $template_name, $thrash4) function api_set_disable_alert_alias($agent_alias, $module_name, $template_name, $thrash4)
{ {
global $config; global $config;
@ -12269,8 +12270,6 @@ function api_set_disable_alert_alias($agent_alias, $module_name, $template_name,
// http://localhost/pandora_console/include/api.php?op=set&op2=enable_alert&id=garfio&id2=Status&other=Warning%20condition // http://localhost/pandora_console/include/api.php?op=set&op2=enable_alert&id=garfio&id2=Status&other=Warning%20condition
*/ */
function api_set_enable_alert($agent_name, $module_name, $template_name, $thrash4) function api_set_enable_alert($agent_name, $module_name, $template_name, $thrash4)
{ {
global $config; global $config;
@ -12316,8 +12315,6 @@ function api_set_enable_alert($agent_name, $module_name, $template_name, $thrash
// http://localhost/pandora_console/include/api.php?op=set&op2=enable_alert_alias&id=garfio&id2=Status&other=Warning%20condition // http://localhost/pandora_console/include/api.php?op=set&op2=enable_alert_alias&id=garfio&id2=Status&other=Warning%20condition
*/ */
function api_set_enable_alert_alias($agent_alias, $module_name, $template_name, $thrash4) function api_set_enable_alert_alias($agent_alias, $module_name, $template_name, $thrash4)
{ {
global $config; global $config;
@ -12369,8 +12366,6 @@ function api_set_enable_alert_alias($agent_alias, $module_name, $template_name,
// http://localhost/pandora_console/include/api.php?op=set&op2=disable_module_alerts&id=garfio&id2=Status // http://localhost/pandora_console/include/api.php?op=set&op2=disable_module_alerts&id=garfio&id2=Status
*/ */
function api_set_disable_module_alerts($agent_name, $module_name, $other, $thrash4) function api_set_disable_module_alerts($agent_name, $module_name, $other, $thrash4)
{ {
global $config; global $config;
@ -12449,8 +12444,6 @@ function api_set_disable_module_alerts($agent_name, $module_name, $other, $thras
* @param $thrash4 Don't use. * @param $thrash4 Don't use.
* // http://localhost/pandora_console/include/api.php?op=set&op2=enable_module_alerts&id=garfio&id2=Status * // http://localhost/pandora_console/include/api.php?op=set&op2=enable_module_alerts&id=garfio&id2=Status
*/ */
function api_set_enable_module_alerts($agent_name, $module_name, $other, $thrash4) function api_set_enable_module_alerts($agent_name, $module_name, $other, $thrash4)
{ {
global $config; global $config;
@ -13184,7 +13177,7 @@ function api_set_create_event($id, $trash1, $other, $returnType)
if ($other['data'][21] != '') { if ($other['data'][21] != '') {
$values['event_custom_id'] = $other['data'][21]; $values['event_custom_id'] = $other['data'][21];
}else{ } else {
$values['event_custom_id'] = ''; $values['event_custom_id'] = '';
} }
@ -13613,8 +13606,6 @@ function api_get_pandora_servers($trash1, $trash2, $other, $returnType)
* *
* @param $thrash3 Don't use. * @param $thrash3 Don't use.
*/ */
function api_set_enable_disable_agent($id, $thrash2, $other, $thrash3) function api_set_enable_disable_agent($id, $thrash2, $other, $thrash3)
{ {
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
@ -13699,8 +13690,6 @@ function api_set_enable_disable_agent($id, $thrash2, $other, $thrash3)
* *
* TODO: Add support to events. * TODO: Add support to events.
*/ */
function api_set_pagerduty_webhook($type, $matchup_path, $tresh2, $return_type) function api_set_pagerduty_webhook($type, $matchup_path, $tresh2, $return_type)
{ {
global $config; global $config;
@ -16808,8 +16797,6 @@ function api_set_reset_agent_counts($id, $thrash1, $thrash2, $thrash3)
* api.php?op=get&op2=list_all_user&return_type=json&apipass=1234&user=admin&pass=pandora * api.php?op=get&op2=list_all_user&return_type=json&apipass=1234&user=admin&pass=pandora
* @return * @return
*/ */
function api_get_list_all_user($thrash1, $thrash2, $other, $returnType) function api_get_list_all_user($thrash1, $thrash2, $other, $returnType)
{ {
global $config; global $config;
@ -16884,8 +16871,6 @@ function api_get_list_all_user($thrash1, $thrash2, $other, $returnType)
* *
* @return * @return
*/ */
function api_get_info_user_name($thrash1, $thrash2, $other, $returnType) function api_get_info_user_name($thrash1, $thrash2, $other, $returnType)
{ {
global $config; global $config;
@ -16960,8 +16945,6 @@ function api_get_info_user_name($thrash1, $thrash2, $other, $returnType)
* *
* @return * @return
*/ */
function api_get_filter_user_group($thrash1, $thrash2, $other, $returnType) function api_get_filter_user_group($thrash1, $thrash2, $other, $returnType)
{ {
global $config; global $config;
@ -17046,8 +17029,6 @@ function api_get_filter_user_group($thrash1, $thrash2, $other, $returnType)
* *
* @return void * @return void
*/ */
function api_set_delete_user_permission($thrash1, $thrash2, $other, $returnType) function api_set_delete_user_permission($thrash1, $thrash2, $other, $returnType)
{ {
global $config; global $config;
@ -17105,8 +17086,6 @@ function api_set_delete_user_permission($thrash1, $thrash2, $other, $returnType)
* *
* @return void * @return void
*/ */
function api_set_add_permission_user_to_group($thrash1, $thrash2, $other, $returnType) function api_set_add_permission_user_to_group($thrash1, $thrash2, $other, $returnType)
{ {
global $config; global $config;

View File

@ -6468,10 +6468,10 @@ function event_print_graph(
$color[] = '#82b92f'; $color[] = '#82b92f';
} }
} else { } else {
$interval_length = 0;
if ($num_intervals > 0) { if ($num_intervals > 0) {
$interval_length = (int) ($period / $num_intervals); $interval_length = (int) ($period / $num_intervals);
} else {
$interval_length = 0;
} }
$intervals = []; $intervals = [];

View File

@ -440,7 +440,7 @@ function extensions_add_operation_menu_option($name, $fatherId=null, $icon=null,
$option_menu['acl'] = $acl; $option_menu['acl'] = $acl;
$extension = &$config['extensions'][$extension_file]; $extension = &$config['extensions'][$extension_file];
$option_menu['sec2'] = $extension['dir'].'/'.mb_substr($extension_file, 0, -4); $option_menu['sec2'] = $extension['dir'].'/'.mb_substr(($extension_file ?? ''), 0, -4);
$option_menu['fatherId'] = $fatherId; $option_menu['fatherId'] = $fatherId;
$option_menu['subfatherId'] = $subfatherId; $option_menu['subfatherId'] = $subfatherId;
$option_menu['icon'] = $icon; $option_menu['icon'] = $icon;

View File

@ -100,7 +100,7 @@ function forecast_projection_graph(
$data[0] = ''; $data[0] = '';
$data[1] = $cont; $data[1] = $cont;
$data[2] = date($config['date_format'], $row[0]); $data[2] = date($config['date_format'], (int) $row[0]);
$data[3] = $row[0]; $data[3] = $row[0];
$data[4] = $row[1]; $data[4] = $row[1];
$data[5] = ($row[0] * $row[1]); $data[5] = ($row[0] * $row[1]);

View File

@ -183,8 +183,6 @@ function html_f2str($function, $params)
* *
* @return string HTML code if return parameter is true. * @return string HTML code if return parameter is true.
*/ */
function html_print_side_layer($params) function html_print_side_layer($params)
{ {
global $config; global $config;
@ -4592,8 +4590,6 @@ function html_print_checkbox_switch_extended(
* *
* @return string HTML code if return parameter is true. * @return string HTML code if return parameter is true.
*/ */
function html_print_checkbox_switch($name, $value, $checked=false, $return=false, $disabled=false, $script='', $disabled_hidden=false, $class='') function html_print_checkbox_switch($name, $value, $checked=false, $return=false, $disabled=false, $script='', $disabled_hidden=false, $class='')
{ {
$output = html_print_checkbox_switch_extended($name, $value, (bool) $checked, $disabled, $script, '', true, '', $class); $output = html_print_checkbox_switch_extended($name, $value, (bool) $checked, $disabled, $script, '', true, '', $class);
@ -7695,3 +7691,52 @@ function html_print_wizard_diagnosis(
echo $output; echo $output;
} }
} }
/**
* Print the modal window for the summary of each alerts group
*
* @param string $id Id.
*
* @return void
*/
function print_email_test_modal_window($id)
{
// Email config table.
$table_mail_test = new stdClass();
$table_mail_test->width = '100%';
$table_mail_test->class = 'filter-table-adv';
$table_mail_test->data = [];
$table_mail_test->data[0][] = html_print_label_input_block(
__('Address'),
html_print_input_text(
'email_test_address',
'',
'',
35,
100,
true
)
);
$table_mail_test->data[1][] = '&nbsp&nbsp<span id="email_test_sent_message" class="invisible"><b>Email sent</b></span><span id="email_test_failure_message" class=invisible"><b>Email could not be sent</b></span>';
// $table_mail_test->colspan[2][0] = 2;
$submitButton = html_print_div(
[
'class' => 'action-buttons-right-forced',
'content' => html_print_button(
__('Send'),
'email_test',
false,
'perform_email_test()',
[
'icon' => 'cog',
'mode' => 'mini',
],
true
),
],
true
);
echo '<div id="email_test_'.$id.'" title="'.__('Check mail configuration').'" class="invisible">'.html_print_table($table_mail_test, true).$submitButton.'</div>';
}

View File

@ -82,11 +82,11 @@ function io_safe_input($value)
return $value; return $value;
} }
if (! mb_check_encoding($value, 'UTF-8')) { if (isset($value) === true && !mb_check_encoding($value, 'UTF-8')) {
$value = utf8_encode($value); $value = utf8_encode($value);
} }
$valueHtmlEncode = htmlentities($value, ENT_QUOTES, 'UTF-8', true); $valueHtmlEncode = htmlentities(($value ?? ''), ENT_QUOTES, 'UTF-8', true);
// Replace the character '\' for the equivalent html entitie // Replace the character '\' for the equivalent html entitie
$valueHtmlEncode = str_replace('\\', '&#92;', $valueHtmlEncode); $valueHtmlEncode = str_replace('\\', '&#92;', $valueHtmlEncode);
@ -561,10 +561,8 @@ function io_output_password($password, $wrappedBy='')
] ]
); );
$output = ($plaintext === ENTERPRISE_NOT_HOOK) ? $password : $plaintext;
// If password already decrypt return same password. // If password already decrypt return same password.
$output = (empty($plaintext) === true) ? $password : $plaintext; $output = (empty($plaintext) === true || $plaintext === ENTERPRISE_NOT_HOOK) ? $password : $plaintext;
return sprintf( return sprintf(
'%s%s%s', '%s%s%s',

View File

@ -155,6 +155,8 @@ function menu_print_menu(&$menu)
} }
} else if ($sec2 === 'godmode/users/configure_user') { } else if ($sec2 === 'godmode/users/configure_user') {
$sec2 = 'godmode/users/user_list'; $sec2 = 'godmode/users/user_list';
} else if ($sec2 === 'godmode/modules/manage_inventory_modules_form') {
$sec2 = 'godmode/modules/manage_inventory_modules';
} else if ($sec2 === 'godmode/groups/configure_group') { } else if ($sec2 === 'godmode/groups/configure_group') {
$sec2 = 'godmode/groups/group_list'; $sec2 = 'godmode/groups/group_list';
} else if ($sec2 === 'godmode/users/configure_profile') { } else if ($sec2 === 'godmode/users/configure_profile') {
@ -1228,6 +1230,22 @@ if (is_ajax()) {
<p style="font-size: 10pt;">'.$php_sys->data->memoryLimit->value.'</p> <p style="font-size: 10pt;">'.$php_sys->data->memoryLimit->value.'</p>
</th> </th>
</tr> </tr>
<tr>
<th style="width: 35%;">
<p><span>'.$php_sys->data->postMaxSize->name.'</span></p>
</th>
<th style="width: 65%;">
<p style="font-size: 10pt;">'.$php_sys->data->postMaxSize->value.'</p>
</th>
</tr>
<tr>
<th style="width: 35%;">
<p><span>'.$php_sys->data->uploadMaxFilesize->name.'</span></p>
</th>
<th style="width: 65%;">
<p style="font-size: 10pt;">'.$php_sys->data->uploadMaxFilesize->value.'</p>
</th>
</tr>
<tr> <tr>
<th style="width: 35%;"> <th style="width: 35%;">
<p><span>'.$php_sys->data->sessionLifetime->name.'</span></p> <p><span>'.$php_sys->data->sessionLifetime->name.'</span></p>

View File

@ -328,12 +328,13 @@ function netflow_data_table($data, $start_date, $end_date, $aggregate, $pdf=fals
/** /**
* Show a table with netflow top N data. * Show a table with netflow top N data.
* *
* @param array $data Netflow data. * @param array $data Netflow data.
* @param integer $total_bytes Total bytes count to calculate percent data. * @param integer $total_bytes Total bytes count to calculate percent data.
* @param boolean $show_extended Display extended table.
* *
* @return string HTML data table. * @return string HTML data table.
*/ */
function netflow_top_n_table(array $data, int $total_bytes) function netflow_top_n_table(array $data, int $total_bytes, bool $show_extended=false)
{ {
global $nfdump_date_format; global $nfdump_date_format;
@ -344,31 +345,44 @@ function netflow_top_n_table(array $data, int $total_bytes)
$table->data = []; $table->data = [];
$table->head = []; $table->head = [];
$table->head[0] = '<b>'.__('Source IP').'</b>'; if ($show_extended === false) {
$table->head[1] = '<b>'.__('Destination IP').'</b>'; $table->head[0] = '<b>'.__('Source IP').'</b>';
$table->head[2] = '<b>'.__('Bytes').'</b>'; $table->head[1] = '<b>'.__('Destination IP').'</b>';
$table->head[3] = '<b>'.__('% Traffic').'</b>'; $table->head[2] = '<b>'.__('Bytes').'</b>';
$table->head[4] = '<b>'.__('Avg. Throughput').'</b>'; $table->head[3] = '<b>'.__('Packets').'</b>';
$table->style[0] = 'padding: 4px'; $table->head[4] = '<b>'.__('% Traffic').'</b>';
$table->head[5] = '<b>'.__('Avg. Throughput').'</b>';
$table->style[0] = 'padding: 4px';
} else {
$table->head[0] = '<b>'.__('Source IP').'</b>';
$table->head[1] = '<b>'.__('Destination IP').'</b>';
$table->head[2] = '<b>'.__('Ingress bytes').'</b>';
$table->head[3] = '<b>'.__('Egress bytes').'</b>';
$table->head[4] = '<b>'.__('Ingress packets').'</b>';
$table->head[5] = '<b>'.__('Egress packets').'</b>';
$table->head[6] = '<b>'.__('% Traffic').'</b>';
$table->head[7] = '<b>'.__('Avg. Throughput').'</b>';
$table->style[0] = 'padding: 4px';
}
$i = 0; $i = 0;
foreach ($data as $value) { foreach ($data as $value) {
$table->data[$i][0] = $value['ip_src']; $table->data[$i][0] = $value['ip_src'];
$table->data[$i][1] = $value['ip_dst']; $table->data[$i][1] = $value['ip_dst'];
$table->data[$i][2] = network_format_bytes($value['bytes']);
$traffic = '-'; if ($show_extended === true) {
$table->data[$i][2] = network_format_bytes($value['ibytes']);
if ($total_bytes > 0) { $table->data[$i][3] = network_format_bytes($value['obytes']);
$traffic = sprintf( $table->data[$i][4] = (empty($value['ipackages']) === true) ? 0 : $value['ipackages'];
'%.2f', $table->data[$i][5] = (empty($value['opackages']) === true) ? 0 : $value['opackages'];
(($value['bytes'] / $total_bytes) * 100) $table->data[$i][6] = $value['traffic'].' %';
); } else {
$table->data[$i][2] = network_format_bytes($value['bytes']);
$table->data[$i][3] = (empty($value['ipackages']) === true) ? 0 : $value['ipackages'];
$table->data[$i][4] = $value['traffic'].' %';
} }
$table->data[$i][3] = $traffic.' %';
$units = [ $units = [
'bps', 'bps',
'Kbps', 'Kbps',
@ -382,7 +396,11 @@ function netflow_top_n_table(array $data, int $total_bytes)
$value['bps'] /= pow(1024, $pow); $value['bps'] /= pow(1024, $pow);
$table->data[$i][4] = round($value['bps'], 2).' '.$units[$pow]; if ($show_extended === true) {
$table->data[$i][7] = round($value['bps'], 2).' '.$units[$pow];
} else {
$table->data[$i][5] = round($value['bps'], 2).' '.$units[$pow];
}
$i++; $i++;
} }
@ -481,7 +499,9 @@ function netflow_get_top_N(
string $end_date, string $end_date,
array $filter, array $filter,
int $max, int $max,
string $connection_name='' string $connection_name='',
bool $extended_info=false,
int $total_bytes=0
) { ) {
global $nfdump_date_format; global $nfdump_date_format;
@ -496,7 +516,8 @@ function netflow_get_top_N(
return json_decode($data, true); return json_decode($data, true);
} }
$options = '-o "fmt:%sap,%dap,%ibyt,%bps" -q -n '.$max.' -s record/bytes -t '.date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); $opts = ($extended_info === true) ? 'fmt:%sap,%dap,%ibyt,%obyt,%ipkt,%opkt,%bps' : 'fmt:%sap,%dap,%ibyt,%ipkt,%bps';
$options = '-o "'.$opts.'" -q -n '.$max.' -s record/bytes -t '.date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date);
$command = netflow_get_command($options, $filter, $start_date, $end_date); $command = netflow_get_command($options, $filter, $start_date, $end_date);
@ -516,8 +537,29 @@ function netflow_get_top_N(
$values[$i]['ip_src'] = $parsed_line[0]; $values[$i]['ip_src'] = $parsed_line[0];
$values[$i]['ip_dst'] = $parsed_line[1]; $values[$i]['ip_dst'] = $parsed_line[1];
$values[$i]['bytes'] = $parsed_line[2];
$values[$i]['bps'] = $parsed_line[3]; $traffic = '-';
if ($total_bytes > 0) {
$conn_bytes = $parsed_line[2];
$traffic = sprintf(
'%.2f',
(($conn_bytes / $total_bytes) * 100)
);
}
$values[$i]['traffic'] = $traffic;
if ($extended_info === true) {
$values[$i]['ibytes'] = $parsed_line[2];
$values[$i]['obytes'] = $parsed_line[3];
$values[$i]['ipackets'] = $parsed_line[4];
$values[$i]['opackets'] = $parsed_line[5];
$values[$i]['bps'] = $parsed_line[6];
} else {
$values[$i]['bytes'] = $parsed_line[2];
$values[$i]['bps'] = $parsed_line[3];
}
$i++; $i++;
} }
@ -1341,7 +1383,11 @@ function netflow_draw_item(
$output='HTML', $output='HTML',
$address_resolution=false, $address_resolution=false,
$width_content=false, $width_content=false,
$height_content=false $height_content=false,
$extended=false,
$show_graph=true,
$show_summary=true,
$show_table=true
) { ) {
$aggregate = $filter['aggregate']; $aggregate = $filter['aggregate'];
$interval = ($end_date - $start_date); $interval = ($end_date - $start_date);
@ -1496,7 +1542,9 @@ function netflow_draw_item(
$end_date, $end_date,
$filter, $filter,
$max_aggregates, $max_aggregates,
$connection_name $connection_name,
$extended,
$data_summary['totalbytes']
); );
if (empty($data_top_n) === true) { if (empty($data_top_n) === true) {
@ -1505,16 +1553,76 @@ function netflow_draw_item(
if ($output === 'HTML' || $output === 'PDF') { if ($output === 'HTML' || $output === 'PDF') {
$html = '<table class="w100p">'; $html = '<table class="w100p">';
$html .= '<tr>'; if ($show_graph === true) {
$html .= "<td class='w50p'>"; $labels = array_map(
$html .= netflow_summary_table($data_summary); function ($conn) {
$html .= '</td>'; return __('% Traffic').' '.$conn['ip_src'].' - '.$conn['ip_dst'];
$html .= '</tr>'; },
$html .= '<tr>'; $data_top_n
$html .= "<td class='w100p'>"; );
$html .= netflow_top_n_table($data_top_n, $data_summary['totalbytes']);
$html .= '</td>'; $pie_data = array_map(
$html .= '</tr>'; function ($conn) {
return $conn['traffic'];
},
$data_top_n
);
$graph_output = pie_graph(
$pie_data,
[
'width' => 200,
'height' => 200,
'ttl' => ($output === 'PDF') ? 2 : 1,
'dataLabel' => ['display' => 'auto'],
'layout' => [
'padding' => [
'top' => 15,
'bottom' => 15,
],
],
'legend' => [
'display' => true,
'position' => 'right',
'align' => 'center',
],
'labels' => $labels,
]
);
$html .= '<tr>';
$html .= "<td class='w500p padding-bottom-25px'>";
if ($output === 'PDF') {
$html .= '<img src="data:image/png;base64,'.$graph_output.'" />';
} else {
$html .= $graph_output;
}
$html .= '</td>';
$html .= '</tr>';
}
if ($show_summary === true) {
$html .= '<tr>';
$html .= "<td class='w50p'>";
$html .= netflow_summary_table($data_summary);
$html .= '</td>';
$html .= '</tr>';
}
if ($show_table === true) {
$html .= '<tr>';
$html .= "<td class='w100p'>";
$html .= netflow_top_n_table(
$data_top_n,
$data_summary['totalbytes'],
$extended
);
$html .= '</td>';
$html .= '</tr>';
}
$html .= '</table>'; $html .= '</table>';
return $html; return $html;
@ -1638,7 +1746,8 @@ function netflow_get_item_data(
string $type_netflow, string $type_netflow,
array $filter, array $filter,
int $max_aggregates, int $max_aggregates,
string $connection_name string $connection_name,
bool $extended=false
) { ) {
$data = []; $data = [];
@ -1656,7 +1765,9 @@ function netflow_get_item_data(
$end_date, $end_date,
$filter, $filter,
$max_aggregates, $max_aggregates,
$connection_name $connection_name,
$extended,
$data_summary['totalbytes']
); );
$data = [ $data = [
@ -2293,3 +2404,50 @@ function netflow_build_map_data($start_date, $end_date, $top, $aggregate, $advan
array_merge($relations, $orphan_hosts) array_merge($relations, $orphan_hosts)
); );
} }
/**
* Run whois command and return all results as array.
*
* @param integer $ip Ip for search info with command whois.
*
* @return array
*/
function command_whois($ip)
{
$command = 'whois '.$ip;
$result = '';
exec($command, $result);
if (empty($result) === false && is_array($result) === true) {
$resultArray = parse_whois_output($result);
} else {
$resultArray = [];
}
return $resultArray;
}
/**
* Parse the result of command whois to array.
*
* @param array $lines Lines result of command whois.
*
* @return array
*/
function parse_whois_output($lines)
{
$resultArray = [];
if (is_array($lines) === true) {
foreach ($lines as $line) {
$parts = explode(':', $line, 2);
if (count($parts) === 2 && strpos($line, '#') !== 0) {
$key = trim($parts[0]);
$value = trim($parts[1]);
$resultArray[$key] = $value;
}
}
}
return $resultArray;
}

View File

@ -133,6 +133,7 @@ function notifications_get_subtypes(?string $source=null)
'NOTIF.PHP.INPUT_TIME', 'NOTIF.PHP.INPUT_TIME',
'NOTIF.PHP.EXECUTION_TIME', 'NOTIF.PHP.EXECUTION_TIME',
'NOTIF.PHP.UPLOAD_MAX_FILESIZE', 'NOTIF.PHP.UPLOAD_MAX_FILESIZE',
'NOTIF.PHP.POST_MAX_SIZE',
'NOTIF.PHP.MEMORY_LIMIT', 'NOTIF.PHP.MEMORY_LIMIT',
'NOTIF.PHP.DISABLE_FUNCTIONS', 'NOTIF.PHP.DISABLE_FUNCTIONS',
'NOTIF.PHP.CHROMIUM', 'NOTIF.PHP.CHROMIUM',
@ -818,7 +819,7 @@ function notifications_print_global_source_configuration($source)
$html_checkboxes = ''; $html_checkboxes = '';
$blacklist = json_decode($source['subtype_blacklist'], 1); $blacklist = json_decode(($source['subtype_blacklist'] ?? ''), 1);
if (json_last_error() !== JSON_ERROR_NONE) { if (json_last_error() !== JSON_ERROR_NONE) {
$blacklist = []; $blacklist = [];
} }

View File

@ -243,6 +243,7 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c
$profile = json_decode($profile); $profile = json_decode($profile);
} }
$result = [];
$result[] = [ $result[] = [
'id_grupo' => $profile->group, 'id_grupo' => $profile->group,
'id_perfil' => $profile->profile, 'id_perfil' => $profile->profile,

View File

@ -6981,6 +6981,20 @@ function reporting_netflow(
$filter['aggregate'] = 'dstport'; $filter['aggregate'] = 'dstport';
} }
$es = json_decode($content['external_source'], true);
$extended = false;
$show_graph = false;
$show_summary = false;
$show_table = false;
if (empty($es) === false) {
$extended = ((int) $es['top_n_type'] === 1);
$show_graph = ((int) $es['display_graph'] === 1);
$show_summary = ((int) $es['display_summary'] === 1);
$show_table = ((int) $es['display_data_table'] === 1);
}
switch ($type) { switch ($type) {
case 'dinamic': case 'dinamic':
case 'static': case 'static':
@ -6992,7 +7006,14 @@ function reporting_netflow(
$filter, $filter,
$content['top_n_value'], $content['top_n_value'],
$content['server_name'], $content['server_name'],
(($pdf === true) ? 'PDF' : 'HTML') (($pdf === true) ? 'PDF' : 'HTML'),
false,
false,
false,
$extended,
$show_graph,
$show_summary,
$show_table
); );
break; break;
@ -7015,11 +7036,15 @@ function reporting_netflow(
break; break;
} }
$return['subtitle'] = netflow_generate_subtitle_report( if ($extended === true) {
$filter['aggregate'], $return['subtitle'] = __('InBound/Outbound traffic per SrcIP/DestIP');
$content['top_n'], } else {
$type_netflow $return['subtitle'] = netflow_generate_subtitle_report(
); $filter['aggregate'],
$content['top_n'],
$type_netflow
);
}
return reporting_check_structure_content($return); return reporting_check_structure_content($return);
} }

View File

@ -1039,7 +1039,7 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false)
echo " echo "
<script> <script>
function sendHash(url) { function sendHash(url) {
window.open(url+'&loginhash=auto&loginhash_data=".$hashdata.'&loginhash_user='.str_rot13($user)."', '_blank'); window.open(url+'&loginhash=auto&loginhash_data=".$hashdata.'&loginhash_user='.str_rot13(($user ?? ''))."', '_blank');
} }

View File

@ -148,7 +148,7 @@ function ui_print_truncate_text(
$text_html_decoded = io_safe_output($text); $text_html_decoded = io_safe_output($text);
$text_has_entities = $text != $text_html_decoded; $text_has_entities = $text != $text_html_decoded;
if (mb_strlen($text_html_decoded, 'UTF-8') > ($numChars)) { if (isset($text_html_decoded) === true && mb_strlen($text_html_decoded, 'UTF-8') > ($numChars)) {
// '/2' because [...] is in the middle of the word. // '/2' because [...] is in the middle of the word.
$half_length = intval(($numChars - 3) / 2); $half_length = intval(($numChars - 3) / 2);
@ -969,15 +969,27 @@ function ui_print_os_icon(
$options['title'] = $os_name; $options['title'] = $os_name;
} }
$output = html_print_image( if ($icon === '.png') {
'images/'.$subfolder.'/'.$icon, $output = html_print_image(
true, 'images/os@svg.svg',
$options, true,
false, $options,
$relative, false,
$no_in_meta, $relative,
true $no_in_meta,
); true
);
} else {
$output = html_print_image(
'images/'.$subfolder.'/'.$icon,
true,
$options,
false,
$relative,
$no_in_meta,
true
);
}
} }
} else { } else {
// $output = "<img src='images/os_icons/" . $icon . "' alt='" . $os_name . "' title='" . $os_name . "'>"; // $output = "<img src='images/os_icons/" . $icon . "' alt='" . $os_name . "' title='" . $os_name . "'>";
@ -4257,15 +4269,15 @@ function ui_print_datatable(array $parameters)
// * END JAVASCRIPT. // * END JAVASCRIPT.
$info_msg_arr = []; $info_msg_arr = [];
$info_msg_arr['message'] = $emptyTable; $info_msg_arr['message'] = $emptyTable;
$info_msg_arr['div_class'] = 'info_box_container invisible_important datatable-msg-info-'.$table_id; $info_msg_arr['div_class'] = 'info_box_container invisible_important datatable-info-massage datatable-msg-info-'.$table_id;
$info_msg_arr_filter = []; $info_msg_arr_filter = [];
$info_msg_arr_filter['message'] = __('Please apply a filter to display the data.'); $info_msg_arr_filter['message'] = __('Please apply a filter to display the data.');
$info_msg_arr_filter['div_class'] = 'info_box_container invisible_important datatable-msg-info-filter-'.$table_id; $info_msg_arr_filter['div_class'] = 'info_box_container invisible_important datatable-info-massage datatable-msg-info-filter-'.$table_id;
$spinner = '<div id="'.$table_id.'-spinner" class="invisible spinner-fixed"><span></span><span></span><span></span><span></span></div>'; $spinner = '<div id="'.$table_id.'-spinner" class="invisible spinner-fixed"><span></span><span></span><span></span><span></span></div>';
$info_msg = '<div>'.ui_print_info_message($info_msg_arr, '', true).'</div>'; $info_msg = '<div class="datatable-container-info-massage">'.ui_print_info_message($info_msg_arr, '', true).'</div>';
$info_msg_filter = '<div>'.ui_print_info_message($info_msg_arr_filter, true).'</div>'; $info_msg_filter = '<div>'.ui_print_info_message($info_msg_arr_filter, true).'</div>';

View File

@ -98,25 +98,6 @@ function update_manager_get_current_package()
} }
/**
* Check if a trial license is in use.
*
* @return boolean true if a trial license is in use, false otherwise.
*/
function update_manager_verify_trial()
{
global $config;
if (isset($config['license_licensed_to'])
&& strstr($config['license_licensed_to'], 'info@pandorafms.com') !== false
) {
return true;
}
return false;
}
/** /**
* Checks if there are packages available to be installed. * Checks if there are packages available to be installed.
* *

View File

@ -3791,7 +3791,7 @@ function visual_map_get_user_layouts(
$retval = []; $retval = [];
foreach ($layouts as $layout) { foreach ($layouts as $layout) {
if ($only_names) { if ($only_names) {
$retval[$layout['id']] = $layout['name']; $retval[$layout['id']] = io_safe_output($layout['name']);
} else { } else {
$retval[$layout['id']] = $layout; $retval[$layout['id']] = $layout;
} }

View File

@ -301,6 +301,13 @@ function gd_progress_bubble($width, $height, $progress, $title, $font, $out_of_l
function ImageRectangleWithRoundedCorners(&$im, $x1, $y1, $x2, $y2, $radius, $color) function ImageRectangleWithRoundedCorners(&$im, $x1, $y1, $x2, $y2, $radius, $color)
{ {
$x1 = (int) $x1;
$y1 = (int) $y1;
$x2 = (int) $x2;
$y2 = (int) $y2;
$radius = (int) $radius;
$color = (int) $color;
// Draw rectangle without corners // Draw rectangle without corners
imagefilledrectangle($im, ($x1 + $radius), $y1, ($x2 - $radius), $y2, $color); imagefilledrectangle($im, ($x1 + $radius), $y1, ($x2 - $radius), $y2, $color);
imagefilledrectangle($im, $x1, ($y1 + $radius), $x2, ($y2 - $radius), $color); imagefilledrectangle($im, $x1, ($y1 + $radius), $x2, ($y2 - $radius), $color);

View File

@ -1,3 +1,5 @@
/* global $ */
var dt = dt; var dt = dt;
var config = config; var config = config;
@ -66,6 +68,11 @@ if (typeof dt.pagination_options !== "undefined") {
lengthMenu = dt.pagination_options; lengthMenu = dt.pagination_options;
} }
if (dt.pagination_options_order === "true") {
lengthMenu[0] = lengthMenu[0].sort((a, b) => a - b);
lengthMenu[1] = lengthMenu[1].sort((a, b) => a - b);
}
var ordering = true; var ordering = true;
if (typeof dt.ordering !== "undefined" && dt.ordering === false) { if (typeof dt.ordering !== "undefined" && dt.ordering === false) {
ordering = dt.ordering; ordering = dt.ordering;
@ -136,6 +143,8 @@ if (dt.no_move_elements_to_action === true) {
noMoveElementsToAction = true; noMoveElementsToAction = true;
} }
var showAlwaysPagination = false;
$(document).ready(function() { $(document).ready(function() {
function checkPages() { function checkPages() {
if (dt_table.page.info().pages > 1) { if (dt_table.page.info().pages > 1) {
@ -248,7 +257,11 @@ $(document).ready(function() {
$("div.pagination-child-div").hide(); $("div.pagination-child-div").hide();
$("div.dataTables_info").hide(); $("div.dataTables_info").hide();
$(`#${dt.id}_wrapper`).hide(); $(`#${dt.id}_wrapper`).hide();
$(`.action_buttons_right_content .pagination-child-div`).hide(); if (showAlwaysPagination) {
$(`.action_buttons_right_content .pagination-child-div`).show();
} else {
$(`.action_buttons_right_content .pagination-child-div`).hide();
}
} else { } else {
$(`.datatable-msg-info-${dt.id}`).hide(); $(`.datatable-msg-info-${dt.id}`).hide();
$(`table#${dt.id}`).show(); $(`table#${dt.id}`).show();
@ -278,6 +291,12 @@ $(document).ready(function() {
$(`#${dt.form_id}_loading`).remove(); $(`#${dt.form_id}_loading`).remove();
} }
if (json.showAlwaysPagination) {
showAlwaysPagination = true;
} else {
showAlwaysPagination = false;
}
if (json.error) { if (json.error) {
console.error(json.error); console.error(json.error);
$(`#error-${dt.id}`).html(json.error); $(`#error-${dt.id}`).html(json.error);

View File

@ -4,7 +4,7 @@ $(document).ready(() => {
$("#_credentials_").select2({ $("#_credentials_").select2({
closeOnSelect: true closeOnSelect: true
}); });
var interval;
if (interval === "0") { if (interval === "0") {
setTimeout(() => { setTimeout(() => {
$("#mode_interval") $("#mode_interval")

View File

@ -2621,3 +2621,60 @@ function christmas_click(flagEasternEgg) {
}, 120000); }, 120000);
} }
} }
function perform_email_test() {
$("#email_test_sent_message").hide();
$("#email_test_failure_message").hide();
var test_address = $("#text-email_test_address").val();
var params = {
email_smtpServer: $("#text-email_smtpServer").val(),
email_smtpPort: $("#text-email_smtpPort").val(),
email_username: $("#text-email_username").val(),
email_password: $("#password-email_password").val(),
email_encryption: $("#email_encryption option:selected").val(),
email_from_dir: $("#text-email_from_dir").val(),
email_from_name: $("#text-email_from_name").val()
};
$.ajax({
type: "POST",
url: "ajax.php",
data: {
page: "godmode/setup/setup_general",
test_address: test_address,
params: params
},
dataType: "json",
success: function(data) {
if (parseInt(data) === 1) {
$("#email_test_sent_message").show();
$("#email_test_failure_message").hide();
} else {
console.log($("#email_test_failure_message"));
$("#email_test_failure_message").show();
$("#email_test_sent_message").hide();
}
},
error: function() {
$("#email_test_failure_message").show();
$("#email_test_sent_message").hide();
}
});
}
function show_email_test(id) {
$("#email_test_sent_message").hide();
$("#email_test_failure_message").hide();
$("#email_test_" + id).dialog({
resizable: true,
draggable: true,
modal: true,
width: 450,
overlay: {
opacity: 0.5,
background: "black"
}
});
}

View File

@ -1261,6 +1261,10 @@ function action_events_sound(mode, settings) {
$("#button-start-search") $("#button-start-search")
.removeClass("play") .removeClass("play")
.addClass("stop"); .addClass("stop");
$("#button-start-search")
.find("div")
.removeClass("play")
.addClass("stop");
// Change value button. // Change value button.
$("#button-start-search").val(settings.stop); $("#button-start-search").val(settings.stop);
$("#button-start-search > span").text(settings.stop); $("#button-start-search > span").text(settings.stop);
@ -1277,6 +1281,10 @@ function action_events_sound(mode, settings) {
$("#button-start-search") $("#button-start-search")
.removeClass("stop") .removeClass("stop")
.addClass("play"); .addClass("play");
$("#button-start-search")
.find("div")
.removeClass("stop")
.addClass("play");
// Change value button. // Change value button.
$("#button-start-search").val(settings.start); $("#button-start-search").val(settings.start);
$("#button-start-search > span").text(settings.start); $("#button-start-search > span").text(settings.start);
@ -1601,9 +1609,7 @@ $(document).ajaxSend(function(event, jqXHR, ajaxOptions) {
// Add the minimize icon to the minimize button // Add the minimize icon to the minimize button
$("<span>", { $("<span>", {
class: "ui-button-icon ui-icon", class: "ui-button-icon ui-icon"
style:
"background-color: rgb(51, 51, 51); -webkit-mask: url('images/arrow-down-white.png') no-repeat / contain !important;"
}).appendTo(minimizeButton); }).appendTo(minimizeButton);
$("<span>", { $("<span>", {
@ -1617,23 +1623,9 @@ $(document).ajaxSend(function(event, jqXHR, ajaxOptions) {
class: class:
"ui-corner-all ui-widget ui-button-icon-only ui-dialog-titlebar-disengage disengage-buttom-image", "ui-corner-all ui-widget ui-button-icon-only ui-dialog-titlebar-disengage disengage-buttom-image",
type: "button", type: "button",
title: "Disengage", title: "Disengage"
style: "float: right; position:relative;"
}).insertBefore(minimizeButton); }).insertBefore(minimizeButton);
// Add the disengage icon to the disengage button
$("<span>", {
class: "ui-button-icon ui-icon",
style:
"background-color: rgb(51, 51, 51); -webkit-mask: url('images/dashboard.menu.png') no-repeat center / contain !important;"
}).appendTo(disengageButton);
$("<span>", {
class: "ui-button-icon-space"
})
.html(" ")
.appendTo(disengageButton);
minimizeButton.click(function(e) { minimizeButton.click(function(e) {
if ($("#minimize_arrow_event_sound").hasClass("arrow_menu_up")) { if ($("#minimize_arrow_event_sound").hasClass("arrow_menu_up")) {
$("#minimize_arrow_event_sound").removeClass("arrow_menu_up"); $("#minimize_arrow_event_sound").removeClass("arrow_menu_up");

View File

@ -82,6 +82,7 @@ function removeInputImage(e) {
} }
} }
function render({ title, text, url, files, method }) { function render({ title, text, url, files, method }) {
var positionButtonsBefore = $(".ui-dialog-buttonset").offset().top;
$("#title_tip").html(title); $("#title_tip").html(title);
$("#text_tip").html(text); $("#text_tip").html(text);
if (url) { if (url) {
@ -123,6 +124,7 @@ function render({ title, text, url, files, method }) {
} }
}); });
activeCarousel(); activeCarousel();
checkPositionButtons(positionButtonsBefore);
} }
function close_dialog() { function close_dialog() {
@ -429,3 +431,20 @@ function validateImages() {
}); });
return validate; return validate;
} }
function checkPositionButtons(positionButtonsBefore) {
// posicion actual botones
var buttonsNow = $(".ui-dialog-buttonset").offset().top;
// Position of dialog
var dialogPosition = $(".dialog_tips").position().top;
var positionFinal;
if (positionButtonsBefore > buttonsNow) {
positionFinal = dialogPosition + (positionButtonsBefore - buttonsNow);
positionFinal = positionFinal < 0 ? "100" : positionFinal;
$(".dialog_tips").css("top", positionFinal);
} else if (positionButtonsBefore < buttonsNow) {
positionFinal = dialogPosition - (buttonsNow - positionButtonsBefore);
positionFinal = positionFinal < 0 ? "100" : positionFinal;
$(".dialog_tips").css("top", positionFinal);
}
}

View File

@ -113,6 +113,13 @@ class ClusterWizard extends \HTML
*/ */
private $agent; private $agent;
/**
* Id of clusters.
*
* @var integer
*/
public $id;
/** /**
* Builds a Cluster Wizard. * Builds a Cluster Wizard.

View File

@ -167,6 +167,20 @@ class Manager implements PublicLogin
*/ */
private $duplicateCellId; private $duplicateCellId;
/**
* Url
*
* @var string
*/
public $url;
/**
* Widget
*
* @var Widget
*/
public $cWidget;
/** /**
* Allowed methods to be called using AJAX request. * Allowed methods to be called using AJAX request.
* *
@ -311,6 +325,15 @@ class Manager implements PublicLogin
if ($this->dashboardId !== 0) { if ($this->dashboardId !== 0) {
$this->dashboardFields = $this->get(); $this->dashboardFields = $this->get();
if ($this->deleteDashboard === false && is_array($this->dashboardFields) === true && count($this->dashboardFields) === 0) {
db_pandora_audit(
AUDIT_LOG_HACK_ATTEMPT,
'Trying to access to dashboard that not exist'
);
include 'general/noaccess.php';
exit;
}
$this->cells = Cell::getCells($this->dashboardId); $this->cells = Cell::getCells($this->dashboardId);
} }

View File

@ -65,6 +65,27 @@ class Widget
*/ */
private $dateTo; private $dateTo;
/**
* Data cell
*
* @var array
*/
public $dataCell;
/**
* Overflow scrollbar.
*
* @var boolean
*/
public $overflow_scrollbars;
/**
* Position
*
* @var array
*/
public $position;
/** /**
* Contructor widget. * Contructor widget.

View File

@ -226,7 +226,7 @@ class AgentHive extends Widget
'name' => 'groups[]', 'name' => 'groups[]',
'returnAllGroup' => false, 'returnAllGroup' => false,
'privilege' => 'AR', 'privilege' => 'AR',
'selected' => explode(',', $values['groups'][0]), 'selected' => (isset($values['groups'][0]) === true) ? explode(',', $values['groups'][0]) : [],
'return' => true, 'return' => true,
'multiple' => true, 'multiple' => true,
'required' => true, 'required' => true,

View File

@ -117,6 +117,13 @@ class DataMatrix extends Widget
*/ */
protected $cellId; protected $cellId;
/**
* Position
*
* @var array
*/
public $size;
/** /**
* Construct. * Construct.

View File

@ -0,0 +1,541 @@
<?php
/**
* Widget agiss map Pandora FMS Console
*
* @category Console Class
* @package Pandora FMS
* @subpackage Widget
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2024 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.
* ============================================================================
*/
namespace PandoraFMS\Dashboard;
use PandoraFMS\Enterprise\Metaconsole\Node;
global $config;
/**
* URL Widgets
*/
class GisMap extends Widget
{
/**
* Name widget.
*
* @var string
*/
protected $name;
/**
* Title widget.
*
* @var string
*/
protected $title;
/**
* Page widget;
*
* @var string
*/
protected $page;
/**
* Class name widget.
*
* @var [type]
*/
protected $className;
/**
* Values options for each widget.
*
* @var [type]
*/
protected $values;
/**
* Configuration required.
*
* @var boolean
*/
protected $configurationRequired;
/**
* Error load widget.
*
* @var boolean
*/
protected $loadError;
/**
* Width.
*
* @var integer
*/
protected $width;
/**
* Heigth.
*
* @var integer
*/
protected $height;
/**
* Grid Width.
*
* @var integer
*/
protected $gridWidth;
/**
* Cell ID.
*
* @var integer
*/
protected $cellId;
/**
* Construct.
*
* @param integer $cellId Cell ID.
* @param integer $dashboardId Dashboard ID.
* @param integer $widgetId Widget ID.
* @param integer|null $width New width.
* @param integer|null $height New height.
* @param integer|null $gridWidth Grid width.
*/
public function __construct(
int $cellId,
int $dashboardId=0,
int $widgetId=0,
?int $width=0,
?int $height=0,
?int $gridWidth=0
) {
global $config;
// WARNING: Do not edit. This chunk must be in the constructor.
parent::__construct(
$cellId,
$dashboardId,
$widgetId
);
// Width.
$this->width = $width;
// Height.
$this->height = $height;
// Grid Width.
$this->gridWidth = $gridWidth;
// Cell Id.
$this->cellId = $cellId;
// Options.
$this->values = $this->decoders($this->getOptionsWidget());
// Page.
$this->page = basename(__FILE__);
// ClassName.
$class = new \ReflectionClass($this);
$this->className = $class->getShortName();
// Title.
$this->title = __('Gis map');
// Name.
if (empty($this->name) === true) {
$this->name = 'GisMap';
}
// This forces at least a first configuration.
$this->configurationRequired = false;
if (empty($this->values['gis_map']) === true) {
$this->configurationRequired = true;
}
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['gis_map']) === true) {
$values['gis_map'] = $decoder['gis_map'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*
* @return array Of inputs.
*
* @throws Exception On error.
*/
public function getFormInputs(): array
{
global $config;
include_once $config['homedir'].'/include/functions_gis.php';
// Retrieve global - common inputs.
$inputs = parent::getFormInputs();
if ((bool) $config['activate_gis'] === true) {
$maps = gis_get_maps();
}
$array_map = [];
foreach ($maps as $map) {
if (check_acl($config['id_user'], $map['group_id'], 'MR') === false
&& check_acl($config['id_user'], $map['group_id'], 'MW') === false
&& check_acl($config['id_user'], $map['group_id'], 'MM') === false
) {
continue;
}
$array_map[$map['id_tgis_map']] = $map['map_name'];
}
// Filters.
$inputs[] = [
'class' => 'flex flex-row',
'label' => __('GIS maps'),
'arguments' => [
'type' => 'select',
'fields' => $array_map,
'name' => 'gis_map',
'return' => true,
'selected' => ($this->values['gis_map'] === null) ? 0 : $this->values['gis_map'],
],
];
return $inputs;
}
/**
* Get Post for widget.
*
* @return array
*/
public function getPost(): array
{
// Retrieve global - common inputs.
$values = parent::getPost();
$values['gis_map'] = \get_parameter('gis_map', 0);
return $values;
}
/**
* Draw widget.
*
* @return string;
*/
public function load()
{
global $config;
include_once $config['homedir'].'/include/functions_gis.php';
include_once $config['homedir'].'/include/functions_agents.php';
\ui_require_javascript_file('openlayers.pandora', 'include/javascript/', true);
\ui_require_javascript_file('OpenLayers/OpenLayers', 'include/javascript/', true);
$map = db_get_row('tgis_map', 'id_tgis_map', $this->values['gis_map']);
$output = '';
if (check_acl($config['id_user'], $map['group_id'], 'MR') === false
&& check_acl($config['id_user'], $map['group_id'], 'MW') === false
&& check_acl($config['id_user'], $map['group_id'], 'MM') === false
) {
$output .= '<div class="container-center">';
$output .= ui_print_error_message(
__('You don\'t have access'),
'',
true
);
$output .= '</div>';
return $output;
}
$confMap = gis_get_map_conf($this->values['gis_map']);
// Default open map (used to overwrite unlicensed google map view).
$confMapDefault = get_good_con();
$confMapDefaultFull = json_decode($confMapDefault['conection_data'], true);
$confMapUrlDefault = $confMapDefaultFull['url'];
$num_baselayer = 0;
// Initialy there is no Gmap base layer.
$gmap_layer = false;
if ($confMap !== false) {
foreach ($confMap as $mapC) {
$baselayers[$num_baselayer]['typeBaseLayer'] = $mapC['connection_type'];
$baselayers[$num_baselayer]['name'] = $mapC['conection_name'];
$baselayers[$num_baselayer]['num_zoom_levels'] = $mapC['num_zoom_levels'];
$decodeJSON = json_decode($mapC['conection_data'], true);
switch ($mapC['connection_type']) {
case 'OSM':
$baselayers[$num_baselayer]['url'] = $decodeJSON['url'];
break;
case 'Gmap':
if (!isset($decodeJSON['gmap_key']) || empty($decodeJSON['gmap_key'])) {
// If there is not gmap_key, show the default view.
$baselayers[$num_baselayer]['url'] = $confMapUrlDefault;
$baselayers[$num_baselayer]['typeBaseLayer'] = 'OSM';
} else {
$baselayers[$num_baselayer]['gmap_type'] = $decodeJSON['gmap_type'];
$baselayers[$num_baselayer]['gmap_key'] = $decodeJSON['gmap_key'];
$gmap_key = $decodeJSON['gmap_key'];
// Once a Gmap base layer is found we mark it to import the API.
$gmap_layer = true;
}
break;
case 'Static_Image':
$baselayers[$num_baselayer]['url'] = $decodeJSON['url'];
$baselayers[$num_baselayer]['bb_left'] = $decodeJSON['bb_left'];
$baselayers[$num_baselayer]['bb_right'] = $decodeJSON['bb_right'];
$baselayers[$num_baselayer]['bb_bottom'] = $decodeJSON['bb_bottom'];
$baselayers[$num_baselayer]['bb_top'] = $decodeJSON['bb_top'];
$baselayers[$num_baselayer]['image_width'] = $decodeJSON['image_width'];
$baselayers[$num_baselayer]['image_height'] = $decodeJSON['image_height'];
break;
case 'WMS':
$baselayers[$num_baselayer]['url'] = $decodeJSON['url'];
$baselayers[$num_baselayer]['layers'] = $decodeJSON['layers'];
break;
default:
// Do nothing.
break;
}
$num_baselayer++;
if ($mapC['default_map_connection'] == 1) {
$numZoomLevels = $mapC['num_zoom_levels'];
}
}
}
if ($gmap_layer === true) {
if (https_is_running()) {
?>
<script type="text/javascript" src="https://maps.google.com/maps?file=api&v=2&sensor=false&key=<?php echo $gmap_key; ?>" ></script>
<?php
} else {
?>
<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=<?php echo $gmap_key; ?>" ></script>
<?php
}
}
$controls = [
'PanZoomBar',
'ScaleLine',
'Navigation',
'MousePosition',
'layerSwitcher',
];
$layers = gis_get_layers($this->values['gis_map']);
$output .= '<div id="map_'.$this->cellId.'" style="width: 100%; height: 100%" />';
gis_print_map(
'map_'.$this->cellId,
$map['zoom_level'],
$map['initial_latitude'],
$map['initial_longitude'],
$baselayers,
$controls
);
$output .= '</div>';
if (empty($layers) === false) {
foreach ($layers as $layer) {
gis_make_layer(
$layer['layer_name'],
$layer['view_layer'],
null,
$layer['id_tmap_layer']
);
// Calling agents_get_group_agents with none to obtain the names in the same case as they are in the DB.
$agentNamesByGroup = [];
if ($layer['tgrupo_id_grupo'] >= 0) {
$agentNamesByGroup = agents_get_group_agents(
$layer['tgrupo_id_grupo'],
false,
'none',
true,
true,
false
);
}
$agentNamesByLayer = gis_get_agents_layer($layer['id_tmap_layer']);
$groupsByAgentId = gis_get_groups_layer_by_agent_id($layer['id_tmap_layer']);
$agentNamesOfGroupItems = [];
foreach ($groupsByAgentId as $agentId => $groupInfo) {
$agentNamesOfGroupItems[$agentId] = $groupInfo['agent_name'];
}
$agentNames = array_unique($agentNamesByGroup + $agentNamesByLayer + $agentNamesOfGroupItems);
foreach ($agentNames as $key => $agentName) {
$idAgent = $key;
$coords = gis_get_data_last_position_agent($idAgent);
if ($coords === false) {
$coords['stored_latitude'] = $map['default_latitude'];
$coords['stored_longitude'] = $map['default_longitude'];
} else {
if ($show_history == 'y') {
$lastPosition = [
'longitude' => $coords['stored_longitude'],
'latitude' => $coords['stored_latitude'],
];
gis_add_path($layer['layer_name'], $idAgent, $lastPosition);
}
}
$status = agents_get_status($idAgent, true);
$icon = gis_get_agent_icon_map($idAgent, true, $status);
$icon_size = getimagesize($icon);
$icon_width = $icon_size[0];
$icon_height = $icon_size[1];
// Is a group item.
if (empty($groupsByAgentId[$idAgent]) === false) {
$groupId = (int) $groupsByAgentId[$idAgent]['id'];
$groupName = $groupsByAgentId[$idAgent]['name'];
gis_add_agent_point(
$layer['layer_name'],
io_safe_output($groupName),
$coords['stored_latitude'],
$coords['stored_longitude'],
$icon,
$icon_width,
$icon_height,
$idAgent,
$status,
'point_group_info',
$groupId
);
} else {
$parent = db_get_value('id_parent', 'tagente', 'id_agente', $idAgent);
gis_add_agent_point(
$layer['layer_name'],
io_safe_output($agentName),
$coords['stored_latitude'],
$coords['stored_longitude'],
$icon,
$icon_width,
$icon_height,
$idAgent,
$status,
'point_agent_info',
$parent
);
}
}
}
gis_add_parent_lines();
$timestampLastOperation = db_get_value_sql('SELECT UNIX_TIMESTAMP()');
gis_activate_select_control();
gis_activate_ajax_refresh($layers, $timestampLastOperation);
}
return $output;
}
/**
* Get description.
*
* @return string.
*/
public static function getDescription()
{
return __('GIS map');
}
/**
* Get Name.
*
* @return string.
*/
public static function getName()
{
return 'GisMap';
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 500,
'height' => 300,
];
return $size;
}
}

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