diff --git a/extras/build_rpm_rhel7.sh b/extras/build_rpm_rhel7.sh new file mode 100755 index 0000000000..3684bd42e5 --- /dev/null +++ b/extras/build_rpm_rhel7.sh @@ -0,0 +1,26 @@ +#!/bin/bash +source build_vars.sh + +if [ ! -d $RPMHOME/RPMS ]; then + mkdir -p $RPMHOME/RPMS || exit 1 +fi + +echo "Creating RPM packages in $RPMHOME/RPMS" + +# Console +rpmbuild -ba $CODEHOME/pandora_console/pandora_console.rhel7.spec || exit 1 + +# Server +#rpmbuild -ba $CODEHOME/pandora_server/pandora_server.rhel7.spec || exit 1 + +# Unix agent +#rpmbuild -ba $CODEHOME/pandora_agents/unix/pandora_agent.rhel7.spec || exit 1 + +# Enterprise console +rpmbuild -ba $PANDHOME_ENT/pandora_console/enterprise/pandora_console_enterprise.rhel7.spec || exit 1 + +# Enterprise server +#rpmbuild -ba $PANDHOME_ENT/pandora_server/PandoraFMS-Enterprise/pandora_server_enterprise.rhel7.spec || exit 1 + +exit 0 + diff --git a/extras/docker/build_and_push.sh b/extras/docker/build_and_push.sh index 980087cfe5..91e6fa15e5 100755 --- a/extras/docker/build_and_push.sh +++ b/extras/docker/build_and_push.sh @@ -1,3 +1,3 @@ #!/bin/bash -docker build --rm=true --build-arg BRANCH="develop" --build-arg DB_PASS="pandora" -t pandorafms/pandorafms:7 . && \ +docker build --rm=true --pull --no-cache --build-arg BRANCH="develop" --build-arg DB_PASS="pandora" -t pandorafms/pandorafms:7 . && \ docker push pandorafms/pandorafms:7 diff --git a/extras/pandora_update_version.sh b/extras/pandora_update_version.sh index 7d143f0f03..edab1affeb 100755 --- a/extras/pandora_update_version.sh +++ b/extras/pandora_update_version.sh @@ -26,9 +26,11 @@ $CODEHOME/pandora_server/pandora_server.spec \ $PANDHOME_ENT/pandora_console/enterprise/pandora_console_enterprise.spec \ $PANDHOME_ENT/pandora_server/PandoraFMS-Enterprise/pandora_server_enterprise.spec \ $CODEHOME/pandora_console/pandora_console.redhat.spec \ +$CODEHOME/pandora_console/pandora_console.rhel7.spec \ $CODEHOME/pandora_agents/unix/pandora_agent.redhat.spec \ $CODEHOME/pandora_server/pandora_server.redhat.spec \ $PANDHOME_ENT/pandora_console/enterprise/pandora_console_enterprise.redhat.spec \ +$PANDHOME_ENT/pandora_console/enterprise/pandora_console_enterprise.rhel7.spec \ $PANDHOME_ENT/pandora_server/PandoraFMS-Enterprise/pandora_server_enterprise.redhat.spec" DEBIAN_FILES="$CODEHOME/pandora_console/DEBIAN \ $CODEHOME/pandora_server/DEBIAN \ diff --git a/pandora_agents/pc/AIX/pandora_agent.conf b/pandora_agents/pc/AIX/pandora_agent.conf index 07054ee2e1..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.732, 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 9d8a49bb99..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.732, 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 c02e4647e1..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.732, 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 153113e070..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.732, 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 6ddeba7edc..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.732, 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 502317f893..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.732, 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 96b20ea7e3..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.732 +# 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 200ff9db97..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.732, 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 2002f4db65..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.732 +# 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 f9c19dbd06..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.732, 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 dc272a7a71..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.732 +# 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 5a466677d2..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.732 +# 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 170188cc6f..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.732 +# 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 aad04ca60d..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.732, 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 3ce7da3c7e..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.732, 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 0ed50c03e2..6db1d38c37 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.732-190322 +Version: 7.0NG.735-190607 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 4d75c27172..515b22c668 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.732-190322" +pandora_version="7.0NG.735-190607" 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 35202fcbe5..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.732, 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 c505d5f75e..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.732, 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 237bffb291..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.732, 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 5a65e0e095..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.732, 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 1394067390..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.732, 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 677615a47c..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.732, 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 89d5b46100..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.732, 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 3d531b1c05..0ad412a5ee 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.732'; -use constant AGENT_BUILD => '190322'; +use constant AGENT_VERSION => '7.0NG.735'; +use constant AGENT_BUILD => '190607'; # 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'}; @@ -662,6 +668,8 @@ sub parse_conf_modules($) { $module->{'ff_timeout'} = $1; } elsif ($line =~ /^\s*module_each_ff\s+(\S+)\s*$/) { $module->{'each_ff'} = $1; + } elsif ($line =~ /^\s*module_ff_type\s+(\d+)\s*$/) { + $module->{'ff_type'} = $1; # Macros } elsif ($line =~ /^\s*module_macro(\S+)\s+(.*)\s*$/) { $module->{'macros'}{$1} = $2; @@ -1073,6 +1081,10 @@ sub send_buffered_xml_files ($;$) { unlink ("$temporal_file/$xml_file"); } } + # Do not get stuck trying to send buffered XML files to a secondary server. + elsif ($flag_always == 2) { + last; + } } if (defined($flag_always) && ($flag_always == 2)){ swap_servers (); @@ -2101,45 +2113,28 @@ sub cron_next_execution { } # Get day of the week and month from cron config - my ($mday, $wday) = (split (/\s/, $cron))[2, 4]; + my ($wday) = (split (/\s/, $cron))[4]; + # Check the wday values to avoid infinite loop + my ($wday_down, $wday_up) = cron_get_interval($wday); + if ($wday_down ne "*" && ($wday_down > 6 || (defined($wday_up) && $wday_up > 6))) { + log_message('setup', "Invalid cron configuration $cron. Day of the week is out of limits."); + $wday = "*"; + } # Get current time and day of the week my $cur_time = time(); my $cur_wday = (localtime ($cur_time))[6]; - # Any day of the week - if ($wday eq '*') { - my $nex_time = cron_next_execution_date ($cron, $cur_time, $interval); - return $nex_time - time(); - } - # A range? - else { - $wday = cron_get_closest_in_range ($cur_wday, $wday); + my $nex_time = cron_next_execution_date ($cron, $cur_time, $interval); + + # Check the day + while (!cron_check_interval($wday, (localtime ($nex_time))[6])) { + # If it does not acomplish the day of the week, go to the next day. + $nex_time += 86400; + $nex_time = cron_next_execution_date ($cron, $nex_time, 0); } - # A specific day of the week - my $count = 0; - my $nex_time = $cur_time; - do { - $nex_time = cron_next_execution_date ($cron, $nex_time, $interval); - my $nex_time_wd = $nex_time; - my ($nex_mon, $nex_wday) = (localtime ($nex_time_wd))[4, 6]; - my $nex_mon_wd; - do { - # Check the day of the week - if ($nex_wday == $wday) { - return $nex_time_wd - time(); - } - - # Move to the next day of the month - $nex_time_wd += 86400; - ($nex_mon_wd, $nex_wday) = (localtime ($nex_time_wd))[4, 6]; - } while ($mday eq '*' && $nex_mon_wd == $nex_mon); - $count++; - } while ($count < 60); - - # Something went wrong, default to 5 minutes - return $interval; + return $nex_time - time(); } ############################################################################### @@ -2151,7 +2146,30 @@ sub cron_check_syntax ($) { return 0 if !defined ($cron); return ($cron =~ m/^(\d|\*|-)+ (\d|\*|-)+ (\d|\*|-)+ (\d|\*|-)+ (\d|\*|-)+$/); } +############################################################################### +# Check if a value is inside an interval. +############################################################################### +sub cron_check_interval { + my ($elem_cron, $elem_curr_time) = @_; + # Return 1 if wildcard. + return 1 if ($elem_cron eq "*"); + + my ($down, $up) = cron_get_interval($elem_cron); + # Check if it is not a range + if (!defined($up)) { + return ($down == $elem_curr_time) ? 1 : 0; + } + + # Check if it is on the range + if ($down < $up) { + return 0 if ($elem_curr_time < $down || $elem_curr_time > $up); + } else { + return 0 if ($elem_curr_time > $down || $elem_curr_time < $up); + } + + return 1; +} ############################################################################### # Get the next execution date for the given cron entry in seconds since epoch. ############################################################################### @@ -2189,8 +2207,7 @@ sub cron_next_execution_date { my @nex_time_array = @curr_time_array; # Update minutes - my ($min_down, undef) = cron_get_interval ($min); - $nex_time_array[0] = ($min_down eq '*') ? 0 : $min_down; + $nex_time_array[0] = cron_get_next_time_element($min); $nex_time = cron_valid_date(@nex_time_array, $cur_year); if ($nex_time >= $cur_time) { @@ -2224,8 +2241,7 @@ sub cron_next_execution_date { return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array); #Update the hour if fails - my ($hour_down, undef) = cron_get_interval ($hour); - $nex_time_array[1] = ($hour_down eq '*') ? 0 : $hour_down; + $nex_time_array[1] = cron_get_next_time_element($hour); # When an overflow is passed check the hour update again $nex_time = cron_valid_date(@nex_time_array, $cur_year); @@ -2253,10 +2269,9 @@ sub cron_next_execution_date { return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array); #Update the day if fails - my ($mday_down, undef) = cron_get_interval ($mday); - $nex_time_array[2] = ($mday_down eq '*') ? 1 : $mday_down; + $nex_time_array[2] = cron_get_next_time_element($mday, 1); - # When an overflow is passed check the day update in the next execution + # When an overflow is passed check the hour update in the next execution $nex_time = cron_valid_date(@nex_time_array, $cur_year); if ($nex_time >= $cur_time) { return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array); @@ -2276,8 +2291,7 @@ sub cron_next_execution_date { return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array); #Update the month if fails - my ($mon_down, undef) = cron_get_interval ($mon); - $nex_time_array[3] = ($mon_down eq '*') ? 0 : $mon_down; + $nex_time_array[3] = cron_get_next_time_element($mon); # When an overflow is passed check the month update in the next execution $nex_time = cron_valid_date(@nex_time_array, $cur_year); @@ -2308,23 +2322,30 @@ sub cron_is_in_cron { #If there is no elements means that is in cron return 1 unless (defined($elem_cron) || defined($elem_curr_time)); - # Go to last element if current is a wild card - if ($elem_cron ne '*') { - my ($down, $up) = cron_get_interval($elem_cron); - # Check if there is no a range - return 0 if (!defined($up) && ($down != $elem_curr_time)); - # Check if there is on the range - if (defined($up)) { - if ($down < $up) { - return 0 if ($elem_curr_time < $down || $elem_curr_time > $up); - } else { - return 0 if ($elem_curr_time > $down || $elem_curr_time < $up); - } - } - } + # Check the element interval + return 0 unless (cron_check_interval($elem_cron, $elem_curr_time)); + return cron_is_in_cron(\@deref_elems_cron, \@deref_elems_curr_time); } +################################################################################ +#Get the next tentative time for a cron value or interval in case of overflow. +#Floor data is the minimum localtime data for a position. Ex: +#Ex: +# * should returns floor data. +# 5 should returns 5. +# 10-55 should returns 10. +# 55-10 should retunrs floor data. +################################################################################ +sub cron_get_next_time_element { + # Default floor data is 0 + my ($curr_element, $floor_data) = @_; + $floor_data = 0 unless defined($floor_data); + my ($elem_down, $elem_up) = cron_get_interval ($curr_element); + return ($elem_down eq '*' || (defined($elem_up) && $elem_down > $elem_up)) + ? $floor_data + : $elem_down; +} ############################################################################### # Returns the interval of a cron element. If there is not a range, # returns an array with the first element in the first place of array @@ -2416,12 +2437,11 @@ sub check_module_cron { return 1 unless ($is_first); # Check if current timestamp is a valid cron date - my $next_execution = cron_next_execution_date( + my $next_execution = cron_next_execution( $module->{'cron'}, - $now - $interval, - $interval + 0 ); - return 1 if ($next_execution == $now); + return 1 if (time() + $next_execution == $now); return 0; } @@ -2532,6 +2552,7 @@ sub write_module_xml ($@) { $Xml .= " " . $module->{'min_ff_event_critical'} . "\n" if (defined ($module->{'min_ff_event_critical'})); $Xml .= " " . $module->{'ff_timeout'} . "\n" if (defined ($module->{'ff_timeout'})); $Xml .= " " . $module->{'each_ff'} . "\n" if (defined ($module->{'each_ff'})); + $Xml .= " " . $module->{'ff_type'} . "\n" if (defined ($module->{'ff_type'})); # Data list if ($#data > 0) { @@ -3017,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 6e7bfed828..4fb5833b12 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.732 -%define release 190322 +%define version 7.0NG.735 +%define release 190607 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 d7364299e8..ae395eff69 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.732 -%define release 190322 +%define version 7.0NG.735 +%define release 190607 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 dbd0cccdfc..516a471ddf 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.732" -PI_BUILD="190322" +PI_VERSION="7.0NG.735" +PI_BUILD="190607" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/unix/plugins/inventory b/pandora_agents/unix/plugins/inventory index a6d9a8bc83..6ef6233d23 100755 --- a/pandora_agents/unix/plugins/inventory +++ b/pandora_agents/unix/plugins/inventory @@ -4,23 +4,44 @@ # Copyright (c) 2009 Artica Soluciones Tecnologicas S.L. # # inventory Generate a hardware/software inventory. -# +# # Sample usage: ./inventory [cpu] [ram] [video] [nic] [hd] [cdrom] [software] [init_services] [filesystem] [process] [users] # # 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; use constant TSTAMP_FILE => '/tmp/pandora_inventory.tstamp'; +use Scalar::Util qw(looks_like_number); +use Data::Dumper; +# Set environment language to English +$ENV{"LANG"} = "en_US"; + +# Check AIX system +my $AIX=0; +my $system = `uname -a | awk '{print $1}'`; +if ($system =~ 'AIX') { + $AIX=1; +} + +sub is_enabled { + my $value = shift; + if ((defined ($value)) && looks_like_number($value) && ($value > 0)){ + # return true + return 1; + } + #return false + return 0; +} # Operation mode (LSHW or HWINFO) my $Mode; @@ -31,12 +52,12 @@ my $Separator; sub get_module_data ($$$$) { my ($name, $hwinfo, $keys, $modules) = @_; my %module; - - # Store keys + $Separator='\s+\*\-'; + # Store keys foreach my $key (@{$keys}) { push (@{$module{'_keys'}}, $key); } - + # Parse module data while (my $line = shift (@{$hwinfo})) { if ($line =~ /$Separator/) { @@ -46,7 +67,7 @@ sub get_module_data ($$$$) { foreach my $key (@{$keys}) { if ($line =~ /$key:\s+(.+)/) { $module{$key} = $1; - # Replace semicolon by comma to avoid parse errors + # Replace semicolon by comma to avoid parse errors $module{$key} =~ s/;/,/g; } } @@ -58,12 +79,65 @@ sub get_module_data ($$$$) { push (@{$modules->{$name}}, \%module); } +sub test_contain ($$) { + my ($value, $array)=@_; + if ( grep( /$value/, @{$array} ) ) { + return 1; + } +} +sub get_module_data_aix_ram_cpu ($$$$) { + my ($name, $hwinfo, $keys, $modules) = @_; + my %module; + # Store keys + foreach my $key (@{$keys}) { + push (@{$module{'_keys'}}, $key); + } + # Parse module data + foreach my $line (@{$hwinfo}) { + foreach my $key (@{$keys}) { + if ($line =~ /$key:\s+(.+)/) { + $module{$key} = $1; + $module{$key} =~ s/,/ /g; + } + } + } + + # No data found + #my @data = keys (%module); + #return unless ($#data >= 0); + + push (@{$modules->{$name}}, \%module); +} +sub get_module_data_aix ($$$$) { + my ($name,$hwinfo,$regex,$modules) = @_; + my %module; + foreach my $line (@{$hwinfo}) { + $line =~ s/\s{2,}/;/g; + $line =~ s/\+ //g; + $line =~ s/\* //g; + } + foreach my $line (@{$hwinfo}) { + if ($line =~ /$regex/){ + my ($var1, $var2, $var3) = split /;/, $line; + my %module; + $module{'device'} = $var1; + $module{'serial'} = $var2; + $module{'description'}=$var3; + $module{'_keys'} = ['device','serial','description']; + push (@{$modules->{$name}}, \%module); + } + } +} # Get a list of information file system in machine sub get_file_system($$) { my ($name, $modules) = @_; - - my @fileSystems = `df -hP | tail -n +2`; #remove the titles of columns + my @fileSystems; + if (is_enabled $AIX){ + @fileSystems = `df -gP | tail -n +2`; + } else { + @fileSystems = `df -hP | tail -n +2`; #remove the titles of columns + } foreach my $row (@fileSystems) { next unless ($row =~ /^(\S+)\s+\S+\s+(\S+)\s+(\S+)\s+\S+\s+(\S+)/); @@ -73,94 +147,110 @@ sub get_file_system($$) { $module{'used'} = $2; $module{'avail'} = $3; $module{'mount'} = $4; - $module{'_keys'} = ['filesystem', 'used','avail', 'mount']; - push (@{$modules->{$name}}, \%module); - } + $module{'_keys'} = ['filesystem', 'used','avail', 'mount']; + push (@{$modules->{$name}}, \%module); + } } # Get a list of services init in machine sub get_servicies_init_machine($$) { my ($name, $modules) = @_; - my $runlevel = `who -r | awk '{print \$2}'`; + my $runlevel; + if (is_enabled $AIX) { + $runlevel = `who -r | awk '{print \$3}'`; + } else { + $runlevel = `who -r | awk '{print \$2}'`; + } #ini trim($runlevel) $runlevel =~ s/^\s*//; #ltrim $runlevel =~ s/\s*$//; #rtrim #end trim($runlevel) - my $script = ""; - + my $script; + if (-e "/etc/rc" . $runlevel .".d/") { - $script = "ls /etc/rc" . $runlevel .".d/ -l | grep \"^l.*\" | awk \"{print \\\$NF}\" | sed -e \"s/\\.\\.\\///g\" | sed -e \"s/.*init\\.d\\///g\""; + $script = "ls -l /etc/rc" . $runlevel .".d/ | grep \"^l.*\" | awk \"{print \\\$NF}\" | sed -e \"s/\\.\\.\\///g\" | sed -e \"s/.*init\\.d\\///g\""; } else { - $script = "ls /etc/rc.d/rc" . $runlevel .".d/ -l | grep \"^l.*\" | grep \" S.* \" | awk \"{print \\\$NF}\" | sed -e \"s/\\.\\.\\///g\" | sed -e \"s/.*init\\.d\\///g\""; - + $script = "ls -l /etc/rc.d/rc" . $runlevel .".d/ | grep \"^l.*\" | grep \" S.* \" | awk \"{print \\\$NF}\" | sed -e \"s/\\.\\.\\///g\" | sed -e \"s/.*init\\.d\\///g\""; } - + my @services = `$script`; foreach my $row (@services) { - my %module; - $row =~ s/\n//; - $module{'service'} = $row; - $module{'_keys'} = ['service']; - push (@{$modules->{$name}}, \%module); + $row =~ s/\n//; + $module{'service'} = $row; + $module{'_keys'} = ['service']; + push (@{$modules->{$name}}, \%module); } } # Get a list of running processes sub get_processes ($$) { my ($name, $modules) = @_; + my $script; + if (is_enabled $AIX) { + $script = "ps -eo args | tail -n +2"; + } else { + $script = "ps -eo command | tail -n +2"; + } - my $script = "ps -eo command"; - - my @services = `$script`; - foreach my $row (@services) { - my %module; - # Remove carriage returns - $row =~ s/[\n\l\f]//g; - # Replace semicolon by comma to avoid parse errors - $row =~ s/;/,/g; - $module{'service'} = $row; - $module{'_keys'} = ['service']; - push (@{$modules->{$name}}, \%module); - } + my @services = `$script`; + foreach my $row (@services) { + my %module; + # Remove carriage returns + $row =~ s/[\n\l\f]//g; + # Replace semicolon by comma to avoid parse errors + $row =~ s/;/,/g; + $module{'service'} = $row; + $module{'_keys'} = ['service']; + push (@{$modules->{$name}}, \%module); + } } # Get a list of valid users in the system sub get_users ($$) { - my ($name, $modules) = @_; - - my $script = "cat /etc/passwd"; + my ($name, $modules) = @_; + my $script = "cat /etc/passwd"; my $user = ""; my $estado = ""; - my @services = `$script`; - foreach my $row (@services) { - my %module; + my @services = `$script`; + foreach my $row (@services) { + my %module; - next unless ($row =~ /^([A-Za-z0-9\-\_]*)/); - - $user = $1; - $script = `passwd -S $user`; - if ( $script =~ /^(\S+)\sP./){ - $module{'user'} = $user; - $module{'_keys'} = ['user']; - push (@{$modules->{$name}}, \%module); + next unless ($row =~ /^([A-Za-z0-9\-\_]*)/); + if (is_enabled $AIX) { + $user = $1; + $script = `lsuser $user`; + if ( $script =~ /^(\S+)\sid./){ + $module{'user'} = $user; + $module{'_keys'} = ['user']; + push (@{$modules->{$name}}, \%module); + } + } else { + $user = $1; + $script = `passwd -S $user`; + if ( $script =~ /^(\S+)\sP./){ + $module{'user'} = $user; + $module{'_keys'} = ['user']; + push (@{$modules->{$name}}, \%module); } } + + } } # Show Kernel Information sub get_kernel_info ($$) { - my ($name, $modules) = @_; - my $script = `uname -a | tr -d \";\"`; - my %module; + my ($name, $modules) = @_; + my $script = `uname -a | tr -d \";\"`; + my %module; - $module{'Kernel'} = $script; - $module{'_keys'} = ['Kernel']; - push (@{$modules->{$name}}, \%module); + $module{'Kernel'} = $script; + $module{'_keys'} = ['Kernel']; + push (@{$modules->{$name}}, \%module); } @@ -171,11 +261,13 @@ sub get_software_module_data ($$) { # Guess the current distribution my $distrib_id = ""; - if ( -e "/etc/SuSE-release"){ + if (is_enabled $AIX) { + $distrib_id = "AIX"; + }elsif ( -e "/etc/SuSE-release"){ $distrib_id = "SUSE"; - } elsif ( -e "/etc/redhat-release"){ + }elsif ( -e "/etc/redhat-release"){ $distrib_id = "REDHAT"; - } else { + }else { $distrib_id = "DEBIAN"; } @@ -183,7 +275,9 @@ sub get_software_module_data ($$) { my @soft; if ($distrib_id eq 'DEBIAN') { @soft = `dpkg -l | grep ii`; - } else { + }elsif ($distrib_id eq 'AIX') { + @soft = `lslpp -Lcq | awk -F: '{print "ii "\$1" "\$3" "\$8}'`; + }else { # Sometimes rpm return data splitted in two lines, and with dupes. Thats bad for our inventory system @soft = `rpm -q -a --qf "ii %{NAME} %{VERSION} %{SUMMARY}\n" | grep "^ii" | sort -u`; } @@ -197,7 +291,7 @@ sub get_software_module_data ($$) { $module{'program'} = $1; $module{'version'} = $2; $module{'description'} = $3; - # Replace semicolon by comma to avoid parse errors + # Replace semicolon by comma to avoid parse errors $module{'program'} =~ s/;/,/g; $module{'version'} =~ s/;/,/g; $module{'description'} =~ s/;/,/g; @@ -211,67 +305,95 @@ sub get_software_module_data ($$) { #Get the list of interfaces with the ip assigned sub get_ips ($$) { my ($name, $modules) = @_; + my @interfaces; + my $ifconfig; + if (is_enabled $AIX) { + $ifconfig = `ifconfig -a`; + } else { + $ifconfig = `ifconfig`; + } - my $ifconfig = `ifconfig`; - - my @ifconfig_array = split("\n", $ifconfig); - - for(my $i = 0; $i<$#ifconfig_array; $i++) { - - #Check for an interface - if ($ifconfig_array[$i] =~ /Link/) { - my %info; - - my @line_split = split(" ", $ifconfig_array[$i]); - - #Get interface name - $info{'interface'} = $line_split[0]; - #Get IP address - my $line = $ifconfig_array[$i+1]; - - $line =~ s/\s+//g; + my @ifconfig_array = split("\n", $ifconfig); - @line_split = split(":", $line); - - if($line_split[1] =~ /(\d+\.\d+\.\d+\.\d+).+/) { - $info{'ip'} = $1; - } - - $info{'_keys'} = ['interface', 'ip']; - push (@{$modules->{$name}}, \%info); - - } + foreach (@ifconfig_array){ + if ($_=~/(.*)flags/){ + my $match; + ($match)=$_=~/^(.*?)\: flags/; + $match=~s/://; + push @interfaces,$match; + } + } + foreach (@interfaces) { + my $ifconfig_item=`ifconfig $_`; + my $interface=$_; + my @ip_array = split("\n", $ifconfig_item); + foreach (@ip_array) { + if ($_=~/(?<=inet )(.*)(?= netmask)/){ + my $ip; + ($ip)=$_=~/inet (.*) netmask/; + my %info; + $info{'interface'} = $interface; + $info{'ip'} = $ip; + $info{'_keys'} = ['interface','ip']; + push (@{$modules->{$name}}, \%info); + } + } } } #Get route table sub get_route_table ($$) { - my ($name, $modules) = @_; - - my $route_table = `route`; - - my @table_split = split("\n", $route_table); - - for (my $i=2; $i<=$#table_split; $i++) { - - my @split = split(" ", $table_split[$i]); - - my %info; - - $info{'destination'} = $split[0]; - $info{'gateway'} = $split[1]; - $info{'mask'} = $split[2]; - $info{'flags'} = $split[3]; - $info{'metric'} = $split[4]; - $info{'ref'} = $split[5]; - $info{'use'} = $split[6]; - $info{'interface'} = $split[7]; - - $info{'_keys'} = ['destination', 'gateway', 'mask', 'flags', 'metric', 'use', 'interface']; - - push (@{$modules->{$name}}, \%info); - } + my ($name, $modules) = @_; + my $route_table; + my @table_split; + if (is_enabled $AIX) { + $route_table = `netstat -rn`; + @table_split = split("\n", $route_table); + my $length=scalar @table_split; + for (my $i=4; $i<=$length-4; $i++) { + + my @split = split(" ", $table_split[$i]); + + my %info; + + $info{'destination'} = $split[0]; + $info{'gateway'} = $split[1]; + $info{'mask'} = $split[2]; + $info{'flags'} = $split[3]; + $info{'metric'} = $split[4]; + $info{'ref'} = $split[5]; + $info{'use'} = $split[6]; + $info{'interface'} = $split[7]; + + $info{'_keys'} = ['destination', 'gateway', 'mask', 'flags', 'metric', 'use', 'interface']; + + push (@{$modules->{$name}}, \%info); + } + } else { + $route_table = `route`; + my @table_split = split("\n", $route_table); + + for (my $i=2; $i<=$#table_split; $i++) { + + my @split = split(" ", $table_split[$i]); + + my %info; + + $info{'destination'} = $split[0]; + $info{'gateway'} = $split[1]; + $info{'mask'} = $split[2]; + $info{'flags'} = $split[3]; + $info{'metric'} = $split[4]; + $info{'ref'} = $split[5]; + $info{'use'} = $split[6]; + $info{'interface'} = $split[7]; + + $info{'_keys'} = ['destination', 'gateway', 'mask', 'flags', 'metric', 'use', 'interface']; + + push (@{$modules->{$name}}, \%info); + } + } } # Print module data sub print_module ($$) { @@ -309,14 +431,18 @@ my $enable_all = 0; $interval = $ARGV[0]; if ($#ARGV == 0){ - $enable_all = 1; + $enable_all = 1; +} +if ($interval!=/[:alpha:]/){ + splice @ARGV,0,1; } -foreach my $module (@ARGV) { +foreach my $module (@ARGV) { if ($module eq "all"){ - $enable_all = 1; - } - $enabled{$module} = 1; + $enable_all = 1; + }else { + $enabled{$module} = 1; + } } # Check execution interval @@ -333,76 +459,107 @@ close (FILE); # Retrieve hardware information $Mode = 'LSHW'; $Separator = '\s+\*\-'; -my @hwinfo = `lshw 2>/dev/null`; -if ($? != 0) { - $Mode = 'HWINFO'; - $Separator = 'Hardware Class:'; - @hwinfo = `hwinfo --cpu --memory --gfxcard --netcard --cdrom --disk 2>/dev/null`; +my @hwinfo; +if (is_enabled $AIX) { + $Separator = '^\s*$'; + @hwinfo=`prtconf 2>/dev/null`; +} else { + @hwinfo = `lshw 2>/dev/null`; + if ($? != 0) { + $Mode = 'HWINFO'; + $Separator = 'Hardware Class:'; + @hwinfo = `hwinfo --cpu --memory --gfxcard --netcard --cdrom --disk 2>/dev/null`; + } } -# Parse hardware information my %modules; -while (my $line = shift (@hwinfo)) { + + if (is_enabled $AIX) { + #CPU + # VIDEO + ### Not avilable in AIX ### + # NIC + ### Not relevant in AIX ### + if ((test_contain('ent',\@hwinfo)) && ($enable_all == 1 || $enabled{'nic'} == 1)) { + get_module_data_aix ('NIC',\@hwinfo,'^ent',\%modules); + } + if ((test_contain('hdisk',\@hwinfo)) && ($enable_all == 1 || $enabled{'hd'} == 1)) { + get_module_data_aix ('HD',\@hwinfo,'^hdisk',\%modules); + } + + foreach my $line (@hwinfo) { + chomp ($line); + #CPU + if (($line =~ /^Memory Size:/) && ($enable_all == 1 || $enabled{'ram'} == 1)) { + get_module_data_aix_ram_cpu ('RAM', \@hwinfo, ['Memory Size','Good Memory Size'], \%modules); + } + + if (($line =~ /^System Model/) && ($enable_all == 1 || $enabled{'cpu'} == 1)) { + get_module_data_aix_ram_cpu ('CPU', \@hwinfo, ['System Model', 'Processor Implementation Mode', 'Number Of Processors'], \%modules); + } + } +} else { + # Parse hardware information + while (my $line= shift (@hwinfo)) { chomp ($line); + # CPU + if (($line =~ /\*\-cpu/ || $line =~ /Hardware Class: cpu/) && ($enable_all == 1 || $enabled{'cpu'} == 1)) { + if ($Mode eq 'LSHW') { + get_module_data ('CPU', \@hwinfo, ['product', 'vendor', 'capacity'], \%modules); + } else { + get_module_data ('CPU', \@hwinfo, ['Model', 'Vendor', 'Clock'], \%modules); + } + } - # CPU - if (($line =~ /\*\-cpu/ || $line =~ /Hardware Class: cpu/) && ($enable_all == 1 || $enabled{'cpu'} == 1)) { - if ($Mode eq 'LSHW') { - get_module_data ('CPU', \@hwinfo, ['product', 'vendor', 'capacity'], \%modules); - } else { - get_module_data ('CPU', \@hwinfo, ['Model', 'Vendor', 'Clock'], \%modules); - } - } + # RAM + if (($line =~ /\*\-bank/ || $line =~ /\*\-memory/ || $line =~ /Hardware Class: memory/) && ($enable_all == 1 || $enabled{'ram'} == 1)) { + if ($Mode eq 'LSHW') { + get_module_data ('RAM', \@hwinfo, ['description', 'size'], \%modules); + } else { + get_module_data ('RAM', \@hwinfo, ['Model', 'Memory Size'], \%modules); + } + } - # RAM - if (($line =~ /\*\-bank/ || $line =~ /Hardware Class: memory/) && ($enable_all == 1 || $enabled{'ram'} == 1)) { - if ($Mode eq 'LSHW') { - get_module_data ('RAM', \@hwinfo, ['description', 'size'], \%modules); - } else { - get_module_data ('RAM', \@hwinfo, ['Model', 'Memory Size'], \%modules); - } - } + # VIDEO + if (($line =~ /\*\-display/ || $line =~ /Hardware Class: graphics card/) && ($enable_all == 1 || $enabled{'video'} == 1)) { + if ($Mode eq 'LSHW') { + get_module_data ('VIDEO', \@hwinfo, ['product', 'description', 'vendor'], \%modules); + } else { + # Spaces before Device and Vendor are intentional to avoid matching SubDevice and SubVendor + get_module_data ('VIDEO', \@hwinfo, ['Model', ' Device', ' Vendor'], \%modules); + } + } - # VIDEO - if (($line =~ /\*\-display/ || $line =~ /Hardware Class: graphics card/) && ($enable_all == 1 || $enabled{'video'} == 1)) { - if ($Mode eq 'LSHW') { - get_module_data ('VIDEO', \@hwinfo, ['product', 'description', 'vendor'], \%modules); - } else { - # Spaces before Device and Vendor are intentional to avoid matching SubDevice and SubVendor - get_module_data ('VIDEO', \@hwinfo, ['Model', ' Device', ' Vendor'], \%modules); - } - } + # NIC + if (($line =~ /\*\-network/ || $line =~ /Hardware Class: network/) && ($enable_all == 1 || $enabled{'nic'} == 1)) { + if ($Mode eq 'LSHW') { + get_module_data ('NIC', \@hwinfo, ['product', 'description', 'vendor', 'serial'], \%modules); + } else { + # Spaces before Device and Vendor are intentional to avoid matching SubDevice and SubVendor + get_module_data ('NIC', \@hwinfo, ['Model', ' Device', ' Vendor', 'HW Address'], \%modules); + } + } - # NIC - if (($line =~ /\*\-network/ || $line =~ /Hardware Class: network/) && ($enable_all == 1 || $enabled{'nic'} == 1)) { - if ($Mode eq 'LSHW') { - get_module_data ('NIC', \@hwinfo, ['product', 'description', 'vendor', 'serial'], \%modules); - } else { - # Spaces before Device and Vendor are intentional to avoid matching SubDevice and SubVendor - get_module_data ('NIC', \@hwinfo, ['Model', ' Device', ' Vendor', 'HW Address'], \%modules); - } - } - - # CDROM - if (($line =~ /\*\-cdrom/ || $line =~ /Hardware Class: cdrom/) && ($enable_all == 1 || $enabled{'cdrom'} == 1)) { - if ($Mode eq 'LSHW') { - get_module_data ('CDROM', \@hwinfo, ['product', 'description', 'vendor'], \%modules); - } else { - # Spaces before Device and Vendor are intentional to avoid matching SubDevice and SubVendor - get_module_data ('CDROM', \@hwinfo, ['Model', ' Device', ' Vendor'], \%modules); - } - } + # CDROM + if (($line =~ /\*\-cdrom/ || $line =~ /Hardware Class: cdrom/) && ($enable_all == 1 || $enabled{'cdrom'} == 1)) { + if ($Mode eq 'LSHW') { + get_module_data ('CDROM', \@hwinfo, ['product', 'description', 'vendor'], \%modules); + } else { + # Spaces before Device and Vendor are intentional to avoid matching SubDevice and SubVendor + get_module_data ('CDROM', \@hwinfo, ['Model', ' Device', ' Vendor'], \%modules); + } + } - # HD - if (($line =~ /\*\-disk/ || $line =~ /Hardware Class: disk/) && ($enable_all == 1 || $enabled{'hd'} == 1)) { - if ($Mode eq 'LSHW') { - get_module_data ('HD', \@hwinfo, ['product', 'description', 'size'], \%modules); - } else { - get_module_data ('HD', \@hwinfo, ['Model', 'Serial ID', 'Size'], \%modules); - } - } + # HD + if (($line =~ /\*\-disk/ || $line =~ /Hardware Class: disk/) && ($enable_all == 1 || $enabled{'hd'} == 1)) { + if ($Mode eq 'LSHW') { + get_module_data ('HD', \@hwinfo, ['product', 'description', 'size'], \%modules); + } else { + get_module_data ('HD', \@hwinfo, ['Model', 'Serial ID', 'Size'], \%modules); + } + } + } } - # Software if ($enable_all == 1 || $enabled{'software'} == 1) { get_software_module_data ('Software', \%modules); @@ -410,12 +567,12 @@ if ($enable_all == 1 || $enabled{'software'} == 1) { #init_services if ($enable_all == 1 || $enabled{'init_services'} == 1) { - get_servicies_init_machine ('Init services', \%modules); + get_servicies_init_machine ('Init_services', \%modules); } #filesystem if ($enable_all == 1 || $enabled{'filesystem'} == 1) { - get_file_system('File system', \%modules); + get_file_system('Filesystem', \%modules); } #processes @@ -442,7 +599,6 @@ if ($enable_all == 1 || $enabled{'route'} == 1) { if ($enable_all == 1 || $enabled{'kernel'} == 1){ get_kernel_info ('Kernel', \%modules); } - # Print module data print "\n"; while (my ($name, $module) = each (%modules)) { diff --git a/pandora_agents/win32/bin/pandora_agent.conf b/pandora_agents/win32/bin/pandora_agent.conf index 3d1e208de8..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.732 +# 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 @@ -44,6 +44,8 @@ remote_config 0 #agent_name_cmd cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\agentname.vbs" agent_name_cmd __rand__ +# Agent alias. Name should be unique rather than alias. Hostname by default +# agent_alias $Alias$ #Parent agent_name #parent_agent_name caprica diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index b1802a4e14..f0861035f3 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.732} +{Pandora FMS Windows Agent v7.0NG.735} ApplicationID {17E3D2CF-CA02-406B-8A80-9D31C17BD08F} @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{190322} +{190607} ViewReadme {Yes} diff --git a/pandora_agents/win32/misc/cron.cc b/pandora_agents/win32/misc/cron.cc index 2d3e5e0440..409a43f726 100644 --- a/pandora_agents/win32/misc/cron.cc +++ b/pandora_agents/win32/misc/cron.cc @@ -214,7 +214,7 @@ int Cron::getResetValue (int position) { int default_value = 0; // Days start in 1 if (position == 2) default_value = 1; - return isWildCard(position) + return (isWildCard(position) || !isNormalInterval(position)) ? default_value : this->params[position][CRDOWN]; } diff --git a/pandora_agents/win32/modules/pandora_module.cc b/pandora_agents/win32/modules/pandora_module.cc index eac38c8fa1..e7c751d367 100644 --- a/pandora_agents/win32/modules/pandora_module.cc +++ b/pandora_agents/win32/modules/pandora_module.cc @@ -78,6 +78,7 @@ Pandora_Module::Pandora_Module (string name) { this->warning_inverse = ""; this->quiet = ""; this->module_ff_interval = ""; + this->module_ff_type = ""; this->module_alert_template = ""; this->module_crontab = ""; } @@ -733,6 +734,13 @@ Pandora_Module::getXml () { module_xml += this->module_ff_interval; module_xml += "\n"; } + + /* Module FF type */ + if (this->module_ff_type != "") { + module_xml += "\t"; + module_xml += this->module_ff_type; + module_xml += "\n"; + } /* Module Alert template */ if (this->module_alert_template != "") { @@ -1028,6 +1036,16 @@ Pandora_Module::setModuleFFInterval (string value) { this->module_ff_interval = value; } +/** + * Set the module FF type for the module. + * + * @param value module FF type value to set. + */ +void +Pandora_Module::setModuleFFType (string value) { + this->module_ff_type = value; +} + /** * Set the module Alert template for the module. * diff --git a/pandora_agents/win32/modules/pandora_module.h b/pandora_agents/win32/modules/pandora_module.h index 9fb29e1183..c766766950 100644 --- a/pandora_agents/win32/modules/pandora_module.h +++ b/pandora_agents/win32/modules/pandora_module.h @@ -176,6 +176,7 @@ namespace Pandora_Modules { string unit, custom_id, str_warning, str_critical; string module_group, warning_inverse, critical_inverse, quiet; string module_ff_interval, module_alert_template, module_crontab; + string module_ff_type; string critical_instructions, warning_instructions, unknown_instructions, tags; protected: @@ -277,6 +278,7 @@ namespace Pandora_Modules { void setWarningInverse (string value); void setQuiet (string value); void setModuleFFInterval (string value); + void setModuleFFType (string value); void setModuleAlertTemplate (string value); void setModuleCrontab (string value); diff --git a/pandora_agents/win32/modules/pandora_module_factory.cc b/pandora_agents/win32/modules/pandora_module_factory.cc index 658ff724fd..a4d9553c20 100644 --- a/pandora_agents/win32/modules/pandora_module_factory.cc +++ b/pandora_agents/win32/modules/pandora_module_factory.cc @@ -119,6 +119,7 @@ using namespace Pandora_Strutils; #define TOKEN_WARNING_INVERSE ("module_warning_inverse ") #define TOKEN_QUIET ("module_quiet ") #define TOKEN_MODULE_FF_INTERVAL ("module_ff_interval ") +#define TOKEN_MODULE_FF_TYPE ("module_ff_type ") #define TOKEN_MACRO ("module_macro") #define TOKEN_NATIVE_ENCODING ("module_native_encoding") #define TOKEN_ALERT_TEMPLATE ("module_alert_template") @@ -176,7 +177,7 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { string module_unit, module_group, module_custom_id, module_str_warning, module_str_critical; string module_critical_instructions, module_warning_instructions, module_unknown_instructions, module_tags; string module_critical_inverse, module_warning_inverse, module_quiet, module_ff_interval; - string module_native_encoding, module_alert_template; + string module_native_encoding, module_alert_template, module_ff_type; string macro; Pandora_Module *module; bool numeric; @@ -254,6 +255,7 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { module_warning_inverse = ""; module_quiet = ""; module_ff_interval = ""; + module_ff_type = ""; module_native_encoding = ""; module_alert_template = ""; module_user_session = ""; @@ -507,6 +509,10 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { if (module_ff_interval == "") { module_ff_interval = parseLine (line, TOKEN_MODULE_FF_INTERVAL); } + + if (module_ff_type == "") { + module_ff_type = parseLine (line, TOKEN_MODULE_FF_TYPE); + } if (module_alert_template == "") { module_alert_template = parseLine (line, TOKEN_ALERT_TEMPLATE); @@ -1087,6 +1093,13 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { } } + if (module_ff_type != "") { + pos_macro = module_ff_type.find(macro_name); + if (pos_macro != string::npos){ + module_ff_type.replace(pos_macro, macro_name.size(), macro_value); + } + } + if (module_alert_template != "") { pos_macro = module_alert_template.find(macro_name); if (pos_macro != string::npos){ @@ -1104,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, @@ -1447,6 +1466,10 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { if (module_ff_interval != "") { module->setModuleFFInterval (module_ff_interval); } + + if (module_ff_type != "") { + module->setModuleFFType (module_ff_type); + } if (module_alert_template != "") { module->setModuleAlertTemplate (module_alert_template); diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index fa7d6d3b31..18df0920d3 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.732(Build 190322)") +#define PANDORA_VERSION ("7.0NG.735(Build 190607)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 076b2b6611..5848e265ac 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.732(Build 190322))" + VALUE "ProductVersion", "(7.0NG.735(Build 190607))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index aff09660bc..93ebb71f4f 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.732-190322 +Version: 7.0NG.735-190607 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 d63eb7642b..f7dbf58009 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.732-190322" +pandora_version="7.0NG.735-190607" package_pear=0 package_pandora=1 diff --git a/pandora_console/composer.json b/pandora_console/composer.json index acc6a3e352..208e2d3d14 100644 --- a/pandora_console/composer.json +++ b/pandora_console/composer.json @@ -10,5 +10,16 @@ "require": { "mpdf/mpdf": "^7.1", "swiftmailer/swiftmailer": "^6.0" + }, + "autoload": { + "psr-4": { + "Models\\": "include/rest-api/models", + "Enterprise\\Models\\": "enterprise/include/rest-api/models" + } + }, + "autoload-dev": { + "psr-4": { + "Tests\\": "tests/" + } } } diff --git a/pandora_console/extensions/agents_alerts.php b/pandora_console/extensions/agents_alerts.php index 46272504f6..54e0ec6b12 100755 --- a/pandora_console/extensions/agents_alerts.php +++ b/pandora_console/extensions/agents_alerts.php @@ -138,8 +138,15 @@ function mainAgentsAlerts() $onheader['combo_refr'] = $comborefr; } - // Header - ui_print_page_header(__('Agents/Alerts'), 'images/op_alerts.png', false, '', false, $updated_time); + // Header. + ui_print_page_header( + __('Agents/Alerts'), + 'images/op_alerts.png', + false, + 'agents_alerts_view', + false, + $updated_time + ); // Old style table, we need a lot of special formatting,don't use table function // Prepare old-style table @@ -291,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); @@ -378,7 +385,8 @@ function mainAgentsAlerts() 'alerts_agents' ); - echo ''; + echo '
'; + echo ''; echo "'; if ($hor_offset > 0) { @@ -421,9 +429,10 @@ function mainAgentsAlerts() continue; } - echo ''; + echo ''; } + echo ''; if (($hor_offset + $block) < $ntemplates) { $new_hor_offset = ($hor_offset + $block); echo "
".__('Agents').' / '.__('Alert templates').''.io_safe_output($tname).html_print_image('images/information_alerts.png', true, ['title' => io_safe_output($tname), 'style' => 'margin-left:5px' ]).''.io_safe_output($tname).'
@@ -455,7 +464,7 @@ function mainAgentsAlerts() $cellstyle = 'background:'.COL_ALERTFIRED.';'; } - echo ' '; + echo ' '; $uniqid = uniqid(); echo '
'; @@ -478,6 +487,23 @@ function mainAgentsAlerts() } echo '
'; + + ui_pagination( + $nagents, + false, + 0, + 0, + false, + 'offset', + true, + 'pagination-bottom', + '', + [ + 'count' => '', + 'offset' => 'offset_param', + ], + 'alerts_agents' + ); } } @@ -487,7 +513,7 @@ function mainAgentsAlerts() function print_alerts_summary_modal_window($id, $alerts) { $table->width = '98%'; - $table->class = 'databox'; + $table->class = 'info_table'; $table->data = []; $table->head[0] = __('Module'); diff --git a/pandora_console/extensions/agents_modules.php b/pandora_console/extensions/agents_modules.php index 798f4e140e..b5860068d8 100644 --- a/pandora_console/extensions/agents_modules.php +++ b/pandora_console/extensions/agents_modules.php @@ -181,8 +181,15 @@ function mainAgentsModules() // 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(__('Agents/Modules'), 'images/module_mc.png', false, '', false, $updated_time); + // Header. + ui_print_page_header( + __('Agents/Modules'), + 'images/module_mc.png', + false, + 'agents_module_view', + false, + $updated_time + ); echo ''; echo ''; echo "'; @@ -661,7 +668,7 @@ $ignored_params['refresh'] = ''; else { var agentes_id = $("#id_agents2").val(); - var id_agentes = $.get("full_agents_id"); + var id_agentes = getQueryParam("full_agents_id"); if (agentes_id === null && id_agentes !== null) { id_agentes = id_agentes.split(";") id_agentes.forEach(function(element) { @@ -799,7 +806,7 @@ $ignored_params['refresh'] = ''; $("#module").append (option); }); - var id_modules = $.get("full_modules_selected"); + var id_modules = getQueryParam("full_modules_selected"); if(id_modules !== null) { id_modules = id_modules.split(";"); id_modules.forEach(function(element) { @@ -812,20 +819,18 @@ $ignored_params['refresh'] = ''; ); } - (function($) { - $.get = function(key) { - key = key.replace(/[[]/, '['); - key = key.replace(/[]]/, ']'); - var pattern = "[?&]" + key + "=([^&#]*)"; - var regex = new RegExp(pattern); - var url = unescape(window.location.href); - var results = regex.exec(url); - if (results === null) { - return null; - } else { - return results[1]; - } - } - })(jQuery); + function getQueryParam (key) { + key = key.replace(/[[]/, '['); + key = key.replace(/[]]/, ']'); + var pattern = "[?&]" + key + "=([^&#]*)"; + var regex = new RegExp(pattern); + var url = unescape(window.location.href); + var results = regex.exec(url); + if (results === null) { + return null; + } else { + return results[1]; + } + } - \ No newline at end of file + diff --git a/pandora_console/extensions/db_status.php b/pandora_console/extensions/db_status.php index 435474dc53..2d8669f83f 100755 --- a/pandora_console/extensions/db_status.php +++ b/pandora_console/extensions/db_status.php @@ -25,7 +25,7 @@ function extension_db_status() __('DB Schema check'), 'images/extensions.png', false, - '', + 'db_status_tab', true, '' ); diff --git a/pandora_console/extensions/dbmanager.php b/pandora_console/extensions/dbmanager.php index 2aface6996..546ee463fa 100644 --- a/pandora_console/extensions/dbmanager.php +++ b/pandora_console/extensions/dbmanager.php @@ -148,7 +148,7 @@ function dbmgr_extension_main() echo "
"; $table = new stdClass(); $table->width = '100%'; - $table->class = 'databox data'; + $table->class = 'info_table'; $table->head = array_keys($result[0]); $table->data = $result; diff --git a/pandora_console/extensions/files_repo/files_repo_list.php b/pandora_console/extensions/files_repo/files_repo_list.php index 1d01cd1418..80de4563ae 100644 --- a/pandora_console/extensions/files_repo/files_repo_list.php +++ b/pandora_console/extensions/files_repo/files_repo_list.php @@ -45,11 +45,9 @@ if (!empty($files)) { $table = new stdClass(); $table->width = '100%'; - $table->class = 'databox data'; + $table->class = 'info_table'; $table->style = []; $table->style[1] = 'max-width: 200px;'; - $table->style[2] = 'text-align: center;'; - $table->style[3] = 'text-align: center;'; $table->style[4] = 'text-align: center;'; $table->head = []; $table->head[0] = __('Name'); @@ -81,6 +79,7 @@ if (!empty($files)) { // Last modification // Public URL $data[4] = ''; + $table->cellclass[][4] = 'action_buttons'; if (!empty($file['hash'])) { $public_url = ui_get_full_url(EXTENSIONS_DIR.'/files_repo/files_repo_get_file.php?file='.$file['hash']); $message = __('Copy to clipboard').': Ctrl+C -> Enter'; @@ -92,7 +91,7 @@ if (!empty($files)) { } $data[4] .= ""; - $data[4] .= html_print_image('images/download.png', true, ['title' => __('Download')]); + $data[4] .= html_print_image('images/download.png', true, ['title' => __('Download'), 'style' => 'padding:3px' ]); // Download image $data[4] .= ''; diff --git a/pandora_console/extensions/module_groups.php b/pandora_console/extensions/module_groups.php index 1a505538ed..9e750be932 100644 --- a/pandora_console/extensions/module_groups.php +++ b/pandora_console/extensions/module_groups.php @@ -192,7 +192,14 @@ function mainModuleGroups() $array_data[$value['id_grupo']][$value['id_mg']] = $value; } - ui_print_page_header(__('Combined table of agent group and module group'), 'images/module_group.png', false, '', false, ''); + ui_print_page_header( + __('Combined table of agent group and module group'), + 'images/module_group.png', + false, + 'module_groups_view', + false, + '' + ); echo "
".$fullscreen['text'].'
"; diff --git a/pandora_console/extensions/realtime_graphs.php b/pandora_console/extensions/realtime_graphs.php index 09d66abf0c..cea09fe4d5 100644 --- a/pandora_console/extensions/realtime_graphs.php +++ b/pandora_console/extensions/realtime_graphs.php @@ -29,7 +29,14 @@ function pandora_realtime_graphs() $hide_header = get_parameter('hide_header', 0); if (!$hide_header) { - ui_print_page_header(__('Realtime graphs'), 'images/extensions.png', false, '', false, $onheader); + ui_print_page_header( + __('Realtime graphs'), + 'images/extensions.png', + false, + 'real_time_view', + false, + $onheader + ); } $chart[time()]['graph'] = '0'; diff --git a/pandora_console/extensions/resource_registration.php b/pandora_console/extensions/resource_registration.php index 92d106d153..c43e2a97f2 100755 --- a/pandora_console/extensions/resource_registration.php +++ b/pandora_console/extensions/resource_registration.php @@ -998,20 +998,23 @@ function process_upload_xml($xml) { $hook_enterprise = enterprise_include('extensions/resource_registration/functions.php'); - // Extract component + // Extract component. process_upload_xml_component($xml); $group_filter = get_parameter('group'); - // Extract visual map + // Extract visual map. process_upload_xml_visualmap($xml, $group_filter); - // Extract policies + // Extract policies. if ($hook_enterprise === true) { - process_upload_xml_policy($xml, $group_filter); + $centralized_management = !is_central_policies_on_node(); + if ($centralized_management) { + process_upload_xml_policy($xml, $group_filter); + } } - // Extract reports + // Extract reports. process_upload_xml_report($xml, $group_filter); } @@ -1038,6 +1041,11 @@ function resource_registration_extension_main() return; } + $centralized_management = !is_central_policies_on_node(); + if (!$centralized_management) { + ui_print_warning_message(__('This node is configured with centralized mode. Go to metaconsole to create a policy.')); + } + echo '
'; echo __('This extension makes registering resource templates easier.').' '.__('Here you can upload a resource template in .ptr format.').' '.__('Please refer to our documentation for more information on how to obtain and use %s resources.', get_product_name()).' '.'

'.__("You can get more resurces in our Public Resource Library"); echo '
'; diff --git a/pandora_console/extensions/users_connected.php b/pandora_console/extensions/users_connected.php index 562d757a20..e26b0dab1e 100644 --- a/pandora_console/extensions/users_connected.php +++ b/pandora_console/extensions/users_connected.php @@ -66,10 +66,10 @@ function users_extension_main_god($god=true) $rows = []; echo "
".__('No other users connected').'
'; } else { - $table->cellpadding = 4; - $table->cellspacing = 4; + $table->cellpadding = 0; + $table->cellspacing = 0; $table->width = '100%'; - $table->class = 'databox data'; + $table->class = 'info_table'; $table->size = []; $table->data = []; $table->head = []; diff --git a/pandora_console/extras/delete_files/delete_files.txt b/pandora_console/extras/delete_files/delete_files.txt index 7ddcdae14e..82ce1527aa 100644 --- a/pandora_console/extras/delete_files/delete_files.txt +++ b/pandora_console/extras/delete_files/delete_files.txt @@ -1,3 +1,3 @@ -/godmode/servers/recorn_script.php -/godmode/servers/manage_recontask_form.php -/godmode/servers/manage_recontask.php \ No newline at end of file +/general/login_identification_wizard.php +/general/login_required.php +/godmode/update_manager/update_manager.messages.php \ No newline at end of file diff --git a/pandora_console/extras/mr/26.sql b/pandora_console/extras/mr/26.sql index f9c904a0a3..591edd6499 100644 --- a/pandora_console/extras/mr/26.sql +++ b/pandora_console/extras/mr/26.sql @@ -1,8 +1,24 @@ START TRANSACTION; --- ---------------------------------------------------------------------- --- Add column in table `tagent_custom_fields` --- ---------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tnetwork_matrix` ( + `id` int(10) unsigned NOT NULL auto_increment, + `source` varchar(60) default '', + `destination` varchar(60) default '', + `utimestamp` bigint(20) default 0, + `bytes` int(18) unsigned default 0, + `pkts` int(18) unsigned default 0, + PRIMARY KEY (`id`), + UNIQUE (`source`, `destination`, `utimestamp`) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +ALTER TABLE `treport_content` ADD COLUMN `show_extended_events` tinyint(1) default '0'; + +UPDATE `treport_content` SET type="netflow_summary" WHERE type="netflow_pie" OR type="netflow_statistics"; + +UPDATE `tnetflow_filter` SET aggregate="dstip" WHERE aggregate NOT IN ("dstip", "srcip", "dstport", "srcport"); + ALTER TABLE tagent_custom_fields ADD COLUMN `combo_values` VARCHAR(255) DEFAULT ''; +ALTER TABLE `trecon_task` ADD COLUMN `summary` text; + COMMIT; diff --git a/pandora_console/extras/mr/27.sql b/pandora_console/extras/mr/27.sql new file mode 100644 index 0000000000..697be21a93 --- /dev/null +++ b/pandora_console/extras/mr/27.sql @@ -0,0 +1,54 @@ +START TRANSACTION; + +ALTER TABLE `tnetflow_filter` DROP COLUMN `output`; + +ALTER TABLE `tagente_modulo` ADD COLUMN `ff_type` tinyint(1) unsigned default '0'; +ALTER TABLE `tnetwork_component` ADD COLUMN `ff_type` tinyint(1) unsigned default '0'; +ALTER TABLE `tlocal_component` ADD COLUMN `ff_type` tinyint(1) unsigned default '0'; +ALTER TABLE `tpolicy_modules` ADD COLUMN `ff_type` tinyint(1) unsigned default '0'; + +ALTER TABLE `tagente_estado` ADD COLUMN `ff_normal` int(4) unsigned default '0'; +ALTER TABLE `tagente_estado` ADD COLUMN `ff_warning` int(4) unsigned default '0'; +ALTER TABLE `tagente_estado` ADD COLUMN `ff_critical` int(4) unsigned default '0'; + +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"; + +ALTER TABLE `treport_content` ADD COLUMN `total_time` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `time_failed` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `time_in_ok_status` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `time_in_unknown_status` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `time_of_not_initialized_module` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `time_of_downtime` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `total_checks` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `checks_failed` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `checks_in_ok_status` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `unknown_checks` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `agent_max_value` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `agent_min_value` TINYINT(1) DEFAULT '1'; + +ALTER TABLE `treport_content_template` ADD COLUMN `total_time` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `time_failed` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `time_in_ok_status` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `time_in_unknown_status` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `time_of_not_initialized_module` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `time_of_downtime` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `total_checks` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `checks_failed` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `checks_in_ok_status` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `unknown_checks` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `agent_max_value` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `agent_min_value` TINYINT(1) DEFAULT '1'; + +ALTER TABLE `trecon_script` ADD COLUMN `type` int NOT NULL default 0; +ALTER TABLE `trecon_task` ADD COLUMN `type` int NOT NULL default 0; + +UPDATE `trecon_script` SET `type` = 1 WHERE `name`="Discovery.Application.VMware"; +UPDATE `trecon_script` SET `type` = 2 WHERE `name`="Discovery.Cloud"; +UPDATE `trecon_script` SET `type` = 3 WHERE `name` LIKE "IPAM%Recon"; +UPDATE `trecon_script` SET `type` = 4 WHERE `name` LIKE "IPMI%Recon"; + +UPDATE `trecon_task` SET `type`=3 WHERE `description`="Discovery.Application.VMware"; +UPDATE `trecon_task` SET `type`=2 WHERE `description`="Discovery.Cloud"; +UPDATE `trecon_task` SET `type`=7 WHERE `description`="Discovery.Cloud.RDS"; + +COMMIT; diff --git a/pandora_console/extras/mr/28.sql b/pandora_console/extras/mr/28.sql new file mode 100644 index 0000000000..bab07bead8 --- /dev/null +++ b/pandora_console/extras/mr/28.sql @@ -0,0 +1,45 @@ +START TRANSACTION; + +ALTER TABLE `treport_content` ADD COLUMN `current_month` TINYINT(1) DEFAULT '1'; + +ALTER TABLE `treport_content_template` ADD COLUMN `current_month` TINYINT(1) DEFAULT '1'; + +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 (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'; + +-- --------------------------------------------------------------------- +-- 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 d6cd017087..c5420c26bd 100644 --- a/pandora_console/extras/pandora_diag.php +++ b/pandora_console/extras/pandora_diag.php @@ -122,7 +122,7 @@ function execution_time() if ($times[0]['datos'] > ($times[1]['datos'] * 1.2)) { return "Warning Status   The execution time could be degrading. For a more extensive information of this data consult the Execution Time graph"; } else { - return "Normal Status   The execution time is correct. For a more extensive information of this data consult the Execution Time graph"; + return "Normal Status   The execution time is correct. For more information about this data, check the Execution Time graph"; } } @@ -139,7 +139,7 @@ function get_logs_size($file) function get_status_logs($path) { $status_server_log = ''; - $size_server_log = number_format(get_logs_size($path)); + $size_server_log = get_logs_size($path); if ($size_server_log <= 1048576) { $status_server_log = "Normal Status   You have less than 10 MB of logs"; } else { @@ -157,9 +157,9 @@ function percentage_modules_per_agent() $total_modules = db_get_value_sql('SELECT count(*) FROM tagente_modulo'); $average_modules_per_agent = ($total_modules / $total_agents); if ($average_modules_per_agent <= 40) { - $status_average_modules = "Normal Status   The average of modules per agent is less than 40 percent"; + $status_average_modules = "Normal Status   The average of modules per agent is less than 40"; } else { - $status_average_modules = "Warning Status  The average of modules per agent is more than 40 percent. You can have performance problems"; + $status_average_modules = "Warning Status  The average of modules per agent is more than 40. You can have performance problems"; } return $status_average_modules; @@ -173,9 +173,9 @@ function license_capacity() $status_license_capacity = ''; $current_count = db_get_value_sql('SELECT count(*) FROM tagente'); if ($current_count > ($license_limit * 90 / 100)) { - $status_license_capacity = "Warning Status   The license capacity is more than 90 percent"; + $status_license_capacity = "Warning Status   License capacity exceeds 90 percent"; } else { - $status_license_capacity = "Normal Status   The license capacity is less than 90 percent"; + $status_license_capacity = "Normal Status   License capacity is less than 90 percent"; } return $status_license_capacity; @@ -202,9 +202,9 @@ function interval_average_of_network_modules() $average_time = ((int) $total_module_interval_time / $total_network_modules); if ($average_time < 180) { - $status_average_modules = "Warning Status   The system has a lot of load and a very fine configuration is required"; + $status_average_modules = "Warning Status   The system is overloaded (average time $average_time) and a very fine configuration is required"; } else { - $status_average_modules = "Normal Status   The system has an acceptable charge"; + $status_average_modules = "Normal Status   The system is not overloaded (average time $average_time) "; } if ($average_time == 0) { @@ -221,9 +221,9 @@ $attachment_total_files = count(glob($config['homedir'].'/attachment/{*.*}', GLO function files_attachment_folder($total_files) { if ($total_files <= 700) { - $status_total_files = "Normal Status   The attachment folder has less than 700 files."; + $status_total_files = "Normal Status   The attached folder contains less than 700 files."; } else { - $status_total_files = "Warning Status   The attachment folder has more than 700 files."; + $status_total_files = "Warning Status   The attached folder contains more than 700 files."; } return $status_total_files; @@ -236,9 +236,9 @@ $tagente_datos_size = db_get_value_sql('SELECT COUNT(*) FROM tagente_datos'); function status_tagente_datos($tagente_datos_size) { if ($tagente_datos_size <= 3000000) { - $tagente_datos_size = "Normal Status   The tagente_datos table has an acceptable amount of data."; + $tagente_datos_size = "Normal Status   The tagente_datos table contains an acceptable amount of data."; } else { - $tagente_datos_size = "Warning Status   The tagente_datos table has too much data. A historical database is recommended."; + $tagente_datos_size = "Warning Status   The tagente_datos table contains too much data. A historical database is recommended."; } return $tagente_datos_size; @@ -274,6 +274,7 @@ if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') { } $path_server_logs = '/log/pandora/pandora_server.log'; +$path_err_logs = '/log/pandora/pandora_server.error'; $path_console_logs = '/www/html/pandora_console/pandora_console.log'; $innodb_log_file_size_min_rec_value = '64M'; $innodb_log_buffer_size_min_rec_value = '16M'; @@ -294,16 +295,16 @@ $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) { $status_tables_frag = ''; if ($tables_fragmentation > $tables_fragmentation_max_rec_value) { - $status_tables_frag = "Warning Status   The fragmentation tables is higher than recommended. You should defragment them."; + $status_tables_frag = "Warning Status   Table fragmentation is higher than recommended. They should be defragmented."; } else { - $status_tables_frag = "Normal Status   The fragmentation tables is correct."; + $status_tables_frag = "Normal Status   Table fragmentation is correct."; } return $status_tables_frag; @@ -319,9 +320,9 @@ if ($console_mode == 1) { echo "\nPandora FMS PHP diagnostic tool v3.2 (c) Artica ST 2009-2010 \n"; if ($argc == 1 || in_array($argv[1], ['--help', '-help', '-h', '-?'])) { - echo "\nThis command line script gives information about Pandora FMS database. -This program only can be executed from console, and need a parameter, the -full path to Pandora FMS 'config.php' file. + echo "\nThis command line script contains information about Pandora FMS database. + This program can only be executed from the console, and it needs a parameter, the + full path to Pandora FMS 'config.php' file. Usage: php pandora_diag.php path_to_pandora_console @@ -344,15 +345,21 @@ full path to Pandora FMS 'config.php' file. include '../include/config.php'; } - // Not from console, this is a web session - if ((!isset($config['id_user'])) or (!check_acl($config['id_user'], 0, 'PM'))) { + // Not from console, this is a web session. + if ((!isset($config['id_user'])) || (!check_acl($config['id_user'], 0, 'PM'))) { echo "

You don't have privileges to use diagnostic tool

"; echo '

Please login with an administrator account before try to use this tool

'; exit; } - // Header - ui_print_page_header(__('Pandora FMS Diagnostic tool'), '', false, '', true); + // Header. + ui_print_page_header( + __('Pandora FMS Diagnostic tool'), + '', + false, + 'diagnostic_tool_tab', + true + ); echo "
"; echo "'; @@ -677,7 +684,7 @@ render_info_data( $read_rnd_buffer_size = (db_get_value_sql('SELECT @@read_rnd_buffer_size') / 1024); $query_cache_min_res_unit = (db_get_value_sql('SELECT @@query_cache_min_res_unit') / 1024); $innodb_file_per_table = db_get_value_sql('SELECT @@innodb_file_per_table'); - echo "'; + echo "'; render_row(status_values($innodb_log_file_size_min_rec_value, $innodb_log_file_size), 'InnoDB log file size ', 'InnoDB log file size '); render_row(status_values($innodb_log_buffer_size_min_rec_value, $innodb_log_buffer_size), 'InnoDB log buffer size ', 'InnoDB log buffer size '); @@ -704,12 +711,14 @@ render_info_data( render_row($tables_fragmentation_max_rec_value.'%', 'Tables fragmentation (maximum recommended value)'); render_row(number_format($tables_fragmentation, 2).'%', 'Tables fragmentation (current value)'); - render_row(status_fragmentation_tables($tables_fragmentation_max_rec_value, $tables_fragmentation), 'Status fragmentation tables'); + render_row(status_fragmentation_tables($tables_fragmentation_max_rec_value, $tables_fragmentation), 'Table fragmentation status'); echo "'; render_row(number_format((get_logs_size($path_server_logs) / 1048576), 3).'M', 'Size server logs (current value)'); render_row(get_status_logs($path_server_logs), 'Status server logs'); + render_row(number_format((get_logs_size($path_err_logs) / 1048576), 3).'M', 'Size error logs (current value)'); + render_row(get_status_logs($path_err_logs), 'Status error logs'); render_row(number_format((get_logs_size($path_console_logs) / 1048576), 3).'M', 'Size console logs (current value)'); render_row(get_status_logs($path_console_logs), 'Status console logs'); @@ -731,14 +740,14 @@ render_info_data( echo "'; - render_row($attachment_total_files, 'Total files in the attachment folder'); + render_row($attachment_total_files, 'Total files in the attached folder'); render_row(files_attachment_folder($attachment_total_files), 'Status of the attachment folder'); echo "'; - render_row($tagente_datos_size, 'Total data in the tagente_datos table'); - render_row(status_tagente_datos($tagente_datos_size), 'Status of the tagente_datos table'); - render_row(execution_time(), 'Degradation of the execution time when executing a count'); + render_row($tagente_datos_size, 'Total data in tagente_datos table'); + render_row(status_tagente_datos($tagente_datos_size), 'Tangente_datos table status'); + render_row(execution_time(), 'Execution time degradation when executing a count'); echo "'; @@ -781,6 +790,6 @@ render_info_data( echo "
"; echo ''.__( - '(*) Please check your Pandora Server setup and be sure that database maintenance daemon is running. It\' very important to -keep up-to-date database to get the best performance and results in Pandora' + '(*) Please check your Pandora Server setup and make sure that the database maintenance daemon is running. It\' is very important to + keep the database up-to-date to get the best performance and results in Pandora' ).'


'; 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 e7cedb62f5..2c9ff7e7de 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 @@ -58,6 +58,7 @@ CREATE TABLE IF NOT EXISTS `tlocal_component` ( ALTER TABLE `tlocal_component` ADD COLUMN `dynamic_next` bigint(20) NOT NULL default '0'; ALTER TABLE `tlocal_component` ADD COLUMN `dynamic_two_tailed` tinyint(1) unsigned default '0'; +ALTER TABLE `tlocal_component` ADD COLUMN `ff_type` tinyint(1) unsigned default '0'; -- ----------------------------------------------------- -- Table `tpolicy_modules` @@ -136,6 +137,7 @@ CREATE TABLE IF NOT EXISTS `tpolicy_modules` ( ALTER TABLE `tpolicy_modules` ADD COLUMN `dynamic_next` bigint(20) NOT NULL default '0'; ALTER TABLE `tpolicy_modules` ADD COLUMN `dynamic_two_tailed` tinyint(1) unsigned default '0'; +ALTER TABLE `tpolicy_modules` ADD COLUMN `ff_type` tinyint(1) unsigned default '0'; -- --------------------------------------------------------------------- -- Table `tpolicies` @@ -759,11 +761,41 @@ CREATE TABLE IF NOT EXISTS `treport_content_template` ( PRIMARY KEY(`id_rc`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; +-- ---------------------------------------------------------------------- +-- Table `tnews` +-- ---------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tnews` ( + `id_news` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `author` varchar(255) NOT NULL DEFAULT '', + `subject` varchar(255) NOT NULL DEFAULT '', + `text` TEXT NOT NULL, + `timestamp` DATETIME NOT NULL DEFAULT 0, + `id_group` int(10) NOT NULL default 0, + `modal` tinyint(1) DEFAULT 0, + `expire` tinyint(1) DEFAULT 0, + `expire_timestamp` DATETIME NOT NULL DEFAULT 0, + PRIMARY KEY(`id_news`) +) ENGINE = InnoDB DEFAULT CHARSET=utf8; + + ALTER TABLE treport_content_template ADD COLUMN `historical_db` tinyint(1) NOT NULL DEFAULT '0'; ALTER TABLE treport_content_template ADD COLUMN `lapse_calc` tinyint(1) default '0'; ALTER TABLE treport_content_template ADD COLUMN `lapse` int(11) default '300'; ALTER TABLE treport_content_template ADD COLUMN `visual_format` tinyint(1) default '0'; ALTER TABLE treport_content_template ADD COLUMN `hide_no_data` tinyint(1) default '0'; +ALTER TABLE `treport_content_template` ADD COLUMN `total_time` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `time_failed` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `time_in_ok_status` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `time_in_unknown_status` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `time_of_not_initialized_module` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `time_of_downtime` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `total_checks` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `checks_failed` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `checks_in_ok_status` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `unknown_checks` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `agent_max_value` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `agent_min_value` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `current_month` TINYINT(1) DEFAULT '1'; -- ----------------------------------------------------- -- Table `treport_content_sla_com_temp` (treport_content_sla_combined_template) @@ -1150,6 +1182,9 @@ ALTER TABLE tagente_estado MODIFY `status_changes` tinyint(4) unsigned default 0 ALTER TABLE tagente_estado CHANGE `last_known_status` `known_status` tinyint(4) default 0; ALTER TABLE tagente_estado ADD COLUMN `last_known_status` tinyint(4) default 0; ALTER TABLE tagente_estado ADD COLUMN last_unknown_update bigint(20) NOT NULL default 0; +ALTER TABLE `tagente_estado` ADD COLUMN `ff_normal` int(4) unsigned default '0'; +ALTER TABLE `tagente_estado` ADD COLUMN `ff_warning` int(4) unsigned default '0'; +ALTER TABLE `tagente_estado` ADD COLUMN `ff_critical` int(4) unsigned default '0'; -- --------------------------------------------------------------------- -- Table `talert_actions` @@ -1180,6 +1215,7 @@ ALTER TABLE talert_actions ADD COLUMN `field15_recovery` TEXT NOT NULL DEFAULT " UPDATE `talert_commands` SET `fields_descriptions` = '[\"Integria IMS API path\",\"Integria IMS API pass\",\"Integria IMS user\",\"Integria IMS user pass\",\"Ticket title\",\"Ticket group ID\",\"Ticket priority\",\"Email copy\",\"Ticket owner\",\"Ticket description\"]', `fields_values` = '[\"\",\"\",\"\",\"\",\"\",\"\",\"10,Maintenance;0,Informative;1,Low;2,Medium;3,Serious;4,Very Serious\",\"\",\"\",\"\"]' WHERE `id` = 11 AND `name` = 'Integria IMS Ticket'; UPDATE `talert_commands` SET `description` = 'This alert send an email using internal Pandora FMS Server SMTP capabilities (defined in each server, using: _field1_ as destination email address, and _field2_ as subject for message. _field3_ as text of message. _field4_ as content type (text/plain or html/text).', `fields_descriptions` = '[\"Destination address\",\"Subject\",\"Text\",\"Content Type\",\"\",\"\",\"\",\"\",\"\",\"\"]', `fields_values` = '[\"\",\"\",\"_html_editor_\",\"_content_type_\",\"\",\"\",\"\",\"\",\"\",\"\"]' WHERE id=1; ALTER TABLE `talert_commands` ADD COLUMN `id_group` mediumint(8) unsigned NULL default 0; +ALTER TABLE `talert_commands` ADD COLUMN `fields_hidden` text; UPDATE `talert_actions` SET `field4` = 'text/html', `field4_recovery` = 'text/html' WHERE id = 1; @@ -1199,13 +1235,13 @@ ALTER TABLE titem MODIFY `source_data` int(10) unsigned; INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30'); -INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 26); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 28); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_docs_logo', 'default_docs.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png'); UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager'; DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise'; -INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '733'); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '735'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp'); -- --------------------------------------------------------------------- @@ -1252,6 +1288,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` @@ -1260,6 +1301,10 @@ ALTER TABLE tagente_modulo ADD COLUMN `dynamic_next` bigint(20) NOT NULL default ALTER TABLE tagente_modulo ADD COLUMN `dynamic_two_tailed` tinyint(1) unsigned default '0'; ALTER TABLE tagente_modulo ADD COLUMN `parent_module_id` int(10) unsigned NOT NULL default 0; ALTER TABLE `tagente_modulo` ADD COLUMN `cps` int NOT NULL default 0; +ALTER TABLE `tagente_modulo` ADD COLUMN `ff_type` tinyint(1) unsigned default '0'; +ALTER TABLE `tagente_modulo` ADD COLUMN `ff_normal` int(4) unsigned default '0'; +ALTER TABLE `tagente_modulo` ADD COLUMN `ff_warning` int(4) unsigned default '0'; +ALTER TABLE `tagente_modulo` ADD COLUMN `ff_critical` int(4) unsigned default '0'; -- --------------------------------------------------------------------- -- Table `tagente_datos` @@ -1279,6 +1324,7 @@ ALTER TABLE tnetwork_component ADD COLUMN `dynamic_max` int(4) default '0'; ALTER TABLE tnetwork_component ADD COLUMN `dynamic_min` int(4) default '0'; ALTER TABLE tnetwork_component ADD COLUMN `dynamic_next` bigint(20) NOT NULL default '0'; ALTER TABLE tnetwork_component ADD COLUMN `dynamic_two_tailed` tinyint(1) unsigned default '0'; +ALTER TABLE `tnetwork_component` ADD COLUMN `ff_type` tinyint(1) unsigned default '0'; -- --------------------------------------------------------------------- -- Table `tagente` @@ -1329,6 +1375,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` @@ -1355,6 +1402,7 @@ ALTER TABLE tgraph ADD COLUMN `fullscale` tinyint(1) UNSIGNED NOT NULL default ' -- Table `tnetflow_filter` -- --------------------------------------------------------------------- ALTER TABLE tnetflow_filter ADD COLUMN `router_ip` TEXT NOT NULL DEFAULT ""; +UPDATE `tnetflow_filter` SET aggregate="dstip" WHERE aggregate NOT IN ("dstip", "srcip", "dstport", "srcport"); -- --------------------------------------------------------------------- -- Table `treport_custom_sql` @@ -1369,13 +1417,27 @@ UPDATE treport_custom_sql SET `sql` = 'select t1.alias as agent_n -- ---------------------------------------------------------------------- -- Table `treport_content` -- --------------------------------------------------------------------- - ALTER TABLE treport_content ADD COLUMN `historical_db` tinyint(1) NOT NULL DEFAULT '0'; ALTER TABLE treport_content ADD COLUMN `lapse_calc` tinyint(1) default '0'; ALTER TABLE treport_content ADD COLUMN `lapse` int(11) default '300'; ALTER TABLE treport_content ADD COLUMN `visual_format` tinyint(1) default '0'; ALTER TABLE treport_content ADD COLUMN `hide_no_data` tinyint(1) default '0'; ALTER TABLE treport_content ADD COLUMN `recursion` tinyint(1) default NULL; +ALTER TABLE treport_content ADD COLUMN `show_extended_events` tinyint(1) default '0'; +UPDATE `treport_content` SET type="netflow_summary" WHERE type="netflow_pie" OR type="netflow_statistics"; +ALTER TABLE `treport_content` ADD COLUMN `total_time` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `time_failed` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `time_in_ok_status` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `time_in_unknown_status` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `time_of_not_initialized_module` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `time_of_downtime` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `total_checks` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `checks_failed` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `checks_in_ok_status` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `unknown_checks` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `agent_max_value` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `agent_min_value` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `current_month` TINYINT(1) DEFAULT '1'; -- --------------------------------------------------------------------- -- Table `tmodule_relationship` @@ -1410,6 +1472,7 @@ ALTER TABLE trecon_task ADD `vlan_enabled` int(2) unsigned default '0'; ALTER TABLE trecon_task ADD `wmi_enabled` tinyint(1) unsigned DEFAULT '0'; ALTER TABLE trecon_task ADD `auth_strings` text; ALTER TABLE trecon_task ADD `autoconfiguration_enabled` tinyint(1) unsigned default '0'; +ALTER TABLE trecon_task ADD `summary` text; -- --------------------------------------------------------------------- -- Table `twidget` AND Table `twidget_dashboard` @@ -1912,6 +1975,47 @@ CREATE TABLE `tgis_map_layer_groups` ( CONSTRAINT `tgis_map_layer_groups_ibfk_3` FOREIGN KEY (`agent_id`) REFERENCES `tagente` (`id_agente`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- ----------------------------------------------------- +-- Table `tnetwork_matrix` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tnetwork_matrix` ( + `id` int(10) unsigned NOT NULL auto_increment, + `source` varchar(60) default '', + `destination` varchar(60) default '', + `utimestamp` bigint(20) default 0, + `bytes` int(18) unsigned default 0, + `pkts` int(18) unsigned default 0, + PRIMARY KEY (`id`), + 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` -- ----------------------------------------------------- @@ -1934,7 +2038,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); -- ----------------------------------------------------- @@ -2031,6 +2135,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 -- ---------------------------------------------------------------------- @@ -2040,3 +2147,48 @@ INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Di -- Add column in table `tagent_custom_fields` -- ---------------------------------------------------------------------- ALTER TABLE tagent_custom_fields ADD COLUMN `combo_values` VARCHAR(255) DEFAULT ''; + +-- ---------------------------------------------------------------------- +-- Add column in table `tnetflow_filter` +-- ---------------------------------------------------------------------- +ALTER TABLE `tnetflow_filter` DROP COLUMN `output`; + + +-- ---------------------------------------------------------------------- +-- Update table `tuser_task` +-- ---------------------------------------------------------------------- +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' +-- ---------------------------------------------------------------------- + +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` +-- ---------------------------------------------------------------------- + + 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/firts_task/collections.php b/pandora_console/general/firts_task/collections.php index 269de3ba12..8e27ce6ee3 100755 --- a/pandora_console/general/firts_task/collections.php +++ b/pandora_console/general/firts_task/collections.php @@ -22,7 +22,7 @@ ui_require_css_file('firts_task'); __('Collections')]); ?>
-

+

true, 'message' => __('There are no custom __('Custom Fields')]); ?>

-

+

true, 'message' => __('There are no custom __('Custom Graphs')]); ?>

-

+

__('Fields Manager')]); ?>

-

+

__('Incidents')]); ?>

-

+

__('Visual Console')]); ?>

-

+

__('Network Map')]); ?>

-

+

__('Planned Downtime')]); ?>

-

+

__('Discovery server')]); ?>

