diff --git a/extras/deploy-scripts/pandora_deploy_community.sh b/extras/deploy-scripts/pandora_deploy_community.sh index 5e580ef1a3..29502b8ef2 100644 --- a/extras/deploy-scripts/pandora_deploy_community.sh +++ b/extras/deploy-scripts/pandora_deploy_community.sh @@ -254,6 +254,8 @@ server_dependencies=" \ perl(Geo::IP) \ perl(IO::Socket::INET6) \ perl(XML::Twig) \ + expect \ + openssh-clients \ http://firefly.artica.es/centos7/xprobe2-0.3-12.2.x86_64.rpm \ http://firefly.artica.es/centos7/wmic-1.4-1.el7.x86_64.rpm" execute_cmd "yum install -y $server_dependencies" "Installing Pandora FMS Server dependencies" diff --git a/extras/docker/centos8/base/Dockerfile b/extras/docker/centos8/base/Dockerfile index a35aea2937..2e66972229 100644 --- a/extras/docker/centos8/base/Dockerfile +++ b/extras/docker/centos8/base/Dockerfile @@ -11,7 +11,7 @@ RUN dnf install -y --setopt=tsflags=nodocs \ RUN dnf module reset -y php && dnf module install -y php:remi-7.3 RUN dnf config-manager --set-enabled powertools -# Install console +# Install console dependencies RUN dnf install -y --setopt=tsflags=nodocs \ php \ php-mcrypt \php-cli \ @@ -91,9 +91,9 @@ RUN dnf install -y --setopt=tsflags=nodocs \ php-yaml RUN mkdir -p /run/php-fpm/ ; chown -R root:apache /run/php-fpm/ -# not installed perl-Net-Telnet gtk-update-icon-cach ghostscript-fonts +# Not installed perl-Net-Telnet gtk-update-icon-cach ghostscript-fonts -# Install server +# Install server dependencies RUN dnf install -y --setopt=tsflags=nodocs \ GeoIP \ @@ -256,16 +256,18 @@ RUN dnf install -y --setopt=tsflags=nodocs \ nmap \ net-snmp-utils \ sudo \ + expect \ + openssh-clients \ http://firefly.artica.es/centos8/perl-Net-Telnet-3.04-1.el8.noarch.rpm \ - http://firefly.artica.es/centos8/wmi-1.3.14-4.el7.art.x86_64.rpm + http://firefly.artica.es/centos7/wmic-1.4-1.el7.x86_64.rpm -# install utils +# Install utils RUN dnf install -y supervisor crontabs http://firefly.artica.es/centos8/phantomjs-2.1.1-1.el7.x86_64.rpm --setopt=tsflags=nodocs # SDK VMware perl dependencies RUN dnf install -y http://firefly.artica.es/centos8/perl-Crypt-OpenSSL-AES-0.02-1.el8.x86_64.rpm http://firefly.artica.es/centos8/perl-Crypt-SSLeay-0.73_07-1.gf.el8.x86_64.rpm perl-Net-HTTP perl-libwww-perl openssl-devel perl-Crypt-CBC perl-Bytes-Random-Secure perl-Crypt-Random-Seed perl-Math-Random-ISAAC perl-JSON http://firefly.artica.es/centos8/VMware-vSphere-Perl-SDK-6.5.0-4566394.x86_64.rpm # Instant client Oracle RUN dnf install -y https://download.oracle.com/otn_software/linux/instantclient/19800/oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm https://download.oracle.com/otn_software/linux/instantclient/19800/oracle-instantclient19.8-sqlplus-19.8.0.0.0-1.x86_64.rpm - +# Install Phantom RUN dnf install -y supervisor crontabs http://firefly.artica.es/centos8/phantomjs-2.1.1-1.el7.x86_64.rpm --setopt=tsflags=nodocs diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 36e53ecea4..5199a030ae 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.754-210513 +Version: 7.0NG.754-210528 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 cf86004742..f01b00ee29 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.754-210513" +pandora_version="7.0NG.754-210528" 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/pandora_agent b/pandora_agents/unix/pandora_agent index 248f0fd4a1..0329fd8a41 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1015,7 +1015,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.754'; -use constant AGENT_BUILD => '210513'; +use constant AGENT_BUILD => '210528'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; @@ -2331,9 +2331,6 @@ sub launch_tentacle_proxy () { #Execute tentacle server as a daemon my $new_process = "tentacle_server -a ".$Conf{'proxy_address'}." -p ".$Conf{'proxy_port'}." -b ".$Conf{'server_ip'}." -g ".$Conf{'server_port'}." -c ".$Conf{'proxy_max_connection'}." -t ".$Conf{'proxy_timeout'}; - - $new_process .= ' -C' if ($Conf{'server_ssl'} eq '1'); - log_message ('setup', 'Proxy mode enabled'); exec ($new_process); } diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 2e51763325..b094bd0ae7 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.754 -%define release 210513 +%define release 210528 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 7e85bcba76..d71828b386 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.754 -%define release 210513 +%define release 210528 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 99f7f5d086..c64d01b09e 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.754" -PI_BUILD="210513" +PI_BUILD="210528" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/unix/pandora_revent b/pandora_agents/unix/pandora_revent index 3af581decb..5f1bc8c3bd 100755 --- a/pandora_agents/unix/pandora_revent +++ b/pandora_agents/unix/pandora_revent @@ -3,7 +3,7 @@ ######################################################################## # Pandora FMS - Remote Event Tool (via WEB API) ######################################################################## -# Copyright (c) 2013 Artica Soluciones Tecnologicas S.L +# Copyright (c) 2021 Artica Soluciones Tecnologicas S.L # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License version 2 @@ -12,6 +12,7 @@ # Includes list use strict; use LWP::Simple; +use LWP::UserAgent; use MIME::Base64; use lib '/usr/lib/perl5'; use PandoraFMS::Tools; @@ -32,40 +33,41 @@ sub help_screen{ \t$0 -p -u -create_event Where options:\n - -u : API credentials separated by comma: ,, - -name : Free text - -group : Group ID (use 0 for 'all') - -agent : Agent ID + -u : API credentials separated by comma: ,, + -name : Free text (surrounded by single-quotes, for security reasons) + -group : Group ID (use 0 for 'all') Optional parameters: - - [-status ] : 0 New, 1 Validated, 2 In process - [-user ] : User comment (use in combination with -comment option) - [-type ] : unknown, alert_fired, alert_recovered, alert_ceased + + [-agent ] : 0 New, 1 Validated, 2 In process + [-user ] : User comment (use in combination with -comment option) + [-type ] : unknown, alert_fired, alert_recovered, alert_ceased alert_manual_validation, system, error, new_agent configuration_change, going_unknown, going_down_critical, going_down_warning, going_up_normal - [-severity ] : 0 Maintance, + [-severity ] : 0 Maintance, 1 Informative, 2 Normal, 3 Warning, 4 Crit, 5 Minor, 6 Major - [-am ] : ID Agent Module linked to event - [-alert ] : ID Alert Module linked to event + [-am ] : ID Agent Module linked to event + [-alert ] : ID Alert Module linked to event [-c_instructions ] [-w_instructions ] [-u_instructions ] - [-user_comment ] - [-owner_user ] : Use the login name, not the descriptive - [-source ] : (By default 'Pandora') - [-tag ] : Tag (must exist in the system to be imported) + [-user_comment ] : Free text (surrounded by single-quotes, for security reasons) + [-owner_user ] : Use the login name, not the descriptive + [-source ] : (By default 'Pandora') + [-tag ] : Tag (must exist in the system to be imported) [-custom_data ]: Custom data has to be in JSON format. Example: -custom_data \'{\"test1\" : \"t1\", \"test2\": \"2\"}\' - [-id_extra ] : Id extra - [-agent_name ] : Agent name, Not to be confused with the alias. - [-force_create_agent<0 o 1>]: Force the creation of agent through an event this will create when it is 1. - [-server_id ] : The pandora node server_id\n\n"; + [-id_extra ] : Id extra + [-agent_name ] : Agent name, Not to be confused with the alias. + [-force_create_agent<0 o 1>] : Force the creation of agent through an event this will create when it is 1. + [-separator ''] : If you use the vertical bar `|` in the event name, you must set other character for send the info. This must be surrounded by single-quotes + [-server_id ] : The pandora node server_id\n\n"; print "Example of event generation:\n\n"; @@ -88,7 +90,7 @@ Optional parameters: ############################################################################## sub tool_api_init () { - print "\nPandora FMS Remote Event Tool Copyright (c) 2013-2015 Artica ST\n"; + print "\nPandora FMS Remote Event Tool Copyright (c) 2013-2021 Artica ST\n"; print "This program is Free Software, licensed under the terms of GPL License v2\n"; print "You can download latest versions and documentation at http://www.pandorafms.org\n\n"; @@ -120,7 +122,7 @@ sub tool_api_main () { my $db_user; my $db_pass; my @db_info; - my $id_agent; + my $id_agent = '0'; my $id_user = ''; my $status = ''; my $id_agent_module = ''; @@ -141,6 +143,7 @@ sub tool_api_main () { my $call_api; my $custom_data = ""; my $server_id = 0; + my $separator = '|'; #~ help or api path (required) if ($ARGV[0] eq '-h') { @@ -185,12 +188,18 @@ sub tool_api_main () { if ($line eq '-agent') { $id_agent = $ARGV[$i + 1]; + # If not defined, send 0 for API. + if ($id_agent eq undef) { + $id_agent = '0'; + } + } if ($line eq '-group') { $id_group = $ARGV[$i + 1]; } if ($line eq '-name') { $event_name = $ARGV[$i + 1]; + $event_name =~ s/#/%23/g; } if ($line eq '-type') { $event_type = $ARGV[$i + 1]; @@ -250,50 +259,49 @@ sub tool_api_main () { if ($line eq '-server_id') { $server_id = $ARGV[$i + 1]; } + if ($line eq '-separator') { + $separator = $ARGV[$i + 1]; + } $i++; } if ($event_name eq "") { - print "[ERROR] Missing id agent! Read help info:\n\n"; + print "[ERROR] Missing event name! Read help info:\n\n"; help_screen (); } if ($id_group eq "") { print "[ERROR] Missing event group! Read help info:\n\n"; help_screen (); } - if ($id_agent eq "" && $agent_name eq "") { - print "[ERROR] Missing id agent! and agent_name Read help info:\n\n"; - help_screen (); - } $data_event = $event_name . - "|" . $id_group . - "|" . $id_agent . - "|" . $status . - "|" . $id_user . - "|" . $event_type . - "|" . $severity . - "|" . $id_agent_module . - "|" . $id_alert_am . - "|" . $critical_instructions . - "|" . $warning_instructions . - "|" . $unknown_instructions . - "|" . $user_comment . - "|" . $owner_user . - "|" . $source . - "|" . $tags . - "|" . $custom_data . - "|" . $server_id . - "|" . $id_extra . - "|" . $agent_name . - "|" . $force_create_agent; + $separator . $id_group . + $separator . $id_agent . + $separator . $status . + $separator . $id_user . + $separator . $event_type . + $separator . $severity . + $separator . $id_agent_module . + $separator . $id_alert_am . + $separator . $critical_instructions . + $separator . $warning_instructions . + $separator . $unknown_instructions . + $separator . $user_comment . + $separator . $owner_user . + $separator . $source . + $separator . $tags . + $separator . $custom_data . + $separator . $server_id . + $separator . $id_extra . + $separator . $agent_name . + $separator . $force_create_agent; $call_api = $api_path . '?' . 'op=set&' . 'op2=create_event&' . 'other=' . $data_event .'&' . - 'other_mode=url_encode_separator_|&' . + 'other_mode=url_encode_separator_'.$separator.'&' . 'apipass=' . $api_pass . '&' . 'user=' . $db_user . '&' . 'pass=' . $db_pass; @@ -321,7 +329,8 @@ sub tool_api_main () { exit; } else { - my $content = get($call_api); + my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0 }); + my $content = $ua->get($call_api); if ($option eq '-create_event') { if ($content eq undef) { @@ -329,7 +338,7 @@ sub tool_api_main () { help_screen(); } else { - print "Event ID: $content"; + print "Event ID: $content->{'_content'}"; } } elsif ($option eq '-validate_event') { diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index d1cb263733..01fba38997 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{210513} +{210528} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 57c368a773..83d167d56d 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.754 Build 210513") +#define PANDORA_VERSION ("7.0NG.754 Build 210528") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/pandora_windows_service.cc b/pandora_agents/win32/pandora_windows_service.cc index 70ce28b1f1..900694183c 100644 --- a/pandora_agents/win32/pandora_windows_service.cc +++ b/pandora_agents/win32/pandora_windows_service.cc @@ -423,7 +423,7 @@ Pandora_Windows_Service::killTentacleProxy() { int Pandora_Windows_Service::launchTentacleProxy() { - string server_ip, server_port, proxy_max_connections, proxy_timeout, server_ssl; + string server_ip, server_port, proxy_max_connections, proxy_timeout; string proxy_cmd, proxy_address, proxy_port; PROCESS_INFORMATION pi; STARTUPINFO si; @@ -451,15 +451,6 @@ Pandora_Windows_Service::launchTentacleProxy() { server_port = "41121"; } - server_ssl = conf->getValue("server_ssl"); - - if (server_ssl == "1") { - proxy_cmd = "tentacle_server.exe -C"; - } - else { - proxy_cmd = "tentacle_server.exe"; - } - // Proxy address. proxy_address = conf->getValue("proxy_address"); if (proxy_address == "") { @@ -472,7 +463,7 @@ Pandora_Windows_Service::launchTentacleProxy() { proxy_port = "41121"; } - proxy_cmd += " -b " + server_ip + " -g " + server_port + " -c " + proxy_max_connections + " -t " + proxy_timeout + " -a " + proxy_address + " -p " + proxy_port; + proxy_cmd = "tentacle_server.exe -b " + server_ip + " -g " + server_port + " -c " + proxy_max_connections + " -t " + proxy_timeout + " -a " + proxy_address + " -p " + proxy_port; ZeroMemory (&si, sizeof (si)); ZeroMemory (&pi, sizeof (pi)); diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 895e32ceb8..bc907eca4b 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.754(Build 210513))" + VALUE "ProductVersion", "(7.0NG.754(Build 210528))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index f0bb243dba..f56c42c5e2 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.754-210513 +Version: 7.0NG.754-210528 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 0c82e3b4f4..15edaa640e 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.754-210513" +pandora_version="7.0NG.754-210528" package_pear=0 package_pandora=1 diff --git a/pandora_console/ajax.php b/pandora_console/ajax.php index fca916d796..f0032476e2 100644 --- a/pandora_console/ajax.php +++ b/pandora_console/ajax.php @@ -31,18 +31,18 @@ require 'vendor/autoload.php'; define('AJAX', true); -if (!defined('__PAN_XHPROF__')) { +if (defined('__PAN_XHPROF__') === false) { define('__PAN_XHPROF__', 0); } if (__PAN_XHPROF__ === 1) { - if (function_exists('tideways_xhprof_enable')) { + if (function_exists('tideways_xhprof_enable') === true) { tideways_xhprof_enable(); } } -if ((! file_exists('include/config.php')) - || (! is_readable('include/config.php')) +if (file_exists('include/config.php') === false + || is_readable('include/config.php') === false ) { exit; } @@ -57,11 +57,11 @@ require_once 'include/auth/mysql.php'; if (isset($config['console_log_enabled']) === true && $config['console_log_enabled'] == 1 ) { - ini_set('log_errors', 1); + ini_set('log_errors', true); ini_set('error_log', $config['homedir'].'/log/console.log'); } else { - ini_set('log_errors', 0); - ini_set('error_log', null); + ini_set('log_errors', false); + ini_set('error_log', ''); } // Sometimes input is badly retrieved from caller... @@ -98,9 +98,11 @@ if (isset($_GET['loginhash']) === true) { } } +// Another auth class example: PandoraFMS\Dashboard\Manager. $auth_class = io_safe_output( - get_parameter('auth_class', 'PandoraFMS\Dashboard\Manager') + get_parameter('auth_class', 'PandoraFMS\User') ); + $public_hash = get_parameter('auth_hash', false); $public_login = false; // Check user. @@ -124,7 +126,7 @@ if (class_exists($auth_class) === false || $public_hash === false) { ob_start(); // Enterprise support. -if (file_exists(ENTERPRISE_DIR.'/load_enterprise.php')) { +if (file_exists(ENTERPRISE_DIR.'/load_enterprise.php') === true) { include_once ENTERPRISE_DIR.'/load_enterprise.php'; } @@ -142,12 +144,12 @@ if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) { ); } -if (is_metaconsole()) { +if (is_metaconsole() === true) { // Backward compatibility. define('METACONSOLE', true); } -if (file_exists($page)) { +if (file_exists($page) === true) { include_once $page; } else { echo '
Sorry! I can\'t find the page '.$page.'!'; @@ -172,7 +174,7 @@ if (isset($config['force_instant_logout']) === true header_remove('Set-Cookie'); setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/'); - if ($config['auth'] == 'saml') { + if ($config['auth'] === 'saml') { include_once $config['saml_path'].'simplesamlphp/lib/_autoload.php'; $as = new SimpleSAML_Auth_Simple('PandoraFMS'); $as->logout(); diff --git a/pandora_console/extensions/agents_modules.php b/pandora_console/extensions/agents_modules.php index 0abde09010..f93dec02a4 100644 --- a/pandora_console/extensions/agents_modules.php +++ b/pandora_console/extensions/agents_modules.php @@ -1,16 +1,29 @@ '', + 'label' => __('Monitoring'), + ], + [ + 'link' => '', + 'label' => __('Views'), + ], + ] ); + echo ''; echo ''; echo "'; diff --git a/pandora_console/extensions/module_groups.php b/pandora_console/extensions/module_groups.php index 3b9670a8e0..054eabb73d 100644 --- a/pandora_console/extensions/module_groups.php +++ b/pandora_console/extensions/module_groups.php @@ -246,13 +246,24 @@ function mainModuleGroups() $array_data[$value['id_grupo']][$value['id_mg']] = $value; } - ui_print_page_header( + // Header. + ui_print_standard_header( __('Combined table of agent group and module group'), 'images/module_group.png', false, '', false, - '' + [], + [ + [ + 'link' => '', + 'label' => __('Monitoring'), + ], + [ + 'link' => '', + 'label' => __('Views'), + ], + ] ); echo "
".$fullscreen['text'].'
diff --git a/pandora_console/extensions/realtime_graphs.php b/pandora_console/extensions/realtime_graphs.php index 37593d5355..cd417e3a43 100644 --- a/pandora_console/extensions/realtime_graphs.php +++ b/pandora_console/extensions/realtime_graphs.php @@ -53,13 +53,24 @@ function pandora_realtime_graphs() $hide_header = get_parameter('hide_header', 0); if ($hide_header === 0) { - ui_print_page_header( + // Header. + ui_print_standard_header( __('Realtime graphs'), 'images/extensions.png', false, 'real_time_view', false, - $onheader + $onheader, + [ + [ + 'link' => '', + 'label' => __('Monitoring'), + ], + [ + 'link' => '', + 'label' => __('Views'), + ], + ] ); } diff --git a/pandora_console/extensions/resource_registration.php b/pandora_console/extensions/resource_registration.php index 950f4e2b81..f1fc645179 100755 --- a/pandora_console/extensions/resource_registration.php +++ b/pandora_console/extensions/resource_registration.php @@ -1,29 +1,43 @@ 0, + "UPDATE `tconfig` set value = 'pandoraFMS_metaconsole_full.svg' WHERE token LIKE 'meta_custom_logo'", + "SELECT 1" +)); + +PREPARE pr_oum755 FROM @st_oum755; +EXECUTE pr_oum755; +DEALLOCATE PREPARE pr_oum755; + +COMMIT; 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 3a22bd4f90..1335550ef7 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 @@ -1019,7 +1019,7 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_event` ( -- Criticity: 5 - Minor -- Criticity: 6 - Major -ALTER TABLE `tmetaconsole_event` ADD COLUMN `data` double(22,5) default NULL; +ALTER TABLE `tmetaconsole_event` ADD COLUMN `data` double(50,5) default NULL; ALTER TABLE `tmetaconsole_event` ADD COLUMN `module_status` int(4) NOT NULL default '0'; ALTER TABLE `tmetaconsole_event` ADD INDEX `server_id` (`server_id`); ALTER TABLE `tmetaconsole_event` ADD INDEX `tme_timestamp_idx` (`timestamp`); @@ -1072,7 +1072,7 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_event_history` ( -- Criticity: 5 - Minor -- Criticity: 6 - Major -ALTER TABLE `tmetaconsole_event_history` ADD COLUMN `data` double(22,5) default NULL; +ALTER TABLE `tmetaconsole_event_history` ADD COLUMN `data` double(50,5) default NULL; ALTER TABLE `tmetaconsole_event_history` ADD COLUMN `module_status` int(4) NOT NULL default '0'; ALTER TABLE `tmetaconsole_event_history` ADD INDEX `tmeh_estado_idx` (`estado`); ALTER TABLE `tmetaconsole_event_history` ADD INDEX `tmeh_timestamp_idx` (`timestamp`); @@ -1532,6 +1532,8 @@ ALTER TABLE `tusuario` MODIFY COLUMN `default_event_filter` int(10) unsigned NOT ADD CONSTRAINT `fk_filter_id` FOREIGN KEY `fk_filter_id` (`id_filter`) REFERENCES `tevent_filter` (`id_filter`) ON DELETE SET NULL ON UPDATE RESTRICT, DROP FOREIGN KEY `fk_id_filter`, DROP INDEX `fk_id_filter`; +ALTER TABLE `tusuario` ADD COLUMN `integria_user_level_user` VARCHAR(60); +ALTER TABLE `tusuario` ADD COLUMN `integria_user_level_pass` VARCHAR(45); -- --------------------------------------------------------------------- @@ -1554,7 +1556,7 @@ ALTER TABLE `tagente_modulo` ADD COLUMN `debug_content` varchar(200); -- --------------------------------------------------------------------- -- Table `tagente_datos` -- --------------------------------------------------------------------- -ALTER TABLE tagente_datos MODIFY `datos` double(22,5); +ALTER TABLE tagente_datos MODIFY `datos` double(50,5); ALTER TABLE `tagente_datos` DROP INDEX `data_index1`, ADD INDEX `data_index1` (`id_agente_modulo`, `utimestamp`); -- --------------------------------------------------------------------- @@ -1565,7 +1567,7 @@ ALTER TABLE `tagente_datos_string` MODIFY COLUMN `datos` mediumtext NOT NULL, DR -- --------------------------------------------------------------------- -- Table `tagente_datos_inc` -- --------------------------------------------------------------------- -ALTER TABLE tagente_datos_inc MODIFY `datos` double(22,5); +ALTER TABLE tagente_datos_inc MODIFY `datos` double(50,5); -- --------------------------------------------------------------------- -- Table `tnetwork_component` @@ -2339,7 +2341,7 @@ CREATE TABLE IF NOT EXISTS `tagent_custom_fields_filter` ( -- --------------------------------------------------------------------- -- Table `tevento` -- --------------------------------------------------------------------- -ALTER TABLE `tevento` ADD COLUMN `data` double(22,5) default NULL; +ALTER TABLE `tevento` ADD COLUMN `data` double(50,5) default NULL; ALTER TABLE `tevento` ADD COLUMN `module_status` int(4) NOT NULL default '0'; @@ -4030,3 +4032,6 @@ DELETE FROM `tconfig` WHERE `token` = 'ipam_installed'; DELETE FROM `tconfig` WHERE `token` = 'ipam_recon_script_id'; +ALTER TABLE `tperfil` DROP COLUMN `incident_view`; +ALTER TABLE `tperfil` DROP COLUMN `incident_edit`; +ALTER TABLE `tperfil` DROP COLUMN `incident_management`; \ No newline at end of file diff --git a/pandora_console/general/alert_enterprise.php b/pandora_console/general/alert_enterprise.php index 8946b5e1f8..90a1bc5d4d 100644 --- a/pandora_console/general/alert_enterprise.php +++ b/pandora_console/general/alert_enterprise.php @@ -192,15 +192,15 @@ if (check_login()) { echo " -
-
+
+
OK
"; if ($open) { echo "
About Enterprise -
"; +
"; } } diff --git a/pandora_console/general/first_task/cluster_builder.php b/pandora_console/general/first_task/cluster_builder.php index 08ea618cce..157bdce0d7 100644 --- a/pandora_console/general/first_task/cluster_builder.php +++ b/pandora_console/general/first_task/cluster_builder.php @@ -24,12 +24,20 @@ if (! check_acl($config['id_user'], 0, 'AR') && ! check_acl($config['id_user'], return; } -\ui_print_page_header( - __('Monitoring').' » '.__('Clusters'), +// Header. +ui_print_standard_header( + __('Clusters'), 'images/chart.png', false, '', - false + false, + [], + [ + [ + 'link' => '', + 'label' => __('Monitoring'), + ], + ] ); ui_require_css_file('first_task'); diff --git a/pandora_console/general/main_menu.php b/pandora_console/general/main_menu.php index 9a5e4168b4..5a45058c58 100644 --- a/pandora_console/general/main_menu.php +++ b/pandora_console/general/main_menu.php @@ -88,7 +88,6 @@ if (check_acl($config['id_user'], 0, 'AW') || check_acl($config['id_user'], 0, 'LM') || check_acl($config['id_user'], 0, 'UM') || check_acl($config['id_user'], 0, 'LW') - || check_acl($config['id_user'], 0, 'IW') || check_acl($config['id_user'], 0, 'EW') || check_acl($config['id_user'], 0, 'DW') ) { diff --git a/pandora_console/godmode/agentes/agent_incidents.php b/pandora_console/godmode/agentes/agent_incidents.php index 16cdd9370c..3917c2f81a 100644 --- a/pandora_console/godmode/agentes/agent_incidents.php +++ b/pandora_console/godmode/agentes/agent_incidents.php @@ -39,7 +39,7 @@ $offset = (int) get_parameter('offset', 0); // See if id_agente is set (either POST or GET, otherwise -1 $id_agent = (int) get_parameter('id_agente'); -$groups = users_get_groups($config['id_user'], 'IR'); +$groups = users_get_groups($config['id_user'], 'AR'); $filter = ' AND id_agent = '.$id_agent; $url = 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=incident&id_agente='.$id_agent; @@ -55,7 +55,7 @@ $params = [ agents_get_name($id_agent), ]; -$result = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incidents', $params, false, 'json', ','); +$result = integria_api_call(null, null, null, null, 'get_incidents', $params, false, 'json', ','); $result = json_decode($result, true); diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 3856b1be8c..32b1d14ea2 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -1,17 +1,32 @@ $viewtab]; // Header. -ui_print_page_header( +ui_print_standard_header( __('Agents defined in %s', get_product_name()), 'images/agent.png', false, '', true, - $onheader + $onheader, + [ + [ + 'link' => '', + 'label' => __('Resources'), + ], + [ + 'link' => '', + 'label' => __('Manage agents'), + ], + ] ); if (is_central_policies_on_node()) { diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index 335017ab51..6f2747de19 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -1130,7 +1130,6 @@ foreach ($modules as $module) { [ 'alt' => __('Enable module'), 'title' => __('Enable module'), - 'class' => 'invert_filter_important', ] ).''; } else { diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index 1a4577c4ee..5e994499f3 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -1,17 +1,32 @@ data[2][0] = __('Group'); $table->data[2][1] = html_print_select_groups( false, - 'IW', + 'AR', $return_all_group, 'map_group_id', $map_group_id, diff --git a/pandora_console/godmode/groups/configure_group.php b/pandora_console/godmode/groups/configure_group.php index b06ae97b25..cfcd708947 100644 --- a/pandora_console/godmode/groups/configure_group.php +++ b/pandora_console/godmode/groups/configure_group.php @@ -95,7 +95,7 @@ if ($id_group) { } // Header -if (defined('METACONSOLE')) { +if (is_metaconsole() === true) { agents_meta_print_header(); $sec = 'advanced'; } else { @@ -105,13 +105,24 @@ if (defined('METACONSOLE')) { $title_in_header = __('Create group'); } - ui_print_page_header( + // Header. + ui_print_standard_header( $title_in_header, 'images/group.png', false, '', - true, - '' + false, + [], + [ + [ + 'link' => '', + 'label' => __('Profiles'), + ], + [ + 'link' => '', + 'label' => __('Manage agents group'), + ], + ] ); $sec = 'gagente'; } diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index be1abc90d3..507f21ff9c 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -333,6 +333,7 @@ $title = __('Groups defined in %s', get_product_name()); switch ($tab) { case 'tree': $buttons['tree']['active'] = true; + $title .= sprintf(' » %s', __('Tree view')); break; case 'credbox': @@ -343,23 +344,38 @@ switch ($tab) { case 'groups': default: $buttons['groups']['active'] = true; + $title .= sprintf(' » %s', __('Table view')); break; } // Header. if (is_metaconsole() === true) { agents_meta_print_header(); - echo '
'; - echo __('Edit or delete groups can cause problems with synchronization'); - echo '
'; + html_print_div( + [ + 'class' => 'notify', + 'content' => __('Edit or delete groups can cause problems with synchronization'), + ] + ); } else { - ui_print_page_header( + // Header. + ui_print_standard_header( $title, 'images/group.png', false, '', - true, - $buttons + false, + $buttons, + [ + [ + 'link' => '', + 'label' => __('Profiles'), + ], + [ + 'link' => '', + 'label' => __('Manage agents group'), + ], + ] ); } @@ -471,7 +487,7 @@ if ($update_group) { $values = [ 'nombre' => $name, 'icon' => empty($icon) ? '' : substr($icon, 0, -4), - 'parent' => $id_parent == -1 ? 0 : $id_parent, + 'parent' => ($id_parent == -1) ? 0 : $id_parent, 'disabled' => !$alerts_enabled, 'custom_id' => $custom_id, 'id_skin' => $skin, diff --git a/pandora_console/godmode/module_library/module_library_view.php b/pandora_console/godmode/module_library/module_library_view.php index f69c7779fb..31553a5352 100644 --- a/pandora_console/godmode/module_library/module_library_view.php +++ b/pandora_console/godmode/module_library/module_library_view.php @@ -58,12 +58,27 @@ $buttons['view'] = [ $tab = get_parameter('tab', 'view'); -if ($tab != 'search_module') { +if ($tab !== 'search_module') { $buttons[$tab]['active'] = true; } -ui_print_page_header(__('Module Library').' » '.__('View'), '', false, 'module_library', true, $buttons); +$headerTitle = ($tab === 'categories') ? __('Categories') : __('Main view'); +// Header. +ui_print_standard_header( + $headerTitle, + '', + false, + 'module_library', + true, + $buttons, + [ + [ + 'link' => '', + 'label' => __('Module library'), + ], + ] +); // Styles. ui_require_css_file('module_library'); diff --git a/pandora_console/godmode/netflow/nf_item_list.php b/pandora_console/godmode/netflow/nf_item_list.php index 558cbb339c..d7a267aed6 100644 --- a/pandora_console/godmode/netflow/nf_item_list.php +++ b/pandora_console/godmode/netflow/nf_item_list.php @@ -20,15 +20,6 @@ require_once $config['homedir'].'/include/functions_html.php'; check_login(); -if (! check_acl($config['id_user'], 0, 'IW')) { - db_pandora_audit( - 'ACL Violation', - 'Trying to access event viewer' - ); - include 'general/noaccess.php'; - return; -} - // id report $id = (int) get_parameter('id'); diff --git a/pandora_console/godmode/reporting/graph_builder.php b/pandora_console/godmode/reporting/graph_builder.php index 79fdfde250..c891f66cad 100644 --- a/pandora_console/godmode/reporting/graph_builder.php +++ b/pandora_console/godmode/reporting/graph_builder.php @@ -26,10 +26,9 @@ * ============================================================================ */ +// Begin. global $config; - - if (is_ajax()) { $search_agents = (bool) get_parameter('search_agents'); @@ -319,7 +318,7 @@ if ($edit_graph) { 'view' => [ 'active' => false, 'text' => ''.html_print_image( - 'images/operation.png', + 'images/eye.png', true, [ 'title' => __('View graph'), @@ -340,37 +339,43 @@ if ($edit_graph) { $head = __('Graph builder'); -if (isset($name)) { - $head .= ' - '.$name; +if (isset($name) === true) { + $head .= ' » '.$name; } // Header. -$tab = get_parameter('tab', ''); +$tab = get_parameter('tab'); switch ($tab) { - default: - case 'main': - ui_print_page_header( - $head, - 'images/chart.png', - false, - 'graph_builder', - false, - $buttons - ); + case 'graph_editor': + $headerHelp = ''; break; - case 'graph_editor': - ui_print_page_header( - $head, - 'images/chart.png', - false, - '', - false, - $buttons - ); + case 'main': + default: + $headerHelp = 'graph_builder'; break; } +// Header. +ui_print_standard_header( + $head, + 'images/chart.png', + false, + $headerHelp, + false, + [$buttons], + [ + [ + 'link' => '', + 'label' => __('Reporting'), + ], + [ + 'link' => '', + 'label' => __('Custom graphs'), + ], + ] +); + if ($add_graph) { ui_print_result_message( $id_graph, @@ -418,7 +423,8 @@ if (!$delete_module) { $chunk1 = explode('|', $chunkdata); $modules = ''; $weights = ''; - for ($a = 0; $a < count($chunk1); $a++) { + $chunkCount = count($chunk1); + for ($a = 0; $a < $chunkCount; $a++) { $chunk2[$a] = []; $chunk2[$a] = explode(',', $chunk1[$a]); if (strpos($modules, $chunk2[$a][1]) == 0) { @@ -450,4 +456,8 @@ switch ($active_tab) { case 'graph_editor': include_once 'godmode/reporting/graph_builder.graph_editor.php'; break; + + default: + // Nothing to do. + break; } diff --git a/pandora_console/godmode/reporting/graph_container.php b/pandora_console/godmode/reporting/graph_container.php index 0c8e2a58a1..765e93ea60 100644 --- a/pandora_console/godmode/reporting/graph_container.php +++ b/pandora_console/godmode/reporting/graph_container.php @@ -1,19 +1,35 @@ ', ]; -// Header -ui_print_page_header(__('Graph container'), '', false, '', false, $buttons); + +// Header. +ui_print_standard_header( + __('Graph container'), + '', + false, + '', + false, + $buttons, + [ + [ + 'link' => '', + 'label' => __('Reporting'), + ], + [ + 'link' => '', + 'label' => __('Custom graphs'), + ], + ] +); $container = folder_get_folders(); diff --git a/pandora_console/godmode/reporting/graphs.php b/pandora_console/godmode/reporting/graphs.php index 3fdf7b3969..0c93074a2d 100644 --- a/pandora_console/godmode/reporting/graphs.php +++ b/pandora_console/godmode/reporting/graphs.php @@ -1,16 +1,32 @@ '', + 'label' => __('Reporting'), + ], + [ + 'link' => '', + 'label' => __('Custom graphs'), + ], + ] +); // Delete module SQL code if ($delete_graph) { diff --git a/pandora_console/godmode/reporting/map_builder.php b/pandora_console/godmode/reporting/map_builder.php index 1dd607c57c..b0a8803336 100644 --- a/pandora_console/godmode/reporting/map_builder.php +++ b/pandora_console/godmode/reporting/map_builder.php @@ -1,16 +1,32 @@ '', + 'label' => __('Topology maps'), + ], + [ + 'link' => '', + 'label' => __('Visual console'), + ], + ] ); } else { ui_meta_print_header( diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index b9b32dd09a..ad995a7af8 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -567,17 +567,24 @@ switch ($action) { // Print header. ui_meta_print_header(__('Reporting'), '', $buttons); } else { - // Page header for normal console. - ui_print_page_header( - __('Custom reporting'), + // Header. + ui_print_standard_header( + __('List of reports'), 'images/op_reporting.png', false, '', false, $buttons, - false, - '', - 60 + [ + [ + 'link' => '', + 'label' => __('Reporting'), + ], + [ + 'link' => '', + 'label' => __('Custom reports'), + ], + ] ); } @@ -2500,7 +2507,7 @@ switch ($action) { 0 ); $values['exception_condition'] = (int) get_parameter( - 'radiobutton_exception_condition', + 'exception_condition', 0 ); $values['exception_condition_value'] = get_parameter( @@ -3173,17 +3180,24 @@ switch ($action) { // Print header. ui_meta_print_header(__('Reporting'), '', $buttons); } else { - // Page header for normal console. - ui_print_page_header( + // Header. + ui_print_standard_header( $subsection, 'images/op_reporting.png', false, '', false, $buttons, - false, - '', - 60 + [ + [ + 'link' => '', + 'label' => __('Reporting'), + ], + [ + 'link' => '', + 'label' => __('Custom reports'), + ], + ] ); } @@ -3237,7 +3251,7 @@ if ($enterpriseEnable) { $buttons['view'] = [ 'active' => false, 'text' => ''.html_print_image( - 'images/operation.png', + 'images/eye.png', true, [ 'title' => __('View report'), @@ -3279,17 +3293,25 @@ if ($enterpriseEnable && defined('METACONSOLE')) { } else { $tab_builder = ($activeTab === 'item_editor') ? 'reporting_item_editor_tab' : ''; - if ($action !== 'update' && !is_metaconsole()) { - ui_print_page_header( + if ($action !== 'update' && is_metaconsole() === false) { + // Header. + ui_print_standard_header( $textReportName, 'images/op_reporting.png', false, $tab_builder, false, $buttons, - false, - '', - 60 + [ + [ + 'link' => '', + 'label' => __('Reporting'), + ], + [ + 'link' => '', + 'label' => __('Custom reports'), + ], + ] ); } } @@ -3319,17 +3341,25 @@ if ($resultOperationDB !== null) { $activeTab = 'list_items'; $buttons[$activeTab]['active'] = true; - if (!is_metaconsole()) { - ui_print_page_header( + if (is_metaconsole() === false) { + // Header. + ui_print_standard_header( $textReportName, 'images/op_reporting.png', false, $helpers, false, $buttons, - false, - '', - 60 + [ + [ + 'link' => '', + 'label' => __('Reporting'), + ], + [ + 'link' => '', + 'label' => __('Custom reports'), + ], + ] ); } } diff --git a/pandora_console/godmode/reporting/visual_console_builder.php b/pandora_console/godmode/reporting/visual_console_builder.php index b03b55dd76..23ff0e5889 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.php +++ b/pandora_console/godmode/reporting/visual_console_builder.php @@ -1,19 +1,38 @@ '', + 'label' => __('Topology maps'), + ], + [ + 'link' => '', + 'label' => __('Visual console'), + ], + ] ); } diff --git a/pandora_console/godmode/reporting/visual_console_favorite.php b/pandora_console/godmode/reporting/visual_console_favorite.php index 8bd58abf64..16b5978dd2 100644 --- a/pandora_console/godmode/reporting/visual_console_favorite.php +++ b/pandora_console/godmode/reporting/visual_console_favorite.php @@ -1,19 +1,38 @@ '', + 'label' => __('Topology maps'), + ], + [ + 'link' => '', + 'label' => __('Visual console'), + ], + ] ); } else { ui_meta_print_header( diff --git a/pandora_console/godmode/servers/modificar_server.php b/pandora_console/godmode/servers/modificar_server.php index 90c9130d4d..d1ac51b279 100644 --- a/pandora_console/godmode/servers/modificar_server.php +++ b/pandora_console/godmode/servers/modificar_server.php @@ -386,10 +386,10 @@ function check_process (id_server) { parameters, function (data) { if (data['correct']) { - $("#check_exec_server img").attr("src", ); + $("#check_exec_server img").attr("src", "images/dot_green.png"); } else { - $("#check_exec_server img").attr("src", ); + $("#check_exec_server img").attr("src", "images/dot_red.png"); $("#check_error_message").empty(); $("#check_error_message").append("" + data['message'] + ""); } diff --git a/pandora_console/godmode/setup/os.php b/pandora_console/godmode/setup/os.php index 44888465bf..1be6755749 100644 --- a/pandora_console/godmode/setup/os.php +++ b/pandora_console/godmode/setup/os.php @@ -1,17 +1,32 @@ '', + 'label' => __('Servers'), + ], + [ + 'link' => '', + 'label' => __('Edit OS'), + ], + ] + ); } -if (!empty($id_message)) { +if (empty($id_message) === false) { switch ($id_message) { case 1: echo ui_print_success_message(__('Success creating OS'), '', true); @@ -226,13 +260,11 @@ if (!empty($id_message)) { switch ($tab) { case 'list': + default: include_once $config['homedir'].'/godmode/setup/os.list.php'; - return; + break; - break; case 'builder': include_once $config['homedir'].'/godmode/setup/os.builder.php'; - return; - - break; + break; } diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index f611b14b7f..25165996c7 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -34,9 +34,11 @@ check_login(); if (is_ajax()) { $test_address = get_parameter('test_address', ''); + $params = get_parameter('params', ''); $res = send_test_email( - $test_address + $test_address, + $params ); echo $res; @@ -709,12 +711,25 @@ function perform_email_test () { $('#email_test_failure_message').hide(); var test_address = $('#text-email_test_address').val(); + params = { + email_smtpServer : $('#text-email_smtpServer').val(), + email_smtpPort : $('#text-email_smtpPort').val(), + email_username : $('#text-email_username').val(), + email_password : $('#password-email_password').val(), + email_encryption : $( "#email_encryption option:selected" ).val(), + email_from_dir : $('#text-email_from_dir').val(), + email_from_name : $('#text-email_from_name').val() + }; $.ajax({ type: "POST", url: "ajax.php", - data: "page=godmode/setup/setup_general&test_address="+test_address, - dataType: "html", + data : { + page: "godmode/setup/setup_general", + test_address: test_address, + params: params + }, + dataType: "json", success: function(data) { if (parseInt(data) === 1) { $('#email_test_sent_message').show(); diff --git a/pandora_console/godmode/setup/setup_integria.php b/pandora_console/godmode/setup/setup_integria.php index 58a3d054ae..d97921ff43 100644 --- a/pandora_console/godmode/setup/setup_integria.php +++ b/pandora_console/godmode/setup/setup_integria.php @@ -41,8 +41,10 @@ if (is_ajax()) { $integria_pass = get_parameter('integria_pass', ''); $integria_api_hostname = get_parameter('api_hostname', ''); $integria_api_pass = get_parameter('api_pass', ''); + $user_level_conf = get_parameter('user_level_conf', 0); + $user_level_conf_bool = $user_level_conf === 'true' ? true : false; - $login_result = integria_api_call($integria_api_hostname, $integria_user, $integria_pass, $integria_api_pass, 'get_login', []); + $login_result = integria_api_call($integria_api_hostname, $integria_user, $integria_pass, $integria_api_pass, 'get_login', [], false, '', '', $user_level_conf_bool); if ($login_result != false) { echo json_encode(['login' => 1]); @@ -53,7 +55,7 @@ if (is_ajax()) { return; } -$has_connection = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_login', []); +$has_connection = integria_api_call(null, null, null, null, 'get_login', []); if ($has_connection === false && $config['integria_enabled']) { ui_print_error_message(__('Integria IMS API is not reachable')); @@ -86,7 +88,7 @@ if (get_parameter('update_config', 0) == 1) { ); } - $ticket_types = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_types', '', false, 'json'); + $ticket_types = integria_api_call(null, null, null, null, 'get_types', '', false, 'json'); $types_string = ''; @@ -216,19 +218,19 @@ $integria_users_values = []; $integria_types_values = []; $integria_status_values = []; -$integria_groups_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_groups', []); +$integria_groups_csv = integria_api_call(null, null, null, null, 'get_groups', []); get_array_from_csv_data_pair($integria_groups_csv, $integria_group_values); -$integria_status_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incidents_status', []); +$integria_status_csv = integria_api_call(null, null, null, null, 'get_incidents_status', []); get_array_from_csv_data_pair($integria_status_csv, $integria_status_values); -$integria_criticity_levels_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_priorities', []); +$integria_criticity_levels_csv = integria_api_call(null, null, null, null, 'get_incident_priorities', []); get_array_from_csv_data_pair($integria_criticity_levels_csv, $integria_criticity_values); -$integria_users_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_users', []); +$integria_users_csv = integria_api_call(null, null, null, null, 'get_users', []); $csv_array = explode("\n", $integria_users_csv); @@ -238,7 +240,7 @@ foreach ($csv_array as $csv_line) { } } -$integria_types_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_types', []); +$integria_types_csv = integria_api_call(null, null, null, null, 'get_types', []); get_array_from_csv_data_pair($integria_types_csv, $integria_types_values); @@ -267,6 +269,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'] = ('Integria configuration at user level'); +$row['control'] = html_print_checkbox_switch('integria_user_level_conf', 1, $config['integria_user_level_conf'], true); +$table_remote->data['integria_user_level_conf'] = $row; + // Integria user. $row = []; $row['name'] = __('User'); @@ -629,6 +637,29 @@ echo ''; '; if ($rawjs) { @@ -1002,6 +1003,7 @@ class HTML $output .= ''; $output .= '
    '.$output_submit.'
'; + $output .= html_print_csrf_hidden(true); $output .= ''; $output .= ''; if ($rawjs) { @@ -1073,6 +1075,7 @@ class HTML $output .= ''; $output .= '
    '.$output_submit.'
'; + $output .= html_print_csrf_hidden(true); $output .= ''; $output .= ''; if ($rawjs) { diff --git a/pandora_console/include/class/NetworkMap.class.php b/pandora_console/include/class/NetworkMap.class.php index 1298fe1ef1..c953b74dec 100644 --- a/pandora_console/include/class/NetworkMap.class.php +++ b/pandora_console/include/class/NetworkMap.class.php @@ -3207,7 +3207,7 @@ class NetworkMap $table->data[0][0] = __('Group'); $table->data[0][1] = html_print_select_groups( false, - 'IW', + 'AR', false, 'group_for_show_agents', -1, diff --git a/pandora_console/include/class/OrderInterpreter.class.php b/pandora_console/include/class/OrderInterpreter.class.php index 947c70c953..e5b347d58f 100644 --- a/pandora_console/include/class/OrderInterpreter.class.php +++ b/pandora_console/include/class/OrderInterpreter.class.php @@ -424,7 +424,7 @@ class OrderInterpreter extends Wizard } if ($iterator === 0) { - echo __('No results found'); + echo __('Press enter to search'); } echo ''; diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index dc0dca6df4..6050bffa2e 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -279,8 +279,10 @@ class Tree protected function getTagJoin() { - return 'INNER JOIN ttag_module ttm - ON tam.id_agente_modulo = ttm.id_agente_modulo'; + return 'INNER JOIN tagente_modulo tam + ON ta.id_agente = tam.id_agente + INNER JOIN ttag_module ttm + ON tam.id_agente_modulo = ttm.id_agente_modulo'; } @@ -931,11 +933,16 @@ class Tree $agent_status_filter = $this->getAgentStatusFilter(); $module_search_filter = $this->getModuleSearchFilter(); $module_status_inner = ''; - $module_status_filter = $this->getModuleStatusFilterFromTestado(); - if (!empty($module_status_filter)) { - $module_status_inner = ' - INNER JOIN tagente_estado tae - ON tae.id_agente_modulo = tam.id_agente_modulo'; + $module_search_inner = ''; + $module_search_filter = ''; + if (!empty($this->filter['searchModule'])) { + $module_search_inner = ' + INNER JOIN tagente_modulo tam + ON ta.id_agente = tam.id_agente + INNER JOIN tagente_estado tae + ON tae.id_agente_modulo = tam.id_agente_modulo'; + $module_search_filter = "AND tam.disabled = 0 + AND tam.nombre LIKE '%%".$this->filter['searchModule']."%%' ".$this->getModuleStatusFilterFromTestado(); } $sql_model = "SELECT %s FROM @@ -944,13 +951,11 @@ class Tree FROM tagente ta LEFT JOIN tagent_secondary_group tasg ON ta.id_agente = tasg.id_agent - INNER JOIN tagente_modulo tam - ON ta.id_agente = tam.id_agente $inner_inside $module_status_inner $group_inner + $module_search_inner WHERE ta.disabled = 0 - AND tam.disabled = 0 %s $agent_search_filter $agent_status_filter @@ -973,6 +978,7 @@ class Tree $inner GROUP BY g ORDER BY $order_by_final"; + hd($sql, true); return $sql; } @@ -1020,7 +1026,7 @@ class Tree $agent_search_filter = $this->getAgentSearchFilter(); $agent_status_filter = $this->getAgentStatusFilter(); $module_search_filter = $this->getModuleSearchFilter(); - $module_status_filter = $this->getModuleStatusFilterFromTestado($this->filter['statusModule']); + $module_status_filter = $this->getModuleStatusFilter(); $condition = $this->L2condition; $condition_inside = $this->L2conditionInside; diff --git a/pandora_console/include/class/TreeModuleGroup.class.php b/pandora_console/include/class/TreeModuleGroup.class.php index b5cec41370..9b8d39fd6f 100644 --- a/pandora_console/include/class/TreeModuleGroup.class.php +++ b/pandora_console/include/class/TreeModuleGroup.class.php @@ -31,6 +31,8 @@ class TreeModuleGroup extends Tree 'tmg.id_mg AS id', ]; $this->L1inner = 'INNER JOIN tmodule_group tmg ON tmg.id_mg = x2.g'; + $this->L1innerInside = 'INNER JOIN tagente_modulo tam + ON ta.id_agente = tam.id_agente'; $this->L1orderByFinal = 'tmg.name'; $this->L2condition = 'AND tam.id_module_group = '.$this->rootID; diff --git a/pandora_console/include/class/TreeTag.class.php b/pandora_console/include/class/TreeTag.class.php index 280d34fa2b..87d05a644b 100644 --- a/pandora_console/include/class/TreeTag.class.php +++ b/pandora_console/include/class/TreeTag.class.php @@ -27,6 +27,8 @@ class TreeTag extends Tree $this->L1fieldName = 'id_tag'; $this->L1fieldNameSql = 'ttm.id_tag'; $this->L1innerInside = ' + INNER JOIN tagente_modulo tam + ON ta.id_agente = tam.id_agente INNER JOIN ttag_module ttm ON ttm.id_agente_modulo = tam.id_agente_modulo '; diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index ac57a8e236..d18146b678 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC210513'; +$build_version = 'PC210528'; $pandora_version = 'v7.0NG.754'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 32312238ce..e483bebaa8 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -2281,9 +2281,6 @@ function check_login($output=true) * Check access privileges to resources * * Access can be: - * IR - Incident/report Read - * IW - Incident/report Write - * IM - Incident/report Management * AR - Agent Read * AW - Agent Write * LW - Alert Write @@ -2374,9 +2371,6 @@ function check_acl_one_of_groups($id_user, $groups, $access, $cache=true) * Check access privileges to resources (write or management is not allowed for 'all' group ) * * Access can be: - * IR - Incident/report Read - * IW - Incident/report Write - * IM - Incident/report Management * AR - Agent Read * AW - Agent Write * LW - Alert Write @@ -2445,18 +2439,6 @@ function check_acl_restricted_all($id_user, $id_group, $access, $onlyOneGroup=fa function get_acl_column($access) { switch ($access) { - case 'IR': - return 'incident_view'; - - break; - case 'IW': - return 'incident_edit'; - - break; - case 'IM': - return 'incident_management'; - - break; case 'AR': return 'agent_view'; @@ -2552,10 +2534,7 @@ function get_users_acl($id_user) $rowdup = $users_acl_cache[$id_user]; } else { $query = sprintf( - "SELECT sum(tperfil.incident_view) as incident_view, - sum(tperfil.incident_edit) as incident_edit, - sum(tperfil.incident_management) as incident_management, - sum(tperfil.agent_view) as agent_view, + "SELECT sum(tperfil.agent_view) as agent_view, sum(tperfil.agent_edit) as agent_edit, sum(tperfil.alert_edit) as alert_edit, sum(tperfil.alert_management) as alert_management, @@ -5960,27 +5939,57 @@ function get_data_multiplier($unit) /** * Send test email to check email setups. * - * @param string $to Target email account. + * @param string $to Target email account. + * @param array $params Array with connection data. + * Available fields: + * 'email_smtpServer', + * 'email_smtpPort', + * 'email_username', + * 'email_password', + * 'email_encryption', + * 'email_from_dir', + * 'email_from_name', * * @return integer Status of the email send task. */ function send_test_email( - string $to + string $to, + array $params=null ) { global $config; + $valid_params = [ + 'email_smtpServer', + 'email_smtpPort', + 'email_username', + 'email_password', + 'email_encryption', + 'email_from_dir', + 'email_from_name', + ]; + + if (empty($params) === true) { + foreach ($valid_params as $token) { + $params[$token] = $config[$token]; + } + } else { + if (array_diff($valid_params, array_keys($params)) === false) { + return false; + } + } + $result = false; try { $transport = new Swift_SmtpTransport( - $config['email_smtpServer'], - $config['email_smtpPort'] + $params['email_smtpServer'], + $params['email_smtpPort'] ); - $transport->setUsername($config['email_username']); - $transport->setPassword($config['email_password']); + $transport->setUsername($params['email_username']); + $transport->setPassword($params['email_password']); - if ($config['email_encryption']) { - $transport->setEncryption($config['email_encryption']); + if ($params['email_encryption']) { + $transport->setEncryption($params['email_encryption']); } $mailer = new Swift_Mailer($transport); @@ -5989,8 +5998,8 @@ function send_test_email( $message->setFrom( [ - $config['email_from_dir'] => io_safe_output( - $config['email_from_name'] + $params['email_from_dir'] => io_safe_output( + $params['email_from_name'] ), ] ); diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 68fc23a7ac..03fb8b9be2 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -503,7 +503,7 @@ function api_get_groups($thrash1, $thrash2, $other, $returnType, $user_in_db) $returnAllColumns = ( $other['data'][2] == '1' ? true : false); } - $groups = users_get_groups($user_in_db, 'IR', $returnAllGroup, $returnAllColumns); + $groups = users_get_groups($user_in_db, 'AR', $returnAllGroup, $returnAllColumns); $data_groups = []; foreach ($groups as $id => $group) { @@ -7541,6 +7541,305 @@ function api_set_planned_downtimes_additem($id, $thrash1, $other, $thrash3) } +/** + * Edit planned Downtime. + * e.g.: api.php?op=set&op2=planned_downtimes_edit&apipass=1234&user=admin&pass=pandora&id=2&other=testing2|test2|2021/05/10|2021/06/12|19:03:03|19:55:00|0|0|0|0|0|0|0|0|1|31|quiet|once|weekly&other_mode=url_encode_separator_| + * + * @param $id id of planned downtime. + * @param $thrash1 Don't use. + * @param array $other + * The first index contains a list of agent Ids. + * The second index contains a list of module names. + * The list separator is the character ';'. + * @param $thrash3 Don't use. + */ +function api_set_planned_downtimes_edit($id, $thrash1, $other, $thrash3) +{ + global $config; + + if (defined('METACONSOLE')) { + return; + } + + if (!check_acl($config['id_user'], 0, 'PM')) { + returnError('forbidden', 'string'); + return; + } + + if ($id == '') { + returnError( + 'id cannot be left blank.' + ); + return; + } + + if (db_get_value('id', 'tplanned_downtime', 'id', $id) === false) { + returnError( + 'id does not exist' + ); + return; + } + + if ($other['data'] == '') { + returnError( + 'data cannot be left blank.' + ); + return; + } + + $values = []; + if (!empty($other['data'][0])) { + $values['name'] = io_safe_input($other['data'][0]); + } + + if (!empty($other['data'][1])) { + $values['description'] = io_safe_input($other['data'][1]); + } + + if (!empty($other['data'][2]) && !empty($other['data'][4])) { + $date_from = strtotime(html_entity_decode($other['data'][2].' '.$other['data'][4])); + $values['date_from'] = io_safe_input($date_from); + } + + if (!empty($other['data'][4])) { + $values['periodically_time_from'] = io_safe_input($other['data'][4]); + } + + if (!empty($other['data'][3]) && !empty($other['data'][5])) { + $date_to = strtotime(html_entity_decode($other['data'][3].' '.$other['data'][5])); + $values['date_to'] = io_safe_input($date_to); + } + + if (!empty($other['data'][5])) { + $values['periodically_time_to'] = io_safe_input($other['data'][5]); + } + + if ($other['data'][6] != '') { + $values['id_group'] = io_safe_input($other['data'][6]); + } + + if ($other['data'][7] != '') { + $values['monday'] = io_safe_input($other['data'][7]); + } + + if ($other['data'][8] != '') { + $values['tuesday'] = io_safe_input($other['data'][8]); + } + + if ($other['data'][9] != '') { + $values['wednesday'] = io_safe_input($other['data'][9]); + } + + if ($other['data'][10] != '') { + $values['thursday'] = io_safe_input($other['data'][10]); + } + + if ($other['data'][11] != '') { + $values['friday'] = io_safe_input($other['data'][11]); + } + + if ($other['data'][12] != '') { + $values['saturday'] = io_safe_input($other['data'][12]); + } + + if ($other['data'][13] != '') { + $values['sunday'] = io_safe_input($other['data'][13]); + } + + if (!empty($other['data'][14])) { + $values['periodically_day_from'] = io_safe_input($other['data'][14]); + } + + if (!empty($other['data'][15])) { + $values['periodically_day_to'] = io_safe_input($other['data'][15]); + } + + if (!empty($other['data'][16])) { + $values['type_downtime'] = io_safe_input($other['data'][16]); + } + + if (!empty($other['data'][17])) { + $values['type_execution'] = io_safe_input($other['data'][17]); + } + + if (!empty($other['data'][18])) { + $values['type_periodicity'] = io_safe_input($other['data'][18]); + } + + $res = db_process_sql_update('tplanned_downtime', $values, ['id' => $id]); + + if ($res === false) { + returnError('Planned downtime could not be updated'); + } else { + returnData( + 'string', + [ + 'type' => 'string', + 'data' => __('Planned downtime updated'), + ] + ); + } +} + + +/** + * Delete agents in planned Downtime. + * e.g.: pi.php?op=set&op2=planned_downtimes_delete_agents&apipass=1234&user=admin&pass=pandora&id=4&other=1;2;3&other_mode=url_encode_separator_| + * + * @param $id id of planned downtime. + * @param $thrash1 Don't use. + * @param array $other + * The first index contains a list of agent Ids. + * The list separator is the character ';'. + * @param $thrash3 Don't use. + */ +function api_set_planned_downtimes_delete_agents($id, $thrash1, $other, $thrash3) +{ + global $config; + + if (defined('METACONSOLE')) { + return; + } + + if (!check_acl($config['id_user'], 0, 'PM')) { + returnError('forbidden', 'string'); + return; + } + + if ($id == '') { + returnError( + 'id cannot be left blank.' + ); + return; + } + + if (db_get_value('id', 'tplanned_downtime', 'id', $id) === false) { + returnError( + 'id does not exist' + ); + return; + } + + if ($other['data'] == '') { + returnError( + 'data cannot be left blank.' + ); + return; + } + + if (!empty($other['data'][0])) { + $agents = io_safe_input($other['data']); + $agents = explode(';', $agents); + $results = false; + foreach ($agents as $agent) { + if (db_get_value_sql(sprintf('SELECT id from tplanned_downtime_agents WHERE id_agent = %d AND id_downtime = %d', $agent, $id)) !== false) { + $result = db_process_sql_delete('tplanned_downtime_agents', ['id_agent' => $agent]); + db_process_sql_delete('tplanned_downtime_modules', ['id_agent' => $agent]); + + if ($result == false) { + returnError(" Agent $agent could not be deleted."); + } else { + $results = true; + } + } else { + returnError(" Agent $agent is not in planned downtime."); + } + } + + if ($results) { + returnData( + 'string', + [ + 'type' => 'string', + 'data' => __(' Agents deleted'), + ] + ); + } + } +} + + +/** + * Add agents planned Downtime. + * e.g.: api.php?op=set&op2=planned_downtimes_add_agents&apipass=1234&user=admin&pass=pandora&id=4&other=1;2;3&other_mode=url_encode_separator_| + * + * @param $id id of planned downtime. + * @param $thrash1 Don't use. + * @param array $other + * The first index contains a list of agent Ids. + * The list separator is the character ';'. + * @param $thrash3 Don't use. + */ +function api_set_planned_downtimes_add_agents($id, $thrash1, $other, $thrash3) +{ + global $config; + + if (defined('METACONSOLE')) { + return; + } + + if (!check_acl($config['id_user'], 0, 'PM')) { + returnError('forbidden', 'string'); + return; + } + + if ($id == '') { + returnError( + 'id cannot be left blank.' + ); + return; + } + + if (db_get_value('id', 'tplanned_downtime', 'id', $id) === false) { + returnError( + 'id does not exist' + ); + return; + } + + if ($other['data'] == '') { + returnError( + 'data cannot be left blank.' + ); + return; + } + + if (!empty($other['data'][0])) { + $agents = io_safe_input($other['data']); + $agents = explode(';', $agents); + $results = false; + foreach ($agents as $agent) { + if (db_get_value_sql(sprintf('SELECT id from tplanned_downtime_agents tpd WHERE tpd.id_agent = %d AND id_downtime = %d', $agent, $id)) === false) { + $res = db_process_sql_insert( + 'tplanned_downtime_agents', + [ + 'id_agent' => $agent, + 'id_downtime' => $id, + 'all_modules' => 0, + 'manually_disabled' => 0, + ] + ); + if ($res) { + $results = true; + } + } else { + returnError(" Agent $agent is already at the planned downtime."); + } + } + + if ($results) { + returnData( + 'string', + [ + 'type' => 'string', + 'data' => __(' Agents added'), + ] + ); + } + } +} + + /** * Update data module in policy. And return id from new module. * @@ -11672,9 +11971,6 @@ function api_get_user_profiles_info($thrash1, $thrash2, $thrash3, $returnType) [ 'id_perfil', 'name', - 'incident_view as IR', - 'incident_edit as IW', - 'incident_management as IM', 'agent_view as AR', 'agent_edit as AW', 'agent_disable as AD', @@ -11727,29 +12023,26 @@ function api_set_create_user_profile_info($thrash1, $thrash2, $other, $returnTyp $values = [ 'name' => (string) $other['data'][0], - 'incident_view' => (bool) $other['data'][1] ? 1 : 0, - 'incident_edit' => (bool) $other['data'][2] ? 1 : 0, - 'incident_management' => (bool) $other['data'][3] ? 1 : 0, - 'agent_view' => (bool) $other['data'][4] ? 1 : 0, - 'agent_edit' => (bool) $other['data'][5] ? 1 : 0, - 'agent_disable' => (bool) $other['data'][6] ? 1 : 0, - 'alert_edit' => (bool) $other['data'][7] ? 1 : 0, - 'alert_management' => (bool) $other['data'][8] ? 1 : 0, - 'user_management' => (bool) $other['data'][9] ? 1 : 0, - 'db_management' => (bool) $other['data'][10] ? 1 : 0, - 'event_view' => (bool) $other['data'][11] ? 1 : 0, - 'event_edit' => (bool) $other['data'][12] ? 1 : 0, - 'event_management' => (bool) $other['data'][13] ? 1 : 0, - 'report_view' => (bool) $other['data'][14] ? 1 : 0, - 'report_edit' => (bool) $other['data'][15] ? 1 : 0, - 'report_management' => (bool) $other['data'][16] ? 1 : 0, - 'map_view' => (bool) $other['data'][17] ? 1 : 0, - 'map_edit' => (bool) $other['data'][18] ? 1 : 0, - 'map_management' => (bool) $other['data'][19] ? 1 : 0, - 'vconsole_view' => (bool) $other['data'][20] ? 1 : 0, - 'vconsole_edit' => (bool) $other['data'][21] ? 1 : 0, - 'vconsole_management' => (bool) $other['data'][22] ? 1 : 0, - 'pandora_management' => (bool) $other['data'][23] ? 1 : 0, + 'agent_view' => (bool) $other['data'][1] ? 1 : 0, + 'agent_edit' => (bool) $other['data'][2] ? 1 : 0, + 'agent_disable' => (bool) $other['data'][3] ? 1 : 0, + 'alert_edit' => (bool) $other['data'][4] ? 1 : 0, + 'alert_management' => (bool) $other['data'][5] ? 1 : 0, + 'user_management' => (bool) $other['data'][6] ? 1 : 0, + 'db_management' => (bool) $other['data'][7] ? 1 : 0, + 'event_view' => (bool) $other['data'][8] ? 1 : 0, + 'event_edit' => (bool) $other['data'][9] ? 1 : 0, + 'event_management' => (bool) $other['data'][10] ? 1 : 0, + 'report_view' => (bool) $other['data'][11] ? 1 : 0, + 'report_edit' => (bool) $other['data'][12] ? 1 : 0, + 'report_management' => (bool) $other['data'][13] ? 1 : 0, + 'map_view' => (bool) $other['data'][14] ? 1 : 0, + 'map_edit' => (bool) $other['data'][15] ? 1 : 0, + 'map_management' => (bool) $other['data'][16] ? 1 : 0, + 'vconsole_view' => (bool) $other['data'][17] ? 1 : 0, + 'vconsole_edit' => (bool) $other['data'][18] ? 1 : 0, + 'vconsole_management' => (bool) $other['data'][19] ? 1 : 0, + 'pandora_management' => (bool) $other['data'][20] ? 1 : 0, ]; $return = db_process_sql_insert('tperfil', $values); @@ -11789,29 +12082,26 @@ function api_set_update_user_profile_info($id_profile, $thrash1, $other, $return $values = [ 'name' => $other['data'][0] == '' ? $profile['name'] : (string) $other['data'][0], - 'incident_view' => $other['data'][1] == '' ? $profile['incident_view'] : (bool) $other['data'][1] ? 1 : 0, - 'incident_edit' => $other['data'][2] == '' ? $profile['incident_edit'] : (bool) $other['data'][2] ? 1 : 0, - 'incident_management' => $other['data'][3] == '' ? $profile['incident_management'] : (bool) $other['data'][3] ? 1 : 0, - 'agent_view' => $other['data'][4] == '' ? $profile['agent_view'] : (bool) $other['data'][4] ? 1 : 0, - 'agent_edit' => $other['data'][5] == '' ? $profile['agent_edit'] : (bool) $other['data'][5] ? 1 : 0, - 'agent_disable' => $other['data'][6] == '' ? $profile['agent_disable'] : (bool) $other['data'][6] ? 1 : 0, - 'alert_edit' => $other['data'][7] == '' ? $profile['alert_edit'] : (bool) $other['data'][7] ? 1 : 0, - 'alert_management' => $other['data'][8] == '' ? $profile['alert_management'] : (bool) $other['data'][8] ? 1 : 0, - 'user_management' => $other['data'][9] == '' ? $profile['user_management'] : (bool) $other['data'][9] ? 1 : 0, - 'db_management' => $other['data'][10] == '' ? $profile['db_management'] : (bool) $other['data'][10] ? 1 : 0, - 'event_view' => $other['data'][11] == '' ? $profile['event_view'] : (bool) $other['data'][11] ? 1 : 0, - 'event_edit' => $other['data'][12] == '' ? $profile['event_edit'] : (bool) $other['data'][12] ? 1 : 0, - 'event_management' => $other['data'][13] == '' ? $profile['event_management'] : (bool) $other['data'][13] ? 1 : 0, - 'report_view' => $other['data'][14] == '' ? $profile['report_view'] : (bool) $other['data'][14] ? 1 : 0, - 'report_edit' => $other['data'][15] == '' ? $profile['report_edit'] : (bool) $other['data'][15] ? 1 : 0, - 'report_management' => $other['data'][16] == '' ? $profile['report_management'] : (bool) $other['data'][16] ? 1 : 0, - 'map_view' => $other['data'][17] == '' ? $profile['map_view'] : (bool) $other['data'][17] ? 1 : 0, - 'map_edit' => $other['data'][18] == '' ? $profile['map_edit'] : (bool) $other['data'][18] ? 1 : 0, - 'map_management' => $other['data'][19] == '' ? $profile['map_management'] : (bool) $other['data'][19] ? 1 : 0, - 'vconsole_view' => $other['data'][20] == '' ? $profile['vconsole_view'] : (bool) $other['data'][20] ? 1 : 0, - 'vconsole_edit' => $other['data'][21] == '' ? $profile['vconsole_edit'] : (bool) $other['data'][21] ? 1 : 0, - 'vconsole_management' => $other['data'][22] == '' ? $profile['vconsole_management'] : (bool) $other['data'][22] ? 1 : 0, - 'pandora_management' => $other['data'][23] == '' ? $profile['pandora_management'] : (bool) $other['data'][23] ? 1 : 0, + 'agent_view' => $other['data'][1] == '' ? $profile['agent_view'] : (bool) $other['data'][1] ? 1 : 0, + 'agent_edit' => $other['data'][2] == '' ? $profile['agent_edit'] : (bool) $other['data'][2] ? 1 : 0, + 'agent_disable' => $other['data'][3] == '' ? $profile['agent_disable'] : (bool) $other['data'][3] ? 1 : 0, + 'alert_edit' => $other['data'][4] == '' ? $profile['alert_edit'] : (bool) $other['data'][4] ? 1 : 0, + 'alert_management' => $other['data'][5] == '' ? $profile['alert_management'] : (bool) $other['data'][5] ? 1 : 0, + 'user_management' => $other['data'][6] == '' ? $profile['user_management'] : (bool) $other['data'][6] ? 1 : 0, + 'db_management' => $other['data'][7] == '' ? $profile['db_management'] : (bool) $other['data'][7] ? 1 : 0, + 'event_view' => $other['data'][8] == '' ? $profile['event_view'] : (bool) $other['data'][8] ? 1 : 0, + 'event_edit' => $other['data'][9] == '' ? $profile['event_edit'] : (bool) $other['data'][9] ? 1 : 0, + 'event_management' => $other['data'][10] == '' ? $profile['event_management'] : (bool) $other['data'][10] ? 1 : 0, + 'report_view' => $other['data'][11] == '' ? $profile['report_view'] : (bool) $other['data'][11] ? 1 : 0, + 'report_edit' => $other['data'][12] == '' ? $profile['report_edit'] : (bool) $other['data'][12] ? 1 : 0, + 'report_management' => $other['data'][13] == '' ? $profile['report_management'] : (bool) $other['data'][13] ? 1 : 0, + 'map_view' => $other['data'][14] == '' ? $profile['map_view'] : (bool) $other['data'][14] ? 1 : 0, + 'map_edit' => $other['data'][15] == '' ? $profile['map_edit'] : (bool) $other['data'][15] ? 1 : 0, + 'map_management' => $other['data'][16] == '' ? $profile['map_management'] : (bool) $other['data'][16] ? 1 : 0, + 'vconsole_view' => $other['data'][17] == '' ? $profile['vconsole_view'] : (bool) $other['data'][17] ? 1 : 0, + 'vconsole_edit' => $other['data'][18] == '' ? $profile['vconsole_edit'] : (bool) $other['data'][18] ? 1 : 0, + 'vconsole_management' => $other['data'][19] == '' ? $profile['vconsole_management'] : (bool) $other['data'][19] ? 1 : 0, + 'pandora_management' => $other['data'][20] == '' ? $profile['pandora_management'] : (bool) $other['data'][20] ? 1 : 0, ]; $return = db_process_sql_update('tperfil', $values, ['id_perfil' => $id_profile]); @@ -11859,101 +12149,6 @@ function api_set_delete_user_profile_info($id_profile, $thrash1, $thrash2, $retu } -/** - * Create new incident in Pandora. - * - * @param $thrash1 Don't use. - * @param $thrash2 Don't use. - * @param array $other it's array, $other as param is ;<description>; - * <origin>;<priority>;<state>;<group> in this order and separator char - * (after text ; ) and separator (pass in param othermode as - * othermode=url_encode_separator_<separator>) - * example: - * - * api.php?op=set&op2=new_incident&other=titulo|descripcion%20texto|Logfiles|2|10|12&other_mode=url_encode_separator_| - * - * @param $thrash3 Don't use. - */ -function api_set_new_incident($thrash1, $thrash2, $other, $thrash3) -{ - global $config; - - if (defined('METACONSOLE')) { - return; - } - - if (!check_acl($config['id_user'], 0, 'IW')) { - returnError('forbidden', 'string'); - return; - } - - $title = $other['data'][0]; - $description = $other['data'][1]; - $origin = $other['data'][2]; - $priority = $other['data'][3]; - $id_creator = 'API'; - $state = $other['data'][4]; - $group = $other['data'][5]; - - $values = [ - 'inicio' => 'NOW()', - 'actualizacion' => 'NOW()', - 'titulo' => $title, - 'descripcion' => $description, - 'id_usuario' => 'API', - 'origen' => $origin, - 'estado' => $state, - 'prioridad' => $priority, - 'id_grupo' => $group, - 'id_creator' => $id_creator, - ]; - $idIncident = db_process_sql_insert('tincidencia', $values); - - if ($idIncident === false) { - returnError('A new incident could not be created.'); - } else { - returnData('string', ['type' => 'string', 'data' => $idIncident]); - } -} - - -/** - * Add note into a incident. - * - * @param $id string Username author of note. - * @param $id2 integer ID of incident. - * @param $other string Note. - * @param $thrash2 Don't use. - */ -function api_set_new_note_incident($id, $id2, $other, $thrash2) -{ - global $config; - - if (defined('METACONSOLE')) { - return; - } - - if (!check_acl($config['id_user'], 0, 'IW')) { - returnError('forbidden', 'string'); - return; - } - - $values = [ - 'id_usuario' => $id, - 'id_incident' => $id2, - 'nota' => $other['data'], - ]; - - $idNote = db_process_sql_insert('tnota', $values); - - if ($idNote === false) { - returnError('A new incident could not be created+.'); - } else { - returnData('string', ['type' => 'string', 'data' => $idNote]); - } -} - - /** * Disable a module, given agent and module name. * @@ -12922,8 +13117,10 @@ function api_set_create_event($id, $trash1, $other, $returnType) $error_msg = ''; if ($other['data'][2] != '') { + // Id agent assignment. If come from pandora_revent, id_agent can be 0. $id_agent = $other['data'][2]; - if (is_metaconsole()) { + // To the next if is metaconsole and id_agent is not none. + if (is_metaconsole() === true && $id_agent > 0) { // On metaconsole, connect with the node to check the permissions if (empty($values['server_id'])) { $agent_cache = db_get_row('tmetaconsole_agent', 'id_tagente', $id_agent); @@ -12946,7 +13143,7 @@ function api_set_create_event($id, $trash1, $other, $returnType) $values['id_agente'] = $id_agent; - if (!util_api_check_agent_and_print_error($id_agent, 'string', 'AR')) { + if ((int) $id_agent > 0 && util_api_check_agent_and_print_error($id_agent, 'string', 'AR') === false) { if (is_metaconsole()) { metaconsole_restore_db(); } diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index e118cf4d52..3920109890 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -1032,6 +1032,14 @@ function config_update_config() $error_update[] = __('Custom subtitle header'); } + if (!config_update_value('meta_custom_title_header', (string) get_parameter('meta_custom_title_header'))) { + $error_update[] = __('Meta custom title header'); + } + + if (!config_update_value('meta_custom_subtitle_header', (string) get_parameter('meta_custom_subtitle_header'))) { + $error_update[] = __('Meta custom subtitle header'); + } + if (!config_update_value('custom_title1_login', (string) get_parameter('custom_title1_login'))) { $error_update[] = __('Custom title1 login'); } @@ -1060,10 +1068,6 @@ function config_update_config() $error_update[] = __('Copyright notice'); } - if (!config_update_value('meta_custom_logo', (string) get_parameter('meta_custom_logo'))) { - $error_update[] = __('Custom logo metaconsole'); - } - if (!config_update_value('meta_custom_logo_white_bg', (string) get_parameter('meta_custom_logo_white_bg'))) { $error_update[] = __('Custom logo metaconsole (white background)'); } @@ -1642,6 +1646,10 @@ function config_update_config() break; case 'integria': + if (!config_update_value('integria_user_level_conf', (int) get_parameter('integria_user_level_conf', 0))) { + $error_update[] = __('Integria user login'); + } + if (!config_update_value('integria_enabled', (int) get_parameter('integria_enabled', 0))) { $error_update[] = __('Enable Integria IMS'); } @@ -2287,6 +2295,20 @@ function config_process_config() config_update_value('custom_logo_collapsed', 'pandora_logo_green_collapsed.png'); } + if (is_metaconsole()) { + if (!isset($config['meta_custom_logo'])) { + config_update_value('meta_custom_logo', 'pandoraFMS_metaconsole_full.svg'); + } + + if (!isset($config['meta_custom_logo_collapsed'])) { + config_update_value('meta_custom_logo_collapsed', 'pandoraFMS_metaconsole_collapse.svg'); + } + + if (!isset($config['meta_menu_type'])) { + config_update_value('meta_menu_type', 'classic'); + } + } + if (!isset($config['custom_logo_white_bg'])) { config_update_value('custom_logo_white_bg', 'pandora_logo_head_white_bg.png'); } @@ -2323,6 +2345,14 @@ function config_process_config() config_update_value('custom_subtitle_header', __('the Flexible Monitoring System')); } + if (!isset($config['meta_custom_title_header'])) { + config_update_value('meta_custom_title_header', __('PandoraFMS Metaconsole')); + } + + if (!isset($config['meta_custom_subtitle_header'])) { + config_update_value('meta_custom_subtitle_header', __('Centralized operation console')); + } + if (!isset($config['custom_title1_login'])) { config_update_value('custom_title1_login', __('PANDORA FMS')); } @@ -2355,10 +2385,6 @@ function config_process_config() config_update_value('meta_custom_support_url', 'https://support.pandorafms.com'); } - if (!isset($config['meta_custom_logo'])) { - config_update_value('meta_custom_logo', 'logo_pandora_metaconsola.png'); - } - if (!isset($config['meta_custom_logo_white_bg'])) { config_update_value('pandora_logo_head_white_bg', 'pandora_logo_head_white_bg.png'); } @@ -3244,6 +3270,10 @@ function config_process_config() } // Integria. + if (!isset($config['integria_user_level_conf'])) { + config_update_value('integria_user_level_conf', 0); + } + if (!isset($config['integria_enabled'])) { config_update_value('integria_enabled', 0); } diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index f7d264d0c4..26a46eae7b 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -374,7 +374,7 @@ function db_get_value_filter($field, $table, $filter, $where_join='AND', $search * * @param string SQL select statement to execute. * - * @return the first value of the first row of a table result from query. + * @return mixed the first value of the first row of a table result from query. */ function db_get_value_sql($sql, $dbconnection=false) { diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 348e72424b..c1d7aeb404 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -3152,10 +3152,6 @@ function events_get_agent( } } - if (is_metaconsole() === true && empty($id_server) === false) { - $sql_where .= ' AND server_id = '.$id_server; - } - if ($show_summary_group) { return events_get_events_grouped( $sql_where, @@ -3169,7 +3165,7 @@ function events_get_agent( } else { return events_get_events_no_grouped( $sql_where, - (is_metaconsole() === true && empty($id_server) === false) ? true : false, + (is_metaconsole() === true && (int) $id_server === 0) ? true : false, $history ); } diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 0546945b40..fea7a23609 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -2978,9 +2978,9 @@ function grafico_incidente_prioridad() { global $config; - $integria_ticket_count_by_priority_json = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_tickets_count', ['prioridad', 30], false, '', '|;|'); + $integria_ticket_count_by_priority_json = integria_api_call(null, null, null, null, 'get_tickets_count', ['prioridad', 30], false, '', '|;|'); - $integria_priorities_map_json = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_priorities', '', false, 'json'); + $integria_priorities_map_json = integria_api_call(null, null, null, null, 'get_incident_priorities', '', false, 'json'); $integria_ticket_count_by_priority = json_decode($integria_ticket_count_by_priority_json, true); $integria_priorities_map = json_decode($integria_priorities_map_json, true); @@ -3023,9 +3023,9 @@ function graph_incidents_status() { global $config; - $integria_ticket_count_by_status_json = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_tickets_count', ['estado', 30], false, '', '|;|'); + $integria_ticket_count_by_status_json = integria_api_call(null, null, null, null, 'get_tickets_count', ['estado', 30], false, '', '|;|'); - $integria_status_map_json = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incidents_status', '', false, 'json'); + $integria_status_map_json = integria_api_call(null, null, null, null, 'get_incidents_status', '', false, 'json'); $integria_ticket_count_by_status = json_decode($integria_ticket_count_by_status_json, true); $integria_status_map = json_decode($integria_status_map_json, true); @@ -3068,9 +3068,9 @@ function graphic_incident_group() { global $config; - $integria_ticket_count_by_group_json = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_tickets_count', ['id_grupo', 30], false, '', '|;|'); + $integria_ticket_count_by_group_json = integria_api_call(null, null, null, null, 'get_tickets_count', ['id_grupo', 30], false, '', '|;|'); - $integria_group_map_json = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_groups', '', false, 'json'); + $integria_group_map_json = integria_api_call(null, null, null, null, 'get_groups', '', false, 'json'); $integria_ticket_count_by_group = json_decode($integria_ticket_count_by_group_json, true); $integria_group_map = json_decode($integria_group_map_json, true); @@ -3114,7 +3114,7 @@ function graphic_incident_user() { global $config; - $integria_ticket_count_by_user_json = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_tickets_count', ['id_usuario', 30], false, '', '|;|'); + $integria_ticket_count_by_user_json = integria_api_call(null, null, null, null, 'get_tickets_count', ['id_usuario', 30], false, '', '|;|'); $integria_ticket_count_by_user = json_decode($integria_ticket_count_by_user_json, true); diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 11298f6062..d934c7815d 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -4306,10 +4306,14 @@ function html_print_sort_arrows($params, $order_tag, $up='up', $down='down') /** * Print an input hidden with a new csrf token generated + * + * @param boolean $return If it is true return a string with the output instead to echo the output. + * + * @return void */ -function html_print_csrf_hidden() +function html_print_csrf_hidden(bool $return=false) { - html_print_input_hidden('csrf_code', generate_csrf_code()); + return html_print_input_hidden('csrf_code', generate_csrf_code(), $return); } diff --git a/pandora_console/include/functions_integriaims.php b/pandora_console/include/functions_integriaims.php index c117b679e5..c0bc3dfe8e 100644 --- a/pandora_console/include/functions_integriaims.php +++ b/pandora_console/include/functions_integriaims.php @@ -21,6 +21,7 @@ global $config; require_once $config['homedir'].'/include/functions_ui.php'; require_once $config['homedir'].'/include/functions_html.php'; +require_once $config['homedir'].'/include/functions_users.php'; require_once $config['homedir'].'/include/functions.php'; @@ -78,22 +79,10 @@ function integriaims_tabs($active_tab, $view=false) } $onheader = []; - - if (check_acl($config['id_user'], 0, 'IR') && $view) { - $onheader['view'] = $view_tab; - } - - if (check_acl($config['id_user'], 0, 'PM')) { - $onheader['configure'] = $setup_tab; - } - - if (check_acl($config['id_user'], 0, 'IR')) { - $onheader['list'] = $list_tab; - } - - if (check_acl($config['id_user'], 0, 'IW')) { - $onheader['create'] = $create_tab; - } + $onheader['view'] = $view_tab; + $onheader['configure'] = $setup_tab; + $onheader['list'] = $list_tab; + $onheader['create'] = $create_tab; return $onheader; } @@ -137,7 +126,7 @@ function integriaims_get_details($details, $detail_index=false) break; } - $api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], $operation); + $api_call = integria_api_call(null, null, null, null, $operation); $result = []; get_array_from_csv_data_pair($api_call, $result); @@ -165,8 +154,42 @@ function integriaims_get_details($details, $detail_index=false) * * @return boolean True if API request succeeded, false if API request failed. */ -function integria_api_call($api_hostname, $user, $user_pass, $api_pass, $operation, $params='', $show_credentials_error_msg=false, $return_type='', $token='') +function integria_api_call($api_hostname=null, $user=null, $user_pass=null, $api_pass=null, $operation, $params='', $show_credentials_error_msg=false, $return_type='', $token='', $user_level_conf=null) { + global $config; + + if ($user_level_conf === null) { + $user_level_conf = (bool) $config['integria_user_level_conf']; + } + + $user_info = users_get_user_by_id($config['id_user']); + + // API access data. + if ($api_hostname === null) { + $api_hostname = $config['integria_hostname']; + } + + if ($api_pass === null) { + $api_pass = $config['integria_api_pass']; + } + + // Integria user and password. + if ($user === null || $user_level_conf === true) { + $user = $config['integria_user']; + + if ($user_level_conf === true) { + $user = $user_info['integria_user_level_user']; + } + } + + if ($user_pass === null || $user_level_conf === true) { + $user_pass = $config['integria_pass']; + + if ($user_level_conf === true) { + $user_pass = $user_info['integria_user_level_pass']; + } + } + if (is_array($params)) { $params = implode($token, $params); } @@ -352,10 +375,10 @@ function get_tickets_integriaims($tickets_filters) // API call. $result_api_call_list = integria_api_call( - $config['integria_hostname'], - $config['integria_user'], - $config['integria_pass'], - $config['integria_api_pass'], + null, + null, + null, + null, 'get_incidents', [ $incident_text, diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 0a643480f7..1a7548174b 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -218,7 +218,16 @@ function modules_copy_agent_module_to_agent($id_agent_module, $id_destiny_agent, $new_module = $module; // Rewrite different values - $new_module['ip_target'] = agents_get_address($id_destiny_agent); + if ($module['id_tipo_modulo'] == MODULE_TYPE_REMOTE_CMD + || $module['id_tipo_modulo'] == MODULE_TYPE_REMOTE_CMD_PROC + || $module['id_tipo_modulo'] == MODULE_TYPE_REMOTE_CMD_STRING + || $module['id_tipo_modulo'] == MODULE_TYPE_REMOTE_CMD_INC + ) { + $new_module['ip_target'] = $module['ip_target']; + } else { + $new_module['ip_target'] = agents_get_address($id_destiny_agent); + } + $new_module['policy_linked'] = 0; $new_module['id_policy_module'] = 0; diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 69d9a85cd5..cd31986a2a 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -120,7 +120,7 @@ function netflow_check_filter_group($id_sg) $id_group = db_get_value('id_group', 'tnetflow_filter', 'id_sg', $id_sg); $own_info = get_user_info($config['id_user']); // Get group list that user has access. - $groups_user = users_get_groups($config['id_user'], 'IW', $own_info['is_admin'], true); + $groups_user = users_get_groups($config['id_user'], 'AR', $own_info['is_admin'], true); $groups_id = []; $has_permission = false; diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php index ed76a6b880..7e0a467041 100644 --- a/pandora_console/include/functions_networkmap.php +++ b/pandora_console/include/functions_networkmap.php @@ -1500,7 +1500,7 @@ function networkmap_delete_relations($id_map) function get_networkmaps($id) { - $groups = array_keys(users_get_groups(null, 'IW')); + $groups = array_keys(users_get_groups(null, 'MW')); $filter = []; $filter['id_group'] = $groups; diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 73bd978dc9..4ff9e63939 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -1844,6 +1844,7 @@ function reporting_event_report_group( $content['name'] = __('Event Report Group'); } + $id_meta = 0; if (is_metaconsole() === true && empty($content['server_name']) === false) { $id_meta = metaconsole_get_id_server($content['server_name']); $server = metaconsole_get_connection_by_id($id_meta); @@ -1935,7 +1936,7 @@ function reporting_event_report_group( true, false, false, - false, + $id_meta, $filter_event_filter_exclude ); @@ -2183,10 +2184,6 @@ function reporting_event_report_module( ); } - if (is_metaconsole()) { - metaconsole_restore_db(); - } - $return['description'] = $content['description']; $return['show_extended_events'] = $content['show_extended_events']; $return['date'] = reporting_get_date_text($report, $content); @@ -2248,7 +2245,7 @@ function reporting_event_report_module( $return['data'] = array_reverse($data); } - if ($config['metaconsole']) { + if (is_metaconsole() === true) { metaconsole_restore_db(); } @@ -2899,6 +2896,7 @@ function reporting_exception( // Metaconsole connection. $server_name = $exc['server_name']; if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) { + metaconsole_restore_db(); $connection = metaconsole_get_connection($server_name); if (metaconsole_load_external_db($connection) != NOERR) { // ui_print_error_message ("Error connecting to ".$server_name); @@ -3427,10 +3425,6 @@ function reporting_event_report_agent( ); } - if ($config['metaconsole']) { - metaconsole_restore_db(); - } - $label = (isset($content['style']['label'])) ? $content['style']['label'] : ''; if ($label != '') { $label = reporting_label_macro( @@ -3477,9 +3471,14 @@ function reporting_event_report_agent( $filter_event_type, $filter_event_status, $filter_event_filter_search, - $filter_event_filter_exclude + $filter_event_filter_exclude, + $id_server ); + if (is_metaconsole() === true) { + metaconsole_restore_db(); + } + reporting_set_conf_charts( $width, $height, @@ -9765,12 +9764,21 @@ function reporting_get_module_detailed_event( * It construct a table object with all the grouped events happened in an agent * during a period of time. * - * @param mixed Agent id(s) to get the report from. - * @param int Period of time (in seconds) to get the report. - * @param int Beginning date (unixtime) of the report - * @param bool Flag to return or echo the report table (echo by default). + * @param mixed $id_agents Agent id(s) to get the report from. + * @param integer $period Period of time (in seconds) to get the report. + * @param integer $date Beginning date (unixtime) of the report. + * @param boolean $return Flag to return or echo the report table (echo by default). + * @param boolean $only_data Only data. + * @param boolean $history History. + * @param boolean $show_summary_group Show summary group. + * @param boolean $filter_event_severity Filter. + * @param boolean $filter_event_type Filter. + * @param boolean $filter_event_status Filter. + * @param boolean $filter_event_filter_search Filter. + * @param boolean $filter_event_filter_exclude Filter. + * @param integer $id_server Id server. * - * @return A table object (XHTML) + * @return array table object (XHTML) */ function reporting_get_agents_detailed_event( $id_agents, @@ -9784,7 +9792,8 @@ function reporting_get_agents_detailed_event( $filter_event_type=false, $filter_event_status=false, $filter_event_filter_search=false, - $filter_event_filter_exclude=false + $filter_event_filter_exclude=false, + $id_server=0 ) { global $config; @@ -9819,7 +9828,7 @@ function reporting_get_agents_detailed_event( false, false, false, - false, + $id_server, $filter_event_filter_exclude ); diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 0d12af41a9..ecd985d5c3 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -27,6 +27,8 @@ */ // Begin. +global $config; + // Check to avoid error when load this library in error screen situations. if (isset($config['homedir'])) { include_once $config['homedir'].'/include/functions_agents.php'; @@ -4302,6 +4304,101 @@ function ui_get_full_url($url='', $no_proxy=false, $add_name_php_file=false, $me } +/** + * Generates the Pandora 75x Standard views header. + * This function should be the standard for + * generating the headers of all PFMS views. + * + * @param string $title The title of this view. + * @param string $icon Icon for show. + * @param boolean $return If true, the string with the formed header is returned. + * @param string $help String for attach at end a link for help. + * @param boolean $godmode If false, it will created like operation mode. + * @param array $options Tabs allowed + * @param array $breadcrumbs Breadcrumbs with the walk. + * + * EXAMPLE: + * ``` + * $buttons['option_1'] = [ + * 'active' => false, + * 'text' => '<a href="'.$url.'">'.html_print_image( + * 'images/wand.png', + * true, + * [ 'title' => __('Option 1 for show'), 'class' => 'invert_filter' ] + * ).'</a>', + * ]; + * + * ui_print_standard_header( + * __('Favorites'), + * 'images/op_reporting.png', + * false, + * '', + * true, + * $buttons, + * [ + * [ 'link' => '', 'label' => __('Topology maps') ], + * [ 'link' => '', 'label' => __('Visual console') ], + * ] + * ); + * ``` + * + * @return string If apply + */ +function ui_print_standard_header( + string $title, + string $icon='', + bool $return=false, + string $help='', + bool $godmode=false, + array $options=[], + array $breadcrumbs=[] +) { + // For standard breadcrumbs. + ui_require_css_file('discovery'); + // Create the breadcrumb. + $headerInformation = new HTML(); + $headerInformation->setBreadcrum([]); + // Prepare the breadcrumbs. + $countBreadcrumbs = count($breadcrumbs); + $countUnitBreadcrumb = 0; + $applyBreadcrumbs = []; + foreach ($breadcrumbs as $unitBreadcrumb) { + // Count new breadcrumb. + $countUnitBreadcrumb++; + // Apply selected if is the last. + $unitBreadcrumb['selected'] = ($countBreadcrumbs === $countUnitBreadcrumb); + // Apply for another breadcrumb. + $applyBreadcrumbs[] = $unitBreadcrumb; + } + + // Attach breadcrumbs. + $headerInformation->prepareBreadcrum( + $applyBreadcrumbs, + true + ); + // Create the header. + $output = ui_print_page_header( + $title, + $icon, + true, + $help, + $godmode, + $options, + false, + '', + GENERIC_SIZE_TEXT, + '', + $headerInformation->printHeader(true) + ); + + if ($return !== true) { + echo $output; + } else { + return $output; + } +} + + /** * Return a standard page header (Pandora FMS 3.1 version) * diff --git a/pandora_console/include/functions_update_manager.php b/pandora_console/include/functions_update_manager.php index 3c9d23f86c..0b9e755c1d 100755 --- a/pandora_console/include/functions_update_manager.php +++ b/pandora_console/include/functions_update_manager.php @@ -755,43 +755,47 @@ function newsletter_wiz_modal( ); // Avoid to show default email. - if ($email == 'admin@example.com') { + if ($email === 'admin@example.com') { $email = ''; } - $output .= '<div id="newsletter_wizard" title="'; - $output .= __('Do you want to be up to date?'); - $output .= '" class="invisible">'; - $output .= '<div class="register_update_manager">'; - $output .= html_print_image('images/pandora_circle_big.png', true); - $output .= '</div>'; - - $output .= '<div class="newsletter_div">'; - $output .= __( - 'Subscribe to our newsletter', - $product_name - ); - $output .= '</div>'; - - $output .= '<div class="license_text both">'; - $output .= '<p>Stay up to date with updates, upgrades and promotions by subscribing to our newsletter.</p>'; - $output .= '<p>'; - $output .= __( - 'By subscribing to the newsletter, you accept that your email will be transferred to a database owned by %s. These data will be used only to provide you with information about %s and will not be given to third parties. You can unsubscribe from this database at any time from the newsletter subscription options.', - $product_name, - $product_name + $modalContent = html_print_div( + [ + 'class' => 'register_update_manager', + 'content' => html_print_image( + 'images/pandora_circle_big.png', + true + ), + ], + true ); - $output .= '</p>'; + $modalContent .= html_print_div( + [ + 'class' => 'newsletter_div', + 'content' => __('Subscribe to our newsletter'), + ], + true + ); - $output .= '</div>'; - // Show regiter to newsletter state. - $show_newsletter = ($display_newsletter !== true) ? 'inline-block' : 'none'; + $modalContent .= html_print_div( + [ + 'class' => 'license_text both', + 'content' => sprintf( + '<p>%s</p><p>%s</p>', + __('Stay up to date with updates, upgrades and promotions by subscribing to our newsletter.'), + __( + 'By subscribing to the newsletter, you accept that your email will be transferred to a database owned by %s. These data will be used only to provide you with information about %s and will not be given to third parties. You can unsubscribe from this database at any time from the newsletter subscription options.', + $product_name, + $product_name + ) + ), + ], + true + ); - $output .= '<div class="mrgn_lft_4em">'; - $output .= '<div id="box_newsletter">'; - $output .= '<span id="label-email-newsletter">'.__('Email').' </span>'; - $output .= html_print_input_text_extended( + // Email Input case. + $emailInputCase = '<span id="label-email-newsletter">'.__('Email').' </span>'.html_print_input_text_extended( 'email-newsletter', $email, 'text-email-newsletter', @@ -800,52 +804,110 @@ function newsletter_wiz_modal( 255, false, '', - ['style' => 'display:'.$show_newsletter.'; width: 200px;'], + ['style' => 'display: inline-block; width: 200px;'], true ); - $output .= '</div><br /><br />'; - $output .= '<div class="submit_buttons_container">'; - $output .= '<div class="left">'; - $output .= html_print_submit_button( - __('Cancel'), - 'cancel_newsletter', - false, - 'class="ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel w100px"', + // Generate the submit buttons. + // Cancel Button. + $submitButtons = html_print_div( + [ + 'class' => 'left', + 'content' => html_print_submit_button( + __('Cancel'), + 'cancel_newsletter', + false, + 'class="ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel w100px"', + true + ), + ], true ); - $output .= '</div>'; - $output .= '<div class="right">'; - $output .= html_print_submit_button( - __('OK!'), - 'newsletter', - false, - 'class="ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next w100px"', - true - ); - $output .= '</div>'; - $output .= '</div>'; - $output .= '<div id="both"></div>'; - $output .= '<br/>'; - $output .= '</div>'; - $output .= '</div>'; + // OK Button. + $submitButtons .= html_print_div( + [ + 'class' => 'right', + 'content' => html_print_submit_button( + __('OK!'), + 'newsletter', + false, + 'class="ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next w100px"', + true + ), + ], + true + ); + + $submitButtonsCase = html_print_div( + [ + 'class' => 'submit_buttons_container', + 'content' => $submitButtons, + ], + true + ); + + $modalContent .= html_print_div( + [ + 'class' => 'mrgn_lft_4em', + 'content' => html_print_div( + [ + 'id' => 'box_newsletter', + 'content' => $emailInputCase.$submitButtonsCase.'<div id="both"></div><br />', + ], + true + ), + ], + true + ); + + $output .= html_print_div( + [ + 'id' => 'newsletter_wizard', + 'style' => 'display: none;', + 'title' => __('Do you want to be up to date?'), + 'content' => $modalContent, + ], + true + ); // Verification modal. - $output .= '<div id="news_ensure_cancel" title="Confirmation Required" class="invisible">'; - $output .= '<div class="font_12_20">'; - $output .= __('Are you sure you don\'t want to subscribe?'); - $output .= '<p>'; - $output .= __('You will miss all news about amazing features and fixes!'); - $output .= '</p>'; - $output .= '</div>'; - $output .= '</div>'; + $verificationContent = html_print_div( + [ + 'class' => 'font_12_20', + 'content' => __('Are you sure you don\'t want to subscribe?').'<p>'.__('You will miss all news about amazing features and fixes!').'</p>', + ], + true + ); + + $output .= html_print_div( + [ + 'id' => 'news_ensure_cancel', + 'style' => 'display: none;', + 'title' => 'Confirmation Required', + 'content' => $verificationContent, + ], + true + ); // Results modal. - $output .= '<div id="news_result" title="Subscription process result" class="invisible">'; - $output .= '<div id="news_result_content" class="font_12_20">'; - $output .= '</div>'; - $output .= '</div>'; + $resultsContent = html_print_div( + [ + 'id' => 'news_result_content', + 'class' => 'font_12_20', + ], + true + ); + + $output .= html_print_div( + [ + 'id' => 'news_result', + 'style' => 'display: none;', + 'title' => 'Subscription process result', + 'content' => $resultsContent, + ], + true + ); ob_start(); ?> diff --git a/pandora_console/include/functions_users.php b/pandora_console/include/functions_users.php index 17e2d8baf0..6eb975eaff 100755 --- a/pandora_console/include/functions_users.php +++ b/pandora_console/include/functions_users.php @@ -235,9 +235,6 @@ function groups_combine_acl($acl_group_a, $acl_group_b) } $acl_list = [ - 'incident_view' => 1, - 'incident_edit' => 1, - 'incident_management' => 1, 'agent_view' => 1, 'agent_edit' => 1, 'agent_disable' => 1, diff --git a/pandora_console/include/javascript/pandora_dashboards.js b/pandora_console/include/javascript/pandora_dashboards.js index efefaf1195..0b370deab7 100644 --- a/pandora_console/include/javascript/pandora_dashboards.js +++ b/pandora_console/include/javascript/pandora_dashboards.js @@ -1151,7 +1151,9 @@ function dashboardLoadVC(settings) { 300 * 1000, handleUpdate, beforeUpdate, - settings.size + settings.size, + settings.id_user, + settings.hash ); } diff --git a/pandora_console/include/javascript/pandora_visual_console.js b/pandora_console/include/javascript/pandora_visual_console.js index 30a3d3f795..0400ca56ad 100755 --- a/pandora_console/include/javascript/pandora_visual_console.js +++ b/pandora_console/include/javascript/pandora_visual_console.js @@ -17,6 +17,9 @@ * @param {function | null} onUpdate Callback which will be execuded when the Visual Console. * is updated. It will receive two arguments with the old and the new Visual Console's * data structure. + * @param {string|null} id_user User id given for public access. + * @param {string|null} hash Authorization hash given for public access. + * * @return {VisualConsole | null} The Visual Console instance or a null value. */ // eslint-disable-next-line no-unused-vars @@ -28,7 +31,9 @@ function createVisualConsole( updateInterval, onUpdate, beforeUpdate, - size + size, + id_user, + hash ) { if (container == null || props == null || items == null) return null; if (baseUrl == null) baseUrl = ""; @@ -46,6 +51,8 @@ function createVisualConsole( baseUrl, visualConsoleId, size, + id_user, + hash, function(error, data) { if (error) { //Remove spinner change VC. @@ -69,7 +76,7 @@ function createVisualConsole( "[API]", error.message ); - done(); + abortable.abort(); return; } @@ -651,6 +658,8 @@ function createVisualConsole( * Fetch a Visual Console's structure and its items. * @param {string} baseUrl Base URL to build the API path. * @param {number} vcId Identifier of the Visual Console. + * @param {string|null} id_user User id given for public access. + * @param {string|null} hash Authorization hash given for public access. * @param {function} callback Function to be executed on request success or fail. * On success, the function will receive an object with the next properties: * - `props`: object with the Visual Console's data structure. @@ -658,7 +667,7 @@ function createVisualConsole( * @return {Object} Cancellable. Object which include and .abort([statusText]) function. */ // eslint-disable-next-line no-unused-vars -function loadVisualConsoleData(baseUrl, vcId, size, callback) { +function loadVisualConsoleData(baseUrl, vcId, size, id_user, hash, callback) { // var apiPath = baseUrl + "/include/rest-api"; var apiPath = baseUrl + "/ajax.php"; var vcJqXHR = null; @@ -720,7 +729,9 @@ function loadVisualConsoleData(baseUrl, vcId, size, callback) { { page: "include/rest-api/index", getVisualConsole: 1, - visualConsoleId: vcId + visualConsoleId: vcId, + id_user: typeof id_user == undefined ? id_user : null, + auth_hash: typeof hash == undefined ? hash : null }, "json" ) @@ -735,7 +746,9 @@ function loadVisualConsoleData(baseUrl, vcId, size, callback) { page: "include/rest-api/index", getVisualConsoleItems: 1, size: size, - visualConsoleId: vcId + visualConsoleId: vcId, + id_user: typeof id_user == undefined ? id_user : null, + auth_hash: typeof hash == undefined ? hash : null }, "json" ) diff --git a/pandora_console/include/lib/Dashboard/Manager.php b/pandora_console/include/lib/Dashboard/Manager.php index be87ef8732..e72f292537 100644 --- a/pandora_console/include/lib/Dashboard/Manager.php +++ b/pandora_console/include/lib/Dashboard/Manager.php @@ -5,11 +5,12 @@ namespace PandoraFMS\Dashboard; use PandoraFMS\View; use PandoraFMS\Dashboard\Cell; +use PandoraFMS\PublicLogin; /** * Dashboard manager. */ -class Manager +class Manager implements PublicLogin { /** diff --git a/pandora_console/include/lib/Dashboard/Widgets/maps_made_by_user.php b/pandora_console/include/lib/Dashboard/Widgets/maps_made_by_user.php index 32a095e132..9bbd69d470 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/maps_made_by_user.php +++ b/pandora_console/include/lib/Dashboard/Widgets/maps_made_by_user.php @@ -29,7 +29,7 @@ namespace PandoraFMS\Dashboard; // Load Visual Console. use Models\VisualConsole\Container as VisualConsole; - +use PandoraFMS\User; /** * Maps by users Widgets. */ @@ -498,6 +498,8 @@ class MapsMadeByUser extends Widget 'ratio' => $ratio_t, 'size' => $size, 'cellId' => $this->cellId, + 'hash' => User::generatePublicHash(), + 'id_user' => $config['id_user'], ] ); diff --git a/pandora_console/include/lib/Module.php b/pandora_console/include/lib/Module.php index 3e11480c3e..4a49bd5435 100644 --- a/pandora_console/include/lib/Module.php +++ b/pandora_console/include/lib/Module.php @@ -706,6 +706,13 @@ class Module extends Entity $updates = $this->fields; $updates['id_tipo_modulo'] = $this->moduleType()->id_tipo(); + // In the case of the webserver modules, debug_content special characters must be handled. + if ($updates['id_tipo_modulo'] >= MODULE_TYPE_WEB_ANALYSIS + && $updates['id_tipo_modulo'] <= MODULE_TYPE_WEB_CONTENT_STRING + ) { + $updates['debug_content'] = io_safe_input($updates['debug_content']); + } + if ($this->fields['id_agente_modulo'] > 0) { // Update. $rs = \db_process_sql_update( diff --git a/pandora_console/include/lib/PublicLogin.php b/pandora_console/include/lib/PublicLogin.php new file mode 100644 index 0000000000..b6124a62e7 --- /dev/null +++ b/pandora_console/include/lib/PublicLogin.php @@ -0,0 +1,61 @@ +<?php +/** + * Public access interface to provide access using hash and id_user. + * + * @category Interfaces + * @package Pandora FMS + * @subpackage Login + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ + */ + +// Begin. +namespace PandoraFMS; + +interface PublicLogin +{ + + + /** + * Generates a hash to authenticate in public views. + * + * @param string|null $other_secret If you need to authenticate using a + * varable string, use this 'other_secret' to customize the hash. + * + * @return string Returns a hash with the authenticaction. + */ + public static function generatePublicHash(?string $other_secret=''):string; + + + /** + * Validates a hash to authenticate in public view. + * + * @param string $hash Hash to be checked. + * @param string $other_secret Any custom string needed for you. + * + * @return boolean Returns true if hash is valid. + */ + public static function validatePublicHash( + string $hash, + string $other_secret='' + ):bool; + + +} diff --git a/pandora_console/include/lib/User.php b/pandora_console/include/lib/User.php index 8668c625e8..692a18308a 100644 --- a/pandora_console/include/lib/User.php +++ b/pandora_console/include/lib/User.php @@ -32,7 +32,7 @@ namespace PandoraFMS; /** * Object user. */ -class User +class User implements PublicLogin { /** @@ -53,11 +53,11 @@ class User /** * Initializes a user object. * - * @param array $data User information + * @param array|null $data User information. * - Username * - PHP session ID. */ - public function __construct($data) + public function __construct(?array $data) { global $config; @@ -88,17 +88,20 @@ class User if (isset($data['id_usuario']) === true && isset($data['password']) === true ) { - $user_in_db = process_user_login($user, $password, true); + $user_in_db = process_user_login( + $data['id_usuario'], + $data['password'], + true + ); if ($user_in_db !== false) { $config['id_usuario'] = $user_in_db; - $correctLogin = true; // Originally at api.php. if (session_status() === PHP_SESSION_NONE) { session_start(); } - $_SESSION['id_usuario'] = $user; + $_SESSION['id_usuario'] = $data['id_usuario']; session_write_close(); $this->idUser = $data['id_usuario']; @@ -113,4 +116,81 @@ class User } + /** + * Generates a hash to authenticate in public views. + * + * @param string|null $other_secret If you need to authenticate using a + * varable string, use this 'other_secret' to customize the hash. + * + * @return string Returns a hash with the authenticaction. + */ + public static function generatePublicHash(?string $other_secret=''):string + { + global $config; + + $str = $config['dbpass']; + $str .= $config['id_user']; + $str .= $other_secret; + return hash('sha256', $str); + } + + + /** + * Validates a hash to authenticate in public view. + * + * @param string $hash Hash to be checked. + * @param string $other_secret Any custom string needed for you. + * + * @return boolean Returns true if hash is valid. + */ + public static function validatePublicHash( + string $hash, + string $other_secret='' + ):bool { + global $config; + + if (isset($config['id_user']) === true) { + // Already logged in. + return true; + } + + $userFromParams = false; + // Try to get id_user from parameters if it is missing. + if (isset($config['id_user']) === false) { + $userFromParams = true; + $config['id_user'] = get_parameter('id_user', false); + // It is impossible to authenticate without an id user. + if ($config['id_user'] === false) { + unset($config['id_user']); + return false; + } + } else { + $config['public_access'] = false; + } + + // Build a hash to check. + $hashCheck = self::generatePublicHash($other_secret); + if ($hashCheck === $hash) { + // "Log" user in. + if (session_status() !== PHP_SESSION_ACTIVE) { + session_start(); + } + + $_SESSION['id_usuario'] = $config['id_user']; + session_write_close(); + + $config['public_access'] = true; + $config['force_instant_logout'] = true; + return true; + } + + // Remove id user from config array if authentication has failed. + if ($userFromParams === true) { + unset($config['id_user']); + } + + return false; + } + + } diff --git a/pandora_console/include/lib/Websockets/WebSocketUser.php b/pandora_console/include/lib/Websockets/WebSocketUser.php index bcbe30cc17..9ab6c9e5da 100644 --- a/pandora_console/include/lib/Websockets/WebSocketUser.php +++ b/pandora_console/include/lib/Websockets/WebSocketUser.php @@ -147,8 +147,8 @@ class WebSocketUser /** * Initializes a websocket user. * - * @param string $id Id of the new user. - * @param Socket $socket Socket where communication is stablished. + * @param string $id Id of the new user. + * @param \Socket $socket Socket where communication is stablished. */ public function __construct($id, $socket) { diff --git a/pandora_console/include/rest-api/models/VisualConsole/Item.php b/pandora_console/include/rest-api/models/VisualConsole/Item.php index c391917731..028551e09d 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Item.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Item.php @@ -1071,9 +1071,8 @@ class Item extends CachedModel $mobile_navigation = false; - if (isset($_SERVER['PHP_SELF']) === true - && (strstr($_SERVER['PHP_SELF'], 'mobile/') !== false - || strstr($_SERVER['HTTP_REFERER'], 'mobile/') !== false) + if (strstr(($_SERVER['PHP_SELF'] ?? ''), 'mobile/') !== false + || strstr(($_SERVER['HTTP_REFERER'] ?? ''), 'mobile/') !== false ) { $mobile_navigation = true; } diff --git a/pandora_console/include/styles/agent_alerts.css b/pandora_console/include/styles/agent_alerts.css index 7a140a1704..8726228b33 100644 --- a/pandora_console/include/styles/agent_alerts.css +++ b/pandora_console/include/styles/agent_alerts.css @@ -26,6 +26,10 @@ justify-content: center; } +#img-full-screen { + width: 12em; +} + #full_screen_refresh_box, #slc-refresh-rate, #img-full-screen { @@ -45,6 +49,7 @@ .agent_alerts_header_pure { position: absolute; + z-index: 500; } .agents_alerts_header form > ul > li { diff --git a/pandora_console/include/styles/alert.css b/pandora_console/include/styles/alert.css index eb8f2d7583..63b97a0414 100644 --- a/pandora_console/include/styles/alert.css +++ b/pandora_console/include/styles/alert.css @@ -2,6 +2,10 @@ display: inline-block; } +#rules { + display: block; +} + li#li-buttons-alert-list > div { margin-left: 10px; } @@ -132,11 +136,14 @@ div.target { width: 100%; } div.target.flex { - display: block; border: 2px dashed #ddd; margin-left: 0em; margin-top: 10px; padding: 1em; + display: flex; + flex-direction: row; + flex-wrap: wrap; + height: fit-content; } .fields, @@ -190,6 +197,8 @@ div#rules.show { font-weight: 600; background-color: #333; word-break: break-all; + height: fit-content; + min-height: 2.3em; } .field.opacityElements { @@ -215,6 +224,11 @@ div#rules.show { background-color: #82b92e; } +.variable:empty::before { + content: "empty"; + font-style: italic; +} + .modifier { background-color: #cba9d2; } diff --git a/pandora_console/include/styles/meta_dashboards.css b/pandora_console/include/styles/meta_dashboards.css index 1b24b3bce5..b42a9b47b6 100644 --- a/pandora_console/include/styles/meta_dashboards.css +++ b/pandora_console/include/styles/meta_dashboards.css @@ -1,5 +1,5 @@ div#page { - width: 90% !important; + width: auto; margin: 0 auto; } @@ -22,3 +22,11 @@ div#page { right: 50px; top: 20px; } + +.select-dashboard-width { + width: 110%; +} + +#menu_tab li.nomn form#form-select-dashboard { + margin-top: 0px !important; +} diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 850842cb1e..3b48e5f919 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -2163,6 +2163,11 @@ div.loading { div.loading img { float: right; } + +textarea.resizev { + resize: vertical; +} + /* Tablesorter jQuery pager */ div.pager { margin-left: 10px; @@ -4877,7 +4882,8 @@ input:checked + .p-slider:before { .user_edit_first_row, .user_edit_second_row, -.user_edit_third_row { +.user_edit_third_row, +.user_edit_fourth_row { margin-bottom: 20px; } @@ -8505,3 +8511,12 @@ div.stat-win-spinner img { width: 100px !important; margin-left: 20px; } + +.btn_update_online_open { + float: right; + margin-bottom: 20px; +} + +.align-left-important { + text-align: left !important; +} diff --git a/pandora_console/include/styles/pandora_black.css b/pandora_console/include/styles/pandora_black.css index f5e971c065..09393879ba 100644 --- a/pandora_console/include/styles/pandora_black.css +++ b/pandora_console/include/styles/pandora_black.css @@ -1019,3 +1019,11 @@ li.ui-tabs-tab.ui-corner-top.ui-state-default.ui-tab { margin: 20px auto; border-radius: 3px; } + +table.alternate tr:nth-child(2n + 1) td { + background-color: #222; +} + +table.alternate tr:nth-child(2n) td { + background-color: #111; +} diff --git a/pandora_console/index.php b/pandora_console/index.php index 462d08d2f9..b42fb3e1fb 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -1277,6 +1277,7 @@ if ($config['pure'] == 0) { // Container div. echo '</div>'; echo '<div id="both"></div>'; + echo '</div>'; echo '<div id="foot">'; include 'general/footer.php'; diff --git a/pandora_console/install.php b/pandora_console/install.php index 579f810b12..b423e99b20 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@ <div style='height: 10px'> <?php $version = '7.0NG.754'; - $build = '210513'; + $build = '210528'; $banner = "v$version Build $build"; error_reporting(0); diff --git a/pandora_console/operation/agentes/alerts_status.php b/pandora_console/operation/agentes/alerts_status.php index 3f45a7a42c..54e936839a 100755 --- a/pandora_console/operation/agentes/alerts_status.php +++ b/pandora_console/operation/agentes/alerts_status.php @@ -188,12 +188,25 @@ if ($idAgent != 0) { $print_agent = true; - if (!is_metaconsole()) { - ui_print_page_header( + if (is_metaconsole() === false) { + // Header. + ui_print_standard_header( __('Alert detail'), 'images/op_alerts.png', false, - '' + '', + false, + [], + [ + [ + 'link' => '', + 'label' => __('Monitoring'), + ], + [ + 'link' => '', + 'label' => __('Views'), + ], + ] ); } else { ui_meta_print_header(__('Alerts view')); diff --git a/pandora_console/operation/agentes/estado_agente.php b/pandora_console/operation/agentes/estado_agente.php index 73aaa601ff..377cff3d4d 100644 --- a/pandora_console/operation/agentes/estado_agente.php +++ b/pandora_console/operation/agentes/estado_agente.php @@ -1,17 +1,32 @@ <?php +/** + * Agent Status View. + * + * @category View + * @package Pandora FMS + * @subpackage Monitoring. + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ + */ -// Pandora FMS - http://pandorafms.com -// ================================================== -// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas -// Please see http://pandorafms.org for full contribution list -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation for version 2. -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// Load global vars +// Begin. global $config; ob_start(); @@ -192,13 +207,24 @@ if (check_acl($config['id_user'], 0, 'AW')) { $onheader = ['setup' => $setuptab]; } -ui_print_page_header( +// Header. +ui_print_standard_header( __('Agent detail'), 'images/agent.png', false, '', false, - $onheader + $onheader, + [ + [ + 'link' => '', + 'label' => __('Monitoring'), + ], + [ + 'link' => '', + 'label' => __('Views'), + ], + ] ); if (!$strict_user) { diff --git a/pandora_console/operation/agentes/group_view.php b/pandora_console/operation/agentes/group_view.php index 61dfda1a22..000931ff6b 100644 --- a/pandora_console/operation/agentes/group_view.php +++ b/pandora_console/operation/agentes/group_view.php @@ -1,16 +1,32 @@ <?php -// Pandora FMS - http://pandorafms.com -// ================================================== -// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas -// Please see http://pandorafms.org for full contribution list -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation for version 2. -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// Load global vars +/** + * Group View. + * + * @category View + * @package Pandora FMS + * @subpackage Monitoring. + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ + */ + +// Begin. require_once 'include/config.php'; require_once 'include/functions_reporting.php'; require_once $config['homedir'].'/include/functions_agents.php'; @@ -62,17 +78,27 @@ if ($config['realtimestats'] == 0) { $updated_time .= '</a>'; } else { // $updated_info = __("Updated at realtime"); - $updated_info = ''; + $updated_info = ''; } // Header. -ui_print_page_header( +ui_print_standard_header( __('Group view'), 'images/group.png', false, '', false, - $updated_time + (array) $updated_time, + [ + [ + 'link' => '', + 'label' => __('Monitoring'), + ], + [ + 'link' => '', + 'label' => __('Views'), + ], + ] ); $total_agentes = 0; diff --git a/pandora_console/operation/agentes/interface_view.functions.php b/pandora_console/operation/agentes/interface_view.functions.php new file mode 100644 index 0000000000..d94c56bd22 --- /dev/null +++ b/pandora_console/operation/agentes/interface_view.functions.php @@ -0,0 +1,741 @@ +<?php +/** + * Pandora FMS - http://pandorafms.com + * ================================================== + * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; version 2 + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + + +/** + * Print filters for interface view. + * + * @param string sec Section (type of filter will vary across sections). + */ +function print_filters($sec) +{ + $table = new StdClass(); + $table->width = '100%'; + $table->cellspacing = 0; + $table->cellpadding = 0; + $table->class = 'databox filters'; + + if ($sec === 'view') { + $table->style[0] = 'font-weight: bold;'; + $table->style[1] = 'font-weight: bold;'; + $table->style[2] = 'font-weight: bold;'; + $table->style[3] = 'font-weight: bold;'; + $table->style[4] = 'font-weight: bold;'; + + $table->data[0][0] = __('Group'); + $table->data[0][1] .= html_print_select_groups( + $config['id_user'], + 'AR', + true, + 'group_id', + $ag_group, + '', + '', + '0', + true, + false, + false, + '', + false, + '', + false, + false, + 'id_grupo', + false + ); + + $table->data[0][2] = __('Recursion'); + + $table->data[0][2] .= html_print_input( + [ + 'type' => 'checkbox', + 'name' => 'recursion', + 'return' => true, + 'checked' => $recursion, + 'value' => 1, + ] + ); + + $table->data[1][0] = __('Agents'); + + if (empty($agents) === true || $agents == -1) { + $agents = []; + } + + $table->data[1][1] = html_print_select( + [], + 'selected_agents[]', + '', + '', + '', + 0, + true, + true, + true, + '', + false, + 'min-width: 180px; max-width: 200px;' + ); + + // Interfaces. + $table->data[1][3] = '<b>'.__('Interfaces').'</b>'; + $table->data[1][4] = html_print_select( + [], + 'selected_interfaces[]', + $selected_interfaces, + '', + '', + 0, + true, + true, + true, + '', + false, + 'min-width: 180px; max-width: 200px;' + ); + + $filters = '<form method="post" action="'.ui_get_url_refresh( + [ + 'selected_agents' => $selected_agents, + 'selected_interfaces' => $selected_interfaces, + 'selected_group_id' => $selected_group_id, + ] + ).'">'; + + $filters .= html_print_table($table, true); + + $filters .= "<div class='height_100p right'>".html_print_submit_button( + __('Show'), + 'uptbutton', + false, + 'class="sub search mgn_tp_0"', + true + ).'</div>'; + + $filters .= '</form>'; + } else { + $table->style[0] = 'font-weight: bold;'; + + $table->data[0][0] = '<b>'.__('Interfaces').'</b>'; + $table->data[0][1] = html_print_select( + [], + 'selected_interfaces[]', + $selected_interfaces, + '', + '', + 0, + true, + true, + true, + '', + false, + 'min-width: 180px; max-width: 200px;' + ); + + $filters = '<form method="post" action="'.ui_get_url_refresh( + [ + 'selected_agents' => $selected_agents, + 'selected_interfaces' => $selected_interfaces, + 'selected_group_id' => $selected_group_id, + ] + ).'">'; + + $filters .= html_print_table($table, true); + + $filters .= "<div class='height_100p right'>".html_print_submit_button( + __('Show'), + 'uptbutton', + false, + 'class="sub search mgn_tp_0"', + true + ).'</div>'; + + $filters .= '</form>'; + } + + ui_toggle( + $filters, + __('Interface filter'), + __('Interface filter'), + 'ui_toggle_if_filter' + ); + + unset($table); +} + + +/** + * Print interfaces table. + * + * @param array data Array containing data of interfaces. + * @param array selected_agents Selected agents. + * @param array selected_interfaces Selected interfaces. + * @param string sort_field Field used to sort table. + * @param string sort Direction used to sort by field. + * @param int pagination_index Active page (used for pagination). + * @param string sec Active section of page. + */ +function print_table( + $data, + $selected_agents, + $selected_interfaces, + $sort_field, + $sort, + $pagination_index, + $sec +) { + global $config; + + $selected = true; + $select_if_name_up = false; + $select_if_name_down = false; + $select_if_speed_data_up = false; + $select_if_speed_data_down = false; + $select_if_in_octets_up = false; + $select_if_in_octets_down = false; + $select_if_out_octets_up = false; + $select_if_out_octets_down = false; + $select_if_usage_module_data_in_up = false; + $select_if_usage_module_data_in_down = false; + $select_if_usage_module_data_out_up = false; + $select_if_usage_module_data_out_down = false; + $select_if_last_data_up = false; + $select_if_last_data_down = false; + $order = null; + + switch ($sort_field) { + case 'if_agent_name': + switch ($sort) { + case 'up': + $select_if_agent_name_up = $selected; + $order = [ + 'field' => 'if_agent_name', + 'order' => 'ASC', + ]; + break; + + case 'down': + default: + $select_if_agent_name_down = $selected; + $order = [ + 'field' => 'if_agent_name', + 'order' => 'DESC', + ]; + break; + } + break; + + case 'if_name': + switch ($sort) { + case 'up': + $select_if_name_up = $selected; + $order = [ + 'field' => 'if_name', + 'order' => 'ASC', + ]; + break; + + case 'down': + default: + $select_if_name_down = $selected; + $order = [ + 'field' => 'if_name', + 'order' => 'DESC', + ]; + break; + } + break; + + case 'if_speed_data': + switch ($sort) { + case 'up': + $select_if_speed_data_up = $selected; + $order = [ + 'field' => 'if_speed_data', + 'order' => 'ASC', + ]; + break; + + case 'down': + default: + $select_if_speed_data_down = $selected; + $order = [ + 'field' => 'if_speed_data', + 'order' => 'DESC', + ]; + break; + } + break; + + case 'if_in_octets': + switch ($sort) { + case 'up': + $select_if_in_octets_up = $selected; + $order = [ + 'field' => 'if_in_octets', + 'order' => 'ASC', + ]; + break; + + case 'down': + default: + $select_if_in_octets_down = $selected; + $order = [ + 'field' => 'if_in_octets', + 'order' => 'DESC', + ]; + break; + } + break; + + case 'if_out_octets': + switch ($sort) { + case 'up': + $select_if_out_octets_up = $selected; + $order = [ + 'field' => 'if_out_octets', + 'order' => 'ASC', + ]; + break; + + case 'down': + default: + $select_if_out_octets_down = $selected; + $order = [ + 'field' => 'if_out_octets', + 'order' => 'DESC', + ]; + break; + } + break; + + case 'if_usage_module_data_in': + switch ($sort) { + case 'up': + $select_if_usage_module_data_in_up = $selected; + $order = [ + 'field' => 'if_usage_module_data_in', + 'order' => 'ASC', + ]; + break; + + case 'down': + default: + $select_if_usage_module_data_in_down = $selected; + $order = [ + 'field' => 'if_usage_module_data_in', + 'order' => 'DESC', + ]; + break; + } + break; + + case 'if_usage_module_data_out': + switch ($sort) { + case 'up': + $select_if_usage_module_data_out_up = $selected; + $order = [ + 'field' => 'if_usage_module_data_out', + 'order' => 'ASC', + ]; + break; + + case 'down': + default: + $select_if_usage_module_data_out_down = $selected; + $order = [ + 'field' => 'if_usage_module_data_out', + 'order' => 'DESC', + ]; + break; + } + break; + + case 'if_last_data': + switch ($sort) { + case 'up': + $select_if_last_data_up = $selected; + $order = [ + 'field' => 'if_last_data', + 'order' => 'ASC', + ]; + break; + + case 'down': + default: + $select_if_last_data_down = $selected; + $order = [ + 'field' => 'if_last_data', + 'order' => 'DESC', + ]; + break; + } + break; + + default: + $select_if_agent_name = ($sec === 'view') ? true : false; + $select_if_name_up = ($sec === 'estado') ? true : false; + $select_if_name_down = false; + $select_if_speed_data_up = false; + $select_if_speed_data_down = false; + $select_if_in_octets_up = false; + $select_if_in_octets_down = false; + $select_if_out_octets_up = false; + $select_if_out_octets_down = false; + $select_if_usage_module_data_in_up = false; + $select_if_usage_module_data_in_down = false; + $select_if_usage_module_data_out_up = false; + $select_if_usage_module_data_out_down = false; + $select_if_last_data_up = false; + $select_if_last_data_down = false; + break; + } + + if ($sec === 'estado') { + $agent_id = (int) get_parameter('id_agente', 0); + + $sort_url_page = 'ver_agente'; + $sec = 'estado'; + $query_params = '&id_agente='.$agent_id.'&tab=interface'; + } else { + $sort_url_page = 'interface_view'; + $sec = 'view'; + $query_params = ''; + } + + // Build URLs to sort the table. + $url_if_agent_name = 'index.php?sec='.$sec.'&sec2=operation/agentes/'.$sort_url_page.$query_params; + $url_if_name = 'index.php?sec='.$sec.'&sec2=operation/agentes/'.$sort_url_page.$query_params; + $url_if_speed = 'index.php?sec='.$sec.'&sec2=operation/agentes/'.$sort_url_page.$query_params; + $url_if_in_octets = 'index.php?sec='.$sec.'&sec2=operation/agentes/'.$sort_url_page.$query_params; + $url_if_out_octets = 'index.php?sec='.$sec.'&sec2=operation/agentes/'.$sort_url_page.$query_params; + $url_if_bandwidth_usage_in = 'index.php?sec='.$sec.'&sec2=operation/agentes/'.$sort_url_page.$query_params; + $url_if_bandwidth_usage_out = 'index.php?sec='.$sec.'&sec2=operation/agentes/'.$sort_url_page.$query_params; + $last_data = 'index.php?sec='.$sec.'&sec2=operation/agentes/'.$sort_url_page.$query_params; + + $selected_agents_query_str = ''; + $selected_interfaces_query_str = ''; + + foreach ($selected_agents as $key => $agent) { + $selected_agents_query_str .= '&selected_agents['.$key.']='.$agent; + } + + foreach ($selected_interfaces as $key => $interface) { + $selected_interfaces_query_str .= '&selected_interfaces['.$key.']='.$interface; + } + + $url_if_agent_name .= $selected_agents_query_str.'&'.$selected_interfaces_query_str; + $url_if_name .= $selected_agents_query_str.'&'.$selected_interfaces_query_str; + $url_if_speed .= $selected_agents_query_str.'&'.$selected_interfaces_query_str; + $url_if_in_octets .= $selected_agents_query_str.'&'.$selected_interfaces_query_str; + $url_if_out_octets .= $selected_agents_query_str.'&'.$selected_interfaces_query_str; + $url_if_bandwidth_usage_in .= $selected_agents_query_str.'&'.$selected_interfaces_query_str; + $url_if_bandwidth_usage_out .= $selected_agents_query_str.'&'.$selected_interfaces_query_str; + $last_data .= $selected_agents_query_str.'&'.$selected_interfaces_query_str; + + $url_if_agent_name .= '&recursion='.$recursion; + $url_if_name .= '&recursion='.$recursion; + $url_if_speed .= '&recursion='.$recursion; + $url_if_in_octets .= '&recursion='.$recursion; + $url_if_out_octets .= '&recursion='.$recursion; + $url_if_bandwidth_usage_in .= '&recursion='.$recursion; + $url_if_bandwidth_usage_out .= '&recursion='.$recursion; + $last_data .= '&recursion='.$recursion; + + $url_if_agent_name .= '&sort_field=if_agent_name&sort='; + $url_if_name .= '&sort_field=if_name&sort='; + $url_if_speed .= '&sort_field=if_speed_data&sort='; + $url_if_in_octets .= '&sort_field=if_in_octets&sort='; + $url_if_out_octets .= '&sort_field=if_out_octets&sort='; + $url_if_bandwidth_usage_in .= '&sort_field=if_usage_module_data_in&sort='; + $url_if_bandwidth_usage_out .= '&sort_field=if_usage_module_data_out&sort='; + $last_data .= '&sort_field=if_last_data&sort='; + + if (empty($data) === false) { + $table = new StdClass(); + $table->cellpadding = 0; + $table->cellspacing = 0; + $table->width = '100%'; + $table->class = 'info_table'; + $table->head = []; + $table->data = []; + $table->size = []; + $table->align = []; + + $show_fields = explode(',', $config['status_monitor_fields']); + + if ($sec === 'view') { + $table->head[0] = __('Agent'); + $table->head[0] .= ui_get_sorting_arrows( + $url_if_agent_name.'up', + $url_if_agent_name.'down', + $select_if_agent_name_up, + $select_if_agent_name_down + ); + } + + $table->head[1] = __('IfName'); + $table->head[1] .= ui_get_sorting_arrows( + $url_if_name.'up', + $url_if_name.'down', + $select_if_name_up, + $select_if_name_down + ); + + $table->head[2] = __('Status'); + + $table->head[3] = __('IfSpeed'); + $table->head[3] .= ui_get_sorting_arrows( + $url_if_speed.'up', + $url_if_speed.'down', + $select_if_speed_data_up, + $select_if_speed_data_down + ); + + $table->head[4] = __('IfInOctets'); + $table->head[4] .= ui_get_sorting_arrows( + $url_if_in_octets.'up', + $url_if_in_octets.'down', + $select_if_in_octets_up, + $select_if_in_octets_down + ); + + $table->head[5] = __('IfOutOctets'); + $table->head[5] .= ui_get_sorting_arrows( + $url_if_out_octets.'up', + $url_if_out_octets.'down', + $select_if_out_octets_up, + $select_if_out_octets_down + ); + + $table->head[6] = __('% Bandwidth usage (in)'); + $table->head[6] .= ui_get_sorting_arrows( + $url_if_bandwidth_usage_in.'up', + $url_if_bandwidth_usage_in.'down', + $select_if_usage_module_data_in_up, + $select_if_usage_module_data_in_down + ); + + $table->head[7] = __('% Bandwidth usage (out)'); + $table->head[7] .= ui_get_sorting_arrows( + $url_if_bandwidth_usage_out.'up', + $url_if_bandwidth_usage_out.'down', + $select_if_usage_module_data_out_up, + $select_if_usage_module_data_out_down + ); + + $table->head[8] = __('Last data'); + $table->head[8] .= ui_get_sorting_arrows( + $last_data.'up', + $last_data.'down', + $select_if_last_data_up, + $select_if_last_data_down + ); + + $loop_index = 0; + $table_data = []; + + $interfaces_array = array_column($data, 'interfaces'); + $agents = array_column($data, 'name'); + + $all_interfaces = []; + + foreach ($data as $value) { + $agent_alias = agents_get_alias($value['name']); + + foreach ($value['interfaces'] as $if_name => $interface) { + $interface['agent_id'] = $value['name']; + $interface['agent_alias'] = $agent_alias; + $interface['if_name'] = $if_name; + $all_interfaces[$if_name] = $interface; + } + } + + if ($sec === 'estado' + && is_array($selected_interfaces) === true + && empty($selected_interfaces) === true + ) { + $filtered_interfaces = $all_interfaces; + } else { + // Filter interfaces array. + $filtered_interfaces = array_filter( + $all_interfaces, + function ($interface) use ($selected_interfaces) { + return in_array( + $interface['status_module_id'], + $selected_interfaces + ) === true; + } + ); + } + + $data = []; + + foreach ($filtered_interfaces as $if_name => $agent_interfaces) { + // Get usage modules. + $usage_module_in = db_get_row( + 'tagente_modulo', + 'nombre', + $if_name.'_inUsage' + ); + $usage_module_out = db_get_row( + 'tagente_modulo', + 'nombre', + $if_name.'_outUsage' + ); + + $usage_module_id_in = $usage_module_in['id_agente_modulo']; + $usage_module_id_out = $usage_module_out['id_agente_modulo']; + $usage_module_description = $usage_module_in['descripcion']; + + // Get usage modules data. + $usage_module_data_in = modules_get_previous_data( + $usage_module_id_in, + time() + ); + + $usage_module_data_out = modules_get_previous_data( + $usage_module_id_out, + time() + ); + + // Extract ifSpeed from description of usage module. + $if_speed_str = strstr($usage_module_description, 'Speed:'); + $if_speed_str = substr($if_speed_str, 0, -1); + $if_speed_str = explode(':', $if_speed_str)[1]; + + $matches = []; + preg_match_all('/\d+/', $if_speed_str, $matches); + + $if_speed_value = $matches[0][0]; + + // Transform ifSpeed unit. + $divisor = 1000; + $counter = 0; + while ($if_speed_value >= $divisor) { + if ($if_speed_value >= $divisor) { + $if_speed_value = ($if_speed_value / $divisor); + } + + $counter++; + } + + $if_speed_unit = 'bps'; + + switch ($counter) { + case 1: + $if_speed_unit = 'Kbps'; + break; + + case 2: + $if_speed_unit = 'Mbps'; + break; + + case 3: + $if_speed_unit = 'Gbps'; + break; + + case 4: + $if_speed_unit = 'Tbps'; + break; + + default: + $if_speed_unit = 'bps'; + break; + } + + // Get in and out traffic. + $ifInOctets = modules_get_previous_data( + $agent_interfaces['traffic']['in'], + time() + ); + $ifOutOctets = modules_get_previous_data( + $agent_interfaces['traffic']['out'], + time() + ); + + // Get last data timestamp. + $timestamps_array = array_merge( + array_column(ifInOctets, 'utimestamp'), + array_column(ifOutOctets, 'utimestamp') + ); + + if ($sec === 'view') { + $table_data[$loop_index]['if_agent_name'] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&id_agente='.$agent_interfaces['agent_id'].'">'.$agent_interfaces['agent_alias'].'</a>'; + } + + $table_data[$loop_index]['if_name'] = $agent_interfaces['if_name']; + $table_data[$loop_index]['if_status_image'] = $agent_interfaces['status_image']; + $table_data[$loop_index]['if_speed_data'] = ($if_speed_value === null) ? __('N/A') : $if_speed_value.' '.$if_speed_unit; + $table_data[$loop_index]['if_in_octets'] = ($ifInOctets['datos'] === null) ? __('N/A') : $ifInOctets['datos']; + $table_data[$loop_index]['if_out_octets'] = ($ifOutOctets['datos'] === null) ? __('N/A') : $ifOutOctets['datos']; + $table_data[$loop_index]['if_usage_module_data_in'] = ($usage_module_data_in['datos'] === null) ? __('N/A') : $usage_module_data_in['datos']; + $table_data[$loop_index]['if_usage_module_data_out'] = ($usage_module_data_out['datos'] === null) ? __('N/A') : $usage_module_data_out['datos']; + $table_data[$loop_index]['if_last_data'] = human_time_comparation( + max( + $ifInOctets['utimestamp'], + $ifOutOctets['utimestamp'] + ) + ); + + $loop_index++; + } + + // Sort array of previously processed table values. + if ($sort === 'up') { + $res = usort( + $table_data, + function ($a, $b) use ($sort_field) { + if ($a[$sort_field] > $b[$sort_field]) { + return 1; + } else { + return -1; + } + } + ); + } + + if ($sort === 'down') { + $res = usort( + $table_data, + function ($a, $b) use ($sort_field) { + if ($b[$sort_field] > $a[$sort_field]) { + return 1; + } else { + return -1; + } + } + ); + } + + $sliced_table_data = array_slice( + $table_data, + $pagination_index, + $config['block_size'] + ); + + foreach ($sliced_table_data as $value) { + array_push($table->data, array_values($value)); + } + + html_print_table($table); + + if (count($selected_interfaces) > $config['block_size']) { + ui_pagination(count($selected_interfaces), false, $pagination_index, 0, false, 'offset', true, 'pagination-bottom'); + } + } else { + ui_print_info_message(['no_close' => true, 'message' => __('No search parameters')]); + } +} diff --git a/pandora_console/operation/agentes/interface_view.php b/pandora_console/operation/agentes/interface_view.php new file mode 100644 index 0000000000..4f20c459f3 --- /dev/null +++ b/pandora_console/operation/agentes/interface_view.php @@ -0,0 +1,284 @@ +<?php +/** + * Interfaces view. + * + * @category Monitoring + * @package Pandora FMS + * @subpackage Community + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2007-2021 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ + */ + +// Begin. +global $config; + +check_login(); + +if (check_acl($config['id_user'], 0, 'AR') === false) { + db_pandora_audit( + 'ACL Violation', + 'Trying to access Agent Management' + ); + include 'general/noaccess.php'; + return; +} + +require_once 'interface_view.functions.php'; +require_once $config['homedir'].'/include/functions_agents.php'; + +$recursion = get_parameter_switch('recursion', false); +if ($recursion === false) { + $recursion = get_parameter('recursion', false); +} + +$selected_agents = get_parameter('selected_agents', []); +$selected_interfaces = get_parameter('selected_interfaces', []); +$refr = (int) get_parameter('refr', 0); +$offset = (int) get_parameter('offset', 0); +$sort_field = get_parameter('sort_field'); +$sort = get_parameter('sort', 'none'); +$autosearch = false; +$sec = (string) get_parameter('sec', 'view'); +$agent_id = (int) get_parameter('id_agente', 0); + +if ($sec === 'view') { + ui_print_standard_header( + __('Interface view').$subpage, + '', + false, + '', + true, + [], + [ + [ + 'link' => '', + 'label' => __('Monitoring'), + ], + [ + 'link' => '', + 'label' => __('Views'), + ], + ] + ); +} + +$agent_filter = ['id_agente' => $agent_id]; + +// Autosearch if search parameters are different from those by default. +if (empty($selected_agents) === false || empty($selected_interfaces) === false + || $sort_field !== '' || $sort !== 'none' || $sec === 'estado' +) { + $autosearch = true; +} + +print_filters($sec); + +$result = false; + +if ($autosearch === true) { + if ($sec === 'estado') { + $result = agents_get_network_interfaces(false, $agent_filter); + } else { + $result = agents_get_network_interfaces($selected_agents); + } + + if ($result === false) { + $result = []; + } else { + ui_pagination( + count($selected_interfaces), + false, + $offset, + 0, + false, + 'offset', + true + ); + } +} + +print_table( + $result, + $selected_agents, + $selected_interfaces, + $sort_field, + $sort, + $offset, + $sec +); + +?> +<script type="text/javascript"> + +$(document).ready(function() { + var group_id = $("#group_id").val(); + load_agents_selector(group_id); + + var sec = "<?php echo $sec; ?>"; + var agent_id = "<?php echo $agent_id; ?>"; + + if (sec === 'estado' && agent_id > 0) { + load_agent_interfaces_selector([agent_id]); + } +}); + + +$('#moduletype').click(function() { + jQuery.get ( + "ajax.php", + { + "page": "general/subselect_data_module", + "module":$('#moduletype').val() + }, + function (data, status) { + $("#datatypetittle").show (); + $("#datatypebox").hide () + .empty () + .append (data) + .show (); + }, + "html" + ); + + return false; +}); + + +function toggle_full_value(id) { + text = $('#hidden_value_module_' + id).html(); + old_text = $("#value_module_text_" + id).html(); + + $("#hidden_value_module_" + id).html(old_text); + + $("#value_module_text_" + id).html(text); +} + +function load_agents_selector(group) { + + jQuery.post ("ajax.php", + { + "page" : "operation/agentes/ver_agente", + "get_agents_group_json" : 1, + "id_group" : group, + "privilege" : "AW", + "keys_prefix" : "_", + "recursion" : $('#checkbox-recursion').is(':checked') + }, + function (data, status) { + $("#selected_agents").html(''); + jQuery.each (data, function (id, value) { + id = id.substring(1); + + option = $("<option></option>") + .attr ("value", value["id_agente"]) + .html (value["alias"]); + $("#id_agents").append (option); + $("#selected_agents").append (option); + }); + + var selected_agents = "<?php echo implode(',', $selected_agents); ?>"; + + $.each(selected_agents.split(","), function(i,e) { + $("#selected_agents option[value='" + e + "']").prop( + "selected", + true + ); + }); + + load_agent_interfaces_selector($("#selected_agents").val()); + }, + "json" + ); +} + +$("#group_id").change(function() { + load_agents_selector(this.value); +}); + +$("#checkbox-recursion").change (function () { + jQuery.post ("ajax.php", + {"page" : "operation/agentes/ver_agente", + "get_agents_group_json" : 1, + "id_group" : $("#group_id").val(), + "privilege" : "AW", + "keys_prefix" : "_", + "recursion" : $('#checkbox-recursion').is(':checked') + }, + function (data, status) { + $("#selected_agents").html(''); + $("#module").html(''); + jQuery.each (data, function (id, value) { + id = id.substring(1); + + option = $("<option></option>") + .attr ("value", value["id_agente"]) + .html (value["alias"]); + $("#id_agents").append (option); + $("#selected_agents").append (option); + }); + }, + "json" + ); +}); + +$("#selected_agents").click (function() { + var selected_agents = $(this).val(); + + load_agent_interfaces_selector(selected_agents); +}); + +function load_agent_interfaces_selector(selected_agents) { + $("#selected_interfaces").empty(); + jQuery.post ("ajax.php", + { + "page" : "include/ajax/agent", + "get_agents_interfaces" : 1, + "id_agents" : selected_agents + }, + function (data, status) { + $("#module").html(''); + + if (data) { + Object.values(data).forEach(function(obj) { + for (const [key, value] of Object.entries(obj.interfaces)) { + option = $("<option></option>") + .attr ("value", value.status_module_id) + .html (key + ' (' + obj.agent_alias + ')'); + $("#selected_interfaces").append(option); + } + }); + } + + var selected_interfaces = + "<?php echo implode(',', $selected_interfaces); ?>"; + + $.each(selected_interfaces.split(","), function(i,e) { + $("#selected_interfaces option[value='" + e + "']").prop( + "selected", + true + ); + }); + + }, + "json" + ); +} + +</script> diff --git a/pandora_console/operation/agentes/pandora_networkmap.editor.php b/pandora_console/operation/agentes/pandora_networkmap.editor.php index 8f735e72de..5eccda04f8 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.editor.php +++ b/pandora_console/operation/agentes/pandora_networkmap.editor.php @@ -1,9 +1,8 @@ <?php /** - * Extension to manage a list of gateways and the node address where they should - * point to. + * Empty Network editor. * - * @category Extensions + * @category View * @package Pandora FMS * @subpackage Community * @version 1.0.0 @@ -27,6 +26,7 @@ * ============================================================================ */ +// Begin. global $config; // Check user credentials. @@ -203,12 +203,24 @@ if ($edit_networkmap) { } } -ui_print_page_header( - __('Networkmap'), +// Header. +ui_print_standard_header( + __('Network maps editor'), 'images/bricks.png', false, 'network_map_enterprise_edit', - false + false, + [], + [ + [ + 'link' => '', + 'label' => __('Topology maps'), + ], + [ + 'link' => '', + 'label' => __('Networkmap'), + ], + ] ); $id_snmp_l2_recon = db_get_value( diff --git a/pandora_console/operation/agentes/pandora_networkmap.php b/pandora_console/operation/agentes/pandora_networkmap.php index 8c8c5ec087..c960a333aa 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.php +++ b/pandora_console/operation/agentes/pandora_networkmap.php @@ -1,15 +1,32 @@ <?php -// ______ __ _______ _______ _______ -// | __ \.---.-.-----.--| |.-----.----.---.-. | ___| | | __| -// | __/| _ | | _ || _ | _| _ | | ___| |__ | -// |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| -// -// ============================================================================ -// Copyright (c) 2007-2021 Artica Soluciones Tecnologicas, http://www.artica.es -// This code is NOT free software. This code is NOT licenced under GPL2 licence -// You cannnot redistribute it without written permission of copyright holder. -// ============================================================================ -// Load global variables +/** + * Network map. + * + * @category View + * @package Pandora FMS + * @subpackage Community + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ + */ + +// Begin. global $config; // Check user credentials. @@ -645,12 +662,24 @@ switch ($tab) { <?php } - ui_print_page_header( - __('Networkmap'), + // Header. + ui_print_standard_header( + __('List of network maps'), 'images/op_network.png', false, '', - false + false, + [], + [ + [ + 'link' => '', + 'label' => __('Topology maps'), + ], + [ + 'link' => '', + 'label' => __('Networkmap'), + ], + ] ); echo $result_txt; diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index a6811c1856..f7d3c7ea30 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -1,17 +1,32 @@ <?php -// This file is an example on how things must NEVER be done. -// Pandora FMS - http://pandorafms.com -// ================================================== -// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas -// Please see http://pandorafms.org for full contribution list -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation for version 2. -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// Load global vars +/** + * Monitor Status View. + * + * @category View + * @package Pandora FMS + * @subpackage Monitoring. + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ + */ + +// Begin. global $config; check_login(); @@ -67,7 +82,7 @@ if (! defined('METACONSOLE')) { switch ($section) { case 'fields': $buttons['fields']['active'] = true; - $subpage = ' - '.__('Custom fields'); + $subpage = ' » '.__('Custom fields'); break; default: @@ -75,13 +90,24 @@ if (! defined('METACONSOLE')) { break; } - ui_print_page_header( + // Header. + ui_print_standard_header( __('Monitor detail').$subpage, - '', + 'images/agent.png', false, '', true, - $buttons + $buttons, + [ + [ + 'link' => '', + 'label' => __('Monitoring'), + ], + [ + 'link' => '', + 'label' => __('Views'), + ], + ] ); if ($section == 'fields') { diff --git a/pandora_console/operation/agentes/tactical.php b/pandora_console/operation/agentes/tactical.php index d7f668597e..d82a749a85 100755 --- a/pandora_console/operation/agentes/tactical.php +++ b/pandora_console/operation/agentes/tactical.php @@ -1,17 +1,32 @@ <?php +/** + * Tactical View. + * + * @category View + * @package Pandora FMS + * @subpackage Monitoring. + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ + */ -// Pandora FMS - http://pandorafms.com -// ================================================== -// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas -// Please see http://pandorafms.org for full contribution list -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation for version 2. -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// Load global vars +// Begin. global $config; require_once 'include/functions_events.php'; @@ -46,17 +61,27 @@ if ($config['realtimestats'] == 0) { $updated_time .= '</a>'; } else { // $updated_info = __("Updated at realtime"); - $updated_info = ''; + $updated_info = ''; } // Header. -ui_print_page_header( +ui_print_standard_header( __('Tactical view'), '', false, '', false, - $updated_time + (array) $updated_time, + [ + [ + 'link' => '', + 'label' => __('Monitoring'), + ], + [ + 'link' => '', + 'label' => __('Views'), + ], + ] ); // Currently this function makes loading this page is impossible. Change diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 667e483ffd..4c5b25a469 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -153,7 +153,7 @@ if (is_ajax()) { // Case. 'lower', // NoACL. - true, + false, // ChildGroups. $recursion, // Serialized. @@ -1319,7 +1319,30 @@ if ($tab == 'main') { $maintab['active'] = false; } +// Interfaces tab. +$agent_interfaces = agents_get_network_interfaces( + false, + ['id_agente' => $id_agente] +); +$agent_interfaces_count = count($agent_interfaces[$id_agente]['interfaces']); + +if ($agent_interfaces_count > 0) { + $interfacetab['text'] = '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agente.'&tab=interface">'.html_print_image( + 'images/link.png', + true, + [ + 'title' => __('Interfaces'), + 'class' => 'invert_filter', + ] + ).'</a>'; + + if ($tab == 'interface') { + $interfacetab['active'] = true; + } else { + $interfacetab['active'] = false; + } +} // Alert tab. $alerttab['text'] = '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agente.'&tab=alert">'.html_print_image( @@ -1600,6 +1623,7 @@ $onheader = [ 'manage' => $managetab, 'main' => $maintab, 'alert' => $alerttab, + 'interface' => $interfacetab, 'inventory' => $inventorytab, 'collection' => $collectiontab, 'gis' => $gistab, @@ -1718,6 +1742,10 @@ switch ($tab) { $tab_name = ''; break; + case 'interface': + $tab_name = 'Interfaces'; + break; + case 'alert': $tab_name = 'Alerts'; break; @@ -1848,6 +1876,10 @@ switch ($tab) { include 'datos_agente.php'; break; + case 'interface': + include 'interface_view.php'; + break; + case 'alert': include 'alerts_status.php'; break; @@ -1943,4 +1975,4 @@ switch ($tab) { $('.subsubmenu').hide("fast"); },15000); } -</script> \ No newline at end of file +</script> diff --git a/pandora_console/operation/dashboard/dashboard.php b/pandora_console/operation/dashboard/dashboard.php index 3b081cfc7a..348b365e9f 100644 --- a/pandora_console/operation/dashboard/dashboard.php +++ b/pandora_console/operation/dashboard/dashboard.php @@ -1,7 +1,6 @@ <?php /** - * Extension to manage a list of gateways and the node address where they should - * point to. + * Dashboards. * * @category Dashboards * @package Pandora FMS @@ -27,6 +26,7 @@ * ============================================================================ */ +// Begin. global $config; require $config['homedir'].'/vendor/autoload.php'; @@ -70,6 +70,14 @@ if (is_ajax() === true) { } } } else { + if ((bool) is_metaconsole() === true) { + echo '<div class="meta_container_dashboard">'; + } + // Run. $cs->run(); + + if ((bool) is_metaconsole() === true) { + echo '</div>'; + } } diff --git a/pandora_console/operation/incidents/configure_integriaims_incident.php b/pandora_console/operation/incidents/configure_integriaims_incident.php index fa4fdbacda..5ac33db935 100644 --- a/pandora_console/operation/incidents/configure_integriaims_incident.php +++ b/pandora_console/operation/incidents/configure_integriaims_incident.php @@ -16,13 +16,6 @@ global $config; check_login(); -if (!(check_acl($config['id_user'], 0, 'IW') && check_acl($config['id_user'], 0, 'IR'))) { - // Doesn't have access to this page. - db_pandora_audit('ACL Violation', 'Trying to access IntegriaIMS ticket creation'); - include 'general/noaccess.php'; - exit; -} - require_once $config['homedir'].'/include/functions_integriaims.php'; $update = (isset($_GET['incident_id']) === true); @@ -42,7 +35,7 @@ if ($config['integria_enabled'] == 0) { } // Check connection to Integria IMS API. -$has_connection = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_login'); +$has_connection = integria_api_call(null, null, null, null, 'get_login'); if ($has_connection === false) { ui_print_error_message(__('Integria IMS API is not reachable')); @@ -59,19 +52,19 @@ $integria_users_values = []; $integria_types_values = []; $integria_status_values = []; -$integria_groups_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_groups'); +$integria_groups_csv = integria_api_call(null, null, null, null, 'get_groups'); get_array_from_csv_data_pair($integria_groups_csv, $integria_group_values); -$integria_status_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incidents_status'); +$integria_status_csv = integria_api_call(null, null, null, null, 'get_incidents_status'); get_array_from_csv_data_pair($integria_status_csv, $integria_status_values); -$integria_criticity_levels_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_priorities'); +$integria_criticity_levels_csv = integria_api_call(null, null, null, null, 'get_incident_priorities'); get_array_from_csv_data_pair($integria_criticity_levels_csv, $integria_criticity_values); -$integria_users_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_users'); +$integria_users_csv = integria_api_call(null, null, null, null, 'get_users'); $csv_array = explode("\n", $integria_users_csv); @@ -81,7 +74,7 @@ foreach ($csv_array as $csv_line) { } } -$integria_types_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_types'); +$integria_types_csv = integria_api_call(null, null, null, null, 'get_types'); get_array_from_csv_data_pair($integria_types_csv, $integria_types_values); @@ -105,7 +98,7 @@ $incident_content = str_replace(',', ':::', $incident_content); // Perform action. if ($create_incident === true) { // Call Integria IMS API method to create an incident. - $result_api_call = integria_api_call($config['integria_hostname'], $incident_creator, $config['integria_pass'], $config['integria_api_pass'], 'create_incident', [$incident_title, $incident_group_id, $incident_criticity_id, $incident_content, '', $incident_type, '', $incident_owner, '0', $incident_status], false, '', ','); + $result_api_call = integria_api_call(null, null, null, null, 'create_incident', [$incident_title, $incident_group_id, $incident_criticity_id, $incident_content, '', $incident_type, '', $incident_owner, '0', $incident_status], false, '', ','); // Necessary to explicitly set true if not false because function returns api call result in case of success instead of true value. $incident_created_ok = ($result_api_call != false) ? true : false; @@ -117,7 +110,7 @@ if ($create_incident === true) { ); } else if ($update_incident === true) { // Call Integria IMS API method to update an incident. - $result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'update_incident', [$incident_id_edit, $incident_title, $incident_content, '', $incident_group_id, $incident_criticity_id, 0, $incident_status, $incident_owner, 0, $incident_type], false, '', ','); + $result_api_call = integria_api_call(null, null, null, null, 'update_incident', [$incident_id_edit, $incident_title, $incident_content, '', $incident_group_id, $incident_criticity_id, 0, $incident_status, $incident_owner, 0, $incident_type], false, '', ','); // Necessary to explicitly set true if not false because function returns api call result in case of success instead of true value. $incident_updated_ok = ($result_api_call != false) ? true : false; @@ -132,7 +125,7 @@ if ($create_incident === true) { // If incident id is specified, retrieve incident values from api to populate combos with such values. if ($update) { // Call Integria IMS API method to get details of an incident given its id. - $result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_details', [$incident_id_edit], false, '', ','); + $result_api_call = integria_api_call(null, null, null, null, 'get_incident_details', [$incident_id_edit], false, '', ','); // API call does not return indexes, therefore future modifications of API function in Integria IMS may lead to inconsistencies when accessing resulting array in this file. $incident_details_separator = explode(',', $result_api_call); diff --git a/pandora_console/operation/incidents/dashboard_detail_integriaims_incident.php b/pandora_console/operation/incidents/dashboard_detail_integriaims_incident.php index d534df5902..9229ffdd90 100644 --- a/pandora_console/operation/incidents/dashboard_detail_integriaims_incident.php +++ b/pandora_console/operation/incidents/dashboard_detail_integriaims_incident.php @@ -18,13 +18,6 @@ require_once 'include/functions_integriaims.php'; check_login(); -if (!check_acl($config['id_user'], 0, 'IR')) { - // Doesn't have access to this page. - db_pandora_audit('ACL Violation', 'Trying to access IntegriaIMS ticket creation'); - include 'general/noaccess.php'; - exit; -} - // Check if Integria integration enabled. if ($config['integria_enabled'] == 0) { ui_print_error_message(__('In order to access ticket management system, integration with Integria IMS must be enabled and properly configured')); @@ -32,7 +25,7 @@ if ($config['integria_enabled'] == 0) { } // Check connection to Integria IMS API. -$has_connection = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_login', []); +$has_connection = integria_api_call(null, null, null, null, 'get_login', []); if ($has_connection === false) { ui_print_error_message(__('Integria IMS API is not reachable')); @@ -46,10 +39,10 @@ ui_require_css_file('integriaims'); $incident_id = (int) get_parameter('incident_id'); // API call. $result_api_call_list = integria_api_call( - $config['integria_hostname'], - $config['integria_user'], - $config['integria_pass'], - $config['integria_api_pass'], + null, + null, + null, + null, 'get_incident_details', [$incident_id] ); @@ -124,10 +117,7 @@ $table_files->head[1] = __('Timestamp'); $table_files->head[2] = __('Description'); $table_files->head[3] = __('User'); $table_files->head[4] = __('Size'); - -if (check_acl($config['id_user'], 0, 'IW')) { - $table_files->head[5] = __('Delete'); -} +$table_files->head[5] = __('Delete'); $table_files->data = []; @@ -159,9 +149,7 @@ if ($upload_file && ($_FILES['userfile']['name'] != '')) { $filecontent = base64_encode(file_get_contents($_FILES['userfile']['tmp_name'])); - $filename = str_replace(' ', '+', $filename); - - $result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'attach_file', [$incident_id, $filename, $filesize, $filedescription, $filecontent], false, '', '|;|'); + $result_api_call = integria_api_call(null, null, null, null, 'attach_file', [$incident_id, $filename, $filesize, $filedescription, $filecontent], false, '', '|;|'); // API method returns '0' string if success. $file_added = ($result_api_call === '0') ? true : false; @@ -178,7 +166,7 @@ if ($upload_file && ($_FILES['userfile']['name'] != '')) { // Delete file. if (isset($_GET['delete_file'])) { - $result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'delete_file', [$delete_file_id]); + $result_api_call = integria_api_call(null, null, null, null, 'delete_file', [$delete_file_id]); $file_deleted = false; @@ -195,7 +183,7 @@ if (isset($_GET['delete_file'])) { // Download file. if (isset($_GET['download_file'])) { - $file_base64 = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'download_file', [$download_file_id]); + $file_base64 = integria_api_call(null, null, null, null, 'download_file', [$download_file_id]); ob_end_clean(); $decoded = base64_decode($file_base64); @@ -221,7 +209,7 @@ if (isset($_GET['download_file'])) { } // Retrieve files belonging to incident and create list table. -$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_files', [$incident_id]); +$result_api_call = integria_api_call(null, null, null, null, 'get_incident_files', [$incident_id]); if ($result_api_call != false && strlen($result_api_call) > 0) { $files = []; @@ -242,11 +230,10 @@ foreach ($files as $key => $value) { $table_files->data[$i][2] = $value[12]; $table_files->data[$i][3] = $value[8]; $table_files->data[$i][4] = $value[13]; - if (check_acl($config['id_user'], 0, 'IW')) { - $table_files->data[$i][5] .= '<a id="link_delete_file" href="'.ui_get_full_url('index.php?sec=incident&sec2=operation/incidents/dashboard_detail_integriaims_incident&incident_id='.$incident_id.'&delete_file='.$value[0]).'" - onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">'; - $table_files->data[$i][5] .= html_print_image('images/cross.png', true, ['title' => __('Delete'), 'class' => 'invert_filter']); - } + $table_files->data[$i][5] .= '<a id="link_delete_file" href="'.ui_get_full_url('index.php?sec=incident&sec2=operation/incidents/dashboard_detail_integriaims_incident&incident_id='.$incident_id.'&delete_file='.$value[0]).'" + onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">'; + $table_files->data[$i][5] .= html_print_image('images/cross.png', true, ['title' => __('Delete'), 'class' => 'invert_filter']); + $table_files->data[$i][5] .= '</a>'; @@ -269,9 +256,7 @@ $table_files_section->data[2][0] .= '<div class="w100p right">'.html_print_submi $upload_file_form = '<div class="w100p">'; -if (check_acl($config['id_user'], 0, 'IW')) { - $upload_file_form .= '<form method="post" id="file_control" enctype="multipart/form-data">'.'<h4>'.__('Add attachment').'</h4>'.html_print_table($table_files_section, true).html_print_input_hidden('upload_file', 1, true); -} +$upload_file_form .= '<form method="post" id="file_control" enctype="multipart/form-data">'.'<h4>'.__('Add attachment').'</h4>'.html_print_table($table_files_section, true).html_print_input_hidden('upload_file', 1, true); $upload_file_form .= '<h4>'.__('Attached files').'</h4>'.html_print_table($table_files, true).'</form></div>'; @@ -324,7 +309,7 @@ $table_comments_section->data[1][1] .= '<div class="w100p right">'.html_print_su // Upload comment. If ticket is closed, this action cannot be performed. if ($upload_comment && $array_get_incidents[6] != 7) { - $result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'create_workunit', [$incident_id, $comment_description, '0.00', 0, 1, '0'], false, '', '|;|'); + $result_api_call = integria_api_call(null, null, null, null, 'create_workunit', [$incident_id, $comment_description, '0.00', 0, 1, '0'], false, '', '|;|'); // API method returns id of new comment if success. $comment_added = ($result_api_call >= '0') ? true : false; @@ -337,7 +322,7 @@ if ($upload_comment && $array_get_incidents[6] != 7) { } // Retrieve comments belonging to incident and create comments table. -$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_workunits', [$incident_id]); +$result_api_call = integria_api_call(null, null, null, null, 'get_incident_workunits', [$incident_id]); if ($result_api_call != false && strlen($result_api_call) > 0) { $comments = []; @@ -363,9 +348,8 @@ if (!empty($comments)) { $upload_comment_form = '<div class="w100p">'; -if (check_acl($config['id_user'], 0, 'IW')) { - $upload_comment_form .= '<form method="post" id="comment_form" enctype="multipart/form-data"><h4>'.__('Add comment').'</h4>'.html_print_table($table_comments_section, true).html_print_input_hidden('upload_comment', 1, true).'</form>'; -} +$upload_comment_form .= '<form method="post" id="comment_form" enctype="multipart/form-data"><h4>'.__('Add comment').'</h4>'.html_print_table($table_comments_section, true).html_print_input_hidden('upload_comment', 1, true).'</form>'; + $upload_comment_form .= '<h4>'.__('Comments').'</h4>'.$comment_table.'</div>'; @@ -487,4 +471,4 @@ $(document).ready (function () { }); }); -</script> +</script> \ No newline at end of file diff --git a/pandora_console/operation/incidents/incident_statistics.php b/pandora_console/operation/incidents/incident_statistics.php index af1867264f..b4966c1b96 100755 --- a/pandora_console/operation/incidents/incident_statistics.php +++ b/pandora_console/operation/incidents/incident_statistics.php @@ -18,12 +18,6 @@ require_once $config['homedir'].'/include/functions_graph.php'; check_login(); -if (! check_acl($config['id_user'], 0, 'IR') && ! check_acl($config['id_user'], 0, 'IW') && ! check_acl($config['id_user'], 0, 'IM')) { - db_pandora_audit('ACL Violation', 'Trying to access Incident section'); - include 'general/noaccess.php'; - exit; -} - ui_print_page_header(__('Incidents').' » '.__('Statistics'), 'images/book_edit.png', false, '', false, ''); if (!$config['integria_enabled']) { diff --git a/pandora_console/operation/incidents/integriaims_export_csv.php b/pandora_console/operation/incidents/integriaims_export_csv.php index d4be4443d6..04e0970ab4 100644 --- a/pandora_console/operation/incidents/integriaims_export_csv.php +++ b/pandora_console/operation/incidents/integriaims_export_csv.php @@ -20,14 +20,6 @@ require_once '../../include/functions_integriaims.php'; check_login(); -if (! check_acl($config['id_user'], 0, 'IR') && ! check_acl($config['id_user'], 0, 'IW') && ! check_acl($config['id_user'], 0, 'IM')) { - // Doesn't have access to this page. - db_pandora_audit('ACL Violation', 'Trying to access IntegriaIMS ticket creation'); - include 'general/noaccess.php'; - exit; -} - - // API calls. $status_incident = integriaims_get_details('status'); $group_incident = integriaims_get_details('group'); diff --git a/pandora_console/operation/incidents/list_integriaims_incidents.php b/pandora_console/operation/incidents/list_integriaims_incidents.php index a352300cd2..7d597a980e 100644 --- a/pandora_console/operation/incidents/list_integriaims_incidents.php +++ b/pandora_console/operation/incidents/list_integriaims_incidents.php @@ -18,13 +18,6 @@ require_once 'include/functions_integriaims.php'; check_login(); -if (! check_acl($config['id_user'], 0, 'IR')) { - // Doesn't have access to this page. - db_pandora_audit('ACL Violation', 'Trying to access IntegriaIMS ticket creation'); - include 'general/noaccess.php'; - exit; -} - // Header tabs. $onheader = integriaims_tabs('list_tab'); ui_print_page_header( @@ -43,7 +36,7 @@ if ($config['integria_enabled'] == 0) { } // Check connection to Integria IMS API. -$has_connection = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_login', []); +$has_connection = integria_api_call(null, null, null, null, 'get_login', []); if ($has_connection === false) { ui_print_error_message(__('Integria IMS API is not reachable')); @@ -70,10 +63,10 @@ $delete_incident = get_parameter('delete_incident'); if ($delete_incident) { // Call Integria IMS API method to delete an incident. $result_api_call_delete = integria_api_call( - $config['integria_hostname'], - $config['integria_user'], - $config['integria_pass'], - $config['integria_api_pass'], + null, + null, + null, + null, 'delete_incident', [$delete_incident] ); @@ -266,9 +259,7 @@ $table->head[4] = __('Prior'); $table->head[5] = __('Updated/Started'); $table->head[6] = __('Creator'); $table->head[7] = __('Owner'); -if (check_acl($config['id_user'], 0, 'IW') || check_acl($config['id_user'], 0, 'IM')) { - $table->head[8] = ''; -} +$table->head[8] = ''; $table->data = []; $i = 0; @@ -284,7 +275,7 @@ foreach ($incidents_paginated as $key => $value) { $table->data[$i][0] = '#'.$array_get_incidents[$key][0]; $table->data[$i][1] = '<a href="'.ui_get_full_url('index.php?sec=incident&sec2=operation/incidents/dashboard_detail_integriaims_incident&incident_id='.$array_get_incidents[$key][0]).'">'; - $table->data[$i][1] .= $array_get_incidents[$key][3]; + $table->data[$i][1] .= ui_print_truncate_text($array_get_incidents[$key][3], 160, false); $table->data[$i][1] .= '</a>'; $table->data[$i][2] = $group_incident[$array_get_incidents[$key][8]]; $table->data[$i][3] = $status_incident[$array_get_incidents[$key][6]].' / '.$resolution_incident[$array_get_incidents[$key][12]]; @@ -294,18 +285,14 @@ foreach ($incidents_paginated as $key => $value) { $table->data[$i][7] = $array_get_incidents[$key][5]; $table->data[$i][8] = ''; $table->cellclass[$i][8] = 'action_buttons'; - if (check_acl($config['id_user'], 0, 'IW')) { - $table->data[$i][8] .= '<a href="'.ui_get_full_url('index.php?sec=incident&sec2=operation/incidents/configure_integriaims_incident&incident_id='.$array_get_incidents[$key][0]).'">'; - $table->data[$i][8] .= html_print_image('images/config.png', true, ['title' => __('Edit')]); - $table->data[$i][8] .= '</a>'; - } + $table->data[$i][8] .= '<a href="'.ui_get_full_url('index.php?sec=incident&sec2=operation/incidents/configure_integriaims_incident&incident_id='.$array_get_incidents[$key][0]).'">'; + $table->data[$i][8] .= html_print_image('images/config.png', true, ['title' => __('Edit')]); + $table->data[$i][8] .= '</a>'; - if (check_acl($config['id_user'], 0, 'IM')) { - $table->data[$i][8] .= '<a id="link_delete_incident" href="'.ui_get_full_url('index.php?sec=incident&sec2=operation/incidents/list_integriaims_incidents&delete_incident='.$array_get_incidents[$key][0]).'" - onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">'; - $table->data[$i][8] .= html_print_image('images/cross.png', true, ['title' => __('Delete'), 'class' => 'invert_filter']); - $table->data[$i][8] .= '</a>'; - } + $table->data[$i][8] .= '<a id="link_delete_incident" href="'.ui_get_full_url('index.php?sec=incident&sec2=operation/incidents/list_integriaims_incidents&delete_incident='.$array_get_incidents[$key][0]).'" + onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">'; + $table->data[$i][8] .= html_print_image('images/cross.png', true, ['title' => __('Delete'), 'class' => 'invert_filter']); + $table->data[$i][8] .= '</a>'; $i++; } @@ -320,13 +307,11 @@ if (empty($table->data) === true) { } // Show button to create incident. -if (check_acl($config['id_user'], 0, 'IR')) { - echo '<form method="POST" action="'.ui_get_full_url('index.php?sec=incident&sec2=operation/incidents/configure_integriaims_incident').'">'; - echo '<div class="wi100p right">'; - html_print_submit_button(__('Create'), 'create_new_incident', false, 'class="sub next"'); - echo '</div>'; - echo '</form>'; -} +echo '<form method="POST" action="'.ui_get_full_url('index.php?sec=incident&sec2=operation/incidents/configure_integriaims_incident').'">'; + echo '<div class="wi100p right">'; + html_print_submit_button(__('Create'), 'create_new_incident', false, 'class="sub next"'); + echo '</div>'; +echo '</form>'; // Datapicker library for show calendar. ui_require_jquery_file('ui.datepicker-'.get_user_language(), 'include/javascript/i18n/'); diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index d43829b753..1d8178f1af 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -58,6 +58,9 @@ if (check_acl($config['id_user'], 0, 'AR')) { $sub2['operation/agentes/status_monitor']['text'] = __('Monitor detail'); $sub2['operation/agentes/status_monitor']['refr'] = 0; + $sub2['operation/agentes/interface_view']['text'] = __('Interface view'); + $sub2['operation/agentes/interface_view']['refr'] = 0; + enterprise_hook('tag_view_submenu'); $sub2['operation/agentes/alerts_status']['text'] = __('Alert detail'); @@ -267,9 +270,9 @@ if (check_acl($config['id_user'], 0, 'MR') || check_acl($config['id_user'], 0, ' $own_info = get_user_info($config['id_user']); if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) { - $own_groups = array_keys(users_get_groups($config['id_user'], 'IR')); + $own_groups = array_keys(users_get_groups($config['id_user'], 'MR')); } else { - $own_groups = array_keys(users_get_groups($config['id_user'], 'IR', false)); + $own_groups = array_keys(users_get_groups($config['id_user'], 'MR', false)); } foreach ($gisMaps as $gisMap) { @@ -278,10 +281,6 @@ if (check_acl($config['id_user'], 0, 'MR') || check_acl($config['id_user'], 0, ' continue; } - if (! check_acl($config['id_user'], $gisMap['group_id'], 'IR')) { - continue; - } - $sub2['operation/gis_maps/render_view&map_id='.$gisMap['id_tgis_map']]['text'] = mb_substr(io_safe_output($gisMap['map_name']), 0, 15); $sub2['operation/gis_maps/render_view&map_id='.$gisMap['id_tgis_map']]['id'] = mb_substr(io_safe_output($gisMap['map_name']), 0, 15); $sub2['operation/gis_maps/render_view&map_id='.$gisMap['id_tgis_map']]['title'] = io_safe_output($gisMap['map_name']); @@ -459,30 +458,25 @@ $sub['operation/users/user_edit_notifications']['refr'] = 0; // Incidents. -if (check_acl($config['id_user'], 0, 'IR') - || check_acl($config['id_user'], 0, 'IW') - || check_acl($config['id_user'], 0, 'IM') -) { - $temp_sec2 = $sec2; - $sec2 = 'incident'; - $sec2sub = 'operation/incidents/incident_statistics'; - $sub[$sec2]['text'] = __('Incidents'); - $sub[$sec2]['id'] = 'Incidents'; - $sub[$sec2]['type'] = 'direct'; - $sub[$sec2]['subtype'] = 'nolink'; - $sub[$sec2]['refr'] = 0; - $sub[$sec2]['subsecs'] = [ - 'operation/incidents/incident_detail', - 'operation/integria_incidents', - ]; +$temp_sec2 = $sec2; +$sec2 = 'incident'; +$sec2sub = 'operation/incidents/incident_statistics'; +$sub[$sec2]['text'] = __('Incidents'); +$sub[$sec2]['id'] = 'Incidents'; +$sub[$sec2]['type'] = 'direct'; +$sub[$sec2]['subtype'] = 'nolink'; +$sub[$sec2]['refr'] = 0; +$sub[$sec2]['subsecs'] = [ + 'operation/incidents/incident_detail', + 'operation/integria_incidents', +]; - $sub2 = []; - $sub2[$sec2sub]['text'] = __('Integria IMS statistics'); - $sub2['operation/incidents/list_integriaims_incidents']['text'] = __('Integria IMS ticket list'); +$sub2 = []; +$sub2[$sec2sub]['text'] = __('Integria IMS statistics'); +$sub2['operation/incidents/list_integriaims_incidents']['text'] = __('Integria IMS ticket list'); - $sub[$sec2]['sub2'] = $sub2; - $sec2 = $temp_sec2; -} +$sub[$sec2]['sub2'] = $sub2; +$sec2 = $temp_sec2; // Messages. diff --git a/pandora_console/operation/messages/message_edit.php b/pandora_console/operation/messages/message_edit.php index c2ce7529ec..b1748a6736 100644 --- a/pandora_console/operation/messages/message_edit.php +++ b/pandora_console/operation/messages/message_edit.php @@ -1,6 +1,6 @@ <?php /** - * Message Edition. + * Compose message view * * @category Workspace * @package Pandora FMS @@ -82,13 +82,23 @@ $buttons['create_message'] = [ ]; // Header. -ui_print_page_header( - __('Messages'), +ui_print_standard_header( + __('Compose message'), 'images/email_mc.png', false, '', false, - $buttons + $buttons, + [ + [ + 'link' => '', + 'label' => __('Workspace'), + ], + [ + 'link' => '', + 'label' => __('Messages'), + ], + ] ); // Read a message. @@ -381,4 +391,4 @@ html_print_div( ); echo '</form>'; -echo $jsOutput; \ No newline at end of file +echo $jsOutput; diff --git a/pandora_console/operation/messages/message_list.php b/pandora_console/operation/messages/message_list.php index 9b25b9da9c..fe96a811a5 100644 --- a/pandora_console/operation/messages/message_list.php +++ b/pandora_console/operation/messages/message_list.php @@ -1,9 +1,8 @@ <?php /** - * Extension to manage a list of gateways and the node address where they should - * point to. + * Sent / Received messages view. * - * @category Extensions + * @category Workspace * @package Pandora FMS * @subpackage Community * @version 1.0.0 @@ -27,23 +26,24 @@ * ============================================================================ */ +// Begin. require_once 'include/functions_messages.php'; global $config; $delete_msg = get_parameter('delete_message', 0); $multiple_delete = get_parameter('multiple_delete', 0); -$show_sent = get_parameter('show_sent', 0); +$show_sent = (bool) get_parameter('show_sent', false); $mark_unread = get_parameter('mark_unread', 0); $active_list = true; $active_sent = false; -if ($show_sent !== 0) { +if ($show_sent === true) { $active_list = false; $active_sent = true; } - +$tabSelectedMessage = ($show_sent === true) ? __('Sent messages') : __('Received messages'); $buttons['message_list'] = [ 'active' => $active_list, @@ -67,14 +67,25 @@ $buttons['create_message'] = [ ).'</a>', ]; -if (!is_ajax()) { - ui_print_page_header( - __('Messages'), +if (is_ajax() === false) { + // Header. + ui_print_standard_header( + $tabSelectedMessage, 'images/email_mc.png', false, '', false, - $buttons + $buttons, + [ + [ + 'link' => '', + 'label' => __('Workspace'), + ], + [ + 'link' => '', + 'label' => __('Messages'), + ], + ] ); } @@ -86,7 +97,7 @@ if ($mark_unread) { if ($delete_msg) { $id = (int) get_parameter('id'); - if ($show_sent) { + if ($show_sent === true) { $result = messages_delete_message_sent($id); } else { $result = messages_delete_message($id); @@ -104,7 +115,7 @@ if ($multiple_delete) { $ids = (array) get_parameter('delete_multiple_messages', []); foreach ($ids as $id) { - if ($show_sent) { + if ($show_sent === true) { $result = messages_delete_message_sent($id); } else { $result = messages_delete_message($id); @@ -122,7 +133,7 @@ if ($multiple_delete) { ); } -if ($show_sent) { +if ($show_sent === true) { // Sent view. $num_messages = messages_get_count_sent($config['id_user']); if ($num_messages > 0 && !is_ajax()) { @@ -142,7 +153,7 @@ if ($show_sent) { } } -if (empty($messages)) { +if (empty($messages) === true) { ui_print_info_message( [ 'no_close' => true, @@ -175,7 +186,7 @@ if (empty($messages)) { $table->head[5] = html_print_checkbox('all_delete_messages', 0, false, true, false); $table->head[0] = __('Status'); - if ($show_sent) { + if ($show_sent === true) { $table->head[1] = __('Destination'); } else { $table->head[1] = __('Sender'); @@ -194,7 +205,7 @@ if (empty($messages)) { $data[0] = ''; if ($message['read'] == 1) { - if ($show_sent) { + if ($show_sent === true) { $data[0] .= '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&show_sent=1&id_message='.$message_id.'">'; $data[0] .= html_print_image('images/email_inbox.png', true, ['border' => 0, 'title' => __('Click to read'), 'class' => 'invert_filter']); $data[0] .= '</a>'; @@ -204,7 +215,7 @@ if (empty($messages)) { $data[0] .= '</a>'; } } else { - if ($show_sent) { + if ($show_sent === true) { $data[0] .= '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&show_sent=1&id_message='.$message_id.'">'; $data[0] .= html_print_image('images/email_inbox.png', true, ['border' => 0, 'title' => __('Message unread - click to read'), 'class' => 'invert_filter']); $data[0] .= '</a>'; @@ -215,7 +226,7 @@ if (empty($messages)) { } } - if ($show_sent) { + if ($show_sent === true) { $dest_user = get_user_fullname($message['dest']); if (!$dest_user) { $dest_user = $message['dest']; @@ -231,7 +242,7 @@ if (empty($messages)) { $data[1] = $orig_user; } - if ($show_sent) { + if ($show_sent === true) { $data[2] = '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&show_sent=1&id_message='.$message_id.'">'; } else { $data[2] = '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&id_message='.$message_id.'">'; @@ -252,7 +263,7 @@ if (empty($messages)) { ); $table->cellclass[][4] = 'action_buttons'; - if ($show_sent) { + if ($show_sent === true) { $data[4] = '<a href="index.php?sec=message_list&sec2=operation/messages/message_list&show_sent=1&delete_message=1&id='.$message_id.'" onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['title' => __('Delete'), 'class' => 'invert_filter']).'</a>'; } else { @@ -264,8 +275,8 @@ if (empty($messages)) { } } -if (!empty($messages)) { - if ($show_sent) { +if (empty($messages) === false) { + if ($show_sent === true) { echo '<form method="post" action="index.php?sec=message_list&sec2=operation/messages/message_list&show_sent=1">'; } else { echo '<form method="post" action="index.php?sec=message_list&sec2=operation/messages/message_list">'; diff --git a/pandora_console/operation/netflow/nf_live_view.php b/pandora_console/operation/netflow/nf_live_view.php index dae0c9457a..a27686f8a7 100644 --- a/pandora_console/operation/netflow/nf_live_view.php +++ b/pandora_console/operation/netflow/nf_live_view.php @@ -370,7 +370,7 @@ if (is_metaconsole()) { ).'</td>'; $own_info = get_user_info($config['id_user']); echo '<td><span id="filter_group_color"><b>'.__('Group').'</b></span></td>'; - echo "<td colspan='2'>".html_print_select_groups($config['id_user'], 'IW', $own_info['is_admin'], 'assign_group', $filter['id_group'], '', '', -1, true, false, false).'</td>'; + echo "<td colspan='2'>".html_print_select_groups($config['id_user'], 'AR', $own_info['is_admin'], 'assign_group', $filter['id_group'], '', '', -1, true, false, false).'</td>'; echo '</tr>'; $advanced_toggle = '<table class="w100p">'; diff --git a/pandora_console/operation/reporting/graph_viewer.php b/pandora_console/operation/reporting/graph_viewer.php index 000179fe4e..5e2de125e0 100644 --- a/pandora_console/operation/reporting/graph_viewer.php +++ b/pandora_console/operation/reporting/graph_viewer.php @@ -196,7 +196,7 @@ if ($view_graph) { } $options['view']['text'] = '<a href="index.php?sec=reporting&sec2=operation/reporting/graph_viewer&view_graph=1&id='.$id_graph.'">'.html_print_image( - 'images/operation.png', + 'images/eye.png', true, [ 'title' => __('View graph'), diff --git a/pandora_console/operation/reporting/reporting_viewer.php b/pandora_console/operation/reporting/reporting_viewer.php index 5434553aea..34f3b7819c 100755 --- a/pandora_console/operation/reporting/reporting_viewer.php +++ b/pandora_console/operation/reporting/reporting_viewer.php @@ -125,7 +125,7 @@ if (check_acl_restricted_all($config['id_user'], $report_group, 'RW')) { $options['view'] = [ 'active' => true, 'text' => '<a href="index.php?sec=reporting&sec2=operation/reporting/reporting_viewer&id='.$id_report.'&pure='.$pure.'">'.html_print_image( - 'images/operation.png', + 'images/eye.png', true, [ 'title' => __('View report'), @@ -173,16 +173,24 @@ if (is_metaconsole()) { // Print header ui_meta_print_header(__('Reporting'), '', $options); } else { - ui_print_page_header( + // Header. + ui_print_standard_header( reporting_get_name($id_report), 'images/op_reporting.png', false, '', false, $options, - false, - '', - 55 + [ + [ + 'link' => '', + 'label' => __('Reporting'), + ], + [ + 'link' => '', + 'label' => __('Custom reports'), + ], + ] ); } diff --git a/pandora_console/operation/search_graphs.getdata.php b/pandora_console/operation/search_graphs.getdata.php index 9874ef37e2..13db4c2923 100644 --- a/pandora_console/operation/search_graphs.getdata.php +++ b/pandora_console/operation/search_graphs.getdata.php @@ -16,7 +16,7 @@ global $config; require_once 'include/functions_custom_graphs.php'; // Check ACL -$searchGraphs = check_acl($config['id_user'], 0, 'IR'); +$searchGraphs = check_acl($config['id_user'], 0, 'RR'); $graphs = false; diff --git a/pandora_console/operation/search_graphs.php b/pandora_console/operation/search_graphs.php index 69df4e4ded..8f76f0dea8 100755 --- a/pandora_console/operation/search_graphs.php +++ b/pandora_console/operation/search_graphs.php @@ -15,7 +15,7 @@ global $config; require_once 'include/functions_custom_graphs.php'; -$searchGraphs = check_acl($config['id_user'], 0, 'IR'); +$searchGraphs = check_acl($config['id_user'], 0, 'RR'); if ($graphs === false || !$searchGraphs) { echo "<br><div class='nf'>".__('Zero results found')."</div>\n"; diff --git a/pandora_console/operation/search_helps.php b/pandora_console/operation/search_helps.php index 2433355571..b205d265ef 100644 --- a/pandora_console/operation/search_helps.php +++ b/pandora_console/operation/search_helps.php @@ -13,8 +13,6 @@ // GNU General Public License for more details. global $config; -$totalHelps = check_acl($config['id_user'], 0, 'IR'); - if ($helps === false || !$searchHelps) { echo "<br><div class='nf'>".__('Zero results found.').sprintf( __('You can find more help in the <a class="underline" href="%s">wiki</a>'), diff --git a/pandora_console/operation/search_maps.getdata.php b/pandora_console/operation/search_maps.getdata.php index 2f8fa18a49..e96113cbb3 100644 --- a/pandora_console/operation/search_maps.getdata.php +++ b/pandora_console/operation/search_maps.getdata.php @@ -13,7 +13,7 @@ // GNU General Public License for more details. global $config; -$searchMaps = check_acl($config['id_user'], 0, 'IR'); +$searchMaps = check_acl($config['id_user'], 0, 'VR'); $maps = false; $totalMaps = 0; diff --git a/pandora_console/operation/search_maps.php b/pandora_console/operation/search_maps.php index 804051f000..0ab656d9b5 100755 --- a/pandora_console/operation/search_maps.php +++ b/pandora_console/operation/search_maps.php @@ -13,7 +13,7 @@ // GNU General Public License for more details. global $config; -$searchMaps = check_acl($config['id_user'], 0, 'IR'); +$searchMaps = check_acl($config['id_user'], 0, 'VR'); if ($maps === false || !$searchMaps) { echo "<br><div class='nf'>".__('Zero results found')."</div>\n"; diff --git a/pandora_console/operation/search_reports.php b/pandora_console/operation/search_reports.php index ee565676eb..d86b0c5446 100755 --- a/pandora_console/operation/search_reports.php +++ b/pandora_console/operation/search_reports.php @@ -19,9 +19,7 @@ require_once 'include/functions_reports.php'; $linkReport = false; $searchReports = check_acl($config['id_user'], 0, 'RR'); -if (check_acl($config['id_user'], 0, 'IW')) { - $linkReport = true; -} +$linkReport = true; if ($reports === false || !$searchReports) { echo "<br><div class='nf'>".__('Zero results found')."</div>\n"; diff --git a/pandora_console/operation/search_results.php b/pandora_console/operation/search_results.php index e1a9d078e3..5e0fa14384 100644 --- a/pandora_console/operation/search_results.php +++ b/pandora_console/operation/search_results.php @@ -19,7 +19,8 @@ enterprise_include('operation/reporting/custom_reporting.php'); $searchAgents = $searchAlerts = $searchModules = check_acl($config['id_user'], 0, 'AR'); $searchUsers = $searchPolicies = check_acl($config['id_user'], 0, 'AR'); -$searchMaps = $searchReports = $searchGraphs = check_acl($config['id_user'], 0, 'IR'); +$searchReports = $searchGraphs = check_acl($config['id_user'], 0, 'RR'); +$searchMaps = check_acl($config['id_user'], 0, 'VR'); $searchMain = true; $searchHelps = true; diff --git a/pandora_console/operation/snmpconsole/snmp_browser.php b/pandora_console/operation/snmpconsole/snmp_browser.php index dc2b373e82..39451616e7 100644 --- a/pandora_console/operation/snmpconsole/snmp_browser.php +++ b/pandora_console/operation/snmpconsole/snmp_browser.php @@ -1,9 +1,8 @@ <?php /** - * Extension to manage a list of gateways and the node address where they should - * point to. + * SMNP Browser view * - * @category Extensions + * @category Monitoring * @package Pandora FMS * @subpackage Community * @version 1.0.0 @@ -27,6 +26,7 @@ * ============================================================================ */ +// Begin. global $config; require_once $config['homedir'].'/include/functions_snmp_browser.php'; ui_require_javascript_file('pandora_snmp_browser'); @@ -42,7 +42,6 @@ if (!check_acl($config['id_user'], 0, 'AR')) { -// Header. $url = 'index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_browser&pure='.$config['pure']; if ($config['pure']) { // Windowed. @@ -70,13 +69,24 @@ if ($config['pure']) { $link['text'] .= '</a>'; } -ui_print_page_header( +// Header. +ui_print_standard_header( __('SNMP Browser'), 'images/op_snmp.png', false, 'snmp_browser_view', false, - [$link] + [$link], + [ + [ + 'link' => '', + 'label' => __('Monitoring'), + ], + [ + 'link' => '', + 'label' => __('SMNP'), + ], + ] ); // SNMP tree container. diff --git a/pandora_console/operation/snmpconsole/snmp_mib_uploader.php b/pandora_console/operation/snmpconsole/snmp_mib_uploader.php index 8b21420fb0..53bc811268 100644 --- a/pandora_console/operation/snmpconsole/snmp_mib_uploader.php +++ b/pandora_console/operation/snmpconsole/snmp_mib_uploader.php @@ -1,17 +1,32 @@ <?php +/** + * MIB Uploader view + * + * @category Monitoring + * @package Pandora FMS + * @subpackage Community + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ + */ -// Pandora FMS - http://pandorafms.com -// ================================================== -// Copyright (c) 2013-2021 Artica Soluciones Tecnologicas -// Please see http://pandorafms.org for full contribution list -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation for version 2. -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// Load global vars +// Begin. global $config; check_login(); @@ -24,8 +39,26 @@ if (! check_acl($config['id_user'], 0, 'PM')) { require_once 'include/functions_filemanager.php'; -// Header -ui_print_page_header(__('MIB uploader'), 'images/op_snmp.png', false, '', false); +// Header. +ui_print_standard_header( + __('MIB uploader'), + 'images/op_snmp.png', + false, + '', + false, + [], + [ + [ + 'link' => '', + 'label' => __('Monitoring'), + ], + [ + 'link' => '', + 'label' => __('SMNP'), + ], + ] +); + if (isset($config['filemanager']['message'])) { echo $config['filemanager']['message']; diff --git a/pandora_console/operation/snmpconsole/snmp_statistics.php b/pandora_console/operation/snmpconsole/snmp_statistics.php index a240c7d6a6..ca1a3ce6e7 100755 --- a/pandora_console/operation/snmpconsole/snmp_statistics.php +++ b/pandora_console/operation/snmpconsole/snmp_statistics.php @@ -81,8 +81,8 @@ $statistics['text'] = '<a href="index.php?sec=estado&sec2=operation/snmpconsole/ ).'</a>'; // Header -ui_print_page_header( - __('SNMP Console'), +ui_print_standard_header( + __('SNMP Statistics'), 'images/op_snmp.png', false, '', @@ -91,6 +91,16 @@ ui_print_page_header( $fullscreen, $list, $statistics, + ], + [ + [ + 'link' => '', + 'label' => __('Monitoring'), + ], + [ + 'link' => '', + 'label' => __('SNMP'), + ], ] ); diff --git a/pandora_console/operation/snmpconsole/snmp_view.php b/pandora_console/operation/snmpconsole/snmp_view.php index 5442f75823..2641cc51fb 100755 --- a/pandora_console/operation/snmpconsole/snmp_view.php +++ b/pandora_console/operation/snmpconsole/snmp_view.php @@ -133,10 +133,10 @@ if ($config['pure']) { // OPERATIONS -// Delete SNMP Trap entry Event (only incident management access). +// Delete SNMP Trap entry Event. if (isset($_GET['delete'])) { $id_trap = (int) get_parameter_get('delete', 0); - if ($id_trap > 0 && check_acl($config['id_user'], 0, 'IM')) { + if ($id_trap > 0) { if ($group_by) { $sql_ids_traps = 'SELECT id_trap, source FROM ttrap WHERE oid IN (SELECT oid FROM ttrap WHERE id_trap = '.$id_trap.') AND source IN (SELECT source FROM ttrap WHERE id_trap = '.$id_trap.')'; @@ -156,42 +156,30 @@ if (isset($_GET['delete'])) { __('Could not be deleted') ); } - } else { - db_pandora_audit( - 'ACL Violation', - 'Trying to delete SNMP event ID #'.$id_trap - ); } } -// Check Event (only incident write access). +// Check Event. if (isset($_GET['check'])) { $id_trap = (int) get_parameter_get('check', 0); - if (check_acl($config['id_user'], 0, 'IW')) { - $values = [ - 'status' => 1, - 'id_usuario' => $config['id_user'], - ]; - $result = db_process_sql_update('ttrap', $values, ['id_trap' => $id_trap]); - enterprise_hook('snmp_update_forwarded_modules', [$id_trap]); + $values = [ + 'status' => 1, + 'id_usuario' => $config['id_user'], + ]; + $result = db_process_sql_update('ttrap', $values, ['id_trap' => $id_trap]); + enterprise_hook('snmp_update_forwarded_modules', [$id_trap]); - ui_print_result_message( - $result, - __('Successfully updated'), - __('Could not be updated') - ); - } else { - db_pandora_audit( - 'ACL Violation', - 'Trying to checkout SNMP Trap ID'.$id_trap - ); - } + ui_print_result_message( + $result, + __('Successfully updated'), + __('Could not be updated') + ); } // Mass-process DELETE. if (isset($_POST['deletebt'])) { $trap_ids = get_parameter_post('snmptrapid', []); - if (is_array($trap_ids) && check_acl($config['id_user'], 0, 'IW')) { + if (is_array($trap_ids)) { if ($group_by) { foreach ($trap_ids as $key => $value) { $sql_ids_traps = 'SELECT id_trap, source FROM ttrap WHERE oid IN (SELECT oid FROM ttrap WHERE id_trap = '.$value.') @@ -210,28 +198,18 @@ if (isset($_POST['deletebt'])) { enterprise_hook('snmp_update_forwarded_modules', [$forward_info]); } } - } else { - db_pandora_audit( - 'ACL Violation', - 'Trying to mass-delete SNMP Trap ID' - ); } } // Mass-process UPDATE. if (isset($_POST['updatebt'])) { $trap_ids = get_parameter_post('snmptrapid', []); - if (is_array($trap_ids) && check_acl($config['id_user'], 0, 'IW')) { + if (is_array($trap_ids)) { foreach ($trap_ids as $id_trap) { $sql = sprintf("UPDATE ttrap SET status = 1, id_usuario = '%s' WHERE id_trap = %d", $config['id_user'], $id_trap); db_process_sql($sql); enterprise_hook('snmp_update_forwarded_modules', [$id_trap]); } - } else { - db_pandora_audit( - 'ACL Violation', - 'Trying to mass-delete SNMP Trap ID' - ); } } @@ -698,8 +676,8 @@ $trapcount = (int) db_get_value_sql($sql_count); // No traps. if (empty($traps)) { - // Header. - ui_print_page_header( + // Header + ui_print_standard_header( __('SNMP Console'), 'images/op_snmp.png', false, @@ -708,6 +686,16 @@ if (empty($traps)) { [ $list, $statistics, + ], + [ + [ + 'link' => '', + 'label' => __('Monitoring'), + ], + [ + 'link' => '', + 'label' => __('SNMP'), + ], ] ); @@ -796,8 +784,8 @@ if (empty($traps)) { ui_require_javascript_file('wz_jsgraphics'); ui_require_javascript_file('pandora_visual_console'); } else { - // Header. - ui_print_page_header( + // Header + ui_print_standard_header( __('SNMP Console'), 'images/op_snmp.png', false, @@ -807,6 +795,16 @@ if (empty($traps)) { $fullscreen, $list, $statistics, + ], + [ + [ + 'link' => '', + 'label' => __('Monitoring'), + ], + [ + 'link' => '', + 'label' => __('SNMP'), + ], ] ); } @@ -1025,7 +1023,7 @@ if ($traps !== false) { // Actions. $data[8] = ''; - if (empty($trap['status']) && check_acl($config['id_user'], 0, 'IW')) { + if (empty($trap['status'])) { $data[8] .= '<a href="'.$urlPagination.'&check='.$trap['id_trap'].'">'.html_print_image('images/ok.png', true, ['border' => '0', 'title' => __('Validate')]).'</a> '; } @@ -1045,17 +1043,15 @@ if ($traps !== false) { } else { $agent_trap_group = db_get_value('id_grupo', 'tagente', 'nombre', $trap['source']); - if ((check_acl($config['id_user'], $agent_trap_group, 'IM'))) { - $data[8] .= '<a href="'.$urlPagination.'&delete='.$trap['id_trap'].'&offset='.$offset.'" onClick="javascript:return confirm(\''.__('Are you sure?').'\')">'.html_print_image( - 'images/cross.png', - true, - [ - 'border' => '0', - 'title' => __('Delete'), - 'class' => 'invert_filter', - ] - ).'</a> '; - } + $data[8] .= '<a href="'.$urlPagination.'&delete='.$trap['id_trap'].'&offset='.$offset.'" onClick="javascript:return confirm(\''.__('Are you sure?').'\')">'.html_print_image( + 'images/cross.png', + true, + [ + 'border' => '0', + 'title' => __('Delete'), + 'class' => 'invert_filter', + ] + ).'</a> '; } $data[8] .= '<a href="javascript: toggleVisibleExtendedInfo('.$trap['id_trap'].');">'.html_print_image( @@ -1217,14 +1213,11 @@ if ($idx == 0) { unset($table); echo '<div class="w98p right">'; -if (check_acl($config['id_user'], 0, 'IW')) { - html_print_submit_button(__('Validate'), 'updatebt', false, 'class="sub ok"'); -} -if (check_acl($config['id_user'], 0, 'IM')) { - echo ' '; - html_print_submit_button(__('Delete'), 'deletebt', false, 'class="sub delete" onClick="javascript:return confirm(\''.__('Are you sure?').'\')"'); -} +html_print_submit_button(__('Validate'), 'updatebt', false, 'class="sub ok"'); + +echo ' '; +html_print_submit_button(__('Delete'), 'deletebt', false, 'class="sub delete" onClick="javascript:return confirm(\''.__('Are you sure?').'\')"'); echo '</div></form>'; diff --git a/pandora_console/operation/tree.php b/pandora_console/operation/tree.php index 93e1c18813..3a96bae3c9 100755 --- a/pandora_console/operation/tree.php +++ b/pandora_console/operation/tree.php @@ -147,12 +147,29 @@ switch ($tab) { break; } -if (!is_metaconsole()) { +if (is_metaconsole() === false) { if (!$strict_acl) { - $header_title = $header_title.' - '.$header_sub_title; + $header_title = $header_title.' » '.$header_sub_title; } - ui_print_page_header($header_title, 'images/extensions.png', false, 'tree_view', false, $tabs); + ui_print_standard_header( + $header_title, + 'images/extensions.png', + false, + 'tree_view', + false, + $tabs, + [ + [ + 'link' => '', + 'label' => __('Monitoring'), + ], + [ + 'link' => '', + 'label' => __('View'), + ], + ] + ); } // ---------------------Tabs ------------------------------------------- @@ -444,7 +461,6 @@ enterprise_hook('close_meta_frame'); .hide() .prop("id", "module_details_window") .appendTo('body'); - console.log("vamos a ver"); function show_module_detail_dialog(module_id, id_agent, server_name, offset, period, module_name) { var params = {}; var f = new Date(); diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php index e808a0a271..d988d3d388 100644 --- a/pandora_console/operation/users/user_edit.php +++ b/pandora_console/operation/users/user_edit.php @@ -1,9 +1,8 @@ <?php /** - * Extension to manage a list of gateways and the node address where they should - * point to. + * User edition. * - * @category Extensions + * @category Operation * @package Pandora FMS * @subpackage Community * @version 1.0.0 @@ -29,6 +28,7 @@ global $config; +$headerTitle = __('User detail editor'); // Load the header. require $config['homedir'].'/operation/users/user_edit_header.php'; @@ -127,7 +127,8 @@ if (isset($_GET['modified']) && !$view_mode) { $upd_info['ehorus_user_level_pass'] = get_parameter('ehorus_user_level_pass'); $upd_info['ehorus_user_level_enabled'] = get_parameter('ehorus_user_level_enabled', 0); - + $upd_info['integria_user_level_user'] = get_parameter('integria_user_level_user'); + $upd_info['integria_user_level_pass'] = get_parameter('integria_user_level_pass'); $is_admin = db_get_value('is_admin', 'tusuario', 'id_user', $id); @@ -731,12 +732,57 @@ if ($config['ehorus_enabled'] && $config['ehorus_user_level_conf']) { $row['control'] .= '<span id="test-ehorus-message" class="invisible"></span>'; $table_remote->data['ehorus_test'] = $row; - echo '<div class="ehorus_user_conf">'; - + echo '<div class="ehorus_user_conf user_edit_fourth_row">'; html_print_table($table_remote); echo '</div>'; } +if ($config['integria_enabled'] && $config['integria_user_level_conf']) { + // Integria IMS user remote login. + $table_remote = new StdClass(); + $table_remote->data = []; + $table_remote->width = '100%'; + $table_remote->id = 'integria-remote-setup'; + $table_remote->class = 'white_box'; + $table_remote->size['name'] = '30%'; + $table_remote->style['name'] = 'font-weight: bold'; + + // Integria IMS user level authentication. + // Title + $row = []; + $row['control'] = '<p class="edit_user_labels">'.__('Integria user configuration').': </p>'; + $table_remote->data['integria_user_level_conf'] = $row; + + // Integria IMS user. + $row = []; + $row['name'] = __('User'); + $row['control'] = html_print_input_text('integria_user_level_user', $user_info['integria_user_level_user'], '', 30, 100, true); + $table_remote->data['integria_user_level_user'] = $row; + + // Integria IMS pass. + $row = []; + $row['name'] = __('Password'); + $row['control'] = html_print_input_password('integria_user_level_pass', io_output_password($user_info['integria_user_level_pass']), '', 30, 100, true); + $table_remote->data['integria_user_level_pass'] = $row; + + // Test. + $integria_host = db_get_value('value', 'tconfig', 'token', 'integria_hostname'); + $integria_api_pass = db_get_value('value', 'tconfig', 'token', 'integria_api_pass'); + + $row = []; + $row['name'] = __('Test'); + $row['control'] = html_print_button(__('Start'), 'test-integria', false, 'integria_connection_test("'.$integria_host.'",'.$integria_api_pass.')', 'class="sub next"', true); + $row['control'] .= ' <span id="test-integria-spinner" class="invisible"> '.html_print_image('images/spinner.gif', true).'</span>'; + $row['control'] .= ' <span id="test-integria-success" class="invisible"> '.html_print_image('images/status_sets/default/severity_normal.png', true).'</span>'; + $row['control'] .= ' <span id="test-integria-failure" class="invisible"> '.html_print_image('images/status_sets/default/severity_critical.png', true).'</span>'; + $row['control'] .= '<span id="test-integria-message" class="invisible"></span>'; + $table_remote->data['integria_test'] = $row; + + echo '<div class="integria_user_conf">'; + html_print_table($table_remote); + echo '</div>'; +} + echo '<div class="edit_user_button">'; if (!$config['user_can_update_info']) { @@ -1280,4 +1326,75 @@ function ehorus_connection_test(host, port) { hideLoadingImage(); }); } + +function integria_connection_test(api_hostname, api_pass) { + var user = $('input#text-integria_user_level_user').val(); + var pass = $('input#password-integria_user_level_pass').val(); + + var badRequestMessage = '<?php echo __('Empty user or password'); ?>'; + var notFoundMessage = '<?php echo __('User not found'); ?>'; + var invalidPassMessage = '<?php echo __('Invalid password'); ?>'; + + var hideLoadingImage = function () { + $('#test-integria-spinner').hide(); + } + var showLoadingImage = function () { + $('#test-integria-spinner').show(); + } + var hideSuccessImage = function () { + $('#test-integria-success').hide(); + } + var showSuccessImage = function () { + $('#test-integria-success').show(); + } + var hideFailureImage = function () { + $('#test-integria-failure').hide(); + } + var showFailureImage = function () { + $('#test-integria-failure').show(); + } + var hideMessage = function () { + $('#test-integria-message').hide(); + } + var showMessage = function () { + $('#test-integria-message').show(); + } + var changeTestMessage = function (message) { + $('#test-integria-message').text(message); + } + + hideSuccessImage(); + hideFailureImage(); + hideMessage(); + showLoadingImage(); + + $.ajax({ + url: "ajax.php", + type: 'POST', + dataType: 'json', + data: { + page: 'godmode/setup/setup_integria', + operation: 'check_api_access', + integria_user: user, + integria_pass: pass, + api_hostname: api_hostname, + api_pass: api_pass, + } + }) + .done(function(data, textStatus, xhr) { + if (data.login == '1') { + showSuccessImage(); + } else { + showFailureImage(); + showMessage(); + } + }) + .fail(function(xhr, textStatus, errorThrown) { + showFailureImage(); + showMessage(); + }) + .always(function(xhr, textStatus) { + hideLoadingImage(); + }); + } </script> diff --git a/pandora_console/operation/users/user_edit_header.php b/pandora_console/operation/users/user_edit_header.php index 8f1d3e9a02..4e28945e04 100644 --- a/pandora_console/operation/users/user_edit_header.php +++ b/pandora_console/operation/users/user_edit_header.php @@ -113,17 +113,23 @@ if (is_metaconsole()) { $tab_name = 'User Notifications'; } - ui_print_page_header( - __('User detail editor'), + // Header. + ui_print_standard_header( + $headerTitle, 'images/user.png', false, $helpers, false, $buttons, - false, - '', - GENERIC_SIZE_TEXT, - '', - __('Workspace').ui_print_breadcrums($tab_name) + [ + [ + 'link' => '', + 'label' => __('Workspace'), + ], + [ + 'link' => '', + 'label' => __('Edit user'), + ], + ] ); } diff --git a/pandora_console/operation/users/user_edit_notifications.php b/pandora_console/operation/users/user_edit_notifications.php index c7cd4bb1b5..4228c16543 100644 --- a/pandora_console/operation/users/user_edit_notifications.php +++ b/pandora_console/operation/users/user_edit_notifications.php @@ -33,6 +33,7 @@ global $config; require_once $config['homedir'].'/include/functions_notifications.php'; // Load the header. +$headerTitle = __('User notifications'); require $config['homedir'].'/operation/users/user_edit_header.php'; if (get_parameter('change_label', 0)) { diff --git a/pandora_console/operation/visual_console/legacy_public_view.php b/pandora_console/operation/visual_console/legacy_public_view.php index eae9f1767f..f7c23f8d00 100644 --- a/pandora_console/operation/visual_console/legacy_public_view.php +++ b/pandora_console/operation/visual_console/legacy_public_view.php @@ -15,7 +15,11 @@ // The session is configured and started inside the config process. require_once '../../include/config.php'; -// Set root on homedir, as defined in setup +require_once $config['homedir'].'/vendor/autoload.php'; + +use PandoraFMS\User; + +// Set root on homedir, as defined in setup. chdir($config['homedir']); ob_start(); @@ -61,10 +65,13 @@ $id_layout = (int) get_parameter('id_layout'); $graph_javascript = (bool) get_parameter('graph_javascript'); $config['id_user'] = get_parameter('id_user'); -$myhash = md5($config['dbpass'].$id_layout.$config['id_user']); - -// Check input hash -if ($myhash != $hash) { +// Check input hash. +if (User::validatePublicHash($hash) !== true) { + db_pandora_audit( + 'Invalid public visual console', + 'Trying to access public visual console' + ); + include 'general/noaccess.php'; exit; } diff --git a/pandora_console/operation/visual_console/legacy_view.php b/pandora_console/operation/visual_console/legacy_view.php index c9b4c086b2..3dab575425 100644 --- a/pandora_console/operation/visual_console/legacy_view.php +++ b/pandora_console/operation/visual_console/legacy_view.php @@ -13,6 +13,8 @@ // GNU General Public License for more details. global $config; +use PandoraFMS\User; + // Login check require_once $config['homedir'].'/include/functions_visual_map.php'; ui_require_css_file('visual_maps'); @@ -122,7 +124,9 @@ $options['consoles_list']['text'] = '<a href="index.php?sec=network&sec2=godmode if ($vconsole_write || $vconsole_manage) { $url_base = 'index.php?sec=network&sec2=godmode/reporting/visual_console_builder&action='; - $hash = md5($config['dbpass'].$id_layout.$config['id_user']); + // Hash for auto-auth in public link. + $hash = User::generatePublicHash(); + $options['public_link']['text'] = '<a href="'.ui_get_full_url( 'operation/visual_console/public_console.php?hash='.$hash.'&id_layout='.$id_layout.'&id_user='.$config['id_user'] diff --git a/pandora_console/operation/visual_console/public_console.php b/pandora_console/operation/visual_console/public_console.php index 8a6ff462fc..5c6f2d1fcf 100755 --- a/pandora_console/operation/visual_console/public_console.php +++ b/pandora_console/operation/visual_console/public_console.php @@ -16,6 +16,10 @@ require_once '../../include/config.php'; $legacy = (bool) get_parameter('legacy', $config['legacy_vc']); +if (is_metaconsole() === true) { + $config['requirements_use_base_url'] = true; +} + if ($legacy === false) { include_once $config['homedir'].'/operation/visual_console/public_view.php'; } else { diff --git a/pandora_console/operation/visual_console/public_view.php b/pandora_console/operation/visual_console/public_view.php index e5e761cb19..759888aabb 100644 --- a/pandora_console/operation/visual_console/public_view.php +++ b/pandora_console/operation/visual_console/public_view.php @@ -13,6 +13,8 @@ // GNU General Public License for more details. require_once '../../include/config.php'; +use PandoraFMS\User; + // Set root on homedir, as defined in setup. chdir($config['homedir']); @@ -67,10 +69,13 @@ if (!isset($config['pure'])) { $config['pure'] = 0; } -$myhash = md5($config['dbpass'].$visualConsoleId.$config['id_user']); - // Check input hash. -if ($myhash != $hash) { +if (User::validatePublicHash($hash) !== true) { + db_pandora_audit( + 'Invalid public visual console', + 'Trying to access public visual console' + ); + include 'general/noaccess.php'; exit; } @@ -259,7 +264,15 @@ $visualConsoleItems = VisualConsole::getItemsFromDB( items, baseUrl, <?php echo ($refr * 1000); ?>, - handleUpdate + handleUpdate, + // BeforeUpdate. + null, + // Size. + null, + // User id. + "<?php echo get_parameter('id_user', ''); ?>", + // Hash. + "<?php echo get_parameter('hash', ''); ?>" ); var controls = document.getElementById('vc-controls'); diff --git a/pandora_console/operation/visual_console/pure_ajax.php b/pandora_console/operation/visual_console/pure_ajax.php deleted file mode 100644 index 9ef9fe3f56..0000000000 --- a/pandora_console/operation/visual_console/pure_ajax.php +++ /dev/null @@ -1,314 +0,0 @@ -<?php - -// Pandora FMS - http://pandorafms.com -// ================================================== -// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas -// Please see http://pandorafms.org for full contribution list -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU 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. -global $config; - -// Login check -require_once $config['homedir'].'/include/functions_visual_map.php'; - -check_login(); - -if (!defined('METACONSOLE')) { - $id_layout = (int) get_parameter('id'); -} else { - $id_layout = (int) get_parameter('id_visualmap'); -} - -if ($id_layout) { - $default_action = 'edit'; -} else { - $default_action = 'new'; -} - -if (!defined('METACONSOLE')) { - $action = get_parameterBetweenListValues( - 'action', - [ - 'new', - 'save', - 'edit', - 'update', - 'delete', - ], - $default_action - ); -} else { - $action = get_parameterBetweenListValues( - 'action2', - [ - 'new', - 'save', - 'edit', - 'update', - 'delete', - ], - $default_action - ); -} - -$refr = (int) get_parameter('refr', $config['vc_refr']); -$graph_javascript = (bool) get_parameter('graph_javascript', false); -$vc_refr = false; - -if (isset($config['vc_refr']) and $config['vc_refr'] != 0) { - $view_refresh = $config['vc_refr']; -} else { - $view_refresh = '300'; -} - -// Get input parameter for layout id -if (! $id_layout) { - db_pandora_audit( - 'ACL Violation', - 'Trying to access visual console without id layout' - ); - include 'general/noaccess.php'; - exit; -} - -$layout = db_get_row('tlayout', 'id', $id_layout); - -if (! $layout) { - db_pandora_audit( - 'ACL Violation', - 'Trying to access visual console without id layout' - ); - include 'general/noaccess.php'; - exit; -} - -$id_group = $layout['id_group']; -$layout_name = $layout['name']; -$background = $layout['background']; -$bwidth = $layout['width']; -$bheight = $layout['height']; - -$pure_url = '&pure='.$config['pure']; - -// ACL -$vconsole_read = check_acl($config['id_user'], $id_group, 'VR'); -$vconsole_write = check_acl($config['id_user'], $id_group, 'VW'); -$vconsole_manage = check_acl($config['id_user'], $id_group, 'VM'); - -if (! $vconsole_read && !$vconsole_write && !$vconsole_manage) { - db_pandora_audit( - 'ACL Violation', - 'Trying to access visual console without group access' - ); - include 'general/noaccess.php'; - exit; -} - -// Render map -$options = []; - -$options['consoles_list']['text'] = '<a href="index.php?sec=network&sec2=godmode/reporting/map_builder&refr='.$refr.'">'.html_print_image( - 'images/visual_console.png', - true, - ['title' => __('Visual consoles list')] -).'</a>'; - -if ($vconsole_write || $vconsole_manage) { - $url_base = 'index.php?sec=network&sec2=godmode/reporting/visual_console_builder&action='; - - $hash = md5($config['dbpass'].$id_layout.$config['id_user']); - - $options['public_link']['text'] = '<a href="'.ui_get_full_url('operation/visual_console/public_console.php?hash='.$hash.'&id_layout='.$id_layout.'&id_user='.$config['id_user']).'" target="_blank">'.html_print_image( - 'images/camera_mc.png', - true, - [ - 'title' => __('Show link to public Visual Console'), - 'class' => 'invert_filter', - ] - ).'</a>'; - $options['public_link']['active'] = false; - - $options['data']['text'] = '<a href="'.$url_base.$action.'&tab=data&id_visual_console='.$id_layout.'">'.html_print_image( - 'images/op_reporting.png', - true, - [ - 'title' => __('Main data'), - 'class' => 'invert_filter', - ] - ).'</a>'; - $options['list_elements']['text'] = '<a href="'.$url_base.$action.'&tab=list_elements&id_visual_console='.$id_layout.'">'.html_print_image( - 'images/list.png', - true, - [ - 'title' => __('List elements'), - 'class' => 'invert_filter', - ] - ).'</a>'; - - if (enterprise_installed()) { - $options['wizard_services']['text'] = '<a href="'.$url_base.$action.'&tab=wizard_services&id_visual_console='.$id_layout.'">'.html_print_image( - 'images/wand_services.png', - true, - [ - 'title' => __('Services wizard'), - 'class' => 'invert_filter', - ] - ).'</a>'; - } - - $options['wizard']['text'] = '<a href="'.$url_base.$action.'&tab=wizard&id_visual_console='.$id_layout.'">'.html_print_image( - 'images/wand.png', - true, - [ - 'title' => __('Wizard'), - 'class' => 'invert_filter', - ] - ).'</a>'; - $options['editor']['text'] = '<a href="'.$url_base.$action.'&tab=editor&id_visual_console='.$id_layout.'">'.html_print_image( - 'images/builder.png', - true, - [ - 'title' => __('Builder'), - 'class' => 'invert_filter', - ] - ).'</a>'; -} - -$options['view']['text'] = '<a href="index.php?sec=network&sec2=operation/visual_console/render_view&id='.$id_layout.'&refr='.$view_refresh.'">'.html_print_image( - 'images/eye.png', - true, - [ - 'title' => __('View'), - 'class' => 'invert_filter', - ] -).'</a>'; -$options['view']['active'] = true; - -if (!is_metaconsole()) { - if (!$config['pure']) { - $options['pure']['text'] = '<a href="index.php?sec=network&sec2=operation/visual_console/render_view&id='.$id_layout.'&refr='.$refr.'&pure=1">'.html_print_image( - 'images/full_screen.png', - true, - [ - 'title' => __('Full screen mode'), - 'class' => 'invert_filter', - ] - ).'</a>'; - ui_print_page_header($layout_name, 'images/visual_console.png', false, '', false, $options); - } - - // Set the hidden value for the javascript - html_print_input_hidden('metaconsole', 0); -} else { - // Set the hidden value for the javascript - html_print_input_hidden('metaconsole', 1); -} - - visual_map_print_visual_map( - $id_layout, - true, - true, - null, - null, - '', - false, - $graph_javascript - ); - - ?> - <style type="text/css"> - /* Avoid the main_pure container 1000px height */ - body.pure { - min-height: 100px; - } - div#main_pure { - height: 100%; - margin: 0px; - } - </style> - <?php - ui_require_javascript_file('wz_jsgraphics'); - ui_require_javascript_file('pandora_visual_console'); - $ignored_params['refr'] = ''; - ?> - -<script language="javascript" type="text/javascript"> - $(document).ready (function () { - var refr = <?php echo (int) $refr; ?>; - var pure = <?php echo (int) $config['pure']; ?>; - var href = "<?php echo ui_get_url_refresh($ignored_params); ?>"; - - $(".module_graph .menu_graph").css('display','none'); - - $(".parent_graph").each(function(){ - - if($(this).css('background-color') != 'rgb(255, 255, 255)'){ - $(this).css('color', '#999'); - } - }); - - $(".overlay").removeClass("overlay").addClass("overlaydisabled"); - - }); - - $(window).on('load', function () { - $('.item:not(.icon) img').each(function(){ - - - if($(this).css('float')=='left' || $(this).css('float')=='right'){ - - - $(this).css('margin-top',(parseInt($(this).parent().parent().css('height'))/2-parseInt($(this).css('height'))/2)+'px'); - $(this).css('margin-left',''); - - } - else{ - $(this).css('margin-left',(parseInt($(this).parent().parent().css('width'))/2-parseInt($(this).css('width'))/2)+'px'); - $(this).css('margin-top',''); - } - - }); - - $('.item > div').each( function() { - if ($(this).css('float')=='left' || $(this).css('float')=='right') { - if($(this).attr('id').indexOf('clock') || $(this).attr('id').indexOf('overlay')){ - $(this).css('margin-top',(parseInt($(this).parent().css('height'))/2-parseInt($(this).css('height'))/2)+'px'); - } - else{ - $(this).css('margin-top',(parseInt($(this).parent().css('height'))/2-parseInt($(this).css('height'))/2-15)+'px'); - } - $(this).css('margin-left',''); - } - else { - $(this).css('margin-left',(parseInt($(this).parent().css('width'))/2-parseInt($(this).css('width'))/2)+'px'); - $(this).css('margin-top',''); - } - }); - - $('.item > a > div').each(function(){ - if($(this).css('float')=='left' || $(this).css('float')=='right'){ - - - $(this).css('margin-top',(parseInt($(this).parent().parent().css('height'))/2-parseInt($(this).css('height'))/2-5)+'px'); - $(this).css('margin-left',''); - - } - else{ - $(this).css('margin-left',(parseInt($(this).parent().parent().css('width'))/2-parseInt($(this).css('width'))/2)+'px'); - $(this).css('margin-top',''); - } - - }); - - $(".graph:not([class~='noresizevc'])").each(function(){ - height = parseInt($(this).css("height")) - 30; - $(this).css('height', height); - }); - - }); -</script> \ No newline at end of file diff --git a/pandora_console/operation/visual_console/view.php b/pandora_console/operation/visual_console/view.php index 0b229c46d8..12ca2e3869 100644 --- a/pandora_console/operation/visual_console/view.php +++ b/pandora_console/operation/visual_console/view.php @@ -198,7 +198,7 @@ $options['view']['text'] = '<a href="index.php?sec=network&sec2=operation/visual ).'</a>'; $options['view']['active'] = true; -if (!is_metaconsole()) { +if (is_metaconsole() === false) { if (!$config['pure']) { $options['pure']['text'] = '<a href="index.php?sec=network&sec2=operation/visual_console/render_view&id='.$visualConsoleId.'&pure=1&refr='.$refr.'">'.html_print_image( 'images/full_screen.png', @@ -208,13 +208,25 @@ if (!is_metaconsole()) { 'class' => 'invert_filter', ] ).'</a>'; - ui_print_page_header( + + // Header. + ui_print_standard_header( $visualConsoleName, 'images/visual_console.png', false, 'visual_console_view', false, - $options + $options, + [ + [ + 'link' => '', + 'label' => __('Topology maps'), + ], + [ + 'link' => '', + 'label' => __('Visual console'), + ], + ] ); } @@ -465,7 +477,7 @@ if ($pure === true) { // Check groups can access user. $aclUserGroups = []; -if (!users_can_manage_group_all('AR')) { +if (users_can_manage_group_all('AR') === false) { $aclUserGroups = array_keys(users_get_groups(false, 'AR')); } diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index b5e1e63fcf..86e48653f6 100644 --- a/pandora_console/pandora_console.redhat.spec +++ b/pandora_console/pandora_console.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.754 -%define release 210513 +%define release 210528 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec index bc1637ef98..e5dcbf63ce 100644 --- a/pandora_console/pandora_console.rhel7.spec +++ b/pandora_console/pandora_console.rhel7.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.754 -%define release 210513 +%define release 210528 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec index 49e0304ef8..38ea611d43 100644 --- a/pandora_console/pandora_console.spec +++ b/pandora_console/pandora_console.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.754 -%define release 210513 +%define release 210528 %define httpd_name httpd # User and Group under which Apache is running %define httpd_name apache2 diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 90f2e4a076..ec7d1a2072 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -100,7 +100,7 @@ CREATE TABLE IF NOT EXISTS `tagente` ( -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tagente_datos` ( `id_agente_modulo` int(10) unsigned NOT NULL default '0', - `datos` double(22,5) default NULL, + `datos` double(50,5) default NULL, `utimestamp` bigint(20) default '0', KEY `data_index1` (`id_agente_modulo`, `utimestamp`), KEY `idx_utimestamp` USING BTREE (`utimestamp`) @@ -111,7 +111,7 @@ CREATE TABLE IF NOT EXISTS `tagente_datos` ( -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tagente_datos_inc` ( `id_agente_modulo` int(10) unsigned NOT NULL default '0', - `datos` double(22,5) default NULL, + `datos` double(50,5) default NULL, `utimestamp` int(20) unsigned default '0', KEY `data_inc_index_1` (`id_agente_modulo`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -681,7 +681,7 @@ CREATE TABLE IF NOT EXISTS `tevento` ( `owner_user` VARCHAR(100) NOT NULL DEFAULT '', `ack_utimestamp` BIGINT(20) NOT NULL DEFAULT '0', `custom_data` TEXT NOT NULL, - `data` double(22,5) default NULL, + `data` double(50,5) default NULL, `module_status` int(4) NOT NULL default '0', PRIMARY KEY (`id_evento`), KEY `idx_agente` (`id_agente`), @@ -1049,9 +1049,6 @@ CREATE TABLE IF NOT EXISTS `torigen` ( CREATE TABLE IF NOT EXISTS `tperfil` ( `id_perfil` int(10) unsigned NOT NULL auto_increment, `name` TEXT NOT NULL, - `incident_edit` tinyint(1) NOT NULL DEFAULT 0, - `incident_view` tinyint(1) NOT NULL DEFAULT 0, - `incident_management` tinyint(1) NOT NULL DEFAULT 0, `agent_view` tinyint(1) NOT NULL DEFAULT 0, `agent_edit` tinyint(1) NOT NULL DEFAULT 0, `alert_edit` tinyint(1) NOT NULL DEFAULT 0, @@ -1267,6 +1264,8 @@ CREATE TABLE IF NOT EXISTS `tusuario` ( `ehorus_user_level_user` VARCHAR(60), `ehorus_user_level_pass` VARCHAR(45), `ehorus_user_level_enabled` TINYINT(1), + `integria_user_level_user` VARCHAR(60), + `integria_user_level_pass` VARCHAR(45), CONSTRAINT `fk_filter_id` FOREIGN KEY (`id_filter`) REFERENCES tevent_filter (`id_filter`) ON DELETE SET NULL, UNIQUE KEY `id_user` (`id_user`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -3276,7 +3275,7 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_event` ( `ack_utimestamp` BIGINT(20) NOT NULL DEFAULT '0', `server_id` int(10) NOT NULL, `custom_data` TEXT NOT NULL DEFAULT '', - `data` double(22,5) default NULL, + `data` double(50,5) default NULL, `module_status` int(4) NOT NULL default '0', PRIMARY KEY (`id_evento`), KEY `idx_agente` (`id_agente`), @@ -3329,7 +3328,7 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_event_history` ( `ack_utimestamp` BIGINT(20) NOT NULL DEFAULT '0', `server_id` int(10) NOT NULL, `custom_data` TEXT NOT NULL DEFAULT '', - `data` double(22,5) default NULL, + `data` double(50,5) default NULL, `module_status` int(4) NOT NULL default '0', PRIMARY KEY (`id_evento`), KEY `idx_agente` (`id_agente`), diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 6fe259d898..b1d5f860c7 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -364,7 +364,7 @@ INSERT INTO `tusuario_perfil` (`id_up`, `id_usuario`, `id_perfil`, `id_grupo`, ` -- Dumping data for table `tperfil` -- -INSERT INTO `tperfil` VALUES (1,'Operator (Read)',0,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0),(2,'Operator (Write)',1,1,0,1,0,0,0,0,0,0,1,1,0,1,1,0,0,1,1,0,1,1,0),(3,'Chief Operator',1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,0,1,1,1,1,1,1,1),(4,'Group coordinator',1,1,1,1,1,1,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1),(5,'Pandora Administrator',1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); +INSERT INTO `tperfil` VALUES (1,'Operator (Read)',1,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0),(2,'Operator (Write)',1,0,0,0,0,0,0,1,1,0,1,1,0,0,1,1,0,1,1,0),(3,'Chief Operator',1,0,0,0,0,0,0,1,1,1,1,1,0,1,1,1,1,1,1,1),(4,'Group coordinator',1,1,1,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1),(5,'Pandora Administrator',1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); -- -- Dumping data for table `tnews` diff --git a/pandora_console/vendor/composer/ClassLoader.php b/pandora_console/vendor/composer/ClassLoader.php index 1a58957d25..247294d66e 100644 --- a/pandora_console/vendor/composer/ClassLoader.php +++ b/pandora_console/vendor/composer/ClassLoader.php @@ -42,6 +42,8 @@ namespace Composer\Autoload; */ class ClassLoader { + private $vendorDir; + // PSR-4 private $prefixLengthsPsr4 = array(); private $prefixDirsPsr4 = array(); @@ -57,6 +59,13 @@ class ClassLoader private $missingClasses = array(); private $apcuPrefix; + private static $registeredLoaders = array(); + + public function __construct($vendorDir = null) + { + $this->vendorDir = $vendorDir; + } + public function getPrefixes() { if (!empty($this->prefixesPsr0)) { @@ -300,6 +309,17 @@ class ClassLoader public function register($prepend = false) { spl_autoload_register(array($this, 'loadClass'), true, $prepend); + + if (null === $this->vendorDir) { + return; + } + + if ($prepend) { + self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; + } else { + unset(self::$registeredLoaders[$this->vendorDir]); + self::$registeredLoaders[$this->vendorDir] = $this; + } } /** @@ -308,6 +328,10 @@ class ClassLoader public function unregister() { spl_autoload_unregister(array($this, 'loadClass')); + + if (null !== $this->vendorDir) { + unset(self::$registeredLoaders[$this->vendorDir]); + } } /** @@ -367,6 +391,16 @@ class ClassLoader return $file; } + /** + * Returns the currently registered loaders indexed by their corresponding vendor directories. + * + * @return self[] + */ + public static function getRegisteredLoaders() + { + return self::$registeredLoaders; + } + private function findFileWithExtension($class, $ext) { // PSR-4 lookup diff --git a/pandora_console/vendor/composer/autoload_classmap.php b/pandora_console/vendor/composer/autoload_classmap.php index 4169e631c6..934f8e77e2 100644 --- a/pandora_console/vendor/composer/autoload_classmap.php +++ b/pandora_console/vendor/composer/autoload_classmap.php @@ -113,6 +113,7 @@ return array( 'Models\\VisualConsole\\Items\\Label' => $baseDir . '/include/rest-api/models/VisualConsole/Items/Label.php', 'Models\\VisualConsole\\Items\\Line' => $baseDir . '/include/rest-api/models/VisualConsole/Items/Line.php', 'Models\\VisualConsole\\Items\\ModuleGraph' => $baseDir . '/include/rest-api/models/VisualConsole/Items/ModuleGraph.php', + 'Models\\VisualConsole\\Items\\NetworkLink' => $baseDir . '/include/rest-api/models/VisualConsole/Items/NetworkLink.php', 'Models\\VisualConsole\\Items\\Percentile' => $baseDir . '/include/rest-api/models/VisualConsole/Items/Percentile.php', 'Models\\VisualConsole\\Items\\SimpleValue' => $baseDir . '/include/rest-api/models/VisualConsole/Items/SimpleValue.php', 'Models\\VisualConsole\\Items\\StaticGraph' => $baseDir . '/include/rest-api/models/VisualConsole/Items/StaticGraph.php', @@ -320,6 +321,7 @@ return array( 'PandoraFMS\\Module' => $baseDir . '/include/lib/Module.php', 'PandoraFMS\\ModuleStatus' => $baseDir . '/include/lib/ModuleStatus.php', 'PandoraFMS\\ModuleType' => $baseDir . '/include/lib/ModuleType.php', + 'PandoraFMS\\PublicLogin' => $baseDir . '/include/lib/PublicLogin.php', 'PandoraFMS\\User' => $baseDir . '/include/lib/User.php', 'PandoraFMS\\View' => $baseDir . '/include/lib/View.php', 'PandoraFMS\\Websockets\\WSManager' => $baseDir . '/include/lib/Websockets/WSManager.php', diff --git a/pandora_console/vendor/composer/autoload_real.php b/pandora_console/vendor/composer/autoload_real.php index 33d719ba60..d079efd543 100644 --- a/pandora_console/vendor/composer/autoload_real.php +++ b/pandora_console/vendor/composer/autoload_real.php @@ -25,7 +25,7 @@ class ComposerAutoloaderInitfdecadadce22e6dde51e9535fe4ad7aa require __DIR__ . '/platform_check.php'; spl_autoload_register(array('ComposerAutoloaderInitfdecadadce22e6dde51e9535fe4ad7aa', 'loadClassLoader'), true, true); - self::$loader = $loader = new \Composer\Autoload\ClassLoader(); + self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); spl_autoload_unregister(array('ComposerAutoloaderInitfdecadadce22e6dde51e9535fe4ad7aa', 'loadClassLoader')); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); diff --git a/pandora_console/vendor/composer/autoload_static.php b/pandora_console/vendor/composer/autoload_static.php index e1953333f9..fc522a2370 100644 --- a/pandora_console/vendor/composer/autoload_static.php +++ b/pandora_console/vendor/composer/autoload_static.php @@ -195,6 +195,7 @@ class ComposerStaticInitfdecadadce22e6dde51e9535fe4ad7aa 'Models\\VisualConsole\\Items\\Label' => __DIR__ . '/../..' . '/include/rest-api/models/VisualConsole/Items/Label.php', 'Models\\VisualConsole\\Items\\Line' => __DIR__ . '/../..' . '/include/rest-api/models/VisualConsole/Items/Line.php', 'Models\\VisualConsole\\Items\\ModuleGraph' => __DIR__ . '/../..' . '/include/rest-api/models/VisualConsole/Items/ModuleGraph.php', + 'Models\\VisualConsole\\Items\\NetworkLink' => __DIR__ . '/../..' . '/include/rest-api/models/VisualConsole/Items/NetworkLink.php', 'Models\\VisualConsole\\Items\\Percentile' => __DIR__ . '/../..' . '/include/rest-api/models/VisualConsole/Items/Percentile.php', 'Models\\VisualConsole\\Items\\SimpleValue' => __DIR__ . '/../..' . '/include/rest-api/models/VisualConsole/Items/SimpleValue.php', 'Models\\VisualConsole\\Items\\StaticGraph' => __DIR__ . '/../..' . '/include/rest-api/models/VisualConsole/Items/StaticGraph.php', @@ -402,6 +403,7 @@ class ComposerStaticInitfdecadadce22e6dde51e9535fe4ad7aa 'PandoraFMS\\Module' => __DIR__ . '/../..' . '/include/lib/Module.php', 'PandoraFMS\\ModuleStatus' => __DIR__ . '/../..' . '/include/lib/ModuleStatus.php', 'PandoraFMS\\ModuleType' => __DIR__ . '/../..' . '/include/lib/ModuleType.php', + 'PandoraFMS\\PublicLogin' => __DIR__ . '/../..' . '/include/lib/PublicLogin.php', 'PandoraFMS\\User' => __DIR__ . '/../..' . '/include/lib/User.php', 'PandoraFMS\\View' => __DIR__ . '/../..' . '/include/lib/View.php', 'PandoraFMS\\Websockets\\WSManager' => __DIR__ . '/../..' . '/include/lib/Websockets/WSManager.php', diff --git a/pandora_console/views/dashboard/header.php b/pandora_console/views/dashboard/header.php index 64626056dd..c828740565 100644 --- a/pandora_console/views/dashboard/header.php +++ b/pandora_console/views/dashboard/header.php @@ -189,7 +189,7 @@ $combo_dashboard['text'] .= html_print_select( true, false, true, - '', + 'select-dashboard-width', false, '' ); diff --git a/pandora_plugins/message_app_connectors/.vscode/settings.json b/pandora_plugins/message_app_connectors/.vscode/settings.json deleted file mode 100644 index cf160325ad..0000000000 --- a/pandora_plugins/message_app_connectors/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "python.pythonPath": "slack/venv/bin/python" -} diff --git a/pandora_plugins/message_app_connectors/discord/pandora_discord_cli.py b/pandora_plugins/message_app_connectors/discord/pandora_discord_cli.py index 5a278a0e6b..522f5fb75e 100644 --- a/pandora_plugins/message_app_connectors/discord/pandora_discord_cli.py +++ b/pandora_plugins/message_app_connectors/discord/pandora_discord_cli.py @@ -21,7 +21,7 @@ parser.add_argument('--author_icon_url', help='Alert custom author icon url ', d parser.add_argument('--thumb', help='Custom thumbnail url', default='') parser.add_argument('--api_conf', help='Api configuration parameters in coma separate keypairs. EX "user=admin,pass=pandora,api_pass=1234,api_url=http://test.artica.es/pandora_console/include/api.php"') parser.add_argument('--module_graph', help='Uses pandora API to generate a module graph and attach it to the alert needs module_id and interval parameters in coma separate keypairs. EX "module_id=55,interval=3600"') -parser.add_argument('--tmp_dir', help='Temporary path to store grph images', default='/tmp') +parser.add_argument('--tmp_dir', help='Temporary path to store graph images', default='/tmp') args = parser.parse_args() @@ -50,15 +50,15 @@ def parse_api_conf(cConf): apid = parse_dic(cConf) if apid.get("user") is None: - print ("Error no user defined in api_conf keypairs, skiping graph generation.") + print ("Error no user defined in api_conf keypairs, skipping graph generation.") return if apid.get("pass") is None: - print ("Error no password defined in api_conf keypairs, skiping graph generation.") + print ("Error no password defined in api_conf keypairs, skipping graph generation.") return if apid.get("api_pass") is None: - print ("Error no Api pass defined in api_conf keypairs, skiping graph generation.") + print ("Error no Api pass defined in api_conf keypairs, skipping graph generation.") return if apid.get("api_url") is None: @@ -78,7 +78,7 @@ def parse_graph_conf(cGraph): # Parse Api config graphd = parse_dic(cGraph) if graphd.get("module_id") is None: - print ("error no module_id defined in module_graph keypairs, skiping graph generation.") + print ("error no module_id defined in module_graph keypairs, skipping graph generation.") return if graphd.get("interval") is None: @@ -91,19 +91,19 @@ def parse_graph_conf(cGraph): def get_graph_by_moduleid (baseUrl,pUser, pPass, apiPass, moduleId, graphInterval) : sep="url_encode_separator_%7C" try: - url = f"{baseUrl}?op=get&op2=module_graph&id={moduleId}&other={graphInterval}%7C1&other_mode={sep}C&apipass={apiPass}&api=1&user={pUser}&pass={pPass}" + url = f"{baseUrl}?op=get&op2=module_graph&id={moduleId}&other={graphInterval}%7C1&other_mode={sep}&apipass={apiPass}&api=1&user={pUser}&pass={pPass}" graph = requests.get(url) if graph.status_code != 200: - print (f"Error requested api url, status code: {graph.status_code}. Skiping graph generation") + print (f"Error requested api url, status code: {graph.status_code}. skipping graph generation") return None if graph.text == "auth error": - print (f"Error requested Pandora api url, status code: {graph.text}. Skiping graph generation") + print (f"Error requested Pandora api url, status code: {graph.text}. skipping graph generation") return None if graph.text == "Id does not exist in database.": - print (f"Error requested Pandora api url, status code: {graph.text}. Skiping graph generation") + print (f"Error requested Pandora api url, status code: {graph.text}. skipping graph generation") return None except: - print("Error requested api url. Skiping graph generation") + print("Error requested api url. skipping graph generation") return None return graph diff --git a/pandora_plugins/message_app_connectors/gchat/pandora-gchat-cli.py b/pandora_plugins/message_app_connectors/gchat/pandora-gchat-cli.py index 5e2a47b3f8..4584768ec7 100644 --- a/pandora_plugins/message_app_connectors/gchat/pandora-gchat-cli.py +++ b/pandora_plugins/message_app_connectors/gchat/pandora-gchat-cli.py @@ -88,9 +88,9 @@ def sendMessage(url, message): header = {'Content-Type': 'application/json; charset: UTF-8'} response = requests.post(url, headers=header, data=message) - print(f"Mesage sent succefuly: {response.status_code}") + print(f"Message sent successfully: {response.status_code}") except: - print("Error requested api url. Skiping graph generation") + print("Error requested api url. skipping graph generation") return None return response diff --git a/pandora_plugins/message_app_connectors/slack/pandora-slack-cli.py b/pandora_plugins/message_app_connectors/slack/pandora-slack-cli.py index 31cfa97811..b09938b885 100644 --- a/pandora_plugins/message_app_connectors/slack/pandora-slack-cli.py +++ b/pandora_plugins/message_app_connectors/slack/pandora-slack-cli.py @@ -21,7 +21,7 @@ parser.add_argument('-D', '--desc', help='Slack description message', default='' parser.add_argument('-F','--footer', help='Custom footer, default: PandoraFMS', default='PandoraFMS') parser.add_argument('--api_conf', help='Api configuration parameters in coma separate keypairs. EX "user=admin,pass=pandora,api_pass=1234,api_url=http://test.artica.es/pandora_console/include/api.php"') parser.add_argument('--module_graph', help='Uses pandora API to generate a module graph and attach it to the alert needs module_id and interval parameters in coma separate keypairs. EX "module_id=55,interval=3600"') -parser.add_argument('--tmp_dir', help='Temporary path to store grph images', default='/tmp') +parser.add_argument('--tmp_dir', help='Temporary path to store graph images', default='/tmp') args = parser.parse_args() filename = None @@ -49,22 +49,22 @@ def compose_message (values, tittle, emoji, message, footer): return m def parse_api_conf(cConf): - """Check apiconfiguration parameters """ + """Check api configuration parameters """ if args.api_conf : # Parse Api config print ("Api config enable") apid = parse_dic(cConf) if apid.get("user") is None: - print ("Warning. no user defined in api_conf keypairs, skiping graph generation.") + print ("Warning. no user defined in api_conf keypairs, skipping graph generation.") return None if apid.get("pass") is None: - print ("Warning. no password defined in api_conf keypairs, skiping graph generation.") + print ("Warning. no password defined in api_conf keypairs, skipping graph generation.") return None if apid.get("api_pass") is None: - print ("Warning. no api pass defined in api_conf keypairs, skiping graph generation.") + print ("Warning. no api pass defined in api_conf keypairs, skipping graph generation.") return None if apid.get("api_url") is None: @@ -81,7 +81,7 @@ def parse_graph_conf(cGraph): # Parse Api config graphd = parse_dic(cGraph) if graphd.get("module_id") is None: - print ("Warning. no module_id defined in module_graph keypairs, skiping graph generation.") + print ("Warning. no module_id defined in module_graph keypairs, skipping graph generation.") return if graphd.get("interval") is None: @@ -89,26 +89,26 @@ def parse_graph_conf(cGraph): return graphd else: - print("Warning. no module_graph keypairs defined, skiping graph generation") + print("Warning. no module_graph keypairs defined, skipping graph generation") return None def get_graph_by_moduleid (baseUrl,pUser, pPass, apiPass, moduleId, graphInterval, sep="url_encode_separator_%7C") : """Call Pandorafms api to get graph""" try: - url = f"{baseUrl}?op=get&op2=module_graph&id={moduleId}&other={graphInterval}%7C1&other_mode={sep}C&apipass={apiPass}&api=1&user={pUser}&pass={pPass}" + url = f"{baseUrl}?op=get&op2=module_graph&id={moduleId}&other={graphInterval}%7C1&other_mode={sep}&apipass={apiPass}&api=1&user={pUser}&pass={pPass}" graph = requests.get(url) if graph.status_code != 200: - print (f"Error requested api url, status code: {graph.status_code}. Skiping graph generation") + print (f"Error requested api url, status code: {graph.status_code}. skipping graph generation") return None if graph.text == "auth error": - print (f"Error requested Pandora api url, status code: {graph.text}. Skiping graph generation") + print (f"Error requested Pandora api url, status code: {graph.text}. skipping graph generation") return None if graph.text == "Id does not exist in database.": - print (f"Error requested Pandora api url, status code: {graph.text}. Skiping graph generation") + print (f"Error requested Pandora api url, status code: {graph.text}. skipping graph generation") return None except: - print("Error requested api url. Skiping graph generation") + print("Error requested api url. skipping graph generation") return None return graph @@ -166,7 +166,7 @@ if args.api_conf : else: filename = None # Send message -send_message(messageString, args.channel, client, "> Mesage sent succefuly") +send_message(messageString, args.channel, client, "> Message sent successfully") if filename is not None: if os.path.isfile(filename): send_image(filename, args.channel, client) if args.footer: send_message(args.footer, args.channel, client) diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index ea23fcb54b..abc97a4a1f 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 7.0NG.754-210513 +Version: 7.0NG.754-210528 Architecture: all Priority: optional Section: admin diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh index 1d3514d6c0..338f41f060 100644 --- a/pandora_server/DEBIAN/make_deb_package.sh +++ b/pandora_server/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.754-210513" +pandora_version="7.0NG.754-210528" package_cpan=0 package_pandora=1 diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index cf8e4bc2e7..85c2fd20f8 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -45,7 +45,7 @@ our @EXPORT = qw( # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.754"; -my $pandora_build = "210513"; +my $pandora_build = "210528"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index a384d3701e..bbce7913e9 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -4652,11 +4652,17 @@ sub get_module_status ($$$) { } # (-inf, critical_min), [critical_max, +inf) else { - return 1 if ($data < $critical_min || $data >= $critical_max); - return 1 if ($data <= $critical_max && $critical_max < $critical_min); + if ($critical_min == 0) { + return 1 if ($data > $critical_max); + }elsif ($critical_max == 0) { + return 1 if ($data <= $critical_min); + } else { + return 1 if ($data < $critical_min || $data >= $critical_max); + return 1 if ($data <= $critical_max && $critical_max < $critical_min); + } } } - + # Warning if ($warning_min ne $warning_max) { # [warning_min, warning_max) @@ -4666,8 +4672,14 @@ sub get_module_status ($$$) { } # (-inf, warning_min), [warning_max, +inf) else { - return 2 if ($data < $warning_min || $data >= $warning_max); - return 2 if ($data <= $warning_max && $warning_max < $warning_min); + if ($warning_min == 0) { + return 1 if ($data > $warning_max); + }elsif ($warning_max == 0) { + return 1 if ($data <= $warning_min); + } else { + return 2 if ($data < $warning_min || $data >= $warning_max); + return 2 if ($data <= $warning_max && $warning_max < $warning_min); + } } } } diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index 4e20c5e69f..ba539d94e6 100644 --- a/pandora_server/lib/PandoraFMS/PluginTools.pm +++ b/pandora_server/lib/PandoraFMS/PluginTools.pm @@ -34,7 +34,7 @@ our @ISA = qw(Exporter); # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.754"; -my $pandora_build = "210513"; +my $pandora_build = "210528"; our $VERSION = $pandora_version." ".$pandora_build; our %EXPORT_TAGS = ( 'all' => [ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 8a8cfd64fa..e0c3bd5aab 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.754 -%define release 210513 +%define release 210528 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 36504c200e..1597fac0db 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.754 -%define release 210513 +%define release 210528 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 34be4a360a..d896afab15 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.754" -PI_BUILD="210513" +PI_BUILD="210528" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 83a9dfdec9..32ff1f6268 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.754 Build 210513"; +my $version = "7.0NG.754 Build 210528"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 0d8a97ae19..ab5f85af33 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.754 Build 210513"; +my $version = "7.0NG.754 Build 210528"; # save program name for logging my $progname = basename($0); @@ -192,8 +192,8 @@ sub help_screen{ help_screen_line('--add_profile', '<user_name> <profile_name> <group_name>', 'Add perfil to user'); help_screen_line('--delete_profile', '<user_name> <profile_name> <group_name>', 'Delete perfil from user'); help_screen_line('--add_profile_to_user', '<user_id> <profile_name> [<group_name>]', 'Add a profile in group to a user'); - help_screen_line('--create_profile', "<profile_name> <incident_view> <incident_edit> <incident_management> <agent_view>\n\t <agent_edit> <agent_disable> <alert_edit> <alert_management> <user_management> <db_management>\n\t <event_view> <event_edit> <event_management> <report_view> <report_edit> <report_management>\n\t <map_view> <map_edit> <map_management> <vconsole_view> <vconsole_edit> <vconsole_management>\n\t <pandora_management>", 'Create profile'); - help_screen_line('--update_profile', "<profile_name> <incident_view> <incident_edit> <incident_management> <agent_view>\n\t <agent_edit> <agent_disable> <alert_edit> <alert_management> <user_management> <db_management>\n\t <event_view> <event_edit> <event_management> <report_view> <report_edit> <report_management>\n\t <map_view> <map_edit> <map_management> <vconsole_view> <vconsole_edit> <vconsole_management>\n\t <pandora_management>", 'Modify profile'); + help_screen_line('--create_profile', "<profile_name> <agent_view>\n\t <agent_edit> <agent_disable> <alert_edit> <alert_management> <user_management> <db_management>\n\t <event_view> <event_edit> <event_management> <report_view> <report_edit> <report_management>\n\t <map_view> <map_edit> <map_management> <vconsole_view> <vconsole_edit> <vconsole_management>\n\t <pandora_management>", 'Create profile'); + help_screen_line('--update_profile', "<profile_name> <agent_view>\n\t <agent_edit> <agent_disable> <alert_edit> <alert_management> <user_management> <db_management>\n\t <event_view> <event_edit> <event_management> <report_view> <report_edit> <report_management>\n\t <map_view> <map_edit> <map_management> <vconsole_view> <vconsole_edit> <vconsole_management>\n\t <pandora_management>", 'Modify profile'); help_screen_line('--disable_eacl', '', 'Disable enterprise ACL system'); help_screen_line('--enable_eacl', '', 'Enable enterprise ACL system'); help_screen_line('--disable_double_auth', '<user_name>', 'Disable the double authentication for the specified user'); @@ -563,14 +563,14 @@ sub pandora_create_user_profile ($$$$) { ########################################################################## ## Create profile. ########################################################################## -sub pandora_create_profile ($$$$$$$$$$$$$$$$$$$$$$$$$) { - my ($dbh, $profile_name, $incident_view,$incident_edit, $incident_management, $agent_view, +sub pandora_create_profile ($$$$$$$$$$$$$$$$$$$$$$) { + my ($dbh, $profile_name, $agent_view, $agent_edit, $agent_disable, $alert_edit, $alert_management, $user_management, $db_management, $event_view, $event_edit, $event_management, $report_view, $report_edit, $report_management, $map_view, $map_edit, $map_management, $vconsole_view, $vconsole_edit, $vconsole_management, $pandora_management) = @_; - return db_insert ($dbh, 'id_up', 'INSERT INTO tperfil (name,incident_view,incident_edit,incident_management,agent_view,agent_edit,agent_disable,alert_edit,alert_management,user_management,db_management,event_view,event_edit,event_management,report_view,report_edit,report_management,map_view,map_edit,map_management,vconsole_view,vconsole_edit,vconsole_management,pandora_management) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);', - safe_input($profile_name), $incident_view,$incident_edit, $incident_management, $agent_view, + return db_insert ($dbh, 'id_up', 'INSERT INTO tperfil (name,agent_view,agent_edit,agent_disable,alert_edit,alert_management,user_management,db_management,event_view,event_edit,event_management,report_view,report_edit,report_management,map_view,map_edit,map_management,vconsole_view,vconsole_edit,vconsole_management,pandora_management) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);', + safe_input($profile_name), $agent_view, $agent_edit, $agent_disable, $alert_edit, $alert_management, $user_management, $db_management, $event_view, $event_edit, $event_management, $report_view, $report_edit, $report_management, $map_view, $map_edit, $map_management, $vconsole_view, $vconsole_edit, $vconsole_management, $pandora_management); @@ -579,14 +579,14 @@ sub pandora_create_profile ($$$$$$$$$$$$$$$$$$$$$$$$$) { ########################################################################## #### Update profile. ########################################################################### -sub pandora_update_profile ($$$$$$$$$$$$$$$$$$$$$$$$$) { - my ($dbh, $profile_name, $incident_view,$incident_edit, $incident_management, $agent_view, +sub pandora_update_profile ($$$$$$$$$$$$$$$$$$$$$$) { + my ($dbh, $profile_name, $agent_view, $agent_edit, $agent_disable, $alert_edit, $alert_management, $user_management, $db_management, $event_view, $event_edit, $event_management, $report_view, $report_edit, $report_management, $map_view, $map_edit, $map_management, $vconsole_view, $vconsole_edit, $vconsole_management, $pandora_management) = @_; - return db_update ($dbh, 'UPDATE tperfil SET incident_view = ?, incident_edit = ?, incident_management = ?, agent_view = ?, agent_edit = ?, agent_disable = ?, alert_edit = ?, alert_management = ?, user_management = ?, db_management = ?, event_view = ?, event_edit = ?, event_management = ?, report_view = ?, report_edit = ?, report_management = ?, map_view = ?, map_edit = ?, map_management = ?, vconsole_view = ?, vconsole_edit = ?, vconsole_management = ?, pandora_management = ? WHERE name=?;', - $incident_view,$incident_edit, $incident_management, $agent_view, + return db_update ($dbh, 'UPDATE tperfil SET agent_view = ?, agent_edit = ?, agent_disable = ?, alert_edit = ?, alert_management = ?, user_management = ?, db_management = ?, event_view = ?, event_edit = ?, event_management = ?, report_view = ?, report_edit = ?, report_management = ?, map_view = ?, map_edit = ?, map_management = ?, vconsole_view = ?, vconsole_edit = ?, vconsole_management = ?, pandora_management = ? WHERE name=?;', + $agent_view, $agent_edit, $agent_disable, $alert_edit, $alert_management, $user_management, $db_management, $event_view, $event_edit, $event_management, $report_view, $report_edit, $report_management, $map_view, $map_edit, $map_management, $vconsole_view, $vconsole_edit, $vconsole_management, $pandora_management, safe_input($profile_name)); @@ -4008,7 +4008,7 @@ sub cli_add_profile() { ############################################################################## sub cli_create_profile() { - my ($profile_name,$incident_view,$incident_edit,$incident_management,$agent_view, + my ($profile_name,$agent_view, $agent_edit,$agent_disable,$alert_edit,$alert_management,$user_management,$db_management, $event_view,$event_edit,$event_management,$report_view,$report_edit,$report_management, $map_view,$map_edit,$map_management,$vconsole_view,$vconsole_edit,$vconsole_management,$pandora_management) = @ARGV[2..25]; @@ -4016,7 +4016,7 @@ sub cli_create_profile() { my $id_profile = get_profile_id($dbh,$profile_name); non_exist_check($id_profile,'profile',$profile_name); - pandora_create_profile ($dbh, $profile_name, $incident_view, $incident_edit, $incident_management, $agent_view, + pandora_create_profile ($dbh, $profile_name, $agent_view, $agent_edit, $agent_disable, $alert_edit, $alert_management, $user_management, $db_management, $event_view, $event_edit, $event_management, $report_view, $report_edit, $report_management, $map_view, $map_edit, $map_management, $vconsole_view, $vconsole_edit, $vconsole_management, $pandora_management); @@ -4028,7 +4028,7 @@ sub cli_create_profile() { ############################################################################## # sub cli_update_profile() { - my ($profile_name,$incident_view,$incident_edit,$incident_management,$agent_view, + my ($profile_name,$agent_view, $agent_edit,$agent_disable,$alert_edit,$alert_management,$user_management,$db_management, $event_view,$event_edit,$event_management,$report_view,$report_edit,$report_management, $map_view,$map_edit,$map_management,$vconsole_view,$vconsole_edit,$vconsole_management,$pandora_management) = @ARGV[2..25]; @@ -4036,7 +4036,7 @@ sub cli_update_profile() { my $id_profile = get_profile_id($dbh,$profile_name); exist_check($id_profile,'profile',$profile_name); - pandora_update_profile ($dbh, $profile_name, $incident_view, $incident_edit, $incident_management, $agent_view, + pandora_update_profile ($dbh, $profile_name, $agent_view, $agent_edit, $agent_disable, $alert_edit, $alert_management, $user_management, $db_management, $event_view, $event_edit, $event_management, $report_view, $report_edit, $report_management, $map_view, $map_edit, $map_management, $vconsole_view, $vconsole_edit, $vconsole_management, $pandora_management); diff --git a/pandora_server/util/pandora_revent.pl b/pandora_server/util/pandora_revent.pl index 5a517ffe40..5f1bc8c3bd 100755 --- a/pandora_server/util/pandora_revent.pl +++ b/pandora_server/util/pandora_revent.pl @@ -3,7 +3,7 @@ ######################################################################## # Pandora FMS - Remote Event Tool (via WEB API) ######################################################################## -# Copyright (c) 2013-2021 Artica Soluciones Tecnologicas S.L +# Copyright (c) 2021 Artica Soluciones Tecnologicas S.L # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License version 2 @@ -12,6 +12,7 @@ # Includes list use strict; use LWP::Simple; +use LWP::UserAgent; use MIME::Base64; use lib '/usr/lib/perl5'; use PandoraFMS::Tools; @@ -32,40 +33,41 @@ sub help_screen{ \t$0 -p <path_to_consoleAPI> -u <credentials> -create_event <options> Where options:\n - -u <credentials> : API credentials separated by comma: <api_pass>,<user>,<pass> - -name <event_name> : Free text - -group <id_group> : Group ID (use 0 for 'all') - -agent : Agent ID + -u <credentials> : API credentials separated by comma: <api_pass>,<user>,<pass> + -name <event_name> : Free text (surrounded by single-quotes, for security reasons) + -group <id_group> : Group ID (use 0 for 'all') Optional parameters: - - [-status <status>] : 0 New, 1 Validated, 2 In process - [-user <id_user>] : User comment (use in combination with -comment option) - [-type <event_type>] : unknown, alert_fired, alert_recovered, alert_ceased + + [-agent <id_agent] : Agent ID + [-status <status>] : 0 New, 1 Validated, 2 In process + [-user <id_user>] : User comment (use in combination with -comment option) + [-type <event_type>] : unknown, alert_fired, alert_recovered, alert_ceased alert_manual_validation, system, error, new_agent configuration_change, going_unknown, going_down_critical, going_down_warning, going_up_normal - [-severity <severity>] : 0 Maintance, + [-severity <severity>] : 0 Maintance, 1 Informative, 2 Normal, 3 Warning, 4 Crit, 5 Minor, 6 Major - [-am <id_agent_module>] : ID Agent Module linked to event - [-alert <id_alert_am>] : ID Alert Module linked to event + [-am <id_agent_module>] : ID Agent Module linked to event + [-alert <id_alert_am>] : ID Alert Module linked to event [-c_instructions <critical_instructions>] [-w_instructions <warning_instructions>] [-u_instructions <unknown_instructions>] - [-user_comment <comment>] - [-owner_user <owner event>] : Use the login name, not the descriptive - [-source <source>] : (By default 'Pandora') - [-tag <tags>] : Tag (must exist in the system to be imported) - [-custom_data <custom_data>]: Custom data should be a base 64 encoded JSON document example -custom_data \'{\"test1\" : 1, \"test2\": 2}\' - [-id_extra <id extra>] : Id extra - [-agent_name <Agent name>] : Agent name, Not to be confused with the alias. - [-force_create_agent<0 o 1>]: Force the creation of agent through an event this will create when it is 1. - [-server_id <server_id>] : The pandora node server_id\n\n"; + [-user_comment <comment>] : Free text (surrounded by single-quotes, for security reasons) + [-owner_user <owner event>] : Use the login name, not the descriptive + [-source <source>] : (By default 'Pandora') + [-tag <tags>] : Tag (must exist in the system to be imported) + [-custom_data <custom_data>]: Custom data has to be in JSON format. Example: -custom_data \'{\"test1\" : \"t1\", \"test2\": \"2\"}\' + [-id_extra <id extra>] : Id extra + [-agent_name <Agent name>] : Agent name, Not to be confused with the alias. + [-force_create_agent<0 o 1>] : Force the creation of agent through an event this will create when it is 1. + [-separator '<char/s>'] : If you use the vertical bar `|` in the event name, you must set other character for send the info. This must be surrounded by single-quotes + [-server_id <server_id>] : The pandora node server_id\n\n"; print "Example of event generation:\n\n"; @@ -120,7 +122,7 @@ sub tool_api_main () { my $db_user; my $db_pass; my @db_info; - my $id_agent; + my $id_agent = '0'; my $id_user = ''; my $status = ''; my $id_agent_module = ''; @@ -141,6 +143,7 @@ sub tool_api_main () { my $call_api; my $custom_data = ""; my $server_id = 0; + my $separator = '|'; #~ help or api path (required) if ($ARGV[0] eq '-h') { @@ -185,12 +188,18 @@ sub tool_api_main () { if ($line eq '-agent') { $id_agent = $ARGV[$i + 1]; + # If not defined, send 0 for API. + if ($id_agent eq undef) { + $id_agent = '0'; + } + } if ($line eq '-group') { $id_group = $ARGV[$i + 1]; } if ($line eq '-name') { $event_name = $ARGV[$i + 1]; + $event_name =~ s/#/%23/g; } if ($line eq '-type') { $event_type = $ARGV[$i + 1]; @@ -250,50 +259,49 @@ sub tool_api_main () { if ($line eq '-server_id') { $server_id = $ARGV[$i + 1]; } + if ($line eq '-separator') { + $separator = $ARGV[$i + 1]; + } $i++; } if ($event_name eq "") { - print "[ERROR] Missing id agent! Read help info:\n\n"; + print "[ERROR] Missing event name! Read help info:\n\n"; help_screen (); } if ($id_group eq "") { print "[ERROR] Missing event group! Read help info:\n\n"; help_screen (); } - if ($id_agent eq "" && $agent_name eq "") { - print "[ERROR] Missing id agent! and agent_name Read help info:\n\n"; - help_screen (); - } $data_event = $event_name . - "|" . $id_group . - "|" . $id_agent . - "|" . $status . - "|" . $id_user . - "|" . $event_type . - "|" . $severity . - "|" . $id_agent_module . - "|" . $id_alert_am . - "|" . $critical_instructions . - "|" . $warning_instructions . - "|" . $unknown_instructions . - "|" . $user_comment . - "|" . $owner_user . - "|" . $source . - "|" . $tags . - "|" . $custom_data . - "|" . $server_id . - "|" . $id_extra . - "|" . $agent_name . - "|" . $force_create_agent; + $separator . $id_group . + $separator . $id_agent . + $separator . $status . + $separator . $id_user . + $separator . $event_type . + $separator . $severity . + $separator . $id_agent_module . + $separator . $id_alert_am . + $separator . $critical_instructions . + $separator . $warning_instructions . + $separator . $unknown_instructions . + $separator . $user_comment . + $separator . $owner_user . + $separator . $source . + $separator . $tags . + $separator . $custom_data . + $separator . $server_id . + $separator . $id_extra . + $separator . $agent_name . + $separator . $force_create_agent; $call_api = $api_path . '?' . 'op=set&' . 'op2=create_event&' . 'other=' . $data_event .'&' . - 'other_mode=url_encode_separator_|&' . + 'other_mode=url_encode_separator_'.$separator.'&' . 'apipass=' . $api_pass . '&' . 'user=' . $db_user . '&' . 'pass=' . $db_pass; @@ -321,13 +329,8 @@ sub tool_api_main () { exit; } else { - #-----------DEBUG---------------------------- - #print($call_api . "\n\n\n"); - - my $content = get($call_api); - - #-----------DEBUG---------------------------- - #print($content . "\n\n\n"); + my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0 }); + my $content = $ua->get($call_api); if ($option eq '-create_event') { if ($content eq undef) { @@ -335,7 +338,7 @@ sub tool_api_main () { help_screen(); } else { - print "Event ID: $content"; + print "Event ID: $content->{'_content'}"; } } elsif ($option eq '-validate_event') {