diff --git a/pandora_agents/pc/AIX/pandora_agent.conf b/pandora_agents/pc/AIX/pandora_agent.conf index f5e67c98ba..0ff67a62d3 100644 --- a/pandora_agents/pc/AIX/pandora_agent.conf +++ b/pandora_agents/pc/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.734, AIX version +# Version 7.0NG.735, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/FreeBSD/pandora_agent.conf b/pandora_agents/pc/FreeBSD/pandora_agent.conf index 74b075e83d..c7c6fdd493 100644 --- a/pandora_agents/pc/FreeBSD/pandora_agent.conf +++ b/pandora_agents/pc/FreeBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.734, FreeBSD Version +# Version 7.0NG.735, FreeBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/HP-UX/pandora_agent.conf b/pandora_agents/pc/HP-UX/pandora_agent.conf index 10d360a51d..1a349583dc 100644 --- a/pandora_agents/pc/HP-UX/pandora_agent.conf +++ b/pandora_agents/pc/HP-UX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.734, HP-UX Version +# Version 7.0NG.735, HP-UX Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/Linux/pandora_agent.conf b/pandora_agents/pc/Linux/pandora_agent.conf index 9ad57d9a9d..dc172b7e2f 100644 --- a/pandora_agents/pc/Linux/pandora_agent.conf +++ b/pandora_agents/pc/Linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.734, GNU/Linux +# Version 7.0NG.735, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/NT4/pandora_agent.conf b/pandora_agents/pc/NT4/pandora_agent.conf index 360efd4d9b..3d76832397 100644 --- a/pandora_agents/pc/NT4/pandora_agent.conf +++ b/pandora_agents/pc/NT4/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.734, GNU/Linux +# Version 7.0NG.735, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/SunOS/pandora_agent.conf b/pandora_agents/pc/SunOS/pandora_agent.conf index f0a8d0c0ef..9b088eae51 100644 --- a/pandora_agents/pc/SunOS/pandora_agent.conf +++ b/pandora_agents/pc/SunOS/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.734, Solaris Version +# Version 7.0NG.735, Solaris Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/Win32/pandora_agent.conf b/pandora_agents/pc/Win32/pandora_agent.conf index d01ed9068f..e2c442a520 100644 --- a/pandora_agents/pc/Win32/pandora_agent.conf +++ b/pandora_agents/pc/Win32/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent # (c) 2006-2010 Artica Soluciones Tecnologicas -# Version 7.0NG.734 +# Version 7.0NG.735 # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software diff --git a/pandora_agents/shellscript/aix/pandora_agent.conf b/pandora_agents/shellscript/aix/pandora_agent.conf index 0e0546261d..fea0cb56db 100644 --- a/pandora_agents/shellscript/aix/pandora_agent.conf +++ b/pandora_agents/shellscript/aix/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.734, AIX version +# Version 7.0NG.735, AIX version # General Parameters # ================== diff --git a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf index a941a9671e..f0ce5b2519 100644 --- a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf +++ b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.734 +# Version 7.0NG.735 # FreeBSD/IPSO version # Licenced under GPL licence, 2003-2007 Sancho Lerena diff --git a/pandora_agents/shellscript/hp-ux/pandora_agent.conf b/pandora_agents/shellscript/hp-ux/pandora_agent.conf index 779ef59e37..20cdfeff99 100644 --- a/pandora_agents/shellscript/hp-ux/pandora_agent.conf +++ b/pandora_agents/shellscript/hp-ux/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.734, HPUX Version +# Version 7.0NG.735, HPUX Version # General Parameters # ================== diff --git a/pandora_agents/shellscript/linux/pandora_agent.conf b/pandora_agents/shellscript/linux/pandora_agent.conf index 07869dd19b..e8ba9653ce 100644 --- a/pandora_agents/shellscript/linux/pandora_agent.conf +++ b/pandora_agents/shellscript/linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.734 +# Version 7.0NG.735 # Licensed under GPL license v2, # (c) 2003-2010 Artica Soluciones Tecnologicas # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/mac_osx/pandora_agent.conf b/pandora_agents/shellscript/mac_osx/pandora_agent.conf index 0d1a1928c3..29d13ff75c 100644 --- a/pandora_agents/shellscript/mac_osx/pandora_agent.conf +++ b/pandora_agents/shellscript/mac_osx/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.734 +# Version 7.0NG.735 # Licensed under GPL license v2, # (c) 2003-2009 Artica Soluciones Tecnologicas # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/openWRT/pandora_agent.conf b/pandora_agents/shellscript/openWRT/pandora_agent.conf index 2eb1b43e76..8ef8a6fdc1 100644 --- a/pandora_agents/shellscript/openWRT/pandora_agent.conf +++ b/pandora_agents/shellscript/openWRT/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.734 +# Version 7.0NG.735 # Licensed under GPL license v2, # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/solaris/pandora_agent.conf b/pandora_agents/shellscript/solaris/pandora_agent.conf index 2928f1d320..1ace947818 100644 --- a/pandora_agents/shellscript/solaris/pandora_agent.conf +++ b/pandora_agents/shellscript/solaris/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.734, Solaris version +# Version 7.0NG.735, Solaris version # General Parameters # ================== diff --git a/pandora_agents/unix/AIX/pandora_agent.conf b/pandora_agents/unix/AIX/pandora_agent.conf index 7c363219a1..c67f64d16c 100644 --- a/pandora_agents/unix/AIX/pandora_agent.conf +++ b/pandora_agents/unix/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.734, AIX version +# Version 7.0NG.735, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 3c6d461c7e..df1ed8c960 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.734-190522 +Version: 7.0NG.735-190621 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 76ca8f9320..5290897e5b 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.734-190522" +pandora_version="7.0NG.735-190621" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/Darwin/pandora_agent.conf b/pandora_agents/unix/Darwin/pandora_agent.conf index 5c5ebf5808..d7ee481255 100644 --- a/pandora_agents/unix/Darwin/pandora_agent.conf +++ b/pandora_agents/unix/Darwin/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.734, GNU/Linux +# Version 7.0NG.735, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2012 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/FreeBSD/pandora_agent.conf b/pandora_agents/unix/FreeBSD/pandora_agent.conf index 5fc956c564..b02b379470 100644 --- a/pandora_agents/unix/FreeBSD/pandora_agent.conf +++ b/pandora_agents/unix/FreeBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.734, FreeBSD Version +# Version 7.0NG.735, FreeBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2016 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/HP-UX/pandora_agent.conf b/pandora_agents/unix/HP-UX/pandora_agent.conf index b5bce38619..57e35c0a03 100644 --- a/pandora_agents/unix/HP-UX/pandora_agent.conf +++ b/pandora_agents/unix/HP-UX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.734, HP-UX Version +# Version 7.0NG.735, HP-UX Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/Linux/pandora_agent.conf b/pandora_agents/unix/Linux/pandora_agent.conf index f0e610c8a3..db07876f12 100644 --- a/pandora_agents/unix/Linux/pandora_agent.conf +++ b/pandora_agents/unix/Linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.734, GNU/Linux +# Version 7.0NG.735, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2014 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/NT4/pandora_agent.conf b/pandora_agents/unix/NT4/pandora_agent.conf index 6599a01803..8cda0f8fe0 100644 --- a/pandora_agents/unix/NT4/pandora_agent.conf +++ b/pandora_agents/unix/NT4/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.734, GNU/Linux +# Version 7.0NG.735, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/NetBSD/pandora_agent.conf b/pandora_agents/unix/NetBSD/pandora_agent.conf index a9cd29af83..629fe6a6fb 100644 --- a/pandora_agents/unix/NetBSD/pandora_agent.conf +++ b/pandora_agents/unix/NetBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.734, NetBSD Version +# Version 7.0NG.735, NetBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/SunOS/pandora_agent.conf b/pandora_agents/unix/SunOS/pandora_agent.conf index 8b1151bbad..8ff3c52de5 100644 --- a/pandora_agents/unix/SunOS/pandora_agent.conf +++ b/pandora_agents/unix/SunOS/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.734, Solaris Version +# Version 7.0NG.735, Solaris Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 5fec85e4a4..bb13d57ee6 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -41,8 +41,8 @@ my $Sem = undef; # Semaphore used to control the number of threads my $ThreadSem = undef; -use constant AGENT_VERSION => '7.0NG.734'; -use constant AGENT_BUILD => '190522'; +use constant AGENT_VERSION => '7.0NG.735'; +use constant AGENT_BUILD => '190621'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; @@ -536,6 +536,12 @@ sub parse_conf_modules($) { # Check for invalid modules next unless (($module->{'name'} ne '' && $module->{'func'} != 0) || $module->{'func'} == \&module_plugin); + # Skip disabled modules. + if (defined($module->{'disabled'}) && $module->{'disabled'} == 1) { + log_message('setup', 'Skipping disabled module "' . $module->{'name'} . '"'); + next; + } + # Set the intensive interval if ($module->{'is_intensive'} == 1) { $module->{'intensive_interval'} = $module->{'interval'}; @@ -3032,10 +3038,10 @@ while (1) { my @address_list; if( -x "/bin/ip" || -x "/sbin/ip" || -x "/usr/sbin/ip" ) { - @address_list = `ip addr show 2>$DevNull | sed -e '/127.0.0/d' -e '/[0-9]*\\.[0-9]*\\.[0-9]*/!d' -e 's/^[ \\t]*\\([^ \\t]*\\)[ \\t]*\\([^ \\t]*\\)[ \\t].*/\\2/' -e 's/\\/.*//'`; + @address_list = `ip addr show 2>$DevNull | sed -e '/127.0.0/d' -e '/\\([0-9][0-9]*\\.\\)\\{3\\}[0-9][0-9]*/!d' -e 's/^[ \\t]*\\([^ \\t]*\\)[ \\t]*\\([^ \\t]*\\)[ \\t].*/\\2/' -e 's/\\/.*//'`; } else { - @address_list = `ifconfig -a 2>$DevNull | sed -e '/127.0.0/d' -e '/[0-9]*\\.[0-9]*\\.[0-9]*/!d' -e 's/^[ \\t]*\\([^ \\t]*\\)[ \\t]*\\([^ \\t]*\\)[ \\t].*/\\2/' -e 's/.*://'`; + @address_list = `ifconfig -a 2>$DevNull | sed -e '/127.0.0/d' -e '/\\([0-9][0-9]*\\.\\)\\{3\\}[0-9][0-9]*/!d' -e 's/^[ \\t]*\\([^ \\t]*\\)[ \\t]*\\([^ \\t]*\\)[ \\t].*/\\2/' -e 's/.*://'`; } for (my $i = 0; $i <= $#address_list; $i++) { diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index fd0b680941..c606d1d811 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -2,8 +2,8 @@ #Pandora FMS Linux Agent # %define name pandorafms_agent_unix -%define version 7.0NG.734 -%define release 190522 +%define version 7.0NG.735 +%define release 190621 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 46955219c0..fca14e0a1c 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -2,8 +2,8 @@ #Pandora FMS Linux Agent # %define name pandorafms_agent_unix -%define version 7.0NG.734 -%define release 190522 +%define version 7.0NG.735 +%define release 190621 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 77f8a5e5c8..67e49267c6 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -9,8 +9,8 @@ # Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license. # ********************************************************************** -PI_VERSION="7.0NG.734" -PI_BUILD="190522" +PI_VERSION="7.0NG.735" +PI_BUILD="190621" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/unix/plugins/grep_log b/pandora_agents/unix/plugins/grep_log index 2e17210a51..76661c5230 100755 --- a/pandora_agents/unix/plugins/grep_log +++ b/pandora_agents/unix/plugins/grep_log @@ -6,17 +6,17 @@ # # grep_log Perl script to search log files for a matching pattern. The last # searched position is saved in an index file so that consecutive -# runs do not return the same results. The log file inode number is +# runs do not return the same results. The log file inode number is # also saved to detect log rotation. # # 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; version 2 of the License. -# +# # 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. +# GNU General Public License for more details. # ############################################################################### use strict; @@ -30,7 +30,7 @@ my $Output = 'module'; my $Verbose = 0; # Index file storage directory, with a trailing '/' -my $Idx_dir=($^O =~ /win/i)?'.\\':'/tmp/'; +my $Idx_dir=($^O =~ /win/i)?"$ENV{'TMP'}\\":"/tmp/"; # Log file my $Log_file = ''; @@ -64,7 +64,7 @@ if ( (defined ($ENV{GREP_LOG_TMP})) && (-d $ENV{GREP_LOG_TMP}) ) { } ######################################################################################## -# Erase blank spaces before and after the string +# Erase blank spaces before and after the string ######################################################################################## sub trim($){ my $string = shift; @@ -226,7 +226,7 @@ sub parse_log (;$$) { open(LOGFILE, $Log_file) || error_msg("Error opening file $Log_file: " . $!); - # Go to starting position. + # Go to starting position. seek(LOGFILE, $Idx_pos, 0); # Parse log file @@ -318,7 +318,7 @@ sub print_log ($) { print_summary() if ($summary_flag == 1); return; } - + # Log module if ($Output eq 'log_module') { my $output = "\n"; diff --git a/pandora_agents/win32/bin/pandora_agent.conf b/pandora_agents/win32/bin/pandora_agent.conf index 0f6d503674..518cd3df0e 100644 --- a/pandora_agents/win32/bin/pandora_agent.conf +++ b/pandora_agents/win32/bin/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent # (c) 2006-2017 Artica Soluciones Tecnologicas -# Version 7.0NG.734 +# Version 7.0NG.735 # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software diff --git a/pandora_agents/win32/bin/util/grep_log.exe b/pandora_agents/win32/bin/util/grep_log.exe index a21e080805..4e4029fb60 100644 Binary files a/pandora_agents/win32/bin/util/grep_log.exe and b/pandora_agents/win32/bin/util/grep_log.exe differ diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index c2b3f74d3f..cb4764278a 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -3,7 +3,7 @@ AllowLanguageSelection {Yes} AppName -{Pandora FMS Windows Agent v7.0NG.734} +{Pandora FMS Windows Agent v7.0NG.735} ApplicationID {17E3D2CF-CA02-406B-8A80-9D31C17BD08F} @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{190522} +{190621} ViewReadme {Yes} diff --git a/pandora_agents/win32/modules/pandora_module_factory.cc b/pandora_agents/win32/modules/pandora_module_factory.cc index b05422f104..a4d9553c20 100644 --- a/pandora_agents/win32/modules/pandora_module_factory.cc +++ b/pandora_agents/win32/modules/pandora_module_factory.cc @@ -1117,6 +1117,12 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { } } + /* Skip disabled modules */ + if (module_disabled == "1") { + pandoraLog ("Skipping disabled module \"%s\"", module_name.c_str ()); + return NULL; + } + /* Create module objects */ if (module_exec != "") { module = new Pandora_Module_Exec (module_name, diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index af1332aae6..9ca3c1b610 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.734(Build 190522)") +#define PANDORA_VERSION ("7.0NG.735(Build 190621)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 25debe882f..febb797e2a 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.734(Build 190522))" + VALUE "ProductVersion", "(7.0NG.735(Build 190621))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 8b58838a96..d5f32de2f0 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.734-190522 +Version: 7.0NG.735-190621 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index b0a4a89713..2563c3de9a 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.734-190522" +pandora_version="7.0NG.735-190621" package_pear=0 package_pandora=1 diff --git a/pandora_console/extensions/agents_alerts.php b/pandora_console/extensions/agents_alerts.php index 18a6fdd0bf..54e0ec6b12 100755 --- a/pandora_console/extensions/agents_alerts.php +++ b/pandora_console/extensions/agents_alerts.php @@ -298,7 +298,7 @@ function mainAgentsAlerts() $table2->data[2][0] = __('Threshold'); $table2->data[2][1] = html_print_input_text('module_action_threshold', '0', '', 5, 7, true); - $table2->data[2][1] .= ' '.__('seconds').ui_print_help_icon('action_threshold', true); + $table2->data[2][1] .= ' '.__('seconds'); $content2 = '
'; $content2 .= html_print_table($table2, true); diff --git a/pandora_console/extensions/agents_modules.php b/pandora_console/extensions/agents_modules.php index b5860068d8..97657f5189 100644 --- a/pandora_console/extensions/agents_modules.php +++ b/pandora_console/extensions/agents_modules.php @@ -1,23 +1,24 @@ '.__('Group').''; $filter_groups = html_print_select_groups(false, 'AR', true, 'group_id', $group_id, '', '', '', true, false, true, '', false, 'width: auto;'); $filter_recursion_label = ''.__('Recursion').''; $filter_recursion = html_print_checkbox('recursion', 1, 0, true); - // groups module + // Groups module. $filter_module_groups_label = ''.__('Module group').''; $filter_module_groups = html_print_select_from_sql( 'SELECT * FROM tmodule_group ORDER BY name', @@ -146,7 +147,7 @@ function mainAgentsModules() 'width: auto;' ); - // agent + // Agent. $agents = agents_get_group_agents($group_id); if ((empty($agents)) || $agents == -1) { $agents = []; @@ -155,7 +156,7 @@ function mainAgentsModules() $filter_agents_label = ''.__('Agents').''; $filter_agents = html_print_select($agents, 'id_agents2[]', $agents_id, '', '', 0, true, true, true, '', false, 'min-width: 180px; max-width: 200px;'); - // type show + // Type show. $selection = [ 0 => __('Show common modules'), 1 => __('Show all modules'), @@ -163,12 +164,12 @@ function mainAgentsModules() $filter_type_show_label = ''.__('Show common modules').''; $filter_type_show = html_print_select($selection, 'selection_agent_module', $selection_a_m, '', '', 0, true, false, true, '', false, 'min-width: 180px;'); - // modules + // Modules. $all_modules = select_modules_for_agent_group($group_id, $agents_id, $selection_a_m, false); $filter_modules_label = ''.__('Module').''; $filter_modules = html_print_select($all_modules, 'module[]', $modules_selected, '', '', 0, true, true, false, '', false, 'min-width: 180px; max-width: 200px;'); - // update + // Update. $filter_update = html_print_submit_button(__('Update item'), 'edit_item', false, 'class="sub upd"', true); $onheader = [ @@ -178,8 +179,11 @@ function mainAgentsModules() 'combo_groups' => $filter_groups, ]; - // Old style table, we need a lot of special formatting,don't use table function - // Prepare old-style table + /* + * Old style table, we need a lot of special formatting,don't use table function. + * Prepare old-style table. + */ + if ($config['pure'] == 0) { // Header. ui_print_page_header( @@ -200,38 +204,51 @@ function mainAgentsModules() $full_modules = urlencode(implode(';', $full_modules_selected)); $full_agents = urlencode(implode(';', $full_agents_id)); - $url = " index.php?sec=view&sec2=extensions/agents_modules&pure=0&offset=$offset + $url = 'index.php?sec=view&sec2=extensions/agents_modules&pure=0&offset=$offset &group_id=$group_id&modulegroup=$modulegroup&refresh=$refr&full_modules_selected=$full_modules - &full_agents_id=$full_agents&selection_agent_module=$selection_a_m"; + &full_agents_id=$full_agents&selection_agent_module=$selection_a_m'; } else { - $url = " index.php?sec=view&sec2=extensions/agents_modules&pure=0&offset=$offset&group_id=$group_id&modulegroup=$modulegroup&refresh=$refr"; + $url = 'index.php?sec=view&sec2=extensions/agents_modules&pure=0&offset=$offset&group_id=$group_id&modulegroup=$modulegroup&refresh=$refr'; } - // Floating menu - Start + // Floating menu - Start. echo '
'; echo ''; echo '
'; - // Floating menu - End + // Floating menu - End. ui_require_jquery_file('countdown'); } if ($config['pure'] != 1) { - echo ''; - - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo "'; - echo ''; - echo '
'.$filter_groups_label.''.$filter_groups.'   '.$filter_recursion_label.$filter_recursion.''.$filter_module_groups_label.''.$filter_module_groups.'
'.$filter_agents_label.''.$filter_agents.''.$filter_type_show_label.''.$filter_type_show.''.$filter_modules_label.''.$filter_modules.'
".$filter_update.'
'; - echo '
'; + $show_filters = '
'; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= "'; + $show_filters .= ''; + $show_filters .= '
'.$filter_groups_label.''.$filter_groups.'   '.$filter_recursion_label.$filter_recursion.''.$filter_module_groups_label.''.$filter_module_groups.'
'.$filter_agents_label.''.$filter_agents.''.$filter_type_show_label.''.$filter_type_show.''.$filter_modules_label.''.$filter_modules.'
".$filter_update.'
'; + $show_filters .= '
'; + ui_toggle($show_filters, __('Filters')); } if ($agents_id[0] != -1) { @@ -291,7 +308,7 @@ function mainAgentsModules() $count = 0; foreach ($agents as $agent) { - // TODO TAGS agents_get_modules + // TODO TAGS agents_get_modules. $module = agents_get_modules( $agent, false, @@ -339,7 +356,7 @@ function mainAgentsModules() } } } else { - // TODO TAGS agents_get_modules + // TODO TAGS agents_get_modules. $all_modules = agents_get_modules( $agents, false, @@ -414,11 +431,11 @@ function mainAgentsModules() if ($hor_offset > 0) { $new_hor_offset = ($hor_offset - $block); - echo ""."".html_print_image( - 'images/arrow_left.png', + echo "".html_print_image( + 'images/arrow_left_green.png', true, ['title' => __('Previous modules')] - ).''.''; + ).''; } $nmodules = 0; @@ -440,11 +457,11 @@ function mainAgentsModules() if (($hor_offset + $block) < $nmodules) { $new_hor_offset = ($hor_offset + $block); - echo ""."".html_print_image( - 'images/arrow.png', + echo "".html_print_image( + 'images/arrow_right_green.png', true, ['title' => __('More modules')] - ).''.''; + ).''; } echo ''; @@ -457,12 +474,12 @@ function mainAgentsModules() $filter_agents['id_grupo'] = $group_id; } - // Prepare pagination - $url = 'index.php?extension_in_menu=estado&sec=extensions&sec2=extensions/agents_modules&save_serialize=1&'.'hor_offset='.$hor_offset.'&selection_a_m='.$selection_a_m; + // Prepare pagination. + $url = 'index.php?extension_in_menu=estado&sec=extensions&sec2=extensions/agents_modules&save_serialize=1&hor_offset='.$hor_offset.'&selection_a_m='.$selection_a_m; ui_pagination($total_pagination, $url); foreach ($agents as $agent) { - // Get stats for this group + // Get stats for this group. $agent_status = agents_get_status($agent['id_agente']); $alias = db_get_row('tagente', 'id_agente', $agent['id_agente']); if (empty($alias['alias'])) { @@ -471,29 +488,29 @@ function mainAgentsModules() switch ($agent_status) { case 4: - // Alert fired status + // Alert fired status. $rowcolor = 'group_view_alrm'; break; case 1: - // Critical status + // Critical status. $rowcolor = 'group_view_crit'; break; case 2: - // Warning status + // Warning status. $rowcolor = 'group_view_warn'; break; case 0: - // Normal status + // Normal status. $rowcolor = 'group_view_ok'; break; case 3: case -1: default: - // Unknown status + // Unknown status. $rowcolor = 'group_view_unk'; break; } @@ -502,7 +519,7 @@ function mainAgentsModules() echo " ".$alias['alias'].''; - // TODO TAGS agents_get_modules + // TODO TAGS agents_get_modules. $agent_modules = agents_get_modules($agent['id_agente'], false, $filter_module_group, true, true); $nmodules = 0; @@ -572,18 +589,23 @@ function mainAgentsModules() echo ''; - echo "
"; + $show_legend = "
"; + $show_legend .= "
+
".__('Orange cell when the module has fired alerts').'
'; + $show_legend .= "
+
".__('Red cell when the module has a critical status').' +
'; + $show_legend .= "
+
".__('Yellow cell when the module has a warning status').'
'; + $show_legend .= "
+
".__('Green cell when the module has a normal status').'
'; + $show_legend .= "
+
".__('Grey cell when the module has an unknown status').'
'; + $show_legend .= "
+
".__("Cell turns blue when the module is in 'not initialize' status").'
'; + $show_legend .= '
'; + ui_toggle($show_legend, __('Legend')); - echo ''; - echo "'; - echo "'; - echo "'; - echo "'; - echo "'; - echo "'; - echo "'; - echo '
".__('Legend').'
".__('Orange cell when the module has fired alerts').'
".__('Red cell when the module has a critical status').'
".__('Yellow cell when the module has a warning status').'
".__('Green cell when the module has a normal status').'
".__('Grey cell when the module has an unknown status').'
".__("Cell turns blue when the module is in 'not initialize' status").'
'; - echo '
'; $pure_var = $config['pure']; if ($pure_var) { $pure_var = 1; @@ -627,16 +649,14 @@ $ignored_params['refresh'] = ''; $.each($('.th_class_module_r'), function (i, elem) { id = $(elem).attr('id').replace('th_module_r_', ''); $("#th_module_r_" + id).height(($("#div_module_r_" + id).width() + 10) + 'px'); - - //$("#div_module_r_" + id).css('margin-top', (max_width - $("#div_module_r_" + id).width()) + 'px'); $("#div_module_r_" + id).css('margin-top', (max_width - 20) + 'px'); $("#div_module_r_" + id).show(); }); - var refr =" . $refr . "; - var pure =" . $pure_var . "; - var href ='" . ui_get_url_refresh ($ignored_params) . "'; - + var refr = ''; + var pure = ''; + var href =' '; + if (pure) { var startCountDown = function (duration, cb) { $('div.vc-countdown').countdown('destroy'); @@ -646,7 +666,7 @@ $ignored_params['refresh'] = ''; $('div.vc-countdown').countdown({ until: t, format: 'MS', - layout: '(%M%nn%M:%S%nn%S Until refresh)', + layout: '(%M%nn%M:%S%nn%S ) ', alwaysExpire: true, onExpiry: function () { $('div.vc-countdown').countdown('destroy'); @@ -655,8 +675,11 @@ $ignored_params['refresh'] = ''; } }); } - - startCountDown(refr, false); + + if(refr>0){ + startCountDown(refr, false); + } + var controls = document.getElementById('vc-controls'); autoHideElement(controls, 1000); diff --git a/pandora_console/extensions/db_status.php b/pandora_console/extensions/db_status.php index 2d8669f83f..d78ff90fc8 100755 --- a/pandora_console/extensions/db_status.php +++ b/pandora_console/extensions/db_status.php @@ -215,7 +215,7 @@ function extension_db_check_tables_differences( $diff_tables = array_diff($tables_test, $tables_system); ui_print_result_message( - !empty($diff_tables), + empty($diff_tables), __('Success! %s DB contains all tables', get_product_name()), __( '%s DB could not retrieve all tables. The missing tables are (%s)', diff --git a/pandora_console/extensions/module_groups.php b/pandora_console/extensions/module_groups.php index 9e750be932..d9843f9860 100644 --- a/pandora_console/extensions/module_groups.php +++ b/pandora_console/extensions/module_groups.php @@ -1,17 +1,32 @@ 0, 1, 0)) AS alerts_module_count, - SUM(IF($condition_warning, 1, 0)) AS warning_module_count, - SUM(IF($condition_unknown, 1, 0)) AS unknown_module_count, - SUM(IF($condition_not_init, 1, 0)) AS notInit_module_count, - SUM(IF($condition_critical, 1, 0)) AS critical_module_count, - SUM(IF($condition_normal, 1, 0)) AS normal_module_count, - COUNT(tae.id_agente_modulo) AS total_count, - tmg.id_mg, - tmg.name as n, - tg.id_grupo - FROM ( - SELECT tam.id_agente_modulo, - tam.id_module_group, - ta.id_grupo AS g, - tae.estado, - SUM(IF(tatm.last_fired <> 0, 1, 0)) AS alert_fired - FROM tagente_modulo tam - LEFT JOIN talert_template_modules tatm - ON tatm.id_agent_module = tam.id_agente_modulo - AND tatm.times_fired = 1 - LEFT JOIN tagente_estado tae - ON tae.id_agente_modulo = tam.id_agente_modulo - INNER JOIN tagente ta - ON ta.id_agente = tam.id_agente - WHERE ta.disabled = 0 - AND tam.disabled = 0 - AND tam.delete_pending = 0 - AND ta.id_grupo IN ($ids_group) - GROUP BY tam.id_agente_modulo - UNION ALL - SELECT tam.id_agente_modulo, - tam.id_module_group, - tasg.id_group AS g, - tae.estado, - SUM(IF(tatm.last_fired <> 0, 1, 0)) AS alert_fired - FROM tagente_modulo tam - LEFT JOIN talert_template_modules tatm - ON tatm.id_agent_module = tam.id_agente_modulo - AND tatm.times_fired = 1 - LEFT JOIN tagente_estado tae - ON tae.id_agente_modulo = tam.id_agente_modulo - INNER JOIN tagente ta - ON ta.id_agente = tam.id_agente - INNER JOIN tagent_secondary_group tasg - ON ta.id_agente = tasg.id_agent - WHERE ta.disabled = 0 - AND tam.disabled = 0 - AND tam.delete_pending = 0 - AND tasg.id_group IN ($ids_group) - GROUP BY tam.id_agente_modulo, tasg.id_group - ) AS tae - RIGHT JOIN tgrupo tg - ON tg.id_grupo = tae.g - INNER JOIN ( - SELECT * FROM tmodule_group - UNION ALL - SELECT 0 AS 'id_mg', 'Nothing' AS 'name' - ) AS tmg - ON tae.id_module_group = tmg.id_mg - GROUP BY tae.g, tmg.id_mg"; + $sql = sprintf( + "SELECT SUM(IF(tae.alert_fired <> 0, 1, 0)) AS alerts_module_count, + SUM(IF(%s, 1, 0)) AS warning_module_count, + SUM(IF(%s, 1, 0)) AS unknown_module_count, + SUM(IF(%s, 1, 0)) AS notInit_module_count, + SUM(IF(%s, 1, 0)) AS critical_module_count, + SUM(IF(%s, 1, 0)) AS normal_module_count, + COUNT(tae.id_agente_modulo) AS total_count, + tmg.id_mg, + tmg.name as n, + tg.id_grupo + FROM ( + SELECT tam.id_agente_modulo, + tam.id_module_group, + ta.id_grupo AS g, + tae.estado, + SUM(IF(tatm.last_fired <> 0, 1, 0)) AS alert_fired + FROM tagente_modulo tam + LEFT JOIN talert_template_modules tatm + ON tatm.id_agent_module = tam.id_agente_modulo + AND tatm.times_fired = 1 + LEFT JOIN tagente_estado tae + ON tae.id_agente_modulo = tam.id_agente_modulo + INNER JOIN tagente ta + ON ta.id_agente = tam.id_agente + WHERE ta.disabled = 0 + AND tam.disabled = 0 + AND tam.delete_pending = 0 + AND ta.id_grupo IN (%s) + GROUP BY tam.id_agente_modulo + UNION ALL + SELECT tam.id_agente_modulo, + tam.id_module_group, + tasg.id_group AS g, + tae.estado, + SUM(IF(tatm.last_fired <> 0, 1, 0)) AS alert_fired + FROM tagente_modulo tam + LEFT JOIN talert_template_modules tatm + ON tatm.id_agent_module = tam.id_agente_modulo + AND tatm.times_fired = 1 + LEFT JOIN tagente_estado tae + ON tae.id_agente_modulo = tam.id_agente_modulo + INNER JOIN tagente ta + ON ta.id_agente = tam.id_agente + INNER JOIN tagent_secondary_group tasg + ON ta.id_agente = tasg.id_agent + WHERE ta.disabled = 0 + AND tam.disabled = 0 + AND tam.delete_pending = 0 + AND tasg.id_group IN (%s) + GROUP BY tam.id_agente_modulo, tasg.id_group + ) AS tae + RIGHT JOIN tgrupo tg + ON tg.id_grupo = tae.g + INNER JOIN ( + SELECT * FROM tmodule_group + UNION ALL + SELECT 0 AS 'id_mg', 'Nothing' AS 'name' + ) AS tmg + ON tae.id_module_group = tmg.id_mg + GROUP BY tae.g, tmg.id_mg", + $condition_warning, + $condition_unknown, + $condition_not_init, + $condition_critical, + $condition_normal, + $ids_group, + $ids_group + ); $array_data_prev = db_get_all_rows_sql($sql); @@ -220,9 +253,21 @@ function mainModuleGroups() echo ''; echo ''; + $cell_style = ' + min-width: 60px; + width: 100%; + margin: 0; + overflow:hidden; + text-align: center; + padding: 5px; + padding-bottom:10px; + font-size: 18px; + text-align: center; + '; + if (true) { $table = new StdClass(); - $table->style[0] = 'color: #ffffff; background-color: #373737; font-weight: bolder; padding-right: 10px; min-width: 230px;'; + $table->style[0] = 'color: #ffffff; background-color: #373737; font-weight: bolder; min-width: 230px;'; $table->width = '100%'; $head[0] = __('Groups'); @@ -248,28 +293,28 @@ function mainModuleGroups() $color = '#FFA631'; // Orange when the cell for this model group and agent has at least one alert fired. } else if ($array_data[$key][$k]['critical_module_count'] != 0) { - $color = '#FC4444'; + $color = '#e63c52'; // Red when the cell for this model group and agent has at least one module in critical state and the rest in any state. } else if ($array_data[$key][$k]['warning_module_count'] != 0) { - $color = '#FAD403'; + $color = '#f3b200'; // Yellow when the cell for this model group and agent has at least one in warning state and the rest in green state. } else if ($array_data[$key][$k]['unknown_module_count'] != 0) { $color = '#B2B2B2 '; // Grey when the cell for this model group and agent has at least one module in unknown state and the rest in any state. } else if ($array_data[$key][$k]['normal_module_count'] != 0) { - $color = '#80BA27'; + $color = '#82b92e'; // Green when the cell for this model group and agent has OK state all modules. } else if ($array_data[$key][$k]['notInit_module_count'] != 0) { $color = '#5BB6E5'; // Blue when the cell for this module group and all modules have not init value. } - $data[$i][$j] = "
"; + $data[$i][$j] = "
"; $data[$i][$j] .= ""; $data[$i][$j] .= $array_data[$key][$k]['total_count']; $data[$i][$j] .= '
'; } else { - $data[$i][$j] = "
"; + $data[$i][$j] = "
"; $data[$i][$j] .= 0; $data[$i][$j] .= '
'; } @@ -278,7 +323,7 @@ function mainModuleGroups() } } else { foreach ($value['gm'] as $k => $v) { - $data[$i][$j] = "
"; + $data[$i][$j] = "
"; $data[$i][$j] .= 0; $data[$i][$j] .= '
'; $j++; diff --git a/pandora_console/extensions/realtime_graphs/realtime_graphs.css b/pandora_console/extensions/realtime_graphs/realtime_graphs.css index ab6c94e238..2219c6152a 100644 --- a/pandora_console/extensions/realtime_graphs/realtime_graphs.css +++ b/pandora_console/extensions/realtime_graphs/realtime_graphs.css @@ -11,5 +11,5 @@ #graph_container { width: 800px; - margin: 20px auto !important; + margin: 20px auto; } diff --git a/pandora_console/extras/delete_files/delete_files.txt b/pandora_console/extras/delete_files/delete_files.txt deleted file mode 100644 index 00eb4021d0..0000000000 --- a/pandora_console/extras/delete_files/delete_files.txt +++ /dev/null @@ -1,3 +0,0 @@ -/godmode/servers/recon_script.php -/godmode/servers/manage_recontask_form.php -/godmode/servers/manage_recontask.php \ No newline at end of file diff --git a/pandora_console/extras/mr/28.sql b/pandora_console/extras/mr/28.sql index eef6682a3b..bab07bead8 100644 --- a/pandora_console/extras/mr/28.sql +++ b/pandora_console/extras/mr/28.sql @@ -9,8 +9,37 @@ ALTER TABLE `talert_commands` ADD COLUMN `fields_hidden` text; ALTER TABLE `talert_templates` MODIFY COLUMN `type` ENUM('regex','max_min','max','min','equal','not_equal','warning','critical','onchange','unknown','always','not_normal'); DELETE FROM `tevent_response` WHERE `name` LIKE 'Create Integria IMS incident from event'; -INSERT INTO `tnews` (`id_news`, `author`, `subject`, `text`, `timestamp`) VALUES (1,'admin','Welcome to Pandora FMS Console', '&lt;p style="text-align: center; font-size: 13px;"&gt;Hello, congratulations, if you've arrived here you already have an operational monitoring console. Remember that our forums and online documentation are available 24x7 to get you out of any trouble. You can replace this message with a personalized one at Admin tools -&amp;gt; Site news.&lt;/p&gt; ',NOW()); +INSERT INTO `tnews` (`id_news`, `author`, `subject`, `text`, `timestamp`) VALUES (NULL,'admin','Welcome to Pandora FMS Console', '&lt;p style="text-align: center; font-size: 13px;"&gt;Hello, congratulations, if you've arrived here you already have an operational monitoring console. Remember that our forums and online documentation are available 24x7 to get you out of any trouble. You can replace this message with a personalized one at Admin tools -&amp;gt; Site news.&lt;/p&gt; ',NOW()); +INSERT INTO `tnotification_source_user` (`id_source`, `id_user`, `enabled`, `also_mail`) VALUES ((SELECT `id` FROM `tnotification_source` WHERE `description`="Official communication"), "admin", 1, 0); +UPDATE `tnotification_source` SET `enabled`=1 WHERE `description` = 'System status' OR `description` = 'Official communication'; +UPDATE `tnotification_source` SET `icon`="icono_logo_pandora.png" WHERE `description` = 'Official communication'; -COMMIT; \ No newline at end of file +-- --------------------------------------------------------------------- +-- Table `tvisual_console_items_cache` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tvisual_console_elements_cache` ( + `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `vc_id` INTEGER UNSIGNED NOT NULL, + `vc_item_id` INTEGER UNSIGNED NOT NULL, + `user_id` VARCHAR(60) DEFAULT NULL, + `data` TEXT NOT NULL, + `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + `expiration` INTEGER UNSIGNED NOT NULL COMMENT 'Seconds to expire', + PRIMARY KEY(`id`), + FOREIGN KEY(`vc_id`) REFERENCES `tlayout`(`id`) + ON DELETE CASCADE, + FOREIGN KEY(`vc_item_id`) REFERENCES `tlayout_data`(`id`) + ON DELETE CASCADE, + FOREIGN KEY (`user_id`) REFERENCES `tusuario`(`id_user`) + ON DELETE CASCADE ON UPDATE CASCADE +) engine=InnoDB DEFAULT CHARSET=utf8; + +ALTER TABLE `tlayout_data` ADD COLUMN `cache_expiration` INTEGER UNSIGNED NOT NULL DEFAULT 0; + +ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_level_user` VARCHAR(60); +ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_level_pass` VARCHAR(45); +ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_level_enabled` TINYINT(1) DEFAULT '1'; + +COMMIT; diff --git a/pandora_console/extras/pandora_diag.php b/pandora_console/extras/pandora_diag.php index 2fbd7072f2..f3b11177d1 100644 --- a/pandora_console/extras/pandora_diag.php +++ b/pandora_console/extras/pandora_diag.php @@ -139,8 +139,9 @@ function get_logs_size($file) function get_status_logs($path) { $status_server_log = ''; - $size_server_log = get_logs_size($path); - if ($size_server_log <= 1048576) { + $size_server_log = number_format(get_logs_size($path)); + $size_server_log = (0 + str_replace(',', '', $size_server_log)); + if ($size_server_log <= 10485760) { $status_server_log = "Normal Status   You have less than 10 MB of logs"; } else { $status_server_log = "Warning Status   You have more than 10 MB of logs"; @@ -295,7 +296,7 @@ $key_buffer_size_min_rec_value = 256; $read_buffer_size_min_rec_value = 32; $read_rnd_buffer_size_min_rec_value = 32; $query_cache_min_res_unit_min_rec_value = 2; -$innodb_file_per_table_min_rec_value = 0; +$innodb_file_per_table_min_rec_value = 1; function status_fragmentation_tables($tables_fragmentation_max_rec_value, $tables_fragmentation) diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 8846f4b80d..18bad4b86a 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1289,6 +1289,11 @@ alter table tusuario add autorefresh_white_list text not null default ''; ALTER TABLE tusuario ADD COLUMN `time_autorefresh` int(5) unsigned NOT NULL default '30'; ALTER TABLE `tusuario` DROP COLUMN `flash_chart`; ALTER TABLE `tusuario` ADD COLUMN `default_custom_view` int(10) unsigned NULL default '0'; +ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_level_user` VARCHAR(60); +ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_level_pass` VARCHAR(45); +ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_level_enabled` TINYINT(1); + + -- --------------------------------------------------------------------- -- Table `tagente_modulo` @@ -1371,6 +1376,7 @@ ALTER TABLE `tlayout_data` ADD COLUMN `linked_layout_status_type` ENUM ('default ALTER TABLE `tlayout_data` ADD COLUMN `linked_layout_status_as_service_warning` FLOAT(20, 3) NOT NULL default 0; ALTER TABLE `tlayout_data` ADD COLUMN `linked_layout_status_as_service_critical` FLOAT(20, 3) NOT NULL default 0; ALTER TABLE `tlayout_data` ADD COLUMN `linked_layout_node_id` INT(10) NOT NULL default 0; +ALTER TABLE `tlayout_data` ADD COLUMN `cache_expiration` INTEGER UNSIGNED NOT NULL DEFAULT 0; -- --------------------------------------------------------------------- -- Table `tagent_custom_fields` @@ -1984,6 +1990,33 @@ CREATE TABLE IF NOT EXISTS `tnetwork_matrix` ( UNIQUE (`source`, `destination`, `utimestamp`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; +-- --------------------------------------------------------------------- +-- Table `user_task` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tuser_task` ( + `id` int(20) unsigned NOT NULL auto_increment, + `function_name` varchar(80) NOT NULL default '', + `parameters` text NOT NULL default '', + `name` varchar(60) NOT NULL default '', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- --------------------------------------------------------------------- +-- Table `user_task_scheduled` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tuser_task_scheduled` ( + `id` int(20) unsigned NOT NULL auto_increment, + `id_usuario` varchar(60) NOT NULL default '0', + `id_user_task` int(20) unsigned NOT NULL default '0', + `args` TEXT NOT NULL, + `scheduled` enum('no','hourly','daily','weekly','monthly','yearly','custom') default 'no', + `last_run` int(20) unsigned default '0', + `custom_data` int(10) NULL default '0', + `flag_delete` tinyint(1) UNSIGNED NOT NULL default 0, + `id_grupo` int(10) unsigned NOT NULL default 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + -- ----------------------------------------------------- -- Table `tnotification_source` -- ----------------------------------------------------- @@ -2006,7 +2039,7 @@ INSERT INTO `tnotification_source`(`description`, `icon`, `max_postpone_time`, ` ("Message", "icono_info_mr.png", 86400, 1, 1, 0), ("Pending task", "icono_info_mr.png", 86400, 1, 1, 0), ("Advertisement", "icono_info_mr.png", 86400, 1, 1, 0), - ("Official communication", "icono_info_mr.png", 86400, 1, 1, 0), + ("Official communication", "icono_logo_pandora.png", 86400, 1, 1, 0), ("Sugerence", "icono_info_mr.png", 86400, 1, 1, 0); -- ----------------------------------------------------- @@ -2103,6 +2136,9 @@ INSERT INTO `talert_commands` (`name`, `command`, `description`, `internal`, `fi INSERT INTO `tnotification_source_user` (`id_source`, `id_user`, `enabled`, `also_mail`) VALUES ((SELECT `id` FROM `tnotification_source` WHERE `description`="System status"), "admin", 1, 0); INSERT INTO `tnotification_source_group` SELECT `id`,0 FROM `tnotification_source` WHERE `description`="Message"; INSERT INTO `tnotification_user` (`id_mensaje`, `id_user`) SELECT `id_mensaje`, `id_usuario_destino` FROM `tmensajes` WHERE `id_usuario_destino` != ''; +INSERT INTO `tnotification_source_user` (`id_source`, `id_user`, `enabled`, `also_mail`) VALUES ((SELECT `id` FROM `tnotification_source` WHERE `description`="Official communication"), "admin", 1, 0); +UPDATE `tnotification_source` SET `enabled`=1 WHERE `description` = 'System status' OR `description` = 'Official communication'; + -- ---------------------------------------------------------------------- -- Add custom internal recon scripts -- ---------------------------------------------------------------------- @@ -2124,11 +2160,11 @@ ALTER TABLE `tnetflow_filter` DROP COLUMN `output`; -- ---------------------------------------------------------------------- UPDATE tuser_task set parameters = 'a:5:{i:0;a:6:{s:11:\"description\";s:28:\"Report pending to be created\";s:5:\"table\";s:7:\"treport\";s:8:\"field_id\";s:9:\"id_report\";s:10:\"field_name\";s:4:\"name\";s:4:\"type\";s:3:\"int\";s:9:\"acl_group\";s:8:\"id_group\";}i:1;a:2:{s:11:\"description\";s:46:\"Send to email addresses (separated by a comma)\";s:4:\"type\";s:4:\"text\";}i:2;a:2:{s:11:\"description\";s:7:\"Subject\";s:8:\"optional\";i:1;}i:3;a:3:{s:11:\"description\";s:7:\"Message\";s:4:\"type\";s:4:\"text\";s:8:\"optional\";i:1;}i:4;a:2:{s:11:\"description\";s:11:\"Report Type\";s:4:\"type\";s:11:\"report_type\";}}' where function_name = "cron_task_generate_report"; ------------------------------------------------------------------------- ------- ADD message in table 'tnews' ------------------------------------------------------------------------- +-- ---------------------------------------------------------------------- +-- ADD message in table 'tnews' +-- ---------------------------------------------------------------------- -INSERT INTO `tnews` (`id_news`, `author`, `subject`, `text`, `timestamp`) VALUES (1,'admin','Welcome to Pandora FMS Console', '&lt;p style="text-align: center; font-size: 13px;"&gt;Hello, congratulations, if you've arrived here you already have an operational monitoring console. Remember that our forums and online documentation are available 24x7 to get you out of any trouble. You can replace this message with a personalized one at Admin tools -&amp;gt; Site news.&lt;/p&gt; ',NOW()); +INSERT INTO `tnews` (`id_news`, `author`, `subject`, `text`, `timestamp`) VALUES (NULL,'admin','Welcome to Pandora FMS Console', '&lt;p style="text-align: center; font-size: 13px;"&gt;Hello, congratulations, if you've arrived here you already have an operational monitoring console. Remember that our forums and online documentation are available 24x7 to get you out of any trouble. You can replace this message with a personalized one at Admin tools -&amp;gt; Site news.&lt;/p&gt; ',NOW()); -- ---------------------------------------------------------------------- -- Alter table `talert_templates` @@ -2136,3 +2172,24 @@ INSERT INTO `tnews` (`id_news`, `author`, `subject`, `text`, `timestamp`) VALUES ALTER TABLE `talert_templates` MODIFY COLUMN `type` ENUM('regex','max_min','max','min','equal','not_equal','warning','critical','onchange','unknown','always','not_normal'); +-- --------------------------------------------------------------------- +-- Table `tvisual_console_items_cache` +-- --------------------------------------------------------------------- +CREATE TABLE `tvisual_console_elements_cache` ( + `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `vc_id` INTEGER UNSIGNED NOT NULL, + `vc_item_id` INTEGER UNSIGNED NOT NULL, + `user_id` VARCHAR(60) DEFAULT NULL, + `data` TEXT NOT NULL, + `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + `expiration` INTEGER UNSIGNED NOT NULL COMMENT 'Seconds to expire', + PRIMARY KEY(`id`), + FOREIGN KEY(`vc_id`) REFERENCES `tlayout`(`id`) + ON DELETE CASCADE, + FOREIGN KEY(`vc_item_id`) REFERENCES `tlayout_data`(`id`) + ON DELETE CASCADE, + FOREIGN KEY (`user_id`) REFERENCES `tusuario`(`id_user`) + ON DELETE CASCADE + ON UPDATE CASCADE +) engine=InnoDB DEFAULT CHARSET=utf8; + diff --git a/pandora_console/general/footer.php b/pandora_console/general/footer.php index b35123b5d3..dcc894989b 100644 --- a/pandora_console/general/footer.php +++ b/pandora_console/general/footer.php @@ -20,6 +20,8 @@ if (isset($_SERVER['REQUEST_TIME'])) { $time = get_system_time(); } +ui_require_css_file('footer'); + $license_file = 'general/license/pandora_info_'.$config['language'].'.html'; if (! file_exists($config['homedir'].$license_file)) { $license_file = 'general/license/pandora_info_en.html'; @@ -41,9 +43,17 @@ if ($current_package == 0) { $build_package_version = $current_package; } -echo sprintf(__('%s %s - Build %s - MR %s', get_product_name(), $pandora_version, $build_package_version, $config['MR'])); +echo __( + '%s %s - Build %s - MR %s', + get_product_name(), + $pandora_version, + $build_package_version, + $config['MR'] +); +echo '
'; +echo ''.__('Page generated on %s', date('Y-m-d H:i:s')).''; + -echo ' '; if (isset($config['debug'])) { $cache_info = []; diff --git a/pandora_console/general/login_identification_wizard.php b/pandora_console/general/login_identification_wizard.php deleted file mode 100644 index 7bdb370b54..0000000000 --- a/pandora_console/general/login_identification_wizard.php +++ /dev/null @@ -1,455 +0,0 @@ - true, - 'message' => '', - ]; - - if ($register_pandora) { - // Pandora register update - $um_message = update_manager_register_instance(); - $ui_feedback['message'] .= $um_message['message'].'

'; - if ($um_message['success']) { - config_update_value('instance_registered', 1); - $ui_feedback['status'] = true && $ui_feedback['status']; - } else { - $ui_feedback['status'] = false; - } - } else if (!$forced) { - config_update_value('identification_reminder_timestamp', $future_8_days); - } - - if ($newsletter) { - // Pandora newsletter update - $email = get_parameter('email', ''); - $um_message = update_manager_insert_newsletter($email); - $ui_feedback['message'] .= $um_message['message']; - if ($um_message['success']) { - db_process_sql_update('tusuario', ['middlename' => 1], ['id_user' => $config['id_user']]); - $ui_feedback['status'] = true && $ui_feedback['status']; - } else { - $ui_feedback['status'] = false; - } - } else if (!$forced) { - db_process_sql_update('tusuario', ['lastname' => $future_8_days], ['id_user' => $config['id_user']]); - } - - // Form answer JSON - $ui_feedback['status'] = $ui_feedback['status'] ? 1 : 0; - echo io_json_mb_encode($ui_feedback); - } - - if (!$not_return) { - return; - } -} - -// Check if user is admin -if (!license_free()) { - return; -} - -if (!users_is_admin($config['id_user'])) { - return; -} - -// Get data to display properly the wizard -$wizard_data = []; - -$wizard_data['newsletter_subscribed'] = db_get_value('middlename', 'tusuario', 'id_user', $config['id_user']); -// force_* = 1 -> force show -// force_* = 0 -> force hide -// force_* = -1 -> show or hide depends reminder and timestamp -$wizard_data['force_newsletter'] = get_parameter('force_newsletter', -1); -$wizard_data['newsletter_reminder'] = db_get_value('firstname', 'tusuario', 'id_user', $config['id_user']); -$wizard_data['newsletter_reminder_timestamp'] = db_get_value('lastname', 'tusuario', 'id_user', $config['id_user']); - - -$wizard_data['instance_registered'] = $config['instance_registered']; -$wizard_data['force_register'] = get_parameter('force_register', -1); -$wizard_data['identification_reminder'] = $config['identification_reminder']; -$wizard_data['identification_reminder_timestamp'] = $config['identification_reminder_timestamp']; - -$display_newsletter = display_newsletter($wizard_data); -$display_register = display_register($wizard_data); -$display_forced = ($wizard_data['force_newsletter'] != -1) || ($wizard_data['force_register'] != -1); - -// Return if it is fully completed -if ((!$display_register) && (!$display_newsletter)) { - return false; -} - -$return_button = get_parameter('return_button', 0) == 1; - -$email = db_get_value('email', 'tusuario', 'id_user', $config['id_user']); -// Avoid to show default email -if ($email == 'admin@example.com') { - $email = ''; -} - -// Prints accept register license -echo '
'; - echo '
'; - echo html_print_image('images/pandora_circle_big.png', true); - echo '
'; - echo '
'; - echo __('Stay up to date with the %s community', get_product_name()).'.'; - echo '
'; - - echo '
'; - echo '

'.__('When you subscribe to the %s Update Manager service, you accept that we register your %s instance as an identifier on the database owned by Artica TS. This data will solely be used to provide you with information about %s and will not be conceded to third parties. You can unregister from said database at any time from the Update Manager options.', get_product_name(), get_product_name(), get_product_name()).'

'; - echo '

'.__('In the same fashion, when subscribed to the newsletter you accept that your email will pass on to a database property of Artica TS. This data will solely be used to provide you with information about %s and will not be conceded to third parties. You can unregister from said database at any time from the newsletter subscription options.', get_product_name()).'

'; - echo '
'; - - echo '
'; - echo '
'; - html_print_submit_button(__('Finish'), 'finish_dialog_button', false, 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok" style="width:100px;"'); - echo '
'; - $display_status_return = $return_button ? 'block' : 'none'; - echo '
'; - html_print_submit_button(__('Return'), 'return_dialog_button', false, 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd" style="width:100px;"'); - echo '
'; - echo '
'; - html_print_checkbox('register', 1, false, false, false, 'cursor: \'pointer\''); - echo ' '.__('Join the %s community!', get_product_name()).'!
'; - html_print_checkbox('newsletter', 1, false, false, false, 'cursor: \'pointer\''); - echo ' '.__('Subscribe to our newsletter').''; - echo '
'; - echo '
'; - echo ' '; - html_print_input_text_extended('email-newsletter', $email, 'text-email-newsletter', '', 30, 255, false, '', ['style' => 'display:none; width: 200px;']); -echo ' '; - echo ' *'.__('Required').' '; - echo '
'; - echo '
'; - echo '
'; -echo '
'; - -// Print yes or not dialog -echo '
'; - echo '
'; - echo __('Do you want to continue without any registration').'?'; - echo '
'; - echo '
'; - html_print_submit_button(__('No'), 'no_registration', false, 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only sub cancel" style="width:100px;"'); - echo '
'; - echo '
'; - html_print_submit_button(__('Yes'), 'yes_registration', false, 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd" style="width:100px;"'); - echo '
'; -echo '
'; - -// Print feedback user dialog -echo '
'; - echo '
'; - echo html_print_image('images/success_circle_big.png', true); - echo '
'; - echo '
'; -echo '
'; -?> - - - - - diff --git a/pandora_console/general/login_page.php b/pandora_console/general/login_page.php index d8e28223c6..4fbdf93140 100755 --- a/pandora_console/general/login_page.php +++ b/pandora_console/general/login_page.php @@ -19,8 +19,8 @@ if (isset($config['homedir'])) { ui_require_css_file('login'); -require_once $homedir.'include/functions_ui.php'; -require_once $homedir.'include/functions.php'; +require_once __DIR__.'/../include/functions_ui.php'; +require_once __DIR__.'/../include/functions.php'; require_once __DIR__.'/../include/functions_html.php'; @@ -186,7 +186,7 @@ switch ($login_screen) { echo '
'; echo ''; echo ''; echo ''; } break; @@ -245,7 +245,7 @@ switch ($login_screen) { html_print_input_text_extended('auth_code', '', 'auth_code', '', '', '', false, '', 'class="login login_password" placeholder="'.__('Authentication code').'"', false, true); echo '
'; echo ''; break; @@ -319,7 +319,7 @@ echo '
'; echo '
'.$pandora_version.(($develop_bypass == 1) ? ' '.__('Build').' '.$build_version : '').'
'; echo ''; -if (!isset($process_error_message) && isset($mail)) { +if (empty($process_error_message) && isset($mail)) { echo '
'; echo '
'; echo '
'; @@ -336,7 +336,7 @@ if (!isset($process_error_message) && isset($mail)) { echo '
'; echo '
'; echo '
'; -} else if (isset($process_error_message)) { +} else if (isset($process_error_message) && !empty($process_error_message)) { echo '
'; echo '
'; echo '
'; @@ -518,6 +518,7 @@ if ($login_screen == 'error_authconfig' || $login_screen == 'error_emptyconfig' ui_require_css_file('dialog'); ui_require_css_file('jquery-ui.min', 'include/styles/js/'); ui_require_jquery_file('jquery-ui.min'); +ui_require_jquery_file('jquery-ui_custom'); ?> $email], - ['id_user' => $config['id_user']] - ); - } - - // Update the alert action Mail to XXX/Administrator if it is set to default - $mail_check = 'yourmail@domain.es'; - $mail_alert = alerts_get_alert_action_field1(1); - if ($mail_check === $mail_alert && $email !== false) { - alerts_update_alert_action( - 1, - [ - 'field1' => $email, - 'field1_recovery' => $email, - ] - ); - } - - config_update_value('initial_wizard', 1); - } - - // Change the language if is change in checkbox - if ($change_language !== 0) { - config_update_value('language', $change_language); - } - - if ($cancel_wizard !== 0) { - config_update_value('initial_wizard', 1); - } - - return; -} - -$email = db_get_value('email', 'tusuario', 'id_user', $config['id_user']); -// Avoid to show default email -if ($email == 'admin@example.com') { - $email = ''; -} - -// Prints first step pandora registration -echo ''; - - ?> - - diff --git a/pandora_console/general/logon_ok.php b/pandora_console/general/logon_ok.php index c3de268dea..a02f6c11ac 100644 --- a/pandora_console/general/logon_ok.php +++ b/pandora_console/general/logon_ok.php @@ -103,246 +103,203 @@ if (!empty($all_data)) { $data['server_sanity'] = format_numeric((100 - $data['module_sanity']), 1); } +ui_require_css_file('logon'); -?> - - - - - - - - -
- - - class = 'databox'; - $table->cellpadding = 4; - $table->cellspacing = 4; - $table->head = []; - $table->data = []; - $table->headstyle[0] = 'text-align:center;'; - $table->width = '100%'; - $table->head[0] = ''.__('%s Overview', get_product_name()).''; - $table->head_colspan[0] = 4; +echo '
'; - // Indicators. - $tdata = []; - $stats = reporting_get_stats_indicators($data, 120, 10, false); - $status = ''; - foreach ($stats as $stat) { - $status .= ''; - } +// +// Overview Table. +// +$table = new stdClass(); +$table->class = 'no-class'; +$table->cellpadding = 4; +$table->cellspacing = 4; +$table->head = []; +$table->data = []; +$table->headstyle[0] = 'text-align:center;'; +$table->width = '100%'; +$table->head_colspan[0] = 4; - $status .= '
'.$stat['title'].''.$stat['graph'].'
'; - $table->data[0][0] = $status; - $table->rowclass[] = ''; +// Indicators. +$tdata = []; +$stats = reporting_get_stats_indicators($data, 120, 10, false); +$status = ''; +foreach ($stats as $stat) { + $status .= ''; +} - $table->data[] = $tdata; +$status .= '
'.$stat['title'].''.$stat['graph'].'
'; +$table->data[0][0] = $status; +$table->rowclass[] = ''; - // Alerts. - $tdata = []; - $tdata[0] = reporting_get_stats_alerts($data); - $table->rowclass[] = ''; - $table->data[] = $tdata; +$table->data[] = $tdata; - // Modules by status. - $tdata = []; - $tdata[0] = reporting_get_stats_modules_status($data, 180, 100); - $table->rowclass[] = ''; - $table->data[] = $tdata; +// Alerts. +$tdata = []; +$tdata[0] = reporting_get_stats_alerts($data); +$table->rowclass[] = ''; +$table->data[] = $tdata; - // Total agents and modules. - $tdata = []; - $tdata[0] = reporting_get_stats_agents_monitors($data); - $table->rowclass[] = ''; - $table->data[] = $tdata; +// Modules by status. +$tdata = []; +$tdata[0] = reporting_get_stats_modules_status($data, 180, 100); +$table->rowclass[] = ''; +$table->data[] = $tdata; - // Users. - if (users_is_admin()) { - $tdata = []; - $tdata[0] = reporting_get_stats_users($data); - $table->rowclass[] = ''; - $table->data[] = $tdata; - } +// Total agents and modules. +$tdata = []; +$tdata[0] = reporting_get_stats_agents_monitors($data); +$table->rowclass[] = ''; +$table->data[] = $tdata; - html_print_table($table); - unset($table); - ?> - - -
- - - rowclass[] = ''; + $table->data[] = $tdata; +} + +ui_toggle( + html_print_table($table, true), + __('%s Overview', get_product_name()), + '', + 'overview', + false +); +unset($table); + +echo ''; - // END OF NEWS BOARD. - } + // News board. + ui_toggle( + $output_news, + __('News board'), + '', + 'news', + false + ); + // END OF NEWS BOARD. +} - $nots = messages_get_overview('utimestamp', 'DESC', false); - if (!empty($nots)) { - // Notifications board. - echo '
'; - - echo ''; - echo ''; - if ($config['prominent_time'] == 'timestamp') { - $comparation_suffix = ''; - } else { - $comparation_suffix = __('ago'); - } - - foreach ($nots as $msg) { - $conversation = io_safe_output( - messages_get_conversation($msg) - ); - - if (is_array($conversation)) { - $text = array_pop($conversation)['message']; - } else { - // Skip empty message. - continue; - } - - $url = ui_get_full_url( - 'index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&id_message='.$msg['id_mensaje'] - ); - if ($msg['url'] != '') { - $url = $msg['url']; - } - - echo ''; - echo ''; - echo ''; - } - - echo '
'.__('Pending notifications').'
'.$msg['subject'].'
'; - if ($msg['id_usuario_origen'] != '') { - echo ''.get_user_fullname($msg['id_usuario_origen']).' '; - } - - echo ''.ui_print_timestamp($msg['timestamp'], true).' '.$comparation_suffix.'
'; - echo nl2br($text); - echo '
'; - echo '
'; - - echo '

'; - - // EO Notifications board. - } - - // LAST ACTIVITY. - // Show last activity from this user. - echo '
'; - - $table = new stdClass(); - $table->class = 'info_table'; - $table->cellpadding = 0; - $table->cellspacing = 0; - $table->width = '100%'; - // Don't specify px. - $table->data = []; - $table->size = []; - $table->size[0] = '5%'; - $table->size[1] = '15%'; - $table->size[2] = '15%'; - $table->size[3] = '10%'; - $table->size[4] = '25%'; - $table->head = []; - $table->head[0] = __('User'); - $table->head[1] = __('Action'); - $table->head[2] = __('Date'); - $table->head[3] = __('Source IP'); - $table->head[4] = __('Comments'); - $table->title = ''.__('This is your last activity performed on the %s console', get_product_name()).''; - $sql = sprintf( - 'SELECT id_usuario,accion, ip_origen,descripcion,utimestamp - FROM tsesion - WHERE (`utimestamp` > UNIX_TIMESTAMP(NOW()) - '.SECONDS_1WEEK.") - AND `id_usuario` = '%s' ORDER BY `utimestamp` DESC LIMIT 10", - $config['id_user'] - ); +// LAST ACTIVITY. +// Show last activity from this user. +$table = new stdClass(); +$table->class = 'no-td-padding info_table'; +$table->cellpadding = 0; +$table->cellspacing = 0; +$table->width = '100%'; +// Don't specify px. +$table->data = []; +$table->size = []; +$table->headstyle = []; +$table->size[0] = '5%'; +$table->size[1] = '15%'; +$table->headstyle[1] = 'min-width: 12em;'; +$table->size[2] = '5%'; +$table->headstyle[2] = 'min-width: 65px;'; +$table->size[3] = '10%'; +$table->size[4] = '25%'; +$table->head = []; +$table->head[0] = __('User'); +$table->head[1] = __('Action'); +$table->head[2] = __('Date'); +$table->head[3] = __('Source IP'); +$table->head[4] = __('Comments'); +$table->align[4] = 'left'; +$sql = sprintf( + 'SELECT id_usuario,accion, ip_origen,descripcion,utimestamp + FROM tsesion + WHERE (`utimestamp` > UNIX_TIMESTAMP(NOW()) - '.SECONDS_1WEEK.") + AND `id_usuario` = '%s' ORDER BY `utimestamp` DESC LIMIT 10", + $config['id_user'] +); - $sessions = db_get_all_rows_sql($sql); +$sessions = db_get_all_rows_sql($sql); - if ($sessions === false) { - $sessions = []; - } +if ($sessions === false) { + $sessions = []; +} - foreach ($sessions as $session) { - $data = []; - $session_id_usuario = $session['id_usuario']; - $session_ip_origen = $session['ip_origen']; +foreach ($sessions as $session) { + $data = []; + $session_id_usuario = $session['id_usuario']; + $session_ip_origen = $session['ip_origen']; + $data[0] = ''.$session_id_usuario.''; + $data[1] = ui_print_session_action_icon($session['accion'], true).' '.$session['accion']; + $data[2] = ui_print_help_tip( + date($config['date_format'], $session['utimestamp']), + true + ).human_time_comparation($session['utimestamp'], 'tiny'); + $data[3] = $session_ip_origen; + $description = str_replace([',', ', '], ', ', $session['descripcion']); + if (strlen($description) > 100) { + $data[4] = '
'.io_safe_output(substr($description, 0, 150).'...').'
'; + } else { + $data[4] = '
'.io_safe_output($description).'
'; + } - $data[0] = ''.$session_id_usuario.''; - $data[1] = ui_print_session_action_icon($session['accion'], true).' '.$session['accion']; - $data[2] = ui_print_help_tip( - date($config['date_format'], $session['utimestamp']), - true - ).human_time_comparation($session['utimestamp'], 'tiny'); - $data[3] = $session_ip_origen; - $description = str_replace([',', ', '], ', ', $session['descripcion']); - if (strlen($description) > 100) { - $data[4] = '
'.io_safe_output(substr($description, 0, 150).'...').'
'; - } else { - $data[4] = '
'.io_safe_output($description).'
'; - } + array_push($table->data, $data); +} - array_push($table->data, $data); - } +$activity .= html_print_table($table, true); +unset($table); - echo "
"; - html_print_table($table); - unset($table); - echo '
'; - echo '
'; - // END OF LAST ACTIVIYY. - ?> - - -
+ui_toggle( + $activity, + __('Latest activity'), + '', + 'activity', + false, + false, + '', + 'white-box-content padded' +); +// END OF LAST ACTIVIYY. +// Close right panel. +echo '
'; + +// Close welcome panel. +echo '
'; diff --git a/pandora_console/general/main_menu.php b/pandora_console/general/main_menu.php index 877f171090..ca6c0fd473 100644 --- a/pandora_console/general/main_menu.php +++ b/pandora_console/general/main_menu.php @@ -30,12 +30,6 @@ $(document).ready(function(){ } }); - -// Set the height of the menu. -$(window).on('load', function (){ - $("#menu_full").height($("#container").height()); -}); - -1], + ['id_user' => $config['id_user']] + ); + + // XXX: Also notify UpdateManager. + } + + if ($register_newsletter) { + $feedback = newsletter_wiz_process(); + } + + if (is_array($feedback)) { + echo json_encode($feedback); + } + + + // Ajax calls finish here. + exit(); +} + + +ui_require_css_file('register'); + +$initial = isset($config['initial_wizard']) !== true + || $config['initial_wizard'] != '1'; + +$newsletter = db_get_value( + 'middlename', + 'tusuario', + 'id_user', + $config['id_user'] +); +$show_newsletter = $newsletter == '0' || $newsletter == ''; + +$registration = isset($config['pandora_uid']) !== true + || $config['pandora_uid'] == ''; + + +if ($initial && users_is_admin()) { + // Show all forms in order. + // 1- Ask for email, timezone, etc. Fullfill alerts and user mail. + config_wiz_modal( + false, + true, + (($registration === true) ? 'show_registration_wizard()' : null) + ); +} + +if ($registration && users_is_admin()) { + // Prepare registration wizard, not launch. leave control to flow. + registration_wiz_modal( + false, + // Launch only if not being launch from 'initial'. + !$initial, + (($show_newsletter === true) ? 'force_run_newsletter()' : null) + ); +} else { + if ($show_newsletter) { + // Show newsletter wizard for current user. + newsletter_wiz_modal( + false, + // Launch only if not being call from 'registration'. + !$registration && !$initial + ); + } +} + + +$newsletter = null; + +?> + diff --git a/pandora_console/godmode/admin_access_logs.php b/pandora_console/godmode/admin_access_logs.php index 67a933d8cb..112a45754f 100644 --- a/pandora_console/godmode/admin_access_logs.php +++ b/pandora_console/godmode/admin_access_logs.php @@ -94,7 +94,7 @@ $table->data[1] = $data; $form = '
'; $form .= html_print_table($table, true); $form .= '
'; -ui_toggle($form, __('Filter'), '', false); +ui_toggle($form, __('Filter'), '', '', false); $filter = '1=1'; diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index cee4cb2684..7c6a3ab03b 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -1,17 +1,32 @@ $value) { - // Check if it has "ifXXXX" syntax and skip it + // Check if it has "ifXXXX" syntax and skip it. if (! preg_match('/if/', $key)) { continue; } @@ -98,7 +109,7 @@ if (is_ajax()) { echo io_json_mb_encode($out); } - // And and remove groups use the same function + // And and remove groups use the same function. $add_secondary_groups = get_parameter('add_secondary_groups'); $remove_secondary_groups = get_parameter('remove_secondary_groups'); if ($add_secondary_groups || $remove_secondary_groups) { @@ -114,12 +125,12 @@ if (is_ajax()) { 'agents_update_secondary_groups', [ $id_agent, - $add_secondary_groups ? $groups_to_add : [], - $remove_secondary_groups ? $groups_to_add : [], + ($add_secondary_groups) ? $groups_to_add : [], + ($remove_secondary_groups) ? $groups_to_add : [], ] ); // Echo 0 in case of error. 0 Otherwise. - echo $ret ? 1 : 0; + echo ($ret) ? 1 : 0; } } @@ -149,7 +160,7 @@ if ($new_agent) { } if (!$new_agent) { - // Agent remote configuration editor + // Agent remote configuration editor. enterprise_include_once('include/functions_config_agents.php'); if (enterprise_installed()) { $filename = config_agents_get_agent_config_filenames($id_agente); @@ -157,27 +168,41 @@ if (!$new_agent) { } $disk_conf_delete = (bool) get_parameter('disk_conf_delete'); -// Agent remote configuration DELETE +// Agent remote configuration DELETE. if ($disk_conf_delete) { // TODO: Get this working on computers where the Pandora server(s) are not on the webserver - // TODO: Get a remote_config editor working in the open version + // TODO: Get a remote_config editor working in the open version. @unlink($filename['md5']); @unlink($filename['conf']); } -echo '
'; +echo ''; + +// Custom ID. +$custom_id_div = '
'; +$custom_id_div .= '

'.__('Custom ID').':

'; +$custom_id_div .= html_print_input_text( + 'custom_id', + $custom_id, + '', + 16, + 255, + true, + false, + false, + '', + 'agent_custom_id' +).'
'; if (!$new_agent && $alias != '') { $table_agent_name = '

'.__('Agent name').': '.ui_print_help_tip(__("The agent's name must be the same as the one defined at the console"), true).'

'; $table_agent_name .= '
'; - $table_agent_name .= '
'.html_print_input_text('agente', $nombre_agente, '', 50, 100, true).'
'; - $table_agent_name .= '
'; - - $table_qr_code = '

'.__('QR Code Agent view').':

'; + $table_agent_name .= '
'.html_print_input_text('agente', $nombre_agente, '', 50, 100, true).'
'; + $table_agent_name .= '
'; + + // QR code div. + $table_qr_code = '
'; + $table_qr_code .= '

'.__('QR Code Agent view').':

'; + $table_qr_code .= '
'; + if ($id_agente) { + $table_qr_code .= "
"; + } + + // Add Custom id div. + $table_qr_code .= '
'; + $table_qr_code .= $custom_id_div; + $table_qr_code .= '
'; } if ($new_agent) { @@ -257,14 +295,6 @@ if ($id_agente) { } "; - } - - $table_qr_code .= '
'; -} - $groups = users_get_groups($config['id_user'], 'AR', false); $modules = db_get_all_rows_sql( @@ -295,7 +325,21 @@ $table_primary_group .= '
'; $table_interval = '

'.__('Interval').':

'; $table_interval .= '
'; -$table_interval .= html_print_extended_select_for_time('intervalo', $intervalo, '', '', '0', 10, true); +$table_interval .= html_print_extended_select_for_time( + 'intervalo', + $intervalo, + '', + '', + '0', + 10, + true, + false, + true, + 'w40p' +); + + + if ($intervalo < SECONDS_5MINUTES) { $table_interval .= clippy_context_help('interval_agent_min'); } @@ -341,22 +385,23 @@ $table_server .= html_print_select( __('None'), 0, true -).'
'.ui_print_help_icon('agent_server', true).'
'; +).'
'; // Description. $table_description = '

'.__('Description').':

'; -$table_description .= html_print_input_text( +$table_description .= html_print_textarea( 'comentarios', + 3, + 10, $comentarios, '', - 45, - 200, - true + true, + 'agent_description' ).'
'; - +// QR code. echo '
-
+
'.$table_agent_name.$table_alias.$table_ip.$table_primary_group.'
'.$table_interval.$table_os.$table_server.$table_description.'
'; @@ -368,49 +413,49 @@ echo '
'; if (enterprise_installed()) { $secondary_groups_selected = enterprise_hook('agents_get_secondary_groups', [$id_agente]); - $table_adv_secondary_groups = '

'.__('Secondary groups').': '.ui_print_help_icon('secondary_groups', true).'

'; - $table_adv_secondary_groups_left = html_print_select_groups( + $adv_secondary_groups_label = '

'.__('Secondary groups').':

'; + $adv_secondary_groups_left = html_print_select_groups( false, - // Use the current user to select the groups + // Use the current user to select the groups. 'AR', - // ACL permission + // ACL permission. false, - // Not all group + // Not all group. 'secondary_groups', - // HTML id + // HTML id. '', - // No select any by default + // No select any by default. '', - // Javascript onChange code + // Javascript onChange code. '', - // Do not user no selected value + // Do not user no selected value. 0, - // Do not use no selected value + // Do not use no selected value. true, - // Return HTML (not echo) + // Return HTML (not echo). true, - // Multiple selection + // Multiple selection. true, - // Sorting by default + // Sorting by default. '', - // CSS classnames (default) + // CSS classnames (default). false, - // Not disabled (default) - 'width:50%; min-width:170px; text-align:center', - // Inline styles (default) + // Not disabled (default). + 'min-width:170px;', + // Inline styles (default). false, - // Option style select (default) + // Option style select (default). false, - // Do not truncate the users tree (default) + // Do not truncate the users tree (default). 'id_grupo', - // Key to get as value (default) + // Key to get as value (default). false, - // Not strict user (default) + // Not strict user (default). $secondary_groups_selected['plain'] - // Do not show the primary group in this selection + // Do not show the primary group in this selection. ); - $table_adv_secondary_groups_arrows = html_print_input_image( + $adv_secondary_groups_arrows = html_print_input_image( 'add_secondary', 'images/darrowright_green.png', 1, @@ -434,34 +479,34 @@ if (enterprise_installed()) { ] ); - $table_adv_secondary_groups_right .= html_print_select( + $adv_secondary_groups_right .= html_print_select( $secondary_groups_selected['for_select'], - // Values + // Values. 'secondary_groups_selected', - // HTML id + // HTML id. '', - // Selected + // Selected. '', - // Javascript onChange code + // Javascript onChange code. '', - // Nothing selected + // Nothing selected. 0, - // Nothing selected + // Nothing selected. true, - // Return HTML (not echo) + // Return HTML (not echo). true, - // Multiple selection + // Multiple selection. true, - // Sort + // Sort. '', - // Class + // Class. false, - // Disabled - 'width:50%; min-width:170px; text-align:center' - // Style + // Disabled. + 'min-width:170px;' + // Style. ); - // safe operation mode + // Safe operation mode. if ($id_agente) { $sql_modules = db_get_all_rows_sql( 'SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo @@ -485,13 +530,13 @@ if (enterprise_installed()) { $table_adv_safe .= __('Module').' '.html_print_select($safe_mode_modules, 'safe_mode_module', $safe_mode_module, '', '', 0, true).'
'; } - // Remote configuration + // Remote configuration. $table_adv_remote = '

'.__('Remote configuration').':

'; if (!$new_agent && isset($filename) && file_exists($filename['md5'])) { $table_adv_remote .= date('F d Y H:i:s', fileatime($filename['md5'])); - // Delete remote configuration - $table_adv_remote .= ''; + // Delete remote configuration. + $table_adv_remote .= ''; $table_adv_remote .= html_print_image( 'images/cross.png', true, @@ -510,28 +555,31 @@ if (enterprise_installed()) { $table_adv_remote .= '
'; - $cps_array[-1] = __('Disabled'); - if ($cps > 0) { - $cps_array[$cps] = __('Enabled'); - } else { - $cps_inc = 0; - if ($id_agente) { - $cps_inc = service_agents_cps($id_agente); - } - $cps_array[$cps_inc] = __('Enabled'); + // Calculate cps value - agents. + if ($id_agente) { + $cps_val = service_agents_cps($id_agente); + } else { + // No agent defined, use received cps as base value. + if ($cps >= 0) { + $cps_val = $cps; + } } - $table_adv_cascade = '

'.__('Cascade protection services').': '; - $table_adv_cascade .= ui_print_help_tip(__('Disable the alerts and events of the elements that belong to this service'), true).'

'; - $table_adv_cascade .= html_print_select($cps_array, 'cps', $cps, '', '', 0, true).'
'; + $cps_html = '
'; + $cps_html .= html_print_checkbox_switch('cps', $cps_val, ($cps >= 0), true); + $cps_html .= __('Cascade protection services').' '; + $cps_html .= ui_print_help_tip( + __('Alerts and events will be managed by the service joined by this agent.'), + true + ); + $cps_html .= '
'; + + $table_adv_cascade .= $cps_html; } -// Custom ID -$table_adv_custom_id = '

'.__('Custom ID').':

'; -$table_adv_custom_id .= html_print_input_text('custom_id', $custom_id, '', 16, 255, true).'
'; -$table_adv_parent = '

'.__('Parent').':

'; +$table_adv_parent = '
'; $params = []; $params['return'] = true; $params['show_helptip'] = true; @@ -546,13 +594,26 @@ $params['cascade_protection'] = true; $table_adv_parent .= '
'; $table_adv_parent .= ui_print_agent_autocomplete_input($params); if (enterprise_installed()) { - $table_adv_parent .= html_print_checkbox_switch('cascade_protection', 1, $cascade_protection, true).__('Cascade protection').' '.ui_print_help_icon('cascade_protection', true); + $table_adv_parent .= html_print_checkbox_switch( + 'cascade_protection', + 1, + $cascade_protection, + true + ).__('Cascade protection').' '; } -$table_adv_parent .= __('Module').' '.html_print_select($modules_values, 'cascade_protection_module', $cascade_protection_module, '', '', 0, true).'
'; +$table_adv_parent .= __('Module').' '.html_print_select( + $modules_values, + 'cascade_protection_module', + $cascade_protection_module, + '', + '', + 0, + true +).'
'; -// Learn mode / Normal mode -$table_adv_module_mode = '

'.__('Module definition').': '.ui_print_help_icon('module_definition', true).'

'; +// Learn mode / Normal mode. +$table_adv_module_mode = '

'.__('Module definition').':

'; $table_adv_module_mode .= '
'; $table_adv_module_mode .= html_print_radio_button_extended( 'modo', @@ -586,9 +647,16 @@ $table_adv_module_mode .= html_print_radio_button_extended( ); $table_adv_module_mode .= '
'; -// Status (Disabled / Enabled) -$table_adv_status = '

'.__('Disabled').': '.ui_print_help_tip(__('If the remote configuration is enabled, it will also go into standby mode when disabling it.'), true).'

'; -$table_adv_status .= html_print_checkbox_switch('disabled', 1, $disabled, true).'
'; +// Status (Disabled / Enabled). +$table_adv_status = '
'; +$table_adv_status .= html_print_checkbox_switch( + 'disabled', + 1, + $disabled, + true +); +$table_adv_status .= '

'.__('Disabled').': '.ui_print_help_tip(__('If the remote configuration is enabled, it will also go into standby mode when disabling it.'), true).'

'; +$table_adv_status .= '
'; // Url address. if (enterprise_installed()) { @@ -599,7 +667,14 @@ if (enterprise_installed()) { '', 45, 255, - true + true, + false, + false, + '', + '', + '', + // Autocomplete. + 'new-password' ).'
'; } else { $table_adv_url = '

'.__('Url address').':

'; @@ -613,9 +688,11 @@ if (enterprise_installed()) { ).''; } -$table_adv_quiet = '

'.__('Quiet').': '; +$table_adv_quiet = '

'; +$table_adv_quiet .= html_print_checkbox_switch('quiet', 1, $quiet, true); +$table_adv_quiet .= '

'.__('Quiet').': '; $table_adv_quiet .= ui_print_help_tip(__('The agent still runs but the alerts and events will be stop'), true).'

'; -$table_adv_quiet .= html_print_checkbox_switch('quiet', 1, $quiet, true).'
'; +$table_adv_quiet .= '
'; $listIcons = gis_get_array_list_icons(); @@ -625,11 +702,11 @@ foreach ($listIcons as $index => $value) { } $path = 'images/gis_map/icons/'; -// TODO set better method the path +// TODO set better method the path. $table_adv_agent_icon = '

'.__('Agent icon').': '.ui_print_help_tip(__('Agent icon for GIS Maps.'), true).'

'; if ($icon_path == '') { $display_icons = 'none'; - // Hack to show no icon. Use any given image to fix not found image errors + // Hack to show no icon. Use any given image to fix not found image errors. $path_without = 'images/spinner.png'; $path_default = 'images/spinner.png'; $path_ok = 'images/spinner.png'; @@ -686,24 +763,47 @@ if ($config['activate_gis']) { -$table_adv_options = $table_adv_secondary_groups.'
-
- '.$table_adv_secondary_groups_left.' +// General display distribution. +$table_adv_options = ' +
+ '.$adv_secondary_groups_label.' +
+ '.$adv_secondary_groups_left.' +
+
+ '.$adv_secondary_groups_arrows.' +
+
+ '.$adv_secondary_groups_right.' +
-
- '.$table_adv_secondary_groups_arrows.' -
-
- '.$table_adv_secondary_groups_right.' -
-
-
-
'.$table_adv_parent.$table_adv_custom_id.$table_adv_module_mode.$table_adv_cascade.$table_adv_gis.'
-
'.$table_adv_agent_icon.$table_adv_url.$table_adv_quiet.$table_adv_status.$table_adv_remote.$table_adv_safe.'
-
'; +
+ '.$table_adv_parent.$table_adv_module_mode.$table_adv_cascade; + +if ($new_agent) { + // If agent is new, show custom id as old style format. + $table_adv_options .= $custom_id_div; +} + +$table_adv_options .= '
'; + +$table_adv_options .= ' +
+ '.$table_adv_gis.$table_adv_agent_icon.$table_adv_url.$table_adv_quiet.$table_adv_status.$table_adv_remote.$table_adv_safe.' +
'; + echo '
'; - ui_toggle($table_adv_options, __('Advanced options'), '', true, false, 'white_box white_box_opened'); +ui_toggle( + $table_adv_options, + __('Advanced options'), + '', + '', + true, + false, + 'white_box white_box_opened', + 'no-border flex' +); echo '
'; @@ -711,10 +811,17 @@ $table = new stdClass(); $table->width = '100%'; $table->class = 'custom_fields_table'; -$table->head = []; +$table->head = [ + 0 => __('Click to display').ui_print_help_tip( + __('This field allows url insertion using the BBCode\'s url tag').'.
'.__('The format is: [url=\'url to navigate\']\'text to show\'[/url]').'.

'.__('e.g.: [url=google.com]Google web search[/url]'), + true + ), +]; +$table->class = 'info_table'; $table->style = []; $table->style[0] = 'font-weight: bold;'; $table->data = []; +$table->rowstyle = []; $fields = db_get_all_fields_in_table('tagent_custom_fields'); @@ -722,15 +829,12 @@ if ($fields === false) { $fields = []; } +$i = 0; foreach ($fields as $field) { $id_custom_field = $field['id_field']; $data[0] = '
'; $data[0] .= ''.$field['name'].''; - $data[0] .= ui_print_help_tip( - __('This field allows url insertion using the BBCode\'s url tag').'.
'.__('The format is: [url=\'url to navigate\']\'text to show\'[/url]').'.

'.__('e.g.: [url=google.com]Google web search[/url]'), - true - ); $data[0] .= '
'; $combo = []; $combo = $field['combo_values']; @@ -753,6 +857,13 @@ foreach ($fields as $field) { $custom_value = ''; } + $table->rowstyle[$i] = 'cursor: pointer;user-select: none;'; + if (!empty($custom_value)) { + $table->rowstyle[($i + 1)] = 'display: table-row;'; + } else { + $table->rowstyle[($i + 1)] = 'display: none;'; + } + if ($field['is_password_type']) { $data_field[1] = html_print_input_text_extended( 'customvalue_'.$field['id_field'], @@ -801,21 +912,30 @@ foreach ($fields as $field) { }; $table->rowid[] = 'name_field-'.$id_custom_field; - array_push($table->data, $data); + $table->data[] = $data; $table->rowid[] = 'field-'.$id_custom_field; - array_push($table->data, $data_field); + $table->data[] = $data_field; + $i += 2; } if (!empty($fields)) { echo '
'; - ui_toggle(html_print_table($table, true), __('Custom fields'), '', true, false, 'white_box white_box_opened'); + ui_toggle( + html_print_table($table, true), + __('Custom fields'), + '', + '', + true, + false, + 'white_box white_box_opened', + 'no-border' + ); echo '
'; } echo '
'; - // The context help about the learning mode. if ($modo == 0) { echo ""; diff --git a/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php b/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php index 5730fea501..b08dc62c4f 100644 --- a/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php +++ b/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php @@ -322,7 +322,7 @@ if ($create_modules) { } else if (preg_match('/ifAdminStatus/', $name_array[1])) { $module_type = 2; } else if (preg_match('/ifOperStatus/', $name_array[1])) { - $module_type = 18; + $module_type = 2; } else { $module_type = 4; } @@ -608,11 +608,11 @@ ui_require_jquery_file('bgiframe'); $(document).ready (function () { var inputActive = true; - + $(document).data('text_for_module', $("#none_text").html()); - + $("#id_snmp").change(snmp_changed_by_multiple_snmp); - + $("#snmp_version").change(function () { if (this.value == "3") { $("#snmp3_options").css("display", ""); @@ -621,7 +621,7 @@ $(document).ready (function () { $("#snmp3_options").css("display", "none"); } }); - + $("#walk_form").submit(function() { $("#submit-snmp_walk").disable (); $("#oid_loading").show (); @@ -632,15 +632,15 @@ $(document).ready (function () { function snmp_changed_by_multiple_snmp (event, id_snmp, selected) { var idSNMP = Array(); - + jQuery.each ($("#id_snmp option:selected"), function (i, val) { idSNMP.push($(val).val()); }); $('#module').attr ('disabled', 1); $('#module').empty (); $('#module').append ($('').html ("Loading...").attr ("value", 0)); - - jQuery.post ('ajax.php', + + jQuery.post ('ajax.php', {"page" : "godmode/agentes/agent_manager", "get_modules_json_for_multiple_snmp": 1, "id_snmp[]": idSNMP, @@ -655,7 +655,7 @@ function snmp_changed_by_multiple_snmp (event, id_snmp, selected) { $('#module').fadeIn ('normal'); c++; }); - + if (c == 0) { if (typeof($(document).data('text_for_module')) != 'undefined') { $('#module').append ($('').html ($(document).data('text_for_module')).attr("value", 0).prop('selected', true)); @@ -666,11 +666,11 @@ function snmp_changed_by_multiple_snmp (event, id_snmp, selected) { } else { var anyText = $("#any_text").html(); //Trick for catch the translate text. - + if (anyText == null) { anyText = 'Any'; } - + $('#module').append ($('').html (anyText).attr ("value", 0).prop('selected', true)); } } @@ -684,4 +684,3 @@ function snmp_changed_by_multiple_snmp (event, id_snmp, selected) { /* ]]> */ - diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 8ebfdb296a..22410b0e23 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -1,17 +1,32 @@ '.html_print_image( + $remote_configuration_tab['text'] = ''.html_print_image( 'images/remote_configuration.png', true, ['title' => __('Remote configuration')] @@ -575,20 +591,24 @@ if ($id_agente) { } $help_header = ''; + $tab_name = ''; // This add information to the header. switch ($tab) { case 'main': $tab_description = '- '.__('Setup'); $help_header = 'main_tab'; + $tab_name = 'Setup'; break; case 'collection': $tab_description = '- '.__('Collection'); + $tab_name = 'Collection'; break; case 'inventory': $tab_description = '- '.__('Inventory'); $help_header = 'inventory_tab'; + $tab_name = 'Inventory'; break; case 'plugins': @@ -599,6 +619,7 @@ if ($id_agente) { case 'module': $type_module_t = get_parameter('moduletype', ''); $tab_description = '- '.__('Modules'); + $tab_name = 'Modules'; if ($type_module_t == 'webux') { $help_header = 'wux_console'; } else { @@ -609,10 +630,12 @@ if ($id_agente) { case 'alert': $tab_description = '- '.__('Alert'); $help_header = 'manage_alert_list'; + $tab_name = 'Alerts'; break; case 'template': $tab_description = '- '.__('Templates'); + $tab_name = 'Module templates'; break; case 'gis': @@ -633,16 +656,19 @@ if ($id_agente) { case 'snmp_explorer': $tab_description = '- '.__('SNMP Wizard'); $help_header = 'agent_snmp_explorer_tab'; + $tab_name = 'SNMP Wizard'; break; case 'snmp_interfaces_explorer': $tab_description = '- '.__('SNMP Interfaces wizard'); $help_header = 'agent_snmp_interfaces_explorer_tab'; + $tab_name = 'SNMP Interfaces wizard'; break; case 'wmi_explorer': $tab_description = '- '.__('WMI Wizard'); $help_header = 'agent_snmp_wmi_explorer_tab'; + $tab_name = 'WMI Wizard'; break; default: @@ -679,7 +705,15 @@ if ($id_agente) { $onheader, false, '', - $config['item_title_size_text'] + $config['item_title_size_text'], + '', + ui_print_breadcrums( + [ + __('Resources'), + __('Manage agents'), + ''.$tab_name.'', + ] + ) ); } else { // Create agent. @@ -688,7 +722,19 @@ if ($id_agente) { 'images/bricks.png', false, 'create_agent', - true + true, + '', + false, + '', + GENERIC_SIZE_TEXT, + '', + ui_print_breadcrums( + [ + __('Resources'), + __('Manage agents'), + ''.__('Create agent').'', + ] + ) ); } @@ -829,8 +875,7 @@ if ($update_agent) { $update_gis_data = (int) get_parameter_post('update_gis_data', 0); $url_description = (string) get_parameter('url_description'); $quiet = (int) get_parameter('quiet', 0); - $cps = (int) get_parameter('cps', 0); - + $cps = get_parameter_switch('cps', -1); $old_values = db_get_row('tagente', 'id_agente', $id_agente); $fields = db_get_all_fields_in_table('tagent_custom_fields'); @@ -978,7 +1023,7 @@ if ($update_agent) { [ $id_agente, 'standby', - $disabled ? '1' : '0', + ($disabled) ? '1' : '0', ] ); // Validate alerts for disabled agents. @@ -1064,7 +1109,7 @@ if ($update_agent) { ui_print_success_message(__('Successfully updated')); db_pandora_audit( 'Agent management', - "Updated agent $alias", + 'Updated agent '.$alias, false, false, $info @@ -1206,7 +1251,7 @@ if ($update_module || $create_module) { } if ($id_module_type == 25) { - // web analysis, from MODULE_WUX. + // Web analysis, from MODULE_WUX. $custom_string_1 = base64_encode((string) get_parameter('custom_string_1', $custom_string_1_default)); $custom_integer_1 = (int) get_parameter('custom_integer_1', $custom_integer_1_default); } else { @@ -1220,6 +1265,7 @@ if ($update_module || $create_module) { // Get macros. $macros = (string) get_parameter('macros'); + $macros_names = (array) get_parameter('macro_name', []); if (!empty($macros)) { $macros = json_decode(base64_decode($macros), true); @@ -1230,10 +1276,18 @@ if ($update_module || $create_module) { $m_hide = $m['hide']; } - if ($m_hide == '1') { - $macros[$k]['value'] = io_input_password(get_parameter($m['macro'], '')); + if ($update_module) { + if ($m_hide == '1') { + $macros[$k]['value'] = io_input_password(get_parameter($m['macro'], '')); + } else { + $macros[$k]['value'] = get_parameter($m['macro'], ''); + } } else { - $macros[$k]['value'] = get_parameter($m['macro'], ''); + if ($m_hide == '1') { + $macros[$k]['value'] = io_input_password($macros_names[$k]); + } else { + $macros[$k]['value'] = $macros_names[$k]; + } } } @@ -1243,12 +1297,11 @@ if ($update_module || $create_module) { foreach ($conf_array as $line) { if (preg_match('/^module_name\s*(.*)/', $line, $match)) { - $new_configuration_data .= 'module_name '.io_safe_output($name)."\n"; - } - - // We delete from conf all the module macros starting with _field. - else if (!preg_match('/^module_macro_field.*/', $line, $match)) { - $new_configuration_data .= "$line\n"; + $new_configuration_data .= 'module_name '; + $new_configuration_data .= io_safe_output($name)."\n"; + } else if (!preg_match('/^module_macro_field.*/', $line, $match)) { + // We delete from conf all the module macros starting with _field. + $new_configuration_data .= $line."\n"; } } @@ -1410,9 +1463,13 @@ if ($update_module || $create_module) { } $active_snmp_v3 = get_parameter('active_snmp_v3'); - if ($active_snmp_v3) { - // LOST CODE? - } + + /* + * if ($active_snmp_v3) { + * // LOST CODE?. + * + * } + */ $throw_unknown_events = (bool) get_parameter('throw_unknown_events', false); // Set the event type that can show. @@ -1428,32 +1485,11 @@ if ($update_module || $create_module) { $module_in_policy = enterprise_hook('policies_is_module_in_policy', [$id_agent_module]); $module_linked = enterprise_hook('policies_is_module_linked', [$id_agent_module]); - - if ((!$module_in_policy && !$module_linked && $update_module) - || ( $module_in_policy && !$module_linked && $update_module) - ) { - enterprise_hook( - 'config_agents_update_module_in_conf', - [ - $id_agente, - io_safe_output($old_configuration_data), - io_safe_output($configuration_data), - $disabled, - ] - ); - } else { - enterprise_hook( - 'config_agents_write_module_in_conf', - [ - $id_agente, - io_safe_output($old_configuration_data), - io_safe_output($configuration_data), - $disabled, - ] - ); - } } +// Initialize result of the action (insert or update). +$success_action = NOERR; + // MODULE UPDATE. if ($update_module) { $id_agent_module = (int) get_parameter('id_agent_module'); @@ -1589,6 +1625,8 @@ if ($update_module) { break; } + // I save the result of the action (insert or update). + $success_action = $result; $result = false; ui_print_error_message($msg); @@ -1596,7 +1634,7 @@ if ($update_module) { db_pandora_audit( 'Agent management', - "Fail to try update module '$name' for agent ".$agent['alias'] + "Fail to try update module '".$name."' for agent ".$agent['alias'] ); } else { if ($prediction_module == 3) { @@ -1620,7 +1658,7 @@ if ($update_module) { db_pandora_audit( 'Agent management', - "Updated module '$name' for agent ".$agent['alias'], + "Updated module '".$name."' for agent ".$agent['alias'], false, false, io_json_mb_encode($values) @@ -1630,6 +1668,9 @@ if ($update_module) { // MODULE INSERT. if ($create_module) { + // Old configuration data must always be empty in case of creation. + $old_configuration_data = ''; + if (isset($_POST['combo_snmp_oid'])) { $combo_snmp_oid = get_parameter_post('combo_snmp_oid'); } @@ -1639,12 +1680,6 @@ if ($create_module) { } $id_module = (int) get_parameter('id_module'); - // Commented because can't create prediction modules - /* - if ($id_module == 5) { - $prediction_module = 1; - } - */ switch ($config['dbtype']) { case 'oracle': @@ -1768,17 +1803,26 @@ if ($create_module) { break; } + // I save the result of the action (insert or update). + $success_action = $id_agent_module; + $id_agent_module = false; ui_print_error_message($msg); $edit_module = true; $moduletype = $id_module; db_pandora_audit( 'Agent management', - "Fail to try added module '$name' for agent ".$agent['alias'] + "Fail to try added module '".$name."' for agent ".$agent['alias'] ); } else { if ($prediction_module == 3) { - enterprise_hook('modules_create_synthetic_operations', [$id_agent_module, $serialize_ops]); + enterprise_hook( + 'modules_create_synthetic_operations', + [ + $id_agent_module, + $serialize_ops, + ] + ); } // Update the module interval. @@ -1793,7 +1837,7 @@ if ($create_module) { $agent = db_get_row('tagente', 'id_agente', $id_agente); db_pandora_audit( 'Agent management', - "Added module '$name' for agent ".$agent['alias'], + "Added module '".$name."' for agent ".$agent['alias'], false, true, io_json_mb_encode($values) @@ -1801,6 +1845,112 @@ if ($create_module) { } } +// MODULE ENABLE/DISABLE +// =====================. +if ($enable_module) { + $result = modules_change_disabled($enable_module, 0); + $module_name = modules_get_agentmodule_name($enable_module); + + // Write for conf disable if remote_config. + $configuration_data = enterprise_hook( + 'config_agents_get_module_from_conf', + [ + $id_agente, + io_safe_output($module_name), + ] + ); + // Force disable. + $disabled = 0; + + // Force Update when disabled for save disabled in conf. + $old_configuration_data = $configuration_data; + + // Successfull action. + $success_action = $result; + + $success_action = $result; + if ($result === NOERR) { + db_pandora_audit( + 'Module management', + 'Enable #'.$enable_module.' | '.$module_name.' | '.$agent['alias'] + ); + } else { + db_pandora_audit( + 'Module management', + 'Fail to enable #'.$enable_module.' | '.$module_name.' | '.$agent['alias'] + ); + } + + ui_print_result_message( + $result, + __('Successfully enabled'), + __('Could not be enabled') + ); +} + +if ($disable_module) { + $result = modules_change_disabled($disable_module, 1); + $module_name = modules_get_agentmodule_name($disable_module); + + // Write for conf disable if remote_config. + $configuration_data = enterprise_hook( + 'config_agents_get_module_from_conf', + [ + $id_agente, + io_safe_output($module_name), + ] + ); + // Force disable. + $disabled = 1; + + // Force Update when disabled for save disabled in conf. + $old_configuration_data = $configuration_data; + + // Successfull action. + $success_action = $result; + + + if ($result === NOERR) { + db_pandora_audit( + 'Module management', + 'Disable #'.$disable_module.' | '.$module_name.' | '.$agent['alias'] + ); + } else { + db_pandora_audit( + 'Module management', + 'Fail to disable #'.$disable_module.' | '.$module_name.' | '.$agent['alias'] + ); + } + + ui_print_result_message( + $result, + __('Successfully disabled'), + __('Could not be disabled') + ); +} + +// Fix to stop the module from being added to the agent's conf +// when an error occurred while updating or inserting. or enable disable module. +if ($update_module || $create_module + || $enable_module || $disable_module +) { + if ((!$module_in_policy && !$module_linked) + || ($module_in_policy && !$module_linked) + ) { + if ($success_action > 0) { + enterprise_hook( + 'config_agents_write_module_in_conf', + [ + $id_agente, + io_safe_output($old_configuration_data), + io_safe_output($configuration_data), + $disabled, + ] + ); + } + } +} + // MODULE DELETION // =================. if ($delete_module) { @@ -2000,46 +2150,6 @@ if (!empty($duplicate_module)) { } } -// MODULE ENABLE/DISABLE -// =====================. -if ($enable_module) { - $result = modules_change_disabled($enable_module, 0); - $modulo_nombre = db_get_row_sql('SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = '.$enable_module.''); - $modulo_nombre = $modulo_nombre['nombre']; - - if ($result === NOERR) { - enterprise_hook('config_agents_enable_module_conf', [$id_agente, $enable_module]); - db_pandora_audit('Module management', 'Enable #'.$enable_module.' | '.$modulo_nombre.' | '.$agent['alias']); - } else { - db_pandora_audit('Module management', 'Fail to enable #'.$enable_module.' | '.$modulo_nombre.' | '.$agent['alias']); - } - - ui_print_result_message( - $result, - __('Successfully enabled'), - __('Could not be enabled') - ); -} - -if ($disable_module) { - $result = modules_change_disabled($disable_module, 1); - $modulo_nombre = db_get_row_sql('SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = '.$disable_module.''); - $modulo_nombre = $modulo_nombre['nombre']; - - if ($result === NOERR) { - enterprise_hook('config_agents_disable_module_conf', [$id_agente, $disable_module]); - db_pandora_audit('Module management', 'Disable #'.$disable_module.' | '.$modulo_nombre.' | '.$agent['alias']); - } else { - db_pandora_audit('Module management', 'Fail to disable #'.$disable_module.' | '.$modulo_nombre.' | '.$agent['alias']); - } - - ui_print_result_message( - $result, - __('Successfully disabled'), - __('Could not be disabled') - ); -} - // UPDATE GIS // ==========. $updateGIS = get_parameter('update_gis', 0); diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 902d074f21..0e08a3728f 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -118,7 +118,7 @@ if ($enable_agent) { enterprise_include_once('include/functions_agents.php'); $values = ['disabled' => 0]; enterprise_hook('agent_update_from_cache', [$enable_agent, $values, $server_name]); - + config_agents_update_config_token($enable_agent, 'standby', 0); db_pandora_audit('Agent management', 'Enable '.$alias); } else { db_pandora_audit('Agent management', 'Fail to enable '.$alias); @@ -140,6 +140,7 @@ if ($disable_agent) { enterprise_include_once('include/functions_agents.php'); $values = ['disabled' => 1]; enterprise_hook('agent_update_from_cache', [$disable_agent, $values, $server_name]); + config_agents_update_config_token($disable_agent, 'standby', 1); db_pandora_audit('Agent management', 'Disable '.$alias); } else { diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index cee4825faa..b340761265 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -583,7 +583,13 @@ echo ''; // TODO: Change to the ui_print_error system echo ''; -html_print_table($table_simple); +ui_toggle( + html_print_table($table_simple, true), + __('Base options'), + '', + '', + false +); ui_toggle( html_print_table($table_advanced, true), diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index 5d6db9cfdf..fbdd620f77 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -81,7 +81,6 @@ function add_component_selection($id_network_component_type) $data = []; $data[0] = __('Using module component').' '; - $data[0] .= ui_print_help_icon('network_component', true); $component_groups = network_components_get_groups($id_network_component_type); $data[1] = ''; @@ -163,7 +162,7 @@ $edit_module = (bool) get_parameter_get('edit_module'); $table_simple = new stdClass(); $table_simple->id = 'simple'; $table_simple->width = '100%'; -$table_simple->class = 'databox'; +$table_simple->class = 'no-class'; $table_simple->data = []; $table_simple->style = []; $table_simple->style[0] = 'font-weight: bold; width: 25%;'; @@ -384,7 +383,7 @@ if ($disabledBecauseInPolicy) { $table_simple->data[2][3] .= html_print_input_hidden('id_module_group', $id_module_group, true); } -$table_simple->data[3][0] = __('Dynamic Threshold Interval').' '.ui_print_help_icon('dynamic_threshold', true); +$table_simple->data[3][0] = __('Dynamic Threshold Interval'); $table_simple->data[3][1] = html_print_extended_select_for_time('dynamic_interval', $dynamic_interval, '', 'None', '0', 10, true, 'width:150px', false, $classdisabledBecauseInPolicy, $disabledBecauseInPolicy); $table_simple->data[3][1] .= ''.html_print_image('images/cog.png', true, ['title' => __('Advanced options Dynamic Threshold')]).''; if ($in_policy) { @@ -424,7 +423,7 @@ $table_simple->data[3][2] .= html_print_input_text( $table_simple->data[3][3] = ''.__('Dynamic Threshold Two Tailed: ').''; $table_simple->data[3][3] .= html_print_checkbox('dynamic_two_tailed', 1, $dynamic_two_tailed, true, $disabledBecauseInPolicy); -$table_simple->data[4][0] = __('Warning status').' '.ui_print_help_icon('warning_status', true); +$table_simple->data[4][0] = __('Warning status'); if (!modules_is_string_type($id_module_type) || $edit) { $table_simple->data[4][1] .= ''.__('Min. ').''; $table_simple->data[4][1] .= html_print_input_text( @@ -477,7 +476,7 @@ if (!modules_is_string_type($id_module_type) || $edit) { $table_simple->data[4][2] = ' '; } -$table_simple->data[5][0] = __('Critical status').' '.ui_print_help_icon('critical_status', true); +$table_simple->data[5][0] = __('Critical status'); if (!modules_is_string_type($id_module_type) || $edit) { $table_simple->data[5][1] .= ''.__('Min. ').''; $table_simple->data[5][1] .= html_print_input_text( @@ -528,7 +527,6 @@ $table_simple->data[5][1] .= html_print_checkbox('critical_inverse', 1, $critica // FF stands for Flip-flop. $table_simple->data[6][0] = __('FF threshold').' '; -$table_simple->data[6][0] .= ui_print_help_icon('ff_threshold', true); $table_simple->data[6][1] .= __('Keep counters'); $table_simple->data[6][1] .= html_print_checkbox( @@ -639,7 +637,7 @@ if ($disabledBecauseInPolicy) { $table_advanced = new stdClass(); $table_advanced->id = 'advanced'; $table_advanced->width = '100%'; -$table_advanced->class = 'databox filters'; +$table_advanced->class = 'no-class'; $table_advanced->data = []; $table_advanced->style = []; $table_advanced->style[0] = $table_advanced->style[3] = $table_advanced->style[5] = 'font-weight: bold;'; @@ -703,15 +701,15 @@ if ($moduletype == MODULE_DATA) { if (isset($id_agente)) { $agent_interval = agents_get_interval($id_agente); $interval_factor = ($interval / $agent_interval); - $table_advanced->data[2][1] = human_time_description_raw($interval).' ('.sprintf(__('Agent interval x %s'), $interval_factor).') '.ui_print_help_icon('module_interval_factor', true); + $table_advanced->data[2][1] = human_time_description_raw($interval).' ('.sprintf(__('Agent interval x %s'), $interval_factor).') '; } else { - $table_advanced->data[2][1] = sprintf(__('Agent interval x %s'), $interval_factor).ui_print_help_icon('module_interval_factor', true); + $table_advanced->data[2][1] = sprintf(__('Agent interval x %s'), $interval_factor); } if ($__code_from == 'policies') { // If is the policy form, module_interval will store the factor (not the seconds). // So server will transform it to interval in seconds - $table_advanced->data[2][1] = sprintf(__('Default').': 1', $interval_factor).ui_print_help_icon('module_interval_factor', true); + $table_advanced->data[2][1] = sprintf(__('Default').': 1', $interval_factor); $table_advanced->data[2][1] .= html_print_input_hidden('module_interval', $interval_factor, true); } else if ($module_id_policy_module != 0) { $table_advanced->data[2][1] .= ui_print_help_tip(__('The policy modules of data type will only update their intervals when policy is applied.'), true); @@ -720,14 +718,14 @@ if ($moduletype == MODULE_DATA) { // If it is a non policy form, the module_interval will not provided and will // be taken the agent interval (this code is at configurar_agente.php) } else { - $table_advanced->data[2][0] = __('Interval').ui_print_help_icon('module_interval', true); + $table_advanced->data[2][0] = __('Interval'); $table_advanced->colspan[2][1] = 2; $table_advanced->data[2][1] = html_print_extended_select_for_time('module_interval', $interval, '', '', '0', false, true, false, false, $classdisabledBecauseInPolicy, $disabledBecauseInPolicy); } $table_advanced->data[2][1] .= html_print_input_hidden('moduletype', $moduletype, true); -$table_advanced->data[2][3] = __('Post process').' '.ui_print_help_icon('postprocess', true); +$table_advanced->data[2][3] = __('Post process'); $table_advanced->data[2][4] = html_print_extended_select_for_post_process( 'post_process', $post_process, @@ -793,7 +791,7 @@ $table_advanced->data[4][4] = html_print_checkbox( ); $table_advanced->colspan[4][4] = 3; -$table_advanced->data[5][0] = __('FF interval').' '.ui_print_help_icon('ff_interval', true); +$table_advanced->data[5][0] = __('FF interval'); $table_advanced->data[5][1] = html_print_input_text( 'module_ff_interval', $ff_interval, @@ -808,7 +806,7 @@ $table_advanced->data[5][1] = html_print_input_text( ).ui_print_help_tip(__('Module execution flip flop time interval (in secs).'), true); $table_advanced->colspan[5][1] = 2; -$table_advanced->data[5][3] = __('FF timeout').' '.ui_print_help_icon('ff_timeout', true); +$table_advanced->data[5][3] = __('FF timeout'); $module_type_name = modules_get_type_name($id_module_type); $table_advanced->data[5][4] = ''; @@ -1010,7 +1008,7 @@ $table_advanced->colspan[10][1] = 6; if (isset($id_agente) && $moduletype == MODULE_DATA) { $has_remote_conf = enterprise_hook('config_agents_has_remote_configuration', [$agent['id_agente']]); if ($has_remote_conf) { - $table_advanced->data[11][0] = __('Cron from').ui_print_help_icon('cron', true); + $table_advanced->data[11][0] = __('Cron from'); $table_advanced->data[11][1] = html_print_extended_select_for_cron($hour_from, $minute_from, $mday_from, $month_from, $wday_from, true, $disabledBecauseInPolicy); $table_advanced->colspan[11][1] = 6; @@ -1018,7 +1016,7 @@ if (isset($id_agente) && $moduletype == MODULE_DATA) { $table_advanced->data[12][1] = html_print_extended_select_for_cron($hour_to, $minute_to, $mday_to, $month_to, $wday_to, true, $disabledBecauseInPolicy, true); $table_advanced->colspan[12][1] = 6; } else { - $table_advanced->data[11][0] = __('Cron from').ui_print_help_icon('cron', true); + $table_advanced->data[11][0] = __('Cron from'); $table_advanced->data[11][1] = html_print_extended_select_for_cron($hour_from, $minute_from, $mday_from, $month_from, $wday_from, true, true); $table_advanced->colspan[11][1] = 6; @@ -1027,7 +1025,7 @@ if (isset($id_agente) && $moduletype == MODULE_DATA) { $table_advanced->colspan[12][1] = 6; } } else { - $table_advanced->data[11][0] = __('Cron from').ui_print_help_icon('cron', true); + $table_advanced->data[11][0] = __('Cron from'); $table_advanced->data[11][1] = html_print_extended_select_for_cron($hour_from, $minute_from, $mday_from, $month_from, $wday_from, true, $disabledBecauseInPolicy); $table_advanced->colspan[11][1] = 6; @@ -1068,7 +1066,7 @@ if (check_acl($config['id_user'], 0, 'PM')) { $table_macros = new stdClass(); $table_macros->id = 'module_macros'; $table_macros->width = '100%'; -$table_macros->class = 'databox filters'; +$table_macros->class = 'no-class'; $table_macros->data = []; $table_macros->style = []; $table_macros->style[0] = 'font-weight: bold;'; @@ -1109,7 +1107,7 @@ html_print_input_hidden('module_macro_count', $macro_count); $table_new_relations = new stdClass(); $table_new_relations->id = 'module_new_relations'; $table_new_relations->width = '100%'; -$table_new_relations->class = 'databox filters'; +$table_new_relations->class = 'no-class'; $table_new_relations->data = []; $table_new_relations->style = []; $table_new_relations->style[0] = 'width: 10%; font-weight: bold;'; diff --git a/pandora_console/godmode/agentes/module_manager_editor_network.php b/pandora_console/godmode/agentes/module_manager_editor_network.php index 11402c8ca6..306e5f9804 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_network.php +++ b/pandora_console/godmode/agentes/module_manager_editor_network.php @@ -128,7 +128,7 @@ $snmp_versions['2c'] = 'v. 2c'; $snmp_versions['3'] = 'v. 3'; $data = []; -$data[0] = __('SNMP community').ui_print_help_icon('column_macros', true); +$data[0] = __('SNMP community'); $adopt = false; if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK && isset($id_agent_module)) { $adopt = policies_is_module_adopt($id_agent_module); @@ -233,7 +233,7 @@ push_table_simple($data, 'snmp_2'); // Advanced stuff $data = []; -$data[0] = __('TCP send').' '.ui_print_help_icon('tcp_send', true); +$data[0] = __('TCP send'); $data[1] = html_print_textarea('tcp_send', 2, 65, $tcp_send, $disabledTextBecauseInPolicy, true, $largeclassdisabledBecauseInPolicy); $table_simple->colspan['tcp_send'][1] = 3; @@ -277,7 +277,7 @@ if (!isset($id_agent_module)) { } $data = []; -$data[0] = __('Auth user').ui_print_help_icon('column_macros', true); +$data[0] = __('Auth user'); $data[1] = html_print_input_text( 'snmp3_auth_user', $snmp3_auth_user, @@ -290,7 +290,7 @@ $data[1] = html_print_input_text( '', $classdisabledBecauseInPolicy ); -$data[2] = __('Auth password').ui_print_help_icon('column_macros', true).ui_print_help_tip(__('The pass length must be eight character minimum.'), true); +$data[2] = __('Auth password').ui_print_help_tip(__('The pass length must be eight character minimum.'), true); $data[3] = html_print_input_password( 'snmp3_auth_pass', $snmp3_auth_pass, @@ -312,7 +312,7 @@ push_table_simple($data, 'field_snmpv3_row1'); $data = []; $data[0] = __('Privacy method'); $data[1] = html_print_select(['DES' => __('DES'), 'AES' => __('AES')], 'snmp3_privacy_method', $snmp3_privacy_method, '', '', '', true, false, false, '', $disabledBecauseInPolicy); -$data[2] = __('Privacy pass').ui_print_help_icon('column_macros', true).ui_print_help_tip(__('The pass length must be eight character minimum.'), true); +$data[2] = __('Privacy pass').ui_print_help_tip(__('The pass length must be eight character minimum.'), true); $data[3] = html_print_input_password( 'snmp3_privacy_pass', $snmp3_privacy_pass, diff --git a/pandora_console/godmode/agentes/module_manager_editor_plugin.php b/pandora_console/godmode/agentes/module_manager_editor_plugin.php index 6b39172bca..f8fbd46c73 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_plugin.php +++ b/pandora_console/godmode/agentes/module_manager_editor_plugin.php @@ -79,7 +79,7 @@ push_table_simple($data, 'plugin_1'); $data = []; $data[0] = 'macro_desc'; $data[0] .= ui_print_help_tip('macro_help', true); -$data[1] = html_print_input_text('macro_name', 'macro_value', '', 100, 1024, true); +$data[1] = html_print_input_text('macro_name[]', 'macro_value', '', 100, 1024, true); $table_simple->colspan['macro_field'][1] = 3; $table_simple->rowstyle['macro_field'] = 'display:none'; diff --git a/pandora_console/godmode/agentes/module_manager_editor_wmi.php b/pandora_console/godmode/agentes/module_manager_editor_wmi.php index 5c89c11d9e..09501c358b 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_wmi.php +++ b/pandora_console/godmode/agentes/module_manager_editor_wmi.php @@ -60,7 +60,7 @@ $data[3] = html_print_input_text( push_table_simple($data, 'target_ip'); $data = []; -$data[0] = __('Username').ui_print_help_icon('column_macros', true); +$data[0] = __('Username'); $data[1] = html_print_input_text( 'plugin_user', $plugin_user, @@ -73,7 +73,7 @@ $data[1] = html_print_input_text( '', $classdisabledBecauseInPolicy ); -$data[2] = __('Password').ui_print_help_icon('column_macros', true); +$data[2] = __('Password'); $data[3] = html_print_input_password( 'plugin_pass', $plugin_pass, @@ -83,15 +83,14 @@ $data[3] = html_print_input_password( true, $disabledBecauseInPolicy, false, - '', - $classdisabledBecauseInPolicy + $classdisabledBecauseInPolicy, + 'new-password' ); push_table_simple($data, 'user_pass'); $data = []; $data[0] = __('WMI query'); -$data[0] .= ui_print_help_icon('wmiquery', true); $data[1] = html_print_input_text( 'snmp_oid', $snmp_oid, diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index 799eddcec6..7fa2b9a3f0 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -84,9 +84,7 @@ if (is_ajax()) { // If the field is the number one, print the help message. if ($i == 1) { // If our context is snmpconsole, show snmp_alert helps. - if ((isset($_SERVER['HTTP_REFERER'])) && ( preg_match('/snmp_alert/', $_SERVER['HTTP_REFERER']) > 0 )) { - $fdesc .= ui_print_help_icon('snmp_alert_field1', true); - } else { + if ((!isset($_SERVER['HTTP_REFERER'])) && ( preg_match('/snmp_alert/', $_SERVER['HTTP_REFERER']) > 0 )) { $fdesc .= ui_print_help_icon('alert_config', true); } } diff --git a/pandora_console/godmode/alerts/alert_list.builder.php b/pandora_console/godmode/alerts/alert_list.builder.php index ca3a099bf3..c97fe2feff 100644 --- a/pandora_console/godmode/alerts/alert_list.builder.php +++ b/pandora_console/godmode/alerts/alert_list.builder.php @@ -37,14 +37,10 @@ $table->head = []; $table->data = []; $table->size = []; $table->size = []; -$table->size[0] = '5%'; -$table->size[1] = '25%'; -$table->size[2] = '5%'; -$table->size[3] = '20%'; -$table->style[0] = 'font-weight: bold; '; -$table->style[1] = 'font-weight: bold; '; -$table->style[2] = 'font-weight: bold; '; -$table->style[3] = 'font-weight: bold; '; +$table->style[0] = 'font-weight: bold;'; +$table->style[1] = 'font-weight: bold;display: flex;align-items: baseline;'; +$table->style[2] = 'font-weight: bold;'; +$table->style[3] = 'font-weight: bold;'; // This is because if this view is reused after list alert view then // styles in the previous view can affect this table. @@ -89,7 +85,7 @@ $table->data[0][1] = html_print_select( true, '', ($id_agente == 0), - 'width: 250px;' + 'min-width: 250px;margin-right: 0.5em;' ); $table->data[0][1] .= ' '; @@ -117,7 +113,7 @@ $table->data[1][1] = html_print_select( true, '', false, - 'width: 250px;' + 'min-width: 250px;' ); $table->data[1][1] .= ''; if (check_acl($config['id_user'], 0, 'LM')) { - $table->data[1][1] .= ''; + $table->data[1][1] .= ''; $table->data[1][1] .= html_print_image('images/add.png', true); - $table->data[1][1] .= ''.__('Create Action').''; + $table->data[1][1] .= ''.__('Create Action').''; $table->data[1][1] .= ''; } @@ -162,13 +158,13 @@ if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) { if (check_acl($config['id_user'], 0, 'LM')) { $table->data[2][1] .= ''; $table->data[2][1] .= html_print_image('images/add.png', true); - $table->data[2][1] .= ''.__('Create Template').''; + $table->data[2][1] .= ''.__('Create Template').''; $table->data[2][1] .= ''; } $table->data[3][0] = __('Threshold'); $table->data[3][1] = html_print_input_text('module_action_threshold', '0', '', 5, 7, true); - $table->data[3][1] .= ' '.__('seconds'); + $table->data[3][1] .= ''.__('seconds').''; if (!isset($step)) { echo ''; diff --git a/pandora_console/godmode/alerts/alert_list.list.php b/pandora_console/godmode/alerts/alert_list.list.php index 4b3a3395cf..f830f47dbd 100644 --- a/pandora_console/godmode/alerts/alert_list.list.php +++ b/pandora_console/godmode/alerts/alert_list.list.php @@ -438,11 +438,11 @@ if (! $id_agente) { $table->style = []; $table->style[0] = 'font-weight: bold;'; $table->head[0] = __('Agent').ui_get_sorting_arrows($url_up_agente, $url_down_agente, $selectAgentUp, $selectAgentDown); - $table->size[0] = '4%'; - $table->size[1] = '8%'; - $table->size[2] = '8%'; - $table->size[3] = '4%'; - $table->size[4] = '4%'; + $table->headstyle[0] = 'width: 100%; min-width: 12em;'; + $table->headstyle[1] = 'min-width: 15em;'; + $table->headstyle[2] = 'min-width: 20em;'; + $table->headstyle[3] = 'min-width: 1em;'; + $table->headstyle[4] = 'min-width: 15em;'; /* if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { @@ -450,16 +450,11 @@ if (! $id_agente) { }*/ } else { $table->head[0] = __('Module').ui_get_sorting_arrows($url_up_module, $url_down_module, $selectModuleUp, $selectModuleDown); - // Different sizes or the layout screws up - $table->size[0] = '0%'; - $table->size[1] = '10%'; - $table->size[2] = '30%'; - /* - if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { - $table->size[4] = '25%'; - } */ - $table->size[3] = '1%'; - $table->size[4] = '1%'; + $table->headstyle[0] = 'width: 100%; min-width: 15em;'; + $table->headstyle[1] = 'min-width: 15em;'; + $table->headstyle[2] = 'min-width: 20em;'; + $table->headstyle[3] = 'min-width: 1em;'; + $table->headstyle[4] = 'min-width: 15em;'; } $table->head[1] = __('Template').ui_get_sorting_arrows($url_up_template, $url_down_template, $selectTemplateUp, $selectTemplateDown); diff --git a/pandora_console/godmode/alerts/alert_view.php b/pandora_console/godmode/alerts/alert_view.php index 6de5473020..f96f6e6644 100644 --- a/pandora_console/godmode/alerts/alert_view.php +++ b/pandora_console/godmode/alerts/alert_view.php @@ -386,7 +386,7 @@ if (count($actions) == 1 && isset($actions[0])) { $table->data[$kaction][($k + 1)] = human_time_description_raw($action_threshold, true, 'tiny'); } - $table->head[($k + 1)] = __('Threshold').''.ui_print_help_icon('action_threshold', true, '', 'images/header_help.png').''; + $table->head[($k + 1)] = __('Threshold'); } } diff --git a/pandora_console/godmode/events/custom_events.php b/pandora_console/godmode/events/custom_events.php index 0bf3b223e2..bfb0e8c64d 100644 --- a/pandora_console/godmode/events/custom_events.php +++ b/pandora_console/godmode/events/custom_events.php @@ -60,96 +60,12 @@ $fields_selected = explode(',', $config['event_fields']); $result_selected = []; -// show list of fields selected. +// Show list of fields selected. if ($fields_selected[0] != '') { foreach ($fields_selected as $field_selected) { - switch ($field_selected) { - case 'id_evento': - $result = __('Event Id'); - break; - - case 'evento': - $result = __('Event Name'); - break; - - case 'id_agente': - $result = __('Agent Name'); - break; - - case 'id_usuario': - $result = __('User'); - break; - - case 'id_grupo': - $result = __('Group'); - break; - - case 'estado': - $result = __('Status'); - break; - - case 'timestamp': - $result = __('Timestamp'); - break; - - case 'event_type': - $result = __('Event Type'); - break; - - case 'id_agentmodule': - $result = __('Module Name'); - break; - - case 'id_alert_am': - $result = __('Alert'); - break; - - case 'criticity': - $result = __('Severity'); - break; - - case 'user_comment': - $result = __('Comment'); - break; - - case 'tags': - $result = __('Tags'); - break; - - case 'source': - $result = __('Source'); - break; - - case 'id_extra': - $result = __('Extra Id'); - break; - - case 'owner_user': - $result = __('Owner'); - break; - - case 'ack_utimestamp': - $result = __('ACK Timestamp'); - break; - - case 'instructions': - $result = __('Instructions'); - break; - - case 'server_name': - $result = __('Server Name'); - break; - - case 'data': - $result = __('Data'); - break; - - case 'module_status': - $result = __('Module Status'); - break; - } - - $result_selected[$field_selected] = $result; + $result_selected[$field_selected] = events_get_column_name( + $field_selected + ); } } @@ -177,7 +93,8 @@ $fields_available = []; $fields_available['id_evento'] = __('Event Id'); $fields_available['evento'] = __('Event Name'); -$fields_available['id_agente'] = __('Agent Name'); +$fields_available['id_agente'] = __('Agent ID'); +$fields_available['agent_name'] = __('Agent Name'); $fields_available['id_usuario'] = __('User'); $fields_available['id_grupo'] = __('Group'); $fields_available['estado'] = __('Status'); @@ -197,12 +114,10 @@ $fields_available['server_name'] = __('Server Name'); $fields_available['data'] = __('Data'); $fields_available['module_status'] = __('Module Status'); -// remove fields already selected +// Remove fields already selected. foreach ($fields_available as $key => $available) { - foreach ($result_selected as $selected) { - if ($selected == $available) { - unset($fields_available[$key]); - } + if (isset($result_selected[$key])) { + unset($fields_available[$key]); } } diff --git a/pandora_console/godmode/gis_maps/configure_gis_map.php b/pandora_console/godmode/gis_maps/configure_gis_map.php index 0e632380ce..8277463e18 100644 --- a/pandora_console/godmode/gis_maps/configure_gis_map.php +++ b/pandora_console/godmode/gis_maps/configure_gis_map.php @@ -357,8 +357,8 @@ function addConnectionMap() { for (var index in connectionMaps) { if (isInt(index)) { if (connectionMaps[index] == idConnectionMap) { - alert(" "' + connectionMapName + '" "); - + alert(" " + connectionMapName + " "); + return; } } diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index dfd2fbc30d..ee61cdaf79 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -516,14 +516,22 @@ if ($tab == 'tree') { $table = new StdClass(); $table->width = '100%'; $table->class = 'info_table'; + $table->headstyle = []; $table->head = []; $table->head[0] = __('ID'); + $table->headstyle[0] = 'min-width: 100px;'; $table->head[1] = __('Name'); + $table->headstyle[1] = 'min-width: 100px;'; $table->head[2] = __('Icon'); + $table->headstyle[2] = 'min-width: 100px;'; $table->head[3] = __('Alerts'); + $table->headstyle[3] = 'min-width: 100px;'; $table->head[4] = __('Parent'); + $table->headstyle[4] = 'min-width: 100px;'; $table->head[5] = __('Description'); + $table->headstyle[5] = 'min-width: 100px;'; $table->head[6] = __('Actions'); + $table->headstyle[6] = 'min-width: 100px;'; $table->align = []; $table->align[0] = 'left'; $table->align[2] = 'left'; diff --git a/pandora_console/godmode/massive/massive_add_action_alerts.php b/pandora_console/godmode/massive/massive_add_action_alerts.php index 919380c9a9..9abac11def 100755 --- a/pandora_console/godmode/massive/massive_add_action_alerts.php +++ b/pandora_console/godmode/massive/massive_add_action_alerts.php @@ -215,7 +215,6 @@ $table->data[3][1] .= __('Number of alerts match from').' '; $table->data[3][1] .= html_print_input_text('fires_min', 0, '', 4, 10, true); $table->data[3][1] .= ' '.__('to').' '; $table->data[3][1] .= html_print_input_text('fires_max', 0, '', 4, 10, true); -$table->data[3][1] .= ui_print_help_icon('alert-matches', true); $table->data[3][1] .= ''; echo ''; diff --git a/pandora_console/godmode/massive/massive_copy_modules.php b/pandora_console/godmode/massive/massive_copy_modules.php index 00c76792e4..b79a64460e 100755 --- a/pandora_console/godmode/massive/massive_copy_modules.php +++ b/pandora_console/godmode/massive/massive_copy_modules.php @@ -125,7 +125,7 @@ echo ''; echo ''; -echo ''.__('Source').ui_print_help_icon('manageconfig', true).''; +echo ''.__('Source'); echo ''; html_print_table($table); echo ''; diff --git a/pandora_console/godmode/massive/massive_edit_modules.php b/pandora_console/godmode/massive/massive_edit_modules.php index ae6b5b1432..a803fa4725 100755 --- a/pandora_console/godmode/massive/massive_edit_modules.php +++ b/pandora_console/godmode/massive/massive_edit_modules.php @@ -695,7 +695,7 @@ $table->data['edit1'][1] = ''; true ); - $table->data['edit3'][0] = __('Post process').ui_print_help_icon('postprocess', true); + $table->data['edit3'][0] = __('Post process'); $table->data['edit3'][1] = html_print_extended_select_for_post_process( 'post_process', @@ -846,10 +846,6 @@ $table->data['edit1'][1] = '
'; // FF stands for Flip-flop. $table->data['edit7'][0] = __('FF threshold').' '; - $table->data['edit7'][0] .= ui_print_help_icon( - 'ff_threshold', - true - ); $table->colspan['edit7'][1] = 3; $table->data['edit7'][1] = __('Mode').' '; @@ -1060,26 +1056,26 @@ $table->data['edit1'][1] = '
'; true ); - $table->data['edit22'][0] = __('Web checks').ui_print_help_icon('web_checks', true); + $table->data['edit22'][0] = __('Web checks'); ; $table->data['edit22'][1] = ''; $table->data['edit16'][2] = __('Port'); $table->data['edit16'][3] = html_print_input_text('tcp_port', '', '', 5, 20, true); - $table->data['edit17'][0] = __('TCP send').' '.ui_print_help_icon('tcp_send', true); + $table->data['edit17'][0] = __('TCP send'); $table->data['edit17'][1] = html_print_textarea('tcp_send2', 2, 65, '', '', true); $table->data['edit17'][2] = __('TCP receive'); $table->data['edit17'][3] = html_print_textarea('tcp_rcv', 2, 65, '', '', true); - $table->data['edit18'][0] = __('WMI query').ui_print_help_icon('wmiquery', true); + $table->data['edit18'][0] = __('WMI query'); $table->data['edit18'][1] = html_print_input_text('wmi_query', '', '', 35, 255, true); $table->data['edit18'][2] = __('Key string'); $table->data['edit18'][3] = html_print_input_text('key_string', '', '', 20, 60, true); - $table->data['edit19'][0] = __('Field number').ui_print_help_icon('wmifield', true); + $table->data['edit19'][0] = __('Field number'); $table->data['edit19'][1] = html_print_input_text('field_number', '', '', 5, 15, true); $table->data['edit20'][0] = __('Plugin').ui_print_help_icon('plugin_macros', true); diff --git a/pandora_console/godmode/massive/massive_edit_plugins.php b/pandora_console/godmode/massive/massive_edit_plugins.php index 48688ded8d..7513c99eb9 100644 --- a/pandora_console/godmode/massive/massive_edit_plugins.php +++ b/pandora_console/godmode/massive/massive_edit_plugins.php @@ -725,7 +725,6 @@ echo ''; } }); - $modulesSelect.change(); } var processGet = function (params, callback) { diff --git a/pandora_console/godmode/massive/massive_operations.php b/pandora_console/godmode/massive/massive_operations.php index 70d82c3af4..9e81bd3aaa 100755 --- a/pandora_console/godmode/massive/massive_operations.php +++ b/pandora_console/godmode/massive/massive_operations.php @@ -72,6 +72,7 @@ if (! check_acl($config['id_user'], 0, 'AW')) { $options_policies = []; $policies_options = enterprise_hook('massive_policies_options'); +$policies_options = array_unique($policies_options); if ($policies_options != ENTERPRISE_NOT_HOOK) { $options_policies = array_merge($options_policies, $policies_options); diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index ac3154b657..bd980f5256 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -418,9 +418,11 @@ if (is_array($config['extensions'])) { $sub['godmode/extensions']['type'] = 'direct'; $sub['godmode/extensions']['subtype'] = 'nolink'; - $submenu = array_merge($menu_godmode['gextensions']['sub'], $sub); - if ($menu_godmode['gextensions']['sub'] != null) { - $menu_godmode['gextensions']['sub'] = $submenu; + if (is_array($menu_godmode['gextensions']['sub'])) { + $submenu = array_merge($menu_godmode['gextensions']['sub'], $sub); + if ($menu_godmode['gextensions']['sub'] != null) { + $menu_godmode['gextensions']['sub'] = $submenu; + } } } @@ -457,19 +459,6 @@ if (check_acl($config['id_user'], 0, 'PM') && $config['enable_update_manager']) $sub['godmode/update_manager/update_manager&tab=setup']['text'] = __('Update Manager options'); $sub['godmode/update_manager/update_manager&tab=setup']['id'] = 'Options'; - if (license_free() && is_user_admin($config['id_user'])) { - include_once 'include/functions_update_manager.php'; - // If there are unread messages, display the notification icon - $number_total_messages; - $number_unread_messages = update_manager_get_unread_messages(); - if ($number_unread_messages > 0) { - $menu_godmode['messages']['notification'] = $number_unread_messages; - } - - $sub['godmode/update_manager/update_manager&tab=messages']['text'] = __('Messages'); - $sub['godmode/update_manager/update_manager&tab=messages']['id'] = 'Messages'; - } - $menu_godmode['messages']['sub'] = $sub; } diff --git a/pandora_console/godmode/modules/manage_network_components.php b/pandora_console/godmode/modules/manage_network_components.php index 82cd02d771..60d39d26d9 100644 --- a/pandora_console/godmode/modules/manage_network_components.php +++ b/pandora_console/godmode/modules/manage_network_components.php @@ -36,6 +36,9 @@ require_once $config['homedir'].'/include/functions_component_groups.php'; if (defined('METACONSOLE')) { components_meta_print_header(); $sec = 'advanced'; + + $id_modulo = (int) get_parameter('id_component_type'); + $new_component = (bool) get_parameter('new_component'); } else { /* Hello there! :) diff --git a/pandora_console/godmode/modules/manage_network_components_form_common.php b/pandora_console/godmode/modules/manage_network_components_form_common.php index 0d52a01377..2a55efb1dd 100644 --- a/pandora_console/godmode/modules/manage_network_components_form_common.php +++ b/pandora_console/godmode/modules/manage_network_components_form_common.php @@ -154,7 +154,7 @@ $table->data[2][1] = html_print_select( $table->data[2][2] = __('Interval'); $table->data[2][3] = html_print_extended_select_for_time('module_interval', $module_interval, '', '', '0', false, true); -$table->data[3][0] = __('Dynamic Interval').' '.ui_print_help_icon('dynamic_threshold', true); +$table->data[3][0] = __('Dynamic Interval'); $table->data[3][1] = html_print_extended_select_for_time('dynamic_interval', $dynamic_interval, '', 'None', '0', 10, true, 'width:150px', false); $table->data[3][1] .= ''.html_print_image('images/cog.png', true, ['title' => __('Advanced options Dynamic Threshold')]).''; @@ -165,7 +165,7 @@ $table->data[3][2] .= html_print_input_text('dynamic_max', $dynamic_max, '', 10, $table->data[3][3] = ''.__('Dynamic Two Tailed: ').''; $table->data[3][3] .= html_print_checkbox('dynamic_two_tailed', 1, $dynamic_two_tailed, true); -$table->data[4][0] = __('Warning status').' '.ui_print_help_icon('warning_status', true); +$table->data[4][0] = __('Warning status'); $table->data[4][1] = ''.__('Min.').'  '; $table->data[4][1] .= html_print_input_text( 'min_warning', @@ -200,7 +200,7 @@ $table->data[4][2] = ' '; $table->colspan[4][2] = 2; $table->rowspan[4][2] = 3; -$table->data[5][0] = __('Critical status').' '.ui_print_help_icon('critical_status', true); +$table->data[5][0] = __('Critical status'); $table->data[5][1] = ''.__('Min.').'  '; $table->data[5][1] .= html_print_input_text( 'min_critical', @@ -231,7 +231,7 @@ $table->data[5][1] .= html_print_input_text( $table->data[5][1] .= '
'.__('Inverse interval').''; $table->data[5][1] .= html_print_checkbox('critical_inverse', 1, $critical_inverse, true); -$table->data[6][0] = __('FF threshold').' '.ui_print_help_icon('ff_threshold', true); +$table->data[6][0] = __('FF threshold'); $table->colspan[6][1] = 3; $table->data[6][1] = __('Keep counters'); diff --git a/pandora_console/godmode/modules/manage_network_components_form_network.php b/pandora_console/godmode/modules/manage_network_components_form_network.php index 8befa28555..0f39406ce9 100755 --- a/pandora_console/godmode/modules/manage_network_components_form_network.php +++ b/pandora_console/godmode/modules/manage_network_components_form_network.php @@ -57,16 +57,16 @@ $data = []; $data[0] = __('SNMP Enterprise String'); $data[1] = html_print_input_text('snmp_oid', $snmp_oid, '', 30, 400, true); // $table->colspan['snmp_2'][1] = 3; -$data[2] = __('SNMP community').ui_print_help_icon('column_macros', true); +$data[2] = __('SNMP community'); $data[3] = html_print_input_text('snmp_community', $snmp_community, '', 15, 60, true); push_table_row($data, 'snmp_2'); $data = []; -$data[0] = __('Auth user').ui_print_help_icon('column_macros', true); +$data[0] = __('Auth user'); $data[1] = html_print_input_text('snmp3_auth_user', $snmp3_auth_user, '', 15, 60, true); -$data[2] = __('Auth password').ui_print_help_icon('column_macros', true); +$data[2] = __('Auth password'); $data[3] = html_print_input_password('snmp3_auth_pass', $snmp3_auth_pass, '', 15, 60, true); $data[3] .= html_print_input_hidden_extended('active_snmp_v3', 0, 'active_snmp_v3_mncfn', true); push_table_row($data, 'field_snmpv3_row1'); @@ -74,7 +74,7 @@ push_table_row($data, 'field_snmpv3_row1'); $data = []; $data[0] = __('Privacy method'); $data[1] = html_print_select(['DES' => __('DES'), 'AES' => __('AES')], 'snmp3_privacy_method', $snmp3_privacy_method, '', '', '', true); -$data[2] = __('Privacy pass').ui_print_help_icon('column_macros', true); +$data[2] = __('Privacy pass'); $data[3] = html_print_input_password('snmp3_privacy_pass', $snmp3_privacy_pass, '', 15, 60, true); push_table_row($data, 'field_snmpv3_row2'); @@ -98,7 +98,7 @@ $data[3] = html_print_select( push_table_row($data, 'field_snmpv3_row3'); $data = []; -$data[0] = __('Post process').' '.ui_print_help_icon('postprocess', true); +$data[0] = __('Post process'); $data[1] = html_print_extended_select_for_post_process( 'post_process', $post_process, @@ -117,7 +117,7 @@ push_table_row($data, 'field_process'); // Advanced stuff $data = []; -$data[0] = __('TCP send').' '.ui_print_help_icon('tcp_send', true); +$data[0] = __('TCP send'); $data[1] = html_print_textarea('tcp_send', 2, 65, $tcp_send, '', true); $table->colspan['tcp_send'][1] = 3; diff --git a/pandora_console/godmode/modules/manage_network_components_form_plugin.php b/pandora_console/godmode/modules/manage_network_components_form_plugin.php index edbabe69eb..19d3c45e8f 100755 --- a/pandora_console/godmode/modules/manage_network_components_form_plugin.php +++ b/pandora_console/godmode/modules/manage_network_components_form_plugin.php @@ -31,7 +31,7 @@ $data[1] = html_print_select_from_sql( ); // 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[2] = __('Post process').' '.ui_print_help_icon('postprocess', true, ui_get_full_url(false, false, false, false)); +$data[2] = __('Post process'); $data[3] = html_print_extended_select_for_post_process( 'post_process', $post_process, diff --git a/pandora_console/godmode/modules/manage_network_components_form_wmi.php b/pandora_console/godmode/modules/manage_network_components_form_wmi.php index 09681b34c8..e76d3c086a 100755 --- a/pandora_console/godmode/modules/manage_network_components_form_wmi.php +++ b/pandora_console/godmode/modules/manage_network_components_form_wmi.php @@ -30,29 +30,29 @@ require_once $config['homedir'].'/include/functions_modules.php'; $data = []; $data[0] = __('WMI query').' '.ui_print_help_icon('wmi_query_tab', true); $data[1] = html_print_input_text('snmp_oid', $snmp_oid, '', 25, 255, true); -$data[2] = __('Key string').' '.ui_print_help_icon('wmikey', true, ui_get_full_url(false, false, false, false)); +$data[2] = __('Key string'); $data[3] = html_print_input_text('snmp_community', $snmp_community, '', 25, 255, true); push_table_row($data, 'wmi_1'); $data = []; -$data[0] = __('Field number').' '.ui_print_help_icon('wmifield', true, ui_get_full_url(false, false, false, false)); +$data[0] = __('Field number'); $data[1] = html_print_input_text('tcp_port', $tcp_port, '', 5, 25, true); -$data[2] = __('Namespace').' '.ui_print_help_icon('wminamespace', true, ui_get_full_url(false, false, false, false)); +$data[2] = __('Namespace'); $data[3] = html_print_input_text('tcp_send', $tcp_send, '', 25, 255, true); push_table_row($data, 'wmi_2'); $data = []; -$data[0] = __('Username').ui_print_help_icon('column_macros', true); +$data[0] = __('Username'); $data[1] = html_print_input_text('plugin_user', $plugin_user, '', 15, 255, true); -$data[2] = __('Password').ui_print_help_icon('column_macros', true); +$data[2] = __('Password'); $data[3] = html_print_input_password('plugin_pass', $plugin_pass, '', 25, 255, true); push_table_row($data, 'wmi_3'); $data = []; -$data[0] = __('Post process').' '.ui_print_help_icon('postprocess', true, ui_get_full_url(false, false, false, false)); +$data[0] = __('Post process'); $data[1] = html_print_extended_select_for_post_process( 'post_process', $post_process, diff --git a/pandora_console/godmode/reporting/create_container.php b/pandora_console/godmode/reporting/create_container.php index b0566d7867..3c2e144178 100644 --- a/pandora_console/godmode/reporting/create_container.php +++ b/pandora_console/godmode/reporting/create_container.php @@ -414,7 +414,7 @@ if ($edit_container) { echo "
"; echo ''; echo ''; echo ''; echo '
'; - echo ui_toggle($single_table, 'Simple module graph', '', true, true); + echo ui_toggle($single_table, 'Simple module graph', '', '', true); echo '
'; @@ -466,7 +466,7 @@ if ($edit_container) { echo ""; echo ''; echo ''; echo ''; echo '
'; - echo ui_toggle(html_print_table($table, true), 'Custom graph', '', true, true); + echo ui_toggle(html_print_table($table, true), 'Custom graph', '', '', true); echo '
'; @@ -561,7 +561,7 @@ if ($edit_container) { echo ""; echo ''; echo ''; echo ''; echo '
'; - echo ui_toggle(html_print_table($table, true), 'Dynamic rules for simple module graph', '', true, true); + echo ui_toggle(html_print_table($table, true), 'Dynamic rules for simple module graph', '', '', true); echo '
'; diff --git a/pandora_console/godmode/reporting/graph_builder.graph_editor.php b/pandora_console/godmode/reporting/graph_builder.graph_editor.php index a03a67737f..33cacc9bab 100644 --- a/pandora_console/godmode/reporting/graph_builder.graph_editor.php +++ b/pandora_console/godmode/reporting/graph_builder.graph_editor.php @@ -356,9 +356,35 @@ echo "".__('Agents').''; echo ''; echo "".__('Modules').''; echo ''; -echo ''.html_print_select(agents_get_group_agents(), 'id_agents[]', 0, false, '', '', true, true, true, '', false, '').''; -echo "".html_print_image('images/darrowright.png', true).''; -echo ''.html_print_select([], 'module[]', 0, false, '', 0, true, true, true, '', false, '').''; +echo ''.html_print_select( + agents_get_group_agents(), + 'id_agents[]', + 0, + false, + '', + '', + true, + true, + true, + 'w100p', + false, + '' +).''; +echo "".html_print_image('images/darrowright.png', true).''; +echo ''.html_print_select( + [], + 'module[]', + 0, + false, + '', + 0, + true, + true, + true, + 'w100p', + false, + '' +).''; echo ''; echo ""; echo ""; diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 61125b15c3..a5e59e46ce 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -221,7 +221,7 @@ switch ($action) { $server_name = $item['server_name']; // Metaconsole db connection. - if ($meta && $server_name != '') { + if ($meta && !empty($server_name)) { $connection = metaconsole_get_connection($server_name); if (metaconsole_load_external_db($connection) != NOERR) { continue; @@ -547,8 +547,43 @@ switch ($action) { break; case 'event_report_agent': - case 'event_report_group': + $description = $item['description']; + $period = $item['period']; + $group = $item['id_group']; $recursion = $item['recursion']; + $idAgent = $item['id_agent']; + $idAgentModule = $item['id_agent_module']; + + + $show_summary_group = $style['show_summary_group']; + $filter_event_severity = json_decode($style['filter_event_severity'], true); + $filter_event_status = json_decode($style['filter_event_status'], true); + $filter_event_type = json_decode($style['filter_event_type'], true); + + $event_graph_by_user_validator = $style['event_graph_by_user_validator']; + $event_graph_by_criticity = $style['event_graph_by_criticity']; + $event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated']; + $include_extended_events = $item['show_extended_events']; + + $filter_search = $style['event_filter_search']; + + break; + + case 'event_report_group': + $description = $item['description']; + $period = $item['period']; + $group = $item['id_group']; + $recursion = $item['recursion']; + + $event_graph_by_agent = $style['event_graph_by_agent']; + $event_graph_by_user_validator = $style['event_graph_by_user_validator']; + $event_graph_by_criticity = $style['event_graph_by_criticity']; + $event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated']; + + $filter_search = $style['event_filter_search']; + + + $include_extended_events = $item['show_extended_events']; break; @@ -877,7 +912,7 @@ $class = 'databox filters'; @@ -293,7 +314,8 @@ function ui_print_message($message, $class='', $attributes='', $return=false, $t
@@ -981,11 +1016,6 @@ $class = 'databox filters'; @@ -1004,10 +1034,7 @@ $class = 'databox filters';
@@ -1026,10 +1053,7 @@ $class = 'databox filters';
@@ -2816,7 +2840,7 @@ function print_SLA_list($width, $action, $idItem=null) foreach ($itemsSLA as $item) { $server_name = $item['server_name']; // Metaconsole db connection. - if ($meta && $server_name != '') { + if ($meta && !empty($server_name)) { $connection = metaconsole_get_connection( $server_name ); @@ -3144,7 +3168,7 @@ function print_General_list($width, $action, $idItem=null, $type='general') foreach ($itemsGeneral as $item) { $server_name = $item['server_name']; // Metaconsole db connection. - if ($meta && $server_name != '') { + if ($meta && !empty($server_name)) { $connection = metaconsole_get_connection( $server_name ); @@ -3502,6 +3526,7 @@ $(document).ready (function () { $("#submit-create_item").click(function () { var type = $('#type').val(); + var name = $('#text-name').val(); switch (type){ case 'alert_report_module': case 'alert_report_agent': @@ -3532,6 +3557,13 @@ $(document).ready (function () { default: break; } + + if($('#text-name').val() == ''){ + alert( ); + return false; + } + + }); $("#submit-edit_item").click(function () { @@ -4865,7 +4897,6 @@ function chooseType() { switch (type) { case 'event_report_agent': case 'simple_graph': - case 'agent_configuration': case 'event_report_module': case 'alert_report_agent': case 'alert_report_module': @@ -4876,8 +4907,6 @@ function chooseType() { case 'min_value': case 'max_value': case 'avg_value': - case 'projection_graph': - case 'prediction_date': case 'TTRT': case 'TTO': case 'MTBF': diff --git a/pandora_console/godmode/reporting/reporting_builder.list_items.php b/pandora_console/godmode/reporting/reporting_builder.list_items.php index 9addb32f26..b2a206a40a 100755 --- a/pandora_console/godmode/reporting/reporting_builder.list_items.php +++ b/pandora_console/godmode/reporting/reporting_builder.list_items.php @@ -745,7 +745,12 @@ function message_check_delete_items() { } function added_ids_deleted_items_to_hidden_input() { - message_check_delete_items(); + var success = message_check_delete_items(); + + if(success === false){ + $(".check_delete").prop("checked", false); + return false; + } var ids = ''; var first = true; diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index e8af78ed62..d87a8f0e0a 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -45,6 +45,9 @@ .parent() .addClass('checkselected'); $(".check_delete").prop("checked", true); + $('.check_delete').each(function(){ + $('#hidden-id_report_'+$(this).val()).prop("disabled", false); + }); } else{ $('[id^=checkbox-massive_report_check]') @@ -760,6 +763,9 @@ switch ($action) { $table->head = []; $table->align = []; + $table->headstyle = []; + $table->style = []; + $table->align[2] = 'left'; $table->align[3] = 'left'; $table->align[4] = 'left'; @@ -768,21 +774,28 @@ switch ($action) { $table->head[1] = __('Description'); $table->head[2] = __('HTML'); $table->head[3] = __('XML'); - $table->size[0] = '20%'; - $table->size[1] = '30%'; + $table->size[0] = '60%'; + $table->size[1] = '20%'; $table->size[2] = '2%'; + $table->headstyle[2] = 'min-width: 35px;text-align: center;'; $table->size[3] = '2%'; + $table->headstyle[3] = 'min-width: 35px;text-align: center;'; $table->size[4] = '2%'; - $table->size[5] = '2%'; - $table->size[6] = '2%'; - $table->size['csv'] = '5%'; + $table->headstyle[4] = 'min-width: 35px;text-align: center;'; $next = 4; // Calculate dinamically the number of the column. - if (enterprise_hook('load_custom_reporting_1') !== ENTERPRISE_NOT_HOOK) { + if (enterprise_hook('load_custom_reporting_1', [$table]) !== ENTERPRISE_NOT_HOOK) { $next = 7; } + $table->size[$next] = '2%'; + $table->style[$next] = 'text-align: center;'; + + $table->headstyle[($next + 2)] = 'min-width: 100px;'; + $table->style[($next + 2)] = 'text-align: center;'; + + // Admin options only for RM flag. if (check_acl($config['id_user'], 0, 'RM')) { $table->head[$next] = __('Private'); @@ -814,7 +827,6 @@ switch ($action) { // $table->size = array (); $table->size[$next] = '10%'; $table->align[$next] = 'left'; - $table->headstyle[$next] = 'text-align:left;'; } $columnview = false; @@ -996,7 +1008,6 @@ switch ($action) { $table->head[$next] = ''.__('Op.').''.html_print_checkbox('all_delete', 0, false, true, false); $table->size = []; // $table->size[$next] = '80px'; - $table->style[$next] = 'text-align:left;'; } if ($edit) { @@ -1334,6 +1345,8 @@ switch ($action) { $values['description'] = get_parameter('description'); $values['type'] = get_parameter('type', null); $values['recursion'] = get_parameter('recursion', null); + $values['show_extended_events'] = get_parameter('include_extended_events', null); + $label = get_parameter('label', ''); // Add macros name. @@ -1889,8 +1902,8 @@ switch ($action) { $style['event_graph_by_user_validator'] = $event_graph_by_user_validator; $style['event_graph_by_criticity'] = $event_graph_by_criticity; $style['event_graph_validated_vs_unvalidated'] = $event_graph_validated_vs_unvalidated; - $style['event_filter_search'] = $event_filter_search; + if ($label != '') { $style['label'] = $label; } else { @@ -1996,6 +2009,7 @@ switch ($action) { ); $name_it = (string) get_parameter('name'); $values['recursion'] = get_parameter('recursion', null); + $values['show_extended_events'] = get_parameter('include_extended_events', null); $values['name'] = reporting_label_macro( $items_label, $name_it @@ -2407,6 +2421,7 @@ switch ($action) { case 'event_report_agent': case 'event_report_group': case 'event_report_module': + $show_summary_group = get_parameter( 'show_summary_group', 0 @@ -2462,22 +2477,11 @@ switch ($action) { $style['event_graph_by_user_validator'] = $event_graph_by_user_validator; $style['event_graph_by_criticity'] = $event_graph_by_criticity; $style['event_graph_validated_vs_unvalidated'] = $event_graph_validated_vs_unvalidated; - - - switch ($values['type']) { - case 'event_report_group': - case 'event_report_agent': - $style['event_filter_search'] = $event_filter_search; - if ($label != '') { - $style['label'] = $label; - } else { - $style['label'] = ''; - } - break; - - default: - // Default. - break; + $style['event_filter_search'] = $event_filter_search; + if ($label != '') { + $style['label'] = $label; + } else { + $style['label'] = ''; } break; diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.js b/pandora_console/godmode/reporting/visual_console_builder.editor.js index bc00f703c8..85cbd9be5e 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.js +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.js @@ -1,3 +1,5 @@ +/* globals $ */ + // Pandora FMS - http://pandorafms.com // ================================================== // Copyright (c) 2005-2009 Artica Soluciones Tecnologicas @@ -31,6 +33,8 @@ var SIZE_GRID = 16; //Const the size (for width and height) of grid. var img_handler_start; var img_handler_end; +var default_cache_expiration = null; + function toggle_advance_options_palette(close) { if ($("#advance_options").css("display") == "none") { $("#advance_options").css("display", ""); @@ -250,7 +254,12 @@ function update_button_palette_callback() { var values = {}; values = readFields(); - + if (values["map_linked"] == 0) { + if (values["agent"] == "" || values["agent"] == "none") { + dialog_message("#message_alert_no_agent"); + return false; + } + } // TODO VALIDATE DATA switch (selectedItem) { case "background": @@ -1183,6 +1192,10 @@ function readFields() { values["timezone"] = $("select[name=timezone]").val(); values["clock_animation"] = $("select[name=clock_animation]").val(); values["show_last_value"] = $("select[name=last_value]").val(); + values["cache_expiration"] = + typeof $("#hidden-cache_expiration").val() !== "undefined" + ? $("#hidden-cache_expiration").val() + : $("#cache_expiration").val(); // Color Cloud values if (selectedItem == "color_cloud" || creationItem == "color_cloud") { @@ -1226,7 +1239,6 @@ function readFields() { function create_button_palette_callback() { var values = readFields(); - //VALIDATE DATA var validate = true; switch (creationItem) { @@ -1253,6 +1265,7 @@ function create_button_palette_callback() { dialog_message("#message_alert_max_height"); validate = false; } + break; case "group_item": if (values["height"] == "") { @@ -1316,6 +1329,12 @@ function create_button_palette_callback() { dialog_message("#message_alert_no_image"); validate = false; } + if (values["map_linked"] == 0) { + if (values["agent"] == "" || values["agent"] == "none") { + dialog_message("#message_alert_no_agent"); + validate = false; + } + } break; case "auto_sla_graph": @@ -2219,6 +2238,26 @@ function loadFieldsFromDB(item) { }); } + if (key == "cache_expiration") { + var intoCacheExpSelect = false; + var cacheExpId = $("#hidden-cache_expiration").attr("class"); + $("#" + cacheExpId + "_select option").each(function() { + if ($(this).val() == val) { + $(this).prop("selected", true); + $(this).trigger("change"); + intoCacheExpSelect = true; + } + }); + if (intoCacheExpSelect == false) { + $("#" + cacheExpId + "_select").val(0); + $("#" + cacheExpId + "_units").val(1); + $("#hidden-cache_expiration").val(val); + $("#text-" + cacheExpId + "_text").val(val); + $("#" + cacheExpId + "_default").hide(); + $("#" + cacheExpId + "_manual").show(); + } + } + if (key == "value_show") { $("select[name=value_show]").val(val); } @@ -2595,6 +2634,9 @@ function hiddenFields(item) { $("#line_case").css("display", "none"); $("#line_case." + item).css("display", ""); + $("#cache_expiration_row").css("display", "none"); + $("#cache_expiration_row." + item).css("display", ""); + // Color cloud rows $("#color_cloud_diameter_row").hide(); $("#color_cloud_diameter_row." + item).show(); @@ -2668,6 +2710,44 @@ function cleanFields(item) { $("table.color-range-creation input[type=color]").val("#FFFFFF"); $("table.color-range:not(table.color-range-creation)").remove(); + // Clean the cache expiration selection. + if (default_cache_expiration === null) { + var cacheExpVal = $("#hidden-cache_expiration").val(); + if (!Number.isNaN(Number.parseInt(cacheExpVal))) { + cacheExpVal = Number.parseInt(cacheExpVal); + } else { + cacheExpVal = 0; + } + + default_cache_expiration = cacheExpVal; + } + var cacheExpId = $("#hidden-cache_expiration").attr("class"); + $("#hidden-cache_expiration").val(default_cache_expiration); + + var intoCacheExpSelect = false; + $("#" + cacheExpId + "_select option").each(function() { + if ($(this).val() == default_cache_expiration) { + $(this).prop("selected", true); + $(this).trigger("change"); + intoCacheExpSelect = true; + } + }); + if (!intoCacheExpSelect) { + // Show input. + $("#" + cacheExpId + "_select").val(0); + $("#" + cacheExpId + "_units").val(1); + $("#text-" + cacheExpId + "_text").val(default_cache_expiration); + $("#" + cacheExpId + "_default").hide(); + $("#" + cacheExpId + "_manual").show(); + } else { + // Show select. + $("#" + cacheExpId + "_select").val(default_cache_expiration); + $("#" + cacheExpId + "_units").val(0); + $("#text-" + cacheExpId + "_text").val(""); + $("#" + cacheExpId + "_default").show(); + $("#" + cacheExpId + "_manual").hide(); + } + $("#preview").empty(); if (item == "simple_value") { diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.php b/pandora_console/godmode/reporting/visual_console_builder.editor.php index 9ba8c56716..9b6697533f 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.php +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.php @@ -25,6 +25,8 @@ if (empty($visualConsole)) { exit; } +ui_require_css_file('visual_maps'); + // ACL for the existing visual console // if (!isset($vconsole_read)) // $vconsole_read = check_acl ($config['id_user'], $visualConsole['id_group'], "VR"); @@ -170,6 +172,7 @@ echo "'; ?> diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php index 9ee95f78cc..8f6630d4e3 100644 --- a/pandora_console/godmode/setup/setup_notifications.php +++ b/pandora_console/godmode/setup/setup_notifications.php @@ -160,6 +160,20 @@ if (get_parameter('get_notifications_dropdown', 0)) { return; } +if (get_parameter('get_notification', 0)) { + $msg_id = get_parameter('id', 0); + + if ($msg_id > 0) { + $msg = messages_get_message($msg_id); + + $msg['mensaje'] = io_safe_output($msg['mensaje']); + $msg['subject'] = io_safe_output($msg['subject']); + echo json_encode($msg); + } + + return; +} + // Notification table. It is just a wrapper. $table_content = new StdClass(); $table_content->data = []; diff --git a/pandora_console/godmode/setup/setup_visuals.php b/pandora_console/godmode/setup/setup_visuals.php index cff2c81c34..bcaff54d95 100755 --- a/pandora_console/godmode/setup/setup_visuals.php +++ b/pandora_console/godmode/setup/setup_visuals.php @@ -918,6 +918,32 @@ $row++; ); $row++; + $intervals = [ + 10 => '10 '.__('seconds'), + 30 => '30 '.__('seconds'), + 60 => '1 '.__('minutes'), + 300 => '5 '.__('minutes'), + 900 => '15 '.__('minutes'), + 1800 => '30 '.__('minutes'), + 3600 => '1 '.__('hour'), + ]; + $table_vc->data[$row][0] = __('Default cache expiration'); + $table_vc->data[$row][1] = html_print_extended_select_for_time( + 'vc_default_cache_expiration', + $config['vc_default_cache_expiration'], + '', + __('No cache'), + 0, + false, + true, + false, + false, + '', + false, + $intervals + ); + $row++; + $table_vc->data[$row][0] = __('Default interval for refresh on Visual Console').ui_print_help_tip(__('This interval will affect to Visual Console pages'), true); $table_vc->data[$row][1] = html_print_select($values, 'vc_refr', (int) $config['vc_refr'], '', 'N/A', 0, true, false, false); $row++; @@ -1394,6 +1420,15 @@ tinyMCE.init({ }); $(document).ready (function () { + + // Show the cache expiration conf or not. + $("input[name=legacy_vc]").change(function (e) { + if ($(this).prop("checked") === true) { + $("select#vc_default_cache_expiration_select").closest("tr").hide(); + } else { + $("select#vc_default_cache_expiration_select").closest("tr").show(); + } + }).change(); var comfort = 0; diff --git a/pandora_console/godmode/snmpconsole/snmp_alert.php b/pandora_console/godmode/snmpconsole/snmp_alert.php index a2a1b8b811..66651d6522 100755 --- a/pandora_console/godmode/snmpconsole/snmp_alert.php +++ b/pandora_console/godmode/snmpconsole/snmp_alert.php @@ -1275,7 +1275,7 @@ if ($create_alert || $update_alert) { $table->align[7] = 'left'; $table->head[8] = __('Action'); - $table->size[8] = '90px'; + $table->size[8] = '120px'; $table->align[8] = 'left'; $table->head[9] = html_print_checkbox('all_delete_box', '1', false, true); diff --git a/pandora_console/godmode/update_manager/update_manager.css b/pandora_console/godmode/update_manager/update_manager.css index 168c6fcf7a..1d3fdc2c12 100644 --- a/pandora_console/godmode/update_manager/update_manager.css +++ b/pandora_console/godmode/update_manager/update_manager.css @@ -34,7 +34,7 @@ float: none; } #drop_file a { - background-color: #80ba27; + background-color: #82b92e; border-radius: 2px; color: #ffffff; cursor: pointer; @@ -101,7 +101,7 @@ width: 15px; } .fileupload_form ul li div { - display: block !important; + display: block; } .fileupload_form ul li.working span { background-position: 0 -12px; @@ -183,39 +183,22 @@ div#box_online * { .update_text a { font-size: 11pt; - color: #82b92e !important; + color: #82b92e; } .ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { - float: left !important; + float: left; padding-left: 19px; padding-bottom: 5px; } -.ui-dialog-buttonset > button.ui-button.ui-corner-all.ui-widget { - background-color: #cecece !important; - border: none !important; - border-radius: 2px !important; - text-transform: uppercase !important; - font-weight: bold !important; -} - -.ui-dialog-buttonset > button.success_button.ui-button.ui-corner-all.ui-widget, -.update_manager_button { - background-color: #82b92e !important; - color: #fff !important; - border-radius: 2px !important; - text-transform: uppercase !important; - font-weight: bold !important; -} - a.update_manager_button { padding: 10px 12px; margin-top: 10px; display: inline-flex; align-items: center; - font-size: 16px !important; - border-radius: 4px !important; + font-size: 16px; + border-radius: 4px; text-decoration: none; font-family: "Open Sans", sans-serif; } @@ -231,7 +214,7 @@ a.update_manager_button:after { .ui-draggable, .ui-draggable .ui-dialog-titlebar { - cursor: default !important; + cursor: default; } #box_online #pkg_version { @@ -242,10 +225,10 @@ a.update_manager_button:after { /* METACONSOLE */ .box_online_meta { - background: none !important; - min-height: 400px !important; + background: none; + min-height: 400px; text-align: center; - border: none !important; + border: none; } div#box_online.box_online_meta * { @@ -277,7 +260,7 @@ div#box_online.box_online_meta * { } .update_manager_warning p { - font-size: 10pt !important; + font-size: 10pt; } .update_manager_warning img { @@ -287,8 +270,8 @@ div#box_online.box_online_meta * { a.update_manager_button_open { padding: 5px 10px; - font-size: 16px !important; - border-radius: 4px !important; + font-size: 16px; + border-radius: 4px; text-decoration: none; border: 1px solid #82b92e; color: #82b92e; diff --git a/pandora_console/godmode/update_manager/update_manager.messages.php b/pandora_console/godmode/update_manager/update_manager.messages.php deleted file mode 100644 index 31f9866b01..0000000000 --- a/pandora_console/godmode/update_manager/update_manager.messages.php +++ /dev/null @@ -1,340 +0,0 @@ - $message_id) { - update_manger_set_read_message($message_id, 0); - } -} - -if ($read_action !== false) { - $selected = get_parameter('select_multiple', false); - foreach ($selected as $k => $message_id) { - update_manger_set_read_message($message_id, 1); - } -} - -if ($delete_action !== false) { - $selected = get_parameter('select_multiple', false); - foreach ($selected as $k => $message_id) { - update_manger_set_deleted_message($message_id); - } -} - -$offset = (int) get_parameter('offset', 0); - -$total_messages = update_manager_get_not_deleted_messages(); -if ($total_messages) { - // Get all messages - $sql = 'SELECT data, svn_version, filename, data_rollback, db_field_value FROM tupdate '; - $sql .= 'WHERE description NOT LIKE \'%"'.$config['id_user'].'":1%\' '; - $sql .= 'OR description IS NULL '; - $sql .= 'ORDER BY svn_version DESC '; - $sql .= 'LIMIT '.$offset.','.$config['block_size'].' '; - $um_messages = []; - $um_messages = db_get_all_rows_sql($sql); - - echo '
'; - - html_print_input_hidden('tab', 'messages'); - html_print_input_hidden('offset', $offset); - echo '
'; - html_print_submit_button( - __('Delete'), - 'delete_button', - false, - 'class="sub delete"' - ); - echo '
'; - - echo '
'; - html_print_submit_button( - __('Mark as not read'), - 'not_read_button', - false, - 'class="sub wand"' - ); - echo '
'; - - echo '
'; - html_print_submit_button( - __('Mark as read'), - 'read_button', - false, - 'class="sub upd"' - ); - echo '
'; - - // Pagination - if ($total_messages > $config['block_size']) { - ui_pagination(update_manager_get_total_messages(), false, 0); - } - - $table = new stdClass(); - $table->width = '100%'; - $table->class = 'databox data'; - $table->cellpadding = 4; - $table->cellspacing = 4; - $table->head = []; - $table->data = []; - $table->align = []; - $table->size = []; - $table->id = 'um_messages_table'; - - $table->align[0] = 'left'; - $table->align[1] = 'left'; - $table->align[2] = 'left'; - $table->align[3] = 'left'; - $table->align[4] = 'left'; - - $table->size[0] = '30px'; - $table->size[1] = '100px'; - $table->size[3] = '80px'; - $table->size[4] = '60px'; - - $table->style[0] = 'padding-left: 20px'; - $table->style[1] = 'display: none'; - - $table->head[0] = html_print_checkbox_extended('all_selection[]', 0, false, false, '', '', true); - $table->head[2] = __('Subject'); - - - $i = 0; - foreach ($um_messages as $message) { - $data[0] = html_print_checkbox_extended('select_multiple[]', $message['svn_version'], false, false, '', 'class="check_selection"', true); - $table->cellclass[count($table->data)][0] = 'um_individual_check'; - - $data[1] = $message['svn_version']; - $table->cellclass[count($table->data)][1] = 'um_individual_info'; - - $data[2] = io_safe_output($message['db_field_value']); - $table->cellclass[count($table->data)][2] = 'um_individual_subject'; - - - // Change row class if message is read or not by this user - if (update_manger_get_read_message($message['svn_version'], $message['data_rollback'])) { - $table->rowclass[count($table->data)] = 'um_read_message'; - } else { - $table->rowclass[count($table->data)] = 'um_not_read_message'; - } - - array_push($table->data, $data); - } - - html_print_table($table); - - echo '
'; - html_print_submit_button( - __('Delete'), - 'delete_button', - false, - 'class="sub delete"' - ); - echo '
'; - - echo '
'; - html_print_submit_button( - __('Mark as not read'), - 'not_read_button', - false, - 'class="sub wand"' - ); - echo '
'; - - echo '
'; - html_print_submit_button( - __('Mark as read'), - 'read_button', - false, - 'class="sub upd"' - ); - echo '
'; - echo '
'; - - // Get unread messages to update the notification ball. - // Clean the cache because the unread messages can be different. - db_clean_cache(); - $total_unread_messages = update_manager_get_unread_messages(); -} else { - ui_print_info_message([ 'no_close' => true, 'message' => __('There is not any update manager messages.') ]); -} -?> - - - - diff --git a/pandora_console/godmode/update_manager/update_manager.online.php b/pandora_console/godmode/update_manager/update_manager.online.php index ef9b25075c..a1524d5518 100644 --- a/pandora_console/godmode/update_manager/update_manager.online.php +++ b/pandora_console/godmode/update_manager/update_manager.online.php @@ -1,22 +1,32 @@ - @import 'styles/meta_pandora.css'; - "; -} - -if (is_metaconsole()) { - $baseurl = ui_get_full_url(false, false, false, false); - echo ' '; - echo "
"; } else { - echo "
"; + $php_settings_fine++; } -echo ""; -echo ""; -echo ''; - -echo '

'.__('The latest version of package installed is:').'

'; -if ($open) { - echo '
'.$build_version.'
'; +$post_max_size = config_return_in_bytes(ini_get('post_max_size')); +if ($post_max_size < $PHPpost_max_size_min) { + ui_print_error_message( + sprintf( + __('Your PHP has post_max_size limited to %s. To use Update Manager Online, please set it to %s'), + ini_get('post_max_size'), + $post_max_size_min + ) + ); } else { - echo '
'.$current_package.'
'; + $php_settings_fine++; } - echo "'; +$upload_max_filesize = config_return_in_bytes(ini_get('upload_max_filesize')); +if ($upload_max_filesize < $PHPupload_max_filesize_min) { + ui_print_error_message( + sprintf( + __('Your PHP has set maximum allowed size for uploaded files limit in %s. To use Update Manager Online, please set it to %s'), + ini_get('upload_max_filesize'), + $upload_max_filesize_min + ) + ); +} else { + $php_settings_fine++; +} - echo "'; +// Verify registry. +if (update_manager_verify_registration() === false) { + ui_require_css_file('register'); + registration_wiz_modal(false, true, 'location.reload()'); + ui_print_error_message( + __('Update Manager Online requires registration') + ); +} else { + // Console registered. + $current_package = update_manager_get_current_package(); - echo "
"; + if (!enterprise_installed()) { + $open = true; + } - echo ""; + // Translators: Do not translade Update Manager, it's the name of the program. + if (is_metaconsole()) { + echo ""; + } + + if (is_metaconsole()) { + $baseurl = ui_get_full_url(false, false, false, false); + echo ' '; + echo "
"; + } else { + echo "
"; + } + + if ($php_settings_fine >= $PHP_SETTINGS_REQUIRED) { + echo ""; + echo ""; + echo ''; + } + + echo '

'.__('The latest version of package installed is:').'

'; + if ($open) { + echo '
'.$build_version.'
'; + } else { + echo '
'.$current_package.'
'; + } + + echo "'; + + echo "'; + + echo "
"; + + echo ""; /* - ------------------------------------------------------------------------- + * ------------------------------------------------------------------------- + * Hello there! :) + * We added some of what seems to be "buggy" messages to the openSource + * version recently. This is not to force open-source users to move to the + * enterprise version, this is just to inform people using Pandora FMS open + * source that it requires skilled people to maintain and keep it running + * smoothly without professional support. This does not imply open-source + * version is limited in any way. If you check the recently added code, it + * contains only warnings and messages, no limitations except one: + * we removed the option to add custom logo in header. + * + * In the Update Manager section, it warns about the 'danger’ of applying + * automated updates without a proper backup, remembering in the process + * that the Enterprise version comes with a human-tested package. + * + * Maintaining an OpenSource version with more than 500 agents is not so + * easy, that's why someone using a Pandora with 8000 agents should consider + * asking for support. It's not a joke, we know of many setups with a huge + * number of agents, and we hate to hear that “its becoming unstable and + * slow” :( + * + * You can of course remove the warnings, that's why we include the source + * and do not use any kind of trick. And that's why we added here this + * comment, to let you know this does not reflect any change in our + * opensource mentality of does the last 14 years. + * ------------------------------------------------------------------------- + */ - Hello there! :) + if ($open) { + echo "
+
+
+

".__('WARNING: You are just one click away from an automated update. This may result in a damaged system, including loss of data and operativity. Check you have a recent backup. OpenSource updates are automatically created packages, and there is no WARRANTY or SUPPORT. If you need professional support and warranty, please upgrade to Enterprise Version.')."

+
+ +
"; + } - We added some of what seems to be "buggy" messages to the openSource version - recently. This is not to force open-source users to move to the enterprise - version, this is just to inform people using Pandora FMS open source that it - requires skilled people to maintain and keep it running smoothly without - professional support. This does not imply open-source version is limited - in any way. If you check the recently added code, it contains only warnings - and messages, no limitations except one: we removed the option to add custom - logo in header. In the Update Manager section, it warns about the 'danger’ - of applying automated updates without a proper backup, remembering in the - process that the Enterprise version comes with a human-tested package. - Maintaining an OpenSource version with more than 500 agents is not so - easy, that's why someone using a Pandora with 8000 agents should consider - asking for support. It's not a joke, we know of many setups with a huge - number of agents, and we hate to hear that “its becoming unstable and slow” :( - You can of course remove the warnings, that's why we include the source and - do not use any kind of trick. And that's why we added here this comment, to - let you know this does not reflect any change in our opensource mentality of - does the last 14 years. + if ($php_settings_fine >= $PHP_SETTINGS_REQUIRED) { + $enterprise = enterprise_hook('update_manager_enterprise_main'); - ------------------------------------------------------------------------- - */ + if ($enterprise == ENTERPRISE_NOT_HOOK) { + // Open view. + update_manager_main(); + } + ?> -if ($open) { - echo "
-
-
-

".__('WARNING: You are just one click away from an automated update. This may result in a damaged system, including loss of data and operativity. Check you have a recent backup. OpenSource updates are automatically created packages, and there is no WARRANTY or SUPPORT. If you need professional support and warranty, please upgrade to Enterprise Version.')."

-
- -
"; + + - - \ No newline at end of file diff --git a/pandora_console/godmode/update_manager/update_manager.php b/pandora_console/godmode/update_manager/update_manager.php index 704312dfdc..7954fd0ada 100644 --- a/pandora_console/godmode/update_manager/update_manager.php +++ b/pandora_console/godmode/update_manager/update_manager.php @@ -45,12 +45,6 @@ $buttons = [ ], ]; -if (license_free()) { - $buttons['messages'] = [ - 'active' => ($tab == 'messages') ? true : false, - 'text' => ''.html_print_image('images/email_mc.png', true, ['title' => __('Update manager messages')]).'', - ]; -} switch ($tab) { case 'setup': @@ -66,10 +60,6 @@ switch ($tab) { $title = __('Update manager » Online'); $help_header = 'update_manager_online_tab'; break; - - case 'messages': - $title = __('Update manager » Messages'); - break; } ui_print_page_header( @@ -90,10 +80,6 @@ switch ($tab) { include $config['homedir'].'/godmode/update_manager/update_manager.offline.php'; break; - case 'messages': - include $config['homedir'].'/godmode/update_manager/update_manager.messages.php'; - break; - case 'online': default: include $config['homedir'].'/godmode/update_manager/update_manager.online.php'; diff --git a/pandora_console/godmode/update_manager/update_manager.setup.php b/pandora_console/godmode/update_manager/update_manager.setup.php index 4717dd8681..1a81cf457c 100644 --- a/pandora_console/godmode/update_manager/update_manager.setup.php +++ b/pandora_console/godmode/update_manager/update_manager.setup.php @@ -1,18 +1,36 @@ data[4][1] = html_print_input_password( true ); + +$table->data[5][0] = __('Registration ID:'); +$table->data[5][1] = ''.$config['pandora_uid'].''; + +if (update_manager_verify_registration() === true && users_is_admin()) { + $table->data[6][0] = __('Cancel registration:'); + $table->data[6][1] = ''.__('Unregister').''; +} + + + if (license_free()) { $config['identification_reminder'] = isset($config['identification_reminder']) ? $config['identification_reminder'] : 1; - $table->data[6][0] = __('Pandora FMS community reminder').ui_print_help_tip(__('Every 8 days, a message is displayed to admin users to remember to register this Pandora instance'), true); - $table->data[6][1] = __('Yes').'   '.html_print_radio_button('identification_reminder', 1, '', $config['identification_reminder'], true).'  '; - $table->data[6][1] .= __('No').'   '.html_print_radio_button('identification_reminder', 0, '', $config['identification_reminder'], true); + $table->data[7][0] = __('Pandora FMS community reminder').ui_print_help_tip(__('Every 8 days, a message is displayed to admin users to remember to register this Pandora instance'), true); + $table->data[7][1] = __('Yes').'   '.html_print_radio_button('identification_reminder', 1, '', $config['identification_reminder'], true).'  '; + $table->data[7][1] .= __('No').'   '.html_print_radio_button('identification_reminder', 0, '', $config['identification_reminder'], true); } html_print_input_hidden('action_update_url_update_manager', 1); diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index cab408c39f..47788284fe 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -151,6 +151,12 @@ if ($new_user && $config['admin_can_add_user']) { $user_info['metaconsole_assigned_server'] = ''; $user_info['metaconsole_access_node'] = 0; } + + if ($config['ehorus_user_level_conf']) { + $user_info['ehorus_user_level_user'] = ''; + $user_info['ehorus_user_level_pass'] = ''; + $user_info['ehorus_user_level_enabled'] = true; + } } if ($create_user) { @@ -215,6 +221,19 @@ if ($create_user) { $values['strict_acl'] = (bool) get_parameter('strict_acl', false); $values['session_time'] = (int) get_parameter('session_time', 0); + // eHorus user level conf + if ($config['ehorus_user_level_conf']) { + $values['ehorus_user_level_enabled'] = (bool) get_parameter('ehorus_user_level_enabled', false); + if ($values['ehorus_user_level_enabled'] === true) { + $values['ehorus_user_level_user'] = (string) get_parameter('ehorus_user_level_user'); + $values['ehorus_user_level_pass'] = (string) get_parameter('ehorus_user_level_pass'); + } else { + $values['ehorus_user_level_user'] = null; + $values['ehorus_user_level_pass'] = null; + } + } + + if ($id == '') { ui_print_error_message(__('User ID cannot be empty')); $user_info = $values; @@ -298,6 +317,13 @@ if ($update_user) { $values['timezone'] = (string) get_parameter('timezone'); $values['default_event_filter'] = (int) get_parameter('default_event_filter'); $values['default_custom_view'] = (int) get_parameter('default_custom_view'); + // eHorus user level conf + $values['ehorus_user_level_enabled'] = (bool) get_parameter('ehorus_user_level_enabled', false); + $values['ehorus_user_level_user'] = (string) get_parameter('ehorus_user_level_user'); + $values['ehorus_user_level_pass'] = (string) get_parameter('ehorus_user_level_pass'); + + + $dashboard = get_parameter('dashboard', ''); $visual_console = get_parameter('visual_console', ''); @@ -760,6 +786,7 @@ if (enterprise_installed() && !is_metaconsole()) { $values['Dashboard'] = __('Dashboard'); } + $table->data[12][1] = html_print_select($values, 'section', io_safe_output($user_info['section']), 'show_data_section();', '', -1, true, false, false); if (enterprise_installed()) { @@ -842,6 +869,16 @@ foreach ($event_filter_data as $filter) { $table->data[16][0] = __('Default event filter'); $table->data[16][1] = html_print_select($event_filter, 'default_event_filter', $user_info['default_event_filter'], '', '', __('None'), true, false, false); +if ($config['ehorus_user_level_conf']) { + $table->data[17][0] = __('eHorus user acces enabled'); + $table->data[17][1] = html_print_checkbox('ehorus_user_level_enabled', 1, $user_info['ehorus_user_level_enabled'], true); + $table->data[18][0] = __('eHorus user'); + $table->data[19][0] = __('eHorus password'); + $table->data[18][1] = html_print_input_text('ehorus_user_level_user', $user_info['ehorus_user_level_user'], '', 15, 45, true); + $table->data[19][1] = html_print_input_password('ehorus_user_level_pass', io_output_password($user_info['ehorus_user_level_pass']), '', 15, 45, true); +} + + if ($meta) { enterprise_include_once('include/functions_metaconsole.php'); @@ -933,6 +970,11 @@ $(document).ready (function () { $('#checkbox-metaconsole_agents_manager').trigger('change'); show_data_section(); + $('#checkbox-ehorus_user_level_enabled').change(function () { + switch_ehorus_conf(); + }); + $('#checkbox-ehorus_user_level_enabled').trigger('change'); + }); function show_data_section () { @@ -987,5 +1029,21 @@ function show_data_section () { } } +function switch_ehorus_conf() +{ + if(!$('#checkbox-ehorus_user_level_enabled').prop('checked')) + { + $("#user_configuration_table-18").hide(); + $("#user_configuration_table-19").hide(); + + }else + { + $("#user_configuration_table-18").show(); + $("#user_configuration_table-19").show() + } + + +} + /* ]]> */ diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php index 63caad6d3f..4e8cfbb2c1 100644 --- a/pandora_console/godmode/users/user_list.php +++ b/pandora_console/godmode/users/user_list.php @@ -297,7 +297,14 @@ if (defined('METACONSOLE')) { $form_filter = "
"; $form_filter .= html_print_table($table, true); $form_filter .= '
'; - ui_toggle($form_filter, __('Users control filter'), __('Toggle filter(s)'), !$search); + ui_toggle( + $form_filter, + __('Users control filter'), + __('Toggle filter(s)'), + '', + '', + !$search + ); } // Urls to sort the table. diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php index da163406ee..9ba322d42f 100644 --- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -361,50 +361,61 @@ class DiscoveryTaskList extends Wizard $recon_tasks = []; } - $url_ajax = $config['homeurl'].'ajax.php'; + $url_ajax = $config['homeurl'].'ajax.php'; - $table = new StdClass(); - $table->cellpadding = 0; - $table->cellspacing = 0; - $table->width = '100%'; - $table->class = 'info_table'; - $table->head = []; - $table->data = []; - $table->align = []; - $table->headstyle = []; + $table = new StdClass(); + $table->cellpadding = 0; + $table->cellspacing = 0; + $table->width = '100%'; + $table->class = 'info_table'; + $table->head = []; + $table->data = []; + $table->align = []; + $table->headstyle = []; for ($i = 0; $i < 9; $i++) { $table->headstyle[$i] = 'text-align: left;'; } - $table->head[0] = __('Force'); - $table->align[0] = 'left'; + // Status. + $table->headstyle[5] .= 'min-width: 100px; width: 100px;'; + // Task type. + $table->headstyle[6] .= 'min-width: 200px; width: 150px;'; + // Progress. + $table->headstyle[7] .= 'min-width: 150px; width: 150px;'; + // Updated at. + $table->headstyle[8] .= 'min-width: 150px; width: 150px;'; + // Operations. + $table->headstyle[9] .= 'min-width: 150px; width: 150px;'; - $table->head[1] = __('Task name'); - $table->align[1] = 'left'; + $table->head[0] = __('Force'); + $table->align[0] = 'left'; - $table->head[2] = __('Server name'); - $table->align[2] = 'left'; + $table->head[1] = __('Task name'); + $table->align[1] = 'left'; - $table->head[3] = __('Interval'); - $table->align[3] = 'left'; + $table->head[2] = __('Server name'); + $table->align[2] = 'left'; - $table->head[4] = __('Network'); - $table->align[4] = 'left'; + $table->head[3] = __('Interval'); + $table->align[3] = 'left'; - $table->head[5] = __('Status'); - $table->align[5] = 'left'; + $table->head[4] = __('Network'); + $table->align[4] = 'left'; - $table->head[6] = __('Task type'); - $table->align[6] = 'left'; + $table->head[5] = __('Status'); + $table->align[5] = 'left'; - $table->head[7] = __('Progress'); - $table->align[7] = 'left'; + $table->head[6] = __('Task type'); + $table->align[6] = 'left'; - $table->head[8] = __('Updated at'); - $table->align[8] = 'left'; + $table->head[7] = __('Progress'); + $table->align[7] = 'left'; - $table->head[9] = __('Operations'); - $table->align[9] = 'left'; + $table->head[8] = __('Updated at'); + $table->align[8] = 'left'; + + $table->head[9] = __('Operations'); + $table->align[9] = 'left'; foreach ($recon_tasks as $task) { $data = []; @@ -553,13 +564,7 @@ class DiscoveryTaskList extends Wizard if ($task['status'] <= 0 || $task['status'] > 100) { $data[7] = '-'; } else { - $data[7] = progress_bar( - $task['status'], - 100, - 20, - __('Progress').':'.$task['status'].'%', - 1 - ); + $data[7] = ui_progress($task['status'], '100%', 1.5); } if ($task['utimestamp'] > 0) { @@ -646,20 +651,24 @@ class DiscoveryTaskList extends Wizard array_push($table->data, $data); } - echo '

'.__('Server tasks').'

'; if (empty($table->data)) { - echo '
'.__('Server').' '.$server_name.' '.__('has no discovery tasks assigned').'
'; - return false; + $content = '
'.__('Server').' '.$server_name.' '.__('has no discovery tasks assigned').'
'; + $return = false; } else { - html_print_table($table); + $content = html_print_table($table, true); + $return = true; } + ui_toggle($content, __('Server Tasks'), '', '', false); + // Div neccesary for modal map task. echo ''; unset($table); ui_require_javascript_file('pandora_taskList'); + + return $return; } return true; diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 6468f1d2ac..2398e3b1c5 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -659,18 +659,18 @@ class Wizard if ($input['arguments']['inline'] != 'true') { $output .= '
'; } else { - $output .= '
'; + $output .= '
'; if (!isset($input['extra'])) { $output .= '
'; } if (isset($input['extra'])) { - $output .= '
'; + $output .= '
'; } } if ($input['arguments']['inline'] == 'true' && isset($input['extra'])) { - $output .= '
'; + $output .= '
'; } $output .= '
'; @@ -690,11 +690,11 @@ class Wizard $output .= $this->printInput($input['arguments']); $output .= '
'; } else if ($input['arguments']['inline'] == 'true') { - $output .= '
'; - if (isset($input['extra'])) { - $output .= '
'; + $output .= '
'; + $output .= '
'; } else { + $output .= '
'; $output .= '
'; } @@ -783,20 +783,24 @@ class Wizard /** * Print a form. * - * @param array $data Definition of target form to be printed. - * @param boolean $return Return as string or direct output. + * @param array $data Definition of target form to be printed. + * @param boolean $return Return as string or direct output. + * @param boolean $print_white_box Print a white box. * * @return string HTML code. */ - public function printForm(array $data, bool $return=false, bool $print_white_box=false) - { + public function printForm( + array $data, + bool $return=false, + bool $print_white_box=false + ) { $form = $data['form']; $inputs = $data['inputs']; $js = $data['js']; $cb_function = $data['cb_function']; $cb_args = $data['cb_args']; - $output_head = '
'; if ($return === false) { @@ -868,7 +872,7 @@ class Wizard $cb_function = $data['cb_function']; $cb_args = $data['cb_args']; - $output_head = ''; if ($return === false) { @@ -963,7 +967,7 @@ class Wizard $cb_function = $data['cb_function']; $cb_args = $data['cb_args']; - $output_head = ''; if ($return === false) { diff --git a/pandora_console/images/arrow_left_green.png b/pandora_console/images/arrow_left_green.png new file mode 100644 index 0000000000..b6aadc9639 Binary files /dev/null and b/pandora_console/images/arrow_left_green.png differ diff --git a/pandora_console/images/arrow_right_green.png b/pandora_console/images/arrow_right_green.png new file mode 100644 index 0000000000..a772cd6cf4 Binary files /dev/null and b/pandora_console/images/arrow_right_green.png differ diff --git a/pandora_console/images/groups_small_white/application_osx.png b/pandora_console/images/groups_small_white/application_osx.png new file mode 100644 index 0000000000..409d9742d2 Binary files /dev/null and b/pandora_console/images/groups_small_white/application_osx.png differ diff --git a/pandora_console/images/groups_small_white/application_osx_terminal.png b/pandora_console/images/groups_small_white/application_osx_terminal.png new file mode 100644 index 0000000000..3deb76aa34 Binary files /dev/null and b/pandora_console/images/groups_small_white/application_osx_terminal.png differ diff --git a/pandora_console/images/groups_small_white/applications.png b/pandora_console/images/groups_small_white/applications.png new file mode 100644 index 0000000000..362ed8b98d Binary files /dev/null and b/pandora_console/images/groups_small_white/applications.png differ diff --git a/pandora_console/images/groups_small_white/bricks.png b/pandora_console/images/groups_small_white/bricks.png new file mode 100644 index 0000000000..b68255b88b Binary files /dev/null and b/pandora_console/images/groups_small_white/bricks.png differ diff --git a/pandora_console/images/groups_small_white/chart_organisation.png b/pandora_console/images/groups_small_white/chart_organisation.png new file mode 100644 index 0000000000..d80fc4f65f Binary files /dev/null and b/pandora_console/images/groups_small_white/chart_organisation.png differ diff --git a/pandora_console/images/groups_small_white/clock.png b/pandora_console/images/groups_small_white/clock.png new file mode 100644 index 0000000000..dc16f55773 Binary files /dev/null and b/pandora_console/images/groups_small_white/clock.png differ diff --git a/pandora_console/images/groups_small_white/computer.png b/pandora_console/images/groups_small_white/computer.png new file mode 100644 index 0000000000..5eab00e255 Binary files /dev/null and b/pandora_console/images/groups_small_white/computer.png differ diff --git a/pandora_console/images/groups_small_white/database.png b/pandora_console/images/groups_small_white/database.png new file mode 100644 index 0000000000..397f3fa5d3 Binary files /dev/null and b/pandora_console/images/groups_small_white/database.png differ diff --git a/pandora_console/images/groups_small_white/database_gear.png b/pandora_console/images/groups_small_white/database_gear.png new file mode 100644 index 0000000000..72a6b63d0f Binary files /dev/null and b/pandora_console/images/groups_small_white/database_gear.png differ diff --git a/pandora_console/images/groups_small_white/drive_network.png b/pandora_console/images/groups_small_white/drive_network.png new file mode 100644 index 0000000000..4e1cd615c6 Binary files /dev/null and b/pandora_console/images/groups_small_white/drive_network.png differ diff --git a/pandora_console/images/groups_small_white/email.png b/pandora_console/images/groups_small_white/email.png new file mode 100644 index 0000000000..496991da88 Binary files /dev/null and b/pandora_console/images/groups_small_white/email.png differ diff --git a/pandora_console/images/groups_small_white/eye.png b/pandora_console/images/groups_small_white/eye.png new file mode 100644 index 0000000000..f5c8a4e940 Binary files /dev/null and b/pandora_console/images/groups_small_white/eye.png differ diff --git a/pandora_console/images/groups_small_white/firewall.png b/pandora_console/images/groups_small_white/firewall.png new file mode 100644 index 0000000000..261adbcb1e Binary files /dev/null and b/pandora_console/images/groups_small_white/firewall.png differ diff --git a/pandora_console/images/groups_small_white/heart.png b/pandora_console/images/groups_small_white/heart.png new file mode 100644 index 0000000000..6bfec0298a Binary files /dev/null and b/pandora_console/images/groups_small_white/heart.png differ diff --git a/pandora_console/images/groups_small_white/house.png b/pandora_console/images/groups_small_white/house.png new file mode 100644 index 0000000000..72ab42dd35 Binary files /dev/null and b/pandora_console/images/groups_small_white/house.png differ diff --git a/pandora_console/images/groups_small_white/images.png b/pandora_console/images/groups_small_white/images.png new file mode 100644 index 0000000000..195c7e222b Binary files /dev/null and b/pandora_console/images/groups_small_white/images.png differ diff --git a/pandora_console/images/groups_small_white/lightning.png b/pandora_console/images/groups_small_white/lightning.png new file mode 100644 index 0000000000..31a0670a68 Binary files /dev/null and b/pandora_console/images/groups_small_white/lightning.png differ diff --git a/pandora_console/images/groups_small_white/lock.png b/pandora_console/images/groups_small_white/lock.png new file mode 100644 index 0000000000..522ff71bd6 Binary files /dev/null and b/pandora_console/images/groups_small_white/lock.png differ diff --git a/pandora_console/images/groups_small_white/network.png b/pandora_console/images/groups_small_white/network.png new file mode 100644 index 0000000000..1a8573a729 Binary files /dev/null and b/pandora_console/images/groups_small_white/network.png differ diff --git a/pandora_console/images/groups_small_white/plugin.png b/pandora_console/images/groups_small_white/plugin.png new file mode 100644 index 0000000000..051ec05d6b Binary files /dev/null and b/pandora_console/images/groups_small_white/plugin.png differ diff --git a/pandora_console/images/groups_small_white/printer.png b/pandora_console/images/groups_small_white/printer.png new file mode 100644 index 0000000000..4187e87a00 Binary files /dev/null and b/pandora_console/images/groups_small_white/printer.png differ diff --git a/pandora_console/images/groups_small_white/server_database.png b/pandora_console/images/groups_small_white/server_database.png new file mode 100644 index 0000000000..864e3cb7cb Binary files /dev/null and b/pandora_console/images/groups_small_white/server_database.png differ diff --git a/pandora_console/images/groups_small_white/transmit.png b/pandora_console/images/groups_small_white/transmit.png new file mode 100644 index 0000000000..d27f5c377d Binary files /dev/null and b/pandora_console/images/groups_small_white/transmit.png differ diff --git a/pandora_console/images/groups_small_white/without_group.png b/pandora_console/images/groups_small_white/without_group.png new file mode 100644 index 0000000000..30915bd101 Binary files /dev/null and b/pandora_console/images/groups_small_white/without_group.png differ diff --git a/pandora_console/images/groups_small_white/world.png b/pandora_console/images/groups_small_white/world.png new file mode 100644 index 0000000000..dcfd04139b Binary files /dev/null and b/pandora_console/images/groups_small_white/world.png differ diff --git a/pandora_console/images/heartbeat_green.gif b/pandora_console/images/heartbeat_green.gif new file mode 100644 index 0000000000..49697adbc7 Binary files /dev/null and b/pandora_console/images/heartbeat_green.gif differ diff --git a/pandora_console/images/heartbeat_red.gif b/pandora_console/images/heartbeat_red.gif new file mode 100644 index 0000000000..e0c4b24ccd Binary files /dev/null and b/pandora_console/images/heartbeat_red.gif differ diff --git a/pandora_console/images/status_sets/default/module_alertsfired_rounded.png b/pandora_console/images/status_sets/default/module_alertsfired_rounded.png new file mode 100644 index 0000000000..7a9b5ae0cd Binary files /dev/null and b/pandora_console/images/status_sets/default/module_alertsfired_rounded.png differ diff --git a/pandora_console/images/status_sets/default/module_critical_rounded.png b/pandora_console/images/status_sets/default/module_critical_rounded.png new file mode 100644 index 0000000000..7fceda18da Binary files /dev/null and b/pandora_console/images/status_sets/default/module_critical_rounded.png differ diff --git a/pandora_console/images/status_sets/default/module_no_data_rounded.png b/pandora_console/images/status_sets/default/module_no_data_rounded.png new file mode 100644 index 0000000000..fd5e433ece Binary files /dev/null and b/pandora_console/images/status_sets/default/module_no_data_rounded.png differ diff --git a/pandora_console/images/status_sets/default/module_ok_rounded.png b/pandora_console/images/status_sets/default/module_ok_rounded.png new file mode 100644 index 0000000000..d47f2ef4ff Binary files /dev/null and b/pandora_console/images/status_sets/default/module_ok_rounded.png differ diff --git a/pandora_console/images/status_sets/default/module_unknown_rounded.png b/pandora_console/images/status_sets/default/module_unknown_rounded.png new file mode 100644 index 0000000000..2ec6d98f39 Binary files /dev/null and b/pandora_console/images/status_sets/default/module_unknown_rounded.png differ diff --git a/pandora_console/images/status_sets/default/module_warning_rounded.png b/pandora_console/images/status_sets/default/module_warning_rounded.png new file mode 100644 index 0000000000..c28924178d Binary files /dev/null and b/pandora_console/images/status_sets/default/module_warning_rounded.png differ diff --git a/pandora_console/images/status_sets/default/severity_critical_rounded.png b/pandora_console/images/status_sets/default/severity_critical_rounded.png new file mode 100644 index 0000000000..7fceda18da Binary files /dev/null and b/pandora_console/images/status_sets/default/severity_critical_rounded.png differ diff --git a/pandora_console/images/status_sets/default/severity_informational_rounded.png b/pandora_console/images/status_sets/default/severity_informational_rounded.png new file mode 100644 index 0000000000..fd5e433ece Binary files /dev/null and b/pandora_console/images/status_sets/default/severity_informational_rounded.png differ diff --git a/pandora_console/images/status_sets/default/severity_maintenance_rounded.png b/pandora_console/images/status_sets/default/severity_maintenance_rounded.png new file mode 100644 index 0000000000..2ec6d98f39 Binary files /dev/null and b/pandora_console/images/status_sets/default/severity_maintenance_rounded.png differ diff --git a/pandora_console/images/status_sets/default/severity_major_rounded.png b/pandora_console/images/status_sets/default/severity_major_rounded.png new file mode 100644 index 0000000000..cc6523e28e Binary files /dev/null and b/pandora_console/images/status_sets/default/severity_major_rounded.png differ diff --git a/pandora_console/images/status_sets/default/severity_minor_rounded.png b/pandora_console/images/status_sets/default/severity_minor_rounded.png new file mode 100644 index 0000000000..fd3ea3d2d9 Binary files /dev/null and b/pandora_console/images/status_sets/default/severity_minor_rounded.png differ diff --git a/pandora_console/images/status_sets/default/severity_normal_rounded.png b/pandora_console/images/status_sets/default/severity_normal_rounded.png new file mode 100644 index 0000000000..d47f2ef4ff Binary files /dev/null and b/pandora_console/images/status_sets/default/severity_normal_rounded.png differ diff --git a/pandora_console/images/status_sets/default/severity_warning_rounded.png b/pandora_console/images/status_sets/default/severity_warning_rounded.png new file mode 100644 index 0000000000..c28924178d Binary files /dev/null and b/pandora_console/images/status_sets/default/severity_warning_rounded.png differ diff --git a/pandora_console/include/ajax/custom_fields.php b/pandora_console/include/ajax/custom_fields.php index 9baacdcdc2..21d3d11085 100644 --- a/pandora_console/include/ajax/custom_fields.php +++ b/pandora_console/include/ajax/custom_fields.php @@ -299,6 +299,7 @@ if (check_login()) { 'status' => "
".$image_status.'
', 'id_agent' => $values['id_tagente'], 'id_server' => $values['id_tmetaconsole_setup'], + 'status_value' => $values['status'], ]; } diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index 6ba163c7ed..ce173898b2 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -26,6 +26,9 @@ * ============================================================================ */ +// Begin. +global $config; + require_once 'include/functions_events.php'; require_once 'include/functions_agents.php'; require_once 'include/functions_ui.php'; @@ -35,6 +38,21 @@ require_once 'include/functions.php'; enterprise_include_once('meta/include/functions_events_meta.php'); enterprise_include_once('include/functions_metaconsole.php'); +// Check access. +check_login(); + +if (! check_acl($config['id_user'], 0, 'ER') + && ! check_acl($config['id_user'], 0, 'EW') + && ! check_acl($config['id_user'], 0, 'EM') +) { + db_pandora_audit( + 'ACL Violation', + 'Trying to access event viewer' + ); + include 'general/noaccess.php'; + return; +} + $get_events_details = (bool) get_parameter('get_events_details'); $get_list_events_agents = (bool) get_parameter('get_list_events_agents'); $get_extended_event = (bool) get_parameter('get_extended_event'); @@ -55,6 +73,680 @@ $total_events = (bool) get_parameter('total_events'); $total_event_graph = (bool) get_parameter('total_event_graph'); $graphic_event_group = (bool) get_parameter('graphic_event_group'); $get_table_response_command = (bool) get_parameter('get_table_response_command'); +$save_filter_modal = get_parameter('save_filter_modal', 0); +$load_filter_modal = get_parameter('load_filter_modal', 0); +$save_filter = get_parameter('save_filter', 0); +$get_filter_values = get_parameter('get_filter_values', 0); +$update_event_filter = get_parameter('update_event_filter', 0); +$save_event_filter = get_parameter('save_event_filter', 0); +$in_process_event = get_parameter('in_process_event', 0); +$validate_event = get_parameter('validate_event', 0); +$delete_event = get_parameter('delete_event', 0); + +// Delete event (filtered or not). +if ($delete_event) { + $filter = get_parameter('filter', []); + $id_evento = get_parameter('id_evento', 0); + $event_rep = get_parameter('event_rep', 0); + + if ($event_rep === 0) { + // Disable group by when there're result is unique. + $filter['group_rep'] = 0; + } + + // Check acl. + if (! check_acl($config['id_user'], 0, 'EM')) { + echo 'unauthorized'; + return; + } + + $r = events_delete($id_evento, $filter); + if ($r === false) { + echo 'Failed'; + } else { + echo $r; + } + + return; +} + +// Validates an event (filtered or not). +if ($validate_event) { + $filter = get_parameter('filter', []); + $id_evento = get_parameter('id_evento', 0); + $event_rep = get_parameter('event_rep', 0); + + if ($event_rep === 0) { + // Disable group by when there're result is unique. + $filter['group_rep'] = 0; + } + + // Check acl. + if (! check_acl($config['id_user'], 0, 'EW')) { + echo 'unauthorized'; + return; + } + + $r = events_update_status($id_evento, EVENT_VALIDATE, $filter); + if ($r === false) { + echo 'Failed'; + } else { + echo $r; + } + + return; +} + +// Sets status to in progress. +if ($in_process_event) { + $filter = get_parameter('filter', []); + $id_evento = get_parameter('id_evento', 0); + $event_rep = get_parameter('event_rep', 0); + + if ($event_rep === 0) { + // Disable group by when there're result is unique. + $filter['group_rep'] = 0; + } + + // Check acl. + if (! check_acl($config['id_user'], 0, 'EW')) { + echo 'unauthorized'; + return; + } + + $r = events_update_status($id_evento, EVENT_PROCESS, $filter); + if ($r === false) { + echo 'Failed'; + } else { + echo $r; + } + + return; +} + +// Saves an event filter. +if ($save_event_filter) { + $values = []; + $values['id_name'] = get_parameter('id_name'); + $values['id_group'] = get_parameter('id_group'); + $values['event_type'] = get_parameter('event_type'); + $values['severity'] = get_parameter('severity'); + $values['status'] = get_parameter('status'); + $values['search'] = get_parameter('search'); + $values['text_agent'] = get_parameter('text_agent'); + $values['id_agent'] = get_parameter('id_agent'); + $values['id_agent_module'] = get_parameter('id_agent_module'); + $values['pagination'] = get_parameter('pagination'); + $values['event_view_hr'] = get_parameter('event_view_hr'); + $values['id_user_ack'] = get_parameter('id_user_ack'); + $values['group_rep'] = get_parameter('group_rep'); + $values['tag_with'] = get_parameter('tag_with', io_json_mb_encode([])); + $values['tag_without'] = get_parameter( + 'tag_without', + io_json_mb_encode([]) + ); + $values['filter_only_alert'] = get_parameter('filter_only_alert'); + $values['id_group_filter'] = get_parameter('id_group_filter'); + $values['date_from'] = get_parameter('date_from'); + $values['date_to'] = get_parameter('date_to'); + $values['source'] = get_parameter('source'); + $values['id_extra'] = get_parameter('id_extra'); + $values['user_comment'] = get_parameter('user_comment'); + + $exists = (bool) db_get_value_filter( + 'id_filter', + 'tevent_filter', + $values + ); + + if ($exists) { + echo 'duplicate'; + } else { + $result = db_process_sql_insert('tevent_filter', $values); + + if ($result === false) { + echo 'error'; + } else { + echo $result; + } + } +} + +if ($update_event_filter) { + $values = []; + $id = get_parameter('id'); + $values['id_group'] = get_parameter('id_group'); + $values['event_type'] = get_parameter('event_type'); + $values['severity'] = get_parameter('severity'); + $values['status'] = get_parameter('status'); + $values['search'] = get_parameter('search'); + $values['text_agent'] = get_parameter('text_agent'); + $values['id_agent'] = get_parameter('id_agent'); + $values['id_agent_module'] = get_parameter('id_agent_module'); + $values['pagination'] = get_parameter('pagination'); + $values['event_view_hr'] = get_parameter('event_view_hr'); + $values['id_user_ack'] = get_parameter('id_user_ack'); + $values['group_rep'] = get_parameter('group_rep'); + $values['tag_with'] = get_parameter('tag_with', io_json_mb_encode([])); + $values['tag_without'] = get_parameter( + 'tag_without', + io_json_mb_encode([]) + ); + $values['filter_only_alert'] = get_parameter('filter_only_alert'); + $values['id_group_filter'] = get_parameter('id_group_filter'); + $values['date_from'] = get_parameter('date_from'); + $values['date_to'] = get_parameter('date_to'); + $values['source'] = get_parameter('source'); + $values['id_extra'] = get_parameter('id_extra'); + $values['user_comment'] = get_parameter('user_comment'); + + if (io_safe_output($values['tag_with']) == '["0"]') { + $values['tag_with'] = '[]'; + } + + if (io_safe_output($values['tag_without']) == '["0"]') { + $values['tag_without'] = '[]'; + } + + $result = db_process_sql_update( + 'tevent_filter', + $values, + ['id_filter' => $id] + ); + + if ($result === false) { + echo 'error'; + } else { + echo 'ok'; + } +} + +// Get db values of a single filter. +if ($get_filter_values) { + $id_filter = get_parameter('id'); + + $event_filter = events_get_event_filter($id_filter); + + $event_filter['search'] = io_safe_output($event_filter['search']); + $event_filter['id_name'] = io_safe_output($event_filter['id_name']); + $event_filter['tag_with'] = base64_encode( + io_safe_output($event_filter['tag_with']) + ); + $event_filter['tag_without'] = base64_encode( + io_safe_output($event_filter['tag_without']) + ); + + echo io_json_mb_encode($event_filter); +} + +if ($load_filter_modal) { + $current = get_parameter('current_filter', ''); + $filters = events_get_event_filter_select(); + $user_groups_array = users_get_groups_for_select( + $config['id_user'], + $access, + true, + true, + false + ); + + echo '
'; + $table = new StdClass; + $table->id = 'load_filter_form'; + $table->width = '100%'; + $table->cellspacing = 4; + $table->cellpadding = 4; + $table->class = 'databox'; + if (is_metaconsole()) { + $table->cellspacing = 0; + $table->cellpadding = 0; + $table->class = 'databox filters'; + } + + $table->styleTable = 'font-weight: bold; color: #555; text-align:left;'; + if (!is_metaconsole()) { + $table->style[0] = 'width: 50%; width:50%;'; + } + + $data = []; + $table->rowid[3] = 'update_filter_row1'; + $data[0] = __('Load filter').$jump; + $data[0] .= html_print_select( + $filters, + 'filter_id', + $current, + '', + __('None'), + 0, + true + ); + $data[1] = html_print_submit_button( + __('Load filter'), + 'load_filter', + false, + 'class="sub upd" onclick="load_form_filter();"', + true + ); + $table->data[] = $data; + $table->rowclass[] = ''; + + html_print_table($table); + echo '
'; + ?> + + '; + if (check_acl($config['id_user'], 0, 'EW') + || check_acl($config['id_user'], 0, 'EM') + ) { + echo '
'; + $table = new StdClass; + $table->id = 'save_filter_form'; + $table->width = '100%'; + $table->cellspacing = 4; + $table->cellpadding = 4; + $table->class = 'databox'; + if (is_metaconsole()) { + $table->class = 'databox filters'; + $table->cellspacing = 0; + $table->cellpadding = 0; + } + + $table->styleTable = 'font-weight: bold; text-align:left;'; + if (!is_metaconsole()) { + $table->style[0] = 'width: 50%; width:50%;'; + } + + $data = []; + $table->rowid[0] = 'update_save_selector'; + $data[0] = html_print_radio_button( + 'filter_mode', + 'new', + '', + true, + true + ).__('New filter').''; + + $data[1] = html_print_radio_button( + 'filter_mode', + 'update', + '', + false, + true + ).__('Update filter').''; + + $table->data[] = $data; + $table->rowclass[] = ''; + + $data = []; + $table->rowid[1] = 'save_filter_row1'; + $data[0] = __('Filter name').$jump; + $data[0] .= html_print_input_text('id_name', '', '', 15, 255, true); + if (is_metaconsole()) { + $data[1] = __('Save in Group').$jump; + } else { + $data[1] = __('Filter group').$jump; + } + + $user_groups_array = users_get_groups_for_select( + $config['id_user'], + 'EW', + users_can_manage_group_all(), + true + ); + + $data[1] .= html_print_select( + $user_groups_array, + 'id_group_filter', + $id_group_filter, + '', + '', + 0, + true, + false, + false, + 'w130' + ); + + $table->data[] = $data; + $table->rowclass[] = ''; + + $data = []; + $table->rowid[2] = 'save_filter_row2'; + + $table->data[] = $data; + $table->rowclass[] = ''; + + $data = []; + $table->rowid[3] = 'update_filter_row1'; + $data[0] = __('Overwrite filter').$jump; + // Fix : Only admin user can see filters of group ALL for update. + $_filters_update = events_get_event_filter_select(false); + + $data[0] .= html_print_select( + $_filters_update, + 'overwrite_filter', + '', + '', + '', + 0, + true + ); + $data[1] = html_print_submit_button( + __('Update filter'), + 'update_filter', + false, + 'class="sub upd" onclick="save_update_filter();"', + true + ); + + $table->data[] = $data; + $table->rowclass[] = ''; + + html_print_table($table); + echo '
'; + echo html_print_submit_button( + __('Save filter'), + 'save_filter', + false, + 'class="sub upd" style="float:right;" onclick="save_new_filter();"', + true + ); + echo '
'; + } else { + include 'general/noaccess.php'; + } + + echo '
'; + ?> + + "; + $tabs = "'; @@ -456,30 +1148,30 @@ if ($get_extended_event) { switch ($event['criticity']) { default: case 0: - $img_sev = 'images/status_sets/default/severity_maintenance.png'; + $img_sev = 'images/status_sets/default/severity_maintenance_rounded.png'; break; case 1: - $img_sev = 'images/status_sets/default/severity_informational.png'; + $img_sev = 'images/status_sets/default/severity_informational_rounded.png'; break; case 2: - $img_sev = 'images/status_sets/default/severity_normal.png'; + $img_sev = 'images/status_sets/default/severity_normal_rounded.png'; break; case 3: - $img_sev = 'images/status_sets/default/severity_warning.png'; + $img_sev = 'images/status_sets/default/severity_warning_rounded.png'; break; case 4: - $img_sev = 'images/status_sets/default/severity_critical.png'; + $img_sev = 'images/status_sets/default/severity_critical_rounded.png'; break; case 5: - $img_sev = 'images/status_sets/default/severity_minor.png'; + $img_sev = 'images/status_sets/default/severity_minor_rounded.png'; break; case 6: - $img_sev = 'images/status_sets/default/severity_major.png'; + $img_sev = 'images/status_sets/default/severity_major_rounded.png'; break; } @@ -498,7 +1190,7 @@ if ($get_extended_event) { $childrens_ids ))) ) { - $responses = events_page_responses($event, $childrens_ids); + $responses = events_page_responses($event); } else { $responses = ''; } @@ -535,7 +1227,7 @@ if ($get_extended_event) { $general = events_page_general($event); - $comments = events_page_comments($event, $childrens_ids); + $comments = events_page_comments($event); $notifications = ''; $notifications .= ''; @@ -717,9 +1409,15 @@ if ($table_events) { 'event_condition', 'AND' ); - echo '
'; - echo ''; - echo html_print_checkbox('all_events_24h', $all_events_24h, $all_events_24h, true, false, '', true); + echo '
'; + echo ''; + echo html_print_switch( + [ + 'name' => 'all_events_24h', + 'value' => $all_events_24h, + 'id' => 'checkbox-all_events_24h', + ] + ); echo '
'; $date_subtract_day = (time() - (24 * 60 * 60)); diff --git a/pandora_console/include/ajax/events_extended.php b/pandora_console/include/ajax/events_extended.php index 9c6ea27482..1fb3e94c63 100644 --- a/pandora_console/include/ajax/events_extended.php +++ b/pandora_console/include/ajax/events_extended.php @@ -84,7 +84,7 @@ if ($get_extended_info == 1) { $table->head = []; $table->cellspacing = 2; $table->cellpadding = 2; - $table->class = 'events_show_more_table'; + $table->class = 'table_modal_alternate'; $output = []; $output[] = ''.__('Timestamp').''; diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 7b11249f18..ef998be34a 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -1,17 +1,33 @@ 0) { - $data[] = human_milliseconds_to_string(($row['data'] / $post_process)); + $data_macro = modules_get_unit_macro($row[$attr[0]], $unit); + if ($data_macro) { + $data[] = $data_macro; } else { - $data[] = human_milliseconds_to_string($row['data']); + $data[] = remove_right_zeros(number_format($row[$attr[0]], $config['graph_precision'])); } } else { $data[] = remove_right_zeros(number_format($row[$attr[0]], $config['graph_precision'])); @@ -523,7 +544,8 @@ if (check_login()) { $agent_w = check_acl($config['id_user'], 0, 'AW'); $access = ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR'); - $id_agente = $id_agent = (int) get_parameter('id_agente', 0); + $id_agent = (int) get_parameter('id_agente', 0); + $id_agente = $id_agent; $show_notinit = (int) get_parameter('show_notinit', 0); $cluster_list = (int) get_parameter('cluster_list', 0); $url = 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agent; @@ -549,6 +571,7 @@ if (check_login()) { case 'type': switch ($sort) { case 'up': + default: $selectTypeUp = $selected; $order[] = [ 'field' => 'tagente_modulo.id_modulo', @@ -583,6 +606,10 @@ if (check_login()) { 'order' => 'DESC', ]; break; + + default: + // Ignore. + break; } break; @@ -603,6 +630,10 @@ if (check_login()) { 'order' => '', ]; break; + + default: + // Ignore. + break; } break; @@ -623,6 +654,10 @@ if (check_login()) { 'order' => 'DESC', ]; break; + + default: + // Ignore. + break; } break; @@ -645,7 +680,8 @@ if (check_login()) { break; } - // Fix: for tag functionality groups have to be all user_groups (propagate ACL funct!) + // Fix: for tag functionality groups have to be all user_groups + // (propagate ACL funct!). $groups = users_get_groups($config['id_user'], $access); $tags_join = ''; @@ -669,7 +705,7 @@ if (check_login()) { $status_filter_sql = '1 = 1'; if ($status_filter_monitor == AGENT_MODULE_STATUS_NOT_NORMAL) { - // Not normal + // Not normal. $status_filter_sql = ' tagente_estado.estado <> 0'; } else if ($status_filter_monitor != -1) { $status_filter_sql = 'tagente_estado.estado = '.$status_filter_monitor; @@ -693,7 +729,7 @@ if (check_login()) { } // Count monitors/modules - // Build the order sql + // Build the order sql. $first = true; foreach ($order as $ord) { if ($first) { @@ -769,6 +805,7 @@ if (check_login()) { $table = new stdClass(); $table->width = '100%'; + $table->styleTable = 'border: 0;border-radius: 0;'; $table->cellpadding = 0; $table->cellspacing = 0; $table->class = 'info_table'; @@ -791,19 +828,29 @@ if (check_login()) { $table->head[6] = __('Thresholds'); $table->head[7] = __('Data'); $table->head[8] = __('Graph'); - $table->headstyle[8] = 'min-width: 60px'; $table->head[9] = __('Last contact').ui_get_sorting_arrows($url_up_last, $url_down_last, $selectLastContactUp, $selectLastContactDown); - $table->align = [ - 'left', - 'left', - 'left', - 'left', - 'left', - 'left', - 'left', - 'left', - 'left', - ]; + $table->align = []; + $table->align[0] = 'center'; + $table->align[1] = 'left'; + $table->align[2] = 'left'; + $table->align[3] = 'left'; + $table->align[4] = 'left'; + $table->align[5] = 'left'; + $table->align[6] = 'center'; + $table->align[7] = 'left'; + $table->align[8] = 'center'; + $table->align[9] = 'right'; + + $table->headstyle[2] = 'min-width: 85px'; + $table->headstyle[3] = 'min-width: 130px'; + $table->size[3] = '30%'; + $table->style[3] = 'max-width: 28em;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;'; + $table->size[4] = '30%'; + $table->headstyle[5] = 'min-width: 85px'; + $table->headstyle[6] = 'min-width: 125px; text-align: center;'; + $table->headstyle[7] = 'min-width: 125px;'; + $table->headstyle[8] = 'min-width: 100px; text-align: center;'; + $table->headstyle[9] = 'min-width: 120px; text-align: right;'; $last_modulegroup = 0; $rowIndex = 0; @@ -842,14 +889,14 @@ if (check_login()) { $last_modulegroup = $module['id_module_group']; } - // End of title of group + // End of title of group. } $data = []; if (($module['id_modulo'] != 1) && ($module['id_tipo_modulo'] != 100)) { if ($agent_w) { if ($module['flag'] == 0) { - $data[0] = ''.html_print_image('images/target.png', true, ['border' => '0', 'title' => __('Force')]).''; + $data[0] = ''.html_print_image('images/target.png', true, ['border' => '0', 'title' => __('Force')]).''; } else { $data[0] = ''.html_print_image('images/refresh.png', true, ['border' => '0', 'title' => __('Refresh')]).''; } @@ -936,12 +983,12 @@ if (check_login()) { } } - // Adds tag context information + // Adds tag context information. if (tags_get_modules_tag_count($module['id_agente_modulo']) > 0) { $data[3] .= ' '.html_print_image('images/tag_red.png', true, ['id' => 'tag-details-'.$module['id_agente_modulo'], 'class' => 'img_help']).' '; } - // Adds relations context information + // Adds relations context information. if (modules_relation_exists($module['id_agente_modulo'])) { $data[3] .= ' '.html_print_image('images/link2.png', true, ['id' => 'relations-details-'.$module['id_agente_modulo'], 'class' => 'img_help']).' '; } @@ -964,7 +1011,7 @@ if (check_login()) { $title ); - $data[5] = ui_print_status_image($status, $title, true); + $data[5] = ui_print_module_status($module['estado'], $title, true, false, true); if (!$show_context_help_first_time) { $show_context_help_first_time = true; @@ -973,122 +1020,85 @@ if (check_login()) { } } - if ($module['id_tipo_modulo'] == 24) { - // log4x - switch ($module['datos']) { - case 10: - $salida = 'TRACE'; - $style = 'font-weight:bold; color:darkgreen;'; - break; + if (is_numeric($module['datos']) && !modules_is_string_type($module['id_tipo_modulo'])) { + if ($config['render_proc']) { + switch ($module['id_tipo_modulo']) { + case 2: + case 6: + case 9: + case 18: + case 21: + case 31: + if ($module['datos'] >= 1) { + $salida = $config['render_proc_ok']; + } else { + $salida = $config['render_proc_fail']; + } + break; - case 20: - $salida = 'DEBUG'; - $style = 'font-weight:bold; color:darkgreen;'; - break; - - case 30: - $salida = 'INFO'; - $style = 'font-weight:bold; color:darkgreen;'; - break; - - case 40: - $salida = 'WARN'; - $style = 'font-weight:bold; color:darkorange;'; - break; - - case 50: - $salida = 'ERROR'; - $style = 'font-weight:bold; color:red;'; - break; - - case 60: - $salida = 'FATAL'; - $style = 'font-weight:bold; color:red;'; - break; - } - - $salida = "$salida"; - } else { - if (is_numeric($module['datos']) && !modules_is_string_type($module['id_tipo_modulo'])) { - if ($config['render_proc']) { - switch ($module['id_tipo_modulo']) { - case 2: - case 6: - case 9: - case 18: - case 21: - case 31: - if ($module['datos'] >= 1) { - $salida = $config['render_proc_ok']; - } else { - $salida = $config['render_proc_fail']; - } - break; - - default: - switch ($module['id_tipo_modulo']) { - case 15: - $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module['id_agente_modulo']); - if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') { - if ($module['post_process'] > 0) { - $salida = human_milliseconds_to_string(($module['datos'] / $module['post_process'])); - } else { - $salida = human_milliseconds_to_string($module['datos']); - } + default: + switch ($module['id_tipo_modulo']) { + case 15: + $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module['id_agente_modulo']); + if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') { + if ($module['post_process'] > 0) { + $salida = human_milliseconds_to_string(($module['datos'] / $module['post_process'])); } else { - $salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision'])); + $salida = human_milliseconds_to_string($module['datos']); } - break; - - default: - $salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision'])); - break; - } - break; - } - } else { - switch ($module['id_tipo_modulo']) { - case 15: - $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module['id_agente_modulo']); - if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') { - if ($module['post_process'] > 0) { - $salida = human_milliseconds_to_string(($module['datos'] / $module['post_process'])); } else { - $salida = human_milliseconds_to_string($module['datos']); + $salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision'])); } - } else { + break; + + default: $salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision'])); - } - break; - - default: - $salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision'])); - break; - } - } - - // Show units ONLY in numeric data types - if (isset($module['unit'])) { - $data_macro = modules_get_unit_macro($module['datos'], $module['unit']); - if ($data_macro) { - $salida = $data_macro; - } else { - $salida .= ' '.''.io_safe_output($module['unit']).''; - } + break; + } + break; } } else { + switch ($module['id_tipo_modulo']) { + case 15: + $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module['id_agente_modulo']); + if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') { + if ($module['post_process'] > 0) { + $salida = human_milliseconds_to_string(($module['datos'] / $module['post_process'])); + } else { + $salida = human_milliseconds_to_string($module['datos']); + } + } else { + $salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision'])); + } + break; + + default: + $salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision'])); + break; + } + } + + // Show units ONLY in numeric data types + if (isset($module['unit'])) { $data_macro = modules_get_unit_macro($module['datos'], $module['unit']); if ($data_macro) { $salida = $data_macro; } else { - $salida = ui_print_module_string_value( - $module['datos'], - $module['id_agente_modulo'], - $module['current_interval'], - $module['module_name'] - ); + $salida .= ' '.io_safe_output($module['unit']).''; } } + } else { + $data_macro = modules_get_unit_macro($module['datos'], $module['unit']); + if ($data_macro) { + $salida = $data_macro; + } else { + $salida = ui_print_module_string_value( + $module['datos'], + $module['id_agente_modulo'], + $module['current_interval'], + $module['module_name'] + ); + } } if ($module['id_tipo_modulo'] != 25) { @@ -1120,17 +1130,17 @@ if (check_login()) { $draw_events = 0; } - $link = "winopeng_var('".'operation/agentes/stat_win.php?'."type=$graph_type&".'period='.SECONDS_1DAY.'&'.'id='.$module['id_agente_modulo'].'&'.'label='.rawurlencode( + $link = "winopeng_var('".'operation/agentes/stat_win.php?'."type=$graph_type&".'period='.SECONDS_1DAY.'&id='.$module['id_agente_modulo'].'&label='.rawurlencode( urlencode( base64_encode($module['nombre']) ) - ).'&'.'refresh='.SECONDS_10MINUTES.'&'."draw_events=$draw_events', 'day_".$win_handle."', 1000, 650)"; + ).'&refresh='.SECONDS_10MINUTES.'&'."draw_events=$draw_events', 'day_".$win_handle."', 1000, 650)"; if (!is_snapshot_data($module['datos'])) { $data[8] .= ''.html_print_image('images/chart_curve.png', true, ['border' => '0', 'alt' => '']).'   '; } $server_name = ''; - $data[8] .= "".html_print_image('images/binary.png', true, ['border' => '0', 'alt' => '']).''; + $data[8] .= "".html_print_image('images/binary.png', true, ['border' => '0', 'alt' => '']).''; } if ($module['estado'] == 3) { @@ -1177,7 +1187,7 @@ if (check_login()) { ui_print_info_message([ 'no_close' => true, 'message' => __('This agent doesn\'t have any active monitors.') ]); } } else { - $url = 'index.php?'.'sec=estado&'.'sec2=operation/agentes/ver_agente&'.'id_agente='.$id_agente.'&'.'refr=&filter_monitors=1&'.'status_filter_monitor='.$status_filter_monitor.'&'.'status_text_monitor='.$status_text_monitor.'&'.'status_module_group='.$status_module_group; + $url = 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agente.'&refr=&filter_monitors=1&status_filter_monitor='.$status_filter_monitor.'&status_text_monitor='.$status_text_monitor.'&status_module_group='.$status_module_group; if ($paginate_module) { ui_pagination( @@ -1230,5 +1240,3 @@ if (check_login()) { return; } } - - diff --git a/pandora_console/include/ajax/tree.ajax.php b/pandora_console/include/ajax/tree.ajax.php index 9ea0a86e8e..24074e8327 100644 --- a/pandora_console/include/ajax/tree.ajax.php +++ b/pandora_console/include/ajax/tree.ajax.php @@ -151,6 +151,10 @@ if (is_ajax()) { ob_clean(); + echo ''; + echo '
'; if (!empty($id) && !empty($type)) { switch ($type) { diff --git a/pandora_console/include/ajax/visual_console_builder.ajax.php b/pandora_console/include/ajax/visual_console_builder.ajax.php index 82c21eae8b..2d37092078 100755 --- a/pandora_console/include/ajax/visual_console_builder.ajax.php +++ b/pandora_console/include/ajax/visual_console_builder.ajax.php @@ -176,6 +176,7 @@ $default_color = get_parameter('default_color', '#FFFFFF'); $color_range_from_values = get_parameter('color_range_from_values', []); $color_range_to_values = get_parameter('color_range_to_values', []); $color_range_colors = get_parameter('color_range_colors', []); +$cache_expiration = (int) get_parameter('cache_expiration'); switch ($action) { case 'get_font': @@ -581,7 +582,21 @@ switch ($action) { $values['label_position'] = $label_position; $values['show_on_top'] = $show_on_top; - // In Graphs, background color is stored in column image (sorry) + switch ($type) { + case 'line_item': + case 'box_item': + case 'clock': + case 'icon': + case 'label': + $values['cache_expiration'] = 0; + break; + + default: + $values['cache_expiration'] = $cache_expiration; + break; + } + + // In Graphs, background color is stored in column image (sorry). if ($type == 'module_graph') { $values['image'] = $background_color; $values['type_graph'] = $type_graph; @@ -997,6 +1012,7 @@ switch ($action) { unset($values['id_layout_linked']); unset($values['element_group']); unset($values['id_layout_linked_weight']); + unset($values['cache_expiration']); // Don't change background color in graphs when move switch ($type) { case 'group_item': @@ -1070,6 +1086,16 @@ switch ($action) { ['id' => $id_element] ); + // Invalidate the item's cache. + if ($result !== false && $result > 0) { + db_process_sql_delete( + 'tvisual_console_elements_cache', + [ + 'vc_item_id' => (int) $id_element, + ] + ); + } + $return_val = []; $return_val['correct'] = (int) $result; $return_val['new_line'] = $new_line; @@ -1180,6 +1206,8 @@ switch ($action) { switch ($type) { case 'auto_sla_graph': $elementFields['event_max_time_row'] = $elementFields['period']; + break; + case 'percentile_item': case 'percentile_bar': $elementFields['width_percentile'] = $elementFields['width']; @@ -1404,9 +1432,22 @@ switch ($action) { $values['show_on_top'] = $show_on_top; $values['image'] = $background_color; $values['type_graph'] = $type_graph; - $values['id_custom_graph'] = $id_custom_graph; + switch ($type) { + case 'line_item': + case 'box_item': + case 'clock': + case 'icon': + case 'label': + $values['cache_expiration'] = 0; + break; + + default: + $values['cache_expiration'] = $cache_expiration; + break; + } + switch ($type) { case 'line_item': $values['type'] = LINE_ITEM; diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php index 718a3a6c71..5ef2fed828 100644 --- a/pandora_console/include/auth/mysql.php +++ b/pandora_console/include/auth/mysql.php @@ -282,39 +282,42 @@ function process_user_login_remote($login, $pass, $api=false) } } } else if ($config['auth'] === 'ldap') { - if ($config['ldap_save_password']) { - $update_credentials = change_local_user_pass_ldap($login, $pass); + // Check if autocreate remote users is active. + if ($config['autocreate_remote_users'] == 1) { + if ($config['ldap_save_password']) { + $update_credentials = change_local_user_pass_ldap($login, $pass); - if ($update_credentials) { - $config['auth_error'] = __('Your permissions have changed. Please, login again.'); - return false; - } - } else { - delete_user_pass_ldap($login); - } - - $permissions = fill_permissions_ldap($sr); - if (empty($permissions)) { - $config['auth_error'] = __('User not found in database or incorrect password'); - return false; - } else { - // check permissions - $result = check_permission_ad( - $login, - $pass, - false, - $permissions, - defined('METACONSOLE') - ); - - if ($return === 'error_permissions') { - $config['auth_error'] = __('Problems with configuration permissions. Please contact with Administrator'); - return false; - } else { - if ($return === 'permissions_changed') { + if ($update_credentials) { $config['auth_error'] = __('Your permissions have changed. Please, login again.'); return false; } + } else { + delete_user_pass_ldap($login); + } + + $permissions = fill_permissions_ldap($sr); + if (empty($permissions)) { + $config['auth_error'] = __('User not found in database or incorrect password'); + return false; + } else { + // check permissions + $result = check_permission_ad( + $login, + $pass, + false, + $permissions, + defined('METACONSOLE') + ); + + if ($return === 'error_permissions') { + $config['auth_error'] = __('Problems with configuration permissions. Please contact with Administrator'); + return false; + } else { + if ($return === 'permissions_changed') { + $config['auth_error'] = __('Your permissions have changed. Please, login again.'); + return false; + } + } } } } @@ -1254,11 +1257,49 @@ function fill_permissions_ldap($sr) global $config; $permissions = []; $permissions_profile = []; - if ((bool) $config['ldap_save_profile'] === false) { + if (defined('METACONSOLE')) { + $meta = true; + } + + if ($meta && (bool) $config['ldap_save_profile'] === false && $config['ldap_advanced_config'] == 0) { + $result = 0; $result = db_get_all_rows_filter( 'tusuario_perfil', ['id_usuario' => $sr['uid'][0]] ); + if ($result == false) { + $permissions[0]['profile'] = $config['default_remote_profile']; + $permissions[0]['groups'][] = $config['default_remote_group']; + $permissions[0]['tags'] = $config['default_assign_tags']; + $permissions[0]['no_hierarchy'] = $config['default_no_hierarchy']; + return $permissions; + } + + foreach ($result as $perms) { + $permissions_profile[] = [ + 'profile' => $perms['id_perfil'], + 'groups' => [$perms['id_grupo']], + 'tags' => $perms['tags'], + 'no_hierarchy' => (bool) $perms['no_hierarchy'] ? 1 : 0, + ]; + } + + return $permissions_profile; + } + + if ((bool) $config['ldap_save_profile'] === false && $config['ldap_advanced_config'] == '') { + $result = db_get_all_rows_filter( + 'tusuario_perfil', + ['id_usuario' => $sr['uid'][0]] + ); + if ($result == false) { + $permissions[0]['profile'] = $config['default_remote_profile']; + $permissions[0]['groups'][] = $config['default_remote_group']; + $permissions[0]['tags'] = $config['default_assign_tags']; + $permissions[0]['no_hierarchy'] = $config['default_no_hierarchy']; + return $permissions; + } + foreach ($result as $perms) { $permissions_profile[] = [ 'profile' => $perms['id_perfil'], @@ -1268,18 +1309,55 @@ function fill_permissions_ldap($sr) ]; } - if (empty($permissions_profile)) { - $permissions[0]['profile'] = $config['default_remote_profile']; - $permissions[0]['groups'][] = $config['default_remote_group']; - $permissions[0]['tags'] = $config['default_assign_tags']; - $permissions[0]['no_hierarchy'] = $config['default_no_hierarchy']; - return $permissions; - } else { - return $permissions_profile; - } + return $permissions_profile; } - if ($config['autocreate_remote_users']) { + if ($config['ldap_advanced_config'] == 1 && $config['ldap_save_profile'] == 1) { + $ldap_adv_perms = json_decode(io_safe_output($config['ldap_adv_perms']), true); + foreach ($ldap_adv_perms as $ldap_adv_perm) { + $permissions[] = [ + 'profile' => $ldap_adv_perm['profile'], + 'groups' => $ldap_adv_perm['group'], + 'tags' => implode(',', $ldap_adv_perm['tags']), + 'no_hierarchy' => (bool) $ldap_adv_perm['no_hierarchy'] ? 1 : 0, + ]; + } + + return $permissions; + } + + if ($config['ldap_advanced_config'] == 1 && $config['ldap_save_profile'] == 0) { + $result = db_get_all_rows_filter( + 'tusuario_perfil', + ['id_usuario' => $sr['uid'][0]] + ); + if ($result == false) { + $ldap_adv_perms = json_decode(io_safe_output($config['ldap_adv_perms']), true); + foreach ($ldap_adv_perms as $ldap_adv_perm) { + $permissions[] = [ + 'profile' => $ldap_adv_perm['profile'], + 'groups' => $ldap_adv_perm['group'], + 'tags' => implode(',', $ldap_adv_perm['tags']), + 'no_hierarchy' => (bool) $ldap_adv_perm['no_hierarchy'] ? 1 : 0, + ]; + } + + return $permissions; + } + + foreach ($result as $perms) { + $permissions_profile[] = [ + 'profile' => $perms['id_perfil'], + 'groups' => [$perms['id_grupo']], + 'tags' => $perms['tags'], + 'no_hierarchy' => (bool) $perms['no_hierarchy'] ? 1 : 0, + ]; + }; + + return $permissions_profile; + } + + if ($config['autocreate_remote_users'] && $config['ldap_save_profile'] == 1) { $permissions[0]['profile'] = $config['default_remote_profile']; $permissions[0]['groups'][] = $config['default_remote_group']; $permissions[0]['tags'] = $config['default_assign_tags']; @@ -1394,7 +1472,10 @@ function local_ldap_search($ldap_host, $ldap_port=389, $ldap_version=3, $dn, $ac $tls = ' -ZZ '; } - if (stripos($ldap_host, 'ldap') !== false) { + if (stripos($ldap_host, 'ldap://') !== false + || stripos($ldap_host, 'ldaps://') !== false + || stripos($ldap_host, 'ldapi://') !== false + ) { $ldap_host = ' -H '.$ldap_host.':'.$ldap_port; } else { $ldap_host = ' -h '.$ldap_host.' -p '.$ldap_port; diff --git a/pandora_console/include/chart_generator.php b/pandora_console/include/chart_generator.php index e7133fd79e..2ae768d4fe 100644 --- a/pandora_console/include/chart_generator.php +++ b/pandora_console/include/chart_generator.php @@ -62,6 +62,7 @@ if (file_exists('languages/'.$user_language.'.mo')) { + diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index 7259287d68..af688fb5a0 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -32,6 +32,7 @@ require_once $config['homedir'].'/include/functions_db.php'; require_once $config['homedir'].'/include/functions_io.php'; require_once $config['homedir'].'/include/functions_notifications.php'; require_once $config['homedir'].'/include/functions_servers.php'; +require_once $config['homedir'].'/include/functions_update_manager.php'; // Enterprise includes. enterprise_include_once('include/functions_metaconsole.php'); @@ -194,6 +195,20 @@ class ConsoleSupervisor $this->checkCronRunning(); } + /* + * Check if instance is registered. + * NOTIF.UPDATEMANAGER.REGISTRATION + */ + + $this->checkUpdateManagerRegistration(); + + /* + * Check if there're new messages in UM. + * NOTIF.UPDATEMANAGER.MESSAGES + */ + + $this->getUMMessages(); + } @@ -406,6 +421,20 @@ class ConsoleSupervisor $this->checkCronRunning(); } + /* + * Check if instance is registered. + * NOTIF.UPDATEMANAGER.REGISTRATION + */ + + $this->checkUpdateManagerRegistration(); + + /* + * Check if there're new messages in UM. + * NOTIF.UPDATEMANAGER.MESSAGES + */ + + $this->getUMMessages(); + } @@ -571,6 +600,7 @@ class ConsoleSupervisor case 'NOTIF.UPDATEMANAGER.OPENSETUP': case 'NOTIF.UPDATEMANAGER.UPDATE': case 'NOTIF.UPDATEMANAGER.MINOR': + case 'NOTIF.UPDATEMANAGER.MESSAGES': case 'NOTIF.CRON.CONFIGURED': default: // NOTIF.SERVER.STATUS. @@ -1911,27 +1941,18 @@ class ConsoleSupervisor public function checkUpdateManagerRegistration() { global $config; + include_once $config['homedir'].'/include/functions_update_manager.php'; $login = get_parameter('login', false); - if (license_free() === true - && users_is_admin($config['id_user']) === true - ) { - $login = get_parameter('login', false); - // Registration advice. - if ((isset($config['instance_registered']) === true - || ($config['instance_registered'] != 1)) && ($login === false) - ) { - $this->notify( - [ - 'type' => 'NOTIF.UPDATEMANAGER.REGISTRATION', - 'title' => __('This instance is not registered in the Update manager section'), - 'message' => __('Click here to start the registration process'), - 'url' => 'javascript: force_run_register();', - ] - ); - } else { - $this->cleanNotifications('NOTIF.UPDATEMANAGER.REGISTRATION'); - } + if (update_manager_verify_registration() === false) { + $this->notify( + [ + 'type' => 'NOTIF.UPDATEMANAGER.REGISTRATION', + 'title' => __('This instance is not registered in the Update manager section'), + 'message' => __('Click here to start the registration process'), + 'url' => 'javascript: force_run_register();', + ] + ); } else { $this->cleanNotifications('NOTIF.UPDATEMANAGER.REGISTRATION'); } @@ -2217,4 +2238,69 @@ class ConsoleSupervisor } + /** + * Search for messages. + * + * @return void + */ + public function getUMMessages() + { + global $config; + include_once $config['homedir'].'/include/functions_update_manager.php'; + + if (update_manager_verify_registration() === false) { + // Console not subscribed. + return; + } + + // Avoid contact for messages too much often. + if (isset($config['last_um_check']) + && time() < $config['last_um_check'] + ) { + return; + } + + // Only ask for messages once a day. + $future = (time() + 2 * SECONDS_1HOUR); + config_update_value('last_um_check', $future); + + $params = [ + 'pandora_uid' => $config['pandora_uid'], + 'timezone' => $config['timezone'], + 'language' => $config['language'], + ]; + + $result = update_manager_curl_request('get_messages', $params); + + try { + if ($result['success'] === true) { + $messages = json_decode($result['update_message'], true); + } + } catch (Exception $e) { + error_log($e->getMessage()); + }; + + if (is_array($messages)) { + $source_id = get_notification_source_id( + 'Official communication' + ); + foreach ($messages as $message) { + if (!isset($message['url'])) { + $message['url'] = '#'; + } + + $this->notify( + [ + 'type' => 'NOTIF.UPDATEMANAGER.MESSAGES.'.$message['id'], + 'title' => $message['subject'], + 'message' => base64_decode($message['message_html']), + 'url' => $message['url'], + ], + $source_id + ); + } + } + } + + } diff --git a/pandora_console/include/class/NetworkMap.class.php b/pandora_console/include/class/NetworkMap.class.php index 90e2f2a0d4..0011167308 100644 --- a/pandora_console/include/class/NetworkMap.class.php +++ b/pandora_console/include/class/NetworkMap.class.php @@ -1519,43 +1519,8 @@ class NetworkMap */ public static function getColorByStatus($status) { - if (isset($status) === false) { - return COL_UNKNOWN; - } - - switch ($status) { - case AGENT_MODULE_STATUS_NORMAL: - case AGENT_STATUS_NORMAL: - return COL_NORMAL; - - case AGENT_MODULE_STATUS_NOT_INIT: - case AGENT_STATUS_NOT_INIT: - return COL_NOTINIT; - - case AGENT_MODULE_STATUS_CRITICAL_BAD: - case AGENT_STATUS_CRITICAL: - return COL_CRITICAL; - - case AGENT_MODULE_STATUS_WARNING: - case AGENT_STATUS_WARNING: - return COL_WARNING; - - case AGENT_MODULE_STATUS_CRITICAL_ALERT: - case AGENT_MODULE_STATUS_WARNING_ALERT: - case AGENT_STATUS_ALERT_FIRED: - return COL_ALERTFIRED; - - case AGENT_MODULE_STATUS_UNKNOWN: - case AGENT_STATUS_UNKNOWN: - return COL_UNKNOWN; - - default: - // Ignored. - break; - } - - return COL_IGNORED; - + include_once __DIR__.'/../functions_modules.php'; + return modules_get_color_status($status); } @@ -2880,6 +2845,7 @@ class NetworkMap html_print_table($table, true), __('Node Details'), __('Node Details'), + '', false, true ); @@ -2932,6 +2898,7 @@ class NetworkMap html_print_table($table, true), __('Node Details'), __('Node Details'), + '', false, true ); @@ -2957,6 +2924,7 @@ class NetworkMap html_print_table($table, true), __('Interface Information (SNMP)'), __('Interface Information (SNMP)'), + '', true, true ); @@ -3031,6 +2999,7 @@ class NetworkMap html_print_table($table, true), __('Node options'), __('Node options'), + '', true, true ); @@ -3091,6 +3060,7 @@ class NetworkMap html_print_table($table, true), __('Relations'), __('Relations'), + '', true, true ); @@ -3200,6 +3170,7 @@ class NetworkMap $add_agent_node_html, __('Add agent node'), __('Add agent node'), + '', false, true ); @@ -3251,6 +3222,7 @@ class NetworkMap $add_agent_node_html, __('Add agent node (filter by group)'), __('Add agent node'), + '', true, true ); @@ -3291,6 +3263,7 @@ class NetworkMap $add_agent_node_html, __('Add fictional point'), __('Add agent node'), + '', true, true ); diff --git a/pandora_console/include/class/TreeService.class.php b/pandora_console/include/class/TreeService.class.php index eaf3c55fea..2316714031 100644 --- a/pandora_console/include/class/TreeService.class.php +++ b/pandora_console/include/class/TreeService.class.php @@ -72,6 +72,8 @@ class TreeService extends Tree protected function getFirstLevel() { + global $config; + $processed_items = $this->getProcessedServices(); $ids = array_keys($processed_items); diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index f75aa819f8..6f8807b770 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,8 +20,8 @@ /** * Pandora build version and version */ -$build_version = 'PC190522'; -$pandora_version = 'v7.0NG.734'; +$build_version = 'PC190621'; +$pandora_version = 'v7.0NG.735'; // Do not overwrite default timezone set if defined. $script_tz = @date_default_timezone_get(); diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index 7266e9eff4..8a67ba1111 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -39,10 +39,11 @@ define('TIME_FORMAT', 'H:i:s'); define('TIME_FORMAT_JS', 'HH:mm:ss'); // Events state constants. +define('EVENT_ALL', -1); define('EVENT_NEW', 0); define('EVENT_VALIDATE', 1); define('EVENT_PROCESS', 2); - +define('EVENT_NO_VALIDATED', 3); // Agents disabled status. @@ -65,7 +66,7 @@ define('ERR_NODATA', -70000); define('ERR_CONNECTION', -80000); define('ERR_DISABLED', -90000); define('ERR_WRONG', -100000); -define('ERR_WRONG_NAME', -100001); +define('ERR_WRONG_MR', -100001); define('ERR_WRONG_PARAMETERS', -100002); define('ERR_ACL', -110000); define('ERR_AUTH', -120000); @@ -137,19 +138,19 @@ switch ($config['dbtype']) { // Color constants. -define('COL_CRITICAL', '#FC4444'); -define('COL_WARNING', '#FAD403'); +define('COL_CRITICAL', '#e63c52'); +define('COL_WARNING', '#f3b200'); define('COL_WARNING_DARK', '#FFB900'); -define('COL_NORMAL', '#80BA27'); -define('COL_NOTINIT', '#3BA0FF'); +define('COL_NORMAL', '#82b92e'); +define('COL_NOTINIT', '#4a83f3'); define('COL_UNKNOWN', '#B2B2B2'); define('COL_DOWNTIME', '#976DB1'); define('COL_IGNORED', '#DDD'); define('COL_ALERTFIRED', '#FFA631'); -define('COL_MINOR', '#F099A2'); +define('COL_MINOR', '#B2B2B2'); define('COL_MAJOR', '#C97A4A'); define('COL_INFORMATIONAL', '#E4E4E4'); -define('COL_MAINTENANCE', '#3BA0FF'); +define('COL_MAINTENANCE', '#4a83f3'); define('COL_GRAPH1', '#C397F2'); define('COL_GRAPH2', '#FFE66C'); diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 73b787ff99..fea9131e09 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -871,12 +871,13 @@ function get_parameter_switch($name, $default='') $data = get_parameter($name, null); if ($data === null) { - return 0; + return (isset($default) ? $default : 0); } else if ($data == 'on') { return 1; } - return 0; + // Return value assigned to switch. + return $data; } @@ -901,6 +902,47 @@ function set_cookie($name, $value) } +/** + * Returns database ORDER clause from datatables AJAX call. + * + * @param boolean $as_array Return as array or as string. + * + * @return string Order or empty. + */ +function get_datatable_order($as_array=false) +{ + $order = get_parameter('order'); + + if (is_array($order)) { + $column = $order[0]['column']; + $direction = $order[0]['dir']; + } + + if (!isset($column) || !isset($direction)) { + return ''; + } + + $columns = get_parameter('columns'); + + if (is_array($columns)) { + $column_name = $columns[$column]['data']; + } + + if (!isset($column_name)) { + return ''; + } + + if ($as_array) { + return [ + 'direction' => $direction, + 'field' => $column_name, + ]; + } + + return $column_name.' '.$direction; +} + + /** * Get a parameter from a request. * @@ -1391,6 +1433,11 @@ function enterprise_installed() { $return = false; + // Load enterprise extensions. + if (defined('DESTDIR')) { + return $return; + } + if (defined('PANDORA_ENTERPRISE')) { if (PANDORA_ENTERPRISE) { $return = true; @@ -1443,7 +1490,7 @@ function enterprise_include($filename) { global $config; - // Load enterprise extensions + // Load enterprise extensions. if (defined('DESTDIR')) { $destdir = DESTDIR; } else { @@ -1469,11 +1516,24 @@ function enterprise_include($filename) } +/** + * Includes a file from enterprise section. + * + * @param string $filename Target file. + * + * @return mixed Result code. + */ function enterprise_include_once($filename) { global $config; - // Load enterprise extensions + // Load enterprise extensions. + if (defined('DESTDIR')) { + $destdir = DESTDIR; + } else { + $destdir = ''; + } + $filepath = realpath($config['homedir'].'/'.ENTERPRISE_DIR.'/'.$filename); if ($filepath === false) { @@ -1573,6 +1633,11 @@ function safe_sql_string($string) } +/** + * Verifies if current Pandora FMS installation is a Metaconsole. + * + * @return boolean True metaconsole installation, false if not. + */ function is_metaconsole() { global $config; @@ -1580,6 +1645,18 @@ function is_metaconsole() } +/** + * Check if current Pandora FMS installation has joined a Metaconsole env. + * + * @return boolean True joined, false if not. + */ +function has_metaconsole() +{ + global $config; + return (bool) $config['node_metaconsole'] && (bool) $config['metaconsole_node_id']; +} + + /** * @brief Check if there is management operations are allowed in current context * (node // meta) @@ -4945,6 +5022,14 @@ function get_help_info($section_name) } break; + case 'create_agent': + if ($es) { + $result .= 'Intro_Monitorizacion&printable=yes#Configuraci.C3.B3n_del_agente_en_consola'; + } else { + $result .= 'Intro_Monitoring&printable=yes#Agent_configuration_in_the_console'; + } + break; + case 'agent_snmp_explorer_tab': if ($es) { $result .= 'Monitorizacion_remota&printable=yes#Wizard_SNMP'; diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index fd5e922e32..affa4269d4 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -1614,9 +1614,9 @@ function agents_get_interval($id_agent) * * @param Agent object. * - * @return The interval value and status of last contact + * @return The interval value and status of last contact or True /False */ -function agents_get_interval_status($agent) +function agents_get_interval_status($agent, $return_html=true) { $return = ''; $last_time = time_w_fixed_tz($agent['ultimo_contacto']); @@ -1624,9 +1624,18 @@ function agents_get_interval_status($agent) $diferencia = ($now - $last_time); $time = ui_print_timestamp($last_time, true, ['style' => 'font-size:6.5pt']); $min_interval = modules_get_agentmodule_mininterval_no_async($agent['id_agente']); - $return = $time; + if ($return_html) { + $return = $time; + } else { + $return = true; + } + if ($diferencia > ($min_interval['min_interval'] * 2) && $min_interval['num_interval'] > 0) { - $return = ''.$time.''; + if ($return_html) { + $return = ''.$time.''; + } else { + $return = false; + } } return $return; @@ -3367,3 +3376,35 @@ function agents_get_image_status($status) return $image_status; } + + +/** + * Animation GIF to show agent's status. + * + * @return string HTML code with heartbeat image. + */ +function agents_get_status_animation($up=true) +{ + switch ($up) { + case true: + default: + return html_print_image( + 'images/heartbeat_green.gif', + true, + [ + 'width' => '170', + 'height' => '40', + ] + ); + + case false: + return html_print_image( + 'images/heartbeat_red.gif', + true, + [ + 'width' => '170', + 'height' => '40', + ] + ); + } +} diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index 011acafae9..83de1ef9ab 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -1783,12 +1783,14 @@ function alerts_validate_alert_agent_module($id_alert_agent_module, $noACLs=fals ['id' => $id] ); + $template_name = io_safe_output(db_get_value('name', 'talert_templates', 'id', $alert['id_alert_template'])); + $module_name = io_safe_output(db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $alert['id_agent_module'])); if ($result > 0) { // Update fired alert count on the agent db_process_sql(sprintf('UPDATE tagente SET update_alert_count=1 WHERE id_agente = %d', $agent_id)); events_create_event( - 'Manual validation of alert for '.alerts_get_alert_template_description($alert['id_alert_template']), + 'Manual validation of alert '.$template_name.' assigned to '.$module_name.'', $group_id, $agent_id, 1, diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 3c6cdbf595..e683b74f7d 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -11519,7 +11519,7 @@ function api_set_create_event($id, $trash1, $other, $returnType) if ($other['data'][18] != '') { $values['id_extra'] = $other['data'][18]; - $sql_validation = 'SELECT id_evento FROM tevento where estado=0 and id_extra ="'.$other['data'][18].'";'; + $sql_validation = 'SELECT id_evento FROM tevento where estado IN (0,2) and id_extra ="'.$other['data'][18].'";'; $validation = db_get_all_rows_sql($sql_validation); if ($validation) { foreach ($validation as $val) { diff --git a/pandora_console/include/functions_clippy.php b/pandora_console/include/functions_clippy.php index f3bc6a5967..67999a75e0 100644 --- a/pandora_console/include/functions_clippy.php +++ b/pandora_console/include/functions_clippy.php @@ -296,7 +296,7 @@ function clippy_context_help($help=null) $code = str_replace('{clippy}', '#'.$id, $code); $code = str_replace('{clippy_obj}', 'intro_'.$id, $code); - $return = $code.'
'.html_print_image( + $return = $code.' diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index dc0e845afb..1d346f3b6d 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -180,7 +180,7 @@ function config_update_config() $error_update[] = __('Automatic check for updates'); } - if (!config_update_value('cert_path', (bool) get_parameter('cert_path'))) { + if (!config_update_value('cert_path', get_parameter('cert_path'))) { $error_update[] = __('SSL cert path'); } @@ -270,7 +270,7 @@ function config_update_config() $error_update[] = __('Referer security'); } - if (!config_update_value('event_storm_protection', get_parameter('event_storm_protection'))) { + if (!config_update_value('event_storm_protection', get_parameter('event_storm_protection', 0))) { $error_update[] = __('Event storm protection'); } @@ -984,6 +984,10 @@ function config_update_config() $error_update[] = __('Use the legacy Visual Console'); } + if (!config_update_value('vc_default_cache_expiration', (int) get_parameter('vc_default_cache_expiration'))) { + $error_update[] = __("Default expiration of the Visual Console item's cache"); + } + if (!config_update_value('vc_refr', (int) get_parameter('vc_refr'))) { $error_update[] = __('Default interval for refresh on Visual Console'); } @@ -1353,6 +1357,10 @@ function config_update_config() $error_update[] = __('Enable eHorus'); } + if (!config_update_value('ehorus_user_level_conf', (int) get_parameter('ehorus_user_level_conf', 0))) { + $error_update[] = __('eHorus user login'); + } + if (!config_update_value('ehorus_user', (string) get_parameter('ehorus_user', $config['ehorus_user']))) { $error_update[] = __('eHorus user'); } @@ -2159,9 +2167,9 @@ function config_process_config() if (!isset($config['ad_adv_perms'])) { config_update_value('ad_adv_perms', ''); } else { + $temp_ad_adv_perms = []; if (!json_decode(io_safe_output($config['ad_adv_perms']))) { - $temp_ad_adv_perms = []; - if (!isset($config['ad_adv_perms']) && $config['ad_adv_perms'] != '') { + if ($config['ad_adv_perms'] != '') { $perms = explode(';', io_safe_output($config['ad_adv_perms'])); foreach ($perms as $ad_adv_perm) { if (preg_match('/[\[\]]/', $ad_adv_perm)) { @@ -2224,22 +2232,26 @@ function config_process_config() if (!empty($new_ad_adv_perms)) { $temp_ad_adv_perms = json_encode($new_ad_adv_perms); } + } else { + $temp_ad_adv_perms = ''; } - - config_update_value('ad_adv_perms', $temp_ad_adv_perms); + } else { + $temp_ad_adv_perms = $config['ad_adv_perms']; } + + config_update_value('ad_adv_perms', $temp_ad_adv_perms); } if (!isset($config['ldap_adv_perms'])) { config_update_value('ldap_adv_perms', ''); } else { + $temp_ldap_adv_perms = []; if (!json_decode(io_safe_output($config['ldap_adv_perms']))) { - $temp_ldap_adv_perms = []; - if (!isset($config['ad_adv_perms']) && $config['ldap_adv_perms'] != '') { + if ($config['ldap_adv_perms'] != '') { $perms = explode(';', io_safe_output($config['ldap_adv_perms'])); - foreach ($perms as $ad_adv_perm) { - if (preg_match('/[\[\]]/', $ad_adv_perm)) { - $all_data = explode(',', io_safe_output($ad_adv_perm)); + foreach ($perms as $ldap_adv_perm) { + if (preg_match('/[\[\]]/', $ldap_adv_perm)) { + $all_data = explode(',', io_safe_output($ldap_adv_perm)); $profile = $all_data[0]; $group_pnd = $all_data[1]; $groups_ad = str_replace(['[', ']'], '', $all_data[2]); @@ -2269,7 +2281,7 @@ function config_process_config() 'groups_ldap' => $groups_ldap, ]; } else { - $all_data = explode(',', io_safe_output($ad_adv_perm)); + $all_data = explode(',', io_safe_output($ldap_adv_perm)); $profile = $all_data[0]; $group_pnd = $all_data[1]; $groups_ad = $all_data[2]; @@ -2298,10 +2310,14 @@ function config_process_config() if (!empty($new_ldap_adv_perms)) { $temp_ldap_adv_perms = json_encode($new_ldap_adv_perms); } + } else { + $temp_ldap_adv_perms = ''; } - - config_update_value('ldap_adv_perms', $temp_ldap_adv_perms); + } else { + $temp_ldap_adv_perms = $config['ldap_adv_perms']; } + + config_update_value('ldap_adv_perms', $temp_ldap_adv_perms); } if (!isset($config['rpandora_server'])) { @@ -2423,6 +2439,10 @@ function config_process_config() config_update_value('legacy_vc', 1); } + if (!isset($config['vc_default_cache_expiration'])) { + config_update_value('vc_default_cache_expiration', 60); + } + if (!isset($config['vc_refr'])) { config_update_value('vc_refr', 300); } @@ -2740,6 +2760,31 @@ function config_check() } +/** + * Retrieves base url stored for Update Manager. + * + * @return string URL. + */ +function get_um_url() +{ + global $config; + + if (isset($config['url_update_manager'])) { + $url = $config['url_update_manager']; + $url = substr($url, 0, (strlen($url) - strpos(strrev($url), '/'))); + } else { + $url = 'https://licensing.artica.es/pandoraupdate7/'; + config_update_value( + 'url_update_manager', + 'https://licensing.artica.es/pandoraupdate7/server.php' + ); + } + + return $url; + +} + + /** * Return in bytes * diff --git a/pandora_console/include/functions_custom_fields.php b/pandora_console/include/functions_custom_fields.php index 9570098766..d1f661e874 100644 --- a/pandora_console/include/functions_custom_fields.php +++ b/pandora_console/include/functions_custom_fields.php @@ -188,10 +188,16 @@ function get_custom_fields_data($custom_field_name) } $array_result = []; - if (isset($result_meta) && is_array($result_meta)) { + if (isset($result_meta) === true + && is_array($result_meta) === true + ) { foreach ($result_meta as $result) { - foreach ($result as $k => $v) { - $array_result[$v['description']] = $v['description']; + if (isset($result) === true + && is_array($result) === true + ) { + foreach ($result as $k => $v) { + $array_result[$v['description']] = $v['description']; + } } } } @@ -385,9 +391,13 @@ function agent_counters_custom_fields($filters) // Filter custom data. $custom_data_and = ''; - if (!in_array(-1, $filters['id_custom_fields_data'])) { - $custom_data_array = implode("', '", $filters['id_custom_fields_data']); - $custom_data_and = "AND tcd.description IN ('".$custom_data_array."')"; + if (isset($filters['id_custom_fields_data']) === true + && is_array($filters['id_custom_fields_data']) === true + ) { + if (!in_array(-1, $filters['id_custom_fields_data'])) { + $custom_data_array = implode("', '", $filters['id_custom_fields_data']); + $custom_data_and = "AND tcd.description IN ('".$custom_data_array."')"; + } } // Filter custom name. @@ -693,3 +703,123 @@ function print_counters_cfv( $html_result .= ''; return $html_result; } + + +/** + * Function for export a csv file from Custom Fields View + * + * @param array $filters Status counters for agents and modules. + * @param array $id_status Agent status. + * @param array $module_status Module status. + * + * @return array Returns the data that will be saved in the csv file + */ +function export_custom_fields_csv($filters, $id_status, $module_status) +{ + $data = agent_counters_custom_fields($filters); + $indexed_descriptions = $data['indexed_descriptions']; + + // Table temporary for save array in table + // by order and search custom_field data. + $table_temporary = 'CREATE TEMPORARY TABLE temp_custom_fields ( + id_server int(10), + id_agent int(10), + name_custom_fields varchar(2048), + critical_count int, + warning_count int, + unknown_count int, + notinit_count int, + normal_count int, + total_count int, + `status` int(2), + KEY `data_index_temp_1` (`id_server`, `id_agent`) + )'; + db_process_sql($table_temporary); + + // Insert values array in table temporary. + $values_insert = []; + foreach ($indexed_descriptions as $key => $value) { + $values_insert[] = '('.$value['id_server'].', '.$value['id_agente'].", '".$value['description']."', '".$value['critical_count']."', '".$value['warning_count']."', '".$value['unknown_count']."', '".$value['notinit_count']."', '".$value['normal_count']."', '".$value['total_count']."', ".$value['status'].')'; + } + + $values_insert_implode = implode(',', $values_insert); + $query_insert = 'INSERT INTO temp_custom_fields VALUES '.$values_insert_implode; + db_process_sql($query_insert); + + // Search for status module. + $status_agent_search = ''; + if (isset($id_status) === true && is_array($id_status) === true) { + if (in_array(-1, $id_status) === false) { + if (in_array(AGENT_MODULE_STATUS_NOT_NORMAL, $id_status) === false) { + $status_agent_search = ' AND temp.status IN ('.implode(',', $id_status).')'; + } else { + // Not normal statuses. + $status_agent_search = ' AND temp.status IN (1,2,3,4,5)'; + } + } + } + + // Search for status module. + $status_module_search = ''; + if (isset($module_status) === true && is_array($module_status) === true) { + if (in_array(-1, $module_status) === false) { + if (in_array(AGENT_MODULE_STATUS_NOT_NORMAL, $module_status) === false) { + if (count($module_status) > 0) { + $status_module_search = ' AND ( '; + foreach ($module_status as $key => $value) { + $status_module_search .= ($key != 0) ? ' OR (' : ' ('; + switch ($value) { + default: + case AGENT_STATUS_NORMAL: + $status_module_search .= ' temp.normal_count > 0) '; + break; + case AGENT_STATUS_CRITICAL: + $status_module_search .= ' temp.critical_count > 0) '; + break; + + case AGENT_STATUS_WARNING: + $status_module_search .= ' temp.warning_count > 0) '; + break; + + case AGENT_STATUS_UNKNOWN: + $status_module_search .= ' temp.unknown_count > 0) '; + break; + + case AGENT_STATUS_NOT_INIT: + $status_module_search .= ' temp.notinit_count > 0) '; + break; + } + } + + $status_module_search .= ' ) '; + } + } else { + // Not normal. + $status_module_search = ' AND ( temp.critical_count > 0 OR temp.warning_count > 0 OR temp.unknown_count > 0 AND temp.notinit_count > 0 )'; + } + } + } + + // Query all fields result. + $query = sprintf( + 'SELECT + temp.name_custom_fields, + tma.alias, + tma.direccion, + tma.server_name, + temp.status + FROM tmetaconsole_agent tma + INNER JOIN temp_custom_fields temp + ON temp.id_agent = tma.id_tagente + AND temp.id_server = tma.id_tmetaconsole_setup + WHERE tma.disabled = 0 + %s + %s + ', + $status_agent_search, + $status_module_search + ); + + $result = db_get_all_rows_sql($query); + return $result; +} diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 7b75906b5e..2e0377769d 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -72,6 +72,1087 @@ function events_get_all_fields() } +/** + * Same as events_get_column_names but retrieving only one result. + * + * @param string $field Raw field name. + * + * @return string Traduction. + */ +function events_get_column_name($field) +{ + switch ($field) { + case 'id_evento': + return __('Event Id'); + + case 'evento': + return __('Event Name'); + + case 'id_agente': + return __('Agent ID'); + + case 'agent_name': + return __('Agent name'); + + case 'agent_alias': + return __('Agent alias'); + + case 'id_usuario': + return __('User'); + + case 'id_grupo': + return __('Group'); + + case 'estado': + return __('Status'); + + case 'timestamp': + return __('Timestamp'); + + case 'event_type': + return __('Event Type'); + + case 'id_agentmodule': + return __('Module Name'); + + case 'id_alert_am': + return __('Alert'); + + case 'criticity': + return __('Severity'); + + case 'user_comment': + return __('Comment'); + + case 'tags': + return __('Tags'); + + case 'source': + return __('Source'); + + case 'id_extra': + return __('Extra Id'); + + case 'owner_user': + return __('Owner'); + + case 'ack_utimestamp': + return __('ACK Timestamp'); + + case 'instructions': + return __('Instructions'); + + case 'server_name': + return __('Server Name'); + + case 'data': + return __('Data'); + + case 'module_status': + return __('Module Status'); + + case 'options': + return __('Options'); + + default: + return __($field); + } +} + + +/** + * Return column names from fields selected. + * + * @param array $fields Array of fields. + * + * @return array Names array. + */ +function events_get_column_names($fields) +{ + if (!isset($fields) || !is_array($fields)) { + return []; + } + + $names = []; + foreach ($fields as $f) { + if (is_array($f)) { + $name = []; + $name['text'] = events_get_column_name($f['text']); + $name['class'] = $f['class']; + $name['style'] = $f['style']; + $name['extra'] = $f['extra']; + $name['id'] = $f['id']; + $names[] = $name; + } else { + $names[] = events_get_column_name($f); + } + } + + return $names; + +} + + +/** + * Validates all events matching target filter. + * + * @param integer $id_evento Master event. + * @param array $filter Optional. Filter options. + * @param boolean $history Apply on historical table. + * + * @return integer Events validated or false if error. + */ +function events_delete($id_evento, $filter=null, $history=false) +{ + if (!isset($id_evento) || $id_evento <= 0) { + return false; + } + + if (!isset($filter) || !is_array($filter)) { + $filter = ['group_rep' => 0]; + } + + $table = events_get_events_table(is_metaconsole(), $history); + + switch ($filter['group_rep']) { + case '0': + case '2': + default: + // No groups option direct update. + $delete_sql = sprintf( + 'DELETE FROM %s + WHERE id_evento = %d', + $table, + $id_evento + ); + break; + + case '1': + // Group by events. + $sql = events_get_all( + ['te.*'], + $filter, + // Offset. + null, + // Limit. + null, + // Order. + null, + // Sort_field. + null, + // Historical table. + $history, + // Return_sql. + true + ); + + $target_ids = db_get_all_rows_sql( + sprintf( + 'SELECT tu.id_evento FROM %s tu INNER JOIN ( %s ) tf + ON tu.estado = tf.estado + AND tu.evento = tf.evento + AND tu.id_agente = tf.id_agente + AND tu.id_agentmodule = tf.id_agentmodule + AND tf.max_id_evento = %d', + $table, + $sql, + $id_evento + ) + ); + + // Try to avoid deadlock while updating full set. + if ($target_ids !== false && count($target_ids) > 0) { + $target_ids = array_reduce( + $target_ids, + function ($carry, $item) { + $carry[] = $item['id_evento']; + return $carry; + } + ); + + $delete_sql = sprintf( + 'DELETE FROM %s WHERE id_evento IN (%s)', + $table, + join(', ', $target_ids) + ); + } + break; + } + + return db_process_sql($delete_sql); +} + + +/** + * Retrieves all events related to matching one. + * + * @param integer $id_evento Master event (max_id_evento). + * @param array $filter Filters. + * @param boolean $count Count results or get results. + * @param boolean $history Apply on historical table. + * + * @return array Events or false in case of error. + */ +function events_get_related_events( + $id_evento, + $filter=null, + $count=false, + $history=false +) { + global $config; + + if (!isset($id_evento) || $id_evento <= 0) { + return false; + } + + if (!isset($filter) || !is_array($filter)) { + $filter = ['group_rep' => 0]; + } + + $table = events_get_events_table(is_metaconsole(), $history); + $select = '*'; + if ($count === true) { + $select = 'count(*) as n'; + }; + + switch ($filter['group_rep']) { + case '0': + case '2': + default: + // No groups option direct update. + $related_sql = sprintf( + 'SELECT %s FROM %s + WHERE id_evento = %d', + $select, + $table, + $id_evento + ); + break; + + case '1': + // Group by events. + $sql = events_get_all( + ['te.*'], + $filter, + // Offset. + null, + // Limit. + null, + // Order. + null, + // Sort_field. + null, + // Historical table. + $history, + // Return_sql. + true + ); + $related_sql = sprintf( + 'SELECT %s FROM %s tu INNER JOIN ( %s ) tf + WHERE tu.estado = tf.estado + AND tu.evento = tf.evento + AND tu.id_agente = tf.id_agente + AND tu.id_agentmodule = tf.id_agentmodule + AND tf.max_id_evento = %d', + $select, + $table, + $sql, + $id_evento + ); + break; + } + + if ($count === true) { + $r = db_get_all_rows_sql($related_sql); + + return $r[0]['n']; + } + + return db_get_all_rows_sql($related_sql); + +} + + +/** + * Validates all events matching target filter. + * + * @param integer $id_evento Master event. + * @param integer $status Target status. + * @param array $filter Optional. Filter options. + * @param boolean $history Apply on historical table. + * + * @return integer Events validated or false if error. + */ +function events_update_status($id_evento, $status, $filter=null, $history=false) +{ + global $config; + + if (!$status) { + error_log('No hay estado'); + return false; + } + + if (!isset($id_evento) || $id_evento <= 0) { + error_log('No hay id_evento'); + return false; + } + + if (!isset($filter) || !is_array($filter)) { + $filter = ['group_rep' => 0]; + } + + $table = events_get_events_table(is_metaconsole(), $history); + + switch ($filter['group_rep']) { + case '0': + case '2': + default: + // No groups option direct update. + $update_sql = sprintf( + 'UPDATE %s + SET estado = %d + WHERE id_evento = %d', + $table, + $status, + $id_evento + ); + break; + + case '1': + // Group by events. + $sql = events_get_all( + ['te.*'], + $filter, + // Offset. + null, + // Limit. + null, + // Order. + null, + // Sort_field. + null, + // Historical table. + $history, + // Return_sql. + true + ); + + $target_ids = db_get_all_rows_sql( + sprintf( + 'SELECT tu.id_evento FROM %s tu INNER JOIN ( %s ) tf + ON tu.estado = tf.estado + AND tu.evento = tf.evento + AND tu.id_agente = tf.id_agente + AND tu.id_agentmodule = tf.id_agentmodule + AND tf.max_id_evento = %d', + $table, + $sql, + $id_evento + ) + ); + + // Try to avoid deadlock while updating full set. + if ($target_ids !== false && count($target_ids) > 0) { + $target_ids = array_reduce( + $target_ids, + function ($carry, $item) { + $carry[] = $item['id_evento']; + return $carry; + } + ); + + $update_sql = sprintf( + 'UPDATE %s + SET estado = %d, + ack_utimestamp = %d, + id_usuario = "%s" + WHERE id_evento IN (%s)', + $table, + $status, + time(), + $config['id_user'], + join(',', $target_ids) + ); + } + break; + } + + return db_process_sql($update_sql); +} + + +/** + * Retrieve all events filtered. + * + * @param array $fields Fields to retrieve. + * @param array $filter Filters to be applied. + * @param integer $offset Offset (pagination). + * @param integer $limit Limit (pagination). + * @param string $order Sort order. + * @param string $sort_field Sort field. + * @param boolean $history Apply on historical table. + * @param boolean $return_sql Return SQL (true) or execute it (false). + * @param string $having Having filter. + * + * @return array Events. + * @throws Exception On error. + */ +function events_get_all( + $fields, + array $filter, + $offset=null, + $limit=null, + $order=null, + $sort_field=null, + $history=false, + $return_sql=false, + $having='' +) { + global $config; + + $user_is_admin = users_is_admin(); + + if (!is_array($filter)) { + error_log('[events_get_all] Filter must be an array.'); + throw new Exception('[events_get_all] Filter must be an array.'); + } + + $count = false; + if (!is_array($fields) && $fields == 'count') { + $fields = ['te.*']; + $count = true; + } else if (!is_array($fields)) { + error_log('[events_get_all] Fields must be an array or "count".'); + throw new Exception('[events_get_all] Fields must be an array or "count".'); + } + + if (isset($filter['date_from']) + && !empty($filter['date_from']) + && $filter['date_from'] != '0000-00-00' + ) { + $date_from = $filter['date_from']; + } + + if (isset($filter['time_from'])) { + $time_from = $filter['time_from']; + } + + if (isset($date_from)) { + if (!isset($time_from)) { + $time_from = '00:00:00'; + } + + $from = $date_from.' '.$time_from; + $sql_filters[] = sprintf( + ' AND te.utimestamp >= %d', + strtotime($from) + ); + } + + if (isset($filter['date_to']) + && !empty($filter['date_to']) + && $filter['date_to'] != '0000-00-00' + ) { + $date_to = $filter['date_to']; + } + + if (isset($filter['time_to'])) { + $time_to = $filter['time_to']; + } + + if (isset($date_to)) { + if (!isset($time_to)) { + $time_to = '23:59:59'; + } + + $to = $date_to.' '.$time_to; + $sql_filters[] = sprintf( + ' AND te.utimestamp <= %d', + strtotime($to) + ); + } + + if (!isset($from)) { + if (isset($filter['event_view_hr']) && ($filter['event_view_hr'] > 0)) { + $sql_filters[] = sprintf( + ' AND utimestamp > UNIX_TIMESTAMP(now() - INTERVAL %d HOUR) ', + $filter['event_view_hr'] + ); + } + } + + if (isset($filter['id_agent']) && $filter['id_agent'] > 0) { + $sql_filters[] = sprintf( + ' AND te.id_agente = %d ', + $filter['id_agent'] + ); + } + + if (!empty($filter['event_type']) && $filter['event_type'] != 'all') { + if ($filter['event_type'] == 'warning' + || $filter['event_type'] == 'critical' + || $filter['event_type'] == 'normal' + ) { + $sql_filters[] = ' AND event_type LIKE "%'.$filter['event_type'].'%"'; + } else if ($filter['event_type'] == 'not_normal') { + $sql_filters[] = ' AND (event_type LIKE "%warning%" + OR event_type LIKE "%critical%" + OR event_type LIKE "%unknown%")'; + } else { + $sql_filters[] = ' AND event_type = "'.$filter['event_type'].'"'; + } + } + + if (isset($filter['severity']) && $filter['severity'] > 0) { + switch ($filter['severity']) { + case EVENT_CRIT_MAINTENANCE: + case EVENT_CRIT_INFORMATIONAL: + case EVENT_CRIT_NORMAL: + case EVENT_CRIT_MINOR: + case EVENT_CRIT_WARNING: + case EVENT_CRIT_MAJOR: + case EVENT_CRIT_CRITICAL: + default: + $sql_filters[] = sprintf( + ' AND criticity = %d ', + $filter['severity'] + ); + break; + + case EVENT_CRIT_WARNING_OR_CRITICAL: + $sql_filters[] = sprintf( + ' AND (criticity = %d OR criticity = %d)', + EVENT_CRIT_WARNING, + EVENT_CRIT_CRITICAL + ); + break; + + case EVENT_CRIT_NOT_NORMAL: + $sql_filters[] = sprintf( + ' AND criticity != %d', + EVENT_CRIT_NORMAL + ); + break; + + case EVENT_CRIT_OR_NORMAL: + $sql_filters[] = sprintf( + ' AND (criticity = %d OR criticity = %d)', + EVENT_CRIT_NORMAL, + EVENT_CRIT_CRITICAL + ); + break; + } + } + + if (isset($filter['id_group_filter']) && $filter['id_group_filter'] > 0) { + $propagate = db_get_value( + 'propagate', + 'tgrupo', + 'id_grupo', + $filter['id_group_filter'] + ); + + if (!$propagate) { + $sql_filters[] = sprintf( + ' AND te.id_grupo = %d ', + $filter['id_group_filter'] + ); + } else { + $groups = [ $filter['id_group_filter'] ]; + $childrens = groups_get_childrens($id_group, null, true); + if (!empty($childrens)) { + foreach ($childrens as $child) { + $groups[] = (int) $child['id_grupo']; + } + } + + $filter['id_group_filter'] = $groups; + $sql_filters[] = sprintf( + ' AND id_group IN (%s) ', + join(',', $filter['id_group_filter']) + ); + } + } + + // Skip system messages if user is not PM. + if (!check_acl($config['id_user'], 0, 'PM')) { + $sql_filters[] = ' AND te.id_grupo != 0 '; + } + + if (isset($filter['status'])) { + switch ($filter['status']) { + case EVENT_ALL: + default: + // Do not filter. + break; + + case EVENT_NEW: + case EVENT_VALIDATE: + case EVENT_PROCESS: + $sql_filters[] = sprintf( + ' AND estado = %d', + $filter['status'] + ); + break; + + case EVENT_NO_VALIDATED: + $sql_filters[] = sprintf( + ' AND (estado = %d OR estado = %d)', + EVENT_NEW, + EVENT_PROCESS + ); + break; + } + } + + $sg_active = enterprise_hook('agents_is_using_secondary_groups'); + + if (!$user_is_admin) { + $ER_groups = users_get_groups($config['id_user'], 'ER', false); + $EM_groups = users_get_groups($config['id_user'], 'EM', false, true); + $EW_groups = users_get_groups($config['id_user'], 'EW', false, true); + } + + if (!$user_is_admin && !users_can_manage_group_all('ER')) { + // Get groups where user have ER grants. + $sql_filters[] = sprintf( + ' AND te.id_grupo IN ( %s )', + join(', ', array_keys($ER_groups)) + ); + } + + $table = events_get_events_table(is_metaconsole(), $history); + $tevento = sprintf( + ' %s te', + $table + ); + + // Prepare agent join sql filters. + $agent_join_filters = []; + $tagente_table = 'tagente'; + $tagente_field = 'id_agente'; + if (is_metaconsole()) { + $tagente_table = 'tmetaconsole_agent'; + $tagente_field = 'id_tagente'; + } + + // Agent alias. + if (!empty($filter['agent_alias'])) { + $agent_join_filters[] = sprintf( + ' AND ta.alias = "%s" ', + $filter['agent_alias'] + ); + } + + // Free search. + if (!empty($filter['search'])) { + if (isset($config['dbconnection']->server_version) + && $config['dbconnection']->server_version > 50600 + ) { + // Use "from_base64" requires mysql 5.6 or greater. + $custom_data_search = 'from_base64(te.custom_data)'; + } else { + // Custom data is JSON encoded base64, if 5.6 or lower, + // user is condemned to use plain search. + $custom_data_search = 'te.custom_data'; + } + + $sql_filters[] = vsprintf( + ' AND (lower(ta.alias) like lower("%%%s%%") + OR te.id_evento like "%%%s%%" + OR lower(te.evento) like lower("%%%s%%") + OR lower(te.user_comment) like lower("%%%s%%") + OR lower(te.id_extra) like lower("%%%s%%") + OR lower(te.source) like lower("%%%s%%") + OR lower('.$custom_data_search.') like lower("%%%s%%") )', + array_fill(0, 7, $filter['search']) + ); + } + + // Id extra. + if (!empty($filter['id_extra'])) { + $sql_filters[] = sprintf( + ' AND lower(te.id_extra) like lower("%%%s%%") ', + $filter['id_extra'] + ); + } + + // User comment. + if (!empty($filter['user_comment'])) { + $sql_filters[] = sprintf( + ' AND lower(te.user_comment) like lower("%%%s%%") ', + $filter['user_comment'] + ); + } + + // Source. + if (!empty($filter['source'])) { + $sql_filters[] = sprintf( + ' AND lower(te.source) like lower("%%%s%%") ', + $filter['source'] + ); + } + + // Validated or in process by. + if (!empty($filter['id_user_ack'])) { + $sql_filters[] = sprintf( + ' AND te.id_usuario like lower("%%%s%%") ', + $filter['id_user_ack'] + ); + } + + $tag_names = []; + // With following tags. + if (!empty($filter['tag_with'])) { + $tag_with = base64_decode($filter['tag_with']); + $tags = json_decode($tag_with, true); + if (is_array($tags) && !in_array('0', $tags)) { + if (!$user_is_admin) { + $user_tags = array_flip(tags_get_tags_for_module_search()); + if ($user_tags != null) { + foreach ($tags as $id_tag) { + // User cannot filter with those tags. + if (!array_search($id_tag, $user_tags)) { + return false; + } + } + } + } + + foreach ($tags as $id_tag) { + if (!isset($tags_names[$id_tag])) { + $tags_names[$id_tag] = tags_get_name($id_tag); + } + + $_tmp .= ' AND ( '; + $_tmp .= sprintf( + ' tags LIKE "%s" OR', + $tags_names[$id_tag] + ); + + $_tmp .= sprintf( + ' tags LIKE "%s,%%" OR', + $tags_names[$id_tag] + ); + + $_tmp .= sprintf( + ' tags LIKE "%%,%s" OR', + $tags_names[$id_tag] + ); + + $_tmp .= sprintf( + ' tags LIKE "%%,%s,%%" ', + $tags_names[$id_tag] + ); + + $_tmp .= ') '; + } + + $sql_filters[] = $_tmp; + } + } + + // Without following tags. + if (!empty($filter['tag_without'])) { + $tag_without = base64_decode($filter['tag_without']); + $tags = json_decode($tag_without, true); + if (is_array($tags) && !in_array('0', $tags)) { + foreach ($tags as $id_tag) { + if (!isset($tags_names[$id_tag])) { + $tags_names[$id_tag] = tags_get_name($id_tag); + } + + $_tmp .= sprintf( + ' AND tags NOT LIKE "%s" ', + $tags_names[$id_tag] + ); + $_tmp .= sprintf( + ' AND tags NOT LIKE "%s,%%" ', + $tags_names[$id_tag] + ); + $_tmp .= sprintf( + ' AND tags NOT LIKE "%%,%s" ', + $tags_names[$id_tag] + ); + $_tmp .= sprintf( + ' AND tags NOT LIKE "%%,%s,%%" ', + $tags_names[$id_tag] + ); + } + + $sql_filters[] = $_tmp; + } + } + + // Filter/ Only alerts. + if (isset($filter['filter_only_alert'])) { + if ($filter['filter_only_alert'] == 0) { + $sql_filters[] = ' AND event_type NOT LIKE "%alert%"'; + } else if ($filter['filter_only_alert'] == 1) { + $sql_filters[] = ' AND event_type LIKE "%alert%"'; + } + } + + // TAgs ACLS. + if (check_acl($config['id_user'], 0, 'ER')) { + $tags_acls_condition = tags_get_acl_tags( + // Id_user. + $config['id_user'], + // Id_group. + $ER_groups, + // Access. + 'ER', + // Return_mode. + 'event_condition', + // Query_prefix. + 'AND', + // Query_table. + '', + // Meta. + is_metaconsole(), + // Childrens_ids. + [], + // Force_group_and_tag. + true, + // Table tag for id_grupo. + 'te.' + ); + // FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)". + } else if (check_acl($config['id_user'], 0, 'EW')) { + $tags_acls_condition = tags_get_acl_tags( + // Id_user. + $config['id_user'], + // Id_group. + $EW_groups, + // Access. + 'EW', + // Return_mode. + 'event_condition', + // Query_prefix. + 'AND', + // Query_table. + '', + // Meta. + is_metaconsole(), + // Childrens_ids. + [], + // Force_group_and_tag. + true, + // Table tag for id_grupo. + 'te.' + ); + // FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)". + } else if (check_acl($config['id_user'], 0, 'EM')) { + $tags_acls_condition = tags_get_acl_tags( + // Id_user. + $config['id_user'], + // Id_group. + $EM_groups, + // Access. + 'EM', + // Return_mode. + 'event_condition', + // Query_prefix. + 'AND', + // Query_table. + '', + // Meta. + is_metaconsole(), + // Childrens_ids. + [], + // Force_group_and_tag. + true, + // Table tag for id_grupo. + 'te.' + ); + // FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)". + } + + if (($tags_acls_condition != ERR_WRONG_PARAMETERS) + && ($tags_acls_condition != ERR_ACL) + ) { + $sql_filters[] = $tags_acls_condition; + } + + // Module search. + $agentmodule_join = 'LEFT JOIN tagente_modulo am ON te.id_agentmodule = am.id_agente_modulo'; + if (is_metaconsole()) { + $agentmodule_join = ''; + } else if (!empty($filter['module_search'])) { + $agentmodule_join = 'INNER JOIN tagente_modulo am ON te.id_agentmodule = am.id_agente_modulo'; + $sql_filters[] = sprintf( + ' AND am.nombre = "%s" ', + $filter['module_search'] + ); + } + + // Order. + $order_by = ''; + if (isset($order, $sort_field)) { + $order_by = events_get_sql_order($sort_field, $order); + } + + // Pagination. + $pagination = ''; + if (isset($limit, $offset) && $limit > 0) { + $pagination = sprintf(' LIMIT %d OFFSET %d', $limit, $offset); + } + + $extra = ''; + if (is_metaconsole()) { + $extra = ', server_id'; + } + + // Group by. + $group_by = 'GROUP BY '; + $tagente_join = 'LEFT'; + switch ($filter['group_rep']) { + case '0': + default: + // All events. + $group_by = ''; + break; + + case '1': + // Group by events. + $group_by .= 'te.estado, te.evento, te.id_agente, te.id_agentmodule'; + $group_by .= $extra; + break; + + case '2': + // Group by agents. + $tagente_join = 'INNER'; + // $group_by .= 'te.id_agente, te.event_type'; + // $group_by .= $extra; + $group_by = ''; + $order_by = events_get_sql_order('id_agente', 'asc'); + if (isset($order, $sort_field)) { + $order_by .= ','.events_get_sql_order( + $sort_field, + $order, + 0, + true + ); + } + break; + } + + $tgrupo_join = 'LEFT'; + $tgrupo_join_filters = []; + if (isset($filter['id_group_filter']) && $filter['id_group_filter'] > 0) { + $tgrupo_join = 'INNER'; + $tgrupo_join_filters[] = sprintf( + ' AND tg.id_grupo = %s', + $filter['id_group_filter'] + ); + } + + // Secondary groups. + db_process_sql('SET group_concat_max_len = 9999999'); + $event_lj = events_get_secondary_groups_left_join($table); + + $group_selects = ''; + if ($group_by != '') { + $group_selects = ',COUNT(id_evento) AS event_rep + ,GROUP_CONCAT(DISTINCT user_comment SEPARATOR "
") AS comments, + MAX(utimestamp) as timestamp_last, + MIN(utimestamp) as timestamp_first, + MAX(id_evento) as max_id_evento'; + + if ($count === false) { + $idx = array_search('te.user_comment', $fields); + if ($idx !== false) { + unset($fields[$idx]); + } + } + } + + $sql = sprintf( + 'SELECT %s + %s + FROM %s + %s + %s + %s JOIN %s ta + ON ta.%s = te.id_agente + %s + %s JOIN tgrupo tg + ON te.id_grupo = tg.id_grupo + %s + WHERE 1=1 + %s + %s + %s + %s + %s + ', + join(',', $fields), + $group_selects, + $tevento, + $event_lj, + $agentmodule_join, + $tagente_join, + $tagente_table, + $tagente_field, + join(' ', $agent_join_filters), + $tgrupo_join, + join(' ', $tgrupo_join_filters), + join(' ', $sql_filters), + $group_by, + $order_by, + $pagination, + $having + ); + + if (!$user_is_admin) { + // XXX: Confirm there's no extra grants unhandled!. + $can_manage = '0 as user_can_manage'; + if (!empty($EM_groups)) { + $can_manage = sprintf( + '(tbase.id_grupo IN (%s)) as user_can_manage', + join(', ', array_keys($EM_groups)) + ); + } + + $can_write = '0 as user_can_write'; + if (!empty($EW_groups)) { + $can_write = sprintf( + '(tbase.id_grupo IN (%s)) as user_can_write', + join(', ', array_keys($EW_groups)) + ); + } + + $sql = sprintf( + 'SELECT + tbase.*, + %s, + %s + FROM + (', + $can_manage, + $can_write + ).$sql.') tbase'; + } else { + $sql = 'SELECT + tbase.*, + 1 as user_can_manage, + 1 as user_can_write + FROM + ('.$sql.') tbase'; + } + + if ($count) { + $sql = 'SELECT count(*) as nitems FROM ('.$sql.') tt'; + } + + if ($return_sql) { + return $sql; + } + + return db_get_all_rows_sql($sql); +} + + /** * Get all rows of events from the database, that * pass the filter, and can get only some fields. @@ -195,7 +1276,7 @@ function events_get_events_no_grouped( /** * Return all events matching sql_post grouped. * - * @param [type] $sql_post Sql_post. + * @param string $sql_post Sql_post. * @param integer $offset Offset. * @param integer $pagination Pagination. * @param boolean $meta Meta. @@ -216,7 +1297,7 @@ function events_get_events_grouped( $total=false, $history_db=false, $order='down', - $sort_field='timestamp' + $sort_field='utimestamp' ) { global $config; @@ -976,6 +2057,8 @@ function events_print_event_table( ) { global $config; + ui_require_css_file('events'); + if ($agent_id == 0) { $agent_condition = ''; } else { @@ -1014,7 +2097,7 @@ function events_print_event_table( $table->cellpadding = 0; $table->cellspacing = 0; $table->width = $width; - $table->class = 'databox data'; + $table->class = 'info_table no-td-padding'; if (!$tactical_view) { $table->title = __('Latest events'); } @@ -1027,36 +2110,38 @@ function events_print_event_table( $table->cellclass = []; $table->data = []; $table->align = []; - $table->style[0] = 'width:25px;'; - $table->style[1] = 'width:25px;'; - $table->style[2] = 'width:25px;'; - if ($agent_id == 0) { - $table->style[3] = 'word-break: break-all;'; - } + $table->style = []; - $table->style[4] = 'width:120px; word-break: break-all;'; + $i = 0; + $table->head[$i] = "".__('S.').''; + $table->headstyle[$i] = 'width: 1%;text-align: center;'; + $table->style[$i++] = 'text-align: center;'; - $table->head[0] = "".__('V.').''; - $table->align[0] = 'center'; + $table->head[$i] = __('Type'); + $table->headstyle[$i] = 'width: 3%;text-align: center;'; + $table->style[$i++] = 'text-align: center;'; - $table->head[1] = "".__('S.').''; - $table->align[1] = 'center'; - - $table->head[2] = __('Type'); - $table->headclass[2] = 'datos3 f9'; - $table->align[2] = 'center'; - - $table->head[3] = __('Event name'); + $table->head[$i] = __('Event name'); + $table->headstyle[$i] = ''; + $table->style[$i++] = 'word-break: break-word;'; if ($agent_id == 0) { - $table->head[4] = __('Agent name'); - $table->size[4] = '15%'; + $table->head[$i] = __('Agent name'); + $table->headstyle[$i] = ''; + $table->style[$i++] = 'word-break: break-all;'; } - $table->head[5] = __('Timestamp'); - $table->headclass[5] = 'datos3 f9'; - $table->align[5] = 'left'; - $table->size[5] = '15%'; + $table->head[$i] = __('Timestamp'); + $table->headstyle[$i] = 'width: 150px;'; + $table->style[$i++] = 'word-break: break-word;'; + + $table->head[$i] = __('Status'); + $table->headstyle[$i] = 'width: 150px;text-align: center;'; + $table->style[$i++] = 'text-align: center;'; + + $table->head[$i] = "".__('V.').''; + $table->headstyle[$i] = 'width: 1%;text-align: center;'; + $table->style[$i++] = 'text-align: center;'; $all_groups = []; if ($agent_id != 0) { @@ -1095,53 +2180,15 @@ function events_print_event_table( break; } - $data[0] = html_print_image( - $img, - true, - [ - 'class' => 'image_status', - 'title' => $title, - ] - ); - - switch ($event['criticity']) { - default: - case EVENT_CRIT_MAINTENANCE: - $img = 'images/status_sets/default/severity_maintenance.png'; - break; - case EVENT_CRIT_INFORMATIONAL: - $img = 'images/status_sets/default/severity_informational.png'; - break; - - case EVENT_CRIT_NORMAL: - $img = 'images/status_sets/default/severity_normal.png'; - break; - - case EVENT_CRIT_WARNING: - $img = 'images/status_sets/default/severity_warning.png'; - break; - - case EVENT_CRIT_CRITICAL: - $img = 'images/status_sets/default/severity_critical.png'; - break; - } - - $data[1] = html_print_image( - $img, - true, - [ - 'class' => 'image_status', - 'width' => 12, - 'height' => 12, - 'title' => get_priority_name($event['criticity']), - ] - ); + $i = 0; + // Criticity. + $data[$i++] = ui_print_event_priority($event['criticity'], true, true); // Event type. - $data[2] = events_print_type_img($event['event_type'], true); + $data[$i++] = events_print_type_img($event['event_type'], true); // Event text. - $data[3] = ui_print_string_substr( + $data[$i++] = ui_print_string_substr( strip_tags(io_safe_output($event['evento'])), 75, true, @@ -1152,40 +2199,39 @@ function events_print_event_table( if ($event['id_agente'] > 0) { // Agent name. // Get class name, for the link color, etc. - $myclass = get_priority_class($event['criticity']); - - $data[4] = "".agents_get_alias($event['id_agente']).''; + $data[$i] = "".agents_get_alias($event['id_agente']).''; // For System or SNMP generated alerts. } else if ($event['event_type'] == 'system') { - $data[4] = __('System'); + $data[$i] = __('System'); } else { - $data[4] = __('Alert').'SNMP'; + $data[$i] = __('Alert').'SNMP'; } + + $i++; } // Timestamp. - $data[5] = ui_print_timestamp($event['timestamp'], true, ['style' => 'font-size: 7.5pt; letter-spacing: 0.3pt;']); + $data[$i++] = ui_print_timestamp($event['timestamp'], true, ['style' => 'font-size: 7.5pt; letter-spacing: 0.3pt;']); - $class = get_priority_class($event['criticity']); - $cell_classes[3] = $class; - $cell_classes[4] = $class; - $cell_classes[5] = $class; + // Status. + $data[$i++] = ui_print_event_type($event['event_type'], true); - array_push($table->cellclass, $cell_classes); - - /* - Commented out (old). - // array_push ($table->rowclass, get_priority_class ($event["criticity"])); - */ - - array_push($table->data, $data); + $data[$i++] = html_print_image( + $img, + true, + [ + 'class' => 'image_status', + 'title' => $title, + ] + ); + $table->data[] = $data; } $events_table = html_print_table($table, true); - $out = '
'; - $out .= $events_table; + $out = $events_table; if (!$tactical_view) { + $out .= '
'; if ($agent_id != 0) { $out .= ''; $out .= '
'; @@ -1201,9 +2247,9 @@ function events_print_event_table( '.__('Event graph by agent').''.grafico_eventos_grupo(180, 60).''; $out .= '
'; } - } - $out .= '
'; + $out .= '
'; + } unset($table); @@ -1966,7 +3012,7 @@ function events_get_event_filter_select($manage=true) $sql = ' SELECT id_filter, id_name FROM tevent_filter - WHERE id_group_filter IN ('.implode(',', array_keys($user_groups)).')'; + WHERE id_group_filter IN (0, '.implode(',', array_keys($user_groups)).')'; $event_filters = db_get_all_rows_sql($sql); @@ -1998,6 +3044,7 @@ function events_page_responses($event, $childrens_ids=[]) // // Responses. // + $table_responses = new StdClass(); $table_responses->cellspacing = 2; $table_responses->cellpadding = 2; $table_responses->id = 'responses_table'; @@ -2006,7 +3053,7 @@ function events_page_responses($event, $childrens_ids=[]) $table_responses->head = []; $table_responses->style[0] = 'height:30px'; $table_responses->style[2] = 'text-align:right;'; - $table_responses->class = 'events_show_more_table'; + $table_responses->class = 'table_modal_alternate'; if (tags_checks_event_acl($config['id_user'], $event['id_grupo'], 'EM', $event['clean_tags'], $childrens_ids)) { // Owner. @@ -2310,7 +3357,7 @@ function events_get_response_target( global $config; // If server_id > 0, it's a metaconsole query. - $meta = $server_id > 0; + $meta = $server_id > 0 || is_metaconsole(); $event_table = events_get_events_table($meta, $history); $event = db_get_row($event_table, 'id_evento', $event_id); @@ -2540,7 +3587,7 @@ function events_page_custom_fields($event) $table->width = '100%'; $table->data = []; $table->head = []; - $table->class = 'events_show_more_table'; + $table->class = 'table_modal_alternate'; $all_customs_fields = (bool) check_acl( $config['id_user'], @@ -2690,7 +3737,7 @@ function events_page_details($event, $server='') $table_details->head = []; $table_details->cellspacing = 0; $table_details->cellpadding = 0; - $table_details->class = 'events_show_more_table'; + $table_details->class = 'table_modal_alternate'; /* * Useless switch. @@ -2934,9 +3981,10 @@ function events_page_details($event, $server='') true, [ 'class' => 'image_status', - 'width' => 12, - 'height' => 12, + 'width' => 61, + 'height' => 28, 'title' => $alert_priority, + 'style' => 'vertical-align:text-bottom', ] ); $data[1] .= ' '.$alert_priority; @@ -3000,7 +4048,7 @@ function events_page_custom_data($event) $table->width = '100%'; $table->data = []; $table->head = []; - $table->class = 'events_show_more_table'; + $table->class = 'table_modal_alternate'; $json_custom_data = base64_decode($event['custom_data']); $custom_data = json_decode($json_custom_data); @@ -3155,7 +4203,7 @@ function events_page_general($event) $table_general->width = '100%'; $table_general->data = []; $table_general->head = []; - $table_general->class = 'events_show_more_table'; + $table_general->class = 'table_modal_alternate'; $data = []; $data[0] = __('Event ID'); @@ -3227,8 +4275,8 @@ function events_page_general($event) true, [ 'class' => 'image_status', - 'width' => 12, - 'height' => 12, + 'width' => 61, + 'height' => 28, 'title' => $event_criticity, ] ); @@ -3306,10 +4354,14 @@ function events_page_general($event) $table_general->data[] = $data; $table_data = $table_general->data; - $table_data_total = count($table_data); + if (is_array($table_data)) { + $table_data_total = count($table_data); + } else { + $table_data_total = -1; + } for ($i = 0; $i <= $table_data_total; $i++) { - if (count($table_data[$i]) == 2) { + if (is_array($table_data[$i]) && count($table_data[$i]) == 2) { $table_general->colspan[$i][1] = 2; $table_general->style[2] = 'text-align:center; width:10%;'; } @@ -3324,34 +4376,49 @@ function events_page_general($event) /** * Generate 'comments' page for event viewer. * - * @param array $event Event. - * @param array $childrens_ids Children ids. + * @param array $event Event. * * @return string HTML. */ -function events_page_comments($event, $childrens_ids=[]) +function events_page_comments($event) { // Comments. global $config; + $comments = ''; + + $comments = $event['user_comment']; + if (isset($event['comments'])) { + $comments = $event['comments']; + } + $table_comments = new stdClass; $table_comments->width = '100%'; $table_comments->data = []; $table_comments->head = []; - $table_comments->class = 'events_show_more_table'; + $table_comments->class = 'table_modal_alternate'; - $event_comments = $event['user_comment']; - $event_comments = str_replace(["\n", ' '], '
', $event_comments); + $comments = str_replace(["\n", ' '], '
', $comments); // If comments are not stored in json, the format is old. - $event_comments_array = json_decode($event_comments, true); - - // Show the comments more recent first. - if (is_array($event_comments_array)) { - $event_comments_array = array_reverse($event_comments_array); + $comments_array = json_decode(io_safe_output($comments), true); + if (!empty($comments) && json_last_error() != JSON_ERROR_NONE) { + $comments_array = [ + [ + 'comment' => 'Error retrieving comments', + 'action' => 'Internal message', + 'id_user' => 'SYSTEM', + 'utimestamp' => time(), + ], + ]; } - if (empty($event_comments_array)) { + // Show the comments more recent first. + if (is_array($comments_array)) { + $comments_array = array_reverse($comments_array); + } + + if (empty($comments_array)) { $comments_format = 'old'; } else { $comments_format = 'new'; @@ -3359,7 +4426,7 @@ function events_page_comments($event, $childrens_ids=[]) switch ($comments_format) { case 'new': - if (empty($event_comments_array)) { + if (empty($comments_array)) { $table_comments->style[0] = 'text-align:center;'; $table_comments->colspan[0][0] = 2; $data = []; @@ -3367,10 +4434,10 @@ function events_page_comments($event, $childrens_ids=[]) $table_comments->data[] = $data; } - if (isset($event_comments_array) === true - && is_array($event_comments_array) === true + if (isset($comments_array) === true + && is_array($comments_array) === true ) { - foreach ($event_comments_array as $c) { + foreach ($comments_array as $c) { $data[0] = ''.$c['action'].' by '.$c['id_user'].''; $data[0] .= '

'.date($config['date_format'], $c['utimestamp']).''; $data[1] = $c['comment']; @@ -3380,7 +4447,7 @@ function events_page_comments($event, $childrens_ids=[]) break; case 'old': - $comments_array = explode('
', $event_comments); + $comments_array = explode('
', $comments); // Split comments and put in table. $col = 0; @@ -3443,9 +4510,26 @@ function events_page_comments($event, $childrens_ids=[]) $childrens_ids ))) && $config['show_events_in_local'] == false || $config['event_replication'] == false ) { - $comments_form = '
'.html_print_textarea('comment', 3, 10, '', 'style="min-height: 15px; padding:0; width: 100%; disabled"', true); + $comments_form = '
'; + $comments_form .= html_print_textarea( + 'comment', + 3, + 10, + '', + 'style="min-height: 15px; padding:0; width: 100%; disabled"', + true + ); - $comments_form .= '
'.html_print_button(__('Add comment'), 'comment_button', false, 'event_comment();', 'class="sub next"', true).'

'; + $comments_form .= '
'; + $comments_form .= html_print_button( + __('Add comment'), + 'comment_button', + false, + 'event_comment();', + 'class="sub next"', + true + ); + $comments_form .= '

'; } else { $comments_form = ui_print_message( __('If event replication is ongoing, it won\'t be possible to enter comments here. This option is only to allow local pandora users to see comments, but not to operate with them. The operation, when event replication is enabled, must be done only in the Metaconsole.') @@ -4602,7 +5686,7 @@ function events_list_events_grouped_agents($sql) $sql = sprintf( 'SELECT * FROM %s LEFT JOIN tagent_secondary_group - ON tagent_secondary_group.id_agent = tevento.id_agente + ON tagent_secondary_group.id_agent = id_agente WHERE %s', $table, $sql @@ -5299,13 +6383,14 @@ function events_list_events_grouped_agents($sql) /** * Retrieves SQL for custom order. * - * @param string $sort_field Field. - * @param string $sort Order. - * @param integer $group_rep Group field. + * @param string $sort_field Field. + * @param string $sort Order. + * @param integer $group_rep Group field. + * @param boolean $only-fields Return only fields. * * @return string SQL. */ -function events_get_sql_order($sort_field='timestamp', $sort='DESC', $group_rep=0) +function events_get_sql_order($sort_field='timestamp', $sort='DESC', $group_rep=0, $only_fields=false) { $sort_field_translated = $sort_field; switch ($sort_field) { @@ -5354,11 +6439,19 @@ function events_get_sql_order($sort_field='timestamp', $sort='DESC', $group_rep= break; default: - // Ignore. + $sort_field_translated = $sort_field; break; } - $dir = ($sort == 'up') ? 'ASC' : 'DESC'; + if (strtolower($sort) != 'asc' && strtolower($sort) != 'desc') { + $dir = ($sort == 'up') ? 'ASC' : 'DESC'; + } else { + $dir = $sort; + } + + if ($only_fields) { + return $sort_field_translated.' '.$dir; + } return 'ORDER BY '.$sort_field_translated.' '.$dir; } diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 4d1fed36e0..72bc9b5c91 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -1,16 +1,32 @@ 0) { - // Propagate the last known data to the end of the interval + // Propagate the last known data to the end of the interval. $nextData = [ 'datos' => $data[(count($data) - 1)]['datos'], 'utimestamp' => $date_array['final_date'], @@ -114,9 +144,8 @@ function grafico_modulo_sparse_data_chart( array_push($data, $nextData); } - // Check available data + // Check available data. if (count($data) < 1) { - // return fs_error_image (); return false; } @@ -126,7 +155,7 @@ function grafico_modulo_sparse_data_chart( $array_percentil = []; foreach ($data as $k => $v) { - // convert array + // Convert array. if ($params['flag_overlapped']) { $array_data['sum'.$series_suffix]['data'][$k] = [ (($v['utimestamp'] + $date_array['period'] ) * 1000), @@ -139,40 +168,43 @@ function grafico_modulo_sparse_data_chart( ]; } - // min + // Min. if ($min_value > $v['datos']) { $min_value = $v['datos']; } - // max + // Max. if ($max_value < $v['datos']) { $max_value = $v['datos']; } - // avg + // Avg. $sum_data += $v['datos']; $count_data++; - // percentil - if (!is_null($params['percentil']) && $params['percentil']) { + // Percentil. + if (!isset($params['percentil']) && $params['percentil']) { $array_percentil[] = $v['datos']; } } - $array_data['sum'.$series_suffix]['min'] = $min_value; - $array_data['sum'.$series_suffix]['max'] = $max_value; - $array_data['sum'.$series_suffix]['avg'] = ($sum_data / $count_data); + $array_data['sum'.$series_suffix]['min'] = $min_value; + $array_data['sum'.$series_suffix]['max'] = $max_value; + $array_data['sum'.$series_suffix]['avg'] = ($sum_data / $count_data); $array_data['sum'.$series_suffix]['agent_module_id'] = $agent_module_id; $array_data['sum'.$series_suffix]['id_module_type'] = $data_module_graph['id_module_type']; - $array_data['sum'.$series_suffix]['agent_name'] = $data_module_graph['agent_name']; - $array_data['sum'.$series_suffix]['module_name'] = $data_module_graph['module_name']; - $array_data['sum'.$series_suffix]['agent_alias'] = $data_module_graph['agent_alias']; + $array_data['sum'.$series_suffix]['agent_name'] = $data_module_graph['agent_name']; + $array_data['sum'.$series_suffix]['module_name'] = $data_module_graph['module_name']; + $array_data['sum'.$series_suffix]['agent_alias'] = $data_module_graph['agent_alias']; - if (!is_null($params['percentil']) + if (!isset($params['percentil']) && $params['percentil'] && !$params['flag_overlapped'] ) { - $percentil_result = get_percentile($params['percentil'], $array_percentil); + $percentil_result = get_percentile( + $params['percentil'], + $array_percentil + ); $array_data['percentil'.$series_suffix]['data'][0] = [ ($date_array['start_date'] * 1000), $percentil_result, @@ -188,6 +220,17 @@ function grafico_modulo_sparse_data_chart( } +/** + * Prepare data for send to function js paint charts. + * + * @param integer $agent_module_id ID. + * @param array $date_array Date stasrt finish and period. + * @param array $data_module_graph Data module. + * @param array $params Params graphs. + * @param integer $series_suffix Int. + * + * @return array Prepare data to paint js. + */ function grafico_modulo_sparse_data( $agent_module_id, $date_array, @@ -210,7 +253,7 @@ function grafico_modulo_sparse_data( $params['type_mode_graph'] ); } else { - // uncompress data except boolean and string. + // Uncompress data except boolean and string. if ($data_module_graph['id_module_type'] == 23 || $data_module_graph['id_module_type'] == 3 || $data_module_graph['id_module_type'] == 17 @@ -232,6 +275,7 @@ function grafico_modulo_sparse_data( $series_suffix ); } else { + $data_slice = ($date_array['period'] / (250 * $params['zoom']) + 100); $array_data = fullscale_data( $agent_module_id, $date_array, @@ -239,13 +283,13 @@ function grafico_modulo_sparse_data( $params['percentil'], $series_suffix, $params['flag_overlapped'], - $data_slice = ($date_array['period'] / (250 * $params['zoom']) + 100), + $data_slice, $params['type_mode_graph'] ); } } - if ($array_data === false || (!$params['graph_combined'] + if ($array_data === false && (!$params['graph_combined'] && !isset($array_data['sum1']['data'][0][1]) && !$params['baseline']) ) { return false; @@ -253,12 +297,13 @@ function grafico_modulo_sparse_data( $array_data['sum'.$series_suffix]['agent_module_id'] = $agent_module_id; $array_data['sum'.$series_suffix]['id_module_type'] = $data_module_graph['id_module_type']; - $array_data['sum'.$series_suffix]['agent_name'] = $data_module_graph['agent_name']; - $array_data['sum'.$series_suffix]['module_name'] = $data_module_graph['module_name']; - $array_data['sum'.$series_suffix]['agent_alias'] = $data_module_graph['agent_alias']; - $array_data['sum'.$series_suffix]['unit'] = $data_module_graph['unit']; + $array_data['sum'.$series_suffix]['agent_name'] = $data_module_graph['agent_name']; + $array_data['sum'.$series_suffix]['module_name'] = $data_module_graph['module_name']; + $array_data['sum'.$series_suffix]['agent_alias'] = $data_module_graph['agent_alias']; + $array_data['sum'.$series_suffix]['unit'] = $data_module_graph['unit']; - // This is for a specific type of report that consists in passing an interval and doing the average sum and avg. + // This is for a specific type of report that consists in passing + // an interval and doing the average sum and avg. if ($params['force_interval'] != '') { $period_time_interval = ($date_array['period'] * 1000); $start_period = ($date_array['start_date'] * 1000); @@ -270,7 +315,9 @@ function grafico_modulo_sparse_data( while ($period_time_interval > 0) { foreach ($array_data['sum1']['data'] as $key => $value) { - if ($value[0] >= $start_period && $value[0] < ($start_period + $params['time_interval'] * 1000)) { + if ($value[0] >= $start_period + && $value[0] < ($start_period + $params['time_interval'] * 1000) + ) { $sum_data = $value[1]; $array_data_only[] = $value[1]; $count_data++; @@ -278,7 +325,9 @@ function grafico_modulo_sparse_data( } else { if ($params['force_interval'] == 'max_only') { $acum_array_data[$i][0] = $start_period; - if (is_array($array_data_only) && count($array_data_only) > 0) { + if (is_array($array_data_only) + && count($array_data_only) > 0 + ) { $acum_array_data[$i][1] = max($array_data_only); $data_last_acum = $array_data_only[(count($array_data_only) - 1)]; } else { @@ -288,7 +337,9 @@ function grafico_modulo_sparse_data( if ($params['force_interval'] == 'min_only') { $acum_array_data[$i][0] = $start_period; - if (is_array($array_data_only) && count($array_data_only) > 0) { + if (is_array($array_data_only) + && count($array_data_only) > 0 + ) { $acum_array_data[$i][1] = min($array_data_only); $data_last_acum = $array_data_only[(count($array_data_only) - 1)]; } else { @@ -298,7 +349,9 @@ function grafico_modulo_sparse_data( if ($params['force_interval'] == 'avg_only') { $acum_array_data[$i][0] = $start_period; - if (is_array($array_data_only) && count($array_data_only) > 0) { + if (is_array($array_data_only) + && count($array_data_only) > 0 + ) { $acum_array_data[$i][1] = ($sum_data / $count_data); } else { $acum_array_data[$i][1] = $data_last_acum; @@ -317,7 +370,7 @@ function grafico_modulo_sparse_data( $period_time_interval = ($period_time_interval - $params['time_interval']); } - // drag the last value to paint the graph correctly + // Drag the last value to paint the graph correctly. $acum_array_data[] = [ 0 => $start_period, 1 => $acum_array_data[($i - 1)][1], @@ -361,7 +414,6 @@ function grafico_modulo_sparse_data( $date_array['final_date'], $data_module_graph['history_db'], 1 - // fix the time ranges to start_date - final_date ); if ($unknown_events !== false) { @@ -496,57 +548,55 @@ function grafico_modulo_sparse_data( } -/* - $params =array( - 'agent_module_id' => $agent_module_id, - 'period' => $period, - 'show_events' => false, - 'width' => $width, - 'height' => $height, - 'title' => '', - 'unit_name' => null, - 'show_alerts' => false, - 'date' => 0, - 'unit' => '', - 'baseline' => 0, - 'return_data' => 0, - 'show_title' => true, - 'only_image' => false, - 'homeurl' => $config['homeurl'], - 'ttl' => 1, - 'adapt_key' => '', - 'compare' => false, - 'show_unknown' => false, - 'menu' => true, - 'backgroundColor' => 'white', - 'percentil' => null, - 'dashboard' => false, - 'vconsole' => false, - 'type_graph' => 'area', - 'fullscale' => false, - 'id_widget_dashboard' => false, - 'force_interval' => '', - 'time_interval' => 300, - 'array_data_create' => 0, - 'show_legend' => true, - 'show_overview' => true, - 'return_img_base_64' => false, - 'image_treshold' => false, - 'graph_combined' => false, - 'zoom' => 1, - 'server_id' => null, - 'stacked' => 0, - ); -*/ +/** + * Functions tu create graphs. + * + * @param array $params Details builds graphs. For example: + * 'agent_module_id' => $agent_module_id, + * 'period' => $period, + * 'show_events' => false, + * 'width' => $width, + * 'height' => $height, + * 'title' => '', + * 'unit_name' => null, + * 'show_alerts' => false, + * 'date' => 0, + * 'unit' => '', + * 'baseline' => 0, + * 'return_data' => 0, + * 'show_title' => true, + * 'only_image' => false, + * 'homeurl' => $config['homeurl'], + * 'ttl' => 1, + * 'adapt_key' => '', + * 'compare' => false, + * 'show_unknown' => false, + * 'menu' => true, + * 'backgroundColor' => 'white', + * 'percentil' => null, + * 'dashboard' => false, + * 'vconsole' => false, + * 'type_graph' => 'area', + * 'fullscale' => false, + * 'id_widget_dashboard' => false, + * 'force_interval' => '', + * 'time_interval' => 300, + * 'array_data_create' => 0, + * 'show_legend' => true, + * 'show_overview' => true, + * 'return_img_base_64' => false, + * 'image_treshold' => false, + * 'graph_combined' => false, + * 'zoom' => 1, + * 'server_id' => null, + * 'stacked' => 0. + * + * @return string html Content graphs. + */ function grafico_modulo_sparse($params) { global $config; - /* - XXXXXXXXXXXX Documnetar - *Set all variable - */ - if (!isset($params) || !is_array($params)) { return false; } @@ -694,11 +744,10 @@ function grafico_modulo_sparse($params) } if (!isset($params['zoom'])) { - $params['zoom'] = $config['zoom_graph'] ? $config['zoom_graph'] : 1; + $params['zoom'] = ($config['zoom_graph']) ? $config['zoom_graph'] : 1; } if (!isset($params['type_mode_graph'])) { - // $config['type_mode_graph'] $params['type_mode_graph'] = $config['type_mode_graph']; } @@ -716,10 +765,11 @@ function grafico_modulo_sparse($params) $params['stacked'] = 0; } - // XXXX Configurable - $params['grid_color'] = '#C1C1C1'; + // TODO: Configurable. + $params['grid_color'] = '#C1C1C1'; $params['legend_color'] = '#636363'; - $params['font'] = $config['fontpath']; + + $params['font'] = $config['fontpath']; $params['font_size'] = $config['font_size']; $params['short_data'] = $config['short_module_graph_data']; @@ -730,8 +780,8 @@ function grafico_modulo_sparse($params) global $graphic_type; global $array_events_alerts; - $array_data = []; - $legend = []; + $array_data = []; + $legend = []; $array_events_alerts = []; $date_array = []; @@ -746,26 +796,36 @@ function grafico_modulo_sparse($params) ); $data_module_graph = []; - $data_module_graph['history_db'] = db_search_in_history_db($date_array['start_date']); - $data_module_graph['agent_name'] = modules_get_agentmodule_agent_name($agent_module_id); - $data_module_graph['agent_alias'] = modules_get_agentmodule_agent_alias($agent_module_id); - $data_module_graph['agent_id'] = $module_data['id_agente']; - $data_module_graph['module_name'] = $module_data['nombre']; + $data_module_graph['history_db'] = db_search_in_history_db( + $date_array['start_date'] + ); + $data_module_graph['agent_name'] = modules_get_agentmodule_agent_name( + $agent_module_id + ); + $data_module_graph['agent_alias'] = modules_get_agentmodule_agent_alias( + $agent_module_id + ); + $data_module_graph['agent_id'] = $module_data['id_agente']; + $data_module_graph['module_name'] = $module_data['nombre']; $data_module_graph['id_module_type'] = $module_data['id_tipo_modulo']; - $data_module_graph['module_type'] = modules_get_moduletype_name($data_module_graph['id_module_type']); - $data_module_graph['uncompressed'] = is_module_uncompressed($data_module_graph['module_type']); - $data_module_graph['w_min'] = $module_data['min_warning']; - $data_module_graph['w_max'] = $module_data['max_warning']; - $data_module_graph['w_inv'] = $module_data['warning_inverse']; - $data_module_graph['c_min'] = $module_data['min_critical']; - $data_module_graph['c_max'] = $module_data['max_critical']; - $data_module_graph['c_inv'] = $module_data['critical_inverse']; - $data_module_graph['unit'] = $module_data['unit']; + $data_module_graph['module_type'] = modules_get_moduletype_name( + $data_module_graph['id_module_type'] + ); + $data_module_graph['uncompressed'] = is_module_uncompressed( + $data_module_graph['module_type'] + ); + $data_module_graph['w_min'] = $module_data['min_warning']; + $data_module_graph['w_max'] = $module_data['max_warning']; + $data_module_graph['w_inv'] = $module_data['warning_inverse']; + $data_module_graph['c_min'] = $module_data['min_critical']; + $data_module_graph['c_max'] = $module_data['max_critical']; + $data_module_graph['c_inv'] = $module_data['critical_inverse']; + $data_module_graph['unit'] = $module_data['unit']; } else { $data_module_graph = false; } - // format of the graph + // Format of the graph. if (empty($params['unit'])) { $params['unit'] = $module_data['unit']; if (modules_is_unit_macro($params['unit'])) { @@ -775,7 +835,12 @@ function grafico_modulo_sparse($params) if (!$params['array_data_create']) { if ($params['baseline']) { - $array_data = get_baseline_data($agent_module_id, $date_array, $data_module_graph, $params); + $array_data = get_baseline_data( + $agent_module_id, + $date_array, + $data_module_graph, + $params + ); } else { if ($params['compare'] !== false) { $series_suffix = 2; @@ -801,10 +866,14 @@ function grafico_modulo_sparse($params) switch ($params['compare']) { case 'separated': case 'overlapped': - // Store the chart calculated + // Store the chart calculated. $array_data_prev = $array_data; $legend_prev = $legend; break; + + default: + // Not defined. + break; } } @@ -857,7 +926,7 @@ function grafico_modulo_sparse($params) $data_module_graph['series_suffix'] = $series_suffix; - // Check available data + // Check available data. if ($params['compare'] === 'separated') { if (!empty($array_data)) { $return = area_graph( @@ -931,67 +1000,41 @@ function grafico_modulo_sparse($params) /** - * Produces a combined/user defined graph + * Functions tu create graphs. * - * @param array List of source modules - * @param array List of weighs for each module - * @param int Period (in seconds) - * @param int Width, in pixels - * @param int Height, in pixels - * @param string Title for graph - * @param string Unit name, for render in legend - * @param int Show events in graph (set to 1) - * @param int Show alerts in graph (set to 1) - * @param int Pure mode (without titles) (set to 1) - * @param int Date to start of getting info. - * @param mixed If is a projection graph this parameter will be module data with prediction data (the projection) - * or false in other case. - * @param array List of names for the items. Should have the same size as the module list. - * @param array List of units for the items. Should have the same size as the module list. - * @param bool Show the last value of the item on the list. - * @param bool Show the max value of the item on the list. - * @param bool Show the min value of the item on the list. - * @param bool Show the average value of the item on the list. + * @param array $module_list Array modules. + * @param array $params Details builds graphs. For example: + * 'period' => $period, + * 'show_events' => false, + * 'width' => $width, + * 'height' => $height, + * 'title' => '', + * 'unit_name' => null, + * 'show_alerts' => false, + * 'date' => 0, + * 'unit' => '', + * 'only_image' => false, + * 'homeurl' => '', + * 'ttl' => 1, + * 'percentil' => null, + * 'dashboard' => false, + * 'vconsole' => false, + * 'fullscale' => false, + * 'id_widget_dashboard' => false. + * @param array $params_combined Details builds graphs. For example: + * 'weight_list' => array(), + * 'stacked' => 0, + * 'projection' => false, + * 'labels' => array(), + * 'from_interface' => false, + * 'summatory' => 0, + * 'average' => 0, + * 'modules_series' => 0, + * 'id_graph' => 0, + * 'return' => 1. * - * @return Mixed + * @return string html Content graphs. */ - - -/* - $params =array( - 'period' => $period, - 'show_events' => false, - 'width' => $width, - 'height' => $height, - 'title' => '', - 'unit_name' => null, - 'show_alerts' => false, - 'date' => 0, - 'unit' => '', - 'only_image' => false, - 'homeurl' => '', - 'ttl' => 1, - 'percentil' => null, - 'dashboard' => false, - 'vconsole' => false, - 'fullscale' => false, - 'id_widget_dashboard' => false, - ); - - $params_combined = array( - 'weight_list' => array(), - 'stacked' => 0, - 'projection' => false, - 'labels' => array(), - 'from_interface' => false, - 'summatory' => 0, - 'average' => 0, - 'modules_series' => 0, - 'id_graph' => 0, - 'return' => 1 - ); -*/ - function graphic_combined_module( $module_list, $params, @@ -1171,18 +1214,24 @@ function graphic_combined_module( $params_combined['graph_combined'] = true; if ($params['only_image']) { - return generator_chart_to_pdf('combined', $params, $params_combined, $module_list); + return generator_chart_to_pdf( + 'combined', + $params, + $params_combined, + $module_list + ); } if (!isset($params['zoom'])) { $params['zoom'] = 1; } - // XXXX Configurable + // TODO: Configurable. $params['grid_color'] = '#C1C1C1'; $params['legend_color'] = '#636363'; - $params['font'] = $config['fontpath']; - $params['font_size'] = $config['font_size']; + + $params['font'] = $config['fontpath']; + $params['font_size'] = $config['font_size']; $params['short_data'] = $config['short_module_graph_data']; @@ -1228,8 +1277,10 @@ function graphic_combined_module( array_push($modules, $source['id_agent_module']); array_push($weights, $source['weight']); if ($source['label'] != '' || $params_combined['labels']) { - $item['type'] = 'custom_graph'; - $item['id_agent'] = agents_get_module_id($source['id_agent_module']); + $item['type'] = 'custom_graph'; + $item['id_agent'] = agents_get_module_id( + $source['id_agent_module'] + ); $item['id_agent_module'] = $source['id_agent_module']; $labels[$source['id_agent_module']] = ($source['label'] != '') ? reporting_label_macro($item, $source['label']) : reporting_label_macro($item, $params_combined['labels']); } @@ -1281,13 +1332,13 @@ function graphic_combined_module( } } - $width = $params['width']; - $height = $params['height']; - $homeurl = $params['homeurl']; - $ttl = $params['ttl']; + $width = $params['width']; + $height = $params['height']; + $homeurl = $params['homeurl']; + $ttl = $params['ttl']; $background_color = $params['backgroundColor']; - $datelimit = $date_array['start_date']; - $fixed_font_size = $config['font_size']; + $datelimit = $date_array['start_date']; + $fixed_font_size = $config['font_size']; if ($config['fixed_graph'] == false) { $water_mark = [ @@ -1344,22 +1395,32 @@ function graphic_combined_module( ); $data_module_graph = []; - $data_module_graph['history_db'] = db_search_in_history_db($date_array['start_date']); - $data_module_graph['agent_name'] = modules_get_agentmodule_agent_name($agent_module_id); - $data_module_graph['agent_alias'] = modules_get_agentmodule_agent_alias($agent_module_id); - $data_module_graph['agent_id'] = $module_data['id_agente']; - $data_module_graph['module_name'] = $module_data['nombre']; + $data_module_graph['history_db'] = db_search_in_history_db( + $date_array['start_date'] + ); + $data_module_graph['agent_name'] = modules_get_agentmodule_agent_name( + $agent_module_id + ); + $data_module_graph['agent_alias'] = modules_get_agentmodule_agent_alias( + $agent_module_id + ); + $data_module_graph['agent_id'] = $module_data['id_agente']; + $data_module_graph['module_name'] = $module_data['nombre']; $data_module_graph['id_module_type'] = $module_data['id_tipo_modulo']; - $data_module_graph['module_type'] = modules_get_moduletype_name($data_module_graph['id_module_type']); - $data_module_graph['uncompressed'] = is_module_uncompressed($data_module_graph['module_type']); - $data_module_graph['w_min'] = $module_data['min_warning']; - $data_module_graph['w_max'] = $module_data['max_warning']; - $data_module_graph['w_inv'] = $module_data['warning_inverse']; - $data_module_graph['c_min'] = $module_data['min_critical']; - $data_module_graph['c_max'] = $module_data['max_critical']; - $data_module_graph['c_inv'] = $module_data['critical_inverse']; - $data_module_graph['module_id'] = $agent_module_id; - $data_module_graph['unit'] = $module_data['unit']; + $data_module_graph['module_type'] = modules_get_moduletype_name( + $data_module_graph['id_module_type'] + ); + $data_module_graph['uncompressed'] = is_module_uncompressed( + $data_module_graph['module_type'] + ); + $data_module_graph['w_min'] = $module_data['min_warning']; + $data_module_graph['w_max'] = $module_data['max_warning']; + $data_module_graph['w_inv'] = $module_data['warning_inverse']; + $data_module_graph['c_min'] = $module_data['min_critical']; + $data_module_graph['c_max'] = $module_data['max_critical']; + $data_module_graph['c_inv'] = $module_data['critical_inverse']; + $data_module_graph['module_id'] = $agent_module_id; + $data_module_graph['unit'] = $module_data['unit']; // Stract data. $array_data_module = grafico_modulo_sparse_data( @@ -1400,10 +1461,11 @@ function graphic_combined_module( // Work around for fixed the agents name with huge size chars. $fixed_font_size = $config['font_size']; - // $array_events_alerts[$series_suffix] = $events; $i++; - if (is_metaconsole() && $params_combined['type_report'] == 'automatic_graph') { + if (is_metaconsole() + && $params_combined['type_report'] == 'automatic_graph' + ) { metaconsole_restore_db(); } } @@ -1418,7 +1480,7 @@ function graphic_combined_module( } if ($params_combined['projection']) { - // If projection doesn't have data then don't draw graph + // If projection doesn't have data then don't draw graph. if ($output_projection != null) { $date_array_projection = max($output_projection); $date_array['final_date'] = ($date_array_projection[0] / 1000); @@ -1426,9 +1488,13 @@ function graphic_combined_module( } } - // summatory and average series - if ($params_combined['stacked'] == CUSTOM_GRAPH_AREA || $params_combined['stacked'] == CUSTOM_GRAPH_LINE) { - if ($params_combined['summatory'] || $params_combined['average']) { + // Summatory and average series. + if ($params_combined['stacked'] == CUSTOM_GRAPH_AREA + || $params_combined['stacked'] == CUSTOM_GRAPH_LINE + ) { + if ($params_combined['summatory'] + || $params_combined['average'] + ) { $array_data = combined_graph_summatory_average( $array_data, $params_combined['average'], @@ -1471,9 +1537,19 @@ function graphic_combined_module( $do_it_critical_inverse = true; foreach ($module_list as $index => $id_module) { - // Get module warning_min and critical_min - $warning_min = db_get_value('min_warning', 'tagente_modulo', 'id_agente_modulo', $id_module); - $critical_min = db_get_value('min_critical', 'tagente_modulo', 'id_agente_modulo', $id_module); + // Get module warning_min and critical_min. + $warning_min = db_get_value( + 'min_warning', + 'tagente_modulo', + 'id_agente_modulo', + $id_module + ); + $critical_min = db_get_value( + 'min_critical', + 'tagente_modulo', + 'id_agente_modulo', + $id_module + ); if ($index == 0) { $compare_warning = $warning_min; @@ -1494,8 +1570,18 @@ function graphic_combined_module( if ($do_it_warning_min || $do_it_critical_min) { foreach ($module_list as $index => $id_module) { - $warning_max = db_get_value('max_warning', 'tagente_modulo', 'id_agente_modulo', $id_module); - $critical_max = db_get_value('max_critical', 'tagente_modulo', 'id_agente_modulo', $id_module); + $warning_max = db_get_value( + 'max_warning', + 'tagente_modulo', + 'id_agente_modulo', + $id_module + ); + $critical_max = db_get_value( + 'max_critical', + 'tagente_modulo', + 'id_agente_modulo', + $id_module + ); if ($index == 0) { $yellow_up = $warning_max; @@ -1517,8 +1603,18 @@ function graphic_combined_module( if ($do_it_warning_min || $do_it_critical_min) { foreach ($module_list as $index => $id_module) { - $warning_inverse = db_get_value('warning_inverse', 'tagente_modulo', 'id_agente_modulo', $id_module); - $critical_inverse = db_get_value('critical_inverse', 'tagente_modulo', 'id_agente_modulo', $id_module); + $warning_inverse = db_get_value( + 'warning_inverse', + 'tagente_modulo', + 'id_agente_modulo', + $id_module + ); + $critical_inverse = db_get_value( + 'critical_inverse', + 'tagente_modulo', + 'id_agente_modulo', + $id_module + ); if ($index == 0) { $yellow_inverse = $warning_inverse; @@ -1538,18 +1634,24 @@ function graphic_combined_module( } } - if ($do_it_warning_min && $do_it_warning_max && $do_it_warning_inverse) { + if ($do_it_warning_min + && $do_it_warning_max + && $do_it_warning_inverse + ) { $yellow_threshold = $compare_warning; $threshold_data['yellow_threshold'] = $compare_warning; - $threshold_data['yellow_up'] = $yellow_up; - $threshold_data['yellow_inverse'] = (bool) $yellow_inverse; + $threshold_data['yellow_up'] = $yellow_up; + $threshold_data['yellow_inverse'] = (bool) $yellow_inverse; } - if ($do_it_critical_min && $do_it_critical_max && $do_it_critical_inverse) { + if ($do_it_critical_min + && $do_it_critical_max + && $do_it_critical_inverse + ) { $red_threshold = $compare_critical; $threshold_data['red_threshold'] = $compare_critical; - $threshold_data['red_up'] = $red_up; - $threshold_data['red_inverse'] = (bool) $red_inverse; + $threshold_data['red_up'] = $red_up; + $threshold_data['red_inverse'] = (bool) $red_inverse; } $params['threshold_data'] = $threshold_data; @@ -1596,9 +1698,12 @@ function graphic_combined_module( foreach ($module_list as $module_item) { $automatic_custom_graph_meta = false; if ($config['metaconsole']) { - // Automatic custom graph from the report template in metaconsole + // Automatic custom graph from the report + // template in metaconsole. if (is_array($module_list[$i])) { - $server = metaconsole_get_connection_by_id($module_item['server']); + $server = metaconsole_get_connection_by_id( + $module_item['server'] + ); metaconsole_connect($server); $automatic_custom_graph_meta = true; } @@ -1635,16 +1740,27 @@ function graphic_combined_module( $value = false; } - if (!empty($params_combined['labels']) && isset($params_combined['labels'][$module])) { + if (!empty($params_combined['labels']) + && isset($params_combined['labels'][$module]) + ) { $label = io_safe_input($params_combined['labels'][$module]); } else { - $alias = db_get_value('alias', 'tagente', 'id_agente', $temp[$module]['id_agente']); + $alias = db_get_value( + 'alias', + 'tagente', + 'id_agente', + $temp[$module]['id_agente'] + ); $label = $alias.': '.$temp[$module]['nombre']; } $temp[$module]['label'] = $label; $temp[$module]['value'] = $value; - $temp_max = reporting_get_agentmodule_data_max($module, $params['period'], $params['date']); + $temp_max = reporting_get_agentmodule_data_max( + $module, + $params['period'], + $params['date'] + ); if ($temp_max < 0) { $temp_max = 0; } @@ -1655,7 +1771,11 @@ function graphic_combined_module( $temp[$module]['max'] = ($temp_max === false) ? 0 : $temp_max; } - $temp_min = reporting_get_agentmodule_data_min($module, $params['period'], $params['date']); + $temp_min = reporting_get_agentmodule_data_min( + $module, + $params['period'], + $params['date'] + ); if ($temp_min < 0) { $temp_min = 0; } @@ -1663,7 +1783,8 @@ function graphic_combined_module( $temp[$module]['min'] = ($temp_min === false) ? 0 : $temp_min; if ($config['metaconsole']) { - // Automatic custom graph from the report template in metaconsole + // Automatic custom graph from the + // report template in metaconsole. if (is_array($module_list[0])) { metaconsole_restore_db(); } @@ -1688,7 +1809,12 @@ function graphic_combined_module( $color, $module_name_list, $long_index, - ui_get_full_url('images/image_problem_area_small.png', false, false, false), + ui_get_full_url( + 'images/image_problem_area_small.png', + false, + false, + false + ), '', '', $water_mark, @@ -1699,7 +1825,6 @@ function graphic_combined_module( $homeurl, $background_color ); - break; case CUSTOM_GRAPH_GAUGE: @@ -1708,9 +1833,12 @@ function graphic_combined_module( foreach ($module_list as $module_item) { $automatic_custom_graph_meta = false; if ($config['metaconsole']) { - // Automatic custom graph from the report template in metaconsole + // Automatic custom graph from + // the report template in metaconsole. if (is_array($module_list[$i])) { - $server = metaconsole_get_connection_by_id($module_item['server']); + $server = metaconsole_get_connection_by_id( + $module_item['server'] + ); metaconsole_connect($server); $automatic_custom_graph_meta = true; } @@ -1747,7 +1875,14 @@ function graphic_combined_module( $temp[$module]['label'] = ($params_combined['labels'][$module] != '') ? $params_combined['labels'][$module] : $temp[$module]['nombre']; $temp[$module]['value'] = $value; - $temp[$module]['label'] = ui_print_truncate_text($temp[$module]['label'], 'module_small', false, true, false, '..'); + $temp[$module]['label'] = ui_print_truncate_text( + $temp[$module]['label'], + 'module_small', + false, + true, + false, + '..' + ); if ($temp[$module]['unit'] == '%') { $temp[$module]['min'] = 0; @@ -1755,7 +1890,11 @@ function graphic_combined_module( } else { $min = $temp[$module]['min']; if ($temp[$module]['max'] == 0) { - $max = reporting_get_agentmodule_data_max($module, $params['period'], $params['date']); + $max = reporting_get_agentmodule_data_max( + $module, + $params['period'], + $params['date'] + ); } else { $max = $temp[$module]['max']; } @@ -1767,7 +1906,8 @@ function graphic_combined_module( $temp[$module]['gauge'] = uniqid('gauge_'); if ($config['metaconsole']) { - // Automatic custom graph from the report template in metaconsole + // Automatic custom graph from the report + // template in metaconsole. if (is_array($module_list[0])) { metaconsole_restore_db(); } @@ -1794,13 +1934,17 @@ function graphic_combined_module( $height, $color, $module_name_list, - ui_get_full_url('images/image_problem_area_small.png', false, false, false), + ui_get_full_url( + 'images/image_problem_area_small.png', + false, + false, + false + ), $config['fontpath'], $fixed_font_size, '', $homeurl ); - break; case CUSTOM_GRAPH_HBARS: @@ -1809,9 +1953,12 @@ function graphic_combined_module( foreach ($module_list as $module_item) { $automatic_custom_graph_meta = false; if ($config['metaconsole']) { - // Automatic custom graph from the report template in metaconsole + // Automatic custom graph from the report + // template in metaconsole. if (is_array($module_list[$i])) { - $server = metaconsole_get_connection_by_id($module_item['server']); + $server = metaconsole_get_connection_by_id( + $module_item['server'] + ); metaconsole_connect($server); $automatic_custom_graph_meta = true; } @@ -1840,17 +1987,25 @@ function graphic_combined_module( modules_get_agentmodule_agent_name($module) ); - if (!empty($params_combined['labels']) && isset($params_combined['labels'][$module])) { + if (!empty($params_combined['labels']) + && isset($params_combined['labels'][$module]) + ) { $label = $params_combined['labels'][$module]; } else { - $alias = db_get_value('alias', 'tagente', 'id_agente', $module_data['id_agente']); + $alias = db_get_value( + 'alias', + 'tagente', + 'id_agente', + $module_data['id_agente'] + ); $label = $alias.' - '.$module_data['nombre']; } $temp[$label]['g'] = round($temp_data, 4); if ($config['metaconsole']) { - // Automatic custom graph from the report template in metaconsole + // Automatic custom graph from the report + // template in metaconsole. if (is_array($module_list[0])) { metaconsole_restore_db(); } @@ -1874,7 +2029,12 @@ function graphic_combined_module( $color, $module_name_list, $long_index, - ui_get_full_url('images/image_problem_area_small.png', false, false, false), + ui_get_full_url( + 'images/image_problem_area_small.png', + false, + false, + false + ), '', '', $water_mark, @@ -1896,7 +2056,12 @@ function graphic_combined_module( $color, $module_name_list, $long_index, - ui_get_full_url('images/image_problem_area_small.png', false, false, false), + ui_get_full_url( + 'images/image_problem_area_small.png', + false, + false, + false + ), '', '', $water_mark, @@ -1918,9 +2083,12 @@ function graphic_combined_module( foreach ($module_list as $module_item) { $automatic_custom_graph_meta = false; if ($config['metaconsole']) { - // Automatic custom graph from the report template in metaconsole + // Automatic custom graph from the report + // template in metaconsole. if (is_array($module_list[$i])) { - $server = metaconsole_get_connection_by_id($module_item['server']); + $server = metaconsole_get_connection_by_id( + $module_item['server'] + ); metaconsole_connect($server); $automatic_custom_graph_meta = true; } @@ -1959,10 +2127,19 @@ function graphic_combined_module( $total_modules += $value; - if (!empty($params_combined['labels']) && isset($params_combined['labels'][$module])) { - $label = io_safe_output($params_combined['labels'][$module]); + if (!empty($params_combined['labels']) + && isset($params_combined['labels'][$module]) + ) { + $label = io_safe_output( + $params_combined['labels'][$module] + ); } else { - $alias = db_get_value('alias', 'tagente', 'id_agente', $data_module['id_agente']); + $alias = db_get_value( + 'alias', + 'tagente', + 'id_agente', + $data_module['id_agente'] + ); $label = io_safe_output($alias.': '.$data_module['nombre']); } @@ -1971,7 +2148,8 @@ function graphic_combined_module( 'unit' => $data_module['unit'], ]; if ($config['metaconsole']) { - // Automatic custom graph from the report template in metaconsole + // Automatic custom graph from the report + // template in metaconsole. if (is_array($module_list[0])) { metaconsole_restore_db(); } @@ -2004,7 +2182,6 @@ function graphic_combined_module( false, $background_color ); - break; } @@ -2016,8 +2193,24 @@ function graphic_combined_module( } -function combined_graph_summatory_average($array_data, $average=false, $summatory=false, $modules_series=false, $baseline=false) -{ +/** + * Function for convert data summatory. + * + * @param array $array_data Data array. + * @param boolean $average Average. + * @param boolean $summatory Summatory. + * @param boolean $modules_series Series module. + * @param boolean $baseline Baseline data. + * + * @return array Data. + */ +function combined_graph_summatory_average( + $array_data, + $average=false, + $summatory=false, + $modules_series=false, + $baseline=false +) { if (isset($array_data) && is_array($array_data)) { foreach ($array_data as $key => $value) { if (strpos($key, 'sum') !== false) { @@ -2035,10 +2228,14 @@ function combined_graph_summatory_average($array_data, $average=false, $summator $data_array_pop = []; $count = 0; - while (count($data_array_reverse['sum0']) > 0) { + $count_data_array_reverse = count($data_array_reverse['sum0']); + while ($count_data_array_reverse > 0) { foreach ($data_array_reverse as $key_reverse => $value_reverse) { if (is_array($value_reverse) && count($value_reverse) > 0) { - $data_array_pop[$key_reverse] = array_pop($data_array_reverse[$key_reverse]); + $data_array_pop[$key_reverse] = array_pop( + $data_array_reverse[$key_reverse] + ); + $count_data_array_reverse--; } } @@ -2092,12 +2289,18 @@ function combined_graph_summatory_average($array_data, $average=false, $summator $count++; } - if ($summatory && isset($array_sum_reverse) && is_array($array_sum_reverse) && count($array_sum_reverse) > 0) { + if ($summatory && isset($array_sum_reverse) + && is_array($array_sum_reverse) + && count($array_sum_reverse) > 0 + ) { $array_data['summatory']['data'] = $array_sum_reverse; $array_data['summatory']['color'] = 'purple'; } - if ($average && isset($array_avg_reverse) && is_array($array_avg_reverse) && count($array_avg_reverse) > 0) { + if ($average && isset($array_avg_reverse) + && is_array($array_avg_reverse) + && count($array_avg_reverse) > 0 + ) { if ($baseline) { $array_data['baseline']['data'] = $array_avg_reverse; $array_data['baseline']['color'] = 'green'; @@ -2118,28 +2321,44 @@ function combined_graph_summatory_average($array_data, $average=false, $summator /** * Print a graph with access data of agents * - * @param integer id_agent Agent ID - * @param integer width pie graph width - * @param integer height pie graph height - * @param integer period time period - * @param bool return or echo the result flag + * @param integer $id_agent Agent ID. + * @param integer $width Pie graph width. + * @param integer $height Pie graph height. + * @param integer $period Time period. + * @param boolean $return Return. + * @param boolean $tree View tree. + * + * @return string Return or echo the result flag. */ -function graphic_agentaccess($id_agent, $width, $height, $period=0, $return=false, $tree=false) -{ +function graphic_agentaccess( + $id_agent, + $width, + $height, + $period=0, + $return=false, + $tree=false +) { global $config; global $graphic_type; - $date = get_system_time(); - $datelimit = ($date - $period); + $date = get_system_time(); + $datelimit = ($date - $period); $data_array = []; + $interval = agents_get_interval($id_agent); $data = db_get_all_rows_sql( - "SELECT count(*) as data, min(utimestamp) as utimestamp - FROM tagent_access - WHERE id_agent = $id_agent - AND utimestamp > $datelimit - AND utimestamp < $date - GROUP by ROUND(utimestamp / 1800)" + sprintf( + 'SELECT utimestamp, count(*) as data + FROM tagent_access + WHERE id_agent = %d + AND utimestamp > %d + AND utimestamp < %d + GROUP BY ROUND(utimestamp/%d)', + $id_agent, + $datelimit, + $date, + $interval + ) ); if (isset($data) && is_array($data)) { @@ -2160,7 +2379,12 @@ function graphic_agentaccess($id_agent, $width, $height, $period=0, $return=fals if ($config['fixed_graph'] == false) { $water_mark = [ 'file' => $config['homedir'].'/images/logo_vertical_water.png', - 'url' => ui_get_full_url('images/logo_vertical_water.png', false, false, false), + 'url' => ui_get_full_url( + 'images/logo_vertical_water.png', + false, + false, + false + ), ]; } @@ -2263,7 +2487,7 @@ function truncate_negatives(&$element) * @param bool return or echo flag * @param bool show_not_init flag */ -function graph_agent_status($id_agent=false, $width=300, $height=200, $return=false, $show_not_init=false, $data_agents=false) +function graph_agent_status($id_agent=false, $width=300, $height=200, $return=false, $show_not_init=false, $data_agents=false, $donut_narrow_graph=false) { global $config; @@ -2316,38 +2540,50 @@ function graph_agent_status($id_agent=false, $width=300, $height=200, $return=fa } // $colors = array(COL_CRITICAL, COL_WARNING, COL_NORMAL, COL_UNKNOWN); - $colors[__('Critical')] = COL_CRITICAL; - $colors[__('Warning')] = COL_WARNING; - $colors[__('Normal')] = COL_NORMAL; - $colors[__('Unknown')] = COL_UNKNOWN; + $colors['Critical'] = COL_CRITICAL; + $colors['Warning'] = COL_WARNING; + $colors['Normal'] = COL_NORMAL; + $colors['Unknown'] = COL_UNKNOWN; if ($show_not_init) { - $colors[__('Not init')] = COL_NOTINIT; + $colors['Not init'] = COL_NOTINIT; } if (array_sum($data) == 0) { $data = []; } - $out = pie_graph( - $data, - $width, - $height, - __('other'), - ui_get_full_url(false, false, false, false), - '', - $config['fontpath'], - $config['font_size'], - 1, - 'hidden', - $colors, - 0 - ); - - if ($return) { + if ($donut_narrow_graph == true) { + $data_total = array_sum($data); + $out = print_donut_narrow_graph( + $colors, + $width, + $height, + $data, + $data_total + ); return $out; } else { - echo $out; + $out = pie_graph( + $data, + $width, + $height, + __('other'), + ui_get_full_url(false, false, false, false), + '', + $config['fontpath'], + $config['font_size'], + 1, + 'hidden', + $colors, + 0 + ); + + if ($return) { + return $out; + } else { + echo $out; + } } } @@ -3704,7 +3940,14 @@ function graph_graphic_moduleevents($id_agent, $id_module, $width, $height, $per } -// Prints an error image +/** + * Function for retun image no data. + * + * @param integer $width Width. + * @param integer $height Height. + * + * @return string Image. + */ function fs_error_image($width=300, $height=110) { global $config; @@ -3712,15 +3955,29 @@ function fs_error_image($width=300, $height=110) } +/** + * Function for uncompressed data module for cherts. + * + * @param integer $agent_module_id Id modulo. + * @param array $date_array Date start, finish, period. + * @param integer $show_unknown Show Unknown. + * @param integer $show_percentil Show Percentil. + * @param integer $series_suffix Series. + * @param boolean $compare Type compare. + * @param boolean $data_slice Size slice. + * @param string $type_mode_graph Type. + * + * @return array Return array data uncompresess. + */ function fullscale_data( $agent_module_id, $date_array, $show_unknown=0, $show_percentil=0, - $series_suffix, + $series_suffix=0, $compare=false, $data_slice=false, - $type_mode_graph + $type_mode_graph='' ) { global $config; $data_uncompress = db_uncompress_module_data( @@ -3732,218 +3989,234 @@ function fullscale_data( $data = []; $previous_data = 0; - // normal + // Normal. $min_value_total = PHP_INT_MAX; - $max_value_total = -PHP_INT_MAX; - // max + $max_value_total = (-PHP_INT_MAX); + // Max. $max_value_min = PHP_INT_MAX; - $max_value_max = -PHP_INT_MAX; - // min + $max_value_max = (-PHP_INT_MAX); + // Min. $min_value_min = PHP_INT_MAX; - $min_value_max = -PHP_INT_MAX; - // avg + $min_value_max = (-PHP_INT_MAX); + // Avg. $avg_value_min = PHP_INT_MAX; - $avg_value_max = -PHP_INT_MAX; + $avg_value_max = (-PHP_INT_MAX); $flag_unknown = 0; $array_percentil = []; if ($data_slice) { - foreach ($data_uncompress as $k) { - $sum_data = 0; - $count_data = 0; - $min_value = PHP_INT_MAX; - $max_value = -PHP_INT_MAX; - $flag_virtual_data = 0; - foreach ($k['data'] as $v) { - if (isset($v['type']) && $v['type'] == 1) { - // skip unnecesary virtual data - continue; - $flag_virtual_data = 1; - } + if (isset($data_uncompress) === true + && is_array($data_uncompress) === true + ) { + foreach ($data_uncompress as $k) { + $sum_data = 0; + $count_data = 0; + $min_value = PHP_INT_MAX; + $max_value = (-PHP_INT_MAX); + $flag_virtual_data = 0; + foreach ($k['data'] as $v) { + if (isset($v['type']) && $v['type'] == 1) { + // Skip unnecesary virtual data. + continue; + $flag_virtual_data = 1; + } - if ($compare) { - // * 1000 need js utimestam mlsecond - $real_date = (($v['utimestamp'] + $date_array['period']) * 1000); - } else { - $real_date = ($v['utimestamp'] * 1000); - } + if ($compare) { + // Data * 1000 need js utimestam mlsecond. + $real_date = (($v['utimestamp'] + $date_array['period']) * 1000); + } else { + $real_date = ($v['utimestamp'] * 1000); + } - if ($v['datos'] === null) { - // Unknown - if ($show_unknown) { - if (!$compare) { - if ($flag_unknown) { - $data['unknown'.$series_suffix]['data'][] = [ - $real_date, - 1, - ]; - } else { - $data['unknown'.$series_suffix]['data'][] = [ - ($real_date - 1), - 0, - ]; - $data['unknown'.$series_suffix]['data'][] = [ - $real_date, - 1, - ]; - $flag_unknown = 1; + if ($v['datos'] === null) { + // Unknown. + if ($show_unknown) { + if (!$compare) { + if ($flag_unknown) { + $data['unknown'.$series_suffix]['data'][] = [ + $real_date, + 1, + ]; + } else { + $data['unknown'.$series_suffix]['data'][] = [ + ($real_date - 1), + 0, + ]; + $data['unknown'.$series_suffix]['data'][] = [ + $real_date, + 1, + ]; + $flag_unknown = 1; + } + } + } + + $v['datos'] = $previous_data; + } else { + // Normal. + $previous_data = $v['datos']; + if ($show_unknown) { + if (!$compare) { + if ($flag_unknown) { + $data['unknown'.$series_suffix]['data'][] = [ + $real_date, + 0, + ]; + $flag_unknown = 0; + } } } } - $v['datos'] = $previous_data; - } else { - // normal - $previous_data = $v['datos']; - if ($show_unknown) { - if (!$compare) { - if ($flag_unknown) { - $data['unknown'.$series_suffix]['data'][] = [ - $real_date, - 0, - ]; - $flag_unknown = 0; - } + if (isset($v['datos']) && $v['datos']) { + // Max. + if ($v['datos'] >= $max_value) { + $max_value = $v['datos']; + } + + // Min. + if ($v['datos'] <= $min_value) { + $min_value = $v['datos']; + } + + // Avg sum. + $sum_data += $v['datos']; + } + + // Avg count. + $count_data++; + + if ($show_percentil && !$compare) { + $array_percentil[] = $v['datos']; + } + + $last_data = $v['datos']; + } + + if (!$flag_virtual_data) { + if ($compare) { + // Data * 1000 need js utimestam mlsecond. + $real_date = (($k['data'][0]['utimestamp'] + $date_array['period']) * 1000); + } else { + $real_date = ($k['data'][0]['utimestamp'] * 1000); + } + + $data['sum'.$series_suffix]['data'][] = [ + $real_date, + ($sum_data / $count_data), + ]; + if ($type_mode_graph && !$params['baseline']) { + if ($min_value != PHP_INT_MAX) { + $data['min'.$series_suffix]['data'][] = [ + $real_date, + $min_value, + ]; + } + + if ($max_value != (-PHP_INT_MAX)) { + $data['max'.$series_suffix]['data'][] = [ + $real_date, + $max_value, + ]; + } + } else { + if ($min_value != PHP_INT_MAX) { + $data['sum'.$series_suffix]['slice_data'][$real_date]['min'] = $min_value; + } + + $data['sum'.$series_suffix]['slice_data'][$real_date]['avg'] = ($sum_data / $count_data); + + if ($max_value != (-PHP_INT_MAX)) { + $data['sum'.$series_suffix]['slice_data'][$real_date]['max'] = $max_value; } } - } - if (isset($v['datos']) && $v['datos']) { - // max - if ($v['datos'] >= $max_value) { - $max_value = $v['datos']; + // Max total. + if ($max_value >= $max_value_total + && $max_value != (-PHP_INT_MAX) + ) { + $max_value_total = $max_value; } - // min - if ($v['datos'] <= $min_value) { - $min_value = $v['datos']; + // Min total. + if ($min_value <= $min_value_total + && $min_value != PHP_INT_MAX + ) { + $min_value_total = $min_value; } - // avg sum - $sum_data += $v['datos']; - } + // Avg sum total. + $sum_data_total += ($sum_data / $count_data); - // avg count - $count_data++; + // Avg count total. + $count_data_total++; - if ($show_percentil && !$compare) { - $array_percentil[] = $v['datos']; - } + if ($type_mode_graph && !$params['baseline']) { + // MIN. + // max min. + if ($min_value >= $min_value_max + && $min_value != PHP_INT_MAX + ) { + $min_value_max = $min_value; + } - $last_data = $v['datos']; - } + // Min min. + if ($min_value <= $min_value_min + && $min_value != PHP_INT_MAX + ) { + $min_value_min = $min_value; + } - if (!$flag_virtual_data) { - if ($compare) { - // * 1000 need js utimestam mlsecond - $real_date = (($k['data'][0]['utimestamp'] + $date_array['period']) * 1000); - } else { - $real_date = ($k['data'][0]['utimestamp'] * 1000); - } + // Avg sum min. + if ($min_value != PHP_INT_MAX) { + $sum_data_min += $min_value; + } - $data['sum'.$series_suffix]['data'][] = [ - $real_date, - ($sum_data / $count_data), - ]; - if ($type_mode_graph && !$params['baseline']) { - if ($min_value != PHP_INT_MAX) { - $data['min'.$series_suffix]['data'][] = [ - $real_date, - $min_value, - ]; + // MAX. + // Max max. + if ($max_value >= $max_value_max + && $max_value != (-PHP_INT_MAX) + ) { + $max_value_max = $max_value; + } + + // Min max. + if ($max_value <= $max_value_min + && $max_value != (-PHP_INT_MAX) + ) { + $max_value_min = $max_value; + } + + // Avg Sum max. + if ($max_value != (-PHP_INT_MAX)) { + $sum_data_max += $max_value; + } + + // AVG. + // Max max. + if (($sum_data / $count_data) >= $avg_value_max) { + $avg_value_max = ($sum_data / $count_data); + } + + // Min max. + if (($sum_data / $count_data) <= $avg_value_min) { + $avg_value_min = ($sum_data / $count_data); + } + + // Avg sum max. + $sum_data_avg += ($sum_data / $count_data); } - - if ($max_value != -PHP_INT_MAX) { - $data['max'.$series_suffix]['data'][] = [ - $real_date, - $max_value, - ]; - } - } else { - if ($min_value != PHP_INT_MAX) { - $data['sum'.$series_suffix]['slice_data'][$real_date]['min'] = $min_value; - } - - $data['sum'.$series_suffix]['slice_data'][$real_date]['avg'] = ($sum_data / $count_data); - - if ($max_value != -PHP_INT_MAX) { - $data['sum'.$series_suffix]['slice_data'][$real_date]['max'] = $max_value; - } - } - - // max_total - if ($max_value >= $max_value_total && $max_value != -PHP_INT_MAX) { - $max_value_total = $max_value; - } - - // min_total - if ($min_value <= $min_value_total && $min_value != PHP_INT_MAX) { - $min_value_total = $min_value; - } - - // avg sum_total - $sum_data_total += ($sum_data / $count_data); - - // avg count_total - $count_data_total++; - - if ($type_mode_graph && !$params['baseline']) { - /* - MIN*/ - // max_min - if ($min_value >= $min_value_max && $min_value != PHP_INT_MAX) { - $min_value_max = $min_value; - } - - // min_min - if ($min_value <= $min_value_min && $min_value != PHP_INT_MAX) { - $min_value_min = $min_value; - } - - // avg sum_min - if ($min_value != PHP_INT_MAX) { - $sum_data_min += $min_value; - } - - /* - MAX*/ - // max_max - if ($max_value >= $max_value_max && $max_value != -PHP_INT_MAX) { - $max_value_max = $max_value; - } - - // min_max - if ($max_value <= $max_value_min && $max_value != -PHP_INT_MAX) { - $max_value_min = $max_value; - } - - // avg sum_max - if ($max_value != -PHP_INT_MAX) { - $sum_data_max += $max_value; - } - - /* - AVG*/ - // max_max - if (($sum_data / $count_data) >= $avg_value_max) { - $avg_value_max = ($sum_data / $count_data); - } - - // min_max - if (($sum_data / $count_data) <= $avg_value_min) { - $avg_value_min = ($sum_data / $count_data); - } - - // avg sum_max - $sum_data_avg += ($sum_data / $count_data); } } } $data['sum'.$series_suffix]['min'] = $min_value_total; $data['sum'.$series_suffix]['max'] = $max_value_total; - $data['sum'.$series_suffix]['avg'] = ($sum_data_total / $count_data_total); + $data['sum'.$series_suffix]['avg'] = 0; + if (isset($count_data_total) === true) { + $data['sum'.$series_suffix]['avg'] = ($sum_data_total / $count_data_total); + } if ($type_mode_graph && !$params['baseline']) { $data['min'.$series_suffix]['min'] = $min_value_min; @@ -3966,19 +4239,19 @@ function fullscale_data( foreach ($data_uncompress as $k) { foreach ($k['data'] as $v) { if (isset($v['type']) && $v['type'] == 1) { - // skip unnecesary virtual data + // Skip unnecesary virtual data. continue; } if ($compare) { - // * 1000 need js utimestam mlsecond + // Data * 1000 need js utimestam mlsecond. $real_date = (($v['utimestamp'] + $date_array['period']) * 1000); } else { $real_date = ($v['utimestamp'] * 1000); } if ($v['datos'] === null) { - // Unknown + // Unknown. if ($show_unknown) { if (!$compare) { if ($flag_unknown) { @@ -4005,7 +4278,7 @@ function fullscale_data( $previous_data, ]; } else { - // normal + // Normal. $previous_data = $v['datos']; $data['sum'.$series_suffix]['data'][] = [ $real_date, @@ -4025,21 +4298,21 @@ function fullscale_data( } if (isset($v['datos']) && $v['datos']) { - // max + // Max. if ((float) $v['datos'] >= $max_value_max) { $max_value_max = $v['datos']; } - // min + // Min. if ((float) $v['datos'] <= $min_value_min) { $min_value_min = $v['datos']; } - // avg sum + // Avg sum. $sum_data += $v['datos']; } - // avg count + // Avg count. $count_data++; if ($show_percentil && !$compare) { @@ -4052,7 +4325,7 @@ function fullscale_data( $data['sum'.$series_suffix]['min'] = $min_value_min; $data['sum'.$series_suffix]['max'] = $max_value_max; - $data['sum'.$series_suffix]['avg'] = $count_data == 0 ? 0 : ($sum_data / $count_data); + $data['sum'.$series_suffix]['avg'] = ($count_data == 0) ? 0 : ($sum_data / $count_data); } if ($show_percentil && !$compare) { @@ -4078,7 +4351,7 @@ function fullscale_data( } } - // Add missed last data + // Add missed last data. if ($compare) { $data['sum'.$series_suffix]['data'][] = [ (($date_array['final_date'] + $date_array['period']) * 1000), @@ -4101,7 +4374,11 @@ function fullscale_data( ]; } else { $data['sum'.$series_suffix]['slice_data'][($date_array['final_date'] * 1000)]['min'] = $min_value; - $data['sum'.$series_suffix]['slice_data'][($date_array['final_date'] * 1000)]['avg'] = ($sum_data / $count_data); + $data['sum'.$series_suffix]['slice_data'][($date_array['final_date'] * 1000)]['avg'] = 0; + if (isset($count_data) === true) { + $data['sum'.$series_suffix]['slice_data'][($date_array['final_date'] * 1000)]['avg'] = ($sum_data / $count_data); + } + $data['sum'.$series_suffix]['slice_data'][($date_array['final_date'] * 1000)]['max'] = $max_value; } } @@ -4124,7 +4401,7 @@ function graph_netflow_aggregate_area($data, $period, $width, $height, $ttl=1, $ return; } - // Calculate source indexes + // Calculate source indexes. foreach ($data['sources'] as $key => $value) { $i = 0; foreach ($data['data'] as $k => $v) { @@ -4143,7 +4420,12 @@ function graph_netflow_aggregate_area($data, $period, $width, $height, $ttl=1, $ if ($config['fixed_graph'] == false) { $water_mark = [ 'file' => $config['homedir'].'/images/logo_vertical_water.png', - 'url' => ui_get_full_url('images/logo_vertical_water.png', false, false, false), + 'url' => ui_get_full_url( + 'images/logo_vertical_water.png', + false, + false, + false + ), ]; $water_mark = $config['homedir'].'/images/logo_vertical_water.png'; @@ -4949,8 +5231,22 @@ function graph_monitor_wheel($width=550, $height=600, $filter=false) } -function get_baseline_data($agent_module_id, $date_array, $data_module_graph, $params) -{ +/** + * Function that on a date requests 3 times that period and takes an average. + * + * @param integer $agent_module_id ID module. + * @param array $date_array Date array start finish period. + * @param array $data_module_graph Data module. + * @param array $params Params. + * + * @return array Data baseline graph. + */ +function get_baseline_data( + $agent_module_id, + $date_array, + $data_module_graph, + $params +) { $period = $date_array['period']; $date = $date_array['final_date']; $array_data = []; @@ -4989,8 +5285,18 @@ function get_baseline_data($agent_module_id, $date_array, $data_module_graph, $p } $result['avg'] = (($array_data[0]['sum0']['avg'] + $array_data[1]['sum1']['avg'] + $array_data[2]['sum2']['avg'] + $array_data[3]['sum3']['avg']) / 4); - $result['max'] = max($array_data[0]['sum0']['max'], $array_data[1]['sum1']['max'], $array_data[2]['sum2']['max'], $array_data[3]['sum3']['max']); - $result['min'] = min($array_data[0]['sum0']['min'], $array_data[1]['sum1']['min'], $array_data[2]['sum2']['min'], $array_data[3]['sum3']['min']); + $result['max'] = max( + $array_data[0]['sum0']['max'], + $array_data[1]['sum1']['max'], + $array_data[2]['sum2']['max'], + $array_data[3]['sum3']['max'] + ); + $result['min'] = min( + $array_data[0]['sum0']['min'], + $array_data[1]['sum1']['min'], + $array_data[2]['sum2']['min'], + $array_data[3]['sum3']['min'] + ); $result['agent_module_id'] = $array_data[0]['sum0']['agent_module_id']; $result['id_module_type'] = $array_data[0]['sum0']['id_module_type']; diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 6ce6a5d57c..bcb6108fec 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -660,7 +660,7 @@ function html_print_select( } if ($optlabel === '') { - $output .= '>'.$value.''; + $output .= '>None'; } else { $output .= '>'.$optlabel.''; } @@ -1079,7 +1079,7 @@ function html_print_extended_select_for_time( 'class' => $uniq_name.'_toggler '.$class, 'alt' => __('Custom'), 'title' => __('Custom'), - 'style' => 'width: 18px;'.$style_icon, + 'style' => 'width: 18px; margin-bottom: -5px;'.$style_icon, ], false, false, @@ -1114,7 +1114,7 @@ function html_print_extended_select_for_time( 'class' => $uniq_name.'_toggler', 'alt' => __('List'), 'title' => __('List'), - 'style' => 'width: 18px;'.$style_icon, + 'style' => 'width: 18px;margin-bottom: -5px;'.$style_icon, ] ).''; echo '
'; @@ -1233,7 +1233,7 @@ function html_print_extended_select_for_cron($hour='*', $minute='*', $mday='*', * * @return string HTML code if return parameter is true. */ -function html_print_input_text_extended($name, $value, $id, $alt, $size, $maxlength, $disabled, $script, $attributes, $return=false, $password=false, $function='') +function html_print_input_text_extended($name, $value, $id, $alt, $size, $maxlength, $disabled, $script, $attributes, $return=false, $password=false, $function='', $autocomplete='off') { static $idcounter = 0; @@ -1241,7 +1241,9 @@ function html_print_input_text_extended($name, $value, $id, $alt, $size, $maxlen $maxlength = 255; } - if ($size == 0) { + if ($size === false) { + $size = ''; + } else if ($size == 0) { $size = 10; } @@ -1283,7 +1285,7 @@ function html_print_input_text_extended($name, $value, $id, $alt, $size, $maxlen 'autocomplete', ]; - $output = ''.html_print_image('images/sort_up.png', true).''.''.html_print_image('images/sort_down.png', true).''; + $out = ' '; + $out .= html_print_image('images/sort_up_black.png', true); + $out .= ''; + $out .= html_print_image('images/sort_down_black.png', true).''; } @@ -2989,6 +3002,7 @@ function html_print_switch($attributes=[]) 'class', 'name', 'onclick', + 'onchange', ]; foreach ($valid_attrs as $va) { if (!isset($attributes[$va])) { @@ -2998,7 +3012,11 @@ function html_print_switch($attributes=[]) $html_expand .= ' '.$va.'="'.$attributes[$va].'"'; } - return "
'.$text_title.' '; if (!$no_close_bool) { - // Use the no_meta parameter because this image is only in the base console + // Use the no_meta parameter because this image is only in + // the base console. $output .= ''.html_print_image('images/blade.png', true, false, false, false, true).''; } @@ -330,11 +352,12 @@ function ui_print_message($message, $class='', $attributes='', $return=false, $t /** * Prints an error message. * - * @param mixed The string error message or array ('title', 'message', 'icon', 'no_close') to be displayed - * @param string Any other attributes to be set for the tag. - * @param bool Whether to output the string or return it - * @param string What tag to use (you could specify something else than - * h3 like div or h2) + * @param mixed $message The string error message or array + * ('title', 'message', 'icon', 'no_close') to be displayed. + * @param string $attributes Any other attributes to be set for the tag. + * @param boolean $return Whether to output the string or return it. + * @param string $tag What tag to use (you could specify something else + * than h3 like div or h2). * * @return string HTML code if return parameter is true. */ @@ -347,11 +370,12 @@ function ui_print_error_message($message, $attributes='', $return=false, $tag='h /** * Prints an operation success message. * - * @param mixed The string message or array ('title', 'message', 'icon', 'no_close') to be displayed - * @param string Any other attributes to be set for the tag. - * @param bool Whether to output the string or return it - * @param string What tag to use (you could specify something else than - * h3 like div or h2) + * @param mixed $message The string message or array + * ('title', 'message', 'icon', 'no_close') to be displayed. + * @param string $attributes Any other attributes to be set for the tag. + * @param boolean $return Whether to output the string or return it. + * @param string $tag What tag to use (you could specify something else + * than h3 like div or h2). * * @return string HTML code if return parameter is true. */ @@ -364,11 +388,12 @@ function ui_print_success_message($message, $attributes='', $return=false, $tag= /** * Prints an operation info message. * - * @param mixed The string message or array ('title', 'message', 'icon', 'no_close') to be displayed - * @param string Any other attributes to be set for the tag. - * @param bool Whether to output the string or return it - * @param string What tag to use (you could specify something else than - * h3 like div or h2) + * @param mixed $message The string message or array + * ('title', 'message', 'icon', 'no_close') to be displayed. + * @param string $attributes Any other attributes to be set for the tag. + * @param boolean $return Whether to output the string or return it. + * @param string $tag What tag to use (you could specify something else + * than h3 like div or h2). * * @return string HTML code if return parameter is true. */ @@ -378,6 +403,18 @@ function ui_print_info_message($message, $attributes='', $return=false, $tag='h3 } +/** + * Prints an operation info message - empty data. + * + * @param mixed $message The string message or array + * ('title', 'message', 'icon', 'no_close') to be displayed. + * @param string $attributes Any other attributes to be set for the tag. + * @param boolean $return Whether to output the string or return it. + * @param string $tag What tag to use (you could specify something else + * than h3 like div or h2). + * + * @return string HTML code if return parameter is true. + */ function ui_print_empty_data($message, $attributes='', $return=false, $tag='h3') { return ui_print_message($message, 'info', $attributes, $return, $tag); @@ -387,14 +424,16 @@ function ui_print_empty_data($message, $attributes='', $return=false, $tag='h3') /** * Evaluates a result using empty() and then prints an error or success message * - * @param mixed The results to evaluate. 0, NULL, false, '' or - * array() is bad, the rest is good - * @param mixed The string or array ('title', 'message') to be displayed if the result was good - * @param mixed The string or array ('title', 'message') to be displayed if the result was bad - * @param string Any other attributes to be set for the h3 - * @param bool Whether to output the string or return it - * @param string What tag to use (you could specify something else than - * h3 like div or h2) + * @param mixed $result The results to evaluate. 0, NULL, false, '' or + * array() is bad, the rest is good. + * @param mixed $good The string or array ('title', 'message') to be + * displayed if the result was good. + * @param mixed $bad The string or array ('title', 'message') to be + * displayed if the result was bad. + * @param string $attributes Any other attributes to be set for the h3. + * @param boolean $return Whether to output the string or return it. + * @param string $tag What tag to use (you could specify something else + * than h3 like div or h2). * * @return string HTML code if return parameter is true. */ @@ -419,11 +458,12 @@ function ui_print_result_message($result, $good='', $bad='', $attributes='', $re /** * Prints an warning message. * - * @param mixed The string warning message or array ('title', 'message', 'icon', 'no_close') to be displayed - * @param string Any other attributes to be set for the tag. - * @param bool Whether to output the string or return it - * @param string What tag to use (you could specify something else than - * h3 like div or h2) + * @param mixed $message The string message or array + * ('title', 'message', 'icon', 'no_close') to be displayed. + * @param string $attributes Any other attributes to be set for the tag. + * @param boolean $return Whether to output the string or return it. + * @param string $tag What tag to use (you could specify something else + * than h3 like div or h2). * * @return string HTML code if return parameter is true. */ @@ -438,13 +478,13 @@ function ui_print_warning_message($message, $attributes='', $return=false, $tag= * with as title the correctly formatted full timestamp and a time comparation * in the tag * - * @param int Any type of timestamp really, but we prefer unixtime - * @param bool Whether to output the string or return it - * @param array An array with different options for this function - * Key html_attr: which html attributes to add (defaults to none) - * Key tag: Which html tag to use (defaults to span) - * Key prominent: Overrides user preference and display "comparation" or "timestamp" - * key units: The type of units. + * @param integer $unixtime Any type of timestamp really, but we prefer unixtime. + * @param boolean $return Whether to output the string or return it. + * @param array $option An array with different options for this function + * Key html_attr: which html attributes to add (defaults to none) + * Key tag: Which html tag to use (defaults to span) + * Key prominent: Overrides user preference and display "comparation" or "timestamp" + * key units: The type of units. * * @return string HTML code if return parameter is true. */ @@ -452,7 +492,8 @@ function ui_print_timestamp($unixtime, $return=false, $option=[]) { global $config; - // TODO: Add/use a javascript timer for the seconds so it automatically updates as time passes by + // TODO: Add/use a javascript timer for the seconds so it automatically + // updates as time passes by. if (isset($option['html_attr'])) { $attributes = $option['html_attr']; } else { @@ -481,7 +522,7 @@ function ui_print_timestamp($unixtime, $return=false, $option=[]) $unixtime = time_w_fixed_tz($unixtime); } - // prominent_time is either timestamp or comparation + // Prominent_time is either timestamp or comparation. if ($unixtime <= 0) { $title = __('Unknown').'/'.__('Never'); $data = __('Unknown'); @@ -507,13 +548,13 @@ function ui_print_timestamp($unixtime, $return=false, $option=[]) switch ($tag) { default: // Usually tags have title attributes, so by default we add, - // then fall through to add attributes and data + // then fall through to add attributes and data. $output .= ' title="'.$title.'" '.$style.'>'.$data.''; break; case 'h1': case 'h2': case 'h3': - // Above tags don't have title attributes + // Above tags don't have title attributes. $output .= ' '.$attributes.' '.$style.'>'.$data.''; break; } @@ -529,8 +570,8 @@ function ui_print_timestamp($unixtime, $return=false, $option=[]) /** * Prints a username with real name, link to the user_edit page etc. * - * @param string The username to render - * @param bool Whether to return or print + * @param string $username The username to render. + * @param boolean $return Whether to return or print. * * @return string HTML code if return parameter is true. */ @@ -546,6 +587,13 @@ function ui_print_username($username, $return=false) } +/** + * Show a notification. + * + * @param boolean $return Return or direct echo. + * + * @return string HTML. + */ function ui_print_tags_warning($return=false) { $msg = '
'; @@ -563,11 +611,14 @@ function ui_print_tags_warning($return=false) /** * Print group icon within a link * - * @param int Group id - * @param bool Whether to return or print - * @param string What path to use (relative to images/). Defaults to groups_small - * @param string Style for group image - * @param bool Whether the group have link or not + * @param integer $id_group Group id. + * @param boolean $return Whether to return or print. + * @param string $path What path to use (relative to images/). + * Defaults to groups_small. + * @param string $style Style for group image. + * @param boolean $link Whether the group have link or not. + * @param boolean $force_show_image Force show image. + * @param boolean $show_as_image Show as image. * * @return string HTML code if return parameter is true. */ @@ -583,7 +634,7 @@ function ui_print_group_icon($id_group, $return=false, $path='groups_small', $st $output = ''; - // Don't show link in metaconsole + // Don't show link in metaconsole. if (defined('METACONSOLE')) { $link = false; } @@ -630,9 +681,12 @@ function ui_print_group_icon($id_group, $return=false, $path='groups_small', $st /** * Print group icon within a link. Other version. * - * @param int Group id - * @param bool Whether to return or print - * @param string What path to use (relative to images/). Defaults to groups_small + * @param integer $id_group Group id. + * @param boolean $return Whether to return or print. + * @param string $path What path to use (relative to images/). + * Defaults to groups_small. + * @param string $style Extra styles. + * @param boolean $link Add anchor. * * @return string HTML code if return parameter is true. */ @@ -674,10 +728,15 @@ function ui_print_group_icon_path($id_group, $return=false, $path='images/groups /** * Get the icon of an operating system. * - * @param int Operating system id - * @param bool Whether to also append the name of the OS after the icon - * @param bool Whether to return or echo the result - * @param bool Whether to apply skin or not + * @param integer $id_os Operating system id. + * @param boolean $name Whether to also append the name of OS after icon. + * @param boolean $return Whether to return or echo the result. + * @param boolean $apply_skin Whether to apply skin or not. + * @param boolean $networkmap Networkmap. + * @param boolean $only_src Only_src. + * @param boolean $relative Relative. + * @param boolean $options Options. + * @param boolean $big_icons Big_icons. * * @return string HTML with icon of the OS */ @@ -744,6 +803,18 @@ function ui_print_os_icon( } +/** + * Print type agent icon. + * + * @param boolean $id_os Id_os. + * @param boolean $remote_contact Remote_contact. + * @param boolean $contact Contact. + * @param boolean $return Return. + * @param integer $remote Remote. + * @param string $version Version. + * + * @return string HTML. + */ function ui_print_type_agent_icon( $id_os=false, $remote_contact=false, @@ -753,15 +824,15 @@ function ui_print_type_agent_icon( $version='' ) { if ($id_os == 19) { - // Satellite + // Satellite. $options['title'] = __('Satellite'); $output = html_print_image('images/op_satellite.png', true, $options, false, false, false, true); } else if ($remote_contact == $contact && $remote == 0 && $version == '') { - // Network + // Network. $options['title'] = __('Network'); $output = html_print_image('images/network.png', true, $options, false, false, false, true); } else { - // Software + // Software. $options['title'] = __('Software'); $output = html_print_image('images/data.png', true, $options, false, false, false, true); } @@ -773,20 +844,31 @@ function ui_print_type_agent_icon( /** * Prints an agent name with the correct link * - * @param int Agent id - * @param bool Whether to return the string or echo it too - * @param int Now uses styles to accomplish this - * @param string Style of name in css. - * @param string server url to concatenate at the begin of the link - * @param string extra parameters to concatenate in the link - * @param string name of the agent to avoid the query in some cases - * @param bool if the agent will provided with link or not - * @param bool use the agent alias or the name + * @param integer $id_agent Agent id. + * @param boolean $return Whether to return the string or echo it too. + * @param integer $cutoff Now uses styles to accomplish this. + * @param string $style Style of name in css. + * @param boolean $cutname Cut names. + * @param string $server_url Server url to concatenate at the begin of the link. + * @param string $extra_params Extra parameters to concatenate in the link. + * @param string $known_agent_name Name of the agent to avoid the query in some cases. + * @param boolean $link If the agent will provided with link or not. + * @param boolean $alias Use the agent alias or the name. * * @return string HTML with agent name and link */ -function ui_print_agent_name($id_agent, $return=false, $cutoff='agent_medium', $style='', $cutname=false, $server_url='', $extra_params='', $known_agent_name=false, $link=true, $alias=true) -{ +function ui_print_agent_name( + $id_agent, + $return=false, + $cutoff='agent_medium', + $style='', + $cutname=false, + $server_url='', + $extra_params='', + $known_agent_name=false, + $link=true, + $alias=true +) { if ($known_agent_name === false) { if ($alias) { $agent_name = (string) agents_get_alias($id_agent); @@ -808,14 +890,14 @@ function ui_print_agent_name($id_agent, $return=false, $cutoff='agent_medium', $ } if ($link) { - $url = $server_url.'index.php?sec=estado&'.'sec2=operation/agentes/ver_agente&'.'id_agente='.$id_agent.$extra_params; + $url = $server_url.'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agent.$extra_params; - $output = ''.$agent_name.''; + $output = ''.$agent_name.''; } else { $output = ''.$agent_name.''; } - // TODO: Add a pretty javascript (using jQuery) popup-box with agent details + // TODO: Add a pretty javascript (using jQuery) popup-box with agent details. if ($return) { return $output; } @@ -827,16 +909,19 @@ function ui_print_agent_name($id_agent, $return=false, $cutoff='agent_medium', $ /** * Formats a row from the alert table and returns an array usable in the table function * - * @param array A valid (non empty) row from the alert table - * @param bool Whether or not this is a combined alert - * @param bool Whether to print the agent information with the module information - * @param string Tab where the function was called from (used for urls) - * @param mixed Style for agent name or default (false) + * @param array $alert A valid (non empty) row from the alert table. + * @param boolean $agent Whether or not this is a combined alert. + * @param string $url Tab where the function was called from (used for urls). + * @param mixed $agent_style Style for agent name or default (false). * * @return array A formatted array with proper html for use in $table->data (6 columns) */ -function ui_format_alert_row($alert, $agent=true, $url='', $agent_style=false) -{ +function ui_format_alert_row( + $alert, + $agent=true, + $url='', + $agent_style=false +) { global $config; if (!isset($alert['server_data'])) { @@ -856,7 +941,7 @@ function ui_format_alert_row($alert, $agent=true, $url='', $agent_style=false) include_once $config['homedir'].'/include/functions_alerts.php'; $isFunctionPolicies = enterprise_include_once('include/functions_policies.php'); $id_group = (int) get_parameter('ag_group', 0); - // 0 is the All group (selects all groups) + // 0 is the All group (selects all groups). if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { if ($agent) { $index = [ @@ -956,13 +1041,13 @@ function ui_format_alert_row($alert, $agent=true, $url='', $agent_style=false) $server = db_get_row('tmetaconsole_setup', 'id', $alert['server_data']['id']); if (metaconsole_connect($server) == NOERR) { - // Get agent data from node + // Get agent data from node. $agente = db_get_row('tagente', 'id_agente', $alert['id_agent']); metaconsole_restore_db(); } } else { - // Get agent id + // Get agent id. $id_agent = modules_get_agentmodule_agent($alert['id_agent_module']); $agente = db_get_row('tagente', 'id_agente', $id_agent); } @@ -972,9 +1057,11 @@ function ui_format_alert_row($alert, $agent=true, $url='', $agent_style=false) $data = []; - // Validate checkbox + // Validate checkbox. if (!defined('METACONSOLE')) { - if (check_acl($config['id_user'], $id_group, 'LW') || check_acl($config['id_user'], $id_group, 'LM')) { + if (check_acl($config['id_user'], $id_group, 'LW') + || check_acl($config['id_user'], $id_group, 'LM') + ) { $data[$index['validate']] = ''; $data[$index['validate']] .= html_print_checkbox( @@ -996,7 +1083,6 @@ function ui_format_alert_row($alert, $agent=true, $url='', $agent_style=false) // Restore the default connection. metaconsole_restore_db(); $errors++; - // break; It does not work in the php7 version remplace for: return false; } } @@ -1018,14 +1104,14 @@ function ui_format_alert_row($alert, $agent=true, $url='', $agent_style=false) } } - // Standby + // Standby. $data[$index['standby']] = ''; if (isset($alert['standby']) && $alert['standby'] == 1) { $data[$index['standby']] = html_print_image('images/bell_pause.png', true, ['title' => __('Standby on')]); } if (!defined('METACONSOLE')) { - // Force alert execution + // Force alert execution. if (check_acl($config['id_user'], $id_group, 'AW') || check_acl($config['id_user'], $id_group, 'LM')) { if ($alert['force_execution'] == 0) { $data[$index['force_execution']] = ''.html_print_image('images/target.png', true, ['border' => '0', 'title' => __('Force')]).''; @@ -1095,7 +1181,12 @@ function ui_format_alert_row($alert, $agent=true, $url='', $agent_style=false) $actionText .= '
'; } else { if ($actionDefault != '') { - $actionText = db_get_sql("SELECT name FROM talert_actions WHERE id = $actionDefault").' ('.__('Default').')'; + $actionText = db_get_sql( + sprintf( + 'SELECT name FROM talert_actions WHERE id = %d', + $actionDefault + ) + ).' ('.__('Default').')'; } } @@ -1126,12 +1217,12 @@ function ui_format_alert_row($alert, $agent=true, $url='', $agent_style=false) /** * Prints a substracted string, length specified by cutoff, the full string will be in a rollover. * - * @param string The string to be cut - * @param int At how much characters to cut - * @param bool Whether to return or print it out - * @param int Size font (fixed) in px, applyed as CSS style (optional) + * @param string $string The string to be cut.. + * @param integer $cutoff At how much characters to cut. + * @param boolean $return Whether to return or print it out. + * @param integer $fontsize Size font (fixed) in px, applyed as CSS style (optional). * - * @return An HTML string + * @return string HTML string. */ function ui_print_string_substr($string, $cutoff=16, $return=false, $fontsize=0) { @@ -1152,7 +1243,8 @@ function ui_print_string_substr($string, $cutoff=16, $return=false, $fontsize=0) $font_size_mod = "style='font-size: ".$fontsize."pt'"; } - $string = ''.mb_substr($string2, 0, $cutoff, 'UTF-8').$string3.''; + $string = ''; + $string .= mb_substr($string2, 0, $cutoff, 'UTF-8').$string3.''; if ($return === false) { echo $string; @@ -1166,9 +1258,9 @@ function ui_print_string_substr($string, $cutoff=16, $return=false, $fontsize=0) * Gets a helper text explaining the requirement needs for an alert template * to get it fired. * - * @param int Alert template id. - * @param bool Wheter to return or print it out. - * @param bool Wheter to put the values in the string or not. + * @param integer $id_alert_template Alert template id. + * @param boolean $return Wheter to return or print it out. + * @param boolean $print_values Wheter to put the values in the string or not. * * @return An HTML string if return was true. */ @@ -1182,21 +1274,21 @@ function ui_print_alert_template_example($id_alert_template, $return=false, $pri switch ($template['type']) { case 'equal': - // Do not translate the HTML attributes + // Do not translate the HTML attributes. $output .= __('The alert would fire when the value is '); break; case 'not_equal': - // Do not translate the HTML attributes + // Do not translate the HTML attributes. $output .= __('The alert would fire when the value is not '); break; case 'regex': if ($template['matches_value']) { - // Do not translate the HTML attributes + // Do not translate the HTML attributes. $output .= __('The alert would fire when the value matches '); } else { - // end if + // End if. $output .= __('The alert would fire when the value doesn\'t match '); } @@ -1205,42 +1297,46 @@ function ui_print_alert_template_example($id_alert_template, $return=false, $pri case 'max_min': if ($template['matches_value']) { - // Do not translate the HTML attributes + // Do not translate the HTML attributes. $output .= __('The alert would fire when the value is between and '); } else { - // end if + // End if. $output .= __('The alert would fire when the value is not between and '); } break; case 'max': - // Do not translate the HTML attributes + // Do not translate the HTML attributes. $output .= __('The alert would fire when the value is over '); - break; case 'min': - // Do not translate the HTML attributes + // Do not translate the HTML attributes. $output .= __('The alert would fire when the value is under '); - break; case 'warning': - // Do not translate the HTML attributes + // Do not translate the HTML attributes. $output .= __('The alert would fire when the module is in warning status'); - break; case 'critical': - // Do not translate the HTML attributes + // Do not translate the HTML attributes. $output .= __('The alert would fire when the module is in critical status'); break; + + default: + // Do nothing. + $output .= __('Unknown option.'); + break; } if ($print_values) { /* - Replace span elements with real values. This is done in such way to avoid - duplicating strings and make it easily modificable via Javascript. */ + * Replace span elements with real values. This is done in such way to avoid + * duplicating strings and make it easily modificable via Javascript. + */ + $output = str_replace('', $template['value'], $output); $output = str_replace('', $template['max_value'], $output); $output = str_replace('', $template['min_value'], $output); @@ -1258,16 +1354,23 @@ function ui_print_alert_template_example($id_alert_template, $return=false, $pri /** * Prints a help tip icon. * - * @param string Id of the help article - * @param bool Whether to return or output the result - * @param string Home url if its necessary - * @param string Image path - * @param bool Route is relative or not + * @param string $help_id Id of the help article. + * @param boolean $return Whether to return or output the result. + * @param string $home_url Home url if its necessary. + * @param string $image Image path. + * @param boolean $is_relative Route is relative or not. + * @param string $id Target id. * * @return string The help tip */ -function ui_print_help_icon($help_id, $return=false, $home_url='', $image='images/help_green.png', $is_relative=false, $id='') -{ +function ui_print_help_icon( + $help_id, + $return=false, + $home_url='', + $image='images/help_green.png', + $is_relative=false, + $id='' +) { global $config; // Do not display the help icon if help is disabled. @@ -1312,12 +1415,13 @@ function ui_print_help_icon($help_id, $return=false, $home_url='', $image='image * file name should be like "name.css". The "name" would be the value * needed to pass to this function. * - * @param string Script name to add without the "jquery." prefix and the ".js" + * @param string $name Script name to add without the "jquery." prefix and the ".js" * suffix. Example: * * ui_require_css_file ('pandora'); * // Would include include/styles/pandora.js - * + * . + * @param string $path Path where script is placed. * * @return boolean True if the file was added. False if the file doesn't exist. */ @@ -1337,11 +1441,16 @@ function ui_require_css_file($name, $path='include/styles/') if (! file_exists($filename) && ! file_exists($config['homedir'].'/'.$filename) + && ! file_exists($config['homedir'].'/'.ENTERPRISE_DIR.'/'.$filename) ) { return false; } - $config['css'][$name] = $filename; + if (is_metaconsole()) { + $config['css'][$name] = '/../../'.$filename; + } else { + $config['css'][$name] = $filename; + } return true; } @@ -1354,13 +1463,14 @@ function ui_require_css_file($name, $path='include/styles/') * file name should be like "name.js". The "name" would be the value * needed to pass to this function. * - * @param string Script name to add without the "jquery." prefix and the ".js" - * suffix. Example: - * - * ui_require_javascript_file ('pandora'); - * // Would include include/javascript/pandora.js - * - * @param bool Just echo the script tag of the file. + * @param string $name Script name to add without the "jquery." prefix and the ".js" + * suffix. Example: + * + * ui_require_javascript_file ('pandora'); + * // Would include include/javascript/pandora.js + * . + * @param string $path Path where script is placed. + * @param boolean $echo_tag Just echo the script tag of the file. * * @return boolean True if the file was added. False if the file doesn't exist. */ @@ -1372,7 +1482,7 @@ function ui_require_javascript_file($name, $path='include/javascript/', $echo_ta if ($echo_tag) { echo ''; - return; + return null; } if (! isset($config['js'])) { @@ -1383,7 +1493,7 @@ function ui_require_javascript_file($name, $path='include/javascript/', $echo_ta return true; } - // We checks two paths because it may fails on enterprise + // We checks two paths because it may fails on enterprise. if (! file_exists($filename) && ! file_exists($config['homedir'].'/'.$filename)) { return false; } @@ -1405,12 +1515,14 @@ function ui_require_javascript_file($name, $path='include/javascript/', $echo_ta * file name should be like "name.js". The "name" would be the value * needed to pass to this function. * - * @param string Script name to add without the "jquery." prefix and the ".js" - * suffix. Example: - * - * ui_require_javascript_file ('pandora'); - * // Would include include/javascript/pandora.js - * + * @param string $name Script name to add without the "jquery." + * prefix and the ".js" + * suffix. Example: + * + * ui_require_javascript_file ('pandora'); + * // Would include include/javascript/pandora.js + * . + * @param boolean $disabled_metaconsole Disabled metaconsole. * * @return boolean True if the file was added. False if the file doesn't exist. */ @@ -1433,7 +1545,7 @@ function ui_require_javascript_file_enterprise($name, $disabled_metaconsole=fals return true; } - // We checks two paths because it may fails on enterprise + // We checks two paths because it may fails on enterprise. if (!file_exists($filename) && !file_exists($config['homedir'].'/'.$filename) ) { @@ -1454,13 +1566,14 @@ function ui_require_javascript_file_enterprise($name, $disabled_metaconsole=fals * needed to pass to this function. Notice that this function does not manage * jQuery denpendencies. * - * @param string Script name to add without the "jquery." prefix and the ".js" - * suffix. Example: - * - * ui_require_jquery_file ('form'); - * // Would include include/javascript/jquery.form.js - * - * @param bool Just echo the script tag of the file. + * @param string $name Script name to add without the "jquery." prefix and the ".js" + * suffix. Example: + * + * ui_require_jquery_file ('form'); + * // Would include include/javascript/jquery.form.js + * . + * @param string $path Path where script is placed. + * @param boolean $echo_tag Just echo the script tag of the file. * * @return boolean True if the file was added. False if the file doesn't exist. */ @@ -1472,7 +1585,7 @@ function ui_require_jquery_file($name, $path='include/javascript/', $echo_tag=fa if ($echo_tag) { echo ''; - return; + return null; } if (! isset($config['jquery'])) { @@ -1483,8 +1596,10 @@ function ui_require_jquery_file($name, $path='include/javascript/', $echo_tag=fa return true; } - // We checks two paths because it may fails on enterprise - if (! file_exists($filename) && ! file_exists($config['homedir'].'/'.$filename)) { + // We checks two paths because it may fails on enterprise. + if (! file_exists($filename) + && ! file_exists($config['homedir'].'/'.$filename) + ) { return false; } @@ -1503,8 +1618,8 @@ function ui_require_jquery_file($name, $path='include/javascript/', $echo_tag=fa * To add css just put them in include/styles and then add them to the * $config['css'] array * - * @param string Callback will fill this with the current buffer. - * @param bitfield Callback will fill this with a bitfield (see ob_start) + * @param string $string Callback will fill this with the current buffer. + * @param mixed $bitfield Callback will fill this with a bitfield (see ob_start). * * @return string String to return to the browser */ @@ -1514,7 +1629,7 @@ function ui_process_page_head($string, $bitfield) global $vc_public_view; if (isset($config['ignore_callback']) && $config['ignore_callback'] == true) { - return; + return ''; } $output = ''; @@ -1524,7 +1639,7 @@ function ui_process_page_head($string, $bitfield) $config_refr = $config['refr']; } - // If user is logged or displayed view is the public view of visual console + // If user is logged or displayed view is the public view of visual console. if ($config_refr > 0 && (isset($config['id_user']) || $vc_public_view == 1) ) { @@ -1537,8 +1652,13 @@ function ui_process_page_head($string, $bitfield) || $_GET['sec2'] == 'enterprise/dashboard/main_dashboard' ) { $query = ui_get_url_refresh(false, false); - // $output .= ''; + + /* + * $output .= ''; + */ + + // End. } } @@ -1558,7 +1678,8 @@ function ui_process_page_head($string, $bitfield) '; if ($config['language'] != 'en') { - // Load translated strings - load them last so they overload all the objects + // Load translated strings - load them last so they overload all + // the objects. ui_require_javascript_file('time_'.$config['language']); ui_require_javascript_file('date'.$config['language']); ui_require_javascript_file('countdown_'.$config['language']); @@ -1566,27 +1687,32 @@ function ui_process_page_head($string, $bitfield) $output .= "\n\t"; - // - // Load CSS - // + /* + * Load CSS + */ + if (empty($config['css'])) { $config['css'] = []; } $login_ok = true; if (! isset($config['id_user']) && isset($_GET['login'])) { - if (isset($_POST['nick']) and isset($_POST['pass'])) { + if (isset($_POST['nick']) && isset($_POST['pass'])) { $nick = get_parameter_post('nick'); - // This is the variable with the login + // This is the variable with the login. $pass = get_parameter_post('pass'); - // This is the variable with the password + // This is the variable with the password. $nick = db_escape_string_sql($nick); $pass = db_escape_string_sql($pass); - // process_user_login is a virtual function which should be defined in each auth file. - // It accepts username and password. The rest should be internal to the auth file. - // The auth file can set $config["auth_error"] to an informative error output or reference their internal error messages to it - // process_user_login should return false in case of errors or invalid login, the nickname if correct + // Process_user_login is a virtual function which should be defined + // in each auth file. + // It accepts username and password. The rest should be internal to + // the auth file. + // The auth file can set $config["auth_error"] to an informative + // error output or reference their internal error messages to it + // process_user_login should return false in case of errors or + // invalid login, the nickname if correct. $nick_in_db = process_user_login($nick, $pass); if ($nick_in_db === false) { @@ -1596,7 +1722,7 @@ function ui_process_page_head($string, $bitfield) } // First, if user has assigned a skin then try to use css files of - // skin subdirectory + // skin subdirectory. $isFunctionSkins = enterprise_include_once('include/functions_skins.php'); if (!$login_ok) { if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) { @@ -1605,8 +1731,8 @@ function ui_process_page_head($string, $bitfield) } $exists_css = false; - if ($login_ok and $isFunctionSkins !== ENTERPRISE_NOT_HOOK) { - // Checks if user's skin is available + if ($login_ok && $isFunctionSkins !== ENTERPRISE_NOT_HOOK) { + // Checks if user's skin is available. $exists_skin = enterprise_hook('skins_is_path_set'); if ($exists_skin) { $skin_path = enterprise_hook('skins_get_skin_path'); @@ -1615,34 +1741,35 @@ function ui_process_page_head($string, $bitfield) } } - // Add the jquery UI styles CSS + // Add the jquery UI styles CSS. $config['css']['jquery-UI'] = 'include/styles/js/jquery-ui.min.css'; - // Add the dialog styles CSS + $config['css']['jquery-UI-custom'] = 'include/styles/js/jquery-ui_custom.css'; + // Add the dialog styles CSS. $config['css']['dialog'] = 'include/styles/dialog.css'; - // Add the dialog styles CSS + // Add the dialog styles CSS. $config['css']['dialog'] = 'include/styles/js/introjs.css'; - // If skin's css files exists then add them + // If skin's css files exists then add them. if ($exists_css) { foreach ($skin_styles as $filename => $name) { $style = substr($filename, 0, (strlen($filename) - 4)); $config['css'][$style] = $skin_path.'include/styles/'.$filename; } - } - // Otherwise assign default and user's css - else { - // User style should go last so it can rewrite common styles + } else { + // Otherwise assign default and user's css. + // User style should go last so it can rewrite common styles. $config['css'] = array_merge( [ 'common' => 'include/styles/common.css', 'menu' => 'include/styles/menu.css', + 'tables' => 'include/styles/tables.css', $config['style'] => 'include/styles/'.$config['style'].'.css', ], $config['css'] ); } - // We can't load empty and we loaded (conditionally) ie + // We can't load empty and we loaded (conditionally) ie. $loaded = [ '', 'ie', @@ -1659,57 +1786,20 @@ function ui_process_page_head($string, $bitfield) $output .= ''."\n\t"; } - // - // End load CSS - // - // - // Load JS - // - if (empty($config['js'])) { - $config['js'] = []; - // If it's empty, false or not init set array to empty just in case - } + /* + * End load CSS + */ - // Pandora specific JavaScript should go first - $config['js'] = array_merge(['pandora' => 'include/javascript/pandora.js'], $config['js']); - // Load base64 javascript library - $config['js']['base64'] = 'include/javascript/encode_decode_base64.js'; - // Load webchat javascript library - $config['js']['webchat'] = 'include/javascript/webchat.js'; - // Load qrcode library - $config['js']['qrcode'] = 'include/javascript/qrcode.js'; - // Load intro.js library (for bubbles and clippy) - $config['js']['intro'] = 'include/javascript/intro.js'; - $config['js']['clippy'] = 'include/javascript/clippy.js'; - // Load Underscore.js library - $config['js']['underscore'] = 'include/javascript/underscore-min.js'; + /* + * Load jQuery + */ - // Load other javascript - // We can't load empty - $loaded = ['']; - foreach ($config['js'] as $name => $filename) { - if (in_array($name, $loaded)) { - continue; - } - - array_push($loaded, $name); - - $url_js = ui_get_full_url($filename); - $output .= ''."\n\t"; - } - - // - // End load JS - // - // - // Load jQuery - // if (empty($config['jquery'])) { $config['jquery'] = []; - // If it's empty, false or not init set array to empty just in case + // If it's empty, false or not init set array to empty just in case. } - // Pandora specific jquery should go first + // Pandora specific jquery should go first. $black_list_pages_old_jquery = ['operation/gis_maps/index']; if (in_array(get_parameter('sec2'), $black_list_pages_old_jquery)) { $config['jquery'] = array_merge( @@ -1732,15 +1822,15 @@ function ui_process_page_head($string, $bitfield) ); } - // Include the datapicker language if exists + // Include the datapicker language if exists. if (file_exists('include/languages/datepicker/jquery.ui.datepicker-'.$config['language'].'.js')) { $config['jquery']['datepicker_language'] = 'include/languages/datepicker/jquery.ui.datepicker-'.$config['language'].'.js'; } - // Include countdown library + // Include countdown library. $config['jquery']['countdown'] = 'include/javascript/jquery.countdown.js'; - // Then add each script as necessary + // Then add each script as necessary. $loaded = ['']; foreach ($config['jquery'] as $name => $filename) { if (in_array($name, $loaded)) { @@ -1753,9 +1843,51 @@ function ui_process_page_head($string, $bitfield) $output .= ''."\n\t"; } - // - // End load JQuery - // + /* + * End load JQuery + */ + + /* + * Load JS + */ + + if (empty($config['js'])) { + $config['js'] = []; + // If it's empty, false or not init set array to empty just in case. + } + + // Pandora specific JavaScript should go first. + $config['js'] = array_merge(['pandora' => 'include/javascript/pandora.js'], $config['js']); + // Load base64 javascript library. + $config['js']['base64'] = 'include/javascript/encode_decode_base64.js'; + // Load webchat javascript library. + $config['js']['webchat'] = 'include/javascript/webchat.js'; + // Load qrcode library. + $config['js']['qrcode'] = 'include/javascript/qrcode.js'; + // Load intro.js library (for bubbles and clippy). + $config['js']['intro'] = 'include/javascript/intro.js'; + $config['js']['clippy'] = 'include/javascript/clippy.js'; + // Load Underscore.js library. + $config['js']['underscore'] = 'include/javascript/underscore-min.js'; + + // Load other javascript. + // We can't load empty. + $loaded = ['']; + foreach ($config['js'] as $name => $filename) { + if (in_array($name, $loaded)) { + continue; + } + + array_push($loaded, $name); + + $url_js = ui_get_full_url($filename); + $output .= ''."\n\t"; + } + + /* + * End load JS + */ + include_once __DIR__.'/graphs/functions_flot.php'; $output .= include_javascript_dependencies_flot_graph(true); @@ -1772,8 +1904,8 @@ function ui_process_page_head($string, $bitfield) /** * Callback function to add stuff to the body * - * @param string Callback will fill this with the current buffer. - * @param bitfield Callback will fill this with a bitfield (see ob_start) + * @param string $string Callback will fill this with the current buffer. + * @param mixed $bitfield Callback will fill this with a bitfield (see ob_start). * * @return string String to return to the browser */ @@ -1784,11 +1916,11 @@ function ui_process_page_body($string, $bitfield) if (isset($config['ignore_callback']) && $config['ignore_callback'] == true ) { - return; + return null; } - // Show custom background - $output = ''; + // Show custom background. + $output = ''; $output .= $string; @@ -1805,12 +1937,15 @@ function ui_process_page_body($string, $bitfield) * @param string $url URL of the pagination links. It must include all form * values as GET form. * @param integer $offset Current offset for the pagination. Default value would be - * taken from $_REQUEST['offset'] + * taken from $_REQUEST['offset']. * @param integer $pagination Current pagination size. If a user requests a larger - * pagination than config["block_size"] - * @param boolean $return Whether to return or print this + * pagination than config["block_size"]. + * @param boolean $return Whether to return or print this. * @param string $offset_name The name of parameter for the offset. * @param boolean $print_total_items Show the text with the total items. By default true. + * @param mixed $other_class Other_class. + * @param mixed $script Script. + * @param mixed $parameter_script Parameter_script. * @param string $set_id Set id of div. * * @return string The pagination div or nothing if no pagination needs to be done @@ -1851,10 +1986,12 @@ function ui_pagination( } if (!empty($set_id)) { - $set_id = " id = '$set_id'"; + $set_id = " id = '".$set_id."'"; } - // Pagination links for users include delete, create and other params, now not use these params, and not retry the previous action when go to pagination link. + // Pagination links for users include delete, create and other params, + // now not use these params, and not retry the previous action when go to + // pagination link. $remove = [ 'user_del', 'disable_user', @@ -1864,7 +2001,10 @@ function ui_pagination( $finalUrl = []; foreach ($url as $key => $value) { - if (strpos($value, $remove[0]) === false && strpos($value, $remove[1]) === false && strpos($value, $remove[2]) === false) { + if (strpos($value, $remove[0]) === false + && strpos($value, $remove[1]) === false + && strpos($value, $remove[2]) === false + ) { array_push($finalUrl, $value); } } @@ -1878,14 +2018,15 @@ function ui_pagination( Pagination needs $url to build the base URL to render links, its a base url, like " http://pandora/index.php?sec=godmode&sec2=godmode/admin_access_logs " */ + $block_limit = PAGINATION_BLOCKS_LIMIT; - // Visualize only $block_limit blocks + // Visualize only $block_limit blocks. if ($count <= $pagination) { if ($print_total_items) { - $output = "'; } - // Actually print the variable given + // Actually print the variable given. echo '
';
     print_r($var);
     echo '
'; @@ -2253,18 +2422,32 @@ function ui_debug($var, $backtrace=true) /** * Prints icon of a module type * - * @param int Module Type ID - * @param bool Whether to return or print - * @param boolean $relative Whether to use relative path to image or not (i.e. $relative= true : /pandora/). - * @param boolean $options Whether to use image options like style, border or title on the icon. + * @param integer $id_moduletype Module Type ID. + * @param boolean $return Whether to return or print. + * @param boolean $relative Whether to use relative path to image or not (i.e. $relative= true : /pandora/). + * @param boolean $options Whether to use image options like style, border or title on the icon. + * @param boolean $src Src. * * @return string An HTML string with the icon. Printed if return is false */ -function ui_print_moduletype_icon($id_moduletype, $return=false, $relative=false, $options=true, $src=false) -{ +function ui_print_moduletype_icon( + $id_moduletype, + $return=false, + $relative=false, + $options=true, + $src=false +) { global $config; - $type = db_get_row('ttipo_modulo', 'id_tipo', (int) $id_moduletype, ['descripcion', 'icon']); + $type = db_get_row( + 'ttipo_modulo', + 'id_tipo', + (int) $id_moduletype, + [ + 'descripcion', + 'icon', + ] + ); if ($type === false) { $type = []; $type['descripcion'] = __('Unknown type'); @@ -2306,15 +2489,23 @@ function ui_print_moduletype_icon($id_moduletype, $return=false, $relative=false /** * Print module max/min values for warning/critical state * - * @param float Max value for warning state - * @param float Min value for warning state - * @param float Max value for critical state - * @param float Min value for critical state + * @param float $max_warning Max value for warning state. + * @param float $min_warning Min value for warning state. + * @param string $str_warning String warning state. + * @param float $max_critical Max value for critical state. + * @param float $min_critical Min value for critical state. + * @param string $str_critical String for critical state. * * @return string HTML string */ -function ui_print_module_warn_value($max_warning, $min_warning, $str_warning, $max_critical, $min_critical, $str_critical) -{ +function ui_print_module_warn_value( + $max_warning, + $min_warning, + $str_warning, + $max_critical, + $min_critical, + $str_critical +) { $data = ""; if ($max_warning != $min_warning) { @@ -2339,7 +2530,8 @@ function ui_print_module_warn_value($max_warning, $min_warning, $str_warning, $m /** * Format a file size from bytes to a human readable meassure. * - * @param int File size in bytes + * @param integer $bytes File size in bytes. + * * @return string Bytes converted to a human readable meassure. */ function ui_format_filesize($bytes) @@ -2400,16 +2592,52 @@ function ui_get_status_images_path() /** * Prints an image representing a status. * - * @param string - * @param string - * @param bool Whether to return an output string or echo now (optional, echo by default). - * @param array options to set image attributes: I.E.: style - * @param Path of the image, if not provided use the status path + * @param string $type Type. + * @param string $title Title. + * @param boolean $return Whether to return an output string or echo now (optional, echo by default). + * @param array $options Options to set image attributes: I.E.: style. + * @param string $path Path of the image, if not provided use the status path. + * @param boolean $rounded_image Round. * * @return string HTML code if return parameter is true. */ -function ui_print_status_image($type, $title='', $return=false, $options=false, $path=false) -{ +function ui_print_status_image( + $type, + $title='', + $return=false, + $options=false, + $path=false, + $rounded_image=false +) { + // This is for the List of Modules in Agent View. + if ($rounded_image === true) { + switch ($type) { + case 'module_ok.png': + $type = 'module_ok_rounded.png'; + break; + + case 'module_critical.png': + $type = 'module_critical_rounded.png'; + break; + + case 'module_warning.png': + $type = 'module_warning_rounded.png'; + break; + + case 'module_no_data.png': + $type = 'module_no_data_rounded.png'; + break; + + case 'module_unknown.png': + $type = 'module_unknown_rounded.png'; + break; + + default: + $type = $type; + break; + } + } + if ($path === false) { $imagepath_array = ui_get_status_images_path(); $imagepath = $imagepath_array[0]; @@ -2430,46 +2658,844 @@ function ui_print_status_image($type, $title='', $return=false, $options=false, /** - * Print a code into a DIV and enable a toggle to show and hide it + * Prints an image representing a status. * - * @param string html code - * @param string name of the link - * @param string title of the link - * @param bool if the div will be hidden by default (default: true) - * @param bool Whether to return an output string or echo now (default: true) + * @param string $status Module status. + * @param string $title Title. + * @param boolean $return Whether to return an output string or echo now (optional, echo by default). + * @param array $options Options to set image attributes: I.E.: style. + * @param boolean $rounded_image Round. + * + * @return string HTML. */ +function ui_print_module_status( + $status, + $title='', + $return=false, + $options=false, + $rounded_image=false +) { + global $config; - -function ui_toggle($code, $name, $title='', $hidden_default=true, $return=false, $toggle_class='') -{ - // Generate unique Id - $uniqid = uniqid(''); - - // Options - if ($hidden_default) { - $style = 'display:none'; - $image_a = html_print_image('images/down.png', true, false, true); - $image_b = html_print_image('images/go.png', true, false, true); - $original = 'images/go.png'; - } else { - $style = ''; - $image_a = html_print_image('images/down.png', true, false, true); - $image_b = html_print_image('images/go.png', true, false, true); - $original = 'images/down.png'; + if ($options === false) { + $options = []; } - // Link to toggle + $options['style'] .= 'width: 50px;'; + $options['style'] .= 'height: 2em;'; + $options['style'] .= 'display: inline-block;'; + + include_once __DIR__.'/functions_modules.php'; + $options['style'] .= 'background: '.modules_get_color_status($status).';'; + + if ($rounded_image === true) { + $options['style'] .= 'border-radius: 5px;'; + } + + $options['title'] = $title; + $options['data-title'] = $title; + $options['data-use_title_for_force_title'] = 1; + $options['class'] = 'forced_title'; + + $output = '
$v) { + $output .= $k.'="'.$v.'"'; + } + + $output .= '>'; + $output .= '
'; + + if ($return === false) { + echo $output; + } + + return $output; + +} + + +/** + * Generates a progress bar CSS based. + * Requires css progress.css + * + * @param integer $progress Progress. + * @param string $width Width. + * @param integer $height Height in 'em'. + * @param string $color Color. + * @param boolean $return Return or paint (if false). + * @param boolean $text Text to be displayed,by default progress %. + * @param array $ajax Ajax: [ 'page' => 'page', 'data' => 'data' ] Sample: + * [ + * 'page' => 'operation/agentes/ver_agente', Target page. + * 'interval' => 100 / $agent["intervalo"], Ask every interval seconds. + * 'data' => [ Data to be sent to target page. + * 'id_agente' => $id_agente, + * 'refresh_contact' => 1, + * ], + * ]. + * + * @return string HTML code. + */ +function ui_progress( + $progress, + $width='100%', + $height='2.5', + $color='#82b92e', + $return=true, + $text='', + $ajax=false +) { + if (!$progress) { + $progress = 0; + } + + if ($progress > 100) { + $progress = 100; + } + + if ($progress < 0) { + $progress = 0; + } + + if (empty($text)) { + $text = $progress.'%'; + } + + ui_require_css_file('progress'); + $output .= ''; + $output .= ''; + $output .= ''; + + if ($ajax !== false && is_array($ajax)) { + $output .= ''; + } + + if (!$return) { + echo $output; + } + + return $output; +} + + +/** + * Generate needed code to print a datatables jquery plugin. + * + * @param array $parameters All desired data using following format: + * [ + * 'print' => true (by default printed) + * 'id' => datatable id. + * 'class' => datatable class. + * 'style' => datatable style. + * 'order' => [ + * 'field' => column name + * 'direction' => asc or desc + * ], + * 'default_pagination' => integer, default pagination is set to block_size + * 'ajax_url' => 'include/ajax.php' ajax_url. + * 'ajax_data' => [ operation => 1 ] extra info to be sent. + * 'ajax_postprocess' => a javscript function to postprocess data received + * by ajax call. It is applied foreach row and must + * use following format: + * * [code] + * * function (item) { + * * // Process received item, for instance, name: + * * tmp = '' + item.name + ''; + * * item.name = tmp; + * * } + * * [/code] + * 'columns_names' => [ + * 'column1' :: Used as th text. Direct text entry. It could be array: + * OR + * [ + * 'id' => th id. + * 'class' => th class. + * 'style' => th style. + * 'text' => 'column1'. + * ] + * ], + * 'columns' => [ + * 'column1', + * 'column2', + * ... + * ], + * 'no_sortable_columns' => [ indexes ] 1,2... -1 etc. Avoid sorting. + * 'form' => [ + * 'html' => 'html code' a directly defined inputs in HTML. + * 'extra_buttons' => [ + * [ + * 'id' => button id, + * 'class' => button class, + * 'style' => button style, + * 'text' => button text, + * 'onclick' => button onclick, + * ] + * ], + * 'search_button_class' => search button class. + * 'class' => form class. + * 'id' => form id. + * 'style' => form style. + * 'js' => optional extra actions onsubmit. + * 'inputs' => [ + * 'label' => Input label. + * 'type' => Input type. + * 'value' => Input value. + * 'name' => Input name. + * 'id' => Input id. + * 'options' => [ + * 'option1' + * 'option2' + * ... + * ] + * ] + * ], + * 'extra_html' => HTML content to be placed after 'filter' section. + * 'drawCallback' => function to be called after draw. Sample in: + * https://datatables.net/examples/advanced_init/row_grouping.html + * ] + * End. + * + * @return string HTML code with datatable. + * @throws Exception On error. + */ +function ui_print_datatable(array $parameters) +{ + global $config; + + if (isset($parameters['id'])) { + $table_id = $parameters['id']; + } else { + $table_id = uniqid('datatable_'); + } + + if (!isset($parameters['columns']) || !is_array($parameters['columns'])) { + throw new Exception('[ui_print_datatable]: You must define columns for datatable'); + } + + if (!isset($parameters['ajax_url'])) { + throw new Exception('[ui_print_datatable]: Parameter ajax_url is required'); + } + + if (!isset($parameters['default_pagination'])) { + $parameters['default_pagination'] = $config['block_size']; + } + + $no_sortable_columns = []; + if (isset($parameters['no_sortable_columns'])) { + $no_sortable_columns = json_encode($parameters['no_sortable_columns']); + } + + if (!is_array($parameters['order'])) { + $order = '0, "asc"'; + } else { + if (!isset($parameters['order']['direction'])) { + $direction = 'asc'; + } + + if (!isset($parameters['order']['field'])) { + $order = 1; + } else { + $order = array_search( + $parameters['order']['field'], + $parameters['columns'] + ); + + if (empty($order)) { + $order = 1; + } + } + + $order .= ', "'.$parameters['order']['direction'].'"'; + } + + if (!isset($parameters['ajax_data'])) { + $parameters['ajax_data'] = ''; + } + + $search_button_class = 'sub filter'; + if (isset($parameters['search_button_class'])) { + $search_button_class = $parameters['search_button_class']; + } + + if (isset($parameters['pagination_options'])) { + $pagination_options = $parameters['pagination_options']; + } else { + $pagination_options = [ + [ + $parameters['default_pagination'], + 10, + 25, + 100, + 200, + 500, + 1000, + -1, + ], + [ + $parameters['default_pagination'], + 10, + 25, + 100, + 200, + 500, + 1000, + 'All', + ], + ]; + } + + if (!is_array($parameters['datacolumns'])) { + $parameters['datacolumns'] = $parameters['columns']; + } + + // Datatable filter. + if (isset($parameters['form']) && is_array($parameters['form'])) { + if (isset($parameters['form']['id'])) { + $form_id = $parameters['form']['id']; + } else { + $form_id = uniqid('datatable_filter_'); + } + + if (isset($parameters['form']['class'])) { + $form_class = $parameters['form']['class']; + } else { + $form_class = ''; + } + + if (isset($parameters['form']['style'])) { + $form_style = $parameters['form']['style']; + } else { + $form_style = ''; + } + + if (isset($parameters['form']['js'])) { + $form_js = $parameters['form']['js']; + } else { + $form_js = ''; + } + + $filter = '
'; + + if (isset($parameters['form']['html'])) { + $filter .= $parameters['form']['html']; + } + + $filter .= '
    '; + + foreach ($parameters['form']['inputs'] as $input) { + $filter .= '
  • '; + $filter .= ''; + if ($input['type'] != 'select') { + $filter .= ''; + } else { + // Select. + $filter .= ''; + } + + $filter .= '
  • '; + } + + $filter .= '
  • '; + // Search button. + $filter .= ''; + + // Extra buttons. + if (is_array($parameters['form']['extra_buttons'])) { + foreach ($parameters['form']['extra_buttons'] as $button) { + $filter .= ''; + } + } + + $filter .= '
  • '; + + $filter .= '
'; + $filter = ui_toggle( + $filter, + __('Filter'), + '', + '', + true, + false, + 'white_box white_box_opened', + 'no-border' + ); + } else if (isset($parameters['form_html'])) { + $filter = ui_toggle( + $parameters['form_html'], + __('Filter'), + '', + '', + true, + false, + 'white_box white_box_opened', + 'no-border' + ); + } + + // Extra html. + $extra = ''; + if (isset($parameters['extra_html']) && !empty($parameters['extra_html'])) { + $extra = $parameters['extra_html']; + } + + // Base table. + $table = ''; + $table .= ''; + + if (isset($parameters['column_names']) + && is_array($parameters['column_names']) + ) { + $names = $parameters['column_names']; + } else { + $names = $parameters['columns']; + } + + foreach ($names as $column) { + if (is_array($column)) { + $table .= ''; + } else { + $table .= ''; + } + } + + $table .= ''; + $table .= '
'.__($column['text']); + $table .= $column['extra']; + $table .= ''.__($column).'
'; + + $pagination_class = 'pandora_pagination'; + if (!empty($parameters['pagination_class'])) { + $pagination_class = $parameters['pagination_class']; + } + + // Javascript controller. + $js = ''; + + // Order. + $err_msg = '
'; + $output = $err_msg.$filter.$extra.$table.$js; + + ui_require_css_file('datatables.min', 'include/styles/js/'); + ui_require_javascript_file('datatables.min'); + ui_require_javascript_file('buttons.dataTables.min'); + ui_require_javascript_file('dataTables.buttons.min'); + ui_require_javascript_file('buttons.html5.min'); + ui_require_javascript_file('buttons.print.min'); + + $output = $include.$output; + + // Print datatable if needed. + if (!(isset($parameters['print']) && $parameters['print'] === false)) { + echo $output; + } + + return $output; +} + + +/** + * Returns a div wich represents the type received. + * + * Requires ui_require_css_file('events');. + * + * @param integer $type Event type. + * @param boolean $return Or print. + * @param boolean $mini Show mini div. + * + * @return string HTML. + */ +function ui_print_event_type( + $type, + $return=false, + $mini=false +) { + global $config; + $output = ''; - $output .= '
'.html_print_image($original, true, ['title' => $title, 'id' => 'image_'.$uniqid]).'  '.$name.''; + switch ($type) { + case EVENTS_ALERT_FIRED: + case EVENTS_ALERT_RECOVERED: + case EVENTS_ALERT_CEASED: + case EVENTS_ALERT_MANUAL_VALIDATION: + $text = __('ALERT'); + $color = COL_ALERTFIRED; + break; + + case EVENTS_RECON_HOST_DETECTED: + case EVENTS_SYSTEM: + case EVENTS_ERROR: + case EVENTS_NEW_AGENT: + case EVENTS_CONFIGURATION_CHANGE: + $text = __('SYSTEM'); + $color = COL_MAINTENANCE; + break; + + case EVENTS_GOING_UP_WARNING: + case EVENTS_GOING_DOWN_WARNING: + $color = COL_WARNING; + $text = __('WARNING'); + break; + + case EVENTS_GOING_DOWN_NORMAL: + case EVENTS_GOING_UP_NORMAL: + $color = COL_NORMAL; + $text = __('NORMAL'); + break; + + case EVENTS_GOING_DOWN_CRITICAL: + case EVENTS_GOING_UP_CRITICAL: + $color = COL_CRITICAL; + $text = __('CRITICAL'); + break; + + case EVENTS_UNKNOWN: + case EVENTS_GOING_UNKNOWN: + default: + $color = COL_UNKNOWN; + $text = __('UNKNOWN'); + break; + } + + if ($mini === false) { + $output = '
'; + $output .= $text; + $output .= '
'; + } else { + $output = '
'; + $output .= '
'; + } + + return $output; +} + + +/** + * Returns a div wich represents the priority received. + * + * Requires ui_require_css_file('events');. + * + * @param integer $priority Priority level. + * @param boolean $return Or print. + * @param boolean $mini Show mini div. + * + * @return string HTML. + */ +function ui_print_event_priority( + $priority, + $return=false, + $mini=false +) { + global $config; + + $output = ''; + switch ($priority) { + case EVENT_CRIT_MAINTENANCE: + $color = COL_MAINTENANCE; + $criticity = __('MAINTENANCE'); + break; + + case EVENT_CRIT_INFORMATIONAL: + $color = COL_INFORMATIONAL; + $criticity = __('INFORMATIONAL'); + break; + + case EVENT_CRIT_NORMAL: + $color = COL_NORMAL; + $criticity = __('NORMAL'); + break; + + case EVENT_CRIT_WARNING: + $color = COL_WARNING; + $criticity = __('WARNING'); + break; + + case EVENT_CRIT_CRITICAL: + $color = COL_CRITICAL; + $criticity = __('CRITICAL'); + break; + + case EVENT_CRIT_MINOR: + $color = COL_MINOR; + $criticity = __('MINOR'); + break; + + case EVENT_CRIT_MAJOR: + $color = COL_MAJOR; + $criticity = __('MAJOR'); + break; + + default: + $color = COL_UNKNOWN; + $criticity = __('UNKNOWN'); + break; + } + + if ($mini === false) { + $output = '
'; + $output .= $criticity; + $output .= '
'; + } else { + $output = '
'; + $output .= '
'; + } + + return $output; +} + + +/** + * Print a code into a DIV and enable a toggle to show and hide it. + * + * @param string $code Html code. + * @param string $name Name of the link. + * @param string $title Title of the link. + * @param string $id Block id. + * @param boolean $hidden_default If the div will be hidden by default (default: true). + * @param boolean $return Whether to return an output string or echo now (default: true). + * @param string $toggle_class Toggle class. + * @param string $container_class Container class. + * @param string $main_class Main object class. + * + * @return string HTML. + */ +function ui_toggle( + $code, + $name, + $title='', + $id='', + $hidden_default=true, + $return=false, + $toggle_class='', + $container_class='white-box-content', + $main_class='box-shadow white_table_graph' +) { + // Generate unique Id. + $uniqid = uniqid(''); + + $image_a = html_print_image('images/arrow_down_green.png', true, false, true); + $image_b = html_print_image('images/arrow_right_green.png', true, false, true); + // Options. + if ($hidden_default) { + $style = 'display:none'; + $original = 'images/arrow_right_green.png'; + } else { + $style = ''; + $original = 'images/arrow_down_green.png'; + } + + // Link to toggle. + $output = '
'; + $output .= '
'.html_print_image( + $original, + true, + [ + 'title' => $title, + 'id' => 'image_'.$uniqid, + ] + ).'  '.$name.'
'; // $output .= '
'; // if (!defined("METACONSOLE")) // $output .= '
'; // Code into a div - $output .= "
\n"; + $output .= "
\n"; + $output .= '
'; $output .= $code; $output .= '
'; + $output .= '
'; - // JQuery Toggle + // JQuery Toggle. $output .= ''; + $output .= '
'; if (!$return) { echo $output; @@ -2501,26 +3528,28 @@ function ui_toggle($code, $name, $title='', $hidden_default=true, $return=false, /** * Construct and return the URL to be used in order to refresh the current page correctly. * - * @param array Extra parameters to be added to the URL. It has prevalence over - * GET and POST. False values will be ignored. - * @param bool Whether to return the relative URL or the absolute URL. Returns - * relative by default - * @param bool Whether to add POST values to the URL. + * @param array $params Extra parameters to be added to the URL. It has prevalence over + * GET and POST. False values will be ignored. + * @param boolean $relative Whether to return the relative URL or the absolute URL. Returns + * relative by default. + * @param boolean $add_post Whether to add POST values to the URL. + * + * @return string Url. */ function ui_get_url_refresh($params=false, $relative=true, $add_post=true) { - // Agent selection filters and refresh + // Agent selection filters and refresh. global $config; - // slerena, 8/Ene/2015 - Need to put index.php on URL which have it. + // Slerena, 8/Ene/2015 - Need to put index.php on URL which have it. if (strpos($_SERVER['REQUEST_URI'], 'index.php') === false) { $url = ''; } else { $url = 'index.php'; } - if (sizeof($_REQUEST)) { - // Some (old) browsers don't like the ?&key=var + if (count($_REQUEST)) { + // Some (old) browsers don't like the ?&key=var. $url .= '?'; } @@ -2528,12 +3557,12 @@ function ui_get_url_refresh($params=false, $relative=true, $add_post=true) $params = []; } - // Avoid showing login info + // Avoid showing login info. $params['pass'] = false; $params['nick'] = false; $params['unnamed'] = false; - // We don't clean these variables up as they're only being passed along + // We don't clean these variables up as they're only being passed along. foreach ($_GET as $key => $value) { if (isset($params[$key])) { continue; @@ -2610,7 +3639,7 @@ function ui_get_url_refresh($params=false, $relative=true, $add_post=true) } } - // Removes final & + // Removes final &. $pos = strrpos($url, '&', 0); if ($pos) { $url = substr_replace($url, '', $pos, 5); @@ -2631,9 +3660,10 @@ function ui_get_url_refresh($params=false, $relative=true, $add_post=true) * * An example of full URL is http:/localhost/pandora_console/index.php?sec=gsetup&sec2=godmode/setup/setup * - * @param mixed $url If provided, it will be added after the index.php, but it is false boolean value, put the homeurl in the url. - * @param boolean $no_proxy To avoid the proxy checks, by default it is false. - * @param boolean $metaconsole_root Set the root to the metaconsole dir if the metaconsole is enabled, true by default. + * @param mixed $url If provided, it will be added after the index.php, but it is false boolean value, put the homeurl in the url. + * @param boolean $no_proxy To avoid the proxy checks, by default it is false. + * @param boolean $add_name_php_file Something. + * @param boolean $metaconsole_root Set the root to the metaconsole dir if the metaconsole is enabled, true by default. * * @return string A full URL in Pandora. */ @@ -2642,7 +3672,7 @@ function ui_get_full_url($url='', $no_proxy=false, $add_name_php_file=false, $me global $config; $port = null; - // null means 'use the starndard port' + // Null means 'use the starndard port'. $proxy = false; // By default Pandora FMS doesn't run across proxy. if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) @@ -2660,7 +3690,7 @@ function ui_get_full_url($url='', $no_proxy=false, $add_name_php_file=false, $me $port = $_SERVER['SERVER_PORT']; } } else if ($config['https']) { - // When $config["https"] is set, enforce https + // When $config["https"] is set, enforce https. $protocol = 'https'; } else { $protocol = 'http'; @@ -2673,7 +3703,7 @@ function ui_get_full_url($url='', $no_proxy=false, $add_name_php_file=false, $me if (!$no_proxy) { // Check if the PandoraFMS runs across the proxy like as // mod_proxy of Apache - // and check if public_url is setted + // and check if public_url is set. if (!empty($config['public_url']) && (!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) ) { @@ -2686,9 +3716,9 @@ function ui_get_full_url($url='', $no_proxy=false, $add_name_php_file=false, $me $fullurl = $protocol.'://'.$_SERVER['SERVER_NAME']; } - // using a different port than the standard + // Using a different port than the standard. if (!$proxy) { - // using a different port than the standard + // Using a different port than the standard. if ($port != null) { $fullurl .= ':'.$port; } @@ -2704,7 +3734,7 @@ function ui_get_full_url($url='', $no_proxy=false, $add_name_php_file=false, $me if ($proxy) { $url = ''; } else { - // Only add the home url + // Only add the home url. $url = $config['homeurl_static'].'/'; } @@ -2750,16 +3780,21 @@ function ui_get_full_url($url='', $no_proxy=false, $add_name_php_file=false, $me /** * Return a standard page header (Pandora FMS 3.1 version) * - * @param string Title - * @param string Icon path - * @param boolean Return (false will print using a echo) - * @param boolean help (Help ID to print the Help link) - * @param boolean Godmode (false = operation mode). - * @param string Options (HTML code for make tabs or just a brief info string + * @param string $title Title. + * @param string $icon Icon path. + * @param boolean $return Return (false will print using a echo). + * @param boolean $help Help (Help ID to print the Help link). + * @param boolean $godmode Godmode (false = operation mode). + * @param string $options Options (HTML code for make tabs or just a brief + * info string. + * @param mixed $modal Modal. + * @param mixed $message Message. + * @param mixed $numChars NumChars. + * @param mixed $alias Alias. + * @param mixed $breadcrumbs Breadcrumbs. + * * @return string Header HTML */ - - function ui_print_page_header( $title, $icon='', @@ -2784,17 +3819,18 @@ function ui_print_page_header( if ($godmode == true) { $type = 'view'; - $type2 = (empty($breadcrumbs)) ? 'menu_tab_frame_view' : 'menu_tab_frame_view_bc'; + $type2 = 'menu_tab_frame_view'; $separator_class = 'separator'; } else { $type = 'view'; - $type2 = (empty($breadcrumbs)) ? 'menu_tab_frame_view' : 'menu_tab_frame_view_bc'; + $type2 = 'menu_tab_frame_view'; $separator_class = 'separator_view'; } $buffer = '
'; if (!empty($breadcrumbs)) { + $buffer .= ''; + if (!empty($breadcrumbs)) { + $buffer .= '
'; + } + if (is_array($options)) { $buffer .= '".''.$sub_string.' '."".html_print_image('images/zoom.png', true).''; } } } @@ -4180,7 +5239,12 @@ function ui_print_module_string_value( /** - * Displays a tag list + * Displays a tag list. + * + * @param string $title Title. + * @param array $tags Tags. + * + * @return void */ function ui_print_tags_view($title='', $tags=[]) { @@ -4209,33 +5273,35 @@ function ui_print_tags_view($title='', $tags=[]) /** - * @brief Get the link to open a snapshot into a new page + * Gets the link to open a snapshot into a new page. * - * @param Array Params to build the link (see $default_params) - * @param bool Flag to choose de return value: - * true: Get the four params required in the function of pandora.js winopen_var (js use) - * false: Get an inline winopen_var function call (php user) + * @param array $params Params to build the link (see $default_params). + * @param boolean $only_params Flag to choose de return value: + * true: Get the four params required in the function of pandora.js winopen_var (js use) + * false: Get an inline winopen_var function call (php user). + * + * @return string Link. */ function ui_get_snapshot_link($params, $only_params=false) { global $config; $default_params = [ + // Id_agente_modulo. 'id_module' => 0, - // id_agente_modulo 'module_name' => '', 'interval' => 300, 'timestamp' => 0, 'id_node' => 0, ]; - // Merge default params with passed params + // Merge default params with passed params. $params = array_merge($default_params, $params); - // First parameter of js winopeng_var + // First parameter of js winopeng_var. $page = $config['homeurl_static'].'/operation/agentes/snapshot_view.php'; - $url = "$page?".'id='.$params['id_module'].'&label='.rawurlencode(urlencode(io_safe_output($params['module_name']))).'&id_node='.$params['id_node']; + $url = $page.'?id='.$params['id_module'].'&label='.rawurlencode(urlencode(io_safe_output($params['module_name']))).'&id_node='.$params['id_node']; if ($params['timestamp'] != 0) { $url .= '×tamp='.$params['timestamp']; @@ -4245,7 +5311,7 @@ function ui_get_snapshot_link($params, $only_params=false) $url .= '&refr='.$params['interval']; } - // Second parameter of js winopeng_var + // Second parameter of js winopeng_var. $win_handle = dechex(crc32('snapshot_'.$params['id_module'])); $link_parts = [ @@ -4255,30 +5321,30 @@ function ui_get_snapshot_link($params, $only_params=false) 480, ]; - // Return only the params to js execution + // Return only the params to js execution. if ($only_params) { return $link_parts; } - // Return the function call to inline js execution + // Return the function call to inline js execution. return "winopeng_var('".implode("', '", $link_parts)."')"; } /** - * @brief Get the snapshot image with the link to open a snapshot into a new page + * Get the snapshot image with the link to open a snapshot into a new page * - * @param string Built link - * @param bool Picture image or list image + * @param string $link Built link. + * @param boolean $is_image Picture image or list image. * - * @return string HTML anchor link with image + * @return string HTML anchor link with image. */ function ui_get_snapshot_image($link, $is_image) { - $image_name = $is_image ? 'photo.png' : 'default_list.png'; + $image_name = ($is_image) ? 'photo.png' : 'default_list.png'; $link = ''.html_print_image( - "images/$image_name", + 'images/'.$image_name, true, [ 'border' => '0', @@ -4291,6 +5357,14 @@ function ui_get_snapshot_image($link, $is_image) } +/** + * Show warning timezone missmatch. + * + * @param string $tag Tag. + * @param boolean $return Return. + * + * @return string HTML. + */ function ui_get_using_system_timezone_warning($tag='h3', $return=true) { global $config; @@ -4302,7 +5376,7 @@ function ui_get_using_system_timezone_warning($tag='h3', $return=true) __('These controls are using the timezone of the system (%s) instead of yours (%s). The difference with your time zone in hours is %s.'), $config['timezone'], date_default_timezone_get(), - $user_offset > 0 ? '+'.$user_offset : $user_offset + ($user_offset > 0) ? '+'.$user_offset : $user_offset ); return ui_print_info_message($message, '', $return, $tag); } else { @@ -4315,13 +5389,13 @@ function ui_get_using_system_timezone_warning($tag='h3', $return=true) /** * Get the custom docs logo * - * @return string with the path to logo. False if it should not be displayed + * @return string with the path to logo. False if it should not be displayed. */ function ui_get_docs_logo() { global $config; - // Default logo to open version (enterprise_installed function only works in login status) + // Default logo to open version (enterprise_installed function only works in login status). if (!file_exists(ENTERPRISE_DIR.'/load_enterprise.php')) { return 'images/icono_docs.png'; } @@ -4337,13 +5411,13 @@ function ui_get_docs_logo() /** * Get the custom support logo * - * @return string with the path to logo. False if it should not be displayed + * @return string with the path to logo. False if it should not be displayed. */ function ui_get_support_logo() { global $config; - // Default logo to open version (enterprise_installed function only works in login status) + // Default logo to open version (enterprise_installed function only works in login status). if (!file_exists(ENTERPRISE_DIR.'/load_enterprise.php')) { return 'images/icono_support.png'; } @@ -4359,7 +5433,9 @@ function ui_get_support_logo() /** * Get the custom header logo * - * @return string with the path to logo. If it is not set, return the default value + * @param boolean $white_bg Using white bg or not. + * + * @return string with the path to logo. If it is not set, return the default value. */ function ui_get_custom_header_logo($white_bg=false) { @@ -4369,7 +5445,7 @@ function ui_get_custom_header_logo($white_bg=false) return 'images/pandora_tinylogo_open.png'; } - $stored_logo = is_metaconsole() ? ($white_bg ? $config['meta_custom_logo_white_bg'] : $config['meta_custom_logo']) : ($white_bg ? $config['custom_logo_white_bg'] : $config['custom_logo']); + $stored_logo = (is_metaconsole()) ? (($white_bg) ? $config['meta_custom_logo_white_bg'] : $config['meta_custom_logo']) : (($white_bg) ? $config['custom_logo_white_bg'] : $config['custom_logo']); if (empty($stored_logo)) { return 'images/pandora_tinylogo.png'; } @@ -4422,7 +5498,7 @@ function ui_get_favicon() global $config; if (empty($config['custom_favicon'])) { - return !is_metaconsole() ? 'images/pandora.ico' : 'enterprise/meta/images/favicon_meta.ico'; + return (!is_metaconsole()) ? 'images/pandora.ico' : 'enterprise/meta/images/favicon_meta.ico'; } return 'images/custom_favicon/'.$config['custom_favicon']; @@ -4432,6 +5508,11 @@ function ui_get_favicon() /** * Show sorting arrows for tables * + * @param string $url_up Url_up. + * @param string $url_down Url_down. + * @param string $selectUp SelectUp. + * @param string $selectDown SelectDown. + * * @return string HTML anchor link with the arrow icon. */ function ui_get_sorting_arrows($url_up, $url_down, $selectUp, $selectDown) @@ -4458,3 +5539,24 @@ function ui_get_sorting_arrows($url_up, $url_down, $selectUp, $selectDown) '.html_print_image($arrow_down, true, ['alt' => 'down']).' '; } + + +/** + * Show breadcrums in the page titles + * + * @param string $tab_name Tab name. + * + * @return string HTML anchor with the name of the section. + */ +function ui_print_breadcrums($tab_name) +{ + if (is_array($tab_name)) { + return join(' / ', $tab_name); + } else if ($tab_name != '') { + $section = str_replace('_', ' ', $tab_name); + $section = ucwords($section); + $section = ' / '.___($section); + } + + return $section; +} diff --git a/pandora_console/include/functions_update_manager.php b/pandora_console/include/functions_update_manager.php index 6912aa05ff..73a654a50d 100755 --- a/pandora_console/include/functions_update_manager.php +++ b/pandora_console/include/functions_update_manager.php @@ -1,7 +1,6 @@ $email], + ['id_user' => $config['id_user']] + ); + } + + // Update the alert action Mail to XXX/Administrator + // if it is set to default. + $mail_check = 'yourmail@domain.es'; + $mail_alert = alerts_get_alert_action_field1(1); + if ($mail_check === $mail_alert && $email !== false) { + alerts_update_alert_action( + 1, + [ + 'field1' => $email, + 'field1_recovery' => $email, + ] + ); + } + + config_update_value('initial_wizard', 1); +} + + +/** + * Generates base code to print main configuration modal. + * + * Asks for timezone, mail. + * + * @param boolean $return Print output or not. + * @param boolean $launch Process JS modal. + * @param string $callback Call to JS function at end. + * + * @return string HTML. + */ +function config_wiz_modal( + $return=false, + $launch=true, + $callback=false +) { + global $config; + + $email = db_get_value('email', 'tusuario', 'id_user', $config['id_user']); + // Avoid to show default email. + if ($email == 'admin@example.com') { + $email = ''; + } + + $output = ''; + + // Prints first step pandora registration. + $output .= ''; + + $output .= '
'; + + // Verification modal. + $output .= ''; + + ob_start(); + ?> + + + + true, + 'message' => '', + ]; + + // Pandora register update. + $um_message = update_manager_register_instance(); + $ui_feedback['message'] .= $um_message['message'].'

'; + $ui_feedback['status'] = $um_message['success'] && $ui_feedback['status']; + + if ($ui_feedback['status']) { + // Store next identification reminder. + config_update_value( + 'identification_reminder_timestamp', + $next_check + ); + } + + return $ui_feedback; +} + + +/** + * Shows a modal to register current console in UpdateManager. + * + * @param boolean $return Return or show html. + * @param boolean $launch Execute wizard. + * @param string $callback Call function when done. + * + * @return string HTML code. + */ +function registration_wiz_modal( + $return=false, + $launch=true, + $callback=false +) { + global $config; + $output = ''; + + $product_name = get_product_name(); + + $output .= ''; + + // Verification modal. + $output .= ''; + + // Results modal. + $output .= ''; + + ob_start(); + ?> + + + 1], + ['id_user' => $config['id_user']] + ); + $ui_feedback['status'] = $um_message['success']; + } else { + $ui_feedback['status'] = false; + } + + return $ui_feedback; +} + + +/** + * Show a modal allowing the user register into newsletter. + * + * @param boolean $return Print content o return it. + * @param boolean $launch Launch directly on load or not. + * @param string $callback Call function when done. + * + * @return string HTML code. + */ +function newsletter_wiz_modal( + $return=false, + $launch=true, + $callback=false +) { + global $config; + + $output = ''; + + $product_name = get_product_name(); + $email = db_get_value( + 'email', + 'tusuario', + 'id_user', + $config['id_user'] + ); + + // Avoid to show default email. + if ($email == 'admin@example.com') { + $email = ''; + } + + $output .= ''; + + // Verification modal. + $output .= ''; + + // Results modal. + $output .= ''; + + ob_start(); + ?> + + + $license, @@ -49,11 +991,18 @@ function update_manager_get_config_values() 'limit_count' => $limit_count, 'build' => $build_version, 'version' => $pandora_version, + 'puid' => $config['pandora_uid'], ]; } -// Function to remove dir and files inside +/** + * Function to remove dir and files inside. + * + * @param string $dir Path to dir. + * + * @return void + */ function rrmdir($dir) { if (is_dir($dir)) { @@ -77,6 +1026,11 @@ function rrmdir($dir) } +/** + * Install updates step2. + * + * @return void + */ function update_manager_install_package_step2() { global $config; @@ -90,9 +1044,9 @@ function update_manager_install_package_step2() $path = sys_get_temp_dir().'/pandora_oum/'.$package; - // All files extracted + // All files extracted. $files_total = $path.'/files.txt'; - // Files copied + // Files copied. $files_copied = $path.'/files.copied.txt'; $return = []; @@ -101,93 +1055,109 @@ function update_manager_install_package_step2() } if (file_exists($path)) { - if ($files_h = fopen($files_total, 'r')) { - while ($line = stream_get_line($files_h, 65535, "\n")) { - $line = trim($line); - - // Tries to move the old file to the directory backup inside the extracted package - if (file_exists($config['homedir'].'/'.$line)) { - rename($config['homedir'].'/'.$line, $path.'/backup/'.$line); - } - - // Tries to move the new file to the Integria directory - $dirname = dirname($line); - if (!file_exists($config['homedir'].'/'.$dirname)) { - $dir_array = explode('/', $dirname); - $temp_dir = ''; - foreach ($dir_array as $dir) { - $temp_dir .= '/'.$dir; - if (!file_exists($config['homedir'].$temp_dir)) { - mkdir($config['homedir'].$temp_dir); - } - } - } - - if (is_dir($path.'/'.$line)) { - if (!file_exists($config['homedir'].'/'.$line)) { - mkdir($config['homedir'].'/'.$line); - file_put_contents($files_copied, $line."\n", (FILE_APPEND | LOCK_EX)); - } - } else { - // Copy the new file - if (rename($path.'/'.$line, $config['homedir'].'/'.$line)) { - // Append the moved file to the copied files txt - if (!file_put_contents($files_copied, $line."\n", (FILE_APPEND | LOCK_EX))) { - // If the copy process fail, this code tries to restore the files backed up before - if ($files_copied_h = fopen($files_copied, 'r')) { - while ($line_c = stream_get_line($files_copied_h, 65535, "\n")) { - $line_c = trim($line_c); - if (!rename($path.'/backup/'.$line, $config['homedir'].'/'.$line_c)) { - $backup_status = __('Some of your files might not be recovered.'); - } - } - - if (!rename($path.'/backup/'.$line, $config['homedir'].'/'.$line)) { - $backup_status = __('Some of your files might not be recovered.'); - } - - fclose($files_copied_h); - } else { - $backup_status = __('Some of your old files might not be recovered.'); - } - - fclose($files_h); - $return['status'] = 'error'; - $return['message'] = __("Line '$line' not copied to the progress file.").' '.$backup_status; - echo json_encode($return); - return; - } - } else { - // If the copy process fail, this code tries to restore the files backed up before - if ($files_copied_h = fopen($files_copied, 'r')) { - while ($line_c = stream_get_line($files_copied_h, 65535, "\n")) { - $line_c = trim($line_c); - if (!rename($path.'/backup/'.$line, $config['homedir'].'/'.$line)) { - $backup_status = __('Some of your old files might not be recovered.'); - } - } - - fclose($files_copied_h); - } else { - $backup_status = __('Some of your files might not be recovered.'); - } - - fclose($files_h); - $return['status'] = 'error'; - $return['message'] = __("File '$line' not copied.").' '.$backup_status; - echo json_encode($return); - return; - } - } - } - - fclose($files_h); - } else { + $files_h = fopen($files_total, 'r'); + if ($files_h === false) { $return['status'] = 'error'; $return['message'] = __('An error ocurred while reading a file.'); echo json_encode($return); return; } + + while ($line = stream_get_line($files_h, 65535, "\n")) { + $line = trim($line); + + // Tries to move the old file to the directory backup + // inside the extracted package. + if (file_exists($config['homedir'].'/'.$line)) { + rename($config['homedir'].'/'.$line, $path.'/backup/'.$line); + } + + // Tries to move the new file to the Integria directory. + $dirname = dirname($line); + if (!file_exists($config['homedir'].'/'.$dirname)) { + $dir_array = explode('/', $dirname); + $temp_dir = ''; + foreach ($dir_array as $dir) { + $temp_dir .= '/'.$dir; + if (!file_exists($config['homedir'].$temp_dir)) { + mkdir($config['homedir'].$temp_dir); + } + } + } + + if (is_dir($path.'/'.$line)) { + if (!file_exists($config['homedir'].'/'.$line)) { + mkdir($config['homedir'].'/'.$line); + file_put_contents($files_copied, $line."\n", (FILE_APPEND | LOCK_EX)); + } + } else { + // Copy the new file. + if (rename($path.'/'.$line, $config['homedir'].'/'.$line)) { + // Append the moved file to the copied files txt. + if (!file_put_contents($files_copied, $line."\n", (FILE_APPEND | LOCK_EX))) { + // If the copy process fail, this code tries to + // restore the files backed up before. + $files_copied_h = fopen($files_copied, 'r'); + if ($files_copied_h === false) { + $backup_status = __('Some of your old files might not be recovered.'); + } else { + while ($line_c = stream_get_line($files_copied_h, 65535, "\n")) { + $line_c = trim($line_c); + if (!rename($path.'/backup/'.$line, $config['homedir'].'/'.$line_c)) { + $backup_status = __('Some of your files might not be recovered.'); + } + } + + if (!rename($path.'/backup/'.$line, $config['homedir'].'/'.$line)) { + $backup_status = __('Some of your files might not be recovered.'); + } + + fclose($files_copied_h); + } + + fclose($files_h); + $return['status'] = 'error'; + $return['message'] = __( + 'Line "%s" not copied to the progress file.', + $line + ).' '.$backup_status; + echo json_encode($return); + return; + } + } else { + // If the copy process fail, this code tries to restore + // the files backed up before. + $files_copied_h = fopen($files_copied, 'r'); + if ($files_copied_h === false) { + $backup_status = __('Some of your files might not be recovered.'); + } else { + while ($line_c = stream_get_line($files_copied_h, 65535, "\n")) { + $line_c = trim($line_c); + if (!rename( + $path.'/backup/'.$line, + $config['homedir'].'/'.$line + ) + ) { + $backup_status = __('Some of your old files might not be recovered.'); + } + } + + fclose($files_copied_h); + } + + fclose($files_h); + $return['status'] = 'error'; + $return['message'] = __( + 'Line "%s" not copied to the progress file.', + $line + ).' '.$backup_status; + echo json_encode($return); + return; + } + } + } + + fclose($files_h); } else { $return['status'] = 'error'; $return['message'] = __('The package does not exist'); @@ -197,20 +1167,28 @@ function update_manager_install_package_step2() update_manager_enterprise_set_version($version); $product_name = get_product_name(); - db_pandora_audit("Update $product_name", "Update version: $version of $product_name by ".$config['id_user']); + + // Generate audit entry. + db_pandora_audit( + 'Update '.$product_name, + 'Update version: '.$version.' of '.$product_name.' by '.$config['id_user'] + ); $return['status'] = 'success'; $return['message'] = __('The package is installed.'); echo json_encode($return); - return; } +/** + * Launch update manager client. + * + * @return void + */ function update_manager_main() { global $config; - ?> "; + + return $out; +} diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php index 637d02b34b..4492da7834 100644 --- a/pandora_console/include/graphs/functions_flot.php +++ b/pandora_console/include/graphs/functions_flot.php @@ -82,9 +82,22 @@ function include_javascript_dependencies_flot_graph($return=false) } -// -// AREA GRAPHS //////// -// +/** + * Function create container for print charts. + * + * @param integer $agent_module_id Id module. + * @param array $array_data Data. + * @param array $legend Legend. + * @param array $series_type Series. + * @param array $color Color. + * @param array $date_array Date. + * @param array $data_module_graph Data module. + * @param array $params Params. + * @param string $water_mark Water. + * @param array $array_events_alerts Events array. + * + * @return string Return graphs. + */ function flot_area_graph( $agent_module_id, $array_data, @@ -99,8 +112,7 @@ function flot_area_graph( ) { global $config; - // include_javascript_dependencies_flot_graph(); - // Get a unique identifier to graph + // Get a unique identifier to graph. $graph_id = uniqid('graph_'); $background_style = ''; @@ -126,19 +138,26 @@ function flot_area_graph( break; } - $padding_vconsole = $params['dashboard'] ? 'padding: 1px 0px 10px 10px;' : ''; + $padding_vconsole = ($params['dashboard']) ? 'padding: 1px 0px 10px 10px;' : ''; - // Parent layer + // Parent layer. $return = "
"; + + if (empty($params['title']) === false) { + $return .= '

'.$params['title'].'

'; + } + // Set some containers to legend, graph, timestamp tooltip, etc. if ($params['show_legend']) { - $return .= "

"; + $return .= '

'; } if (isset($params['graph_combined']) && $params['graph_combined'] && (!isset($params['from_interface']) || !$params['from_interface']) ) { - if (isset($params['threshold_data']) && is_array($params['threshold_data'])) { + if (isset($params['threshold_data']) + && is_array($params['threshold_data']) + ) { $yellow_threshold = $params['threshold_data']['yellow_threshold']; $red_threshold = $params['threshold_data']['red_threshold']; $yellow_up = $params['threshold_data']['yellow_up']; @@ -154,7 +173,7 @@ function flot_area_graph( } else if (!isset($params['combined']) || !$params['combined']) { $yellow_threshold = $data_module_graph['w_min']; $red_threshold = $data_module_graph['c_min']; - // Get other required module datas to draw warning and critical + // Get other required module datas to draw warning and critical. if ($agent_module_id == 0) { $yellow_up = 0; $red_up = 0; @@ -166,8 +185,12 @@ function flot_area_graph( $yellow_inverse = !($data_module_graph['w_inv'] == 0); $red_inverse = !($data_module_graph['c_inv'] == 0); } - } else if (isset($params['from_interface']) && $params['from_interface']) { - if (isset($params['threshold_data']) && is_array($params['threshold_data'])) { + } else if (isset($params['from_interface']) + && $params['from_interface'] + ) { + if (isset($params['threshold_data']) + && is_array($params['threshold_data']) + ) { $yellow_threshold = $params['threshold_data']['yellow_threshold']; $red_threshold = $params['threshold_data']['red_threshold']; $yellow_up = $params['threshold_data']['yellow_up']; @@ -200,7 +223,11 @@ function flot_area_graph( ); } - $return .= html_print_input_hidden('line_width_graph', $config['custom_graph_width'], true); + $return .= html_print_input_hidden( + 'line_width_graph', + $config['custom_graph_width'], + true + ); $return .= "
"; + style='font-size: ".$params['font_size'].'pt; + display:none; position:absolute; overflow: auto; + max-height: '.($params['height'] + 50).'px; + width: '.$extra_width."px; + background:#fff; padding: 2px 2px 2px 2px; + border: solid #000 1px;'>
"; - // Trick to get translated string from javascript + // Trick to get translated string from javascript. $return .= html_print_input_hidden('unknown_text', __('Unknown'), true); - $values = json_encode($array_data); + $values = json_encode($array_data); + $legend = json_encode($legend); $series_type = json_encode($series_type); $color = json_encode($color); @@ -261,7 +289,7 @@ function flot_area_graph( $params = json_encode($params); $array_events_alerts = json_encode($array_events_alerts); - // Javascript code + // Javascript code. if ($font_size == '') { $font_size = '\'\''; } @@ -272,7 +300,7 @@ function flot_area_graph( $return .= '});'; $return .= ''; - // Parent layer + // Parent layer. $return .= ''; return $return; diff --git a/pandora_console/include/graphs/functions_gd.php b/pandora_console/include/graphs/functions_gd.php index 262ed22bb3..10f566185d 100755 --- a/pandora_console/include/graphs/functions_gd.php +++ b/pandora_console/include/graphs/functions_gd.php @@ -344,9 +344,9 @@ function drawRating($rating, $width, $height, $font, $out_of_lim_str, $mode, $fo $image = imagecreate($width, $height); // colors - $back = imagecolorallocate($image, 255, 255, 255); + $back = imagecolorallocate($image, 241, 241, 241); - $bordercolor = imagecolorallocate($image, 174, 174, 174); + $bordercolor = imagecolorallocate($image, 241, 241, 241); $text = imagecolorallocate($image, 74, 74, 74); $red = imagecolorallocate($image, 255, 60, 75); $green = imagecolorallocate($image, 50, 205, 50); @@ -483,7 +483,7 @@ function gd_progress_bar($width, $height, $progress, $title, $font, $out_of_lim_ break; case 1: - drawRating($progress, $width, $height, $font, $out_of_lim_str, $mode, 6, $value_text, $color); + drawRating($progress, $width, $height, $font, $out_of_lim_str, $mode, 9, $value_text, $color); break; diff --git a/pandora_console/include/graphs/pandora.d3.js b/pandora_console/include/graphs/pandora.d3.js index 6bc3d72d66..49d026ed0f 100644 --- a/pandora_console/include/graphs/pandora.d3.js +++ b/pandora_console/include/graphs/pandora.d3.js @@ -1614,9 +1614,9 @@ function print_phases_donut(recipient, phases) { .insert("path") .style("fill", function(d) { if (d.data.value == 0) { - return "#80BA27"; + return "#82b92e"; } else { - return "#FC4444"; + return "#e63c52"; } }) .attr("class", "slice"); @@ -2113,8 +2113,7 @@ function print_circular_progress_bar( var progress = startPercent; - if (transition == 0) - updateProgress(endPercent); + if (transition == 0) updateProgress(endPercent); else { (function loops() { updateProgress(progress); @@ -2762,3 +2761,221 @@ function valueToBytes(value) { // This will actually do the rounding and the decimals. return value.toFixed(2) + shorts[pos] + "B"; } + +function donutNarrowGraph(colores, width, height, total) { + // Default settings + var donutbody = d3.select("body"); + var data = {}; + // var showTitle = true; + + if (width == "") { + width = 180; + } + + if (height == "") { + height = 180; + } + + var radius = Math.min(width, height) / 2; + + var currentVal; + //var color = d3.scale.category20(); + + var colores_index = []; + var colores_value = []; + + $.each(colores, function(index, value) { + colores_index.push(index); + colores_value.push(value); + }); + + var color = d3.scale + .ordinal() + .domain(colores_index) + .range(colores_value); + + var pie = d3.layout + .pie() + .sort(null) + .value(function(d) { + return d.value; + }); + + var svg, g, arc; + + var object = {}; + + // Method for render/refresh graph + object.render = function() { + if (!svg) { + // Show normal status by default. This variable must be initialized here, before clearing data. + var normal_status = data.Normal; + + // Don't draw 0 or invalid values. console.log(data); + var data_map = $.map(data, function(value, index) { + if (value == 0 || isNaN(value)) { + return index; + } + }); + + $.each(data_map, function(i, val) { + delete data[val]; + }); + //New data: console.log(data); + + arc = d3.svg + .arc() + .outerRadius(radius) + .innerRadius(radius - radius / 2.5); + + svg = donutbody + .append("svg") + .attr("width", width) + .attr("height", height) + .append("g") + .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")"); + + g = svg + .selectAll(".arc") + .data(pie(d3.entries(data))) + .enter() + .append("g") + .attr("class", "arc"); + + g.append("path") + // Attach current value to g so that we can use it for animation + .each(function(d) { + this._current = d; + }) + .attr("d", arc) + .attr("stroke", "white") + .style("fill", function(d) { + return color(d.data.key); + }); + // This is to show labels on the graph + /* g.append("text") + .attr("transform", function(d) { + return "translate(" + arc.centroid(d) + ")"; + }) + .attr("dy", ".35em") + .style("text-anchor", "middle"); + g.select("text").text(function(d) { + return d.data.key; + });*/ + + // Show normal status by default. + var percentage_normal; + svg + .append("text") + .datum(data) + .attr("x", 0) + .attr("y", 0 + radius / 10) + .attr("class", "text-tooltip") + .style("text-anchor", "middle") + //.attr("fill", "#82b92e") + .style("font-size", function(d) { + if (normal_status) { + percentage_normal = (normal_status * 100) / total; + if (Number.isInteger(percentage_normal)) { + percentage_normal = percentage_normal.toFixed(0); + return radius / 3 + "px"; + } else { + percentage_normal = percentage_normal.toFixed(1); + return radius / 3.5 + "px"; + } + } + }) + .text(function(d) { + if (normal_status) { + return percentage_normal + "%"; + } else { + return "0%"; + } + }); + + g.on("mouseover", function(obj) { + //console.log(obj); + var percentage; + svg + .select("text.text-tooltip") + // This is to paint the text of the corresponding color. + /* .attr("fill", function(d) { + return color(obj.data.key); + })*/ + .style("font-size", function(d) { + percentage = (d[obj.data.key] * 100) / total; + if (Number.isInteger(percentage)) { + percentage = percentage.toFixed(0); + return radius / 3 + "px"; + } else { + percentage = percentage.toFixed(1); + return radius / 3.5 + "px"; + } + }) + .text(percentage + "%"); + }); + + g.on("mouseout", function(obj) { + svg.select("text.text-tooltip").text(function(d) { + if (normal_status) { + return percentage_normal + "%"; + } else { + return "0%"; + } + }); + // .attr("fill", "#82b92e"); + }); + } else { + g.data(pie(d3.entries(data))) + .exit() + .remove(); + + g.select("path") + .transition() + .duration(200) + .attrTween("d", function(a) { + var i = d3.interpolate(this._current, a); + this._current = i(0); + return function(t) { + return arc(i(t)); + }; + }); + + g.select("text").attr("transform", function(d) { + return "translate(" + arc.centroid(d) + ")"; + }); + + svg.select("text.text-tooltip").datum(data); + } + return object; + }; + + // Getter and setter methods + object.data = function(value) { + if (!arguments.length) return data; + data = value; + return object; + }; + + object.donutbody = function(value) { + if (!arguments.length) return donutbody; + donutbody = value; + return object; + }; + + object.width = function(value) { + if (!arguments.length) return width; + width = value; + radius = Math.min(width, height) / 2; + return object; + }; + + object.height = function(value) { + if (!arguments.length) return height; + height = value; + radius = Math.min(width, height) / 2; + return object; + }; + + return object; +} diff --git a/pandora_console/include/javascript/buttons.dataTables.min.js b/pandora_console/include/javascript/buttons.dataTables.min.js new file mode 100644 index 0000000000..90389767ac --- /dev/null +++ b/pandora_console/include/javascript/buttons.dataTables.min.js @@ -0,0 +1,5 @@ +/*! + DataTables styling wrapper for Buttons + ©2018 SpryMedia Ltd - datatables.net/license +*/ +(function(c){"function"===typeof define&&define.amd?define(["jquery","datatables.net-dt","datatables.net-buttons"],function(a){return c(a,window,document)}):"object"===typeof exports?module.exports=function(a,b){a||(a=window);b&&b.fn.dataTable||(b=require("datatables.net-dt")(a,b).$);b.fn.dataTable.Buttons||require("datatables.net-buttons")(a,b);return c(b,a,a.document)}:c(jQuery,window,document)})(function(c,a,b,d){return c.fn.dataTable}); diff --git a/pandora_console/include/javascript/buttons.html5.min.js b/pandora_console/include/javascript/buttons.html5.min.js new file mode 100644 index 0000000000..deee7fee68 --- /dev/null +++ b/pandora_console/include/javascript/buttons.html5.min.js @@ -0,0 +1,35 @@ +/*! + HTML5 export buttons for Buttons and DataTables. + 2016 SpryMedia Ltd - datatables.net/license + + FileSaver.js (1.3.3) - MIT license + Copyright © 2016 Eli Grey - http://eligrey.com +*/ +(function(f){"function"===typeof define&&define.amd?define(["jquery","datatables.net","datatables.net-buttons"],function(g){return f(g,window,document)}):"object"===typeof exports?module.exports=function(g,p,z,t){g||(g=window);p&&p.fn.dataTable||(p=require("datatables.net")(g,p).$);p.fn.dataTable.Buttons||require("datatables.net-buttons")(g,p);return f(p,g,g.document,z,t)}:f(jQuery,window,document)})(function(f,g,p,z,t,w){function A(a){for(var b="";0<=a;)b=String.fromCharCode(a%26+65)+b,a=Math.floor(a/ +26)-1;return b}function E(a,b){y===w&&(y=-1===C.serializeToString(f.parseXML(F["xl/worksheets/sheet1.xml"])).indexOf("xmlns:r"));f.each(b,function(b,c){if(f.isPlainObject(c))b=a.folder(b),E(b,c);else{if(y){var d=c.childNodes[0],e,h=[];for(e=d.attributes.length-1;0<=e;e--){var m=d.attributes[e].nodeName;var k=d.attributes[e].nodeValue;-1!==m.indexOf(":")&&(h.push({name:m,value:k}),d.removeAttribute(m))}e=0;for(m=h.length;e'+c),c=c.replace(/_dt_b_namespace_token_/g,":"),c=c.replace(/xmlns:NS[\d]+="" NS[\d]+:/g,""));c=c.replace(/<([^<>]*?) xmlns=""([^<>]*?)>/g,"<$1 $2>");a.file(b,c)}})}function r(a,b,d){var c=a.createElement(b);d&&(d.attr&&f(c).attr(d.attr),d.children&&f.each(d.children,function(a,b){c.appendChild(b)}),null!==d.text&&d.text!==w&&c.appendChild(a.createTextNode(d.text))); +return c}function L(a,b){var d=a.header[b].length;a.footer&&a.footer[b].length>d&&(d=a.footer[b].length);for(var c=0,f=a.body.length;cd&&(d=e);if(401*a[1]?!0:!1};try{var C=new XMLSerializer,y}catch(a){}var F={"_rels/.rels":'', +"xl/_rels/workbook.xml.rels":'',"[Content_Types].xml":'', +"xl/workbook.xml":'', +"xl/worksheets/sheet1.xml":'',"xl/styles.xml":''}, +K=[{match:/^\-?\d+\.\d%$/,style:60,fmt:function(a){return a/100}},{match:/^\-?\d+\.?\d*%$/,style:56,fmt:function(a){return a/100}},{match:/^\-?\$[\d,]+.?\d*$/,style:57},{match:/^\-?£[\d,]+.?\d*$/,style:58},{match:/^\-?€[\d,]+.?\d*$/,style:59},{match:/^\-?\d+$/,style:65},{match:/^\-?\d+\.\d{2}$/,style:66},{match:/^\([\d,]+\)$/,style:61,fmt:function(a){return-1*a.replace(/[\(\)]/g,"")}},{match:/^\([\d,]+\.\d{2}\)$/,style:62,fmt:function(a){return-1*a.replace(/[\(\)]/g,"")}},{match:/^\-?[\d,]+$/,style:63}, +{match:/^\-?[\d,]+\.\d{2}$/,style:64}];v.ext.buttons.copyHtml5={className:"buttons-copy buttons-html5",text:function(a){return a.i18n("buttons.copy","Copy")},action:function(a,b,d,c){this.processing(!0);var g=this;a=I(b,c);var e=b.buttons.exportInfo(c),h=H(c),m=a.str;d=f("
").css({height:1,width:1,overflow:"hidden",position:"fixed",top:0,left:0});e.title&&(m=e.title+h+h+m);e.messageTop&&(m=e.messageTop+h+h+m);e.messageBottom&&(m=m+h+h+e.messageBottom);c.customize&&(m=c.customize(m,c,b));c=f("",h.noCloneChecked=!!e.cloneNode(!0).lastChild.defaultValue}();var be=r.documentElement,we=/^key/,Te=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Ce=/^([^.]*)(?:\.(.+)|)/;function Ee(){return!0}function ke(){return!1}function Se(){try{return r.activeElement}catch(e){}}function De(e,t,n,r,i,o){var a,s;if("object"==typeof t){"string"!=typeof n&&(r=r||n,n=void 0);for(s in t)De(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=ke;else if(!i)return e;return 1===o&&(a=i,(i=function(e){return w().off(e),a.apply(this,arguments)}).guid=a.guid||(a.guid=w.guid++)),e.each(function(){w.event.add(this,t,i,r,n)})}w.event={global:{},add:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,y=J.get(e);if(y){n.handler&&(n=(o=n).handler,i=o.selector),i&&w.find.matchesSelector(be,i),n.guid||(n.guid=w.guid++),(u=y.events)||(u=y.events={}),(a=y.handle)||(a=y.handle=function(t){return"undefined"!=typeof w&&w.event.triggered!==t.type?w.event.dispatch.apply(e,arguments):void 0}),l=(t=(t||"").match(M)||[""]).length;while(l--)d=g=(s=Ce.exec(t[l])||[])[1],h=(s[2]||"").split(".").sort(),d&&(f=w.event.special[d]||{},d=(i?f.delegateType:f.bindType)||d,f=w.event.special[d]||{},c=w.extend({type:d,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&w.expr.match.needsContext.test(i),namespace:h.join(".")},o),(p=u[d])||((p=u[d]=[]).delegateCount=0,f.setup&&!1!==f.setup.call(e,r,h,a)||e.addEventListener&&e.addEventListener(d,a)),f.add&&(f.add.call(e,c),c.handler.guid||(c.handler.guid=n.guid)),i?p.splice(p.delegateCount++,0,c):p.push(c),w.event.global[d]=!0)}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,y=J.hasData(e)&&J.get(e);if(y&&(u=y.events)){l=(t=(t||"").match(M)||[""]).length;while(l--)if(s=Ce.exec(t[l])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){f=w.event.special[d]||{},p=u[d=(r?f.delegateType:f.bindType)||d]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=p.length;while(o--)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));a&&!p.length&&(f.teardown&&!1!==f.teardown.call(e,h,y.handle)||w.removeEvent(e,d,y.handle),delete u[d])}else for(d in u)w.event.remove(e,d+t[l],n,r,!0);w.isEmptyObject(u)&&J.remove(e,"handle events")}},dispatch:function(e){var t=w.event.fix(e),n,r,i,o,a,s,u=new Array(arguments.length),l=(J.get(this,"events")||{})[t.type]||[],c=w.event.special[t.type]||{};for(u[0]=t,n=1;n=1))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&("click"!==e.type||!0!==l.disabled)){for(o=[],a={},n=0;n-1:w.find(i,this,null,[l]).length),a[i]&&o.push(r);o.length&&s.push({elem:l,handlers:o})}return l=this,u\x20\t\r\n\f]*)[^>]*)\/>/gi,Ae=/\s*$/g;function Le(e,t){return N(e,"table")&&N(11!==t.nodeType?t:t.firstChild,"tr")?w(e).children("tbody")[0]||e:e}function He(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function Oe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Pe(e,t){var n,r,i,o,a,s,u,l;if(1===t.nodeType){if(J.hasData(e)&&(o=J.access(e),a=J.set(t,o),l=o.events)){delete a.handle,a.events={};for(i in l)for(n=0,r=l[i].length;n1&&"string"==typeof y&&!h.checkClone&&je.test(y))return e.each(function(i){var o=e.eq(i);v&&(t[0]=y.call(this,i,o.html())),Re(o,t,n,r)});if(p&&(i=xe(t,e[0].ownerDocument,!1,e,r),o=i.firstChild,1===i.childNodes.length&&(i=o),o||r)){for(u=(s=w.map(ye(i,"script"),He)).length;f")},clone:function(e,t,n){var r,i,o,a,s=e.cloneNode(!0),u=w.contains(e.ownerDocument,e);if(!(h.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||w.isXMLDoc(e)))for(a=ye(s),r=0,i=(o=ye(e)).length;r0&&ve(a,!u&&ye(e,"script")),s},cleanData:function(e){for(var t,n,r,i=w.event.special,o=0;void 0!==(n=e[o]);o++)if(Y(n)){if(t=n[J.expando]){if(t.events)for(r in t.events)i[r]?w.event.remove(n,r):w.removeEvent(n,r,t.handle);n[J.expando]=void 0}n[K.expando]&&(n[K.expando]=void 0)}}}),w.fn.extend({detach:function(e){return Ie(this,e,!0)},remove:function(e){return Ie(this,e)},text:function(e){return z(this,function(e){return void 0===e?w.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)})},null,e,arguments.length)},append:function(){return Re(this,arguments,function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||Le(this,e).appendChild(e)})},prepend:function(){return Re(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Le(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return Re(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return Re(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(w.cleanData(ye(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return w.clone(this,e,t)})},html:function(e){return z(this,function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!Ae.test(e)&&!ge[(de.exec(e)||["",""])[1].toLowerCase()]){e=w.htmlPrefilter(e);try{for(;n=0&&(u+=Math.max(0,Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-o-u-s-.5))),u}function et(e,t,n){var r=$e(e),i=Fe(e,t,r),o="border-box"===w.css(e,"boxSizing",!1,r),a=o;if(We.test(i)){if(!n)return i;i="auto"}return a=a&&(h.boxSizingReliable()||i===e.style[t]),("auto"===i||!parseFloat(i)&&"inline"===w.css(e,"display",!1,r))&&(i=e["offset"+t[0].toUpperCase()+t.slice(1)],a=!0),(i=parseFloat(i)||0)+Ze(e,t,n||(o?"border":"content"),a,r,i)+"px"}w.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Fe(e,"opacity");return""===n?"1":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var i,o,a,s=G(t),u=Xe.test(t),l=e.style;if(u||(t=Je(s)),a=w.cssHooks[t]||w.cssHooks[s],void 0===n)return a&&"get"in a&&void 0!==(i=a.get(e,!1,r))?i:l[t];"string"==(o=typeof n)&&(i=ie.exec(n))&&i[1]&&(n=ue(e,t,i),o="number"),null!=n&&n===n&&("number"===o&&(n+=i&&i[3]||(w.cssNumber[s]?"":"px")),h.clearCloneStyle||""!==n||0!==t.indexOf("background")||(l[t]="inherit"),a&&"set"in a&&void 0===(n=a.set(e,n,r))||(u?l.setProperty(t,n):l[t]=n))}},css:function(e,t,n,r){var i,o,a,s=G(t);return Xe.test(t)||(t=Je(s)),(a=w.cssHooks[t]||w.cssHooks[s])&&"get"in a&&(i=a.get(e,!0,n)),void 0===i&&(i=Fe(e,t,r)),"normal"===i&&t in Ve&&(i=Ve[t]),""===n||n?(o=parseFloat(i),!0===n||isFinite(o)?o||0:i):i}}),w.each(["height","width"],function(e,t){w.cssHooks[t]={get:function(e,n,r){if(n)return!ze.test(w.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?et(e,t,r):se(e,Ue,function(){return et(e,t,r)})},set:function(e,n,r){var i,o=$e(e),a="border-box"===w.css(e,"boxSizing",!1,o),s=r&&Ze(e,t,r,a,o);return a&&h.scrollboxSize()===o.position&&(s-=Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-parseFloat(o[t])-Ze(e,t,"border",!1,o)-.5)),s&&(i=ie.exec(n))&&"px"!==(i[3]||"px")&&(e.style[t]=n,n=w.css(e,t)),Ke(e,n,s)}}}),w.cssHooks.marginLeft=_e(h.reliableMarginLeft,function(e,t){if(t)return(parseFloat(Fe(e,"marginLeft"))||e.getBoundingClientRect().left-se(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),w.each({margin:"",padding:"",border:"Width"},function(e,t){w.cssHooks[e+t]={expand:function(n){for(var r=0,i={},o="string"==typeof n?n.split(" "):[n];r<4;r++)i[e+oe[r]+t]=o[r]||o[r-2]||o[0];return i}},"margin"!==e&&(w.cssHooks[e+t].set=Ke)}),w.fn.extend({css:function(e,t){return z(this,function(e,t,n){var r,i,o={},a=0;if(Array.isArray(t)){for(r=$e(e),i=t.length;a1)}});function tt(e,t,n,r,i){return new tt.prototype.init(e,t,n,r,i)}w.Tween=tt,tt.prototype={constructor:tt,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||w.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(w.cssNumber[n]?"":"px")},cur:function(){var e=tt.propHooks[this.prop];return e&&e.get?e.get(this):tt.propHooks._default.get(this)},run:function(e){var t,n=tt.propHooks[this.prop];return this.options.duration?this.pos=t=w.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):tt.propHooks._default.set(this),this}},tt.prototype.init.prototype=tt.prototype,tt.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=w.css(e.elem,e.prop,""))&&"auto"!==t?t:0},set:function(e){w.fx.step[e.prop]?w.fx.step[e.prop](e):1!==e.elem.nodeType||null==e.elem.style[w.cssProps[e.prop]]&&!w.cssHooks[e.prop]?e.elem[e.prop]=e.now:w.style(e.elem,e.prop,e.now+e.unit)}}},tt.propHooks.scrollTop=tt.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},w.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},w.fx=tt.prototype.init,w.fx.step={};var nt,rt,it=/^(?:toggle|show|hide)$/,ot=/queueHooks$/;function at(){rt&&(!1===r.hidden&&e.requestAnimationFrame?e.requestAnimationFrame(at):e.setTimeout(at,w.fx.interval),w.fx.tick())}function st(){return e.setTimeout(function(){nt=void 0}),nt=Date.now()}function ut(e,t){var n,r=0,i={height:e};for(t=t?1:0;r<4;r+=2-t)i["margin"+(n=oe[r])]=i["padding"+n]=e;return t&&(i.opacity=i.width=e),i}function lt(e,t,n){for(var r,i=(pt.tweeners[t]||[]).concat(pt.tweeners["*"]),o=0,a=i.length;o1)},removeAttr:function(e){return this.each(function(){w.removeAttr(this,e)})}}),w.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return"undefined"==typeof e.getAttribute?w.prop(e,t,n):(1===o&&w.isXMLDoc(e)||(i=w.attrHooks[t.toLowerCase()]||(w.expr.match.bool.test(t)?dt:void 0)),void 0!==n?null===n?void w.removeAttr(e,t):i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:(e.setAttribute(t,n+""),n):i&&"get"in i&&null!==(r=i.get(e,t))?r:null==(r=w.find.attr(e,t))?void 0:r)},attrHooks:{type:{set:function(e,t){if(!h.radioValue&&"radio"===t&&N(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},removeAttr:function(e,t){var n,r=0,i=t&&t.match(M);if(i&&1===e.nodeType)while(n=i[r++])e.removeAttribute(n)}}),dt={set:function(e,t,n){return!1===t?w.removeAttr(e,n):e.setAttribute(n,n),n}},w.each(w.expr.match.bool.source.match(/\w+/g),function(e,t){var n=ht[t]||w.find.attr;ht[t]=function(e,t,r){var i,o,a=t.toLowerCase();return r||(o=ht[a],ht[a]=i,i=null!=n(e,t,r)?a:null,ht[a]=o),i}});var gt=/^(?:input|select|textarea|button)$/i,yt=/^(?:a|area)$/i;w.fn.extend({prop:function(e,t){return z(this,w.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[w.propFix[e]||e]})}}),w.extend({prop:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&w.isXMLDoc(e)||(t=w.propFix[t]||t,i=w.propHooks[t]),void 0!==n?i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=w.find.attr(e,"tabindex");return t?parseInt(t,10):gt.test(e.nodeName)||yt.test(e.nodeName)&&e.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),h.optSelected||(w.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),w.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){w.propFix[this.toLowerCase()]=this});function vt(e){return(e.match(M)||[]).join(" ")}function mt(e){return e.getAttribute&&e.getAttribute("class")||""}function xt(e){return Array.isArray(e)?e:"string"==typeof e?e.match(M)||[]:[]}w.fn.extend({addClass:function(e){var t,n,r,i,o,a,s,u=0;if(g(e))return this.each(function(t){w(this).addClass(e.call(this,t,mt(this)))});if((t=xt(e)).length)while(n=this[u++])if(i=mt(n),r=1===n.nodeType&&" "+vt(i)+" "){a=0;while(o=t[a++])r.indexOf(" "+o+" ")<0&&(r+=o+" ");i!==(s=vt(r))&&n.setAttribute("class",s)}return this},removeClass:function(e){var t,n,r,i,o,a,s,u=0;if(g(e))return this.each(function(t){w(this).removeClass(e.call(this,t,mt(this)))});if(!arguments.length)return this.attr("class","");if((t=xt(e)).length)while(n=this[u++])if(i=mt(n),r=1===n.nodeType&&" "+vt(i)+" "){a=0;while(o=t[a++])while(r.indexOf(" "+o+" ")>-1)r=r.replace(" "+o+" "," ");i!==(s=vt(r))&&n.setAttribute("class",s)}return this},toggleClass:function(e,t){var n=typeof e,r="string"===n||Array.isArray(e);return"boolean"==typeof t&&r?t?this.addClass(e):this.removeClass(e):g(e)?this.each(function(n){w(this).toggleClass(e.call(this,n,mt(this),t),t)}):this.each(function(){var t,i,o,a;if(r){i=0,o=w(this),a=xt(e);while(t=a[i++])o.hasClass(t)?o.removeClass(t):o.addClass(t)}else void 0!==e&&"boolean"!==n||((t=mt(this))&&J.set(this,"__className__",t),this.setAttribute&&this.setAttribute("class",t||!1===e?"":J.get(this,"__className__")||""))})},hasClass:function(e){var t,n,r=0;t=" "+e+" ";while(n=this[r++])if(1===n.nodeType&&(" "+vt(mt(n))+" ").indexOf(t)>-1)return!0;return!1}});var bt=/\r/g;w.fn.extend({val:function(e){var t,n,r,i=this[0];{if(arguments.length)return r=g(e),this.each(function(n){var i;1===this.nodeType&&(null==(i=r?e.call(this,n,w(this).val()):e)?i="":"number"==typeof i?i+="":Array.isArray(i)&&(i=w.map(i,function(e){return null==e?"":e+""})),(t=w.valHooks[this.type]||w.valHooks[this.nodeName.toLowerCase()])&&"set"in t&&void 0!==t.set(this,i,"value")||(this.value=i))});if(i)return(t=w.valHooks[i.type]||w.valHooks[i.nodeName.toLowerCase()])&&"get"in t&&void 0!==(n=t.get(i,"value"))?n:"string"==typeof(n=i.value)?n.replace(bt,""):null==n?"":n}}}),w.extend({valHooks:{option:{get:function(e){var t=w.find.attr(e,"value");return null!=t?t:vt(w.text(e))}},select:{get:function(e){var t,n,r,i=e.options,o=e.selectedIndex,a="select-one"===e.type,s=a?null:[],u=a?o+1:i.length;for(r=o<0?u:a?o:0;r-1)&&(n=!0);return n||(e.selectedIndex=-1),o}}}}),w.each(["radio","checkbox"],function(){w.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=w.inArray(w(e).val(),t)>-1}},h.checkOn||(w.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})}),h.focusin="onfocusin"in e;var wt=/^(?:focusinfocus|focusoutblur)$/,Tt=function(e){e.stopPropagation()};w.extend(w.event,{trigger:function(t,n,i,o){var a,s,u,l,c,p,d,h,v=[i||r],m=f.call(t,"type")?t.type:t,x=f.call(t,"namespace")?t.namespace.split("."):[];if(s=h=u=i=i||r,3!==i.nodeType&&8!==i.nodeType&&!wt.test(m+w.event.triggered)&&(m.indexOf(".")>-1&&(m=(x=m.split(".")).shift(),x.sort()),c=m.indexOf(":")<0&&"on"+m,t=t[w.expando]?t:new w.Event(m,"object"==typeof t&&t),t.isTrigger=o?2:3,t.namespace=x.join("."),t.rnamespace=t.namespace?new RegExp("(^|\\.)"+x.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=void 0,t.target||(t.target=i),n=null==n?[t]:w.makeArray(n,[t]),d=w.event.special[m]||{},o||!d.trigger||!1!==d.trigger.apply(i,n))){if(!o&&!d.noBubble&&!y(i)){for(l=d.delegateType||m,wt.test(l+m)||(s=s.parentNode);s;s=s.parentNode)v.push(s),u=s;u===(i.ownerDocument||r)&&v.push(u.defaultView||u.parentWindow||e)}a=0;while((s=v[a++])&&!t.isPropagationStopped())h=s,t.type=a>1?l:d.bindType||m,(p=(J.get(s,"events")||{})[t.type]&&J.get(s,"handle"))&&p.apply(s,n),(p=c&&s[c])&&p.apply&&Y(s)&&(t.result=p.apply(s,n),!1===t.result&&t.preventDefault());return t.type=m,o||t.isDefaultPrevented()||d._default&&!1!==d._default.apply(v.pop(),n)||!Y(i)||c&&g(i[m])&&!y(i)&&((u=i[c])&&(i[c]=null),w.event.triggered=m,t.isPropagationStopped()&&h.addEventListener(m,Tt),i[m](),t.isPropagationStopped()&&h.removeEventListener(m,Tt),w.event.triggered=void 0,u&&(i[c]=u)),t.result}},simulate:function(e,t,n){var r=w.extend(new w.Event,n,{type:e,isSimulated:!0});w.event.trigger(r,null,t)}}),w.fn.extend({trigger:function(e,t){return this.each(function(){w.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];if(n)return w.event.trigger(e,t,n,!0)}}),h.focusin||w.each({focus:"focusin",blur:"focusout"},function(e,t){var n=function(e){w.event.simulate(t,e.target,w.event.fix(e))};w.event.special[t]={setup:function(){var r=this.ownerDocument||this,i=J.access(r,t);i||r.addEventListener(e,n,!0),J.access(r,t,(i||0)+1)},teardown:function(){var r=this.ownerDocument||this,i=J.access(r,t)-1;i?J.access(r,t,i):(r.removeEventListener(e,n,!0),J.remove(r,t))}}});var Ct=e.location,Et=Date.now(),kt=/\?/;w.parseXML=function(t){var n;if(!t||"string"!=typeof t)return null;try{n=(new e.DOMParser).parseFromString(t,"text/xml")}catch(e){n=void 0}return n&&!n.getElementsByTagName("parsererror").length||w.error("Invalid XML: "+t),n};var St=/\[\]$/,Dt=/\r?\n/g,Nt=/^(?:submit|button|image|reset|file)$/i,At=/^(?:input|select|textarea|keygen)/i;function jt(e,t,n,r){var i;if(Array.isArray(t))w.each(t,function(t,i){n||St.test(e)?r(e,i):jt(e+"["+("object"==typeof i&&null!=i?t:"")+"]",i,n,r)});else if(n||"object"!==x(t))r(e,t);else for(i in t)jt(e+"["+i+"]",t[i],n,r)}w.param=function(e,t){var n,r=[],i=function(e,t){var n=g(t)?t():t;r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==n?"":n)};if(Array.isArray(e)||e.jquery&&!w.isPlainObject(e))w.each(e,function(){i(this.name,this.value)});else for(n in e)jt(n,e[n],t,i);return r.join("&")},w.fn.extend({serialize:function(){return w.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=w.prop(this,"elements");return e?w.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!w(this).is(":disabled")&&At.test(this.nodeName)&&!Nt.test(e)&&(this.checked||!pe.test(e))}).map(function(e,t){var n=w(this).val();return null==n?null:Array.isArray(n)?w.map(n,function(e){return{name:t.name,value:e.replace(Dt,"\r\n")}}):{name:t.name,value:n.replace(Dt,"\r\n")}}).get()}});var qt=/%20/g,Lt=/#.*$/,Ht=/([?&])_=[^&]*/,Ot=/^(.*?):[ \t]*([^\r\n]*)$/gm,Pt=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Mt=/^(?:GET|HEAD)$/,Rt=/^\/\//,It={},Wt={},$t="*/".concat("*"),Bt=r.createElement("a");Bt.href=Ct.href;function Ft(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(M)||[];if(g(n))while(r=o[i++])"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function _t(e,t,n,r){var i={},o=e===Wt;function a(s){var u;return i[s]=!0,w.each(e[s]||[],function(e,s){var l=s(t,n,r);return"string"!=typeof l||o||i[l]?o?!(u=l):void 0:(t.dataTypes.unshift(l),a(l),!1)}),u}return a(t.dataTypes[0])||!i["*"]&&a("*")}function zt(e,t){var n,r,i=w.ajaxSettings.flatOptions||{};for(n in t)void 0!==t[n]&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&w.extend(!0,e,r),e}function Xt(e,t,n){var r,i,o,a,s=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),void 0===r&&(r=e.mimeType||t.getResponseHeader("Content-Type"));if(r)for(i in s)if(s[i]&&s[i].test(r)){u.unshift(i);break}if(u[0]in n)o=u[0];else{for(i in n){if(!u[0]||e.converters[i+" "+u[0]]){o=i;break}a||(a=i)}o=o||a}if(o)return o!==u[0]&&u.unshift(o),n[o]}function Ut(e,t,n,r){var i,o,a,s,u,l={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)l[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!u&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u=o,o=c.shift())if("*"===o)o=u;else if("*"!==u&&u!==o){if(!(a=l[u+" "+o]||l["* "+o]))for(i in l)if((s=i.split(" "))[1]===o&&(a=l[u+" "+s[0]]||l["* "+s[0]])){!0===a?a=l[i]:!0!==l[i]&&(o=s[0],c.unshift(s[1]));break}if(!0!==a)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(e){return{state:"parsererror",error:a?e:"No conversion from "+u+" to "+o}}}return{state:"success",data:t}}w.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Ct.href,type:"GET",isLocal:Pt.test(Ct.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":$t,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":w.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?zt(zt(e,w.ajaxSettings),t):zt(w.ajaxSettings,e)},ajaxPrefilter:Ft(It),ajaxTransport:Ft(Wt),ajax:function(t,n){"object"==typeof t&&(n=t,t=void 0),n=n||{};var i,o,a,s,u,l,c,f,p,d,h=w.ajaxSetup({},n),g=h.context||h,y=h.context&&(g.nodeType||g.jquery)?w(g):w.event,v=w.Deferred(),m=w.Callbacks("once memory"),x=h.statusCode||{},b={},T={},C="canceled",E={readyState:0,getResponseHeader:function(e){var t;if(c){if(!s){s={};while(t=Ot.exec(a))s[t[1].toLowerCase()]=t[2]}t=s[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return c?a:null},setRequestHeader:function(e,t){return null==c&&(e=T[e.toLowerCase()]=T[e.toLowerCase()]||e,b[e]=t),this},overrideMimeType:function(e){return null==c&&(h.mimeType=e),this},statusCode:function(e){var t;if(e)if(c)E.always(e[E.status]);else for(t in e)x[t]=[x[t],e[t]];return this},abort:function(e){var t=e||C;return i&&i.abort(t),k(0,t),this}};if(v.promise(E),h.url=((t||h.url||Ct.href)+"").replace(Rt,Ct.protocol+"//"),h.type=n.method||n.type||h.method||h.type,h.dataTypes=(h.dataType||"*").toLowerCase().match(M)||[""],null==h.crossDomain){l=r.createElement("a");try{l.href=h.url,l.href=l.href,h.crossDomain=Bt.protocol+"//"+Bt.host!=l.protocol+"//"+l.host}catch(e){h.crossDomain=!0}}if(h.data&&h.processData&&"string"!=typeof h.data&&(h.data=w.param(h.data,h.traditional)),_t(It,h,n,E),c)return E;(f=w.event&&h.global)&&0==w.active++&&w.event.trigger("ajaxStart"),h.type=h.type.toUpperCase(),h.hasContent=!Mt.test(h.type),o=h.url.replace(Lt,""),h.hasContent?h.data&&h.processData&&0===(h.contentType||"").indexOf("application/x-www-form-urlencoded")&&(h.data=h.data.replace(qt,"+")):(d=h.url.slice(o.length),h.data&&(h.processData||"string"==typeof h.data)&&(o+=(kt.test(o)?"&":"?")+h.data,delete h.data),!1===h.cache&&(o=o.replace(Ht,"$1"),d=(kt.test(o)?"&":"?")+"_="+Et+++d),h.url=o+d),h.ifModified&&(w.lastModified[o]&&E.setRequestHeader("If-Modified-Since",w.lastModified[o]),w.etag[o]&&E.setRequestHeader("If-None-Match",w.etag[o])),(h.data&&h.hasContent&&!1!==h.contentType||n.contentType)&&E.setRequestHeader("Content-Type",h.contentType),E.setRequestHeader("Accept",h.dataTypes[0]&&h.accepts[h.dataTypes[0]]?h.accepts[h.dataTypes[0]]+("*"!==h.dataTypes[0]?", "+$t+"; q=0.01":""):h.accepts["*"]);for(p in h.headers)E.setRequestHeader(p,h.headers[p]);if(h.beforeSend&&(!1===h.beforeSend.call(g,E,h)||c))return E.abort();if(C="abort",m.add(h.complete),E.done(h.success),E.fail(h.error),i=_t(Wt,h,n,E)){if(E.readyState=1,f&&y.trigger("ajaxSend",[E,h]),c)return E;h.async&&h.timeout>0&&(u=e.setTimeout(function(){E.abort("timeout")},h.timeout));try{c=!1,i.send(b,k)}catch(e){if(c)throw e;k(-1,e)}}else k(-1,"No Transport");function k(t,n,r,s){var l,p,d,b,T,C=n;c||(c=!0,u&&e.clearTimeout(u),i=void 0,a=s||"",E.readyState=t>0?4:0,l=t>=200&&t<300||304===t,r&&(b=Xt(h,E,r)),b=Ut(h,b,E,l),l?(h.ifModified&&((T=E.getResponseHeader("Last-Modified"))&&(w.lastModified[o]=T),(T=E.getResponseHeader("etag"))&&(w.etag[o]=T)),204===t||"HEAD"===h.type?C="nocontent":304===t?C="notmodified":(C=b.state,p=b.data,l=!(d=b.error))):(d=C,!t&&C||(C="error",t<0&&(t=0))),E.status=t,E.statusText=(n||C)+"",l?v.resolveWith(g,[p,C,E]):v.rejectWith(g,[E,C,d]),E.statusCode(x),x=void 0,f&&y.trigger(l?"ajaxSuccess":"ajaxError",[E,h,l?p:d]),m.fireWith(g,[E,C]),f&&(y.trigger("ajaxComplete",[E,h]),--w.active||w.event.trigger("ajaxStop")))}return E},getJSON:function(e,t,n){return w.get(e,t,n,"json")},getScript:function(e,t){return w.get(e,void 0,t,"script")}}),w.each(["get","post"],function(e,t){w[t]=function(e,n,r,i){return g(n)&&(i=i||r,r=n,n=void 0),w.ajax(w.extend({url:e,type:t,dataType:i,data:n,success:r},w.isPlainObject(e)&&e))}}),w._evalUrl=function(e){return w.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,"throws":!0})},w.fn.extend({wrapAll:function(e){var t;return this[0]&&(g(e)&&(e=e.call(this[0])),t=w(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstElementChild)e=e.firstElementChild;return e}).append(this)),this},wrapInner:function(e){return g(e)?this.each(function(t){w(this).wrapInner(e.call(this,t))}):this.each(function(){var t=w(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=g(e);return this.each(function(n){w(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(e){return this.parent(e).not("body").each(function(){w(this).replaceWith(this.childNodes)}),this}}),w.expr.pseudos.hidden=function(e){return!w.expr.pseudos.visible(e)},w.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},w.ajaxSettings.xhr=function(){try{return new e.XMLHttpRequest}catch(e){}};var Vt={0:200,1223:204},Gt=w.ajaxSettings.xhr();h.cors=!!Gt&&"withCredentials"in Gt,h.ajax=Gt=!!Gt,w.ajaxTransport(function(t){var n,r;if(h.cors||Gt&&!t.crossDomain)return{send:function(i,o){var a,s=t.xhr();if(s.open(t.type,t.url,t.async,t.username,t.password),t.xhrFields)for(a in t.xhrFields)s[a]=t.xhrFields[a];t.mimeType&&s.overrideMimeType&&s.overrideMimeType(t.mimeType),t.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");for(a in i)s.setRequestHeader(a,i[a]);n=function(e){return function(){n&&(n=r=s.onload=s.onerror=s.onabort=s.ontimeout=s.onreadystatechange=null,"abort"===e?s.abort():"error"===e?"number"!=typeof s.status?o(0,"error"):o(s.status,s.statusText):o(Vt[s.status]||s.status,s.statusText,"text"!==(s.responseType||"text")||"string"!=typeof s.responseText?{binary:s.response}:{text:s.responseText},s.getAllResponseHeaders()))}},s.onload=n(),r=s.onerror=s.ontimeout=n("error"),void 0!==s.onabort?s.onabort=r:s.onreadystatechange=function(){4===s.readyState&&e.setTimeout(function(){n&&r()})},n=n("abort");try{s.send(t.hasContent&&t.data||null)}catch(e){if(n)throw e}},abort:function(){n&&n()}}}),w.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),w.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return w.globalEval(e),e}}}),w.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),w.ajaxTransport("script",function(e){if(e.crossDomain){var t,n;return{send:function(i,o){t=w(" \ No newline at end of file + diff --git a/pandora_console/operation/agentes/ehorus.php b/pandora_console/operation/agentes/ehorus.php index 51fca3a801..2091aa5d60 100644 --- a/pandora_console/operation/agentes/ehorus.php +++ b/pandora_console/operation/agentes/ehorus.php @@ -58,6 +58,12 @@ $curl_timeout = $config['ehorus_req_timeout']; $base_url = 'https://'.$hostname.':'.$port; +// If user login is enabled, fetch user and pass from user info +if ($config['ehorus_user_level_conf']) { + $user = $user_info['ehorus_user_level_user']; + $password = io_safe_output(io_output_password($user_info['ehorus_user_level_pass'])); +} + // Get the login auth token $login_path = '/api/login'; $body = [ diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index 30705e7267..88b1d1a247 100755 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -1,17 +1,32 @@ id = 'agent_details_main'; -$table_agent->width = '95%'; -$table_agent->cellspacing = 0; -$table_agent->cellpadding = 0; -$table_agent->class = 'databox filters'; -$table_agent->style[0] = 'width: 16px; text-align:center; padding: 0px;'; -$table_agent->style[5] = 'width: 16px; text-align:center; padding: 0px;'; -$table_agent->styleTable = 'padding:0px;'; -$table_agent->data = []; -$data = []; +$alive_animation = agents_get_status_animation( + agents_get_interval_status($agent, false) +); -$agent_name = ui_print_agent_name($agent['id_agente'], true, 500, 'font-size: medium;font-weight:bold', true); +/* + * START: TABLE AGENT BUILD. + */ + +$agent_name = ui_print_agent_name( + $agent['id_agente'], + true, + 500, + 'font-size: medium;font-weight:bold', + true +); $in_planned_downtime = db_get_sql( 'SELECT executed FROM tplanned_downtime INNER JOIN tplanned_downtime_agents @@ -80,7 +104,6 @@ $in_planned_downtime = db_get_sql( WHERE tplanned_downtime_agents.id_agent = '.$agent['id_agente'].' AND tplanned_downtime.executed = 1' ); - if ($agent['disabled']) { if ($in_planned_downtime) { $agent_name = ''.$agent_name.ui_print_help_tip(__('Disabled'), true); @@ -98,24 +121,35 @@ if ($agent['disabled']) { } if ($in_planned_downtime && !$agent['disabled'] && !$agent['quiet']) { - $agent_name .= ''.' '.ui_print_help_tip(__('Agent in planned downtime'), true, 'images/minireloj-16.png').''; -} else if (($in_planned_downtime && !$agent['disabled']) || ($in_planned_downtime && !$agent['quiet'])) { - $agent_name .= ' '.ui_print_help_tip(__('Agent in planned downtime'), true, 'images/minireloj-16.png').''; + $agent_name .= ' '.ui_print_help_tip( + __('Agent in planned downtime'), + true, + 'images/minireloj-16.png' + ).''; +} else if (($in_planned_downtime && !$agent['disabled']) + || ($in_planned_downtime && !$agent['quiet']) +) { + $agent_name .= ' '.ui_print_help_tip( + __('Agent in planned downtime'), + true, + 'images/minireloj-16.png' + ).''; } +$table_agent_header = '
'; +$table_agent_header .= $agent_name; +$table_agent_header .= '
'; +$table_agent_header .= '
'; if (!$config['show_group_name']) { - $data[0] = ui_print_group_icon($agent['id_grupo'], true); -} else { - $data[0] = ''; + $table_agent_header .= ui_print_group_icon( + $agent['id_grupo'], + true, + 'groups_small', + 'padding-right: 6px;' + ); } -$table_agent->cellstyle[count($table_agent->data)][0] = 'width: 16px; text-align:center; padding: 0px;'; - -$data[2] = $agent_name; -$table_agent->colspan[count($table_agent->data)][2] = 3; - -$table_agent->cellstyle[count($table_agent->data)][2] = 'width: 100px; word-break: break-all;'; - +$table_agent_header .= '
'; $status_img = agents_detail_view_status_img( $agent['critical_count'], @@ -124,39 +158,36 @@ $status_img = agents_detail_view_status_img( $agent['total_count'], $agent['notinit_count'] ); -$data[2] .= '  '.$status_img; -$table_agent->data[] = $data; -$table_agent->rowclass[] = ''; +$table_agent_header .= '
'.$status_img.'
'; +// Fixed width non interactive charts. +$status_chart_width = 180; +$graph_width = 180; -$data = []; +$table_agent_graph = '
'; +$table_agent_graph .= graph_agent_status( + $id_agente, + $graph_width, + $graph_width, + true, + false, + false, + true +); +$table_agent_graph .= '
'; -// $data[0] = reporting_tiny_stats ($agent, true, 'agent', '
'); -// $table_agent->rowspan[count($table_agent->data)][0] = 6; -// Fixed width non interactive charts -$status_chart_width = 150; -$graph_width = 150; - -$data[0] = '
'; -$data[0] .= '
'; -$data[0] .= graph_agent_status($id_agente, $graph_width, 120, true); -$data[0] .= '
'; -$data[0] .= '
'.reporting_tiny_stats($agent, true); -$data[0] .= ui_print_help_tip(__('Agent statuses are re-calculated by the server, they are not shown in real time.'), true); -$data[0] .= '
'; -$table_agent->rowspan[count($table_agent->data)][0] = 6; -$table_agent->colspan[count($table_agent->data)][0] = 2; -$table_agent->cellstyle[count($table_agent->data)][0] = 'width: 150px; text-align:center; padding: 0px; vertical-align: top;'; - - -$data[2] = ui_print_os_icon($agent['id_os'], false, true, true, false, false, false, ['title' => __('OS').': '.get_os_name($agent['id_os'])]); -$table_agent->cellstyle[count($table_agent->data)][2] = 'width: 16px; text-align: right; padding: 0px;'; -$data[3] = empty($agent['os_version']) ? get_os_name((int) $agent['id_os']) : $agent['os_version']; -$table_agent->colspan[count($table_agent->data)][3] = 2; - -$table_agent->data[] = $data; -$table_agent->rowclass[] = ''; +$table_agent_os = '

'.ui_print_os_icon( + $agent['id_os'], + false, + true, + true, + false, + false, + false, + ['title' => __('OS').': '.get_os_name($agent['id_os'])] +); +$table_agent_os .= (empty($agent['os_version'])) ? get_os_name((int) $agent['id_os']) : $agent['os_version'].'

'; $addresses = agents_get_addresses($id_agente); $address = agents_get_address($id_agente); @@ -168,55 +199,95 @@ foreach ($addresses as $k => $add) { } if (!empty($address)) { - $data = []; - $data[2] = html_print_image('images/world.png', true, ['title' => __('IP address')]); - $table_agent->cellstyle[count($table_agent->data)][2] = 'width: 16px; text-align: right; padding: 0px;'; - $data[3] = ''; - $data[3] .= empty($address) ? ''.__('N/A').'' : $address; - $data[3] .= ''; - $table_agent->colspan[count($table_agent->data)][3] = 2; - $table_agent->data[] = $data; - $table_agent->rowclass[] = ''; + $table_agent_ip = '

'.html_print_image('images/world.png', true, ['title' => __('IP address')]); + $table_agent_ip .= ''; + $table_agent_ip .= empty($address) ? ''.__('N/A').'' : $address; + $table_agent_ip .= '

'; } -$data = []; -$data[2] = html_print_image('images/version.png', true, ['title' => __('Agent Version')]); -$table_agent->cellstyle[count($table_agent->data)][2] = 'width: 16px; text-align: right; padding: 0px;'; -$data[3] = ''; -$data[3] .= empty($agent['agent_version']) ? ''.__('N/A').'' : $agent['agent_version']; -$data[3] .= ''; -$table_agent->colspan[count($table_agent->data)][3] = 2; -$table_agent->data[] = $data; -$table_agent->rowclass[] = ''; +$table_agent_version = '

'.html_print_image('images/version.png', true, ['title' => __('Agent Version')]); +$table_agent_version .= ''; +$table_agent_version .= empty($agent['agent_version']) ? ''.__('N/A').'' : $agent['agent_version']; +$table_agent_version .= '

'; -$data = []; -$data[2] = html_print_image( +$table_agent_description = '

'.html_print_image( 'images/default_list.png', true, ['title' => __('Description')] ); -$table_agent->cellstyle[count($table_agent->data)][2] = 'width: 16px; text-align: right; padding: 0px;'; -$data[3] = ''; -$data[3] .= empty($agent['comentarios']) ? ''.__('N/A').'' : $agent['comentarios']; -$data[3] .= ''; -$table_agent->colspan[count($table_agent->data)][3] = 2; +$table_agent_description .= ''; +$table_agent_description .= empty($agent['comentarios']) ? ''.__('N/A').'' : $agent['comentarios']; +$table_agent_description .= '

'; -$table_agent->data[] = $data; -$table_agent->rowclass[] = ''; +$table_agent_count_modules = reporting_tiny_stats( + $agent, + true, + 'agent', + // Useless. + ':', + true +); + +$has_remote_conf = enterprise_hook( + 'config_agents_has_remote_configuration', + [$agent['id_agente']] +); + +if ($has_remote_conf) { + $remote_cfg = '

'.html_print_image('images/remote_configuration.png', true); + $remote_cfg .= __('Remote configuration enabled').'

'; +} else { + $remote_cfg = ''; +} + + + +// $table_agent_count_modules .= ui_print_help_tip(__('Agent statuses are re-calculated by the server, they are not shown in real time.'), true); +$table_agent = ' +
+ '.$table_agent_header.' +
+
+
+ '.$table_agent_graph.' +
+ '.$table_agent_count_modules.' +
+
+
+ '.$alive_animation.$table_agent_os.$table_agent_ip.$table_agent_version.$table_agent_description.$remote_cfg.' +
+
'; + +/* + * END: TABLE AGENT BUILD. + */ + +/* + *START: TABLE CONTACT BUILD. + */ -// END: TABLE AGENT BUILD -// START: TABLE CONTACT BUILD $table_contact = new stdClass(); $table_contact->id = 'agent_contact_main'; $table_contact->width = '100%'; $table_contact->cellspacing = 0; $table_contact->cellpadding = 0; -$table_contact->class = 'databox data'; -$table_contact->style[0] = 'width: 30%;height:30px;'; +$table_contact->class = 'white_table white_table_no_border'; +$table_contact->style[0] = 'width: 30%;'; $table_contact->style[1] = 'width: 70%;'; +$table_contact->headstyle[1] = 'padding-top:6px; padding-bottom:6px;padding-right: 10px;'; $table_contact->head[0] = ' '.__('Agent contact').''; -$table_contact->head_colspan[0] = 2; + +$buttons_refresh_agent_view = '
'; +$buttons_refresh_agent_view .= ''.html_print_image('images/refresh.png', true, ['title' => __('Refresh data'), 'alt' => '']).'
'; +if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) { + $buttons_refresh_agent_view .= ''.html_print_image('images/target.png', true, ['title' => __('Force remote checks'), 'alt' => '']).''; +} + +$buttons_refresh_agent_view .= '
'; + +$table_contact->head[1] = $buttons_refresh_agent_view; $data = []; $data[0] = ''.__('Interval').''; @@ -236,140 +307,150 @@ if ($agent['ultimo_contacto_remoto'] == '01-01-1970 00:00:00') { $table_contact->data[] = $data; + +$data = []; $data[0] = ''.__('Next contact').''; $progress = agents_get_next_contact($id_agente); -$data[1] = progress_bar($progress, 200, 20, '', 1, false, '#666666'); +$data[1] = ui_progress( + $progress, + '100%', + 1.8, + '#BBB', + true, + floor(($agent['intervalo'] * (100 - $progress) / 100)).' s', + [ + 'page' => 'operation/agentes/ver_agente', + 'interval' => (100 / $agent['intervalo']), + 'data' => [ + 'id_agente' => $id_agente, + 'refresh_contact' => 1, + ], + + ] +); if ($progress > 100) { - $data[1] .= clippy_context_help('agent_out_of_limits'); + $data[0] .= clippy_context_help('agent_out_of_limits'); } $table_contact->data[] = $data; -// END: TABLE CONTACT BUILD -// START: TABLE DATA BUILD -$table_data = new stdClass(); -$table_data->id = 'agent_data_main'; -$table_data->width = '100%'; -$table_data->styleTable = 'height:180px'; -$table_data->cellspacing = 0; -$table_data->cellpadding = 0; -$table_data->class = 'databox data'; -$table_data->style[0] = 'width: 30%;'; -$table_data->style[1] = 'width: 40%;'; - -$table_data->head[0] = ' '.__('Agent info').''; -$table_data->head_colspan[0] = 3; - $data = []; $data[0] = ''.__('Group').''; $data[1] = ''.groups_get_name($agent['id_grupo']).''; -// ACCESS RATE GRAPH -$access_agent = db_get_value_sql( - 'SELECT COUNT(id_agent) - FROM tagent_access - WHERE id_agent = '.$id_agente -); -if ($config['agentaccess'] && $access_agent > 0) { - $data[2] = '
- '.__('Agent access rate (24h)').''.graphic_agentaccess($id_agente, '95%', 100, SECONDS_1DAY, true).'
'; - $table_data->style[0] = 'width: 20%;'; - $table_data->style[1] = 'width: 30%;'; - $table_data->style[2] = 'width: 50%;'; - $table_data->rowspan[0][2] = 5; -} - -$table_data->data[] = $data; - -if (!empty($addresses)) { - $data = []; - $data[0] = ''.__('Other IP addresses').''; - $data[1] = '
'.implode('
', $addresses).'
'; - $table_data->data[] = $data; -} +$table_contact->data[] = $data; $data = []; -$data[0] = ''.__('Parent').''; -if ($agent['id_parent'] == 0) { +$data[0] = ''.__('Secondary groups').''; +$secondary_groups = enterprise_hook('agents_get_secondary_groups', [$id_agente]); +if (!$secondary_groups) { $data[1] = ''.__('N/A').''; } else { - $data[1] = ''.agents_get_alias($agent['id_parent']).''; + $secondary_links = []; + foreach ($secondary_groups['for_select'] as $id => $name) { + $secondary_links[] = ''.$name.''; + } + + $data[1] = implode(', ', $secondary_links); } -$table_data->data[] = $data; - -$has_remote_conf = enterprise_hook('config_agents_has_remote_configuration', [$agent['id_agente']]); +$table_contact->data[] = $data; if (enterprise_installed()) { $data = []; - $data[0] = ''.__('Remote configuration').''; - if (!$has_remote_conf) { - $data[1] = __('Disabled'); - } else { - $data[1] = __('Enabled'); - } - - $table_data->data[] = $data; - - $data = []; - $data[0] = ''.__('Secondary groups').''; - $secondary_groups = enterprise_hook('agents_get_secondary_groups', [$id_agente]); - if (!$secondary_groups) { + $data[0] = ''.__('Parent').''; + if ($agent['id_parent'] == 0) { $data[1] = ''.__('N/A').''; } else { - $secondary_links = []; - foreach ($secondary_groups['for_select'] as $id => $name) { - $secondary_links[] = ''.$name.''; - } - - $data[1] = implode(', ', $secondary_links); + $data[1] = ''.agents_get_alias($agent['id_parent']).''; } - $table_data->data[] = $data; + $table_contact->data[] = $data; } -if ($config['activate_gis'] || $agent['url_address'] != '') { - $data = []; - // Position Information - if ($config['activate_gis']) { - $dataPositionAgent = gis_get_data_last_position_agent($agent['id_agente']); +/* + * END: TABLE CONTACT BUILD + */ - $data[0] = ''.__('Position (Long, Lat)').''; +/* + * START: TABLE DATA BUILD + */ - if ($dataPositionAgent === false) { - $data[1] = __('There is no GIS data.'); +$table_data = new stdClass(); +$table_data->id = 'agent_data_main'; +$table_data->width = '100%'; +$table_data->cellspacing = 0; +$table_data->cellpadding = 0; +$table_data->class = 'box-shadow white_table white_table_droppable align-top'; +$table_data->style = array_fill(0, 3, 'width: 25%;'); + +$table_data->head[0] = html_print_image( + 'images/arrow_down_green.png', + true, + $options +); +$table_data->head[0] .= ' '.__('Agent info').''; +$table_data->head_colspan[0] = 4; + +// Gis and url address. +$data_opcional = []; +// Position Information. +if ($config['activate_gis']) { + $data_opcional[] = ''.__('Position (Long, Lat)').''; + $dataPositionAgent = gis_get_data_last_position_agent( + $agent['id_agente'] + ); + + if ($dataPositionAgent === false) { + $data_opcional[] = __('There is no GIS data.'); + } else { + $data_opcional[] = ''; + if ($dataPositionAgent['description'] != '') { + $data_opcional[] .= $dataPositionAgent['description']; } else { - $data[1] = ''; - if ($dataPositionAgent['description'] != '') { - $data[1] .= $dataPositionAgent['description']; - } else { - $data[1] .= $dataPositionAgent['stored_longitude'].', '.$dataPositionAgent['stored_latitude']; - } - - $data[1] .= ''; + $data_opcional[] .= $dataPositionAgent['stored_longitude'].', '.$dataPositionAgent['stored_latitude']; } - $table_data->data[] = $data; + $data_opcional[] .= ''; } - // If the url description is setted + array_push($data_opcional); +} + +// If the url description is set. +if ($agent['url_address'] != '') { + // $data_opcional = []; + $data_opcional[] = ''.__('Url address').''; if ($agent['url_address'] != '') { - $data = []; - $data[0] = ''.__('Url address').''; - $data[1] = ''.$agent['url_address'].''; - $table_data->data[] = $data; + $data_opcional[] = ''.$agent['url_address'].''; } } -// Timezone Offset -if ($agent['timezone_offset'] != 0) { - $data = []; - $data[0] = ''.__('Timezone Offset').''; - $data[1] = $agent['timezone_offset']; - $table->data[] = $data; + +// Other IP address and timezone offset. +if (!empty($addresses)) { + // $data_opcional = []; + $data_opcional[] = ''.__('Other IP addresses').''; + if (!empty($addresses)) { + $data_opcional[] = '
'.implode('
', $addresses).'
'; + } } -// Custom fields +// Timezone Offset. +if ($agent['timezone_offset'] != 0) { + $data_opcional[] = ''.__('Timezone Offset').''; + if ($agent['timezone_offset'] != 0) { + $data_opcional[] = $agent['timezone_offset']; + } +} + + +$data_opcional = array_chunk($data_opcional, 4); +foreach ($data_opcional as $key => $value) { + $table_data->data[] = $data_opcional[$key]; +} + +// Custom fields. $fields = db_get_all_rows_filter( 'tagent_custom_fields', ['display_on_front' => 1] @@ -378,6 +459,7 @@ if ($fields === false) { $fields = []; } +$custom_fields = []; foreach ($fields as $field) { $data = []; $data[0] = ''.$field['name'].ui_print_help_tip(__('Custom field'), true).''; @@ -398,17 +480,75 @@ foreach ($fields as $field) { $data[1] = $custom_value[0]['description']; } - $table_data->data[] = $data; + $custom_fields[] = $data; } -// END: TABLE DATA BUILD -// START: TABLE INCIDENTS +$custom_fields_count = count($custom_fields); +for ($i = 0; $i < $custom_fields_count; $i++) { + $first_column = $custom_fields[$i]; + $j = ($i + 1); + $second_column = $custom_fields[$j]; + + if (is_array($second_column)) { + $columns = array_merge($first_column, $second_column); + } else { + $columns = $first_column; + $filas = count($table_data->data); + $table_data->colspan[$filas][1] = 3; + } + + $table_data->data[] = $columns; + + $i++; +} + +/* + * END: TABLE DATA BUILD + */ + +/* + * START: ACCESS RATE GRAPH + */ + +$access_agent = db_get_value_sql( + 'SELECT COUNT(id_agent) + FROM tagent_access + WHERE id_agent = '.$id_agente +); + +if ($config['agentaccess'] && $access_agent > 0) { + $table_access_rate = '
+
'.html_print_image( + 'images/arrow_down_green.png', + true + ).''.__('Agent access rate (24h)').'
+
+'.graphic_agentaccess( + $id_agente, + '95%', + 100, + SECONDS_1DAY, + true + ).'
+
'; +} + +/* + * END: ACCESS RATE GRAPH + */ + +/* + * START: TABLE INCIDENTS + */ + $last_incident = db_get_row_sql( - " - SELECT * FROM tincidencia - WHERE estado IN (0,1) - AND id_agent = $id_agente - ORDER BY actualizacion DESC" + sprintf( + 'SELECT * FROM tincidencia + WHERE estado IN (0,1) + AND id_agent = %d + ORDER BY actualizacion DESC', + $id_agente + ) ); if ($last_incident != false) { @@ -416,36 +556,35 @@ if ($last_incident != false) { $table_incident->width = '100%'; $table_incident->cellspacing = 0; $table_incident->cellpadding = 0; - $table_incident->class = 'databox'; - $table_incident->style[0] = 'width: 30%;'; - $table_incident->style[1] = 'width: 70%;'; + $table_incident->class = 'white_table'; + $table_incident->style = array_fill(0, 3, 'width: 25%;'); - $table_incident->head[0] = ' '.''.__('Active incident on this agent').''.''; - $table_incident->head_colspan[0] = 2; + $table_incident->head[0] = ' '.__('Active incident on this agent').''; + $table_incident->head_colspan[0] = 4; $data = []; $data[0] = ''.__('Author').''; $data[1] = $last_incident['id_creator']; + $data[2] = ''.__('Timestamp').''; + $data[3] = $last_incident['inicio']; $table_incident->data[] = $data; $data = []; $data[0] = ''.__('Title').''; $data[1] = ''.$last_incident['titulo'].''; - $table_incident->data[] = $data; - - $data = []; - $data[0] = ''.__('Timestamp').''; - $data[1] = $last_incident['inicio']; - $table_incident->data[] = $data; - - $data = []; - $data[0] = ''.__('Priority').''; - $data[1] = incidents_print_priority_img($last_incident['prioridad'], true); + $data[2] = ''.__('Priority').''; + $data[3] = incidents_print_priority_img($last_incident['prioridad'], true); $table_incident->data[] = $data; } -// END: TABLE INCIDENTS -// START: TABLE INTERFACES +/* + * END: TABLE INCIDENTS + */ + +/* + * START: TABLE INTERFACES + */ + $network_interfaces_by_agents = agents_get_network_interfaces([$agent]); $network_interfaces = []; @@ -456,8 +595,8 @@ if (!empty($network_interfaces_by_agents) && !empty($network_interfaces_by_agent if (!empty($network_interfaces)) { $table_interface = new stdClass(); $table_interface->id = 'agent_interface_info'; - $table_interface->class = 'databox data'; - $table_interface->width = '98%'; + $table_interface->class = 'info_table'; + $table_interface->width = '100%'; $table_interface->style = []; $table_interface->style['interface_status'] = 'width: 30px;padding-top:0px;padding-bottom:0px;'; $table_interface->style['interface_graph'] = 'width: 20px;padding-top:0px;padding-bottom:0px;'; @@ -476,12 +615,8 @@ if (!empty($network_interfaces)) { $table_interface->head = []; $options = [ 'class' => 'closed', - 'style' => 'vertical-align:righ; cursor:pointer;', + 'style' => 'cursor:pointer;', ]; - $table_interface->head[0] = html_print_image('images/graphmenu_arrow.png', true, $options).'  '; - $table_interface->head[0] .= ''.__('Interface information').' (SNMP)'; - $table_interface->head_colspan = []; - $table_interface->head_colspan[0] = 8; $table_interface->data = []; $event_text_cont = 0; @@ -499,7 +634,14 @@ if (!empty($network_interfaces)) { $params_json = json_encode($params); $params_encoded = base64_encode($params_json); $win_handle = dechex(crc32($interface['status_module_id'].$interface_name)); - $graph_link = "".html_print_image('images/chart_curve.png', true, ['title' => __('Interface traffic')]).''; + $graph_link = ""; + $graph_link .= html_print_image( + 'images/chart_curve.png', + true, + ['title' => __('Interface traffic')] + ).''; } else { $graph_link = ''; } @@ -522,9 +664,9 @@ if (!empty($network_interfaces)) { $status_condition = ' AND (estado = 0 OR estado = 1) '; $unixtime = (get_system_time() - SECONDS_1DAY); - // last hour + // Last hour. $time_condition = 'AND (utimestamp > '.$unixtime.')'; - // Tags ACLS + // Tags ACLs. if ($id_group > 0 && in_array(0, $user_groups_ids)) { $group_array = (array) $id_group; } else { @@ -547,18 +689,16 @@ if (!empty($network_interfaces)) { $id_modules_array[] = $interface['status_module_id']; $unixtime = (get_system_time() - SECONDS_1DAY); - // last hour + // Last hour. $time_condition = 'WHERE (te.utimestamp > '.$unixtime.')'; $sqlEvents = sprintf( - ' - SELECT * + 'SELECT * FROM tevento te INNER JOIN tagente_estado tae ON te.id_agentmodule = tae.id_agente_modulo AND tae.id_agente_modulo IN (%s) - %s - ', + %s', implode(',', $id_modules_array), $time_condition ); @@ -600,69 +740,113 @@ if (!empty($network_interfaces)) { $table_interface->data[] = $data; } +} - // This javascript piece of code is used to make expandible the body of the table - ?> +/* + * END: TABLE INTERFACES + */ + + // This javascript piece of code is used to make expandible + // the body of the table. +?> - 0) { + $extra_class = 'h80p'; +} else { + $extra_class = ''; } -// END: TABLE INTERFACES -$table = new stdClass(); -$table->id = 'agent_details'; -$table->width = '100%'; -$table->cellspacing = 0; -$table->cellpadding = 0; -$table->class = 'agents'; -$table->style = array_fill(0, 3, 'vertical-align: top;'); +$table_events = '
+
'.html_print_image( + 'images/arrow_down_green.png', + true +).''.__('Events (24h)').'
+
+'.graph_graphic_agentevents( + $id_agente, + 100, + 45, + SECONDS_1DAY, + '', + true, + true +).'
+
'; -$data = []; -$data[0][0] = html_print_table($table_agent, true); -$data[0][0] .= '
- '.''.'
'.__('Events (24h)').'

'.graph_graphic_agentevents($id_agente, 100, 45, SECONDS_1DAY, '', true, true).'
'; +/* + * EVENTS TABLE END. + */ -$table->style[0] = 'width:40%; vertical-align:top;'; -$data[0][1] = html_print_table($table_contact, true); -$data[0][1] .= empty($table_data->data) ? '' : '
'.html_print_table($table_data, true); -$data[0][1] .= !isset($table_incident) ? '' : '
'.html_print_table($table_incident, true); +$agent_contact = html_print_table($table_contact, true); -$table->rowspan[1][0] = 0; +$agent_info = empty($table_data->data) ? '' : html_print_table($table_data, true); -$data[0][2] = '
'; -$data[0][2] .= ''.html_print_image('images/refresh.png', true, ['border' => '0', 'title' => __('Refresh data'), 'alt' => '']).'
'; -if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) { - $data[0][2] .= ''.html_print_image('images/target.png', true, ['border' => '0', 'title' => __('Force remote checks'), 'alt' => '']).''; +$agent_incidents = !isset($table_incident) ? '' : html_print_table($table_incident, true); + +echo '
+
'.$table_agent.'
+
'.$agent_contact.'
+
'.$agent_info; + +// Show both graphs, events and access rate. +if ($table_access_rate) { + echo '
'.$table_access_rate.$table_events.'
'; +} else { + echo '
'.$table_events.'
'; } -$data[0][2] .= '
'; - -$table->data = $data; -$table->rowclass[] = ''; - -$table->cellstyle[1][0] = 'text-align:center;'; - -html_print_table($table); -$data2[1][0] = !isset($table_interface) ? '' : html_print_table($table_interface, true); -$table->data = $data2; -$table->styleTable = ''; -html_print_table($table); - -unset($table); +echo $agent_incidents; +if (isset($table_interface)) { + ui_toggle( + html_print_table($table_interface, true), + ''.__('Interface information (SNMP)').'' + ); +} diff --git a/pandora_console/operation/agentes/estado_monitores.php b/pandora_console/operation/agentes/estado_monitores.php index b311885acb..d50ed3a0fb 100755 --- a/pandora_console/operation/agentes/estado_monitores.php +++ b/pandora_console/operation/agentes/estado_monitores.php @@ -1,17 +1,32 @@ ".ui_print_truncate_text(modules_get_agentmodule_name($id_module), 'module_medium', true, true, true, '[…]').''; + &id_agente=".$id_agent.'&tab=module&edit_module=1&id_agent_module='.$id_module."'>".ui_print_truncate_text(modules_get_agentmodule_name($id_module), 'module_medium', true, true, true, '[…]').''; $table_relations->data[] = $data; } @@ -132,33 +147,46 @@ $sort_field = get_parameter('sort_field', 'name'); $sort = get_parameter('sort', 'up'); -echo "

"; - -echo ui_print_help_tip(__('To see the list of modules paginated, enable this option in the Styles Configuration.'), true).__('Full list of monitors').' '.reporting_tiny_stats($agent, true, 'modules'); - $modules_not_init = agents_monitor_notinit($id_agente); if (!empty($modules_not_init)) { - echo clippy_context_help('modules_not_init'); + $help_not_init = clippy_context_help('modules_not_init'); +} else { + $help_not_init = ''; } -echo '

'; - - ob_start(); -print_form_filter_monitors($id_agente, $status_filter_monitor, $status_text_monitor, $status_hierachy_mode); +print_form_filter_monitors( + $id_agente, + $status_filter_monitor, + $status_text_monitor, + $status_hierachy_mode +); -echo "
".html_print_image('images/spinner.gif', true).'
'; -echo "
".'
'; +echo '
'; $html_toggle = ob_get_clean(); + ui_toggle( $html_toggle, - __('List of modules'), + __('List of modules').$help_not_init.ui_print_help_tip( + __('To see the list of modules paginated, enable this option in the Styles Configuration.'), + true + ).reporting_tiny_stats( + $agent, + true, + 'modules', + ':', + true + ), 'status_monitor_agent', - false + false, + false, + '', + 'white_table_graph_content no-padding-imp' ); + ?> class = 'databox filters'; + $table->class = 'info_table'; + $table->id = 'module_filter_agent_view'; + $table->styleTable = 'border-radius: 0;padding: 0;margin: 0;'; $table->width = '100%'; $table->style[0] = 'font-weight: bold;'; $table->style[2] = 'font-weight: bold;'; $table->style[4] = 'font-weight: bold;'; + $table->style[6] = 'font-weight: bold;'; + $table->style[6] = 'min-width: 150px;'; $table->data[0][0] = html_print_input_hidden('filter_monitors', 1, true); $table->data[0][0] .= html_print_input_hidden('monitors_change_filter', 1, true); $table->data[0][0] .= __('Status:'); @@ -488,9 +532,26 @@ function print_form_filter_monitors( true ); - $table->data[0][3] = html_print_input_text('status_text_monitor', $status_text_monitor, '', 30, 100, true); + $table->data[0][3] = html_print_input_text( + 'status_text_monitor', + $status_text_monitor, + '', + '', + 100, + true + ); $table->data[0][4] = __('Module group'); - $rows = db_get_all_rows_sql("SELECT * FROM tmodule_group where id_mg in (SELECT id_module_group from tagente_modulo where id_agente = $id_agent ) ORDER BY name"); + $rows = db_get_all_rows_sql( + sprintf( + 'SELECT * + FROM tmodule_group + WHERE id_mg IN (SELECT id_module_group + FROM tagente_modulo + WHERE id_agente = %d ) + ORDER BY name', + $id_agent + ) + ); $rows_select[-1] = __('All'); if (!empty($rows)) { @@ -499,11 +560,43 @@ function print_form_filter_monitors( } } - $table->data[0][5] = html_print_select($rows_select, 'status_module_group', $status_module_group, '', '', 0, true); - $table->data[0][6] = __('Show in hierachy mode'); - $table->data[0][6] .= html_print_checkbox('status_hierachy_mode', '', false, true, false, 'onChange=change_module_filter();'); - $table->data[0][7] = html_print_button(__('Filter'), 'filter', false, 'filter_modules();', 'class="sub search"', true); - $table->data[0][8] = ' '.html_print_button(__('Reset'), 'filter', false, 'reset_filter_modules();', 'class="sub upd" style="margin-top:0px;"', true); + $table->data[0][5] = html_print_select( + $rows_select, + 'status_module_group', + $status_module_group, + '', + '', + 0, + true + ); + $table->data[0][6] = '
'; + $table->data[0][6] .= __('Show in hierachy mode'); + $table->data[0][6] .= html_print_switch( + [ + 'name' => 'status_hierachy_mode', + 'value' => $all_events_24h, + 'onchange' => 'change_module_filter()', + 'id' => 'checkbox-status_hierachy_mode', + 'style' => 'margin-left: 1em;', + ] + ); + $table->data[0][6] .= '
'; + $table->data[0][7] = html_print_button( + __('Filter'), + 'filter', + false, + 'filter_modules();', + 'class="sub search"', + true + ); + $table->data[0][8] = html_print_button( + __('Reset'), + 'filter', + false, + 'reset_filter_modules();', + 'class="sub upd" style="margin-top:0px;"', + true + ); $form_text .= html_print_table($table, true); $filter_hidden = false; @@ -514,4 +607,3 @@ function print_form_filter_monitors( echo $form_text; } - diff --git a/pandora_console/operation/agentes/graphs.php b/pandora_console/operation/agentes/graphs.php index 628c25d3ba..79ff02b021 100644 --- a/pandora_console/operation/agentes/graphs.php +++ b/pandora_console/operation/agentes/graphs.php @@ -255,7 +255,7 @@ $htmlForm .= html_print_button( $htmlForm .= '
'; $htmlForm .= ''; -ui_toggle($htmlForm, __('Filter graphs'), __('Toggle filter(s)'), false); +ui_toggle($htmlForm, __('Filter graphs'), __('Toggle filter(s)'), '', false); $utime = get_system_time(); $current = date('Y-m-d', $utime); diff --git a/pandora_console/operation/agentes/group_view.php b/pandora_console/operation/agentes/group_view.php index 080e7ffbaf..c8d6b562a8 100644 --- a/pandora_console/operation/agentes/group_view.php +++ b/pandora_console/operation/agentes/group_view.php @@ -156,16 +156,16 @@ echo '"; echo "'; echo "'; diff --git a/pandora_console/operation/agentes/interface_traffic_graph_win.php b/pandora_console/operation/agentes/interface_traffic_graph_win.php index e00ed0d254..08070a459d 100644 --- a/pandora_console/operation/agentes/interface_traffic_graph_win.php +++ b/pandora_console/operation/agentes/interface_traffic_graph_win.php @@ -185,7 +185,7 @@ if ($date > $now) { $table->style[0] = 'text-align:left;'; $table->style[1] = 'text-align:left;'; $table->styleTable = 'margin-bottom: 20px;'; - $table->class = 'events_show_more_table'; + $table->class = 'table_modal_alternate'; $data = []; $data[0] = __('Refresh time'); @@ -214,7 +214,7 @@ if ($date > $now) { $data = []; $data[0] = __('Show percentil'); - $data[1] = html_print_checkbox('show_percentil', 1, (bool) $show_percentil, true); + $data[1] = html_print_checkbox_switch('show_percentil', 1, (bool) $show_percentil, true); $table->data[] = $data; $table->rowclass[] = ''; @@ -225,7 +225,7 @@ if ($date > $now) { 'images/tip.png', true ); - $data[1] = html_print_checkbox('fullscale', 1, (bool) $fullscale, true); + $data[1] = html_print_checkbox_switch('fullscale', 1, (bool) $fullscale, true); $table->data[] = $data; $table->rowclass[] = ''; @@ -263,7 +263,7 @@ if ($date > $now) { echo '
'.html_print_image('images/arrow_down_green.png', true, ['class' => 'module_graph_menu_arrow', 'float' => 'left'], false, false, true).' - '.__('Graph configuration menu').ui_print_help_icon('graphs', true, $config['homeurl'], 'images/help_g.png', true).' + '.__('Graph configuration menu').' '.html_print_image('images/config.png', true, ['float' => 'right'], false, false, true).'
diff --git a/pandora_console/operation/agentes/stat_win.php b/pandora_console/operation/agentes/stat_win.php index ef4a448360..18f2fea040 100644 --- a/pandora_console/operation/agentes/stat_win.php +++ b/pandora_console/operation/agentes/stat_win.php @@ -72,6 +72,7 @@ $alias = db_get_value('alias', 'tagente', 'id_agente', $id_agent); <?php echo __('%s Graph', get_product_name()).' ('.$alias.' - '.$label; ?>) + @@ -238,7 +239,7 @@ $alias = db_get_value('alias', 'tagente', 'id_agente', $id_agent); $table->style[0] = 'text-align:left;'; $table->style[1] = 'text-align:left;'; $table->styleTable = 'margin-bottom: 20px;'; - $table->class = 'events_show_more_table'; + $table->class = 'table_modal_alternate'; $data = []; $data[0] = __('Refresh time'); @@ -304,7 +305,7 @@ $alias = db_get_value('alias', 'tagente', 'id_agente', $id_agent); } } - $data[1] = html_print_checkbox( + $data[1] = html_print_checkbox_switch( 'draw_events', 1, (bool) $draw_events, @@ -323,14 +324,14 @@ $alias = db_get_value('alias', 'tagente', 'id_agente', $id_agent); $data = []; $data[0] = __('Show alerts'); - $data[1] = html_print_checkbox('draw_alerts', 1, (bool) $draw_alerts, true); + $data[1] = html_print_checkbox_switch('draw_alerts', 1, (bool) $draw_alerts, true); $table->data[] = $data; $table->rowclass[] = ''; /* $data = array(); $data[0] = __('Show event graph'); - $data[1] = html_print_checkbox ("show_events_graph", 1, (bool) $show_events_graph, true); + $data[1] = html_print_checkbox_switch ("show_events_graph", 1, (bool) $show_events_graph, true); $table->data[] = $data; $table->rowclass[] = ''; */ @@ -340,25 +341,25 @@ $alias = db_get_value('alias', 'tagente', 'id_agente', $id_agent); case 'sparse': $data = []; $data[0] = __('Show percentil'); - $data[1] = html_print_checkbox('show_percentil', 1, (bool) $show_percentil, true); + $data[1] = html_print_checkbox_switch('show_percentil', 1, (bool) $show_percentil, true); $table->data[] = $data; $table->rowclass[] = ''; $data = []; $data[0] = __('Time compare (Overlapped)'); - $data[1] = html_print_checkbox('time_compare_overlapped', 1, (bool) $time_compare_overlapped, true); + $data[1] = html_print_checkbox_switch('time_compare_overlapped', 1, (bool) $time_compare_overlapped, true); $table->data[] = $data; $table->rowclass[] = ''; $data = []; $data[0] = __('Time compare (Separated)'); - $data[1] = html_print_checkbox('time_compare_separated', 1, (bool) $time_compare_separated, true); + $data[1] = html_print_checkbox_switch('time_compare_separated', 1, (bool) $time_compare_separated, true); $table->data[] = $data; $table->rowclass[] = ''; $data = []; $data[0] = __('Show unknown graph'); - $data[1] = html_print_checkbox('unknown_graph', 1, (bool) $unknown_graph, true); + $data[1] = html_print_checkbox_switch('unknown_graph', 1, (bool) $unknown_graph, true); $table->data[] = $data; $table->rowclass[] = ''; break; @@ -366,7 +367,7 @@ $alias = db_get_value('alias', 'tagente', 'id_agente', $id_agent); $data = []; $data[0] = __('Show full scale graph (TIP)'); - $data[1] = html_print_checkbox( + $data[1] = html_print_checkbox_switch( 'fullscale', 1, (bool) $fullscale, @@ -402,7 +403,7 @@ $alias = db_get_value('alias', 'tagente', 'id_agente', $id_agent); echo '
'.html_print_image('images/arrow_down_green.png', true, ['class' => 'module_graph_menu_arrow', 'float' => 'left'], false, false, true).' - '.__('Graph configuration menu').ui_print_help_icon('graphs', true, $config['homeurl'], 'images/help_g.png', true).' + '.__('Graph configuration menu').' '.html_print_image('images/config.png', true, ['float' => 'right'], false, false, true).'
diff --git a/pandora_console/operation/agentes/status_events.php b/pandora_console/operation/agentes/status_events.php index 825a4c2c42..df30d75dda 100755 --- a/pandora_console/operation/agentes/status_events.php +++ b/pandora_console/operation/agentes/status_events.php @@ -20,12 +20,16 @@ if (!isset($id_agente)) { } require_once 'include/functions_events.php'; - +ui_require_css_file('events'); ui_toggle( - "
".html_print_image('images/spinner.gif', true).'
', + "
".html_print_image('images/spinner.gif', true).'
', __('Latest events for this agent'), __('Latest events for this agent'), - false + '', + false, + false, + '', + 'white_table_graph_content no-padding-imp' ); ?> diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 447baa3556..0f7257663a 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -421,7 +421,7 @@ if (!is_metaconsole()) { $table->data[0][5] = html_print_select($rows_select, 'modulegroup', $modulegroup, '', __('All'), -1, true, false, true, '', false, 'width: 120px;'); -$table->rowspan[0][6] = 2; +$table->rowspan[0][6] = 3; $table->data[0][6] = html_print_submit_button( __('Show'), 'uptbutton', @@ -705,13 +705,14 @@ if (is_metaconsole()) { html_print_table($table_custom_fields, true), __('Advanced Options'), '', + '', true, true ); $filters .= html_print_table($table, true); $filters .= ''; - ui_toggle($filters, __('Show Options'), '', false); + ui_toggle($filters, __('Show Options'), '', '', false); } else { $table->colspan[3][0] = 7; $table->cellstyle[3][0] = 'padding-left: 10px;'; @@ -722,8 +723,12 @@ if (is_metaconsole()) { ), __('Agent custom fields'), '', + '', true, - true + true, + '', + 'white-box-content', + 'white_table_graph' ); $filters .= html_print_table($table, true); @@ -1389,6 +1394,34 @@ if (!empty($result)) { true ); } + } else if ($row['estado'] == 3) { + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image( + STATUS_MODULE_UNKNOWN, + __('UNKNOWN').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), + true + ); + } else { + $data[6] = ui_print_status_image( + STATUS_MODULE_UNKNOWN, + __('UNKNOWN').': '.$row['datos'], + true + ); + } + } else if ($row['estado'] == 4) { + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image( + STATUS_MODULE_NO_DATA, + __('NO DATA').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), + true + ); + } else { + $data[6] = ui_print_status_image( + STATUS_MODULE_NO_DATA, + __('NO DATA').': '.$row['datos'], + true + ); + } } else { $last_status = modules_get_agentmodule_last_status( $row['id_agente_modulo'] diff --git a/pandora_console/operation/agentes/tactical.php b/pandora_console/operation/agentes/tactical.php index 9264cba0b3..1a54e84afc 100755 --- a/pandora_console/operation/agentes/tactical.php +++ b/pandora_console/operation/agentes/tactical.php @@ -116,13 +116,13 @@ if (!empty($all_data)) { } echo '
"; - echo "".$total_agent_critical.'%'; - echo "".$total_agent_warning.'%'; - echo "".$total_agent_ok.'%'; + echo "".$total_agent_critical.'%'; + echo "".$total_agent_warning.'%'; + echo "".$total_agent_ok.'%'; echo "".$total_agent_unknown.'%'; echo "".$total_not_init.'%'; echo '"; - echo "".$total_critical.'%'; - echo "".$total_warning.'%'; - echo "".$total_ok.'%'; + echo "".$total_critical.'%'; + echo "".$total_warning.'%'; + echo "".$total_ok.'%'; echo "".$total_unknown.'%'; echo "".$total_monitor_not_init.'%'; echo '
'; -echo ''; echo '
'; +echo ''; // --------------------------------------------------------------------- // The status horizontal bars (Global health, Monitor sanity... // --------------------------------------------------------------------- $table = new stdClass(); $table->width = '100%'; -$table->class = ''; +$table->class = 'info_table no-td-borders td-bg-white'; $table->cellpadding = 2; $table->cellspacing = 2; $table->border = 0; @@ -130,7 +130,6 @@ $table->head = []; $table->data = []; $table->style = []; -$table->head[0] = ''.__('Report of State').''; $stats = reporting_get_stats_indicators($data, 120, 10, false); $status = ''; foreach ($stats as $stat) { @@ -166,7 +165,13 @@ if ($is_admin) { $table->rowclass[] = ''; } -html_print_table($table); +ui_toggle( + html_print_table($table, true), + __('Report of State'), + '', + '', + false +); echo ''; // Left column @@ -187,7 +192,13 @@ if (check_acl($config['id_user'], 0, 'ER')) { } $events = events_print_event_table($event_filter, 10, '100%', true, false, true); - ui_toggle($events, __('Latest events'), false, false); + ui_toggle( + $events, + __('Latest events'), + '', + '', + false + ); } // --------------------------------------------------------------------- @@ -205,7 +216,15 @@ $out = '
'.__('Event graph by agent').''.html_print_image('images/spinner.gif', true, ['id' => 'spinner_graphic_event_group']).''; $out .= '
'; -echo $out; + + +ui_toggle( + $out, + __('Event graphs'), + '', + '', + false +); echo '
'; diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 46cfc69aec..5f7f29f916 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -37,6 +37,7 @@ require_once $config['homedir'].'/include/functions_users.php'; enterprise_include_once('include/functions_metaconsole.php'); ui_require_javascript_file('openlayers.pandora'); +ui_require_css_file('agent_view'); enterprise_include_once('operation/agentes/ver_agente.php'); @@ -61,6 +62,36 @@ if (is_ajax()) { $agent_alias = get_parameter('alias', ''); $agents_inserted = get_parameter('agents_inserted', []); $id_group = (int) get_parameter('id_group'); + + $refresh_contact = get_parameter('refresh_contact', 0); + + if ($refresh_contact) { + $id_agente = get_parameter('id_agente', 0); + if ($id_agente > 0) { + $d = db_get_row( + 'tagente', + 'id_agente', + $id_agente + ); + + $progress = agents_get_next_contact($id_agente); + $last_contact = floor(($d['intervalo'] * (100 - $progress) / 100)); + + if ($progress < 0 || $progress > 100) { + $progress = 100; + } + + echo json_encode( + [ + 'progress' => $progress, + 'last_contact' => $last_contact, + ] + ); + } + + return; + } + if ($get_agents_group_json) { $id_group = (int) get_parameter('id_group'); $recursion = (bool) get_parameter('recursion'); @@ -1260,38 +1291,47 @@ if (enterprise_installed() && $config['log_collector']) { // EHorus tab. if ($config['ehorus_enabled'] && !empty($config['ehorus_custom_field']) - && (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') || is_user_admin($config['id_user'])) + && (check_acl_one_of_groups( + $config['id_user'], + $all_groups, + 'AW' + ) || is_user_admin($config['id_user'])) ) { - $ehorus_agent_id = agents_get_agent_custom_field($id_agente, $config['ehorus_custom_field']); - if (!empty($ehorus_agent_id)) { - $tab_url = 'index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=ehorus&id_agente='.$id_agente; - $ehorus_tab['text'] = ''.html_print_image('images/ehorus/ehorus.png', true, [ 'title' => __('eHorus')]).''; + $user_info = users_get_user_by_id($config['id_user']); + if ($config['ehorus_user_level_conf'] && !$user_info['ehorus_user_level_enabled']) { + // If ehorus user configuration is enabled, and userr acces level is disabled do not show eHorus tab. + } else { + $ehorus_agent_id = agents_get_agent_custom_field($id_agente, $config['ehorus_custom_field']); + if (!empty($ehorus_agent_id)) { + $tab_url = 'index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=ehorus&id_agente='.$id_agente; + $ehorus_tab['text'] = ''.html_print_image('images/ehorus/ehorus.png', true, [ 'title' => __('eHorus')]).''; - // Hidden subtab layer. - $ehorus_tab['sub_menu'] = ''; + // Hidden subtab layer. + $ehorus_tab['sub_menu'] = ''; - $ehorus_tab['active'] = $tab == 'ehorus'; + $ehorus_tab['active'] = $tab == 'ehorus'; + } } } @@ -1331,6 +1371,7 @@ if (isset($ehorus_tab) && !empty($ehorus_tab)) { } // Tabs for extensions. +$tab_name_extensions = ''; foreach ($config['extensions'] as $extension) { if (isset($extension['extension_ope_tab']) && !isset($extension['extension_god_tab'])) { if (check_acl_one_of_groups($config['id_user'], $all_groups, $extension['extension_ope_tab']['acl'])) { @@ -1373,6 +1414,7 @@ foreach ($config['extensions'] as $extension) { $image = $extension['extension_ope_tab']['icon']; $name = $extension['extension_ope_tab']['name']; $id = $extension['extension_ope_tab']['id']; + $tab_name_extensions = $name; $id_extension = get_parameter('id_extension', ''); @@ -1395,15 +1437,82 @@ foreach ($config['extensions'] as $extension) { } switch ($tab) { - case 'wux_console_tab': - $help_header = 'wux_console_tab'; + case 'custom_fields': + $tab_name = 'Custom fields'; + break; + + case 'gis': + $tab_name = 'GIS data'; + break; + + case 'manage': + $tab_name = 'Manage'; break; case 'main': + $tab_name = 'Main'; $help_header = 'agent_'.$tab.'_tab'; break; + case 'data_view': + $tab_name = ''; + break; + + case 'alert': + $tab_name = 'Alerts'; + break; + + case 'inventory': + $tab_name = 'Inventory'; + break; + + case 'collection': + $tab_name = 'Collection'; + break; + + case 'policy': + $tab_name = 'Policies'; + break; + + case 'ux_console_tab': + $tab_name = 'UX Console'; + break; + + case 'wux_console_tab': + $tab_name = 'WUX Console'; + $help_header = 'wux_console_tab'; + break; + + case 'url_route_analyzer_tab': + $tab_name = 'URL Route Analyzer'; + break; + + case 'graphs'; + $tab_name = 'Graphs'; + break; + + case 'incident': + $tab_name = 'Incidents'; + break; + + case 'url_address': + $tab_name = 'Url address'; + break; + + case 'log_viewer': + $tab_name = 'Log viewer'; + break; + + case 'ehorus': + $tab_name = 'eHorus'; + break; + + case 'extension': + $tab_name = $tab_name_extensions; + break; + default: + $tab_name = ''; $help_header = ''; break; } @@ -1417,7 +1526,15 @@ ui_print_page_header( $onheader, false, '', - $config['item_title_size_text'] + $config['item_title_size_text'], + '', + ui_print_breadcrums( + [ + __('Monitoring'), + __('View'), + ''.$tab_name.'', + ] + ) ); @@ -1435,6 +1552,7 @@ switch ($tab) { break; case 'main': + default: include 'estado_generalagente.php'; echo ""; include 'estado_monitores.php'; diff --git a/pandora_console/operation/events/event_statistics.php b/pandora_console/operation/events/event_statistics.php index 437ec0f47c..a4a5b1632a 100644 --- a/pandora_console/operation/events/event_statistics.php +++ b/pandora_console/operation/events/event_statistics.php @@ -1,30 +1,48 @@ '; diff --git a/pandora_console/operation/events/events.build_query.php b/pandora_console/operation/events/events.build_query.php index 0d51282b36..da7451ff4c 100755 --- a/pandora_console/operation/events/events.build_query.php +++ b/pandora_console/operation/events/events.build_query.php @@ -148,41 +148,43 @@ switch ($status) { break; } - -$events_wi_cdata = db_get_all_rows_sql('SELECT id_evento,custom_data from tevento WHERE custom_data != ""'); -$count_events = 0; -$events_wi_cdata_id = 'OR id_evento IN ('; -if ($events_wi_cdata === false) { - $events_wi_cdata = []; -} - -foreach ($events_wi_cdata as $key => $value) { - $needle = base64_decode($value['custom_data']); - if (($needle != '') && ($search != '')) { - if (strpos(strtolower($needle), strtolower($search)) != false) { - $events_wi_cdata_id .= $value['id_evento']; - $count_events++; - } - } - - if ($value !== end($events_wi_cdata) && $count_events > 0) { - $events_wi_cdata_id .= ','; - $events_wi_cdata_id = str_replace(',,', ',', $events_wi_cdata_id); - } -} - -$events_wi_cdata_id .= ')'; - -$events_wi_cdata_id = str_replace(',)', ')', $events_wi_cdata_id); - -if ($count_events == 0) { - $events_wi_cdata_id = ''; -} - +/* + * Never use things like this. + * + * $events_wi_cdata = db_get_all_rows_sql('SELECT id_evento,custom_data from tevento WHERE custom_data != ""'); + * $count_events = 0; + * $events_wi_cdata_id = 'OR id_evento IN ('; + * if ($events_wi_cdata === false) { + * $events_wi_cdata = []; + * } + * + * foreach ($events_wi_cdata as $key => $value) { + * $needle = base64_decode($value['custom_data']); + * if (($needle != '') && ($search != '')) { + * if (strpos(strtolower($needle), strtolower($search)) != false) { + * $events_wi_cdata_id .= $value['id_evento']; + * $count_events++; + * } + * } + * + * if ($value !== end($events_wi_cdata) && $count_events > 0) { + * $events_wi_cdata_id .= ','; + * $events_wi_cdata_id = str_replace(',,', ',', $events_wi_cdata_id); + * } + * } + * + * $events_wi_cdata_id .= ')'; + * + * $events_wi_cdata_id = str_replace(',)', ')', $events_wi_cdata_id); + * + * if ($count_events == 0) { + * $events_wi_cdata_id = ''; + * } + */ if ($search != '') { $filter_resume['free_search'] = $search; - $sql_post .= " AND (evento LIKE '%".$search."%' OR id_evento LIKE '%$search%' ".$events_wi_cdata_id.')'; + $sql_post .= " AND (evento LIKE '%".$search."%' OR id_evento LIKE '%$search%' )"; } if ($event_type != '') { diff --git a/pandora_console/operation/events/events.build_table.php b/pandora_console/operation/events/events.build_table.php index 3e112f3fb8..a07ec2a703 100644 --- a/pandora_console/operation/events/events.build_table.php +++ b/pandora_console/operation/events/events.build_table.php @@ -29,7 +29,7 @@ $table->id = 'eventtable'; $table->cellpadding = 4; $table->cellspacing = 4; if (!isset($table->class)) { - $table->class = 'databox data'; + $table->class = 'info_table'; } $table->head = []; @@ -91,11 +91,11 @@ if ($group_rep == 2) { if ($res['event_type'] == 'alert_fired') { $table->rowstyle[$key] = 'background: #FFA631;'; } else if ($res['event_type'] == 'going_up_critical' || $res['event_type'] == 'going_down_critical') { - $table->rowstyle[$key] = 'background: #FC4444;'; + $table->rowstyle[$key] = 'background: #e63c52;'; } else if ($res['event_type'] == 'going_up_warning' || $res['event_type'] == 'going_down_warning') { - $table->rowstyle[$key] = 'background: #FAD403;'; + $table->rowstyle[$key] = 'background: #f3b200;'; } else if ($res['event_type'] == 'going_up_normal' || $res['event_type'] == 'going_down_normal') { - $table->rowstyle[$key] = 'background: #80BA27;'; + $table->rowstyle[$key] = 'background: #82b92e;'; } else if ($res['event_type'] == 'going_unknown') { $table->rowstyle[$key] = 'background: #B2B2B2;'; } @@ -990,12 +990,12 @@ if ($group_rep == 2) { html_print_button(__('Execute event response'), 'submit_event_response', false, 'execute_event_response(true);', 'class="sub next"'); echo "'; echo ''; - echo '