-

+

__('Services')]); ?>

-

+

__('SNMP Filter')]); ?>

-

+

__('Tags')]); ?>

-

+

__('Transactions')]); ?>

-

+

'; -echo ''.__('Page generated at').' '.date($config['date_format']); -echo '
® '.get_copyright_notice().''; if (isset($config['debug'])) { $cache_info = []; diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 7addef057f..a093596b2b 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -18,10 +18,14 @@ require_once 'include/functions_notifications.php'; // Global errors/warnings checking. config_check(); -?> -

-
+if ($config['menu_type'] == 'classic') { + echo '
'; +} else { + echo '
'; +} +?> +
'; - // Search + // Search. $acl_head_search = true; if ($config['acl_enterprise'] == 1 && !users_is_admin()) { $acl_head_search = db_get_sql( @@ -94,7 +98,7 @@ require_once 'include/functions_notifications.php'; } if ($acl_head_search) { - // Search bar + // Search bar. $search_bar = ''; if (!isset($config['search_keywords'])) { $search_bar .= ''; @@ -116,15 +120,13 @@ require_once 'include/functions_notifications.php'; } $search_bar .= 'onfocus="javascript: if (fieldKeyWordEmpty) $(\'#keywords\').val(\'\');" - onkeyup="javascript: fieldKeyWordEmpty = false;" - style="margin-top:5px;" class="search_input" />'; + onkeyup="javascript: fieldKeyWordEmpty = false;" class="search_input" />'; // $search_bar .= 'onClick="javascript: document.quicksearch.submit()"'; $search_bar .= ""; $search_bar .= ''; - $header_searchbar = ''; + $header_searchbar = ''; } @@ -141,14 +143,74 @@ require_once 'include/functions_notifications.php'; $_GET['sec2'] = ''; } + if ($_GET['sec'] == 'main' || !isset($_GET['sec'])) { + // home screen chosen by the user + $home_page = ''; + if (isset($config['id_user'])) { + $user_info = users_get_user_by_id($config['id_user']); + $home_page = io_safe_output($user_info['section']); + $home_url = $user_info['data_section']; + } + + if ($home_page != '') { + switch ($home_page) { + case 'Event list': + $_GET['sec2'] = 'operation/events/events'; + break; + + case 'Group view': + $_GET['sec2'] = 'operation/agentes/group_view'; + break; + + case 'Alert detail': + $_GET['sec2'] = 'operation/agentes/alerts_status'; + break; + + case 'Tactical view': + $_GET['sec2'] = 'operation/agentes/tactical'; + break; + + case 'Default': + $_GET['sec2'] = 'general/logon_ok'; + break; + + case 'Dashboard': + $_GET['sec2'] = 'enterprise/dashboard/main_dashboard'; + break; + + case 'Visual console': + $_GET['sec2'] = 'operation/visual_console/render_view'; + break; + + case 'Other': + $home_url = io_safe_output($home_url); + $url_array = parse_url($home_url); + parse_str($url_array['query'], $res); + foreach ($res as $key => $param) { + $_GET[$key] = $param; + } + break; + } + } + } + if (!isset($_GET['refr'])) { $_GET['refr'] = null; } - $select = db_process_sql("SELECT autorefresh_white_list,time_autorefresh FROM tusuario WHERE id_user = '".$config['id_user']."'"); - $autorefresh_list = json_decode($select[0]['autorefresh_white_list']); + $select = db_process_sql( + "SELECT autorefresh_white_list,time_autorefresh + FROM tusuario + WHERE id_user = '".$config['id_user']."'" + ); - if ($autorefresh_list !== null && array_search($_GET['sec2'], $autorefresh_list) !== false) { + $autorefresh_list = json_decode( + $select[0]['autorefresh_white_list'] + ); + + if ($autorefresh_list !== null + && array_search($_GET['sec2'], $autorefresh_list) !== false + ) { $do_refresh = true; if ($_GET['sec2'] == 'operation/agentes/pandora_networkmap') { if ((!isset($_GET['tab'])) || ($_GET['tab'] != 'view')) { @@ -157,23 +219,65 @@ require_once 'include/functions_notifications.php'; } if ($do_refresh) { - $autorefresh_img = html_print_image('images/header_refresh_gray.png', true, ['class' => 'bot', 'alt' => 'lightning', 'title' => __('Configure autorefresh')]); + $autorefresh_img = html_print_image( + 'images/header_refresh_gray.png', + true, + [ + 'class' => 'bot', + 'alt' => 'lightning', + 'title' => __('Configure autorefresh'), + ] + ); - if ($_GET['refr']) { - $autorefresh_txt .= ' ('.date('i:s', $config['refr']).')'; + if ((isset($select[0]['time_autorefresh']) === true) + && $select[0]['time_autorefresh'] !== 0 + && $config['refr'] === null + ) { + $config['refr'] = $select[0]['time_autorefresh']; + $autorefresh_txt .= ' ('; + $autorefresh_txt .= date( + 'i:s', + $config['refr'] + ); + $autorefresh_txt .= ')'; + } else if ($_GET['refr']) { + $autorefresh_txt .= ' ('; + $autorefresh_txt .= date('i:s', $config['refr']); + $autorefresh_txt .= ')'; } $ignored_params['refr'] = ''; $values = get_refresh_time_array(); + $autorefresh_additional = ''; unset($values); + if ($home_page != '') { + $autorefresh_link_open_img = ''; + } else { + $autorefresh_link_open_img = ''; + } - $autorefresh_link_open_img = ''; - - if ($_GET['refr']) { - $autorefresh_link_open_txt = ''; + if ($_GET['refr'] + || ((isset($select[0]['time_autorefresh']) === true) + && $select[0]['time_autorefresh'] !== 0) + ) { + if ($home_page != '') { + $autorefresh_link_open_txt = ''; + } else { + $autorefresh_link_open_txt = ''; + } } else { $autorefresh_link_open_txt = ''; } @@ -192,7 +296,15 @@ require_once 'include/functions_notifications.php'; $display_counter = 'display:none'; } } else { - $autorefresh_img = html_print_image('images/header_refresh_disabled_gray.png', true, ['class' => 'bot autorefresh_disabled', 'alt' => 'lightning', 'title' => __('Disabled autorefresh')]); + $autorefresh_img = html_print_image( + 'images/header_refresh_disabled_gray.png', + true, + [ + 'class' => 'bot autorefresh_disabled', + 'alt' => 'lightning', + 'title' => __('Disabled autorefresh'), + ] + ); $ignored_params['refr'] = false; @@ -203,56 +315,80 @@ require_once 'include/functions_notifications.php'; $display_counter = 'display:none'; } - $header_autorefresh = '
'.$autorefresh_link_open_img.$autorefresh_img.$autorefresh_link_close.'
'; - $header_autorefresh_counter = '
'.$autorefresh_link_open_txt.$autorefresh_txt.$autorefresh_link_close.$autorefresh_additional.'
'; + $header_autorefresh = '
'; + $header_autorefresh .= $autorefresh_link_open_img; + $header_autorefresh .= $autorefresh_img; + $header_autorefresh .= $autorefresh_link_close; + $header_autorefresh .= '
'; + + $header_autorefresh_counter = '
'; + $header_autorefresh_counter .= $autorefresh_link_open_txt; + $header_autorefresh_counter .= $autorefresh_txt; + $header_autorefresh_counter .= $autorefresh_link_close; + $header_autorefresh_counter .= $autorefresh_additional; + $header_autorefresh_counter .= '
'; - // Qr. - if ($config['show_qr_code_header'] == 0) { - $show_qr_code_header = 'display: none;'; + // Support. + if (defined('PANDORA_ENTERPRISE')) { + $header_support_link = 'https://support.artica.es/'; } else { - $show_qr_code_header = 'display: inline;'; + $header_support_link = 'https://pandorafms.com/forums/'; } - $header_qr = '
'; + $header_support = ''; + + // Documentation. + $header_docu = ''; + - echo "'; - ?> - - __('Edit my user'), 'class' => 'bot', 'alt' => 'user']); + $header_user = html_print_image( + 'images/header_user_admin_green.png', + true, + [ + 'title' => __('Edit my user'), + 'class' => 'bot', + 'alt' => 'user', + ] + ); } else { - $header_user = html_print_image('images/header_user_green.png', true, ['title' => __('Edit my user'), 'class' => 'bot', 'alt' => 'user']); + $header_user = html_print_image( + 'images/header_user_green.png', + true, + [ + 'title' => __('Edit my user'), + 'class' => 'bot', + 'alt' => 'user', + ] + ); } $header_user = ''; // Logout. $header_logout = ''; - echo '
'.$header_autorefresh, $header_autorefresh_counter, $header_qr, $header_chat.'
-
'.$header_searchbar, $header_discovery, $servers_list.'
-
'.$header_user, $header_logout.'
'; + echo '
'.$config['custom_title_header'].''.$config['custom_subtitle_header'].'
+
'.$header_searchbar.'
+
'.$header_chat, $header_autorefresh, $header_autorefresh_counter, $header_discovery, $servers_list, $header_support, $header_docu, $header_user, $header_logout.'
'; ?>
@@ -490,7 +626,12 @@ require_once 'include/functions_notifications.php'; ); - $("a.autorefresh_txt").toggle (); - $("#combo_refr").toggle (); - href = $("a.autorefresh").attr ("href"); - - var refresh = ''; - $(document).attr ("location", href + refresh); - - - if (fixed_header) { $('div#head').addClass('fixed_header'); - $('div#page') - .css('padding-top', $('div#head').innerHeight() + 'px') - .css('position', 'relative'); + $('div#main').css('padding-top', $('div#head').innerHeight() + 'px'); } check_new_chats_icon('icon_new_messages_chat'); @@ -547,14 +669,14 @@ require_once 'include/functions_notifications.php'; blinkpubli(); $("#header_autorefresh").css('padding-right', '5px'); - var refr_time = ; + var refr_time = ; var t = new Date(); - t.setTime (t.getTime () + - parseInt()); - $("#refrcounter").countdown ({until: t, + t.setTime (t.getTime () + parseInt()); + $("#refrcounter").countdown ({ + until: t, layout: '%M%nn%M:%S%nn%S', labels: ['', '', '', '', '', '', ''], onExpiry: function () { 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 ea73318e2a..86dccfa53a 100755 --- a/pandora_console/general/login_page.php +++ b/pandora_console/general/login_page.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; @@ -305,12 +305,12 @@ if (file_exists(ENTERPRISE_DIR.'/load_enterprise.php')) { echo ''; @@ -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 '
'; diff --git a/pandora_console/general/login_required.php b/pandora_console/general/login_required.php deleted file mode 100644 index 726d6ab5d1..0000000000 --- a/pandora_console/general/login_required.php +++ /dev/null @@ -1,273 +0,0 @@ - $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 21c9713a48..649a2d2f68 100644 --- a/pandora_console/general/logon_ok.php +++ b/pandora_console/general/logon_ok.php @@ -1,26 +1,39 @@
".__('Pandora status info').'
".__('MySQL Performance metrics').'
".__('MySQL Performance metrics').' '.ui_print_help_icon('performance_metrics_tab', true).'
".__(' Pandora FMS logs dates').'
".__(' Status of the attachment folder').'
".__(' Information from the tagente_datos table').'
".__(' Pandora FMS server threads').'
@@ -88,7 +113,7 @@ if (!empty($all_data)) { class = 'databox'; @@ -101,12 +126,12 @@ if (!empty($all_data)) { $table->head[0] = ''.__('%s Overview', get_product_name()).''; $table->head_colspan[0] = 4; - // Indicators + // Indicators. $tdata = []; $stats = reporting_get_stats_indicators($data, 120, 10, false); $status = '
'; foreach ($stats as $stat) { - $status .= ''; + $status .= ''; } $status .= '
'.$stat['title'].''.''.$stat['graph'].'
'.$stat['title'].''.$stat['graph'].'
'; @@ -115,25 +140,25 @@ if (!empty($all_data)) { $table->data[] = $tdata; - // Alerts + // Alerts. $tdata = []; $tdata[0] = reporting_get_stats_alerts($data); $table->rowclass[] = ''; $table->data[] = $tdata; - // Modules by status + // Modules by status. $tdata = []; $tdata[0] = reporting_get_stats_modules_status($data, 180, 100); $table->rowclass[] = ''; $table->data[] = $tdata; - // Total agents and modules + // Total agents and modules. $tdata = []; $tdata[0] = reporting_get_stats_agents_monitors($data); $table->rowclass[] = ''; $table->data[] = $tdata; - // Users + // Users. if (users_is_admin()) { $tdata = []; $tdata[0] = reporting_get_stats_users($data); @@ -160,7 +185,7 @@ if (!empty($all_data)) { if (!empty($news)) { - // NEWS BOARD///////////////////////////// + // NEWS BOARD. echo '
'; echo ''; @@ -172,32 +197,42 @@ if (!empty($all_data)) { } foreach ($news as $article) { - $text = io_safe_output($article['text']); - + $image = false; + if ($article['text'] == '&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; ') { + $image = true; + } + $text_bbdd = io_safe_output($article['text']); + $text = html_entity_decode($text_bbdd); echo ''; echo ''; echo ''; } echo '
'.$article['subject'].'
'.__('by').' '.$article['author'].' '.ui_print_timestamp($article['timestamp'], true).' '.$comparation_suffix.'
'; + if ($image) { + echo '
img colabora con nosotros - Support
'; + } + echo nl2br($text); echo '
'; echo '
'; - // News board + // News board. echo '

'; - // END OF NEWS BOARD///////////////////////////// + // END OF NEWS BOARD. } - // LAST ACTIVITY///////////////////////////// - // Show last activity from this user + // LAST ACTIVITY. + // Show last activity from this user. echo '
'; $table = new stdClass(); - $table->class = 'databox data'; + $table->class = 'info_table'; + $table->cellpadding = 0; + $table->cellspacing = 0; $table->width = '100%'; - // Don't specify px + // Don't specify px. $table->data = []; $table->size = []; $table->size[0] = '5%'; @@ -212,38 +247,14 @@ if (!empty($all_data)) { $table->head[3] = __('Source IP'); $table->head[4] = __('Comments'); $table->title = ''.__('This is your last activity performed on the %s console', get_product_name()).''; - - switch ($config['dbtype']) { - case 'mysql': - $sql = sprintf( - 'SELECT id_usuario,accion, ip_origen,descripcion,utimestamp + $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'] - ); - break; + $config['id_user'] + ); - case 'postgresql': - $sql = sprintf( - "SELECT \"id_usuario\", accion, \"ip_origen\", descripcion, utimestamp - FROM tsesion - WHERE (\"utimestamp\" > ceil(date_part('epoch', CURRENT_TIMESTAMP)) - ".SECONDS_1WEEK.") - AND \"id_usuario\" = '%s' ORDER BY \"utimestamp\" DESC LIMIT 10", - $config['id_user'] - ); - break; - - case 'oracle': - $sql = sprintf( - "SELECT id_usuario, accion, ip_origen, descripcion, utimestamp - FROM tsesion - WHERE ((utimestamp > ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) - '.SECONDS_1WEEK.") - AND id_usuario = '%s') AND rownum <= 10 ORDER BY utimestamp DESC", - $config['id_user'] - ); - break; - } $sessions = db_get_all_rows_sql($sql); @@ -253,24 +264,17 @@ if (!empty($all_data)) { foreach ($sessions as $session) { $data = []; + $session_id_usuario = $session['id_usuario']; + $session_ip_origen = $session['ip_origen']; - switch ($config['dbtype']) { - case 'mysql': - case 'oracle': - $session_id_usuario = $session['id_usuario']; - $session_ip_origen = $session['ip_origen']; - break; - - case 'postgresql': - $session_id_usuario = $session['id_usuario']; - $session_ip_origen = $session['ip_origen']; - break; - } $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[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) { @@ -287,8 +291,7 @@ if (!empty($all_data)) { unset($table); echo '
'; echo ''; - // activity - // END OF LAST ACTIVIYY///////////////////////////// + // END OF LAST ACTIVIYY. ?> diff --git a/pandora_console/general/main_menu.php b/pandora_console/general/main_menu.php index cb5126b621..877f171090 100644 --- a/pandora_console/general/main_menu.php +++ b/pandora_console/general/main_menu.php @@ -20,31 +20,13 @@ if (! isset($config['id_user'])) { \ No newline at end of file diff --git a/pandora_console/general/register.php b/pandora_console/general/register.php new file mode 100644 index 0000000000..e6a26bb250 --- /dev/null +++ b/pandora_console/general/register.php @@ -0,0 +1,184 @@ + -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 93c668f00c..67a933d8cb 100644 --- a/pandora_console/godmode/admin_access_logs.php +++ b/pandora_console/godmode/admin_access_logs.php @@ -183,10 +183,10 @@ if (empty($result)) { } $table = new stdClass(); -$table->cellpadding = 4; -$table->cellspacing = 4; +$table->cellpadding = 0; +$table->cellspacing = 0; $table->width = '100%'; -$table->class = 'databox data'; +$table->class = 'info_table'; $table->size = []; $table->data = []; $table->head = []; @@ -246,7 +246,18 @@ foreach ($result as $row) { } } +foreach ($table->rowclass as $key => $value) { + if (strpos($value, 'limit_scroll') !== false) { + $table->colspan[$key] = [7]; + } else { + if ($enterprise_include !== ENTERPRISE_NOT_HOOK) { + $table->cellclass[$key][6] = 'action_buttons'; + } + } +} + html_print_table($table); +ui_pagination($count, $url, 0, 0, false, 'offset', true, 'pagination-bottom'); if ($enterprise_include !== ENTERPRISE_NOT_HOOK) { enterprise_hook('enterpriseAuditFooter'); diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index a7fc1f156a..dfdd7390c3 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,37 +168,42 @@ 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 ''; -$table = new stdClass(); -$table->width = '100%'; -$table->class = 'databox filters'; - -$table->head = []; -$table->style = []; -$table->style[0] = 'font-weight: bold; width: 150px;'; -$table->data = []; - -$table->align[2] = 'center'; +// 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->data[0][0] = __('Agent name').ui_print_help_tip(__("The agent's name must be the same as the one defined at the console"), true); - $table->data[0][1] = html_print_input_text('agente', $nombre_agente, '', 50, 100, true); - - $table->data[0][2] = __('QR Code Agent view'); + $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 .= '
'; if ($id_agente) { - $table->data[0][1] .= ' '.__('ID')."  $id_agente  "; - $table->data[0][1] .= '  '; - $table->data[0][1] .= html_print_image( + $table_agent_name .= ''; + $table_agent_name .= ''; + $table_agent_name .= html_print_image( 'images/zoom.png', true, [ @@ -195,20 +211,23 @@ if (!$new_agent && $alias != '') { 'title' => __('Agent detail'), ] ); - $table->data[0][1] .= ''; + $table_agent_name .= ''; } -} -// Remote configuration available -if (!$new_agent) { + $agent_options_update = 'agent_options_update'; + + // Delete link from here. + $table_agent_name .= "".html_print_image('images/cross.png', true, ['title' => __('Delete agent')]).''; + + // Remote configuration available. if (isset($filename)) { if (file_exists($filename['md5'])) { $agent_name = agents_get_name($id_agente); $agent_name = io_safe_output($agent_name); $agent_md5 = md5($agent_name, false); - $table->data[0][1] .= '  '.''; - $table->data[0][1] .= html_print_image( + $table_agent_name .= ''; + $table_agent_name .= html_print_image( 'images/application_edit.png', true, [ @@ -216,35 +235,57 @@ if (!$new_agent) { 'title' => __('This agent can be remotely configured'), ] ); - $table->data[0][1] .= ''.ui_print_help_tip( + $table_agent_name .= ''.ui_print_help_tip( __('You can remotely edit this agent configuration'), 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 .= '
'; } -// Delete link from here -if (!$new_agent) { - $table->data[0][1] .= "  ".html_print_image('images/cross.png', true, ['title' => __('Delete agent')]).''; -} - -$table->data[1][0] = __('Alias').ui_print_help_tip(__('Characters /,\,|,%,#,&,$ will be ignored'), true).''; -$table->data[1][1] = html_print_input_text('alias', $alias, '', 50, 100, true); if ($new_agent) { - $table->data[1][1] .= html_print_checkbox('alias_as_name', 1, $config['alias_as_name'], true).__('Use alias as name'); + $label_select_child_left = 'label_select_child_left'; + $label_select_parent = 'label_select_parent'; } -$table->data[2][0] = __('IP Address'); -$table->data[2][1] = html_print_input_text('direccion', $direccion_agente, '', 16, 100, true).html_print_checkbox('unique_ip', 1, $config['unique_ip'], true).__('Unique IP').ui_print_help_tip(__('Set the primary IP address as the unique IP, preventing the same primary IP address from being used in more than one agent'), true); +$table_alias = '

'.__('Alias').': '.ui_print_help_tip(__('Characters /,\,|,%,#,&,$ will be ignored'), true).'

'; +$table_alias .= '
'; +$table_alias .= '
'.html_print_input_text('alias', $alias, '', 50, 100, true).'
'; +if ($new_agent) { + $table_alias .= '
'.html_print_checkbox_switch('alias_as_name', 1, $config['alias_as_name'], true).__('Use alias as name').'
'; +} + +$table_alias .= '
'; + +$table_ip = '

'.__('IP Address').':

'; +$table_ip .= '
'; +$table_ip .= '
'.html_print_input_text('direccion', $direccion_agente, '', 16, 100, true).'
'; +$table_ip .= '
'.html_print_checkbox_switch('unique_ip', 1, $config['unique_ip'], true).__('Unique IP').ui_print_help_tip(__('Set the primary IP address as the unique IP, preventing the same primary IP address from being used in more than one agent'), true).'
'; +$table_ip .= '
'; if ($id_agente) { - $table->data[2][1] .= '    '; - $ip_all = agents_get_addresses($id_agente); - $table->data[2][1] .= html_print_select($ip_all, 'address_list', $direccion_agente, '', '', 0, true); - $table->data[2][1] .= ' '.html_print_checkbox('delete_ip', 1, false, true).__('Delete selected'); + $table_ip .= '
'; + $table_ip .= '
'; + $table_ip .= '
'.html_print_select($ip_all, 'address_list', $direccion_agente, '', '', 0, true).'
'; + $table_ip .= '
'.html_print_checkbox_switch('delete_ip', 1, false, true).__('Delete selected').'
'; + $table_ip .= '
'; } ?> @@ -254,15 +295,6 @@ if ($id_agente) { } rowspan[2][2] = 3; - if ($id_agente) { - $table->data[2][2] = ""; - } else { - $table->data[2][2] = __('Only it is show when
the agent is saved.'); - } -} - $groups = users_get_groups($config['id_user'], 'AR', false); $modules = db_get_all_rows_sql( @@ -277,28 +309,46 @@ if (is_array($modules)) { } } -$table->data[4][0] = __('Primary group'); -// Cannot change primary group if user have not permission for that group +$table_primary_group = '

'.__('Primary group').':

'; +$table_primary_group .= '
'; +// Cannot change primary group if user have not permission for that group. if (isset($groups[$grupo]) || $new_agent) { - $table->data[4][1] = html_print_select_groups(false, 'AR', false, 'grupo', $grupo, '', '', 0, true); + $table_primary_group .= html_print_select_groups(false, 'AR', false, 'grupo', $grupo, '', '', 0, true); } else { - $table->data[4][1] = groups_get_name($grupo); - $table->data[4][1] .= html_print_input_hidden('grupo', $grupo, true); + $table_primary_group .= groups_get_name($grupo); + $table_primary_group .= html_print_input_hidden('grupo', $grupo, true); } -$table->data[4][1] .= ' '; -$table->data[4][1] .= ui_print_group_icon($grupo, true); -$table->data[4][1] .= ''; +$table_primary_group .= '
'; +$table_primary_group .= ui_print_group_icon($grupo, true); +$table_primary_group .= '
'; + +$table_interval = '

'.__('Interval').':

'; +$table_interval .= '
'; +$table_interval .= html_print_extended_select_for_time( + 'intervalo', + $intervalo, + '', + '', + '0', + 10, + true, + false, + true, + 'w40p' +); + -$table->data[5][0] = __('Interval'); -$table->data[5][1] = html_print_extended_select_for_time('intervalo', $intervalo, '', '', '0', 10, true); if ($intervalo < SECONDS_5MINUTES) { - $table->data[5][1] .= clippy_context_help('interval_agent_min'); + $table_interval .= clippy_context_help('interval_agent_min'); } -$table->data[6][0] = __('OS'); -$table->data[6][1] = html_print_select_from_sql( +$table_interval .= '
'; + +$table_os = '

'.__('OS').':

'; +$table_os .= '
'; +$table_os .= html_print_select_from_sql( 'SELECT id_os, name FROM tconfig_os', 'id_os', $id_os, @@ -307,18 +357,19 @@ $table->data[6][1] = html_print_select_from_sql( '0', true ); -$table->data[6][1] .= ' '; -$table->data[6][1] .= ui_print_os_icon($id_os, false, true); -$table->data[6][1] .= ''; +$table_os .= '
'; +$table_os .= ui_print_os_icon($id_os, false, true); +$table_os .= '
'; -// Network server +// Network server. $servers = servers_get_names(); if (!array_key_exists($server_name, $servers)) { $server_Name = 0; // Set the agent have not server. } -$table->data[7][0] = __('Server'); +$table_server = '

'.__('Server').':

'; +$table_server .= '
'; if ($new_agent) { // Set first server by default. $servers_get_names = servers_get_names(); @@ -326,7 +377,7 @@ if ($new_agent) { $server_name = reset($array_keys_servers_get_names); } -$table->data[7][1] = html_print_select( +$table_server .= html_print_select( servers_get_names(), 'server_name', $server_name, @@ -334,118 +385,128 @@ $table->data[7][1] = html_print_select( __('None'), 0, true -).' '.ui_print_help_icon('agent_server', true); +).'
'; -// Description -$table->data[8][0] = __('Description'); -$table->data[8][1] = html_print_input_text( +// Description. +$table_description = '

'.__('Description').':

'; +$table_description .= html_print_textarea( 'comentarios', + 3, + 10, $comentarios, '', - 45, - 200, - true -); + true, + 'agent_description' +).'
'; -html_print_table($table); -unset($table); +// QR code. +echo '
+
+
'.$table_agent_name.$table_alias.$table_ip.$table_primary_group.'
+
'.$table_interval.$table_os.$table_server.$table_description.'
+
'; +if (!$new_agent && $alias != '') { + echo $table_qr_code; +} -$table = new stdClass(); -$table->width = '100%'; -$table->class = 'databox filters'; - -$table->head = []; -$table->style = []; -$table->style[0] = 'font-weight: bold; '; -$table->style[4] = 'font-weight: bold;'; -$table->data = []; +echo '
'; if (enterprise_installed()) { $secondary_groups_selected = enterprise_hook('agents_get_secondary_groups', [$id_agente]); - $table->data['secondary_groups'][0] = __('Secondary groups').ui_print_help_icon('secondary_groups', true); - $table->data['secondary_groups'][1] = html_print_select_groups( + $table_adv_secondary_groups = '

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

'; + $table_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) + // Not disabled (default). + 'width:50%; min-width:170px;', + // Inline styles (default). false, - // Inline styles (default) + // Option style select (default). false, - // 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->data['secondary_groups'][2] = html_print_input_image( + $table_adv_secondary_groups_arrows = html_print_input_image( 'add_secondary', - 'images/darrowright.png', + 'images/darrowright_green.png', 1, '', true, [ + 'id' => 'right_autorefreshlist', 'title' => __('Add secondary groups'), 'onclick' => 'agent_manager_add_secondary_groups(event, '.$id_agente.');', ] - ).'



'.html_print_input_image( + ).html_print_input_image( 'remove_secondary', - 'images/darrowleft.png', + 'images/darrowleft_green.png', 1, '', true, [ + 'id' => 'left_autorefreshlist', 'title' => __('Remove secondary groups'), 'onclick' => 'agent_manager_remove_secondary_groups(event, '.$id_agente.');', ] ); - $table->data['secondary_groups'][3] = html_print_select( + $table_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) - true - // Multiple selection + // Return HTML (not echo). + true, + // Multiple selection. + true, + // Sort. + '', + // Class. + false, + // Disabled. + 'width:50%; 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 @@ -457,70 +518,68 @@ if (enterprise_installed()) { $safe_mode_modules[$m['id_module']] = $m['name']; } - $table->data[2][0] = __('Safe operation mode').ui_print_help_tip( + $table_adv_safe = '

'.__('Safe operation mode').': '.ui_print_help_tip( __( 'This mode allow %s to disable all modules of this agent while the selected module is on CRITICAL status', get_product_name() ), true + ).'

'; + $table_adv_safe .= html_print_checkbox_switch('safe_mode', 1, $safe_mode, true); + $table_adv_safe .= __('Module').' '.html_print_select($safe_mode_modules, 'safe_mode_module', $safe_mode_module, '', '', 0, true).'
'; + } + + // 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 .= ''; + $table_adv_remote .= html_print_image( + 'images/cross.png', + true, + [ + 'title' => __('Delete remote configuration file'), + 'style' => 'vertical-align: middle;', + ] + ).''; + $table_adv_remote .= ''.ui_print_help_tip( + __('Delete this conf file implies that for restore you must reactive remote config in the local agent.'), + true ); - $table->data[2][1] = html_print_checkbox('safe_mode', 1, $safe_mode, true); - $table->data[2][1] .= '  '.__('Module').' '.html_print_select($safe_mode_modules, 'safe_mode_module', $safe_mode_module, '', '', 0, true); - } - - // Remote configuration - $table->data[5][0] = __('Remote configuration'); - - if (!$new_agent) { - $table->data[5][1] = ''.__('Not available').''; - if (isset($filename)) { - if (file_exists($filename['md5'])) { - $table->data[5][1] = date('F d Y H:i:s', fileatime($filename['md5'])); - // Delete remote configuration - $table->data[5][1] .= ''; - $table->data[5][1] .= html_print_image( - 'images/cross.png', - true, - [ - 'title' => __('Delete remote configuration file'), - 'style' => 'vertical-align: middle;', - ] - ).''; - $table->data[5][1] .= ''.ui_print_help_tip( - __('Delete this conf file implies that for restore you must reactive remote config in the local agent.'), - true - ); - } - } } else { - $table->data[5][1] = ''.__('Not available').''; + $table_adv_remote .= ''.__('Not available').''; } + $table_adv_remote .= '
'; - $cps_array[-1] = __('Disabled'); - if ($cps > 0) { - $cps_array[$cps] = __('Enabled'); + // Calculate cps value - agents. + if ($id_agente) { + $cps_val = service_agents_cps($id_agente); } else { - $cps_inc = 0; - if ($id_agente) { - $cps_inc = service_agents_cps($id_agente); + // No agent defined, use received cps as base value. + if ($cps >= 0) { + $cps_val = $cps; } - - $cps_array[$cps_inc] = __('Enabled'); } - $table->data[6][0] = __('Cascade protection services'); - $table->data[6][0] .= ui_print_help_tip(__('Disable the alerts and events of the elements that belong to this service'), true); - $table->data[6][1] = 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->data[0][0] = __('Custom ID'); -$table->data[0][1] = html_print_input_text('custom_id', $custom_id, '', 16, 255, true); -$table->data[1][0] = __('Parent'); +$table_adv_parent = '

'.__('Parent').':

'; $params = []; $params['return'] = true; $params['show_helptip'] = true; @@ -532,75 +591,97 @@ $params['value'] = db_get_value('alias', 'tagente', 'id_agente', $id_parent); $params['selectbox_id'] = 'cascade_protection_module'; $params['javascript_is_function_select'] = true; $params['cascade_protection'] = true; - -$table->data[1][1] = ui_print_agent_autocomplete_input($params); +$table_adv_parent .= '
'; +$table_adv_parent .= ui_print_agent_autocomplete_input($params); if (enterprise_installed()) { - $table->data[1][1] .= html_print_checkbox('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->data[1][1] .= '  '.__('Module').' '.html_print_select($modules_values, 'cascade_protection_module', $cascade_protection_module, '', '', 0, true); -// Learn mode / Normal mode -$table->data[3][0] = __('Module definition').ui_print_help_icon('module_definition', true); -$table->data[3][1] = __('Learning mode').' '.html_print_radio_button_extended( +$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').':

'; +$table_adv_module_mode .= '
'; +$table_adv_module_mode .= html_print_radio_button_extended( 'modo', 1, - '', + __('Learning mode'), $modo, false, 'show_modules_not_learning_mode_context_help();', - 'style="margin-right: 40px;"', + '', true ); -$table->data[3][1] .= __('Normal mode').' '.html_print_radio_button_extended( +$table_adv_module_mode .= html_print_radio_button_extended( 'modo', 0, - '', + __('Normal mode'), $modo, false, 'show_modules_not_learning_mode_context_help();', - 'style="margin-right: 40px;"', + '', true ); -$table->data[3][1] .= __('Autodisable mode').' '.html_print_radio_button_extended( +$table_adv_module_mode .= html_print_radio_button_extended( 'modo', 2, - '', + __('Autodisable mode'), $modo, false, 'show_modules_not_learning_mode_context_help();', - 'style="margin-right: 40px;"', + '', true ); +$table_adv_module_mode .= '
'; -// Status (Disabled / Enabled) -$table->data[4][0] = __('Status'); -$table->data[4][1] = __('Disabled').' '.ui_print_help_tip(__('If the remote configuration is enabled, it will also go into standby mode when disabling it.'), true).' '.html_print_radio_button_extended('disabled', 1, '', $disabled, false, '', 'style="margin-right: 40px;"', true); -$table->data[4][1] .= __('Enabled').' '.html_print_radio_button_extended('disabled', 0, '', $disabled, false, '', 'style="margin-right: 40px;"', true); +// 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 +).'
'; + +// Url address. if (enterprise_installed()) { - $table->data[4][2] = __('Url address').ui_print_help_tip(__('URL address must be complete, for example: https://pandorafms.com/'), true); - $table->data[4][3] = html_print_input_text( + $table_adv_url = '

'.__('Url address').': '.ui_print_help_tip(__('URL address must be complete, for example: https://pandorafms.com/'), true).'

'; + $table_adv_url .= html_print_input_text( 'url_description', $url_description, '', 45, 255, true - ); + ).'
'; } else { - $table->data[5][0] = __('Url address'); - $table->data[5][1] = html_print_input_text( + $table_adv_url = '

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

'; + $table_adv_url .= html_print_input_text( 'url_description', $url_description, '', 45, 255, true - ); + ).''; } -$table->data[5][2] = __('Quiet'); -$table->data[5][3] .= ui_print_help_tip(__('The agent still runs but the alerts and events will be stop'), true); -$table->data[5][3] = html_print_checkbox('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).'
'; $listIcons = gis_get_array_list_icons(); @@ -610,11 +691,11 @@ foreach ($listIcons as $index => $value) { } $path = 'images/gis_map/icons/'; -// TODO set better method the path -$table->data[0][2] = __('Agent icon').ui_print_help_tip(__('Agent icon for GIS Maps.'), true); +// 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'; @@ -629,7 +710,7 @@ if ($icon_path == '') { $path_warning = $path.$icon_path.'.warning.png'; } -$table->data[0][3] = html_print_select( +$table_adv_agent_icon .= html_print_select( $arraySelectIcon, 'icon_path', $icon_path, @@ -637,64 +718,84 @@ $table->data[0][3] = html_print_select( __('None'), '', true -).' '.html_print_image( +).html_print_image( $path_ok, true, [ 'id' => 'icon_ok', 'style' => 'display:'.$display_icons.';', ] -).' '.html_print_image( +).html_print_image( $path_bad, true, [ 'id' => 'icon_bad', 'style' => 'display:'.$display_icons.';', ] -).' '.html_print_image( +).html_print_image( $path_warning, true, [ 'id' => 'icon_warning', 'style' => 'display:'.$display_icons.';', ] -); +).'
'; if ($config['activate_gis']) { - $table->data[3][2] = __('Ignore new GIS data:'); - $table->data[3][3] = __('Yes').' '.html_print_radio_button_extended( - 'update_gis_data', - 0, - '', - $update_gis_data, - false, - '', - 'style="margin-right: 40px;"', - true - ); - $table->data[3][3] .= __('No').' '.html_print_radio_button_extended( - 'update_gis_data', - 1, - '', - $update_gis_data, - false, - '', - 'style="margin-right: 40px;"', - true - ); + $table_adv_gis = '

'.__('Ignore new GIS data:').'

'; + if ($new_agent) { + $update_gis_data = true; + } + + $table_adv_gis .= html_print_checkbox_switch('update_gis_data', 1, $update_gis_data, true).'No / Yes
'; } -ui_toggle(html_print_table($table, true), __('Advanced options')); -unset($table); + + +// General display distribution. +$table_adv_options = $table_adv_secondary_groups.'
+
+ '.$table_adv_secondary_groups_left.' +
+
+ '.$table_adv_secondary_groups_arrows.' +
+
+ '.$table_adv_secondary_groups_right.' +
+
+
+
'.$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_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'); +echo '
'; + $table = new stdClass(); $table->width = '100%'; -$table->class = 'databox filters'; +$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; width: 100px;'; +$table->style[0] = 'font-weight: bold;'; $table->data = []; +$table->rowstyle = []; $fields = db_get_all_fields_in_table('tagent_custom_fields'); @@ -702,12 +803,13 @@ if ($fields === false) { $fields = []; } +$i = 0; foreach ($fields as $field) { - $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 - ); + $id_custom_field = $field['id_field']; + + $data[0] = '
'; + $data[0] .= ''.$field['name'].''; + $data[0] .= '
'; $combo = []; $combo = $field['combo_values']; $combo = explode(',', $combo); @@ -729,8 +831,15 @@ foreach ($fields as $field) { $custom_value = ''; } + $table->rowstyle[$i] = 'cursor: pointer;'; + if (!empty($custom_value)) { + $table->rowstyle[($i + 1)] = 'display: table-row;'; + } else { + $table->rowstyle[($i + 1)] = 'display: none;'; + } + if ($field['is_password_type']) { - $data[1] = html_print_input_text_extended( + $data_field[1] = html_print_input_text_extended( 'customvalue_'.$field['id_field'], $custom_value, 'customvalue_'.$field['id_field'], @@ -744,18 +853,18 @@ foreach ($fields as $field) { true ); } else { - $data[1] = html_print_textarea( + $data_field[1] = html_print_textarea( 'customvalue_'.$field['id_field'], 2, 65, $custom_value, - 'style="min-height: 30px; width:96%;"', + 'style="min-height: 30px;"', true ); } if ($field['combo_values'] !== '') { - $data[1] = html_print_select( + $data_field[1] = html_print_select( $combo_values, 'customvalue_'.$field['id_field'], $custom_value, @@ -776,19 +885,32 @@ foreach ($fields as $field) { ); }; - array_push($table->data, $data); + $table->rowid[] = 'name_field-'.$id_custom_field; + $table->data[] = $data; + + $table->rowid[] = 'field-'.$id_custom_field; + $table->data[] = $data_field; + $i += 2; } if (!empty($fields)) { - ui_toggle(html_print_table($table, true), __('Custom fields')); + echo '
'; + ui_toggle( + html_print_table($table, true), + __('Custom fields'), + '', + true, + false, + 'white_box white_box_opened' + ); + echo '
'; } -echo '
'; - +echo '
'; // The context help about the learning mode. if ($modo == 0) { - echo ""; + echo ""; } else { echo "'; if ($id_agente) { - echo '
'; + echo '
'; html_print_submit_button( __('Update'), 'updbutton', @@ -825,6 +947,19 @@ ui_require_jquery_file('bgiframe'); ?> diff --git a/pandora_console/godmode/alerts/configure_alert_template.php b/pandora_console/godmode/alerts/configure_alert_template.php index d6828dd599..d79ca90ca8 100644 --- a/pandora_console/godmode/alerts/configure_alert_template.php +++ b/pandora_console/godmode/alerts/configure_alert_template.php @@ -56,14 +56,20 @@ if ($a_template !== false) { if (defined('METACONSOLE')) { alerts_meta_print_header(); } else { - // ~ ui_print_page_header (__('Alerts') . - // ~ ' » ' . __('Configure alert template'), "", - // ~ false, "alerts_config", true); + $step = (int) get_parameter('step', 1); + if ($step == 1) { + $help_header = 'configure_alert_template_step_1'; + } else if ($step == 2) { + $help_header = 'configure_alert_template_step_2'; + } else if ($step == 3) { + $help_header = 'configure_alert_template_step_3'; + } + ui_print_page_header( __('Alerts').' » '.__('Configure alert template'), '', false, - '', + $help_header, true ); } @@ -83,7 +89,13 @@ if ($a_template !== false) { if (defined('METACONSOLE')) { alerts_meta_print_header(); } else { - ui_print_page_header(__('Alerts').' » '.__('Configure alert template'), 'images/gm_alerts.png', false, 'conf_alert_template', true); + ui_print_page_header( + __('Alerts').' » '.__('Configure alert template'), + 'images/gm_alerts.png', + false, + 'conf_alert_template', + true + ); } } else { db_pandora_audit( @@ -101,7 +113,22 @@ if ($a_template !== false) { if (defined('METACONSOLE')) { alerts_meta_print_header(); } else { - ui_print_page_header(__('Alerts').' » '.__('Configure alert template'), 'images/gm_alerts.png', false, 'conf_alert_template', true); + $step = (int) get_parameter('step', 1); + if ($step == 1) { + $help_header = 'configure_alert_template_step_1'; + } else if ($step == 2) { + $help_header = 'configure_alert_template_step_2'; + } else if ($step == 3) { + $help_header = 'configure_alert_template_step_3'; + } + + ui_print_page_header( + __('Alerts').' » '.__('Configure alert template'), + 'images/gm_alerts.png', + false, + $help_header, + true + ); } } @@ -679,7 +706,7 @@ if ($step == 2) { 'type', $type, '', - __('Select'), + __('None'), 0, true, false, @@ -1018,6 +1045,7 @@ var onchange_msg = ; var unknown = ; var error_message_min_max_zero = ; +var not_normal = ; function check_fields_step2() { var correct = true; @@ -1174,6 +1202,13 @@ if ($step == 2) { /* Show example */ $("span#example").empty ().append (critical); break; + case "not_normal": + $("#template-value, #template-max, span#matches_value, #template-min").hide (); + $("#template-example").show (); + + /* Show example */ + $("span#example").empty ().append (not_normal); + break; case "onchange": $("#template-value, #template-max, #template-min").hide (); $("#template-example, span#matches_value").show (); diff --git a/pandora_console/godmode/category/category.php b/pandora_console/godmode/category/category.php index 727be02057..e1a61a4db6 100755 --- a/pandora_console/godmode/category/category.php +++ b/pandora_console/godmode/category/category.php @@ -82,7 +82,13 @@ $filter['limit'] = (int) $config['block_size']; // Search action: This will filter the display category view $result = false; -$result = categories_get_all_categories(); +$result = db_get_all_rows_filter( + 'tcategory', + [ + 'limit' => $filter['limit'], + 'offset' => $filter['offset'], + ] +); // Display categories previously filtered or not $rowPair = true; @@ -94,7 +100,7 @@ if (!empty($result)) { $table = new stdClass(); $table->width = '100%'; - $table->class = 'databox data'; + $table->class = 'info_table'; $table->data = []; $table->head = []; @@ -123,7 +129,8 @@ if (!empty($result)) { $data[1] .= ''.html_print_image('images/cross.png', true, ['title' => 'Delete']).''; } else { $data[0] = "".$category['name'].''; - $data[1] = "".html_print_image('images/config.png', true, ['title' => 'Edit']).'  '; + $table->cellclass[][1] = 'action_buttons'; + $data[1] = "".html_print_image('images/config.png', true, ['title' => 'Edit']).''; $data[1] .= ''.html_print_image('images/cross.png', true, ['title' => 'Delete']).''; } @@ -131,6 +138,7 @@ if (!empty($result)) { } html_print_table($table); + ui_pagination($total_categories, $url, $offset, 0, false, 'offset', true, 'pagination-bottom'); } else { // No categories available or selected ui_print_info_message(['no_close' => true, 'message' => __('No categories found') ]); diff --git a/pandora_console/godmode/events/event_filter.php b/pandora_console/godmode/events/event_filter.php index 40d60650f6..60ba973996 100644 --- a/pandora_console/godmode/events/event_filter.php +++ b/pandora_console/godmode/events/event_filter.php @@ -113,31 +113,33 @@ if ($filters === false) { $table = new stdClass(); $table->width = '100%'; -$table->class = 'databox data'; +$table->class = 'info_table'; $table->head = []; -$table->head[0] = __('Name'); -$table->head[1] = __('Group'); -$table->head[2] = __('Event type'); -$table->head[3] = __('Event status'); -$table->head[4] = __('Severity'); -$table->head[5] = __('Action').html_print_checkbox('all_delete', 0, false, true, false); +$table->head[0] = html_print_checkbox('all_delete', 0, false, true, false); +$table->head[1] = __('Name'); +$table->head[2] = __('Group'); +$table->head[3] = __('Event type'); +$table->head[4] = __('Event status'); +$table->head[5] = __('Severity'); +$table->head[6] = __('Action'); $table->style = []; -$table->style[0] = 'font-weight: bold'; +$table->style[1] = 'font-weight: bold'; $table->align = []; -$table->align[1] = 'left'; $table->align[2] = 'left'; $table->align[3] = 'left'; - $table->align[4] = 'left'; + $table->align[5] = 'left'; +$table->align[6] = 'left'; $table->size = []; -$table->size[0] = '50%'; -$table->size[1] = '5px'; -$table->size[2] = '80px'; +$table->size[0] = '20px'; +$table->size[1] = '50%'; +$table->size[2] = '5px'; $table->size[3] = '80px'; $table->size[4] = '80px'; -$table->size[5] = '40px'; +$table->size[5] = '80px'; +$table->size[6] = '40px'; $table->data = []; $total_filters = db_get_all_rows_filter('tevent_filter', false, 'COUNT(*) AS total'); @@ -147,13 +149,14 @@ $total_filters = $total_filters[0]['total']; foreach ($filters as $filter) { $data = []; - $data[0] = ''.$filter['id_name'].''; - $data[1] = ui_print_group_icon($filter['id_group_filter'], true); - $data[2] = events_get_event_types($filter['event_type']); - $data[3] = events_get_status($filter['status']); - $data[4] = events_get_severity_types($filter['severity']); - $data[5] = "".html_print_image('images/cross.png', true, ['title' => __('Delete')]).''.html_print_checkbox_extended('delete_multiple[]', $filter['id_filter'], false, false, '', 'class="check_delete"', true); + $data[0] = html_print_checkbox_extended('delete_multiple[]', $filter['id_filter'], false, false, '', 'class="check_delete"', true); + $data[1] = ''.$filter['id_name'].''; + $data[2] = ui_print_group_icon($filter['id_group_filter'], true); + $data[3] = events_get_event_types($filter['event_type']); + $data[4] = events_get_status($filter['status']); + $data[5] = events_get_severity_types($filter['severity']); + $table->cellclass[][6] = 'action_buttons'; + $data[6] = "".html_print_image('images/cross.png', true, ['title' => __('Delete')]).''; array_push($table->data, $data); } @@ -188,8 +191,6 @@ echo '
'; ?> '; } -// Other Checks for the edit the reports +// Other Checks for the edit the reports. if ($idReport != 0) { $report = db_get_row_filter('treport', ['id_report' => $idReport]); $type_access_selected = reports_get_type_access($report); $edit = false; switch ($type_access_selected) { case 'group_view': - $edit = check_acl($config['id_user'], $report['id_group'], 'RW'); + $edit = check_acl( + $config['id_user'], + $report['id_group'], + 'RW' + ); break; case 'group_edit': - $edit = check_acl($config['id_user'], $report['id_group_edit'], 'RW'); + $edit = check_acl( + $config['id_user'], + $report['id_group_edit'], + 'RW' + ); break; case 'user_edit': @@ -162,14 +196,21 @@ if ($idReport != 0) { $edit = true; } break; + + default: + // Default. + break; } if (! $edit) { - // The user that created the report should can delete it. Despite its permissions. + // The user that created the report should can delete it. + // Despite its permissions. $delete_report_bypass = false; if ($action == 'delete_report') { - if ($config['id_user'] == $report['id_user'] || is_user_admin($config['id_user'])) { + if ($config['id_user'] == $report['id_user'] + || is_user_admin($config['id_user']) + ) { $delete_report_bypass = true; } } @@ -191,7 +232,10 @@ switch ($action) { case 'list_items': $resultOperationDB = null; $position_to_sort = (int) get_parameter('position_to_sort', 1); - $ids_serialize = (string) get_parameter('ids_items_to_sort', ''); + $ids_serialize = (string) get_parameter( + 'ids_items_to_sort', + '' + ); $move_to = (string) get_parameter('move_to', 'after'); $countItems = db_get_sql( @@ -201,40 +245,25 @@ switch ($action) { WHERE id_report = '.$idReport ); - if (($countItems < $position_to_sort) || ($position_to_sort < 1)) { + if (($countItems < $position_to_sort) + || ($position_to_sort < 1) + ) { $resultOperationDB = false; } else if (!empty($ids_serialize)) { $ids = explode('|', $ids_serialize); - - switch ($config['dbtype']) { - case 'mysql': - $items = db_get_all_rows_sql( - ' - SELECT id_rc, `order` - FROM treport_content - WHERE id_report = '.$idReport.' - ORDER BY `order`' - ); - break; - - case 'oracle': - case 'postgresql': - $items = db_get_all_rows_sql( - ' - SELECT id_rc, "order" - FROM treport_content - WHERE id_report = '.$idReport.' - ORDER BY "order"' - ); - break; - } + $items = db_get_all_rows_sql( + ' + SELECT id_rc, `order` + FROM treport_content + WHERE id_report = '.$idReport.' + ORDER BY `order`' + ); if ($items === false) { $items = []; } - - // Clean the repeated order values + // Clean the repeated order values. $order_temp = 1; foreach ($items as $item) { switch ($config['dbtype']) { @@ -254,6 +283,10 @@ switch ($action) { ['id_rc' => $item['id_rc']] ); break; + + default: + // Default. + break; } $order_temp++; @@ -281,19 +314,19 @@ switch ($action) { ORDER BY "order"' ); break; + + default: + // Default. + break; } if ($items === false) { $items = []; } - - - $temp = []; - $temp = []; foreach ($items as $item) { - // Remove the contents from the block to sort + // Remove the contents from the block to sort. if (array_search($item['id_rc'], $ids) === false) { $temp[$item['order']] = $item['id_rc']; } @@ -301,8 +334,6 @@ switch ($action) { $items = $temp; - - $sorted_items = []; foreach ($items as $pos => $id_unsort) { if ($pos == $position_to_sort) { @@ -324,8 +355,6 @@ switch ($action) { $items = $sorted_items; - - foreach ($items as $order => $id) { switch ($config['dbtype']) { case 'mysql': @@ -344,6 +373,10 @@ switch ($action) { ['id_rc' => $id] ); break; + + default: + // Default. + break; } } @@ -352,6 +385,10 @@ switch ($action) { $resultOperationDB = false; } break; + + default: + // Default. + break; } break; @@ -360,7 +397,8 @@ switch ($action) { $ids_serialize = (string) get_parameter('ids_items_to_delete', ''); if (!empty($ids_serialize)) { - $sql = "DELETE FROM treport_content WHERE id_rc IN ($ids_serialize)"; + $sql = 'DELETE FROM treport_content + WHERE id_rc IN ('.$ids_serialize.')'; $resultOperationDB = db_process_sql($sql); } else { $resultOperationDB = false; @@ -380,7 +418,9 @@ switch ($action) { if (($countItems < $position_to_delete) || ($position_to_delete < 1)) { $resultOperationDB = false; } else { - $sql = "SELECT id_rc FROM treport_content WHERE id_report=$idReport ORDER BY '`order`'"; + $sql = 'SELECT id_rc + FROM treport_content + WHERE id_report='.$idReport." ORDER BY '`order`'"; $items = db_get_all_rows_sql($sql); switch ($pos_delete) { case 'above': @@ -390,7 +430,10 @@ switch ($action) { $i = 1; foreach ($items as $key => $item) { if ($i < $position_to_delete) { - $resultOperationDB = db_process_sql_delete('treport_content', ['id_rc' => $item['id_rc']]); + $resultOperationDB = db_process_sql_delete( + 'treport_content', + ['id_rc' => $item['id_rc']] + ); } $i++; @@ -415,6 +458,10 @@ switch ($action) { } } break; + + default: + // Default. + break; } } break; @@ -433,6 +480,7 @@ switch ($action) { } $subsection = ''; + $helpers = ''; switch ($activeTab) { case 'main': $buttons['list_reports']['active'] = true; @@ -440,13 +488,20 @@ switch ($action) { break; default: - $subsection = reporting_enterprise_add_subsection_main($activeTab, $buttons); + $data_tab = reporting_enterprise_add_subsection_main( + $activeTab, + $buttons + ); + + $subsection = $data_tab['subsection']; + $buttons = $data_tab['buttons']; + $helpers = $data_tab['helpers']; break; } - // Page header for metaconsole - if ($enterpriseEnable and defined('METACONSOLE')) { - // Bread crumbs + // Page header for metaconsole. + if ($enterpriseEnable && defined('METACONSOLE')) { + // Bread crumbs. ui_meta_add_breadcrumb( [ 'link' => 'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&pure='.$pure, @@ -456,12 +511,21 @@ switch ($action) { ui_meta_print_page_header($nav_bar); - // Print header + // Print header. ui_meta_print_header(__('Reporting'), '', $buttons); - } - // Page header for normal console - else { - ui_print_page_header(__('Custom reporting'), 'images/op_reporting.png', false, '', false, $buttons, false, '', 60); + } else { + // Page header for normal console. + ui_print_page_header( + __('Custom reporting'), + 'images/op_reporting.png', + false, + '', + false, + $buttons, + false, + '', + 60 + ); } @@ -469,9 +533,11 @@ switch ($action) { $delete = false; switch ($type_access_selected) { case 'group_view': - if ($config['id_user'] == $report['id_user'] || is_user_admin($config['id_user'])) { + if ($config['id_user'] == $report['id_user'] + || is_user_admin($config['id_user']) + ) { $delete = true; - // owner can delete + // Owner can delete. } else { $delete = check_acl( $config['id_user'], @@ -482,9 +548,11 @@ switch ($action) { break; case 'group_edit': - if ($config['id_user'] == $report['id_user'] || is_user_admin($config['id_user'])) { + if ($config['id_user'] == $report['id_user'] + || is_user_admin($config['id_user']) + ) { $delete = true; - // owner can delete + // Owner can delete. } else { $delete = check_acl( $config['id_user'], @@ -501,6 +569,10 @@ switch ($action) { $delete = true; } break; + + default: + // Default. + break; } if (! $delete) { @@ -514,9 +586,15 @@ switch ($action) { $result = reports_delete_report($idReport); if ($result !== false) { - db_pandora_audit('Report management', "Delete report #$idReport"); + db_pandora_audit( + 'Report management', + 'Delete report #'.$idReport + ); } else { - db_pandora_audit('Report management', "Fail try to delete report #$idReport"); + db_pandora_audit( + 'Report management', + 'Fail try to delete report #'.$idReport + ); } ui_print_result_message( @@ -531,7 +609,7 @@ switch ($action) { $search_sql = ''; if ($search != '') { - $search_name = "%$search%' OR description LIKE '%$search%"; + $search_name = '%'.$search."%' OR description LIKE '%".$search.'%'; } $table_aux = new stdClass(); @@ -543,25 +621,57 @@ switch ($action) { $table_aux->colspan[0][0] = 4; $table_aux->data[0][0] = ''.__('Group').''; - $table_aux->data[0][1] = html_print_select_groups(false, $access, true, 'id_group', $id_group, '', '', '', true, false, true, '', false, '', false, false, 'id_grupo', $strict_user).'
'; + $table_aux->data[0][1] = html_print_select_groups( + false, + $access, + true, + 'id_group', + $id_group, + '', + '', + '', + true, + false, + true, + '', + false, + '', + false, + false, + 'id_grupo' + ).'
'; - $table_aux->data[0][2] = ''.__('Free text for search: ').ui_print_help_tip( + $table_aux->data[0][2] = ''.__('Free text for search: '); + $table_aux->data[0][2] .= ui_print_help_tip( __('Search by report name or description, list matches.'), true - ).''; - $table_aux->data[0][3] = html_print_input_text('search', $search, '', 30, '', true); + ); + $table_aux->data[0][2] .= ''; + $table_aux->data[0][3] = html_print_input_text( + 'search', + $search, + '', + 30, + '', + true + ); - $table_aux->data[0][6] = html_print_submit_button(__('Search'), 'search_submit', false, 'class="sub upd"', true); + $table_aux->data[0][6] = html_print_submit_button( + __('Search'), + 'search_submit', + false, + 'class="sub upd"', + true + ); + $url_rb = 'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder'; if (is_metaconsole()) { - $filter = ""; + $filter = ''; $filter .= html_print_table($table_aux, true); $filter .= ''; ui_toggle($filter, __('Show Option')); } else { - echo "
"; + echo ''; html_print_table($table_aux); echo '
'; } @@ -571,9 +681,9 @@ switch ($action) { ui_require_jquery_file('bgiframe'); ui_require_jquery_file('autocomplete'); - // Show only selected groups + // Show only selected groups. if ($id_group > 0) { - $group = ["$id_group" => $id_group]; + $group = [$id_group => $id_group]; } else { $group = false; } @@ -595,16 +705,16 @@ switch ($action) { } // Fix : group filter was not working - // Show only selected groups + // Show only selected groups. if ($id_group > 0) { - $group = ["$id_group" => $id_group]; + $group = [$id_group => $id_group]; $filter['id_group'] = $id_group; } else { $group = false; } - // Filter normal and metaconsole reports - if ($config['metaconsole'] == 1 and defined('METACONSOLE')) { + // Filter normal and metaconsole reports. + if ($config['metaconsole'] == 1 && defined('METACONSOLE')) { $filter['metaconsole'] = 1; } else { $filter['metaconsole'] = 0; @@ -623,8 +733,7 @@ switch ($action) { ], $return_all_group, $access, - $group, - $strict_user + $group ); $total_reports = (int) count( @@ -633,25 +742,27 @@ switch ($action) { ['name'], $return_all_group, $access, - $group, - $strict_user + $group ) ); - if (sizeof($reports)) { + if (count($reports)) { $url = 'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder'; ui_pagination($total_reports, $url, $offset, $pagination); $table = new stdClass(); $table->id = 'report_list'; $table->width = '100%'; - $table->class = 'databox data'; + $table->class = 'info_table'; $table->cellpadding = 0; $table->cellspacing = 0; $table->head = []; $table->align = []; + $table->headstyle = []; + $table->style = []; + $table->align[2] = 'left'; $table->align[3] = 'left'; $table->align[4] = 'left'; @@ -663,19 +774,29 @@ switch ($action) { $table->size[0] = '20%'; $table->size[1] = '30%'; $table->size[2] = '2%'; + $table->headstyle[2] = 'min-width: 35px;'; $table->size[3] = '2%'; + $table->headstyle[3] = 'min-width: 35px;'; $table->size[4] = '2%'; + $table->headstyle[4] = 'min-width: 35px;'; $table->size[5] = '2%'; + $table->headstyle[5] = 'min-width: 35px;'; $table->size[6] = '2%'; - $table->size['csv'] = '5%'; + $table->headstyle[6] = 'min-width: 35px;'; + $table->size[7] = '5%'; + $table->headstyle['csv'] = 'min-width: 65px;'; + $table->style[7] = 'text-align: center;'; + + $table->headstyle[9] = 'min-width: 100px;'; + $table->style[9] = 'text-align: center;'; $next = 4; - // Calculate dinamically the number of the column + // Calculate dinamically the number of the column. if (enterprise_hook('load_custom_reporting_1') !== ENTERPRISE_NOT_HOOK) { $next = 7; } - // Admin options only for RM flag + // Admin options only for RM flag. if (check_acl($config['id_user'], 0, 'RM')) { $table->head[$next] = __('Private'); $table->size[$next] = '2%'; @@ -706,7 +827,6 @@ switch ($action) { // $table->size = array (); $table->size[$next] = '10%'; $table->align[$next] = 'left'; - $table->headstyle[$next] = 'text-align:left;'; } $columnview = false; @@ -715,18 +835,44 @@ switch ($action) { foreach ($reports as $report) { if (!is_user_admin($config['id_user'])) { - if ($report['private'] && $report['id_user'] != $config['id_user']) { - if (!check_acl($config['id_user'], $report['id_group'], 'RR') - && !check_acl($config['id_user'], $report['id_group'], 'RW') - && !check_acl($config['id_user'], $report['id_group'], 'RM') + if ($report['private'] + && $report['id_user'] != $config['id_user'] + ) { + if (!check_acl( + $config['id_user'], + $report['id_group'], + 'RR' + ) + && !check_acl( + $config['id_user'], + $report['id_group'], + 'RW' + ) + && !check_acl( + $config['id_user'], + $report['id_group'], + 'RM' + ) ) { continue; } } - if (!check_acl($config['id_user'], $report['id_group'], 'RR') - && !check_acl($config['id_user'], $report['id_group'], 'RW') - && !check_acl($config['id_user'], $report['id_group'], 'RM') + if (!check_acl( + $config['id_user'], + $report['id_group'], + 'RR' + ) + && !check_acl( + $config['id_user'], + $report['id_group'], + 'RW' + ) + && !check_acl( + $config['id_user'], + $report['id_group'], + 'RM' + ) ) { continue; } @@ -734,7 +880,9 @@ switch ($action) { $data = []; - if (check_acl($config['id_user'], $report['id_group'], 'RW') || check_acl($config['id_user'], $report['id_group'], 'RM')) { + if (check_acl($config['id_user'], $report['id_group'], 'RW') + || check_acl($config['id_user'], $report['id_group'], 'RM') + ) { $data[0] = ''.ui_print_truncate_text($report['name'], 70).''; } else { $data[0] = ui_print_truncate_text($report['name'], 70); @@ -743,16 +891,36 @@ switch ($action) { $data[1] = ui_print_truncate_text($report['description'], 70); - // Remove html and xml button if items are larger than limit - $item_count = db_get_num_rows('SELECT * FROM treport_content WHERE id_report='.$report['id_report']); + // Remove html and xml button if items are larger than limit. + $item_count = db_get_num_rows( + 'SELECT * FROM treport_content + WHERE id_report='.$report['id_report'] + ); $report['overload'] = $item_count >= $config['report_limit']; if ($report['overload']) { - $data[2] = html_print_image('images/application_not_writable.png', true, ['title' => __('This report exceeds the item limit for realtime operations')]); + $data[2] = html_print_image( + 'images/application_not_writable.png', + true, + ['title' => __('This report exceeds the item limit for realtime operations')] + ); $data[3] = null; } else if (!$report['non_interactive']) { - $data[2] = ''.html_print_image('images/html.png', true, ['title' => __('HTML view')]).''; - $data[3] = ''.html_print_image('images/xml.png', true, ['title' => __('Export to XML')]).''; - // I chose ajax.php because it's supposed to give XML anyway + $data[2] = ''; + $data[2] .= html_print_image( + 'images/html.png', + true, + ['title' => __('HTML view')] + ); + $data[2] .= ''; + $data[3] = ''; + $data[3] .= html_print_image( + 'images/xml.png', + true, + ['title' => __('Export to XML')] + ); + $data[3] .= ''; + // I chose ajax.php because it's supposed + // to give XML anyway. } else { $data[2] = html_print_image( 'images/html_disabled.png', @@ -764,15 +932,13 @@ switch ($action) { ); } - - // Calculate dinamically the number of the column + // Calculate dinamically the number of the column. $next = 4; if (enterprise_hook('load_custom_reporting_2') !== ENTERPRISE_NOT_HOOK) { $next = 7; } - - // Admin options only for RM flag + // Admin options only for RM flag. if (check_acl($config['id_user'], 0, 'RM')) { if ($report['private'] == 1) { $data[$next] = __('Yes'); @@ -799,14 +965,22 @@ switch ($action) { switch ($type_access_selected) { case 'group_view': - $edit = check_acl($config['id_user'], $report['id_group'], 'RW'); + $edit = check_acl( + $config['id_user'], + $report['id_group'], + 'RW' + ); $delete = $edit || is_user_admin($config['id_user']) || $config['id_user'] == $report['id_user']; break; case 'group_edit': - $edit = check_acl($config['id_user'], $report['id_group_edit'], 'RW'); + $edit = check_acl( + $config['id_user'], + $report['id_group_edit'], + 'RW' + ); $delete = $edit || is_user_admin($config['id_user']) || $config['id_user'] == $report['id_user']; @@ -820,24 +994,24 @@ switch ($action) { $delete = true; } break; + + default: + // Default. + break; } if ($edit || $delete) { $columnview = true; + $table->cellclass[][$next] = 'action_buttons'; + if (!isset($table->head[$next])) { $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) { $data[$next] = '
'; - $data[$next] .= html_print_input_hidden( - 'id_report', - $report['id_report'], - true - ); $data[$next] .= html_print_input_image( 'edit', 'images/config.png', @@ -846,13 +1020,16 @@ switch ($action) { true, ['title' => __('Edit')] ); + $data[$next] .= html_print_input_hidden( + 'id_report', + $report['id_report'], + true + ); $data[$next] .= '
'; } if ($delete) { $data[$next] .= '
'; - $data[$next] .= html_print_input_hidden('id_report', $report['id_report'], true); - $data[$next] .= html_print_input_hidden('action', 'delete_report', true); $data[$next] .= html_print_input_image( 'delete', 'images/cross.png', @@ -861,8 +1038,26 @@ switch ($action) { true, ['title' => __('Delete')] ); + $data[$next] .= html_print_input_hidden( + 'id_report', + $report['id_report'], + true + ); + $data[$next] .= html_print_input_hidden( + 'action', + 'delete_report', + true + ); - $data[$next] .= html_print_checkbox_extended('massive_report_check', $report['id_report'], false, false, '', 'class="check_delete"', true); + $data[$next] .= html_print_checkbox_extended( + 'massive_report_check', + $report['id_report'], + false, + false, + '', + 'class="check_delete"', + true + ); $data[$next] .= '
'; } @@ -887,11 +1082,28 @@ switch ($action) { } html_print_table($table); + ui_pagination( + $total_reports, + $url, + $offset, + $pagination, + false, + 'offset', + true, + 'pagination-bottom' + ); } else { - ui_print_info_message([ 'no_close' => true, 'message' => __('No data found.') ]); + ui_print_info_message( + [ + 'no_close' => true, + 'message' => __('No data found.'), + ] + ); } - if (check_acl($config['id_user'], 0, 'RW') || check_acl($config['id_user'], 0, 'RM')) { + if (check_acl($config['id_user'], 0, 'RW') + || check_acl($config['id_user'], 0, 'RM') + ) { echo '
'; if (defined('METACONSOLE')) { echo '
'; @@ -899,7 +1111,12 @@ switch ($action) { echo '
'; } - html_print_submit_button(__('Create report'), 'create', false, 'class="sub next"'); + html_print_submit_button( + __('Create report'), + 'create', + false, + 'class="sub next"' + ); echo ''; echo '
'; @@ -909,13 +1126,17 @@ switch ($action) { } echo ''; - html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete" style="margin-left:5px;"'); + html_print_submit_button( + __('Delete'), + 'delete_btn', + false, + 'class="sub delete" style="margin-left:5px;"' + ); echo '
'; echo '
'; } enterprise_hook('close_meta_frame'); - return; break; @@ -924,7 +1145,7 @@ switch ($action) { case 'main': $reportName = ''; $idGroupReport = 0; - // All groups + // All groups. $description = ''; $resultOperationDB = null; $report_id_user = 0; @@ -943,6 +1164,10 @@ switch ($action) { $idGroupReport = $report['id_group']; $description = $report['description']; break; + + default: + // Default. + break; } break; @@ -953,12 +1178,15 @@ switch ($action) { $reportName = get_parameter('name'); $idGroupReport = get_parameter('id_group'); $description = get_parameter('description'); - $type_access_selected = get_parameter('type_access', 'group_view'); + $type_access_selected = get_parameter( + 'type_access', + 'group_view' + ); $id_group_edit_param = (int) get_parameter('id_group_edit', 0); $report_id_user = get_parameter('report_id_user'); $non_interactive = get_parameter('non_interactive', 0); - // Pretty font by default for pdf + // Pretty font by default for pdf. $custom_font = 'FreeSans.ttf'; switch ($type_access_selected) { @@ -976,6 +1204,10 @@ switch ($action) { $id_group_edit = 0; $private = 1; break; + + default: + // Default. + break; } if ($action == 'update') { @@ -1011,12 +1243,12 @@ switch ($action) { if ($resultOperationDB !== false) { db_pandora_audit( 'Report management', - "Update report #$idReport" + 'Update report #'.$idReport ); } else { db_pandora_audit( 'Report management', - "Fail try to update report #$idReport" + 'Fail try to update report #'.$idReport ); } } else { @@ -1026,10 +1258,10 @@ switch ($action) { $action = 'edit'; } else if ($action == 'save') { if ($reportName != '' && $idGroupReport != '') { - // This flag allow to differentiate between normal console and metaconsole reports + // This flag allow to differentiate + // between normal console and metaconsole reports. $metaconsole_report = (int) is_metaconsole(); - // Juanma (07/05/2014) New feature: Custom front page for reports if ($config['custom_report_front']) { $custom_font = $config['custom_report_front_font']; $logo = $config['custom_report_front_logo']; @@ -1037,9 +1269,16 @@ switch ($action) { $first_page = $config['custom_report_front_firstpage']; $footer = $config['custom_report_front_footer']; } else { - $start_url = ui_get_full_url(false, false, false, false); + $start_url = ui_get_full_url( + false, + false, + false, + false + ); $first_page = '<p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;"><img src="'.$start_url.'/images/pandora_report_logo.png" alt="" width="800" /></p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;"><span style="font-size: xx-large;">(_REPORT_NAME_)</span></p> <p style="text-align: center;"><span style="font-size: large;">(_DATETIME_)</span></p>'; - $logo = $header = $footer = null; + $logo = null; + $header = null; + $footer = null; } $idOrResult = db_process_sql_insert( @@ -1062,9 +1301,15 @@ switch ($action) { ); if ($idOrResult !== false) { - db_pandora_audit('Report management', "Create report #$idOrResult"); + db_pandora_audit( + 'Report management', + 'Create report #'.$idOrResult + ); } else { - db_pandora_audit('Report management', 'Fail try to create report'); + db_pandora_audit( + 'Report management', + 'Fail try to create report' + ); } } else { $idOrResult = false; @@ -1078,7 +1323,7 @@ switch ($action) { $report_id_user = $config['id_user']; } - $action = $resultOperationDB ? 'edit' : 'new'; + $action = ($resultOperationDB) ? 'edit' : 'new'; } break; @@ -1089,32 +1334,31 @@ switch ($action) { ['id_report' => $idReport] ); - - - $reportName = $report['name']; $idGroupReport = $report['id_group']; $description = $report['description']; $good_format = false; switch ($action) { case 'update': - $values = []; $values['id_report'] = $idReport; - // --------------------------------------------------- - // $values['name'] = (string) get_parameter('name'); $values['description'] = get_parameter('description'); $values['type'] = get_parameter('type', null); $values['recursion'] = get_parameter('recursion', null); $label = get_parameter('label', ''); - // Add macros name + // Add macros name. $items_label = []; $items_label['type'] = get_parameter('type'); $items_label['id_agent'] = get_parameter('id_agent'); - $items_label['id_agent_module'] = get_parameter('id_agent_module'); + $items_label['id_agent_module'] = get_parameter( + 'id_agent_module' + ); $name_it = (string) get_parameter('name'); - $values['name'] = reporting_label_macro($items_label, $name_it); + $values['name'] = reporting_label_macro( + $items_label, + $name_it + ); /* Added support for projection graphs, @@ -1126,13 +1370,14 @@ switch ($action) { switch ($values['type']) { case 'projection_graph': $values['period'] = get_parameter('period1'); - $values['top_n_value'] = get_parameter('period2'); + $values['top_n_value'] = get_parameter( + 'period2' + ); $values['text'] = get_parameter('text'); $good_format = true; break; case 'event_report_log': - $agents_to_report = get_parameter('id_agents3'); $source = get_parameter('source', ''); $search = get_parameter('search', ''); @@ -1150,16 +1395,29 @@ switch ($action) { case 'prediction_date': $values['period'] = get_parameter('period1'); - $values['top_n'] = get_parameter('radiobutton_max_min_avg'); - $values['top_n_value'] = get_parameter('quantity'); + $values['top_n'] = get_parameter( + 'radiobutton_max_min_avg' + ); + $values['top_n_value'] = get_parameter( + 'quantity' + ); $interval_max = get_parameter('max_interval'); $interval_min = get_parameter('min_interval'); - // Checks intervals fields - if (preg_match('/^(\-)*[0-9]*\.?[0-9]+$/', $interval_max) and preg_match('/^(\-)*[0-9]*\.?[0-9]+$/', $interval_min)) { + // Checks intervals fields. + if (preg_match( + '/^(\-)*[0-9]*\.?[0-9]+$/', + $interval_max + ) + && preg_match( + '/^(\-)*[0-9]*\.?[0-9]+$/', + $interval_min + ) + ) { $good_format = true; } - $intervals = get_parameter('max_interval').';'.get_parameter('min_interval'); + $intervals = get_parameter('max_interval').';'; + $intervals .= get_parameter('min_interval'); $values['text'] = $intervals; break; @@ -1170,19 +1428,32 @@ switch ($action) { case 'SLA': case 'availability_graph': $values['period'] = get_parameter('period'); - $values['top_n'] = get_parameter('combo_sla_sort_options', 0); - $values['top_n_value'] = get_parameter('quantity'); + $values['top_n'] = get_parameter( + 'combo_sla_sort_options', + 0 + ); + $values['top_n_value'] = get_parameter( + 'quantity' + ); $values['text'] = get_parameter('text'); - $values['show_graph'] = get_parameter('combo_graph_options'); + $values['show_graph'] = get_parameter( + 'combo_graph_options' + ); $good_format = true; break; case 'agent_module': $agents_to_report = get_parameter('id_agents2'); - $modules_to_report = get_parameter('module', ''); + $modules_to_report = get_parameter( + 'module', + '' + ); - $es['module'] = get_same_modules($agents_to_report, $modules_to_report); + $es['module'] = get_same_modules( + $agents_to_report, + $modules_to_report + ); $es['id_agents'] = $agents_to_report; $values['external_source'] = json_encode($es); @@ -1193,7 +1464,9 @@ switch ($action) { $values['period'] = 0; $es['date'] = get_parameter('date'); $es['id_agents'] = get_parameter('id_agents'); - $es['inventory_modules'] = get_parameter('inventory_modules'); + $es['inventory_modules'] = get_parameter( + 'inventory_modules' + ); $description = get_parameter('description'); $values['external_source'] = json_encode($es); $good_format = true; @@ -1202,37 +1475,85 @@ switch ($action) { case 'inventory_changes': $values['period'] = get_parameter('period'); $es['id_agents'] = get_parameter('id_agents'); - $es['inventory_modules'] = get_parameter('inventory_modules'); + $es['inventory_modules'] = get_parameter( + 'inventory_modules' + ); $description = get_parameter('description'); $values['external_source'] = json_encode($es); $good_format = true; break; case 'netflow_area': - case 'netflow_pie': case 'netflow_data': - case 'netflow_statistics': case 'netflow_summary': - $values['text'] = get_parameter('netflow_filter'); - $values['description'] = get_parameter('description'); + $values['text'] = get_parameter( + 'netflow_filter' + ); + $values['description'] = get_parameter( + 'description' + ); $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter('resolution'); - $values['top_n_value'] = get_parameter('max_values'); + $values['top_n_value'] = get_parameter( + 'max_values' + ); $good_format = true; break; case 'availability': // HACK it is saved in show_graph field. - // Show interfaces instead the modules - $values['show_graph'] = get_parameter('checkbox_show_address_agent'); - $values['period'] = get_parameter('period'); + // Show interfaces instead the modules. + $values['show_graph'] = get_parameter( + 'checkbox_show_address_agent' + ); + $values['period'] = get_parameter( + 'period' + ); + $values['total_time'] = get_parameter( + 'total_time' + ); + $values['time_failed'] = get_parameter( + 'time_failed' + ); + $values['time_in_ok_status'] = get_parameter( + 'time_in_ok_status' + ); + $values['time_in_unknown_status'] = get_parameter( + 'time_in_unknown_status' + ); + $values['time_of_not_initialized_module'] = get_parameter( + 'time_of_not_initialized_module' + ); + $values['time_of_downtime'] = get_parameter( + 'time_of_downtime' + ); + $values['total_checks'] = get_parameter( + 'total_checks' + ); + $values['checks_failed'] = get_parameter( + 'checks_failed' + ); + $values['checks_in_ok_status'] = get_parameter( + 'checks_in_ok_status' + ); + $values['unknown_checks'] = get_parameter( + 'unknown_checks' + ); + $values['agent_max_value'] = get_parameter( + 'agent_max_value' + ); + $values['agent_min_value'] = get_parameter( + 'agent_min_value' + ); $good_format = true; break; case 'simple_graph': case 'simple_baseline_graph': // HACK it is saved in show_graph field. - $values['show_graph'] = (int) get_parameter('time_compare_overlapped'); + $values['show_graph'] = (int) get_parameter( + 'time_compare_overlapped' + ); $values['period'] = get_parameter('period'); $good_format = true; break; @@ -1241,19 +1562,39 @@ switch ($action) { case 'max_value': case 'avg_value': $values['period'] = get_parameter('period'); - $values['lapse_calc'] = get_parameter('lapse_calc'); + $values['lapse_calc'] = get_parameter( + 'lapse_calc' + ); $values['lapse'] = get_parameter('lapse'); - $values['visual_format'] = get_parameter('visual_format'); + $values['visual_format'] = get_parameter( + 'visual_format' + ); + $good_format = true; + break; + + case 'nt_top_n': + $values['period'] = get_parameter('period'); + $values['top_n_value'] = get_parameter( + 'quantity' + ); $good_format = true; break; default: $values['period'] = get_parameter('period'); - $values['top_n'] = get_parameter('radiobutton_max_min_avg', 0); - $values['top_n_value'] = get_parameter('quantity'); + $values['top_n'] = get_parameter( + 'radiobutton_max_min_avg', + 0 + ); + $values['top_n_value'] = get_parameter( + 'quantity' + ); $values['text'] = get_parameter('text'); - $values['show_graph'] = get_parameter('combo_graph_options'); + $values['show_graph'] = get_parameter( + 'combo_graph_options' + ); $good_format = true; + break; } $values['id_agent'] = get_parameter('id_agent'); @@ -1261,16 +1602,27 @@ switch ($action) { $values['id_agent_module'] = ''; if (isset($values['type'])) { - if (($values['type'] == 'alert_report_agent') or ($values['type'] == 'event_report_agent') or ($values['type'] == 'agent_configuration') or ($values['type'] == 'group_configuration')) { + if (($values['type'] == 'alert_report_agent') + || ($values['type'] == 'event_report_agent') + || ($values['type'] == 'agent_configuration') + || ($values['type'] == 'group_configuration') + ) { $values['id_agent_module'] = ''; } else { - $values['id_agent_module'] = get_parameter('id_agent_module'); + $values['id_agent_module'] = get_parameter( + 'id_agent_module' + ); } } else { - $values['id_agent_module'] = get_parameter('id_agent_module'); + $values['id_agent_module'] = get_parameter( + 'id_agent_module' + ); } - $values['only_display_wrong'] = (int) get_parameter('checkbox_only_display_wrong', 0); + $values['only_display_wrong'] = (int) get_parameter( + 'checkbox_only_display_wrong', + 0 + ); $values['monday'] = get_parameter('monday', 0); $values['tuesday'] = get_parameter('tuesday', 0); $values['wednesday'] = get_parameter('wednesday', 0); @@ -1278,89 +1630,221 @@ switch ($action) { $values['friday'] = get_parameter('friday', 0); $values['saturday'] = get_parameter('saturday', 0); $values['sunday'] = get_parameter('sunday', 0); - switch ($config['dbtype']) { - case 'mysql': - case 'postgresql': - $values['time_from'] = get_parameter('time_from'); - $values['time_to'] = get_parameter('time_to'); - break; + $values['total_time'] = get_parameter('total_time', 0); + $values['time_failed'] = get_parameter( + 'time_failed', + 0 + ); + $values['time_in_ok_status'] = get_parameter( + 'time_in_ok_status', + 0 + ); + $values['time_in_unknown_status'] = get_parameter( + 'time_in_unknown_status', + 0 + ); + $values['time_of_not_initialized_module'] = get_parameter( + 'time_of_not_initialized_module', + 0 + ); + $values['time_of_downtime'] = get_parameter( + 'time_of_downtime', + 0 + ); + $values['total_checks'] = get_parameter( + 'total_checks', + 0 + ); + $values['checks_failed'] = get_parameter( + 'checks_failed', + 0 + ); + $values['checks_in_ok_status'] = get_parameter( + 'checks_in_ok_status', + 0 + ); + $values['unknown_checks'] = get_parameter( + 'unknown_checks', + 0 + ); + $values['agent_max_value'] = get_parameter( + 'agent_max_value', + 0 + ); + $values['agent_min_value'] = get_parameter( + 'agent_min_value', + 0 + ); - case 'oracle': - $values['time_from'] = '#to_date(\''.get_parameter('time_from').'\',\'hh24:mi:ss\')'; - $values['time_to'] = '#to_date(\''.get_parameter('time_to').'\', \'hh24:mi:ss\')'; - break; - } + $values['time_from'] = get_parameter( + 'time_from' + ); + $values['time_to'] = get_parameter('time_to'); - $values['group_by_agent'] = get_parameter('checkbox_row_group_by_agent'); - $values['show_resume'] = get_parameter('checkbox_show_resume'); - $values['order_uptodown'] = get_parameter('radiobutton_order_uptodown'); - $values['exception_condition'] = (int) get_parameter('exception_condition', 0); - $values['exception_condition_value'] = get_parameter('exception_condition_value'); - $values['id_module_group'] = get_parameter('combo_modulegroup'); + $values['group_by_agent'] = get_parameter( + 'checkbox_row_group_by_agent' + ); + $values['show_resume'] = get_parameter( + 'checkbox_show_resume' + ); + $values['order_uptodown'] = get_parameter( + 'radiobutton_order_uptodown' + ); + $values['exception_condition'] = (int) get_parameter( + 'exception_condition', + 0 + ); + $values['exception_condition_value'] = get_parameter( + 'exception_condition_value' + ); + $values['id_module_group'] = get_parameter( + 'combo_modulegroup' + ); $values['id_group'] = get_parameter('combo_group'); $values['server_name'] = get_parameter('server_name'); $server_id = (int) get_parameter('server_id'); if ($server_id != 0) { - $connection = metaconsole_get_connection_by_id($server_id); + $connection = metaconsole_get_connection_by_id( + $server_id + ); $values['server_name'] = $connection['server_name']; } if ($values['server_name'] == '') { - $values['server_name'] = get_parameter('combo_server'); + $values['server_name'] = get_parameter( + 'combo_server' + ); } - if ((($values['type'] == 'custom_graph') or ($values['type'] == 'automatic_custom_graph')) && ($values['id_gs'] == 0 || $values['id_gs'] == '')) { + if ((($values['type'] == 'custom_graph') + || ($values['type'] == 'automatic_custom_graph')) + && ($values['id_gs'] == 0 || $values['id_gs'] == '') + ) { $resultOperationDB = false; break; } - $show_summary_group = get_parameter('show_summary_group', 0); - $filter_event_severity = get_parameter('filter_event_severity', 0); - $filter_event_type = get_parameter('filter_event_type', ''); - $filter_event_status = get_parameter('filter_event_status', 0); + $show_summary_group = get_parameter( + 'show_summary_group', + 0 + ); + $filter_event_severity = get_parameter( + 'filter_event_severity', + 0 + ); + $filter_event_type = get_parameter( + 'filter_event_type', + '' + ); + $filter_event_status = get_parameter( + 'filter_event_status', + 0 + ); - $event_graph_by_agent = get_parameter('event_graph_by_agent', 0); - $event_graph_by_user_validator = get_parameter('event_graph_by_user_validator', 0); - $event_graph_by_criticity = get_parameter('event_graph_by_criticity', 0); - $event_graph_validated_vs_unvalidated = get_parameter('event_graph_validated_vs_unvalidated', 0); + $event_graph_by_agent = get_parameter( + 'event_graph_by_agent', + 0 + ); + $event_graph_by_user_validator = get_parameter( + 'event_graph_by_user_validator', + 0 + ); + $event_graph_by_criticity = get_parameter( + 'event_graph_by_criticity', + 0 + ); + $event_graph_validated_vs_unvalidated = get_parameter( + 'event_graph_validated_vs_unvalidated', + 0 + ); - $event_filter_search = get_parameter('filter_search', ''); + $event_filter_search = get_parameter( + 'filter_search', + '' + ); - // If metaconsole is activated - if ($config['metaconsole'] == 1 && defined('METACONSOLE')) { - if (($values['type'] == 'custom_graph') or ($values['type'] == 'automatic_custom_graph')) { - $id_gs = substr($values['id_gs'], 0, strpos($values['id_gs'], '|')); + // If metaconsole is activated. + if ($config['metaconsole'] == 1 + && defined('METACONSOLE') + ) { + if (($values['type'] == 'custom_graph') + || ($values['type'] == 'automatic_custom_graph') + ) { + $id_gs = substr( + $values['id_gs'], + 0, + strpos($values['id_gs'], '|') + ); if ($id_gs !== false) { - $server_name = strstr($values['id_gs'], '|'); + $server_name = strstr( + $values['id_gs'], + '|' + ); $values['id_gs'] = $id_gs; - $values['server_name'] = substr($server_name, 1, strlen($server_name)); + $values['server_name'] = substr( + $server_name, + 1, + strlen($server_name) + ); } } - // Get agent and server name - $agent_name_server = io_safe_output(get_parameter('agent')); + // Get agent and server name. + $agent_name_server = io_safe_output( + get_parameter('agent') + ); if (isset($agent_name_server)) { - $separator_pos = strpos($agent_name_server, '('); + $separator_pos = strpos( + $agent_name_server, + '(' + ); - if (($separator_pos != false) and ($separator_pos != 0)) { - $server_name = substr($agent_name_server, $separator_pos); - $server_name = str_replace('(', '', $server_name); - $server_name = str_replace(')', '', $server_name); - // Will update server_name variable + if (($separator_pos != false) + || ($separator_pos != 0) + ) { + $server_name = substr( + $agent_name_server, + $separator_pos + ); + $server_name = str_replace( + '(', + '', + $server_name + ); + $server_name = str_replace( + ')', + '', + $server_name + ); + // Will update server_name variable. $values['server_name'] = trim($server_name); - $agent_name = substr($agent_name_server, 0, $separator_pos); + $agent_name = substr( + $agent_name_server, + 0, + $separator_pos + ); } } } - if (($values['type'] == 'sql') or ($values['type'] == 'sql_graph_hbar') or ($values['type'] == 'sql_graph_vbar') or ($values['type'] == 'sql_graph_pie')) { - $values['treport_custom_sql_id'] = get_parameter('id_custom'); + if (($values['type'] == 'sql') + || ($values['type'] == 'sql_graph_hbar') + || ($values['type'] == 'sql_graph_vbar') + || ($values['type'] == 'sql_graph_pie') + ) { + $values['treport_custom_sql_id'] = get_parameter( + 'id_custom' + ); if ($values['treport_custom_sql_id'] == 0) { - $values['external_source'] = get_parameter('sql'); + $values['external_source'] = get_parameter( + 'sql' + ); } - $values['historical_db'] = get_parameter('historical_db_check'); + $values['historical_db'] = get_parameter( + 'historical_db_check' + ); $values['top_n_value'] = get_parameter('max_items'); } else if ($values['type'] == 'url') { $values['external_source'] = get_parameter('url'); @@ -1372,22 +1856,45 @@ switch ($action) { $values['column_separator'] = get_parameter('field'); $values['line_separator'] = get_parameter('line'); + $values['current_month'] = get_parameter('current_month'); + $style = []; - $style['show_in_same_row'] = get_parameter('show_in_same_row', 0); - $style['show_in_landscape'] = get_parameter('show_in_landscape', 0); - $style['hide_notinit_agents'] = get_parameter('hide_notinit_agents', 0); - $style['priority_mode'] = get_parameter('priority_mode', REPORT_PRIORITY_MODE_OK); - $style['dyn_height'] = get_parameter('dyn_height', 230); + $style['show_in_same_row'] = get_parameter( + 'show_in_same_row', + 0 + ); + $style['show_in_landscape'] = get_parameter( + 'show_in_landscape', + 0 + ); + $style['hide_notinit_agents'] = get_parameter( + 'hide_notinit_agents', + 0 + ); + $style['priority_mode'] = get_parameter( + 'priority_mode', + REPORT_PRIORITY_MODE_OK + ); + $style['dyn_height'] = get_parameter( + 'dyn_height', + 230 + ); switch ($values['type']) { case 'event_report_agent': case 'event_report_group': case 'event_report_module': - // Added for events items - $style['show_summary_group'] = $show_summary_group; - $style['filter_event_severity'] = json_encode($filter_event_severity); - $style['filter_event_type'] = json_encode($filter_event_type); - $style['filter_event_status'] = json_encode($filter_event_status); + // Added for events items. + $style['show_summary_group'] = $show_summary_group; + $style['filter_event_severity'] = json_encode( + $filter_event_severity + ); + $style['filter_event_type'] = json_encode( + $filter_event_type + ); + $style['filter_event_status'] = json_encode( + $filter_event_status + ); $style['event_graph_by_agent'] = $event_graph_by_agent; $style['event_graph_by_user_validator'] = $event_graph_by_user_validator; @@ -1403,10 +1910,15 @@ switch ($action) { break; case 'simple_graph': - // Warning. We are using this column to hold this value to avoid - // the modification of the database for compatibility reasons. - $style['percentil'] = (int) get_parameter('percentil'); - $style['fullscale'] = (int) get_parameter('fullscale'); + // Warning. We are using this column to hold + // this value to avoid the modification of the + // database for compatibility reasons. + $style['percentil'] = (int) get_parameter( + 'percentil' + ); + $style['fullscale'] = (int) get_parameter( + 'fullscale' + ); if ($label != '') { $style['label'] = $label; } else { @@ -1415,7 +1927,9 @@ switch ($action) { break; case 'network_interfaces_report': - $style['fullscale'] = (int) get_parameter('fullscale'); + $style['fullscale'] = (int) get_parameter( + 'fullscale' + ); break; case 'module_histogram_graph': @@ -1436,12 +1950,17 @@ switch ($action) { case 'MTBF': case 'MTTR': case 'simple_baseline_graph': + case 'nt_top_n': if ($label != '') { $style['label'] = $label; } else { $style['label'] = ''; } break; + + default: + // Default. + break; } $values['style'] = io_safe_input(json_encode($style)); @@ -1456,6 +1975,10 @@ switch ($action) { unset($values['type']); } break; + + default: + // Default. + break; } $resultOperationDB = db_process_sql_update( @@ -1469,54 +1992,81 @@ switch ($action) { break; case 'save': - $values = []; $values['id_report'] = $idReport; $values['type'] = get_parameter('type', null); - // $values['name'] = (string) get_parameter('name'); $values['description'] = get_parameter('description'); $label = get_parameter('label', ''); - // Add macros name + // Add macros name. $items_label = []; $items_label['type'] = get_parameter('type'); $items_label['id_agent'] = get_parameter('id_agent'); - $items_label['id_agent_module'] = get_parameter('id_agent_module'); + $items_label['id_agent_module'] = get_parameter( + 'id_agent_module' + ); $name_it = (string) get_parameter('name'); $values['recursion'] = get_parameter('recursion', null); - $values['name'] = reporting_label_macro($items_label, $name_it); + $values['name'] = reporting_label_macro( + $items_label, + $name_it + ); - // Support for projection graph, prediction date and SLA reports - // 'top_n_value', 'top_n' and 'text' fields will be reused for these types of report + // Support for projection graph, prediction date + // and SLA reports 'top_n_value', 'top_n' and 'text' + // fields will be reused for these types of report. switch ($values['type']) { case 'projection_graph': $values['period'] = get_parameter('period1'); - $values['top_n_value'] = get_parameter('period2'); + $values['top_n_value'] = get_parameter( + 'period2' + ); $values['text'] = get_parameter('text'); $good_format = true; break; case 'prediction_date': $values['period'] = get_parameter('period1'); - $values['top_n'] = get_parameter('radiobutton_max_min_avg'); - $values['top_n_value'] = get_parameter('quantity'); + $values['top_n'] = get_parameter( + 'radiobutton_max_min_avg' + ); + $values['top_n_value'] = get_parameter( + 'quantity' + ); $interval_max = get_parameter('max_interval'); $interval_min = get_parameter('min_interval'); - // Checks intervals fields - if (preg_match('/^(\-)*[0-9]*\.?[0-9]+$/', $interval_max) and preg_match('/^(\-)*[0-9]*\.?[0-9]+$/', $interval_min)) { + // Checks intervals fields. + if (preg_match( + '/^(\-)*[0-9]*\.?[0-9]+$/', + $interval_max + ) + && preg_match( + '/^(\-)*[0-9]*\.?[0-9]+$/', + $interval_min + ) + ) { $good_format = true; } - $intervals = get_parameter('max_interval').';'.get_parameter('min_interval'); + $intervals = get_parameter( + 'max_interval' + ).';'.get_parameter('min_interval'); $values['text'] = $intervals; break; case 'SLA': $values['period'] = get_parameter('period'); - $values['top_n'] = get_parameter('combo_sla_sort_options', 0); - $values['top_n_value'] = get_parameter('quantity'); + $values['top_n'] = get_parameter( + 'combo_sla_sort_options', + 0 + ); + $values['top_n_value'] = get_parameter( + 'quantity' + ); $values['text'] = get_parameter('text'); - $values['show_graph'] = get_parameter('combo_graph_options'); + $values['show_graph'] = get_parameter( + 'combo_graph_options' + ); $good_format = true; break; @@ -1525,7 +2075,9 @@ switch ($action) { $values['period'] = 0; $es['date'] = get_parameter('date'); $es['id_agents'] = get_parameter('id_agents'); - $es['inventory_modules'] = get_parameter('inventory_modules'); + $es['inventory_modules'] = get_parameter( + 'inventory_modules' + ); $values['external_source'] = json_encode($es); $good_format = true; break; @@ -1548,9 +2100,15 @@ switch ($action) { case 'agent_module': $agents_to_report = get_parameter('id_agents2'); - $modules_to_report = get_parameter('module', ''); + $modules_to_report = get_parameter( + 'module', + '' + ); - $es['module'] = get_same_modules($agents_to_report, $modules_to_report); + $es['module'] = get_same_modules( + $agents_to_report, + $modules_to_report + ); $es['id_agents'] = $agents_to_report; $values['external_source'] = json_encode($es); @@ -1560,7 +2118,9 @@ switch ($action) { case 'inventory_changes': $values['period'] = get_parameter('period'); $es['id_agents'] = get_parameter('id_agents'); - $es['inventory_modules'] = get_parameter('inventory_modules'); + $es['inventory_modules'] = get_parameter( + 'inventory_modules' + ); $values['external_source'] = json_encode($es); $good_format = true; break; @@ -1576,30 +2136,38 @@ switch ($action) { break; case 'netflow_area': - case 'netflow_pie': case 'netflow_data': - case 'netflow_statistics': case 'netflow_summary': - $values['text'] = get_parameter('netflow_filter'); - $values['description'] = get_parameter('description'); + $values['text'] = get_parameter( + 'netflow_filter' + ); + $values['description'] = get_parameter( + 'description' + ); $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter('resolution'); - $values['top_n_value'] = get_parameter('max_values'); + $values['top_n_value'] = get_parameter( + 'max_values' + ); $good_format = true; break; case 'availability': $values['period'] = get_parameter('period'); // HACK it is saved in show_graph field. - // Show interfaces instead the modules - $values['show_graph'] = get_parameter('checkbox_show_address_agent'); + // Show interfaces instead the modules. + $values['show_graph'] = get_parameter( + 'checkbox_show_address_agent' + ); $good_format = true; break; case 'simple_graph': case 'simple_baseline_graph': // HACK it is saved in show_graph field. - $values['show_graph'] = (int) get_parameter('time_compare_overlapped'); + $values['show_graph'] = (int) get_parameter( + 'time_compare_overlapped' + ); $values['period'] = get_parameter('period'); $good_format = true; break; @@ -1608,18 +2176,37 @@ switch ($action) { case 'max_value': case 'avg_value': $values['period'] = get_parameter('period'); - $values['lapse_calc'] = get_parameter('lapse_calc'); + $values['lapse_calc'] = get_parameter( + 'lapse_calc' + ); $values['lapse'] = get_parameter('lapse'); - $values['visual_format'] = get_parameter('visual_format'); + $values['visual_format'] = get_parameter( + 'visual_format' + ); + $good_format = true; + break; + + case 'nt_top_n': + $values['top_n_value'] = get_parameter( + 'quantity' + ); + $values['period'] = get_parameter('period'); $good_format = true; break; default: $values['period'] = get_parameter('period'); - $values['top_n'] = get_parameter('radiobutton_max_min_avg', 0); - $values['top_n_value'] = get_parameter('quantity'); + $values['top_n'] = get_parameter( + 'radiobutton_max_min_avg', + 0 + ); + $values['top_n_value'] = get_parameter( + 'quantity' + ); $values['text'] = get_parameter('text'); - $values['show_graph'] = get_parameter('combo_graph_options'); + $values['show_graph'] = get_parameter( + 'combo_graph_options' + ); $good_format = true; break; } @@ -1629,38 +2216,37 @@ switch ($action) { $values['server_name'] = get_parameter('server_name'); $server_id = (int) get_parameter('server_id'); if ($server_id != 0) { - $connection = metaconsole_get_connection_by_id($server_id); + $connection = metaconsole_get_connection_by_id( + $server_id + ); $values['server_name'] = $connection['server_name']; } if ($values['server_name'] == '') { - $values['server_name'] = get_parameter('combo_server'); + $values['server_name'] = get_parameter( + 'combo_server' + ); } $values['id_agent'] = get_parameter('id_agent'); $values['id_gs'] = get_parameter('id_custom_graph'); - if (($values['type'] == 'alert_report_agent') or ($values['type'] == 'event_report_agent') or ($values['type'] == 'agent_configuration') or ($values['type'] == 'group_configuration')) { + if (($values['type'] == 'alert_report_agent') + || ($values['type'] == 'event_report_agent') + || ($values['type'] == 'agent_configuration') + || ($values['type'] == 'group_configuration') + ) { $values['id_agent_module'] = ''; } else { - $values['id_agent_module'] = get_parameter('id_agent_module'); + $values['id_agent_module'] = get_parameter( + 'id_agent_module' + ); } - switch ($config['dbtype']) { - case 'mysql': - case 'postgresql': - $values['only_display_wrong'] = (int) get_parameter('checkbox_only_display_wrong', 0); - break; - - case 'oracle': - $only_display_wrong_tmp = get_parameter('checkbox_only_display_wrong'); - if (empty($only_display_wrong_tmp)) { - $values['only_display_wrong'] = 0; - } else { - $values['only_display_wrong'] = $only_display_wrong_tmp; - } - break; - } + $values['only_display_wrong'] = (int) get_parameter( + 'checkbox_only_display_wrong', + 0 + ); $values['monday'] = get_parameter('monday', 0); $values['tuesday'] = get_parameter('tuesday', 0); @@ -1669,53 +2255,133 @@ switch ($action) { $values['friday'] = get_parameter('friday', 0); $values['saturday'] = get_parameter('saturday', 0); $values['sunday'] = get_parameter('sunday', 0); - switch ($config['dbtype']) { - case 'mysql': - case 'postgresql': - $values['time_from'] = get_parameter('time_from'); - $values['time_to'] = get_parameter('time_to'); - break; + $values['total_time'] = get_parameter('total_time', 0); + $values['time_failed'] = get_parameter( + 'time_failed', + 0 + ); + $values['time_in_ok_status'] = get_parameter( + 'time_in_ok_status', + 0 + ); + $values['time_in_unknown_status'] = get_parameter( + 'time_in_unknown_status', + 0 + ); + $values['time_of_not_initialized_module'] = get_parameter( + 'time_of_not_initialized_module', + 0 + ); + $values['time_of_downtime'] = get_parameter( + 'time_of_downtime', + 0 + ); + $values['total_checks'] = get_parameter( + 'total_checks', + 0 + ); + $values['checks_failed'] = get_parameter( + 'checks_failed', + 0 + ); + $values['checks_in_ok_status'] = get_parameter( + 'checks_in_ok_status', + 0 + ); + $values['unknown_checks'] = get_parameter( + 'unknown_checks', + 0 + ); + $values['agent_max_value'] = get_parameter( + 'agent_max_value', + 0 + ); + $values['agent_min_value'] = get_parameter( + 'agent_min_value', + 0 + ); - case 'oracle': - $values['time_from'] = '#to_date(\''.get_parameter('time_from').'\',\'hh24:mi:ss\')'; - $values['time_to'] = '#to_date(\''.get_parameter('time_to').'\', \'hh24:mi:ss\')'; - break; - } + $values['time_from'] = get_parameter( + 'time_from' + ); + $values['time_to'] = get_parameter('time_to'); - $values['group_by_agent'] = get_parameter('checkbox_row_group_by_agent', 0); - $values['show_resume'] = get_parameter('checkbox_show_resume', 0); - $values['order_uptodown'] = get_parameter('radiobutton_order_uptodown', 0); - $values['exception_condition'] = (int) get_parameter('radiobutton_exception_condition', 0); - $values['exception_condition_value'] = get_parameter('exception_condition_value'); - $values['id_module_group'] = get_parameter('combo_modulegroup'); + $values['group_by_agent'] = get_parameter( + 'checkbox_row_group_by_agent', + 0 + ); + $values['show_resume'] = get_parameter( + 'checkbox_show_resume', + 0 + ); + $values['order_uptodown'] = get_parameter( + 'radiobutton_order_uptodown', + 0 + ); + $values['exception_condition'] = (int) get_parameter( + 'radiobutton_exception_condition', + 0 + ); + $values['exception_condition_value'] = get_parameter( + 'exception_condition_value' + ); + $values['id_module_group'] = get_parameter( + 'combo_modulegroup' + ); $values['id_group'] = get_parameter('combo_group'); - if ((($values['type'] == 'custom_graph') or ($values['type'] == 'automatic_custom_graph')) && ($values['id_gs'] == 0 || $values['id_gs'] == '')) { + if ((($values['type'] == 'custom_graph') + || ($values['type'] == 'automatic_custom_graph')) + && ($values['id_gs'] == 0 || $values['id_gs'] == '') + ) { $resultOperationDB = false; break; } - if ($config['metaconsole'] == 1 && defined('METACONSOLE')) { - if (($values['type'] == 'custom_graph') or ($values['type'] == 'automatic_custom_graph')) { - $id_gs = substr($values['id_gs'], 0, strpos($values['id_gs'], '|')); + if ($config['metaconsole'] == 1 + && defined('METACONSOLE') + ) { + if (($values['type'] == 'custom_graph') + || ($values['type'] == 'automatic_custom_graph') + ) { + $id_gs = substr( + $values['id_gs'], + 0, + strpos($values['id_gs'], '|') + ); if ($id_gs !== false && $id_gs !== '') { - $server_name = strstr($values['id_gs'], '|'); + $server_name = strstr( + $values['id_gs'], + '|' + ); $values['id_gs'] = $id_gs; - $values['server_name'] = substr($server_name, 1, strlen($server_name)); + $values['server_name'] = substr( + $server_name, + 1, + strlen($server_name) + ); } } } - if (($values['type'] == 'sql') or ($values['type'] == 'sql_graph_hbar') - or ($values['type'] == 'sql_graph_vbar') or ($values['type'] == 'sql_graph_pie') + if (($values['type'] == 'sql') + || ($values['type'] == 'sql_graph_hbar') + || ($values['type'] == 'sql_graph_vbar') + || ($values['type'] == 'sql_graph_pie') ) { - $values['treport_custom_sql_id'] = get_parameter('id_custom'); + $values['treport_custom_sql_id'] = get_parameter( + 'id_custom' + ); if ($values['treport_custom_sql_id'] == 0) { - $values['external_source'] = get_parameter('sql'); + $values['external_source'] = get_parameter( + 'sql' + ); } - $values['historical_db'] = get_parameter('historical_db_check'); + $values['historical_db'] = get_parameter( + 'historical_db_check' + ); $values['top_n_value'] = get_parameter('max_items'); } else if ($values['type'] == 'url') { $values['external_source'] = get_parameter('url'); @@ -1727,38 +2393,85 @@ switch ($action) { $values['column_separator'] = get_parameter('field'); $values['line_separator'] = get_parameter('line'); + $values['current_month'] = get_parameter('current_month'); + $style = []; - $style['show_in_same_row'] = get_parameter('show_in_same_row', 0); - $style['show_in_landscape'] = get_parameter('show_in_landscape', 0); - $style['hide_notinit_agents'] = get_parameter('hide_notinit_agents', 0); - $style['priority_mode'] = get_parameter('priority_mode', REPORT_PRIORITY_MODE_OK); + $style['show_in_same_row'] = get_parameter( + 'show_in_same_row', + 0 + ); + $style['show_in_landscape'] = get_parameter( + 'show_in_landscape', + 0 + ); + $style['hide_notinit_agents'] = get_parameter( + 'hide_notinit_agents', + 0 + ); + $style['priority_mode'] = get_parameter( + 'priority_mode', + REPORT_PRIORITY_MODE_OK + ); $style['dyn_height'] = get_parameter('dyn_height', 230); switch ($values['type']) { case 'event_report_agent': case 'event_report_group': case 'event_report_module': - $show_summary_group = get_parameter('show_summary_group', 0); - $filter_event_severity = get_parameter('filter_event_severity', ''); - $filter_event_type = get_parameter('filter_event_type', ''); - $filter_event_status = get_parameter('filter_event_status', ''); + $show_summary_group = get_parameter( + 'show_summary_group', + 0 + ); + $filter_event_severity = get_parameter( + 'filter_event_severity', + '' + ); + $filter_event_type = get_parameter( + 'filter_event_type', + '' + ); + $filter_event_status = get_parameter( + 'filter_event_status', + '' + ); - $event_graph_by_agent = get_parameter('event_graph_by_agent', 0); - $event_graph_by_user_validator = get_parameter('event_graph_by_user_validator', 0); - $event_graph_by_criticity = get_parameter('event_graph_by_criticity', 0); - $event_graph_validated_vs_unvalidated = get_parameter('event_graph_validated_vs_unvalidated', 0); + $event_graph_by_agent = get_parameter( + 'event_graph_by_agent', + 0 + ); + $event_graph_by_user_validator = get_parameter( + 'event_graph_by_user_validator', + 0 + ); + $event_graph_by_criticity = get_parameter( + 'event_graph_by_criticity', + 0 + ); + $event_graph_validated_vs_unvalidated = get_parameter( + 'event_graph_validated_vs_unvalidated', + 0 + ); - $event_filter_search = get_parameter('filter_search', ''); + $event_filter_search = get_parameter( + 'filter_search', + '' + ); - // Added for events items - $style['show_summary_group'] = $show_summary_group; - $style['filter_event_severity'] = json_encode($filter_event_severity); - $style['filter_event_type'] = json_encode($filter_event_type); - $style['filter_event_status'] = json_encode($filter_event_status); + // Added for events items. + $style['show_summary_group'] = $show_summary_group; + $style['filter_event_severity'] = json_encode( + $filter_event_severity + ); + $style['filter_event_type'] = json_encode( + $filter_event_type + ); + $style['filter_event_status'] = json_encode( + $filter_event_status + ); - $style['event_graph_by_agent'] = $event_graph_by_agent; - $style['event_graph_by_user_validator'] = $event_graph_by_user_validator; - $style['event_graph_by_criticity'] = $event_graph_by_criticity; + $style['event_graph_by_agent'] = $event_graph_by_agent; + $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; @@ -1772,14 +2485,23 @@ switch ($action) { $style['label'] = ''; } break; + + default: + // Default. + break; } break; case 'simple_graph': - // Warning. We are using this column to hold this value to avoid - // the modification of the database for compatibility reasons. - $style['percentil'] = (int) get_parameter('percentil'); - $style['fullscale'] = (int) get_parameter('fullscale'); + // Warning. We are using this column to hold + // this value to avoid the modification + // of the database for compatibility reasons. + $style['percentil'] = (int) get_parameter( + 'percentil' + ); + $style['fullscale'] = (int) get_parameter( + 'fullscale' + ); if ($label != '') { $style['label'] = $label; } else { @@ -1788,7 +2510,9 @@ switch ($action) { break; case 'network_interfaces_report': - $style['fullscale'] = (int) get_parameter('fullscale'); + $style['fullscale'] = (int) get_parameter( + 'fullscale' + ); break; case 'module_histogram_graph': @@ -1809,28 +2533,22 @@ switch ($action) { case 'MTBF': case 'MTTR': case 'simple_baseline_graph': + case 'nt_top_n': if ($label != '') { $style['label'] = $label; } else { $style['label'] = ''; } break; + + default: + // Default. + break; } $values['style'] = io_safe_input(json_encode($style)); if ($good_format) { - switch ($config['dbtype']) { - case 'oracle': - if (isset($values['type'])) { - $values[db_escape_key_identifier( - 'type' - )] = $values['type']; - unset($values['type']); - } - break; - } - $result = db_process_sql_insert( 'treport_content', $values @@ -1841,24 +2559,11 @@ switch ($action) { } else { $idItem = $result; - switch ($config['dbtype']) { - case 'mysql': - $max = db_get_all_rows_sql( - 'SELECT max(`order`) AS max - FROM treport_content - WHERE id_report = '.$idReport.';' - ); - break; - - case 'postgresql': - case 'oracle': - $max = db_get_all_rows_sql( - 'SELECT max("order") AS max - FROM treport_content - WHERE id_report = '.$idReport - ); - break; - } + $max = db_get_all_rows_sql( + 'SELECT max(`order`) AS max + FROM treport_content + WHERE id_report = '.$idReport.';' + ); if ($max === false) { $max = 0; @@ -1866,39 +2571,30 @@ switch ($action) { $max = $max[0]['max']; } - switch ($config['dbtype']) { - case 'mysql': - db_process_sql_update( - 'treport_content', - ['`order`' => ($max + 1)], - ['id_rc' => $idItem] - ); - break; - - case 'postgresql': - case 'oracle': - db_process_sql_update( - 'treport_content', - ['"order"' => ($max + 1)], - ['id_rc' => $idItem] - ); - break; - } + db_process_sql_update( + 'treport_content', + ['`order`' => ($max + 1)], + ['id_rc' => $idItem] + ); $resultOperationDB = true; } break; - } - // If fields dont have good format - else { + } else { + // If fields dont have good format. $resultOperationDB = false; } + break; + + default: + // Default. + break; } break; default: - if ($enterpriseEnable and $activeTab != 'advanced') { + if ($enterpriseEnable && $activeTab != 'advanced') { $resultOperationDB = reporting_enterprise_update_action(); } break; @@ -1928,20 +2624,35 @@ switch ($action) { $report = db_get_row_filter('treport', ['id_report' => $idReport]); $reportName = $report['name']; - $resultOperationDB = db_process_sql_delete('treport_content_sla_combined', ['id_report_content' => $idItem]); - $resultOperationDB2 = db_process_sql_delete('treport_content_item', ['id_report_content' => $idItem]); + $resultOperationDB = db_process_sql_delete( + 'treport_content_sla_combined', + ['id_report_content' => $idItem] + ); + $resultOperationDB2 = db_process_sql_delete( + 'treport_content_item', + ['id_report_content' => $idItem] + ); if ($resultOperationDB !== false) { - $resultOperationDB = db_process_sql_delete('treport_content', ['id_rc' => $idItem]); + $resultOperationDB = db_process_sql_delete( + 'treport_content', + ['id_rc' => $idItem] + ); } if ($resultOperationDB2 !== false) { - $resultOperationDB2 = db_process_sql_delete('treport_content', ['id_rc' => $idItem]); + $resultOperationDB2 = db_process_sql_delete( + 'treport_content', + ['id_rc' => $idItem] + ); } break; case 'order': $resultOperationDB = null; - $report = db_get_row_filter('treport', ['id_report' => $idReport]); + $report = db_get_row_filter( + 'treport', + ['id_report' => $idReport] + ); $reportName = $report['name']; $idGroupReport = $report['id_group']; @@ -1956,7 +2667,7 @@ switch ($action) { case 'agent': case 'type': - // Sort functionality for normal console + // Sort functionality for normal console. if (!defined('METACONSOLE')) { switch ($field) { case 'module': @@ -1990,6 +2701,10 @@ switch ($action) { case 'type': $sql = 'SELECT id_rc FROM treport_content WHERE %s ORDER BY type %s'; break; + + default: + // Default. + break; } $sql = sprintf($sql, 'id_report = '.$idReport, '%s'); @@ -2001,17 +2716,24 @@ switch ($action) { case 'down': $sql = sprintf($sql, 'DESC'); break; + + default: + // Default. + break; } $ids = db_get_all_rows_sql($sql); - } - // Sort functionality for metaconsole - else if ($config['metaconsole'] == 1) { + } else if ($config['metaconsole'] == 1) { + // Sort functionality for metaconsole. switch ($field) { case 'agent': case 'module': $sql = 'SELECT id_rc, id_agent, id_agent_module, server_name FROM treport_content WHERE %s ORDER BY server_name'; - $sql = sprintf($sql, 'id_report = '.$idReport, '%s'); + $sql = sprintf( + $sql, + 'id_report = '.$idReport, + '%s' + ); $report_items = db_get_all_rows_sql($sql); @@ -2021,34 +2743,47 @@ switch ($action) { if (!empty($report_items)) { foreach ($report_items as $report_item) { - $connection = metaconsole_get_connection($report_item['server_name']); + $connection = metaconsole_get_connection( + $report_item['server_name'] + ); if (metaconsole_load_external_db($connection) != NOERR) { - // ui_print_error_message ("Error connecting to ".$server_name); + continue; } switch ($field) { case 'agent': - $agents_name = agents_get_agents(['id_agente' => $report_item['id_agent']], 'nombre'); + $agents_name = agents_get_agents( + ['id_agente' => $report_item['id_agent']], + 'nombre' + ); - // Item without agent + // Item without agent. if (!$agents_name) { $element_name = ''; } else { - $agent_name = array_shift($agents_name); + $agent_name = array_shift( + $agents_name + ); $element_name = $agent_name['nombre']; } break; case 'module': - $module_name = modules_get_agentmodule_name($report_item['id_agent_module']); + $module_name = modules_get_agentmodule_name( + $report_item['id_agent_module'] + ); - // Item without module + // Item without module. if (!$module_name) { $element_name = ''; } else { $element_name = $module_name; } break; + + default: + // Default. + break; } metaconsole_restore_db(); @@ -2056,7 +2791,7 @@ switch ($action) { $temp_sort[$report_item['id_rc']] = $element_name; } - // Performes sorting + // Performes sorting. switch ($dir) { case 'up': asort($temp_sort); @@ -2065,6 +2800,10 @@ switch ($action) { case 'down': arsort($temp_sort); break; + + default: + // Default. + break; } foreach ($temp_sort as $temp_element_key => $temp_element_val) { @@ -2073,13 +2812,13 @@ switch ($action) { $i++; } - // Free resources + // Free resources. unset($temp_sort); unset($report_items); } break; - // Type case only depends of local database + // Type case only depends of local database. case 'type': $sql = 'SELECT id_rc FROM treport_content @@ -2098,10 +2837,17 @@ switch ($action) { case 'down': $sql = sprintf($sql, 'DESC'); break; + + default: + // Default. + break; } $ids = db_get_all_rows_sql($sql); + break; + default: + // Default. break; } } @@ -2109,40 +2855,28 @@ switch ($action) { $count = 1; $resultOperationDB = true; foreach ($ids as $id) { - $result = db_process_sql_update('treport_content', ['order' => $count], ['id_rc' => $id['id_rc']]); + $result = db_process_sql_update( + 'treport_content', + ['order' => $count], + ['id_rc' => $id['id_rc']] + ); if ($result === false) { $resultOperationDB = false; break; } - $count = ($count + 1); + $count++; } break; default: - switch ($config['dbtype']) { - case 'mysql': - $oldOrder = db_get_value_sql( - ' - SELECT `order` - FROM treport_content - WHERE id_rc = '.$idItem - ); - break; + $oldOrder = db_get_value_sql( + 'SELECT `order` + FROM treport_content + WHERE id_rc = '.$idItem + ); - case 'postgresql': - case 'oracle': - $oldOrder = db_get_value_sql( - ' - SELECT "order" - FROM treport_content - WHERE id_rc = '.$idItem - ); - break; - } - - // db_get_value_filter('order', 'treport_content', array('id_rc' => $idItem)); switch ($dir) { case 'up': $newOrder = ($oldOrder - 1); @@ -2151,79 +2885,34 @@ switch ($action) { case 'down': $newOrder = ($oldOrder + 1); break; - } - switch ($config['dbtype']) { - case 'mysql': - $resultOperationDB = db_process_sql_update( - 'treport_content', - ['`order`' => $oldOrder], - [ - '`order`' => $newOrder, - 'id_report' => $idReport, - ] - ); - break; - - case 'postgresql': - $resultOperationDB = db_process_sql_update( - 'treport_content', - ['"order"' => $oldOrder], - [ - '"order"' => $newOrder, - 'id_report' => $idReport, - ] - ); - break; - - case 'oracle': - $resultOperationDB = db_process_sql_update( - 'treport_content', - ['"order"' => $oldOrder], - [ - '"order"' => $newOrder, - 'id_report' => $idReport, - ], - 'AND', - false - ); + default: + // Default. break; } + $resultOperationDB = db_process_sql_update( + 'treport_content', + ['`order`' => $oldOrder], + [ + '`order`' => $newOrder, + 'id_report' => $idReport, + ] + ); + + if ($resultOperationDB !== false) { - switch ($config['dbtype']) { - case 'mysql': - $resultOperationDB = db_process_sql_update( - 'treport_content', - ['`order`' => $newOrder], - ['id_rc' => $idItem] - ); - break; - - case 'postgresql': - $resultOperationDB = db_process_sql_update( - 'treport_content', - ['"order"' => $newOrder], - ['id_rc' => $idItem] - ); - break; - - case 'oracle': - $resultOperationDB = db_process_sql_update( - 'treport_content', - ['"order"' => $newOrder], - ['id_rc' => $idItem], - 'AND', - false - ); - break; - } + $resultOperationDB = db_process_sql_update( + 'treport_content', + ['`order`' => $newOrder], + ['id_rc' => $idItem] + ); } break; } break; - // Added for report templates + // Added for report templates. default: if ($enterpriseEnable) { $buttons = [ @@ -2236,6 +2925,7 @@ switch ($action) { $buttons = reporting_enterprise_add_main_Tabs($buttons); $subsection = ''; + $helpers = ''; switch ($activeTab) { case 'main': $buttons['list_reports']['active'] = true; @@ -2243,13 +2933,20 @@ switch ($action) { break; default: - $subsection = reporting_enterprise_add_subsection_main($activeTab, $buttons); + $data_tab = reporting_enterprise_add_subsection_main( + $activeTab, + $buttons + ); + + $subsection = $data_tab['subsection']; + $buttons = $data_tab['buttons']; + $helpers = $data_tab['helper']; break; } - // Page header for metaconsole - if ($enterpriseEnable and defined('METACONSOLE')) { - // Bread crumbs + // Page header for metaconsole. + if ($enterpriseEnable && defined('METACONSOLE')) { + // Bread crumbs. ui_meta_add_breadcrumb( [ 'link' => 'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&pure='.$pure, @@ -2259,14 +2956,22 @@ switch ($action) { ui_meta_print_page_header($nav_bar); - // Print header + // Print header. ui_meta_print_header(__('Reporting'), '', $buttons); + } else { + // Page header for normal console. + ui_print_page_header( + $subsection, + 'images/op_reporting.png', + false, + '', + false, + $buttons, + false, + '', + 60 + ); } - // Page header for normal console - else { - ui_print_page_header($subsection, 'images/op_reporting.png', false, '', false, $buttons, false, '', 60); - } - reporting_enterprise_select_main_tab($action); } @@ -2301,7 +3006,10 @@ $buttons = [ ]; if ($enterpriseEnable) { - $buttons = reporting_enterprise_add_Tabs($buttons, $idReport); + $buttons = reporting_enterprise_add_Tabs( + $buttons, + $idReport + ); } $buttons['view'] = [ @@ -2325,9 +3033,9 @@ if ($idReport != 0) { $textReportName = __('Create Custom Report'); } -// Page header for metaconsole -if ($enterpriseEnable and defined('METACONSOLE')) { - // Bread crumbs +// Page header for metaconsole. +if ($enterpriseEnable && defined('METACONSOLE')) { + // Bread crumbs. ui_meta_add_breadcrumb( [ 'link' => 'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&pure='.$pure, @@ -2337,14 +3045,24 @@ if ($enterpriseEnable and defined('METACONSOLE')) { ui_meta_print_page_header($nav_bar); - // Print header + // Print header. ui_meta_print_header(__('Reporting').$textReportName, '', $buttons); } else { + switch ($activeTab) { + case 'main': + $helpers = ''; + break; + + default: + $helpers = 'reporting_'.$activeTab.'_tab'; + break; + } + ui_print_page_header( $textReportName, 'images/op_reporting.png', false, - 'reporting_'.$activeTab.'_tab', + $helpers, false, $buttons, false, @@ -2367,7 +3085,11 @@ if ($resultOperationDB !== null) { break; } - ui_print_result_message($resultOperationDB, __('Successfull action'), __('Unsuccessful action

'.$err)); + ui_print_result_message( + $resultOperationDB, + __('Successfull action'), + __('Unsuccessful action

'.$err) + ); } switch ($activeTab) { diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.js b/pandora_console/godmode/reporting/visual_console_builder.editor.js index 6744d2fb2d..cb72ce58ce 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", ""); @@ -674,12 +678,17 @@ function update_button_palette_callback() { return false; } } - if (values["module"] == 0) { + var radio_value = $("input[name='radio_choice']:checked").val(); + if (values["agent"] == "" && radio_value == "module_graph") { + dialog_message("#message_alert_no_agent"); + return false; + } + if (values["module"] == 0 && radio_value == "module_graph") { dialog_message("#message_alert_no_module"); return false; } - if (values["agent"] == "") { - dialog_message("#message_alert_no_agent"); + if (values["id_custom_graph"] == 0 && radio_value == "custom_graph") { + dialog_message("#message_alert_no_custom_graph"); return false; } if ($("input[name=width_module_graph]").val() == "") { @@ -1090,10 +1099,11 @@ function readFields() { var text = tinymce.get("text-label").getContent(); values["label"] = text; + values["percentile_label_color"] = $( + "input[name=percentile_label_color]" + ).val(); + if ($("input[name=percentile_label]").val().length > 0) { - values["percentile_label_color"] = $( - "input[name=percentile_label_color]" - ).val(); values["label"] = " __('View')]).''; -} - -$user_groups_w = users_get_groups(false, 'PM', true, false, null, 'id_grupo'); -$user_groups_w = array_keys($user_groups_w); - -$user_groups_r = users_get_groups(false, 'AW', true, false, null, 'id_grupo'); -$user_groups_r = array_keys($user_groups_r); - -// Headers. -ui_print_page_header( - __('Manage recontask'), - 'images/gm_servers.png', - false, - '', - true, - $options -); - - -// -------------------------------- -// DELETE A RECON TASKs. -// -------------------------------- -if (isset($_GET['delete'])) { - $id = get_parameter_get('delete'); - - $result = db_process_sql_delete('trecon_task', ['id_rt' => $id]); - - if ($result !== false) { - ui_print_success_message(__('Successfully deleted recon task')); - } else { - ui_print_error_message(__('Error deleting recon task')); - } -} else if (isset($_GET['disabled'])) { - $id = get_parameter_get('id'); - $disabled = get_parameter_get('disabled'); - - $result = db_process_sql_update( - 'trecon_task', - ['disabled' => $disabled], - ['id_rt' => $id] - ); - - if ($result !== false) { - ui_print_success_message(__('Successfully updated recon task')); - // If the action is enabled, we force recon_task to be queued asap. - if ($disabled == 0) { - servers_force_recon_task($id); - } - } else { - ui_print_error_message(__('Error updating recon task')); - } -} - -// -------------------------------- -// GET PARAMETERS IF UPDATE OR CREATE. -// -------------------------------- -if ((isset($_GET['update'])) || ((isset($_GET['create'])))) { - $name = get_parameter_post('name'); - $network = get_parameter_post('network'); - $description = get_parameter_post('description'); - $id_recon_server = get_parameter_post('id_recon_server'); - $interval = get_parameter_post('interval'); - $id_group = get_parameter_post('id_group'); - $create_incident = get_parameter_post('create_incident'); - $id_network_profile = get_parameter_post('id_network_profile'); - $recon_ports = get_parameter_post('recon_ports', ''); - $id_os = get_parameter_post('id_os', 10); - $snmp_community = get_parameter_post('snmp_community', 'public'); - $id_recon_script = get_parameter('id_recon_script', 0); - $mode = get_parameter('mode', ''); - $field1 = get_parameter('_field1_', ''); - $field2 = get_parameter('_field2_', ''); - $field3 = get_parameter('_field3_', ''); - $field4 = get_parameter('_field4_', ''); - $snmp_version = get_parameter_post('snmp_version'); - $snmp3_auth_user = get_parameter_post('snmp_auth_user'); - $snmp3_auth_pass = get_parameter_post('snmp_auth_pass'); - $snmp3_privacy_method = get_parameter_post('snmp_privacy_method'); - $snmp3_privacy_pass = get_parameter_post('snmp_privacy_pass'); - $snmp3_auth_method = get_parameter_post('snmp_auth_method'); - $snmp3_security_level = get_parameter_post('snmp_security_level'); - - - if ($mode == 'network_sweep') { - $id_recon_script = 0; - } else { - $id_network_profile = 0; - } - - $os_detect = (int) get_parameter('os_detect', 0); - $resolve_names = (int) get_parameter('resolve_names', 0); - $parent_detection = (int) get_parameter('parent_detection', 0); - $parent_recursion = (int) get_parameter('parent_recursion', 1); - $alias_as_name = (int) get_parameter('alias_as_name', 0); - $snmp_enabled = (int) get_parameter('snmp_enabled', 0); - $vlan_enabled = (int) get_parameter('vlan_enabled', 0); - // Get macros. - $macros = (string) get_parameter('macros'); - - if (!empty($macros)) { - $macros = json_decode(base64_decode($macros), true); - - if (isset($macros) === true && is_array($macros) === true) { - foreach ($macros as $k => $m) { - $macros[$k]['value'] = get_parameter($m['macro'], ''); - } - } - } - - $macros = io_json_mb_encode($macros); -} - -// -------------------------------- -// UPDATE A RECON TASK. -// -------------------------------- -if (isset($_GET['update'])) { - $id = get_parameter_get('update'); - - $values = [ - 'snmp_community' => $snmp_community, - 'id_os' => $id_os, - 'name' => $name, - 'subnet' => $network, - 'description' => $description, - 'id_recon_server' => $id_recon_server, - 'create_incident' => $create_incident, - 'id_group' => $id_group, - 'interval_sweep' => $interval, - 'id_network_profile' => $id_network_profile, - 'recon_ports' => $recon_ports, - 'id_recon_script' => $id_recon_script, - 'field1' => $field1, - 'field2' => $field2, - 'field3' => $field3, - 'field4' => $field4, - 'os_detect' => $os_detect, - 'resolve_names' => $resolve_names, - 'parent_detection' => $parent_detection, - 'parent_recursion' => $parent_recursion, - 'macros' => $macros, - 'alias_as_name' => $alias_as_name, - 'snmp_enabled' => $snmp_enabled, - 'vlan_enabled' => $vlan_enabled, - 'snmp_version' => $snmp_version, - ]; - - $values_v3 = [ - 'snmp_auth_user' => $snmp3_auth_user, - 'snmp_auth_pass' => $snmp3_auth_pass, - 'snmp_privacy_method' => $snmp3_privacy_method, - 'snmp_privacy_pass' => $snmp3_privacy_pass, - 'snmp_auth_method' => $snmp3_auth_method, - 'snmp_security_level' => $snmp3_security_level, - ]; - if ($values['snmp_version'] == '1' || $values['snmp_version'] == '2' || $values['snmp_version'] == '2c') { - $values_v3 = [ - 'snmp_auth_user' => '', - 'snmp_auth_pass' => '', - 'snmp_privacy_method' => '', - 'snmp_privacy_pass' => '', - 'snmp_auth_method' => '', - 'snmp_security_level' => '', - ]; - } - - $values = array_merge($values, $values_v3); - - $where = ['id_rt' => $id]; - - $reason = ''; - if ($name != '') { - if (empty($id_recon_script)) { - if (!preg_match('/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/', $network)) { - $reason = __('Wrong format in Subnet field'); - $result = false; - } else { - $result = db_process_sql_update( - 'trecon_task', - $values, - $where - ); - } - } else { - $result = db_process_sql_update( - 'trecon_task', - $values, - $where - ); - } - } else { - $result = false; - } - - if ($result !== false) { - ui_print_success_message(__('Successfully updated recon task')); - } else { - ui_print_error_message(__('Error updating recon task')); - echo $reason; - include 'manage_recontask_form.php'; - return; - } -} - -// -------------------------------- -// CREATE A RECON TASK -// -------------------------------- -if (isset($_GET['create'])) { - $values = [ - 'name' => $name, - 'subnet' => $network, - 'description' => $description, - 'id_recon_server' => $id_recon_server, - 'create_incident' => $create_incident, - 'id_group' => $id_group, - 'id_network_profile' => $id_network_profile, - 'interval_sweep' => $interval, - 'id_os' => $id_os, - 'recon_ports' => $recon_ports, - 'snmp_community' => $snmp_community, - 'id_recon_script' => $id_recon_script, - 'field1' => $field1, - 'field2' => $field2, - 'field3' => $field3, - 'field4' => $field4, - 'os_detect' => $os_detect, - 'resolve_names' => $resolve_names, - 'parent_detection' => $parent_detection, - 'parent_recursion' => $parent_recursion, - 'macros' => $macros, - 'alias_as_name' => $alias_as_name, - 'snmp_enabled' => $snmp_enabled, - 'vlan_enabled' => $vlan_enabled, - 'snmp_version' => $snmp_version, - ]; - - $values_v3 = [ - 'snmp_auth_user' => $snmp3_auth_user, - 'snmp_auth_pass' => $snmp3_auth_pass, - 'snmp_privacy_method' => $snmp3_privacy_method, - 'snmp_privacy_pass' => $snmp3_privacy_pass, - 'snmp_auth_method' => $snmp3_auth_method, - 'snmp_security_level' => $snmp3_security_level, - ]; - if ($values['snmp_version'] == '1' || $values['snmp_version'] == '2' || $values['snmp_version'] == '2c') { - $values_v3 = [ - 'snmp_auth_user' => '', - 'snmp_auth_pass' => '', - 'snmp_privacy_method' => '', - 'snmp_privacy_pass' => '', - 'snmp_auth_method' => '', - 'snmp_security_level' => '', - ]; - } - - if ($values['snmp_version'] == '3') { - $values['vlan_enabled'] = 0; - } - - $values = array_merge($values, $values_v3); - - $name = io_safe_output($name); - $name = trim($name, ' '); - $name = io_safe_input($name); - $reason = ''; - - if ($name != '') { - $name_exists = (bool) db_get_value('name', 'trecon_task', 'name', $name); - - if (empty($id_recon_script)) { - if ($name_exists && (!preg_match('/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/', $network))) { - $reason = __('Recon-task name already exists and incorrect format in Subnet field'); - $result = false; - } else if (!preg_match('/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/', $network)) { - $reason = __('Wrong format in Subnet field'); - $result = false; - } else if ($name_exists) { - $reason = __('Recon-task name already exists'); - $result = false; - } else { - $result = db_process_sql_insert('trecon_task', $values); - } - } else { - if ($name_exists) { - $reason = __('Recon-task name already exists'); - $result = false; - } else { - $result = db_process_sql_insert('trecon_task', $values); - } - } - } else { - $reason = 'The field "Task name" is empty'; - $result = false; - } - - if ($result !== false) { - ui_print_success_message(__('Successfully created recon task')); - } else { - ui_print_error_message(__('Error creating recon task')); - echo $reason; - include 'manage_recontask_form.php'; - return; - } -} - -// -------------------------------- -// SHOW TABLE WITH ALL RECON TASKs. -// -------------------------------- -// Pandora Admin must see all columns. -if (! check_acl($config['id_user'], 0, 'PM')) { - $sql = sprintf( - 'SELECT * - FROM trecon_task RT, tusuario_perfil UP - WHERE - UP.id_usuario = "%s" AND UP.id_grupo = RT.id_group', - $config['id_user'] - ); - - $result = db_get_all_rows_sql($sql); -} else { - $result = db_get_all_rows_in_table('trecon_task'); -} - -$color = 1; -if ($result !== false) { - $table = new StdClass(); - $table->head = [ - __('Name'), - __('Network'), - __('Mode'), - __('Group'), - __('SNMP Version'), - __('Incident'), - __('OS'), - __('Interval'), - __('Ports'), - __('Action'), - ]; - $table->align = [ - 'left', - 'left', - 'left', - 'left', - 'left', - 'left', - 'left', - 'left', - ]; - $table->width = '100%'; - $table->cellpadding = 4; - $table->cellspacing = 4; - $table->class = 'databox data'; - $table->data = []; - - $table->style[8] = 'text-align: left;'; - $table->size[8] = '15%'; - - foreach ($result as $row) { - if (in_array($row['id_group'], $user_groups_r)) { - $data = []; - $data[0] = $row['name']; - if ($row['id_recon_script'] == 0) { - $data[1] = $row['subnet']; - } else { - $data[1] = '-'; - } - - - if ($row['id_recon_script'] == 0) { - // Network recon task. - $data[2] = html_print_image('images/network.png', true, ['title' => __('Network recon task')]).'  '; - $data[2] .= network_profiles_get_name($row['id_network_profile']); - $mode_name = ''; - } else { - // APP recon task. - $data[2] = html_print_image('images/plugin.png', true).'  '; - $mode_name = db_get_sql(sprintf('SELECT name FROM trecon_script WHERE id_recon_script = %d', $row['id_recon_script'])); - $data[2] .= $mode_name; - } - - - // GROUP. - if ($row['id_recon_script'] == 0) { - $data[3] = ui_print_group_icon($row['id_group'], true); - } else { - $data[3] = '-'; - } - - // SNMP VERSION. - if ($row['snmp_version'] == '1') { - $data[4] = 'v. 1'; - } else if ($row['snmp_version'] == '2') { - $data[4] = 'v. 2'; - } else if ($row['snmp_version'] == '2c') { - $data[4] = 'v. 2c'; - } else if ($row['snmp_version'] == '3') { - $data[4] = 'v. 3'; - } - - - - // INCIDENT. - $data[5] = (($row['create_incident'] == 1) ? __('Yes') : __('No')); - - // OS. - if ($row['id_recon_script'] == 0) { - $data[6] = (($row['id_os'] > 0) ? ui_print_os_icon($row['id_os'], false, true) : __('Any')); - } else { - $data[6] = '-'; - } - - // INTERVAL. - if ($row['interval_sweep'] == 0) { - $data[7] = __('Manual'); - } else { - $data[7] = human_time_description_raw($row['interval_sweep']); - } - - // PORTS. - if ($row['id_recon_script'] == 0) { - $data[8] = substr($row['recon_ports'], 0, 15); - } else { - $data[8] = '-'; - } - - // ACTION. - $task_group = $row['id_group']; - - if (in_array($task_group, $user_groups_w)) { - $data[9] = ''.html_print_image('images/eye.png', true).''; - $data[9] .= ''.html_print_image('images/cross.png', true, ['border' => '0']).''; - if ($mode_name != 'IPAM Recon') { - $data[9] .= ''.html_print_image('images/config.png', true).''; - } else { - $sql_ipam = 'select id from tipam_network where id_recon_task ='.$row['id_rt']; - $id_recon_ipam = db_get_sql($sql_ipam); - $data[9] .= ''.html_print_image('images/config.png', true).''; - } - - if ($row['disabled'] == 0) { - $data[9] .= ''.html_print_image('images/lightbulb.png', true).''; - } else { - $data[9] .= ''.html_print_image('images/lightbulb_off.png', true).''; - } - } - - $table->data[] = $data; - } - } - - html_print_table($table); - unset($table); -} else { - echo '
'.__('There are no recon task configured').'
'; -} - -echo '
'; -echo '
'; -echo html_print_submit_button(__('Create'), 'crt', false, 'class="sub next"', true); -echo '
'; -echo '
'; diff --git a/pandora_console/godmode/servers/manage_recontask_form.php b/pandora_console/godmode/servers/manage_recontask_form.php index 0a5967c784..cf95cc76e6 100644 --- a/pandora_console/godmode/servers/manage_recontask_form.php +++ b/pandora_console/godmode/servers/manage_recontask_form.php @@ -1,11 +1,10 @@ '; - echo __('Warning').': '.__('By default, in Windows, %s only support Standard network sweep, not custom scripts', get_product_name()); - echo '
'; -} - -$table = new stdClass(); -$table->id = 'table_recon'; -$table->width = '100%'; -$table->cellspacing = 4; -$table->cellpadding = 4; -$table->class = 'databox filters'; - -$table->rowclass[3] = 'network_sweep'; -$table->rowclass[5] = 'network_sweep'; -$table->rowclass[7] = 'network_sweep'; -$table->rowclass[8] = 'network_sweep'; -$table->rowclass[11] = 'network_sweep'; -$table->rowclass[12] = 'network_sweep'; -$table->rowclass[18] = 'network_sweep'; -$table->rowclass[19] = 'network_sweep'; -$table->rowclass[20] = 'network_sweep'; -$table->rowclass[21] = 'network_sweep'; -$table->rowclass[22] = 'network_sweep'; -$table->rowclass[23] = 'network_sweep'; -$table->rowclass[24] = 'network_sweep'; -$table->rowclass[25] = 'network_sweep recon_v3'; -$table->rowclass[26] = 'network_sweep recon_v3'; -$table->rowclass[27] = 'network_sweep recon_v3'; -$table->rowclass[28] = 'network_sweep recon_v3'; -$table->rowclass[29] = 'network_sweep recon_v3'; -$table->rowclass[30] = 'network_sweep recon_v3'; - -$table->rowclass[6] = 'recon_script'; -$table->rowclass[13] = 'recon_script'; -$table->rowclass[14] = 'recon_script'; -$table->rowclass[15] = 'recon_script'; -$table->rowclass[16] = 'recon_script'; -$table->rowclass[17] = 'recon_script'; -// Name. -$table->data[0][0] = ''.__('Task name').''; -$table->data[0][1] = html_print_input_text('name', $name, '', 25, 0, true); - -// Discovery server. -$table->data[1][0] = ''.__('Discovery server').ui_print_help_tip( - __('You must select a Discovery Server to run the Task, otherwise the Recon Task will never run'), - true -); - -$sql = 'SELECT id_server, name - FROM tserver - WHERE server_type = 3 - ORDER BY name'; -$table->data[1][1] = html_print_select_from_sql( - $sql, - 'id_recon_server', - $id_recon_server, - '', - '', - '', - true -); - -$fields['network_sweep'] = __('Network sweep'); -if (!$is_windows) { - $fields['recon_script'] = __('Custom script'); -} - - -$table->data[2][0] = ''.__('Mode').''; -$table->data[2][1] = html_print_select( - $fields, - 'mode', - $mode, - '', - '', - 0, - true -); - - -// Network. -$table->data[3][0] = ''.__('Network').''; -$table->data[3][0] .= ui_print_help_tip( - __('You can specify several networks, separated by commas, for example: 192.168.50.0/24,192.168.60.0/24'), - true -); -$table->data[3][1] = html_print_input_text( - 'network', - $network, - '', - 25, - 0, - true -); - -// Interval. -$interv_manual = 0; -if ((int) $interval == 0) { - $interv_manual = 1; -} - -$table->data[4][0] = ''.__('Interval'); -$table->data[4][0] .= ui_print_help_tip( - __('Manual interval means that it will be executed only On-demand'), - true -); - -$values = [ - 0 => __('Defined'), - 1 => __('Manual'), -]; -$table->data[4][1] = html_print_select( - $values, - 'interval_manual_defined', - $interv_manual, - '', - '', - '', - true -); - -$table->data[4][1] .= ''; -$table->data[4][1] .= html_print_extended_select_for_time( - 'interval', - $interval, - '', - '', - '0', - false, - true, - false, - false -); -$table->data[4][1] .= ui_print_help_tip( - __('The minimum recomended interval for Recon Task is 5 minutes'), - true -); -$table->data[4][1] .= ''; - - -// Module template. -$table->data[5][0] = ''.__('Module template').''; - -$sql = 'SELECT id_np, name - FROM tnetwork_profile - ORDER BY name'; -$table->data[5][1] = html_print_select_from_sql( - $sql, - 'id_network_profile', - $id_network_profile, - '', - __('None'), - 0, - true -); - -// Recon script. -$data[1] = ''; -$table->data[6][0] = ''.__('Recon script').''; - - -$sql = "SELECT id_recon_script, name - FROM trecon_script - WHERE name <> 'IPAM Recon' - ORDER BY name"; -if ($name_script != 'IPAM Recon') { - $table->data[6][1] = html_print_select_from_sql( - $sql, - 'id_recon_script', - $id_recon_script, - '', - '', - '', - true - ); - $table->data[6][1] .= "'; - $table->data[6][1] .= $data[1] .= html_print_input_hidden( - 'macros', - base64_encode($macros), - true - ); -} else { - $table->data[6][1] = 'IPAM Recon'; -} - -// OS. -$table->data[7][0] = ''.__('OS').''; - -$sql = 'SELECT id_os, name - FROM tconfig_os - ORDER BY name'; -$table->data[7][1] = html_print_select_from_sql( - $sql, - 'id_os', - $id_os, - '', - __('Any'), - -1, - true -); - -// Recon ports. -$table->data[8][0] = ''.__('Ports').''; -$table->data[8][1] = html_print_input_text( - 'recon_ports', - $recon_ports, - '', - 25, - 0, - true -); -$table->data[8][1] .= ui_print_help_tip( - __('Ports defined like: 80 or 80,443,512 or even 0-1024 (Like Nmap command line format). If dont want to do a sweep using portscan, left it in blank'), - true -); - -// Group. -$table->data[9][0] = ''.__('Group'); -$groups = users_get_groups(false, 'PM', false); -$table->data[9][1] = html_print_select_groups( - false, - 'PM', - false, - 'id_group', - $id_group, - '', - '', - 0, - true -); - -// Incident. -$values = [ - 0 => __('No'), - 1 => __('Yes'), -]; -$table->data[10][0] = ''.__('Incident'); -$table->data[10][1] = html_print_select( - $values, - 'create_incident', - $create_incident, - '', - '', - '', - true -).' '.ui_print_help_tip( - __('Choose if the discovery of a new system creates an incident or not.'), - true -); - -// Snmp_enabled. -$table->data[11][0] = ''.__('SNMP enabled'); -$table->data[11][1] = html_print_checkbox( - 'snmp_enabled', - 1, - $snmp_enabled, - true -); - -// SNMP default community. -$table->data[12][0] = ''.__('SNMP Default community'); -$table->data[12][0] .= ui_print_help_tip( - __('You can specify several values, separated by commas, for example: public,mysecret,1234'), - true -); -$table->data[12][1] = html_print_input_text( - 'snmp_community', - $snmp_community, - '', - 35, - 0, - true -); - -// SNMP version. -$snmp_versions['1'] = 'v. 1'; -$snmp_versions['2'] = 'v. 2'; -$snmp_versions['2c'] = 'v. 2c'; -$snmp_versions['3'] = 'v. 3'; -$table->data[24][0] = ''._('SNMP version'); -$table->data[24][1] = html_print_select( - $snmp_versions, - 'snmp_version', - $snmp_version, - '', - '', - 0, - true -); - -$table->data[25][0] = ''.__('Auth user'); -$table->data[25][1] = html_print_input_text( - 'snmp_auth_user', - $snmp3_auth_user, - '', - 15, - 60, - true, - '', - false, - '', - '' -); -$table->data[26][0] = ''.__('Auth password').ui_print_help_tip(__('The pass length must be eight character minimum.'), true); -$table->data[26][1] = html_print_input_password( - 'snmp_auth_pass', - $snmp3_auth_pass, - '', - 15, - 60, - true, - '', - false, - '' -); -$table->data[26][1] .= html_print_input_hidden_extended( - 'active_snmp_v3', - 0, - 'active_snmp_v3_mmen', - true -); - -$table->data[27][0] = ''.__('Privacy method'); -$table->data[27][1] = html_print_select( - [ - 'DES' => __('DES'), - 'AES' => __('AES'), - ], - 'snmp_privacy_method', - $snmp3_privacy_method, - '', - '', - '', - true, - false, - false, - '', - '' -); -$table->data[28][0] = ''.__('Privacy pass').ui_print_help_tip(__('The pass length must be eight character minimum.'), true); -$table->data[28][1] = html_print_input_password( - 'snmp_privacy_pass', - $snmp3_privacy_pass, - '', - 15, - 60, - true, - '', - false, - '' -); -$table->data[29][0] = ''.__('Auth method'); -$table->data[29][1] = html_print_select( - [ - 'MD5' => __('MD5'), - 'SHA' => __('SHA'), - ], - 'snmp_auth_method', - $snmp3_auth_method, - '', - '', - '', - true, - false, - false, - '', - '' -); -$table->data[30][0] = ''.__('Security level'); -$table->data[30][1] = html_print_select( - [ - 'noAuthNoPriv' => __('Not auth and not privacy method'), - 'authNoPriv' => __('Auth and not privacy method'), - 'authPriv' => __('Auth and privacy method'), - ], - 'snmp_security_level', - $snmp3_security_level, - '', - '', - '', - true, - false, - false, - '', - '' -); - -// Explanation. -$explanation = db_get_value( - 'description', - 'trecon_script', - 'id_recon_script', - $id_recon_script -); - -$table->data[13][0] = ''.__('Explanation').''; -$table->data[13][1] = "'.html_print_textarea('explanation', 4, 60, $explanation, 'style="width: 388px;"', true); - -// A hidden "model row" to clone it from javascript to add fields dynamicaly. -$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, - 255, - true -); -$table->colspan['macro_field'][1] = 3; -$table->rowstyle['macro_field'] = 'display:none'; -$table->data['macro_field'] = $data; - -// If there are $macros, we create the form fields. -if (!empty($macros)) { - $macros = json_decode($macros, true); - - if (isset($macros) === true - && is_array($macros) === true - ) { - foreach ($macros as $k => $m) { - $data = []; - $data[0] = ''.$m['desc'].''; - if (!empty($m['help'])) { - $data[0] .= ui_print_help_tip($m['help'], true); - } - - if ($m['hide']) { - $data[1] = html_print_input_password( - $m['macro'], - $m['value'], - '', - 100, - 255, - true - ); - } else { - $data[1] = html_print_input_text( - $m['macro'], - $m['value'], - '', - 100, - 255, - true - ); - } - - $table->colspan['macro'.$m['macro']][1] = 3; - $table->rowclass['macro'.$m['macro']] = 'macro_field'; - - $table->data['macro'.$m['macro']] = $data; - } - } -} - -// Comments. -$table->data[18][0] = ''.__('Comments'); -$table->data[18][1] = html_print_input_text( - 'description', - $description, - '', - 45, - 0, - true -); - -// OS detection. -$table->data[19][0] = ''.__('OS detection'); -$table->data[19][1] = html_print_checkbox( - 'os_detect', - 1, - $os_detect, - true -); - -// Name resolution. -$table->data[20][0] = ''.__('Name resolution'); -$table->data[20][1] = html_print_checkbox( - 'resolve_names', - 1, - $resolve_names, - true -); - -// Parent detection. -$table->data[21][0] = ''.__('Parent detection'); -$table->data[21][1] = html_print_checkbox( - 'parent_detection', - 1, - $parent_detection, - true -); - -// Parent recursion. -$table->data[22][0] = ''.__('Parent recursion'); -$table->data[22][1] = html_print_input_text( - 'parent_recursion', - $parent_recursion, - '', - 5, - 0, - true -).ui_print_help_tip( - __('Maximum number of parent hosts that will be created if parent detection is enabled.'), - true -); - -// Vlan_enabled. -$table->data[23][0] = ''.__('Vlan enabled'); -$table->data[23][1] = html_print_checkbox( - 'vlan_enabled', - 1, - $vlan_enabled, - true -); - -// NOTE: The 7.0NG Recon Server will not generate random names, since IP -// address collisions could have other consequences. -// Different Form url if it's a create or if it's a update form. -echo '
'; -html_print_table($table); -echo '
'; - -if ($id_rt != -1) { - if ($name_script != 'IPAM Recon') { - html_print_submit_button(__('Update'), 'crt', false, 'class="sub upd"'); - } -} else { - html_print_submit_button(__('Add'), 'crt', false, 'class="sub wand"'); -} - -echo '
'; - -echo '
'; - -ui_require_javascript_file('pandora_modules'); - -?> - - diff --git a/pandora_console/godmode/servers/plugin.php b/pandora_console/godmode/servers/plugin.php index b04643e1c3..57fa1a1e67 100644 --- a/pandora_console/godmode/servers/plugin.php +++ b/pandora_console/godmode/servers/plugin.php @@ -242,7 +242,6 @@ if ($filemanager) { $chunck_url = '&create=1'; } - $homedir_filemanager = isset($config['homedir_filemanager']) ? $config['homedir_filemanager'] : false; filemanager_file_explorer( $real_directory, $directory, @@ -253,7 +252,7 @@ if ($filemanager) { 'index.php?sec=gservers&sec2=godmode/servers/plugin'.$chunck_url.'&plugin_command=[FILE_FULLPATH]&id_plugin='.$id_plugin, true, 0775, - $homedir_filemanager + false ); } @@ -404,7 +403,7 @@ if (($create != '') || ($view != '')) { $table->data['plugin_command'] = $data; $data = []; - $data[0] = __('Plug-in parameters').ui_print_help_icon('plugin_parameters', true); + $data[0] = __('Plug-in parameters'); $data[1] = ''; if ($locked) { $data[1] .= html_print_image('images/lock.png', true, ['class' => 'command_advanced_conf lock']); @@ -550,7 +549,7 @@ if (($create != '') || ($view != '')) { $table->headstyle[0] = 'text-align: center'; html_print_table($table); } else { - echo '
'.''.__('Parameters macros').ui_print_help_icon('macros', true).''; + echo '
'.''.__('Parameters macros').''; html_print_table($table); echo '
'; } @@ -613,7 +612,16 @@ if (($create != '') || ($view != '')) { config_update_value('metaconsole_deploy_plugin_server', 1); } } else { - ui_print_page_header(__('Plug-ins registered on %s', get_product_name()), 'images/gm_servers.png', false, '', true); + ui_print_page_header( + __( + 'Plug-ins registered on %s', + get_product_name() + ), + 'images/gm_servers.png', + false, + '', + true + ); $management_allowed = !is_central_policies_on_node(); if (!$management_allowed) { @@ -954,9 +962,10 @@ if (($create != '') || ($view != '')) { if (defined('METACONSOLE')) { echo ''; } else { - echo '
'; + echo '
'; } + echo ''; echo ''; echo ''; echo ''; @@ -964,6 +973,8 @@ if (($create != '') || ($view != '')) { echo "'; } + echo ''; + $color = 0; foreach ($rows as $row) { @@ -1187,13 +1198,13 @@ ui_require_javascript_file('pandora_modules'); } } else { - alert(''); + alert(""); } } } var macros_click_locked_event = function (event) { - alert(''); + alert(""); } if (locked) { @@ -1202,4 +1213,6 @@ ui_require_javascript_file('pandora_modules'); $('.command_macro').click(macros_click_locked_event); } + + diff --git a/pandora_console/godmode/servers/recon_script.php b/pandora_console/godmode/servers/recon_script.php index b24c2a59e2..a77f465395 100644 --- a/pandora_console/godmode/servers/recon_script.php +++ b/pandora_console/godmode/servers/recon_script.php @@ -1,401 +1,27 @@ $id_reconscript] - ); - - echo htmlentities(io_safe_output($description), ENT_QUOTES, 'UTF-8', true); - return; -} - -// Load global vars -global $config; - -check_login(); - -if (! check_acl($config['id_user'], 0, 'LM')) { - db_pandora_audit( - 'ACL Violation', - 'Trying to access recon script Management' - ); - include 'general/noaccess.php'; - return; -} - -/* - * Disabled at the moment. - if (!check_referer()) { - require ("general/noaccess.php"); - - return; - } +/** + * Deprectated. + * + * @category Deprectated + * @package Pandora FMS + * @subpackage recon script + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2019 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ */ - -$view = get_parameter('view', ''); -$create = get_parameter('create', ''); - -if ($view != '') { - $form_id = $view; - $reconscript = db_get_row('trecon_script', 'id_recon_script', $form_id); - $form_name = $reconscript['name']; - $form_description = $reconscript['description']; - $form_script = $reconscript['script']; - $macros = $reconscript['macros']; -} - -if ($create != '') { - $form_name = ''; - $form_description = ''; - $form_script = ''; - $macros = ''; -} - -// SHOW THE FORM -// ================================================================= -if (($create != '') or ($view != '')) { - if ($create != '') { - ui_print_page_header(__('Recon script creation'), 'images/gm_servers.png', false, 'reconscript_definition', true); - } else { - ui_print_page_header(__('Recon script update'), 'images/gm_servers.png', false, 'reconscript_definition', true); - $id_recon_script = get_parameter('view', ''); - } - - - if ($create == '') { - echo ""; - } else { - echo ""; - } - - $table = new stdClass(); - $table->width = '100%'; - $table->id = 'table-form'; - $table->class = 'databox filters'; - $table->style = []; - $table->style[0] = 'font-weight: bold'; - $table->style[2] = 'font-weight: bold'; - $table->data = []; - - $data = []; - $data[0] = __('Name'); - $data[1] = ''; - $table->data['recon_name'] = $data; - $table->colspan['recon_name'][1] = 3; - - $data = []; - $data[0] = __('Script fullpath'); - $data[1] = ''; - $table->data['recon_fullpath'] = $data; - $table->colspan['recon_fullpath'][1] = 3; - - $data = []; - $data[0] = __('Description'); - $data[1] = ''; - $table->data['recon_description'] = $data; - $table->colspan['recon_description'][1] = 3; - - $macros = json_decode($macros, true); - - // This code is ready to add locked feature as plugins - $locked = false; - - // The next row number is recon_3 - $next_name_number = 3; - $i = 1; - while (1) { - // Always print at least one macro - if ((!isset($macros[$i]) || $macros[$i]['desc'] == '') && $i > 1) { - break; - } - - $macro_desc_name = 'field'.$i.'_desc'; - $macro_desc_value = ''; - $macro_help_name = 'field'.$i.'_help'; - $macro_help_value = ''; - $macro_value_name = 'field'.$i.'_value'; - $macro_value_value = ''; - $macro_name_name = 'field'.$i.'_macro'; - $macro_name = '_field'.$i.'_'; - $macro_hide_value_name = 'field'.$i.'_hide'; - $macro_hide_value_value = 0; - - if (isset($macros[$i]['desc'])) { - $macro_desc_value = $macros[$i]['desc']; - } - - if (isset($macros[$i]['help'])) { - $macro_help_value = $macros[$i]['help']; - } - - if (isset($macros[$i]['value'])) { - $macro_value_value = $macros[$i]['value']; - } - - if (isset($macros[$i]['hide'])) { - $macro_hide_value_value = $macros[$i]['hide']; - } - - $datam = []; - $datam[0] = __('Description')." ($macro_name)"; - $datam[0] .= html_print_input_hidden($macro_name_name, $macro_name, true); - $datam[1] = html_print_input_text_extended($macro_desc_name, $macro_desc_value, 'text-'.$macro_desc_name, '', 30, 255, $locked, '', "class='command_advanced_conf'", true); - if ($locked) { - $datam[1] .= html_print_image('images/lock.png', true, ['class' => 'command_advanced_conf']); - } - - $datam[2] = __('Default value')." ($macro_name)"; - $datam[3] = html_print_input_text_extended($macro_value_name, $macro_value_value, 'text-'.$macro_value_name, '', 30, 255, $locked, '', "class='command_component command_advanced_conf'", true); - if ($locked) { - $datam[3] .= html_print_image('images/lock.png', true, ['class' => 'command_advanced_conf']); - } - - $table->data['recon_'.$next_name_number] = $datam; - - $next_name_number++; - - $table->colspan['recon_'.$next_name_number][1] = 3; - - $datam = []; - $datam[0] = __('Hide value').ui_print_help_tip(__('This field will show up as dots like a password'), true); - $datam[1] = html_print_checkbox_extended($macro_hide_value_name, 1, $macro_hide_value_value, 0, '', ['class' => 'command_advanced_conf'], true, 'checkbox-'.$macro_hide_value_name); - - $table->data['recon_'.$next_name_number] = $datam; - $next_name_number++; - - $table->colspan['recon_'.$next_name_number][1] = 3; - - $datam = []; - $datam[0] = __('Help')." ($macro_name)


"; - $tadisabled = $locked === true ? ' disabled' : ''; - $datam[1] = html_print_textarea($macro_help_name, 6, 100, $macro_help_value, 'class="command_advanced_conf" style="width: 97%;"'.$tadisabled, true); - - if ($locked) { - $datam[1] .= html_print_image('images/lock.png', true, ['class' => 'command_advanced_conf']); - } - - $datam[1] .= '


'; - - $table->data['recon_'.$next_name_number] = $datam; - $next_name_number++; - $i++; - } - - if (!$locked) { - $datam = []; - $datam[0] = ''.__('Add macro').''.html_print_image('images/add.png', true).''; - $datam[0] .= ''; - $datam[0] .= ''; - $delete_macro_style = ''; - if ($i <= 2) { - $delete_macro_style = 'display:none;'; - } - - $datam[2] = ''; - - $table->colspan['recon_action'][0] = 2; - $table->rowstyle['recon_action'] = 'text-align:center'; - $table->colspan['recon_action'][2] = 2; - $table->data['recon_action'] = $datam; - } - - html_print_table($table); - - echo '
'.__('Name').''.__('Type').''.__('Command').'".''.__('Op.').''.'
'; - echo '
'; - - if ($create != '') { - echo ""; - } else { - echo ""; - } - - echo '
'; -} else { - ui_print_page_header(__('Recon scripts registered on %s', get_product_name()), 'images/gm_servers.png', false, '', true); - - // Update reconscript - if (isset($_GET['update_reconscript'])) { - // if modified any parameter - $id_recon_script = get_parameter('update_reconscript', 0); - $reconscript_name = get_parameter('form_name', ''); - $reconscript_description = get_parameter('form_description', ''); - $reconscript_script = get_parameter('form_script', ''); - - // Get macros - $i = 1; - $macros = []; - while (1) { - $macro = (string) get_parameter('field'.$i.'_macro'); - if ($macro == '') { - break; - } - - $desc = (string) get_parameter('field'.$i.'_desc'); - $help = (string) get_parameter('field'.$i.'_help'); - $value = (string) get_parameter('field'.$i.'_value'); - $hide = get_parameter('field'.$i.'_hide'); - - $macros[$i]['macro'] = $macro; - $macros[$i]['desc'] = $desc; - $macros[$i]['help'] = $help; - $macros[$i]['value'] = $value; - $macros[$i]['hide'] = $hide; - $i++; - } - - $macros = io_json_mb_encode($macros); - - $sql_update = "UPDATE trecon_script SET - name = '$reconscript_name', - description = '$reconscript_description', - script = '$reconscript_script', - macros = '$macros' - WHERE id_recon_script = $id_recon_script"; - $result = false; - if ($reconscript_name != '' && $reconscript_script != '') { - $result = db_process_sql($sql_update); - } - - if (! $result) { - ui_print_error_message(__('Problem updating')); - } else { - ui_print_success_message(__('Updated successfully')); - } - } - - // Create reconscript - if (isset($_GET['create_reconscript'])) { - $reconscript_name = get_parameter('form_name', ''); - $reconscript_description = get_parameter('form_description', ''); - $reconscript_script = get_parameter('form_script', ''); - - // Get macros - $i = 1; - $macros = []; - while (1) { - $macro = (string) get_parameter('field'.$i.'_macro'); - if ($macro == '') { - break; - } - - $desc = (string) get_parameter('field'.$i.'_desc'); - $help = (string) get_parameter('field'.$i.'_help'); - $value = (string) get_parameter('field'.$i.'_value'); - $hide = get_parameter('field'.$i.'_hide'); - - $macros[$i]['macro'] = $macro; - $macros[$i]['desc'] = $desc; - $macros[$i]['help'] = $help; - $macros[$i]['value'] = $value; - $macros[$i]['hide'] = $hide; - $i++; - } - - $macros = io_json_mb_encode($macros); - - $values = [ - 'name' => $reconscript_name, - 'description' => $reconscript_description, - 'script' => $reconscript_script, - 'macros' => $macros, - ]; - $result = false; - if ($values['name'] != '' && $values['script'] != '') { - $result = db_process_sql_insert('trecon_script', $values); - } - - if (! $result) { - ui_print_error_message(__('Problem creating')); - } else { - ui_print_success_message(__('Created successfully')); - } - } - - if (isset($_GET['kill_reconscript'])) { - // if delete alert - $reconscript_id = get_parameter('kill_reconscript', 0); - - $result = db_process_sql_delete( - 'trecon_script', - ['id_recon_script' => $reconscript_id] - ); - - if (! $result) { - ui_print_error_message(__('Problem deleting reconscript')); - } else { - ui_print_success_message(__('reconscript deleted successfully')); - } - - if ($reconscript_id != 0) { - $result = db_process_sql_delete( - 'trecon_task', - ['id_recon_script' => $reconscript_id] - ); - } - } - - // If not edition or insert, then list available reconscripts - $rows = db_get_all_rows_in_table('trecon_script'); - - if ($rows !== false) { - echo ''; - echo ''; - echo ''; - echo ''; - $color = 0; - foreach ($rows as $row) { - if ($color == 1) { - $tdcolor = 'datos'; - $color = 0; - } else { - $tdcolor = 'datos2'; - $color = 1; - } - - echo ''; - echo "'; - echo "'; - } - - echo '
'.__('Name').''.__('Description').''.__('Delete').'
"; - echo ""; - echo $row['name']; - echo '"; - $desc = io_safe_output($row['description']); - $desc = str_replace("\n", '
', $desc); - echo $desc.'

'; - echo ''.__('Command').': '.$row['script'].''; - echo "
"; - echo "".html_print_image('images/cross.png', true, ['border' => '0']).''; - echo '
'; - } else { - ui_print_info_message(['no_close' => true, 'message' => __('There are no recon scripts in the system') ]); - } - - echo ''; - echo '
'; - echo "
"; - echo ""; - echo '
'; -} - -ui_require_javascript_file('pandora_modules'); diff --git a/pandora_console/godmode/servers/servers.build_table.php b/pandora_console/godmode/servers/servers.build_table.php index 2bb4f6ab00..1b5486b570 100644 --- a/pandora_console/godmode/servers/servers.build_table.php +++ b/pandora_console/godmode/servers/servers.build_table.php @@ -40,7 +40,9 @@ if ($servers === false) { $table = new StdClass(); $table->width = '100%'; -$table->class = 'databox data'; +$table->class = 'info_table'; +$table->cellpadding = 0; +$table->cellspacing = 0; $table->size = []; $table->style = []; @@ -80,7 +82,11 @@ $names_servers = []; foreach ($servers as $server) { $data = []; - $table->cellclass[][3] = 'progress_bar'; + // $table->cellclass[][3] = 'progress_bar'; + $table->cellclass[] = [ + 3 => 'progress_bar', + 8 => 'action_buttons', + ]; $data[0] = ''.strip_tags($server['name']).''; // Status @@ -155,7 +161,7 @@ foreach ($servers as $server) { 'style' => 'width:21px;height:21px;', ] ); - $data[8] .= '  '; + $data[8] .= ''; } if ($server['type'] == 'data') { @@ -165,7 +171,7 @@ foreach ($servers as $server) { true, ['title' => __('Reset module status and fired alert counts')] ); - $data[8] .= '  '; + $data[8] .= ''; } else if ($server['type'] == 'enterprise snmp') { $data[8] .= ''; $data[8] .= html_print_image( @@ -173,7 +179,7 @@ foreach ($servers as $server) { true, ['title' => __('Claim back SNMP modules')] ); - $data[8] .= '  '; + $data[8] .= ''; } $data[8] .= ''; @@ -195,7 +201,7 @@ foreach ($servers as $server) { $names_servers[$safe_server_name] = false; } - $data[8] .= '  '; + $data[8] .= ''; $data[8] .= html_print_image( 'images/cross.png', true, @@ -225,7 +231,12 @@ if ($tiny) { } if ($tiny) { - ui_toggle(html_print_table($table, true), __('Tactical server information'), false, $hidden_toggle); + ui_toggle( + html_print_table($table, true), + __('Tactical server information'), + false, + $hidden_toggle + ); } else { html_print_table($table); } diff --git a/pandora_console/godmode/setup/file_manager.php b/pandora_console/godmode/setup/file_manager.php index 27f3e232c8..6d5e7679b7 100644 --- a/pandora_console/godmode/setup/file_manager.php +++ b/pandora_console/godmode/setup/file_manager.php @@ -66,8 +66,6 @@ $real_directory = realpath($config['homedir'].'/'.$directory); echo '

'.__('Index of %s', $directory).'

'; -$homedir_filemanager = isset($config['homedir_filemanager']) ? $config['homedir_filemanager'] : false; - filemanager_file_explorer( $real_directory, $directory, @@ -78,5 +76,5 @@ filemanager_file_explorer( '', false, '', - $homedir_filemanager + false ); diff --git a/pandora_console/godmode/setup/gis.php b/pandora_console/godmode/setup/gis.php index 946d0526ea..526abc0b0a 100755 --- a/pandora_console/godmode/setup/gis.php +++ b/pandora_console/godmode/setup/gis.php @@ -28,8 +28,14 @@ require_once 'include/functions_gis.php'; ui_require_javascript_file('openlayers.pandora'); -// Header -ui_print_page_header(__('Map conections GIS'), '', false, 'setup_gis_index', true); +// Header. +ui_print_page_header( + __('Map conections GIS'), + '', + false, + '', + true +); $action = get_parameter('action'); @@ -63,14 +69,15 @@ switch ($action) { break; } +$table->class = 'info_table'; $table->width = '98%'; $table->head[0] = __('Map connection name'); $table->head[1] = __('Group'); $table->head[3] = __('Delete'); -$table->align[1] = 'center'; -$table->align[2] = 'center'; -$table->align[3] = 'center'; +$table->align[1] = 'left'; +$table->align[2] = 'left'; +$table->align[3] = 'left'; $mapsConnections = db_get_all_rows_in_table('tgis_map_connection', 'conection_name'); @@ -84,6 +91,7 @@ if ($mapsConnections !== false) { '
'.html_print_image('images/cross.png', true).'', ]; + $table->cellclass[][2] = 'action_buttons'; } } diff --git a/pandora_console/godmode/setup/gis_step_2.php b/pandora_console/godmode/setup/gis_step_2.php index 5203bdef23..133b4fdeaa 100644 --- a/pandora_console/godmode/setup/gis_step_2.php +++ b/pandora_console/godmode/setup/gis_step_2.php @@ -13,7 +13,7 @@ * GNU General Public License for more details. */ -// Load global vars +// Load global vars. global $config; check_login(); @@ -35,8 +35,14 @@ echo ''.''.''.htmlentities(__('Tile Server URL'), ENT_QUOTES, 'UTF-8').':'.''.html_print_input_text('url', $mapConnectionDataUrl, '', 45, 90, true).''.''.''; -// Google Maps Connection +// Google Maps Connection. $gmaps_types['G_PHYSICAL_MAP'] = __('Google Physical'); $gmaps_types['G_HYBRID_MAP'] = __('Google Hybrid'); $gmaps_types['G_SATELITE_MAP'] = __('Google Satelite'); // TODO: Use label tags for the forms. $optionsConnectionGmapTable = ''.''.''.''.''.''.''.''.''.''.''.'
'.__('Google Map Type').':'.trim(html_print_select($gmaps_types, 'gmap_type', $gmap_type, '', '', 0, true)).'
'.__('Google Maps Key').':
'.html_print_input_text('gmap_key', $gmap_key, '', 90, 128, true).'
'; -// Image Map Connection +// Image Map Connection. $optionsConnectionImageTable = ''.''.''.''.''.''.''.''.''.''.''.''.''.''.''.''.''.''.''.''.''.''.''.''.''.''.''.''.''.'
'.__('Image URL').':'.html_print_input_text('url', $mapConnectionDataUrl, '', 45, 90, true).'
'.__('Corners of the area of the image').':
'.__('Left').':'.html_print_input_text('bb_left', $bb_left, '', 25, 25, true).''.__('Bottom').':'.html_print_input_text('bb_bottom', $bb_bottom, '', 25, 25, true).'
'.__('Right').':'.html_print_input_text('bb_right', $bb_right, '', 25, 25, true).''.__('Top').':'.html_print_input_text('bb_top', $bb_top, '', 25, 25, true).'
'.__('Image Size').':
'.__('Width').':'.html_print_input_text('image_width', $image_width, '', 25, 25, true).''.__('Height').':'.html_print_input_text('image_height', $image_height, '', 25, 25, true).'
'; -// WMS Server Connection +// WMS Server Connection. $optionsConnectionWMSTable = ''.''.''.''.''.''.''.''.''.'
'.__('WMS Server URL').''.''.html_print_input_text('url', $mapConnectionDataUrl, '', 90, 255, true).'
'.__('Layers').ui_print_help_tip(__('Enter a single element or a comma separated list'), true).''.html_print_input_text('layers', $layers, '', 90, 255, true).'
'; if ($mapConnectionData != null) { @@ -274,6 +297,10 @@ if ($mapConnectionData != null) { case 'WMS': $optionsConnectionTypeTable = $optionsConnectionWMSTable; break; + + default: + // Default. + break; } } diff --git a/pandora_console/godmode/setup/license.php b/pandora_console/godmode/setup/license.php index 413b1d7fe1..f03d32ef0a 100644 --- a/pandora_console/godmode/setup/license.php +++ b/pandora_console/godmode/setup/license.php @@ -1,15 +1,32 @@ $value) { - db_process_sql_update( - 'tupdate_settings', - [db_escape_key_identifier('value') => $value], - [db_escape_key_identifier('key') => $key] - ); - } - - ui_print_success_message(__('License updated')); + ui_require_javascript_file_enterprise('load_enterprise'); + enterprise_include_once('include/functions_license.php'); +} + +if ($update_settings) { + if (!is_metaconsole()) { + // Node. + foreach ($_POST['keys'] as $key => $value) { + db_process_sql_update( + 'tupdate_settings', + [db_escape_key_identifier('value') => $value], + [db_escape_key_identifier('key') => $key] + ); + } + + ui_print_success_message(__('License updated')); + } } -ui_require_javascript_file_enterprise('load_enterprise'); -enterprise_include_once('include/functions_license.php'); $license = enterprise_hook('license_get_info'); $rows = db_get_all_rows_in_table('tupdate_settings'); @@ -55,11 +88,20 @@ if (enterprise_installed()) { echo ''; echo ''; +// Retrieve UM url configured (or default). +$url = get_um_url(); $table = new stdClass(); $table->width = '100%'; $table->class = 'databox filters'; +if (is_metaconsole()) { + $table->head[0] = __('Licence'); + $table->head_colspan[0] = 3; + $table->headstyle[0] = 'text-align: center'; + $table->style[0] = 'font-weight: bold;'; +} + $table->data = []; $table->data[0][0] = ''.__('Customer key').''; @@ -98,34 +140,45 @@ if (enterprise_installed()) { html_print_input_hidden('update_settings', 1); html_print_submit_button(__('Validate'), 'update_button', false, 'class="sub upd"'); echo '  '; - html_print_button(__('Request new license'), '', false, 'generate_request_code()', 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only sub next"'); + html_print_button(__('Request new license'), '', false, 'generate_request_code()', 'class="sub next"'); echo '
'; } -echo ''; -echo ''; +if (is_metaconsole()) { + ui_require_css_file('pandora_enterprise', '../../'.ENTERPRISE_DIR.'/include/styles/'); + ui_require_css_file('register', '../../include/styles/'); +} else { + ui_require_css_file('pandora'); + ui_require_css_file('pandora_enterprise', ENTERPRISE_DIR.'/include/styles/'); + ui_require_css_file('register'); +} + +if (enterprise_hook('print_activate_licence_dialog') == ENTERPRISE_NOT_HOOK) { + echo ''; + echo ''; +} diff --git a/pandora_console/godmode/setup/links.php b/pandora_console/godmode/setup/links.php index f5016e666e..c15052412b 100644 --- a/pandora_console/godmode/setup/links.php +++ b/pandora_console/godmode/setup/links.php @@ -137,9 +137,11 @@ if ((isset($_GET['form_add'])) or (isset($_GET['form_edit']))) { if (empty($rows)) { ui_print_info_message(['no_close' => true, 'message' => __("There isn't links") ]); } else { - echo ""; + echo "
"; + echo ''; echo "'; echo "'; + echo ''; $color = 1; foreach ($rows as $row) { @@ -152,7 +154,7 @@ if ((isset($_GET['form_add'])) or (isset($_GET['form_edit']))) { } echo "'; - echo ''; + echo ''; } echo '
".__('Link name').'".__('Delete').'
".$row['name'].''.html_print_image('images/cross.png', true).'
'.html_print_image('images/cross.png', true).'
'; diff --git a/pandora_console/godmode/setup/news.php b/pandora_console/godmode/setup/news.php index 7b663bad53..61491496f5 100644 --- a/pandora_console/godmode/setup/news.php +++ b/pandora_console/godmode/setup/news.php @@ -231,14 +231,15 @@ if ((isset($_GET['form_add'])) || (isset($_GET['form_edit']))) { ui_print_info_message(['no_close' => true, 'message' => __('There are no defined news') ]); } else { // Main list view for Links editor - echo ""; + echo "
"; + echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; - + echo ''; $color = 1; @@ -276,7 +277,7 @@ if ((isset($_GET['form_add'])) || (isset($_GET['form_edit']))) { echo "'; } - echo ''; + echo ''; } echo '
'.__('Subject').''.__('Type').''.__('Author').''.__('Timestamp').''.__('Expiration').''.__('Delete').'
".__('No').''.html_print_image('images/cross.png', true, ['border' => '0']).'
'.html_print_image('images/cross.png', true, ['border' => '0']).'
'; @@ -330,7 +331,7 @@ ui_require_javascript_file('tiny_mce', 'include/javascript/tiny_mce/'); theme : "advanced", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", - theme_advanced_buttons1 : "bold,italic, |, image, link, |, cut, copy, paste, |, undo, redo, |, forecolor, |, fontsizeselect, |, justifyleft, justifycenter, justifyright", + theme_advanced_buttons1 : "bold,italic, |, image, link, |, cut, copy, paste, |, undo, redo, |, forecolor, |, fontsizeselect, |, justifyleft, justifycenter, justifyright, | ,code", theme_advanced_buttons2 : "", theme_advanced_buttons3 : "", convert_urls : false, diff --git a/pandora_console/godmode/setup/os.list.php b/pandora_console/godmode/setup/os.list.php index f00b8cb00d..07365edc6c 100644 --- a/pandora_console/godmode/setup/os.list.php +++ b/pandora_console/godmode/setup/os.list.php @@ -25,7 +25,7 @@ if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user $table = new stdClass(); $table->width = '100%'; -$table->class = 'databox data'; +$table->class = 'info_table'; $table->head[0] = ''; $table->head[1] = __('ID'); @@ -37,7 +37,19 @@ $table->align[4] = 'center'; $table->size[0] = '20px'; $table->size[4] = '20px'; -$osList = db_get_all_rows_in_table('tconfig_os'); +// Prepare pagination. +$offset = (int) get_parameter('offset'); +$limit = $config['block_size']; +$count_osList = db_get_value('count(*)', 'tconfig_os'); + +$osList = db_get_all_rows_filter( + 'tconfig_os', + [ + 'offset' => $offset, + 'limit' => $limit, + ] +); + if ($osList === false) { $osList = []; } @@ -54,6 +66,8 @@ foreach ($osList as $os) { } $data[] = ui_print_truncate_text(io_safe_output($os['description']), 'description', true, true); + + $table->cellclass[][4] = 'action_buttons'; if ($os['id_os'] > 16) { if (is_metaconsole()) { $data[] = ''.html_print_image('images/cross.png', true).''; @@ -69,7 +83,9 @@ foreach ($osList as $os) { } if (isset($data)) { + ui_pagination($count_osList, false, $offset); html_print_table($table); + ui_pagination($count_osList, false, $offset, 0, false, 'offset', true, 'pagination-bottom'); } else { ui_print_info_message(['no_close' => true, 'message' => __('There are no defined operating systems') ]); } diff --git a/pandora_console/godmode/setup/performance.php b/pandora_console/godmode/setup/performance.php index 666dd0b21c..af414d6ab3 100644 --- a/pandora_console/godmode/setup/performance.php +++ b/pandora_console/godmode/setup/performance.php @@ -200,8 +200,8 @@ if ($config['history_db_enabled'] == 1) { ); $time_pandora_db_history = false; - if ($history_connect !== false) { - if ($config['history_db_connection'] !== false) { + if ($history_connect) { + if ($config['history_db_connection']) { $time_pandora_db_history = mysql_db_process_sql( $sql, 'insert_id', @@ -247,8 +247,7 @@ $table->style[0] = 'font-weight: bold'; $table->size[0] = '70%'; $table->size[1] = '30%'; -enterprise_hook('enterprise_warnings_history_days'); - +// enterprise_hook('enterprise_warnings_history_days'); $table->data[1][0] = __('Max. days before delete events'); $table->data[1][0] .= ui_print_help_tip( __('If the compaction or purge of the data is more frequent than the events deletion, anomalies in module graphs could appear'), @@ -405,16 +404,16 @@ if ($config['history_db_enabled'] == 1) { ); } - $history_connect = @mysql_db_process_sql( - 'SELECT 1 FROM tconfig', - 'affected_rows', - $config['history_db_connection'], - false - ); - $config_history = false; - if ($history_connect !== false) { - if ($config['history_db_connection'] != false) { + if ($config['history_db_connection']) { + $history_connect = @mysql_db_process_sql( + 'SELECT 1 FROM tconfig', + 'affected_rows', + $config['history_db_connection'], + false + ); + + if ($history_connect !== false) { $config_history_array = mysql_db_process_sql( 'SELECT * FROM tconfig', 'affected_rows', @@ -427,11 +426,11 @@ if ($config['history_db_enabled'] == 1) { $config_history[$value['token']] = $value['value']; } } + } else { + echo ui_print_error_message( + __('The tconfig table does not exist in the historical database') + ); } - } else { - echo ui_print_error_message( - __('The tconfig table does not exist in the historical database') - ); } if ($config_history === false) { @@ -536,6 +535,19 @@ $table->data[] = [ ), ]; + +$table->data[] = [ + __('Max. days before delete old network matrix data'), + html_print_input_text( + 'delete_old_network_matrix', + $config['delete_old_network_matrix'], + '', + 5, + 5, + true + ), +]; + $table_other = new stdClass(); $table_other->width = '100%'; $table_other->class = 'databox filters'; @@ -615,7 +627,7 @@ $table_other->data[6][1] = html_print_input_text( true ); -$table_other->data[7][0] = __('Use agent access graph').ui_print_help_icon('agent_access', true); +$table_other->data[7][0] = __('Use agent access graph'); $table_other->data[7][1] = html_print_checkbox_switch('agentaccess', 1, $config['agentaccess'], true); $table_other->data[8][0] = __('Max. recommended number of files in attachment directory'); @@ -694,24 +706,24 @@ $table_other->data[13][1] = html_print_input_text( echo '
'; echo '
'; - echo ''.__('Database maintenance status').''; + echo ''.__('Database maintenance status').' '.ui_print_help_icon('database_maintenance_status_tab', true).''; html_print_table($table_status); echo '
'; echo '
'; - echo ''.__('Database maintenance options').''; + echo ''.__('Database maintenance options').' '.ui_print_help_icon('database_maintenance_options_tab', true).''; html_print_table($table); echo '
'; if ($config['history_db_enabled'] == 1) { echo '
'; - echo ''.__('Historical database maintenance options').''; + echo ''.__('Historical database maintenance options').' '.ui_print_help_icon('historical_database_maintenance_options_tab', true).''; html_print_table($table_historical); echo '
'; } echo '
'; - echo ''.__('Others').''; + echo ''.__('Others').' '.ui_print_help_icon('others_database_maintenance_options_tab', true).''; html_print_table($table_other); echo '
'; diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index 6ee8577367..f5bfc8c635 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -135,9 +135,9 @@ if (enterprise_installed()) { switch ($section) { case 'general': - default: $buttons['general']['active'] = true; $subpage = ' » '.__('General'); + $help_header = 'setup_general_tab'; break; case 'auth': @@ -148,7 +148,7 @@ switch ($section) { case 'perf': $buttons['perf']['active'] = true; $subpage = ' » '.__('Performance'); - $help_header = 'performance'; + $help_header = ''; break; case 'vis': @@ -164,16 +164,34 @@ switch ($section) { case 'ehorus': $buttons['ehorus']['active'] = true; $subpage = ' » '.__('eHorus'); + $help_header = 'setup_ehorus_tab'; break; case 'notifications': $buttons['notifications']['active'] = true; $subpage = ' » '.__('Notifications'); break; + + case 'enterprise': + $buttons['enterprise']['active'] = true; + $subpage = ' » '.__('Enterprise'); + $help_header = 'setup_enterprise_tab'; + break; + + default: + // Default. + break; } // Header. -ui_print_page_header(__('Configuration').$subpage, '', false, $help_header, true, $buttons); +ui_print_page_header( + __('Configuration').$subpage, + '', + false, + $help_header, + true, + $buttons +); if (isset($config['error_config_update_config'])) { if ($config['error_config_update_config']['correct'] == false) { diff --git a/pandora_console/godmode/setup/setup_ehorus.php b/pandora_console/godmode/setup/setup_ehorus.php index fc2ebd3d3a..89d4ff35e8 100644 --- a/pandora_console/godmode/setup/setup_ehorus.php +++ b/pandora_console/godmode/setup/setup_ehorus.php @@ -66,6 +66,12 @@ $table_remote->class = 'databox filters'; $table_remote->size['name'] = '30%'; $table_remote->style['name'] = 'font-weight: bold'; +// Enable eHorus user configuration. +$row = []; +$row['name'] = ('eHorus configuration at user level'); +$row['control'] = html_print_checkbox_switch('ehorus_user_level_conf', 1, $config['ehorus_user_level_conf'], true); +$table_remote->data['ehorus_user_level_conf'] = $row; + // User. $row = []; $row['name'] = __('User'); @@ -139,58 +145,98 @@ if ($config['ehorus_enabled'] && !$custom_field_exists) { ui_print_error_message($error_message); } +echo ""; // Form enable. -echo ''; +echo '
'; html_print_input_hidden('update_config', 1); html_print_table($table_enable); -echo ''; +echo '
'; // Form remote. -if ($config['ehorus_enabled']) { - echo '
'; + echo '
'; echo '
'; echo ''.__('eHorus API').''; html_print_input_hidden('update_config', 1); html_print_table($table_remote); - echo '
'; + + echo '
'; + echo '
'; + echo '
'; html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"'); echo '
'; - echo ''; echo '
'; -} ?> diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index 370df5d808..8079aee1e8 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -82,7 +82,7 @@ $table->data[2][1] = html_print_input_text('phantomjs_bin', io_safe_output($conf $table->data[6][0] = __('Auto login (hash) password'); $table->data[6][1] = html_print_input_password('loginhash_pwd', io_output_password($config['loginhash_pwd']), '', 15, 15, true); -$table->data[9][0] = __('Time source').ui_print_help_icon('timesource', true); +$table->data[9][0] = __('Time source'); $sources['system'] = __('System'); $sources['sql'] = __('Database'); $table->data[9][1] = html_print_select($sources, 'timesource', $config['timesource'], '', '', '', true); @@ -107,7 +107,7 @@ $table->data[13][1] = html_print_input_text('cert_path', io_safe_output($config[ $table->data[14][0] = __('Attachment store').ui_print_help_tip(__('Directory where temporary data is stored.'), true); $table->data[14][1] = html_print_input_text('attachment_store', io_safe_output($config['attachment_store']), '', 50, 255, true); -$table->data[15][0] = __('IP list with API access').ui_print_help_icon('ip_api_list', true); +$table->data[15][0] = __('IP list with API access'); if (isset($_POST['list_ACL_IPs_for_API'])) { $list_ACL_IPs_for_API = get_parameter_post('list_ACL_IPs_for_API'); } else { @@ -131,6 +131,14 @@ if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { $table->data[19][1] = html_print_checkbox_switch_extended('activate_netflow', 1, $config['activate_netflow'], $rbt_disabled, '', '', true); +$table->data[21][0] = __('Enable Network Traffic Analyzer'); +$table->data[21][1] = html_print_switch( + [ + 'name' => 'activate_nta', + 'value' => $config['activate_nta'], + ] +); + $zone_name = [ 'Africa' => __('Africa'), 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 a1ffc9008a..bcaff54d95 100755 --- a/pandora_console/godmode/setup/setup_visuals.php +++ b/pandora_console/godmode/setup/setup_visuals.php @@ -70,10 +70,6 @@ $values[SECONDS_5MINUTES] = human_time_description_raw(SECONDS_5MINUTES); $values[SECONDS_10MINUTES] = human_time_description_raw(SECONDS_10MINUTES); $values[SECONDS_30MINUTES] = human_time_description_raw(SECONDS_30MINUTES); -$table_behaviour->data[$row][0] = __('Default interval for refresh on Visual Console').ui_print_help_tip(__('This interval will affect to Visual Console pages'), true); -$table_behaviour->data[$row][1] = html_print_select($values, 'vc_refr', $config['vc_refr'], '', 'N/A', 0, true, false, false); -$row++; - $table_behaviour->data[$row][0] = __('Paginated module view'); $table_behaviour->data[$row][1] = html_print_checkbox_switch( 'paginate_module', @@ -121,7 +117,7 @@ if (enterprise_installed()) { } echo '
'; -echo ''.__('Behaviour configuration').''; +echo ''.__('Behaviour configuration').' '.ui_print_help_icon('behavoir_conf_tab', true).''; html_print_table($table_behaviour); echo '
'; // ---------------------------------------------------------------------- @@ -243,7 +239,7 @@ function logo_custom_enterprise($name, $logo) false, true, '', - $open, + false, 'width:240px' ); return $select; @@ -259,7 +255,7 @@ function logo_custom_enterprise($name, $logo) false, true, '', - $open, + true, 'width:240px' ); return $select; @@ -267,12 +263,12 @@ function logo_custom_enterprise($name, $logo) } -$table_styles->data[$row][0] = __('Custom logo (menu)').ui_print_help_icon('custom_logo', true); +$table_styles->data[$row][0] = __('Custom logo (menu)'); $table_styles->data[$row][1] = logo_custom_enterprise('custom_logo', $config['custom_logo']); $table_styles->data[$row][1] .= ' '.html_print_button(__('View'), 'custom_logo_preview', $open, '', 'class="sub camera logo_preview"', true, false, $open, 'visualmodal'); $row++; -$table_styles->data[$row][0] = __('Custom logo collapsed (menu)').ui_print_help_icon('custom_logo_collapsed', true); +$table_styles->data[$row][0] = __('Custom logo collapsed (menu)'); $table_styles->data[$row][1] = logo_custom_enterprise('custom_logo_collapsed', $config['custom_logo_collapsed']); $table_styles->data[$row][1] .= ' '.html_print_button(__('View'), 'custom_logo_collapsed_preview', $open, '', 'class="sub camera logo_preview"', true, false, $open, 'visualmodal'); $row++; @@ -316,7 +312,7 @@ if (enterprise_installed()) { $table_styles->data[$row][1] .= ' '.html_print_button(__('View'), 'custom_logo_white_bg_preview', $open, '', 'class="sub camera logo_preview"', true, false, $open, 'visualmodal'); $row++; -$table_styles->data[$row][0] = __('Custom logo (login)').ui_print_help_icon('custom_logo', true); +$table_styles->data[$row][0] = __('Custom logo (login)'); if (enterprise_installed()) { $table_styles->data[$row][1] = html_print_select( @@ -462,6 +458,20 @@ if (enterprise_installed()) { $row++; } +// Title Header +if (enterprise_installed()) { + $table_styles->data[$row][0] = __('Title (header)'); + $table_styles->data[$row][1] = html_print_input_text('custom_title_header', $config['custom_title_header'], '', 50, 40, true); + $row++; +} + +// Subtitle Header +if (enterprise_installed()) { + $table_styles->data[$row][0] = __('Subtitle (header)'); + $table_styles->data[$row][1] = html_print_input_text('custom_subtitle_header', $config['custom_subtitle_header'], '', 50, 40, true); + $row++; +} + // login title1 if (enterprise_installed()) { $table_styles->data[$row][0] = __('Title 1 (login)'); @@ -555,7 +565,7 @@ $row++; echo '
'; - echo ''.__('Style configuration').''; + echo ''.__('Style configuration').' '.ui_print_help_icon('style_conf_tab', true).''; html_print_table($table_styles); echo '
'; // ---------------------------------------------------------------------- @@ -598,7 +608,7 @@ $row++; $row++; echo '
'; - echo ''.__('GIS configuration').''; + echo ''.__('GIS configuration').' '.ui_print_help_icon('gis_conf_tab', true).''; html_print_table($table_gis); echo '
'; // ---------------------------------------------------------------------- @@ -692,7 +702,7 @@ $row++; $row++; echo '
'; - echo ''.__('Font and Text configuration').''; + echo ''.__('Font and Text configuration').' '.ui_print_help_icon('front_and_text_conf_tab', true).''; html_print_table($table_font); echo '
'; // ---------------------------------------------------------------------- @@ -880,7 +890,7 @@ $row++; */ echo '
'; - echo ''.__('Charts configuration').''; + echo ''.__('Charts configuration').' '.ui_print_help_icon('charts_conf_tab', true).''; html_print_table($table_chars); echo '
'; // ---------------------------------------------------------------------- @@ -894,6 +904,50 @@ $row++; $table_vc->size[0] = '50%'; $table_vc->data = []; + // Remove when the new view reaches rock solid stability. + $table_vc->data[$row][0] = __('Legacy Visual Console View'); + $table_vc->data[$row][0] .= ui_print_help_tip( + __('To use the old view when using the Visual Console visor'), + true + ); + $table_vc->data[$row][1] = html_print_checkbox_switch( + 'legacy_vc', + 1, + (bool) $config['legacy_vc'], + true + ); + $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++; + $vc_favourite_view_array[0] = __('Classic view'); $vc_favourite_view_array[1] = __('View of favorites'); $table_vc->data[$row][0] = __('Type of view of visual consoles').ui_print_help_tip(__('Allows you to directly display the list of favorite visual consoles'), true); @@ -904,16 +958,12 @@ $row++; $table_vc->data[$row][1] = ""; $row++; - if (empty($config['vc_line_thickness'])) { - $config['vc_line_thickness'] = 2; - } - $table_vc->data[$row][0] = __('Default line thickness for the Visual Console').ui_print_help_tip(__('This interval will affect to the lines between elements on the Visual Console'), true); - $table_vc->data[$row][1] = html_print_input_text('vc_line_thickness', $config['vc_line_thickness'], '', 5, 5, true); + $table_vc->data[$row][1] = html_print_input_text('vc_line_thickness', (int) $config['vc_line_thickness'], '', 5, 5, true); echo '
'; - echo ''.__('Visual consoles configuration').''; + echo ''.__('Visual consoles configuration').' '.ui_print_help_icon('visual_consoles_conf_tab', true).''; html_print_table($table_vc); echo '
'; @@ -931,7 +981,7 @@ $row++; $table_ser->data['number'][1] = ""; echo '
'; - echo ''.__('Services configuration').''; + echo ''.__('Services configuration').' '.ui_print_help_icon('services_conf_tab', true).''; html_print_table($table_ser); echo '
'; @@ -1110,7 +1160,7 @@ $row++; ); $row++; - $table_other->data[$row][0] = __('Date format string').ui_print_help_icon('date_format', true); + $table_other->data[$row][0] = __('Date format string'); $table_other->data[$row][1] = ''.__('Example').' '.date($config['date_format']); $table_other->data[$row][1] .= html_print_input_text('date_format', $config['date_format'], '', 30, 100, true); $row++; @@ -1123,7 +1173,7 @@ $row++; $comparation = false; } - $table_other->data[$row][0] = __('Timestamp or time comparation').ui_print_help_icon('time_stamp-comparation', true); + $table_other->data[$row][0] = __('Timestamp or time comparation'); $table_other->data[$row][1] = __('Comparation in rollover').' '; $table_other->data[$row][1] .= html_print_radio_button('prominent_time', 'comparation', '', $comparation, true); $table_other->data[$row][1] .= '
'.__('Timestamp in rollover').' '; @@ -1229,7 +1279,7 @@ $row++; echo '
'; - echo ''.__('Other configuration').''; + echo ''.__('Other configuration').' '.ui_print_help_icon('other_conf_tab', true).''; html_print_table($table_other); echo '
'; @@ -1370,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 677a283854..a2a1b8b811 100755 --- a/pandora_console/godmode/snmpconsole/snmp_alert.php +++ b/pandora_console/godmode/snmpconsole/snmp_alert.php @@ -76,7 +76,7 @@ if ($update_alert || $modify_alert) { __('SNMP Console').' » '.__('Update alert'), 'images/op_snmp.png', false, - 'snmp_alert', + 'snmp_alert_update_tab', false ); } else if ($create_alert || $save_alert) { @@ -84,7 +84,7 @@ if ($update_alert || $modify_alert) { __('SNMP Console').' » '.__('Create alert'), 'images/op_snmp.png', false, - 'snmp_alert', + 'snmp_alert_overview_tab', false ); } else { @@ -92,7 +92,7 @@ if ($update_alert || $modify_alert) { __('SNMP Console').' » '.__('Alert overview'), 'images/op_snmp.png', false, - 'snmp_alert', + 'snmp_alert_overview_tab', false ); } @@ -757,7 +757,6 @@ if ($create_alert || $update_alert) { // Custom echo ''.__('Custom Value/OID'); - echo ui_print_help_icon('snmp_alert_custom', true); echo ''; html_print_textarea('custom_value', 2, 2, $custom_value, 'style="width:400px;"'); @@ -804,7 +803,7 @@ if ($create_alert || $update_alert) { echo ''; // Variable bindings/Data #1 - echo ''.''.__('Variable bindings/Data').ui_print_help_icon('field_match_snmp', true).''.''; + echo ''.''.__('Variable bindings/Data').''; echo '#'; html_print_input_text('order_1', $order_1, '', 4); html_print_input_text('custom_oid_data_1', $custom_oid_data_1, '', 60); @@ -1077,7 +1076,7 @@ if ($create_alert || $update_alert) { } echo ''; - echo ''.__('Position').ui_print_help_icon('snmp_alert_position', true).''; + echo ''.__('Position').''; html_print_input_text('position', $position, '', 3); echo ''; diff --git a/pandora_console/godmode/snmpconsole/snmp_filters.php b/pandora_console/godmode/snmpconsole/snmp_filters.php index b87fb4c3dd..0d8e1e9480 100644 --- a/pandora_console/godmode/snmpconsole/snmp_filters.php +++ b/pandora_console/godmode/snmpconsole/snmp_filters.php @@ -226,13 +226,13 @@ if ($edit_filter > -2) { $table->cellpadding = 4; $table->cellspacing = 4; $table->width = '100%'; - $table->class = 'databox data'; + $table->class = 'info_table'; $table->align = []; $table->head[0] = __('Description'); $table->head[1] = __('Filter'); $table->head[2] = __('Action'); - $table->size[2] = '50px'; + $table->size[2] = '65px'; $table->align[2] = 'center'; foreach ($aglomerate_result as $ind => $row) { @@ -263,6 +263,7 @@ if ($edit_filter > -2) { $data[0] = $compose_id; $data[1] = implode(' AND ', $compose_filter); $data[2] = $compose_action; + $table->cellclass[][2] = 'action_buttons'; array_push($table->data, $data); } } diff --git a/pandora_console/godmode/snmpconsole/snmp_trap_generator.php b/pandora_console/godmode/snmpconsole/snmp_trap_generator.php index ec8ed20930..43ed63abec 100755 --- a/pandora_console/godmode/snmpconsole/snmp_trap_generator.php +++ b/pandora_console/godmode/snmpconsole/snmp_trap_generator.php @@ -33,7 +33,13 @@ $snmp_type = (int) get_parameter('snmp_type', 0); $snmp_value = (string) get_parameter('snmp_value', ''); $generate_trap = (bool) get_parameter('generate_trap', 0); -ui_print_page_header(__('SNMP Trap generator'), 'images/op_snmp.png', false, '', false); +ui_print_page_header( + __('SNMP Trap generator'), + 'images/op_snmp.png', + false, + 'snmp_trap_generator_view', + false +); if ($generate_trap) { $result = true; @@ -64,22 +70,64 @@ $table->size = []; $table->data = []; $table->data[0][0] = __('Host address'); -$table->data[0][1] = html_print_input_text('snmp_host_address', $snmp_host_address, '', 50, 255, true); +$table->data[0][1] = html_print_input_text( + 'snmp_host_address', + $snmp_host_address, + '', + 50, + 255, + true +); $table->data[0][2] = __('Community'); -$table->data[0][3] = html_print_input_text('snmp_community', $snmp_community, '', 50, 255, true); +$table->data[0][3] = html_print_input_text( + 'snmp_community', + $snmp_community, + '', + 50, + 255, + true +); $table->data[2][0] = __('Enterprise String'); -$table->data[2][1] = html_print_input_text('snmp_oid', $snmp_oid, '', 50, 255, true); +$table->data[2][1] = html_print_input_text( + 'snmp_oid', + $snmp_oid, + '', + 50, + 255, + true +); $table->data[2][2] = __('Value'); -$table->data[2][3] = html_print_input_text('snmp_value', $snmp_value, '', 50, 255, true); +$table->data[2][3] = html_print_input_text( + 'snmp_value', + $snmp_value, + '', + 50, + 255, + true +); $table->data[3][0] = __('SNMP Agent'); -$table->data[3][1] = html_print_input_text('snmp_agent', $snmp_agent, '', 50, 255, true); +$table->data[3][1] = html_print_input_text( + 'snmp_agent', + $snmp_agent, + '', + 50, + 255, + true +); -$table->data[3][2] = __('SNMP Type').' '.ui_print_help_icon('snmp_trap_types', true); -$table->data[3][3] = html_print_input_text('snmp_type', $snmp_type, '', 50, 255, true); +$table->data[3][2] = __('SNMP Type'); +$table->data[3][3] = html_print_input_text( + 'snmp_type', + $snmp_type, + '', + 50, + 255, + true +); $types = [ 0 => 'Cold start (0)', @@ -90,7 +138,17 @@ $types = [ 5 => 'EGP neighbor loss (5)', 6 => 'Enterprise (6)', ]; -$table->data[3][3] = html_print_select($types, 'snmp_type', $snmp_type, '', __('Select'), -1, true, false, false); +$table->data[3][3] = html_print_select( + $types, + 'snmp_type', + $snmp_type, + '', + __('Select'), + -1, + true, + false, + false +); $traps_generator .= html_print_table($table, true); diff --git a/pandora_console/godmode/tag/tag.php b/pandora_console/godmode/tag/tag.php index d717a9095e..8a8ddc8887 100644 --- a/pandora_console/godmode/tag/tag.php +++ b/pandora_console/godmode/tag/tag.php @@ -117,7 +117,14 @@ if (is_metaconsole()) { // ui_meta_print_header(__('Tags'), "", $buttons); } else { // Header - ui_print_page_header(__('Tags configuration'), 'images/tag.png', false, 'tags_config', true, $buttons); + ui_print_page_header( + __('Tags configuration'), + 'images/tag.png', + false, + 'tags_config', + true, + $buttons + ); } // Two actions can performed in this page: search and delete tags @@ -191,7 +198,7 @@ if (!empty($result)) { $table = new stdClass(); $table->width = '100%'; - $table->class = 'databox data'; + $table->class = 'info_table'; $table->data = []; $table->head = []; @@ -278,12 +285,14 @@ if (!empty($result)) { $data[5] = $output; - $data[6] = "".html_print_image('images/config.png', true, ['title' => 'Edit']).'  '; + $table->cellclass[][6] = 'action_buttons'; + $data[6] = "".html_print_image('images/config.png', true, ['title' => 'Edit']).''; $data[6] .= ''.html_print_image('images/cross.png', true, ['title' => 'Delete']).''; array_push($table->data, $data); } html_print_table($table); + ui_pagination($total_tags, $url, 0, 0, false, 'offset', true, 'pagination-bottom'); } else { if (is_metaconsole()) { ui_toggle($filter_form, __('Show Options')); diff --git a/pandora_console/godmode/update_manager/update_manager.css b/pandora_console/godmode/update_manager/update_manager.css index f68c92ea94..168c6fcf7a 100644 --- a/pandora_console/godmode/update_manager/update_manager.css +++ b/pandora_console/godmode/update_manager/update_manager.css @@ -140,6 +140,162 @@ } #box_online { - background-color: #e6e6e6; - padding: 10px; + background-image: url("../../images/update_manager_background.jpg"); + background-size: cover; + background-position: center center; + background-repeat: no-repeat; + background-color: #fff; + padding: 40px 50px; + border: 1px solid #f3f3f3; + border-radius: 5px; + min-height: 600px; +} + +div#box_online * { + font-size: 16pt; + font-family: "Open Sans", sans-serif; +} + +#box_online .content { + max-width: 60%; +} + +.update_popup { + display: flex; + justify-content: space-between; + align-items: center; + padding-left: 10px; + padding-right: 10px; +} + +.update_icon { + padding-left: 20px; +} + +.update_text h3 { + font-weight: bold; + font-size: 12pt; +} + +.update_text p { + font-size: 11pt; +} + +.update_text a { + font-size: 11pt; + color: #82b92e !important; +} + +.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { + float: left !important; + 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; + text-decoration: none; + font-family: "Open Sans", sans-serif; +} + +a.update_manager_button:after { + content: url(../../images/update_manager_button.png); + padding-left: 10px; +} + +.progressbar { + margin-top: 15px; +} + +.ui-draggable, +.ui-draggable .ui-dialog-titlebar { + cursor: default !important; +} + +#box_online #pkg_version { + color: #82b92e; + font-size: 75pt; + font-weight: bold; +} + +/* METACONSOLE */ +.box_online_meta { + background: none !important; + min-height: 400px !important; + text-align: center; + border: none !important; +} + +div#box_online.box_online_meta * { + font-size: 14pt; +} + +#box_online.box_online_meta .content { + max-width: 100%; +} + +#box_online.box_online_meta #pkg_version { + font-size: 60pt; +} + +/* COMMUNITY */ +.update_manager_open { + max-width: 50%; + font-size: 10pt; + margin-top: 40px; + padding: 20px; + border: 1px solid #eaeaea; + border-radius: 5px; +} + +.update_manager_warning { + display: flex; + align-items: center; + margin-bottom: 10px; +} + +.update_manager_warning p { + font-size: 10pt !important; +} + +.update_manager_warning img { + padding-right: 20px; + width: 90px; +} + +a.update_manager_button_open { + padding: 5px 10px; + font-size: 16px !important; + border-radius: 4px !important; + text-decoration: none; + border: 1px solid #82b92e; + color: #82b92e; + border-radius: 2px; +} + +a.update_manager_button_open:hover { + color: #fff; + background-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 3e807367bd..a1524d5518 100644 --- a/pandora_console/godmode/update_manager/update_manager.online.php +++ b/pandora_console/godmode/update_manager/update_manager.online.php @@ -1,16 +1,32 @@ - @import 'styles/meta_pandora.css'; - "; -} - -if (is_metaconsole()) { - echo "