Merge branch 'develop' into 'ent-1193-Comprobar-codigo-de-estado-HTTP'

# Conflicts:
#   pandora_console/extras/mr/38.sql
This commit is contained in:
Alejandro Campos 2020-05-14 15:44:07 +02:00
commit 1c0f309047
136 changed files with 36214 additions and 25317 deletions

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.744, AIX version
# Version 7.0NG.745, AIX version
# Licensed under GPL license v2,
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.744, FreeBSD Version
# Version 7.0NG.745, FreeBSD Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.744, HP-UX Version
# Version 7.0NG.745, HP-UX Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.744, GNU/Linux
# Version 7.0NG.745, GNU/Linux
# Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.744, GNU/Linux
# Version 7.0NG.745, GNU/Linux
# Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.744, Solaris Version
# Version 7.0NG.745, Solaris Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,6 +1,6 @@
# Base config file for Pandora FMS Windows Agent
# (c) 2006-2010 Artica Soluciones Tecnologicas
# Version 7.0NG.744
# Version 7.0NG.745
# This program is Free Software, you can redistribute it and/or modify it
# under the terms of the GNU General Public Licence as published by the Free Software

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents
# Version 7.0NG.744, AIX version
# Version 7.0NG.745, AIX version
# General Parameters
# ==================

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents
# Version 7.0NG.744
# Version 7.0NG.745
# FreeBSD/IPSO version
# Licenced under GPL licence, 2003-2007 Sancho Lerena

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents
# Version 7.0NG.744, HPUX Version
# Version 7.0NG.745, HPUX Version
# General Parameters
# ==================

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.744
# Version 7.0NG.745
# Licensed under GPL license v2,
# (c) 2003-2010 Artica Soluciones Tecnologicas
# please visit http://pandora.sourceforge.net

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.744
# Version 7.0NG.745
# Licensed under GPL license v2,
# (c) 2003-2009 Artica Soluciones Tecnologicas
# please visit http://pandora.sourceforge.net

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.744
# Version 7.0NG.745
# Licensed under GPL license v2,
# please visit http://pandora.sourceforge.net

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents
# Version 7.0NG.744, Solaris version
# Version 7.0NG.745, Solaris version
# General Parameters
# ==================

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.744, AIX version
# Version 7.0NG.745, AIX version
# Licensed under GPL license v2,
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.744-200415
Version: 7.0NG.745-200514
Architecture: all
Priority: optional
Section: admin

View File

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

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.744, GNU/Linux
# Version 7.0NG.745, GNU/Linux
# Licensed under GPL license v2,
# Copyright (c) 2003-2012 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.744, FreeBSD Version
# Version 7.0NG.745, FreeBSD Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2016 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.744, HP-UX Version
# Version 7.0NG.745, HP-UX Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.744, GNU/Linux
# Version 7.0NG.745, GNU/Linux
# Licensed under GPL license v2,
# Copyright (c) 2003-2014 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.744, GNU/Linux
# Version 7.0NG.745, GNU/Linux
# Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.744, NetBSD Version
# Version 7.0NG.745, NetBSD Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.744, Solaris Version
# Version 7.0NG.745, Solaris Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -54,8 +54,8 @@ my $Sem = undef;
# Semaphore used to control the number of threads
my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.744';
use constant AGENT_BUILD => '200415';
use constant AGENT_VERSION => '7.0NG.745';
use constant AGENT_BUILD => '200514';
# Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent
#
%define name pandorafms_agent_unix
%define version 7.0NG.744
%define release 200415
%define version 7.0NG.745
%define release 200514
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent
#
%define name pandorafms_agent_unix
%define version 7.0NG.744
%define release 200415
%define version 7.0NG.745
%define release 200514
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -9,8 +9,8 @@
# Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license.
# **********************************************************************
PI_VERSION="7.0NG.744"
PI_BUILD="200415"
PI_VERSION="7.0NG.745"
PI_BUILD="200514"
OS_NAME=`uname -s`
FORCE=0

View File

@ -1,6 +1,6 @@
# Base config file for Pandora FMS Windows Agent
# (c) 2006-2017 Artica Soluciones Tecnologicas
# Version 7.0NG.744
# Version 7.0NG.745
# This program is Free Software, you can redistribute it and/or modify it
# under the terms of the GNU General Public Licence as published by the Free Software

View File

@ -3,13 +3,18 @@
# The installer will be placed in ./installer/output/.
# InstallJammer must be installed and in the PATH.
ARCH=`uname -m`
# ARCH may be set by other build scripts.
if [ "$ARCH" == "" ]; then
ARCH=`uname -m`
fi
# Set the target host.
if [ "$ARCH" == "x86_64" ]; then
HOST="x86_64-w64-mingw32"
else
HOST="i686-w64-mingw32"
fi
#./autogen.sh && ./configure --host=$HOST && make clean && make && cp PandoraAgent.exe bin/ && installjammer --build installer/pandora.mpi
# Compile and update the Pandora FMS Agent binary.
./autogen.sh && ./configure --host=$HOST && make clean && make && cp PandoraAgent.exe bin/

View File

@ -3,7 +3,7 @@ AllowLanguageSelection
{Yes}
AppName
{Pandora FMS Windows Agent v7.0NG.744}
{Pandora FMS Windows Agent v7.0NG.745}
ApplicationID
{17E3D2CF-CA02-406B-8A80-9D31C17BD08F}
@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{200415}
{200514}
ViewReadme
{Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.744(Build 200415)")
#define PANDORA_VERSION ("7.0NG.745(Build 200514)")
string pandora_path;
string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.744(Build 200415))"
VALUE "ProductVersion", "(7.0NG.745(Build 200514))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 7.0NG.744-200415
Version: 7.0NG.745-200514
Architecture: all
Priority: optional
Section: admin

View File

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

View File

@ -188,9 +188,10 @@ function quickShell()
} else if ($method == 'telnet') {
// Telnet.
$port = $config['gotty_telnet_port'];
$username = preg_replace('/[^a-zA-Z0-9\-\.]/', '', $username);
$command_arguments = "var args = '?arg=-l ".$username;
$command_arguments .= '&arg='.$address;
$command_arguments .= '&arg='.$method_port."';";
$command_arguments .= '&arg='.$method_port."&arg=-E';";
} else {
ui_print_error_message(__('Please use SSH or Telnet.'));
return;

View File

@ -1 +1,6 @@
operation/servers/recon_view.php
operation/servers/recon_view.php
operation/users/webchat.php
include/javascript/webchat.js
attachment/pandora_chat.log.json.txt
attachment/pandora_chat.user_list.json.txt
attachment/pandora_chat.global_counter.txt

View File

@ -1,5 +1,6 @@
START TRANSACTION;
INSERT INTO `ttipo_modulo` VALUES (38,'web_server_status_code_string',9,'Remote HTTP module to check server status code','mod_web_data.png');
ALTER TABLE trecon_task add column `rcmd_enabled` TINYINT(1) UNSIGNED DEFAULT 0 AFTER `wmi_enabled`;
COMMIT;

View File

@ -1674,6 +1674,7 @@ ALTER TABLE trecon_task ADD `alias_as_name` int(2) unsigned default '0';
ALTER TABLE trecon_task ADD `snmp_enabled` int(2) unsigned default '0';
ALTER TABLE trecon_task ADD `vlan_enabled` int(2) unsigned default '0';
ALTER TABLE trecon_task ADD `wmi_enabled` tinyint(1) unsigned DEFAULT '0';
ALTER TABLE trecon_task ADD `rcmd_enabled` tinyint(1) unsigned DEFAULT '0';
ALTER TABLE trecon_task ADD `auth_strings` text;
ALTER TABLE trecon_task ADD `autoconfiguration_enabled` tinyint(1) unsigned default '0';
ALTER TABLE trecon_task ADD `summary` text;

View File

@ -81,13 +81,6 @@ if ($config['menu_type'] == 'classic') {
}
// Chat messages.
$header_chat = "<div id='header_chat'><span id='icon_new_messages_chat' style='display: none;'>";
$header_chat .= "<a href='index.php?sec=workspace&sec2=operation/users/webchat'>";
$header_chat .= html_print_image('images/header_chat_gray.png', true, ['title' => __('New chat message')]);
$header_chat .= '</a></span></div>';
// Search.
$acl_head_search = true;
if ($config['acl_enterprise'] == 1 && !users_is_admin()) {
@ -417,7 +410,7 @@ if ($config['menu_type'] == 'classic') {
echo '<div class="header_left"><span class="header_title">'.$config['custom_title_header'].'</span><span class="header_subtitle">'.$config['custom_subtitle_header'].'</span></div>
<div class="header_center">'.$header_searchbar.'</div>
<div class="header_right">'.$header_chat, $header_autorefresh, $header_autorefresh_counter, $header_discovery, $servers_list, $header_feedback, $header_support, $header_docu, $header_user, $header_logout.'</div>';
<div class="header_right">'.$header_autorefresh, $header_autorefresh_counter, $header_discovery, $servers_list, $header_feedback, $header_support, $header_docu, $header_user, $header_logout.'</div>';
?>
</div> <!-- Closes #table_header_inner -->
</div> <!-- Closes #table_header -->
@ -640,8 +633,6 @@ if ($config['menu_type'] == 'classic') {
var fixed_header = <?php echo json_encode((bool) $config_fixed_header); ?>;
var new_chat = <?php echo (int) $_SESSION['new_chat']; ?>;
function showinterpreter(){
document.onclick = function(e) {
@ -789,9 +780,7 @@ if ($config['menu_type'] == 'classic') {
$('div#head').addClass('fixed_header');
$('div#main').css('padding-top', $('div#head').innerHeight() + 'px');
}
check_new_chats_icon('icon_new_messages_chat');
/* Temporal fix to hide graphics when ui_dialog are displayed */
$("#yougotalert").click(function () {
$("#agent_access").css("display", "none");

View File

@ -136,8 +136,11 @@ font-size:10pt;
<div class='modalcontenttex'>
<?php
echo __('Access to this page is restricted to authorized users only, please contact system administrator if you need assistance.');
echo '<br/> <br/>';
echo __('Please know that all attempts to access this page are recorded in security logs of %s System Database', get_product_name());
echo '<br/> <br/>';
echo __('Please know that all attempts to access this page are recorded in security logs of %s System Database', get_product_name());
if ($config['logged'] == false) {
session_destroy();
}
?>
</div>

View File

@ -1901,12 +1901,6 @@ if ($enable_module) {
'Fail to enable #'.$enable_module.' | '.$module_name.' | '.$agent['alias']
);
}
ui_print_result_message(
$result,
__('Successfully enabled'),
__('Could not be enabled')
);
}
if ($disable_module) {
@ -1942,12 +1936,6 @@ if ($disable_module) {
'Fail to disable #'.$disable_module.' | '.$module_name.' | '.$agent['alias']
);
}
ui_print_result_message(
$result,
__('Successfully disabled'),
__('Could not be disabled')
);
}
// Fix to stop the module from being added to the agent's conf

View File

@ -16,7 +16,7 @@ global $config;
check_login();
require 'vendor/autoload.php';
require_once $config['homedir'].'/vendor/autoload.php';
use PandoraFMS\Dashboard\Manager;

View File

@ -160,8 +160,6 @@ if (isset($_GET['user_del'])) {
$result = delete_user($id_user);
if ($result) {
users_save_logout($user_row, true);
db_pandora_audit(
'User management',
__('Deleted user %s', io_safe_input($id_user))

View File

@ -538,7 +538,14 @@ class DiscoveryTaskList extends HTML
}
$can_be_reviewed = false;
if ($task['review_mode'] == DISCOVERY_STANDARD) {
if (empty($task['summary']) === false
&& $task['summary'] == 'cancelled'
) {
$data[5] = __('Cancelled').ui_print_help_tip(
__('Server has been restarted while executing this task, please retry.'),
true
);
} else if ($task['review_mode'] == DISCOVERY_STANDARD) {
if ($task['status'] <= 0
&& empty($task['summary']) === false
) {

View File

@ -482,6 +482,7 @@ class HostDevices extends Wizard
$review_results = get_parameter_switch('review_results');
$review_limited = (bool) get_parameter('review_limited', 0);
$auto_monitor = get_parameter_switch('auto_monitor');
$recon_ports = get_parameter('recon_ports', null);
$autoconf_enabled = get_parameter_switch(
'autoconfiguration_enabled'
);
@ -491,6 +492,7 @@ class HostDevices extends Wizard
$parent_recursion = get_parameter_switch('parent_recursion');
$vlan_enabled = get_parameter_switch('vlan_enabled');
$wmi_enabled = get_parameter_switch('wmi_enabled');
$rcmd_enabled = get_parameter_switch('rcmd_enabled');
$resolve_names = get_parameter_switch('resolve_names');
$snmp_version = get_parameter('snmp_version', null);
$community = get_parameter('community', null);
@ -532,12 +534,14 @@ class HostDevices extends Wizard
}
$this->task['auto_monitor'] = $auto_monitor;
$this->task['recon_ports'] = $recon_ports;
$this->task['snmp_enabled'] = $snmp_enabled;
$this->task['os_detect'] = $os_detect;
$this->task['parent_detection'] = $parent_detection;
$this->task['parent_recursion'] = $parent_recursion;
$this->task['vlan_enabled'] = $vlan_enabled;
$this->task['wmi_enabled'] = $wmi_enabled;
$this->task['rcmd_enabled'] = $rcmd_enabled;
$this->task['resolve_names'] = $resolve_names;
$this->task['snmp_version'] = $snmp_version;
$this->task['snmp_auth_user'] = $snmp_auth_user;
@ -1036,6 +1040,21 @@ class HostDevices extends Wizard
],
];
$form['inputs'][] = [
'label' => __('Filter by opened ports').ui_print_help_tip(
__(
'Targets will be scanned if at least one of defined ports (comma separated) is open.'
),
true
),
'arguments' => [
'name' => 'recon_ports',
'type' => 'text',
'return' => true,
'value' => $this->task['recon_ports'],
],
];
$form['inputs'][] = [
'label' => __('Auto discover known hardware').ui_print_help_tip(
__(

View File

@ -917,9 +917,11 @@ if ($get_response) {
if ($perform_event_response) {
global $config;
$command = get_parameter('target', '');
$response_id = get_parameter('response_id');
$event_id = (int) get_parameter('event_id');
$server_id = (int) get_parameter('server_id', 0);
$command = events_get_response_target($event_id, $response_id, $server_id);
$event_response = db_get_row('tevent_response', 'id', $response_id);
@ -1017,6 +1019,7 @@ if ($dialogue_event_response) {
$show_execute_again_btn = get_parameter('show_execute_again_btn');
$out_iterator = get_parameter('out_iterator');
$event_response = db_get_row('tevent_response', 'id', $response_id);
$server_id = get_parameter('server_id');
$event = db_get_row('tevento', 'id_evento', $event_id);
@ -1067,7 +1070,8 @@ if ($dialogue_event_response) {
echo "<br><div id='response_out' style='text-align:left'></div>";
echo "<br><div id='re_exec_command' style='display:none;'>";
html_print_button(__('Execute again'), 'btn_str', false, 'perform_response(\''.$command.'\', '.$response_id.');', "class='sub next'");
html_print_button(__('Execute again'), 'btn_str', false, "perform_response({'target':'".$command."','event_id':".$event_id.",'server_id':".$server_id.'}, '.$response_id.');', "class='sub next'");
echo '</div>';
}
break;

View File

@ -1034,86 +1034,7 @@ if (check_login()) {
}
}
if (is_numeric($module['datos']) && !modules_is_string_type($module['id_tipo_modulo'])) {
if ($config['render_proc']) {
switch ($module['id_tipo_modulo']) {
case 2:
case 6:
case 9:
case 18:
case 21:
case 31:
if ($module['datos'] >= 1) {
$salida = $config['render_proc_ok'];
} else {
$salida = $config['render_proc_fail'];
}
break;
default:
switch ($module['id_tipo_modulo']) {
case 15:
$value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module['id_agente_modulo']);
if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') {
if ($module['post_process'] > 0) {
$salida = human_milliseconds_to_string(($module['datos'] / $module['post_process']));
} else {
$salida = human_milliseconds_to_string($module['datos']);
}
} else {
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision']));
}
break;
default:
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision']));
break;
}
break;
}
} else {
switch ($module['id_tipo_modulo']) {
case 15:
$value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module['id_agente_modulo']);
if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') {
if ($module['post_process'] > 0) {
$salida = human_milliseconds_to_string(($module['datos'] / $module['post_process']));
} else {
$salida = human_milliseconds_to_string($module['datos']);
}
} else {
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision']));
}
break;
default:
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision']));
break;
}
}
// Show units ONLY in numeric data types
if (isset($module['unit'])) {
$data_macro = modules_get_unit_macro($module['datos'], $module['unit']);
if ($data_macro) {
$salida = $data_macro;
} else {
$salida .= '&nbsp;<i>'.io_safe_output($module['unit']).'</i>';
}
}
} else {
$data_macro = modules_get_unit_macro($module['datos'], $module['unit']);
if ($data_macro) {
$salida = $data_macro;
} else {
$salida = ui_print_module_string_value(
$module['datos'],
$module['id_agente_modulo'],
$module['current_interval'],
$module['module_name']
);
}
}
$salida = modules_get_agentmodule_data_for_humans($module);
if ($module['id_tipo_modulo'] != 25) {
$data[6] = ui_print_module_warn_value($module['max_warning'], $module['min_warning'], $module['str_warning'], $module['max_critical'], $module['min_critical'], $module['str_critical'], $module['warning_inverse'], $module['critical_inverse']);

View File

@ -215,6 +215,12 @@ class ConsoleSupervisor
*/
$this->checkConsoleServerVersions();
/*
* Check if AllowOverride is None or All.
* NOTIF.ALLOWOVERIDE.MESSAGE
*/
$this->checkAllowOverrideEnabled();
}
@ -440,6 +446,11 @@ class ConsoleSupervisor
*/
$this->checkConsoleServerVersions();
/*
* Check if AllowOverride is None or All.
*/
$this->checkAllowOverrideEnabled();
}
@ -606,6 +617,7 @@ class ConsoleSupervisor
case 'NOTIF.UPDATEMANAGER.MINOR':
case 'NOTIF.UPDATEMANAGER.MESSAGES':
case 'NOTIF.CRON.CONFIGURED':
case 'NOTIF.ALLOWOVERRIDE.MESSAGE':
default:
// NOTIF.SERVER.STATUS.
// NOTIF.SERVER.STATUS.ID_SERVER.
@ -740,25 +752,41 @@ class ConsoleSupervisor
// Expiry.
if (($days_to_expiry <= 15) && ($days_to_expiry > 0)) {
if ($config['license_mode'] == 1) {
$title = __('License is about to expire');
$msg = 'Your license will expire in %d days. Please, contact our sales department.';
} else {
$title = __('Support is about to expire');
$msg = 'Your support license will expire in %d days. Please, contact our sales department.';
}
// Warn user if license is going to expire in 15 days or less.
$this->notify(
[
'type' => 'NOTIF.LICENSE.EXPIRATION',
'title' => __('License is about to expire'),
'title' => $title,
'message' => __(
'Your license will expire in %d days. Please, contact our sales department.',
$msg,
$days_to_expiry
),
'url' => ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/license'),
]
);
} else if ($days_to_expiry < 0) {
if ($config['license_mode'] == 1) {
$title = __('Expired license');
$msg = __('Your license has expired. Please, contact our sales department.');
} else {
$title = __('Support expired');
$msg = __('This license is outside of support. Please, contact our sales department.');
}
// Warn user, license has expired.
$this->notify(
[
'type' => 'NOTIF.LICENSE.EXPIRATION',
'title' => __('Expired license'),
'message' => __('Your license has expired. Please, contact our sales department.'),
'title' => $title,
'message' => $msg,
'url' => ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/license'),
]
);
@ -2360,4 +2388,50 @@ class ConsoleSupervisor
}
/**
* Check if AllowOveride is None or All.
*
* @return void
*/
public function checkAllowOverrideEnabled()
{
global $config;
$message = 'If AllowOverride is disabled, .htaccess will not works.';
$message .= '<pre>Please check /etc/httpd/conf/httpd.conf to resolve this problem.';
// Get content file.
$file = file_get_contents('/etc/httpd/conf/httpd.conf');
$file_lines = preg_split("#\r?\n#", $file, -1, PREG_SPLIT_NO_EMPTY);
$is_none = false;
$i = 0;
foreach ($file_lines as $line) {
$i++;
// Check Line and content.
if (preg_match('/ AllowOverride/', $line) && $i === 311) {
$result = explode(' ', $line);
if ($result[5] == 'None') {
$is_none = true;
$this->notify(
[
'type' => 'NOTIF.ALLOWOVERRIDE.MESSAGE',
'title' => __('AllowOverride is disabled'),
'message' => __($message),
'url' => ui_get_full_url('index.php'),
]
);
}
}
}
// Cleanup notifications if AllowOverride is All.
if (!$is_none) {
$this->cleanNotifications('NOTIF.ALLOWOVERRIDE.MESSAGE');
}
}
}

View File

@ -557,7 +557,7 @@ class Tree
$module['id_module_type'] = (int) $module['id_tipo_modulo'];
$module['server_type'] = (int) $module['id_modulo'];
$module['status'] = $module['estado'];
$module['value'] = $module['datos'];
$module['value'] = modules_get_agentmodule_data_for_humans($module);
if (is_metaconsole()) {
$module['serverID'] = $this->serverID;
@ -738,12 +738,10 @@ class Tree
$agent['counters']['warning'],
$agent['counters']['unknown'],
$agent['counters']['total'],
$agent['counters']['not_init']
$agent['counters']['not_init'],
$agent['counters']['alerts']
);
// Alerts fired image
$agent['alertImageHTML'] = agents_tree_view_alert_img_ball($agent['counters']['alerts']);
// search module recalculate counters
if (array_key_exists('state_normal', $agent)) {
$agent['counters']['unknown'] = $agent['state_unknown'];

View File

@ -20,8 +20,8 @@
/**
* Pandora build version and version
*/
$build_version = 'PC200415';
$pandora_version = 'v7.0NG.744';
$build_version = 'PC200514';
$pandora_version = 'v7.0NG.745';
// Do not overwrite default timezone set if defined.
$script_tz = @date_default_timezone_get();

View File

@ -3947,7 +3947,7 @@ function get_copyright_notice()
{
$stored_name = enterprise_hook('enterprise_get_copyright_notice');
if (empty($stored_name) || $stored_name == ENTERPRISE_NOT_HOOK) {
return 'Ártica ST';
return 'PandoraFMS.com';
}
return $stored_name;

View File

@ -310,6 +310,10 @@ function agents_get_alerts_simple($id_agent=false, $filter='', $options=false, $
$subQuery = 'SELECT id_agente_modulo
FROM tagente_modulo WHERE delete_pending = 0';
}
// Filter by agents id.
$id_agents_list = implode(',', $id_agent);
$subQuery .= ' AND id_agente in ('.$id_agents_list.')';
} else if ($id_agent === false || empty($id_agent)) {
if ($allModules) {
$disabled = '';
@ -2638,12 +2642,28 @@ function agents_tree_view_status_img($critical, $warning, $unknown, $total, $not
// Returns the status ball image to display tree view
function agents_tree_view_status_img_ball($critical, $warning, $unknown, $total, $notinit)
function agents_tree_view_status_img_ball($critical, $warning, $unknown, $total, $notinit, $alerts)
{
if ($total == 0 || $total == $notinit) {
return ui_print_status_image(
STATUS_AGENT_NO_MONITORS_BALL,
__('No Monitors'),
true,
false,
false,
// Use CSS shape instead of image.
true
);
}
if ($alerts > 0) {
return ui_print_status_image(
STATUS_ALERT_FIRED_BALL,
__('Alert fired on agent'),
true,
false,
false,
// Use CSS shape instead of image.
true
);
}
@ -2652,24 +2672,40 @@ function agents_tree_view_status_img_ball($critical, $warning, $unknown, $total,
return ui_print_status_image(
STATUS_AGENT_CRITICAL_BALL,
__('At least one module in CRITICAL status'),
true,
false,
false,
// Use CSS shape instead of image.
true
);
} else if ($warning > 0) {
return ui_print_status_image(
STATUS_AGENT_WARNING_BALL,
__('At least one module in WARNING status'),
true,
false,
false,
// Use CSS shape instead of image.
true
);
} else if ($unknown > 0) {
return ui_print_status_image(
STATUS_AGENT_DOWN_BALL,
__('At least one module is in UKNOWN status'),
true,
false,
false,
// Use CSS shape instead of image.
true
);
} else {
return ui_print_status_image(
STATUS_AGENT_OK_BALL,
__('All Monitors OK'),
true,
false,
false,
// Use CSS shape instead of image.
true
);
}

View File

@ -14294,7 +14294,7 @@ function api_get_agents_id_name_by_cluster_name($cluster_name, $trash1, $trash2,
* @param $trash2
* @param string $returnType
* Example:
* api.php?op=get&op2=agents_id_name_by_alias&return_type=json&apipass=1234&user=admin&pass=pandora&id=pandrora&id2=strict
* api.php?op=get&op2=agents_id_name_by_alias&return_type=json&apipass=1234&user=admin&pass=pandora&id=pandorafms&id2=strict
*/
function api_get_agents_id_name_by_alias($alias, $strict, $trash2, $returnType)
{
@ -14307,9 +14307,9 @@ function api_get_agents_id_name_by_alias($alias, $strict, $trash2, $returnType)
}
if (is_metaconsole()) {
$all_agents = db_get_all_rows_sql("SELECT alias, id_agente, id_tagente,id_tmetaconsole_setup as 'id_server', server_name FROM tmetaconsole_agent WHERE $where_clause");
$all_agents = db_get_all_rows_sql("SELECT alias, nombre, id_agente, id_tagente,id_tmetaconsole_setup as 'id_server', server_name FROM tmetaconsole_agent WHERE $where_clause");
} else {
$all_agents = db_get_all_rows_sql("SELECT alias, id_agente from tagente WHERE $where_clause");
$all_agents = db_get_all_rows_sql("SELECT alias, nombre, id_agente from tagente WHERE $where_clause");
}
if ($all_agents !== false) {
@ -15990,3 +15990,34 @@ function util_api_check_agent_and_print_error($id_agent, $returnType, $access='A
return false;
}
/**
* Function for get event id and node id, then we get in return the Metaconsole event ID.
*
* @param [string] $server_id id server (Node)
* @param [string] $console_event_id console Id node event in tmetaconsole_event
* @param [string] $trash2 don't use
* @param [string] $returnType
*
* Example
* api.php?op=get&op2=event_mcid&return_type=json&id=0&id2=0&apipass=1234&user=admin&pass=pandora
*
* @return void
*/
function api_get_event_mcid($server_id, $console_event_id, $trash2, $returnType)
{
global $config;
if (is_metaconsole()) {
$mc_event_id = db_get_all_rows_sql("SELECT id_evento FROM tmetaconsole_event WHERE id_source_event = $console_event_id AND server_id = $server_id ");
if ($mc_event_id !== false) {
returnData($returnType, ['type' => 'string', 'data' => $mc_event_id]);
} else {
returnError('id_not_found', 'string');
}
} else {
returnError('forbidden', 'string');
return;
}
}

View File

@ -2088,10 +2088,10 @@ function html_print_button($label='OK', $name='', $disabled=false, $script='', $
*
* @return string HTML code if return parameter is true.
*/
function html_print_textarea($name, $rows, $columns, $value='', $attributes='', $return=false, $class='')
function html_print_textarea($name, $rows, $columns, $value='', $attributes='', $return=false, $class='', $disable=false)
{
$output = '<textarea id="textarea_'.$name.'" name="'.$name.'" cols="'.$columns.'" rows="'.$rows.'" '.$attributes.' class="'.$class.'">';
// $output .= io_safe_input ($value);
$disabled = ($disable) ? 'disabled' : '';
$output = '<textarea id="textarea_'.$name.'" name="'.$name.'" cols="'.$columns.'" rows="'.$rows.'" '.$attributes.' class="'.$class.'" '.$disabled.'>';
$output .= ($value);
$output .= '</textarea>';

View File

@ -2271,6 +2271,102 @@ function modules_get_agentmodule_data(
}
/**
* Return module data in readable format.
*
* @param array $module Current module.
*
* @return void
*/
function modules_get_agentmodule_data_for_humans($module)
{
global $config;
if (is_numeric($module['datos']) && !modules_is_string_type($module['id_tipo_modulo'])) {
if ($config['render_proc']) {
switch ($module['id_tipo_modulo']) {
case 2:
case 6:
case 9:
case 18:
case 21:
case 31:
if ($module['datos'] >= 1) {
$salida = $config['render_proc_ok'];
} else {
$salida = $config['render_proc_fail'];
}
break;
default:
switch ($module['id_tipo_modulo']) {
case 15:
$value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module['id_agente_modulo']);
if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') {
if ($module['post_process'] > 0) {
$salida = human_milliseconds_to_string(($module['datos'] / $module['post_process']));
} else {
$salida = human_milliseconds_to_string($module['datos']);
}
} else {
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision']));
}
break;
default:
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision']));
break;
}
break;
}
} else {
switch ($module['id_tipo_modulo']) {
case 15:
$value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module['id_agente_modulo']);
if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') {
if ($module['post_process'] > 0) {
$salida = human_milliseconds_to_string(($module['datos'] / $module['post_process']));
} else {
$salida = human_milliseconds_to_string($module['datos']);
}
} else {
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision']));
}
break;
default:
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision']));
break;
}
}
// Show units ONLY in numeric data types
if (isset($module['unit'])) {
$data_macro = modules_get_unit_macro($module['datos'], $module['unit']);
if ($data_macro) {
$salida = $data_macro;
} else {
$salida .= '&nbsp;<i>'.io_safe_output($module['unit']).'</i>';
}
}
} else {
$data_macro = modules_get_unit_macro($module['datos'], $module['unit']);
if ($data_macro) {
$salida = $data_macro;
} else {
$salida = ui_print_module_string_value(
$module['datos'],
$module['id_agente_modulo'],
$module['current_interval'],
$module['module_name']
);
}
}
return $salida;
}
/**
* This function gets the modulegroup for a given group
*

View File

@ -8993,22 +8993,22 @@ function reporting_get_stats_indicators($data, $width=280, $height=20, $html=tru
if ($html) {
$tdata[0] = '<fieldset class="databox tactical_set">
<legend>'.__('Server health').ui_print_help_tip(sprintf(__('%d Downed servers'), $servers['down']), true).'</legend>'.progress_bar($servers['health'], $width, $height, '', 0).'</fieldset>';
<legend>'.__('Server health').ui_print_help_tip(sprintf(__('%d Downed servers'), (int) $servers['down']), true).'</legend>'.progress_bar($servers['health'], $width, $height, '', 0).'</fieldset>';
$table_ind->rowclass[] = '';
$table_ind->data[] = $tdata;
$tdata[0] = '<fieldset class="databox tactical_set">
<legend>'.__('Monitor health').ui_print_help_tip(sprintf(__('%d Not Normal monitors'), $data['monitor_not_normal']), true).'</legend>'.progress_bar($data['monitor_health'], $width, $height, $data['monitor_health'].'% '.__('of monitors up'), 0).'</fieldset>';
<legend>'.__('Monitor health').ui_print_help_tip(sprintf(__('%d Not Normal monitors'), (int) $data['monitor_not_normal']), true).'</legend>'.progress_bar($data['monitor_health'], $width, $height, $data['monitor_health'].'% '.__('of monitors up'), 0).'</fieldset>';
$table_ind->rowclass[] = '';
$table_ind->data[] = $tdata;
$tdata[0] = '<fieldset class="databox tactical_set">
<legend>'.__('Module sanity').ui_print_help_tip(sprintf(__('%d Not inited monitors'), $data['monitor_not_init']), true).'</legend>'.progress_bar($data['module_sanity'], $width, $height, $data['module_sanity'].'% '.__('of total modules inited'), 0).'</fieldset>';
<legend>'.__('Module sanity').ui_print_help_tip(sprintf(__('%d Not inited monitors'), (int) $data['monitor_not_init']), true).'</legend>'.progress_bar($data['module_sanity'], $width, $height, $data['module_sanity'].'% '.__('of total modules inited'), 0).'</fieldset>';
$table_ind->rowclass[] = '';
$table_ind->data[] = $tdata;
$tdata[0] = '<fieldset class="databox tactical_set">
<legend>'.__('Alert level').ui_print_help_tip(sprintf(__('%d Fired alerts'), $data['monitor_alerts_fired']), true).'</legend>'.progress_bar($data['alert_level'], $width, $height, $data['alert_level'].'% '.__('of defined alerts not fired'), 0).'</fieldset>';
<legend>'.__('Alert level').ui_print_help_tip(sprintf(__('%d Fired alerts'), (int) $data['monitor_alerts_fired']), true).'</legend>'.progress_bar($data['alert_level'], $width, $height, $data['alert_level'].'% '.__('of defined alerts not fired'), 0).'</fieldset>';
$table_ind->rowclass[] = '';
$table_ind->data[] = $tdata;

View File

@ -1908,8 +1908,6 @@ function ui_process_page_head($string, $bitfield)
);
// Load base64 javascript library.
$config['js']['base64'] = 'include/javascript/encode_decode_base64.js';
// Load webchat javascript library.
$config['js']['webchat'] = 'include/javascript/webchat.js';
// Load qrcode library.
$config['js']['qrcode'] = 'include/javascript/qrcode.js';
// Load intro.js library (for bubbles and clippy).
@ -5636,7 +5634,7 @@ function ui_get_snapshot_link($params, $only_params=false)
$params = array_merge($default_params, $params);
// First parameter of js winopeng_var.
$page = $config['homeurl_static'].'/operation/agentes/snapshot_view.php';
$page = $config['homeurl'].'/operation/agentes/snapshot_view.php';
$url = $page.'?id='.$params['id_module'].'&label='.rawurlencode(urlencode(io_safe_output($params['module_name']))).'&id_node='.$params['id_node'];

View File

@ -497,508 +497,6 @@ function users_get_user_by_id($id_user)
}
define('MAX_TIMES', 10);
//
// WEBCHAT FUNCTIONS/////////////////////////////////
//
function users_get_last_messages($last_time=false)
{
$file_global_counter_chat = $config['attachment_store'].'/pandora_chat.global_counter.txt';
// First lock the file
$fp_global_counter = @fopen($file_global_counter_chat, 'a+');
if ($fp_global_counter === false) {
echo json_encode($return);
return;
}
// Try to look MAX_TIMES times
$tries = 0;
while (!flock($fp_global_counter, LOCK_EX)) {
$tries++;
if ($tries > MAX_TIMES) {
echo json_encode($return);
return;
}
sleep(1);
}
fscanf($fp_global_counter, '%d', $global_counter_file);
if (empty($global_counter_file)) {
$global_counter_file = 0;
}
$timestamp = time();
if ($last_time === false) {
$last_time = (24 * 60 * 60);
}
$from = ($timestamp - $last_time);
$log_chat_file = $config['attachment_store'].'/pandora_chat.log.json.txt';
$return = [
'correct' => false,
'log' => [],
];
if (!file_exists($log_chat_file)) {
touch($log_chat_file);
}
$text_encode = @file_get_contents($log_chat_file);
$log = json_decode($text_encode, true);
if ($log !== false) {
if ($log === null) {
$log = [];
}
$log_last_time = [];
foreach ($log as $message) {
if ($message['timestamp'] >= $from) {
$log_last_time[] = $message;
}
}
$return['correct'] = true;
$return['log'] = $log_last_time;
$return['global_counter'] = $global_counter_file;
}
echo json_encode($return);
fclose($fp_global_counter);
return;
}
function users_save_login()
{
global $config;
$file_global_user_list = $config['attachment_store'].'/pandora_chat.user_list.json.txt';
$user = db_get_row_filter(
'tusuario',
['id_user' => $config['id_user']]
);
$message = sprintf(
__('User %s login at %s'),
$user['fullname'],
date($config['date_format'])
);
users_save_text_message($message, 'notification');
// First lock the file
$fp_user_list = @fopen($file_global_user_list, 'a+');
if ($fp_user_list === false) {
return;
}
// Try to look MAX_TIMES times
$tries = 0;
while (!flock($fp_user_list, LOCK_EX)) {
$tries++;
if ($tries > MAX_TIMES) {
return;
}
sleep(1);
}
@fscanf($fp_user_list, "%[^\n]", $user_list_json);
$user_list = json_decode($user_list_json, true);
if (empty($user_list)) {
$user_list[$config['id_user']] = [
'name' => $user['fullname'],
'count' => 1,
];
} else if (isset($user_list[$config['id_user']])) {
$user_list[$config['id_user']] = [
'name' => $user['fullname'],
'count' => $user_list[$config['id_user']]['count'],
];
} else {
$users_count = count($user_list);
$user_list[$config['id_user']] = [
'name' => $user['fullname'],
'count' => ++$users_count,
];
}
// Clean the file
ftruncate($fp_user_list, 0);
$status = fwrite($fp_user_list, json_encode($user_list));
if ($status === false) {
fclose($fp_user_list);
return;
}
fclose($fp_user_list);
}
function users_save_logout($user=false, $delete=false)
{
global $config;
$return = [
'correct' => false,
'users' => [],
];
$file_global_user_list = $config['attachment_store'].'/pandora_chat.user_list.json.txt';
if (empty($user)) {
$user = db_get_row_filter(
'tusuario',
['id_user' => $config['id_user']]
);
}
if ($delete) {
$no_json_output = true;
$message = sprintf(
__('User %s was deleted in the DB at %s'),
$user['fullname'],
date($config['date_format'])
);
} else {
$no_json_output = false;
$message = sprintf(
__('User %s logout at %s'),
$user['fullname'],
date($config['date_format'])
);
}
users_save_text_message($message, 'notification', $no_json_output);
// First lock the file
$fp_user_list = @fopen($file_global_user_list, 'a+');
if ($fp_user_list === false) {
return;
}
// Try to look MAX_TIMES times
$tries = 0;
while (!flock($fp_user_list, LOCK_EX)) {
$tries++;
if ($tries > MAX_TIMES) {
return;
}
sleep(1);
}
@fscanf($fp_user_list, "%[^\n]", $user_list_json);
$user_list = json_decode($user_list_json, true);
if (empty($user_list)) {
$user_list = [];
}
unset($user_list[$user['id_user']]);
// Clean the file
ftruncate($fp_user_list, 0);
$status = fwrite($fp_user_list, json_encode($user_list));
if ($status === false) {
fclose($fp_user_list);
return;
}
fclose($fp_user_list);
}
function users_save_text_message($message=false, $type='message', $no_json_output=false)
{
global $config;
$file_global_counter_chat = $config['attachment_store'].'/pandora_chat.global_counter.txt';
$log_chat_file = $config['attachment_store'].'/pandora_chat.log.json.txt';
$return = ['correct' => false];
$id_user = $config['id_user'];
$user = db_get_row_filter(
'tusuario',
['id_user' => $id_user]
);
$message_data = [];
$message_data['type'] = $type;
$message_data['id_user'] = $id_user;
$message_data['user_name'] = $user['fullname'];
$message_data['text'] = io_safe_input_html($message);
// The $message_data['timestamp'] set when adquire the files to save.
// First lock the file
$fp_global_counter = @fopen($file_global_counter_chat, 'a+');
if ($fp_global_counter === false) {
if (!$no_json_output) {
echo json_encode($return);
}
return;
}
// Try to look MAX_TIMES times
$tries = 0;
while (!flock($fp_global_counter, LOCK_EX)) {
$tries++;
if ($tries > MAX_TIMES) {
if (!$no_json_output) {
echo json_encode($return);
}
return;
}
sleep(1);
}
@fscanf($fp_global_counter, '%d', $global_counter_file);
if (empty($global_counter_file)) {
$global_counter_file = 0;
}
// Clean the file
ftruncate($fp_global_counter, 0);
$message_data['timestamp'] = time();
$message_data['human_time'] = date($config['date_format'], $message_data['timestamp']);
$global_counter = ($global_counter_file + 1);
$status = fwrite($fp_global_counter, $global_counter);
if ($status === false) {
fclose($fp_global_counter);
if (!$no_json_output) {
echo json_encode($return);
}
return;
} else {
$text_encode = @file_get_contents($log_chat_file);
$log = json_decode($text_encode, true);
$log[$global_counter] = $message_data;
$status = file_put_contents($log_chat_file, json_encode($log));
fclose($fp_global_counter);
$return['correct'] = true;
if (!$no_json_output) {
echo json_encode($return);
}
}
return;
}
function users_long_polling_check_messages($global_counter)
{
global $config;
$file_global_counter_chat = $config['attachment_store'].'/pandora_chat.global_counter.txt';
$log_chat_file = $config['attachment_store'].'/pandora_chat.log.json.txt';
$changes = false;
$tries_general = 0;
$error = false;
while (!$changes) {
// First lock the file
$fp_global_counter = @fopen($file_global_counter_chat, 'a+');
if ($fp_global_counter) {
// Try to look MAX_TIMES times
$tries = 0;
$lock = true;
while (!flock($fp_global_counter, LOCK_EX)) {
$tries++;
if ($tries > MAX_TIMES) {
$lock = false;
$error = true;
break;
}
sleep(1);
}
if ($lock) {
@fscanf($fp_global_counter, '%d', $global_counter_file);
if (empty($global_counter_file)) {
$global_counter_file = 0;
}
if ($global_counter_file > $global_counter) {
// TODO Optimize slice the array.
$text_encode = @file_get_contents($log_chat_file);
$log = json_decode($text_encode, true);
$return_log = [];
foreach ($log as $key => $message) {
if ($key <= $global_counter) {
continue;
}
$return_log[] = $message;
}
$return = [
'correct' => true,
'global_counter' => $global_counter_file,
'log' => $return_log,
];
echo json_encode($return);
fclose($fp_global_counter);
return;
}
}
fclose($fp_global_counter);
}
sleep(3);
$tries_general = ($tries_general + 3);
if ($tries_general > MAX_TIMES) {
break;
}
}
// Because maybe the exit of loop for exaust.
echo json_encode(['correct' => false, 'error' => $error]);
return;
}
/**
* Get the last global counter for chat.
*
* @param string $mode There are two modes 'json', 'return' and 'session'. And json is by default.
*/
function users_get_last_global_counter($mode='json')
{
global $config;
$file_global_counter_chat = $config['attachment_store'].'/pandora_chat.global_counter.txt';
$global_counter_file = 0;
$fp_global_counter = @fopen($file_global_counter_chat, 'a+');
if ($fp_global_counter) {
$tries = 0;
$lock = true;
while (!flock($fp_global_counter, LOCK_EX)) {
$tries++;
if ($tries > MAX_TIMES) {
$lock = false;
break;
}
sleep(1);
}
if ($lock) {
@fscanf($fp_global_counter, '%d', $global_counter_file);
if (empty($global_counter_file)) {
$global_counter_file = 0;
}
fclose($fp_global_counter);
}
}
switch ($mode) {
case 'json':
echo json_encode(['correct' => true, 'global_counter' => $global_counter_file]);
break;
case 'return':
return $global_counter_file;
break;
case 'session':
$_SESSION['global_counter_chat'] = $global_counter_file;
break;
}
}
/**
* Get the last global counter for chat.
*
* @param string $mode There are two modes 'json', 'return' and 'session'. And json is by default.
*/
function users_get_last_type_message()
{
global $config;
$return = 'false';
$file_global_counter_chat = $config['attachment_store'].'/pandora_chat.global_counter.txt';
$log_chat_file = $config['attachment_store'].'/pandora_chat.log.json.txt';
$global_counter_file = 0;
$fp_global_counter = @fopen($file_global_counter_chat, 'a+');
if ($fp_global_counter) {
$tries = 0;
$lock = true;
while (!flock($fp_global_counter, LOCK_EX)) {
$tries++;
if ($tries > MAX_TIMES) {
$lock = false;
break;
}
sleep(1);
}
if ($lock) {
$text_encode = @file_get_contents($log_chat_file);
$log = json_decode($text_encode, true);
// Prevent from error when chat file log doesn't exists
if (empty($log)) {
$return = false;
} else {
$last = end($log);
$return = $last['type'];
}
fclose($fp_global_counter);
}
}
return $return;
}
function users_is_admin($id_user=false)
{
global $config;
@ -1026,98 +524,6 @@ function users_is_admin($id_user=false)
}
function users_is_last_system_message()
{
$type = users_get_last_type_message();
if ($type != 'message') {
return true;
} else {
return false;
}
}
function users_check_users()
{
global $config;
$return = [
'correct' => false,
'users' => '',
];
$users_with_session = db_get_all_rows_sql('SELECT tsessions_php.data FROM pandora.tsessions_php;');
$users_logged_now = [];
foreach ($users_with_session as $user_with_session) {
$tmp_id_user = explode('"', $user_with_session['data']);
array_push($users_logged_now, $tmp_id_user[1]);
}
$file_global_user_list = $config['attachment_store'].'/pandora_chat.user_list.json.txt';
// First lock the file
$fp_user_list = @fopen($file_global_user_list, 'a+');
if ($fp_user_list === false) {
echo json_encode($return);
return;
}
// Try to look MAX_TIMES times
$tries = 0;
while (!flock($fp_user_list, LOCK_EX)) {
$tries++;
if ($tries > MAX_TIMES) {
echo json_encode($return);
return;
}
sleep(1);
}
@fscanf($fp_user_list, "%[^\n]", $user_list_json);
$user_list = json_decode($user_list_json, true);
if (empty($user_list)) {
$user_list = [];
}
// Compare both user list. Meanwhile the user from chat file have an active
// session, his continue in the list of active chat users
$user_name_list = [];
foreach ($user_list as $key => $user) {
if (in_array($key, $users_logged_now)) {
array_push($user_name_list, $user['name']);
} else {
unset($user_list[$key]);
}
}
// Clean the file
ftruncate($fp_user_list, 0);
// Update the file with the correct list of users
$status = fwrite($fp_user_list, json_encode($user_list));
/*
if ($status === false) {
fclose($fp_user_list);
return;
} */
// Closing the resource
fclose($fp_user_list);
$return['correct'] = true;
$return['users'] = implode('<br />', $user_name_list);
echo json_encode($return);
return;
}
// Check if a user can manage a group when group is all
// This function dont check acls of the group, only if the
// user is admin or pandora manager and the group is all

View File

@ -564,13 +564,13 @@ function visual_map_print_item(
}
if ($is_a_link_to_other_visualconsole) {
if (METACONSOLE == 1) {
if (is_metaconsole() === true) {
$url = $config['homeurl'].'index.php?sec=screen&sec2=screens/screens&action=visualmap&pure=0&id_visualmap='.$layoutData['id_layout_linked'].'&refr=300';
} else {
$url = $config['homeurl'].'index.php?sec=network&amp;sec2=operation/visual_console/render_view&amp;pure='.$config['pure'].'&amp;id='.$layoutData['id_layout_linked'];
}
} else {
if (METACONSOLE == 1) {
if (is_metaconsole() === true) {
$url = $config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=0&ag_group='.$layoutData['id_group'].'&ag_freestring=&module_option=1&ag_modulename=&moduletype=&datatype=&status=-1&sort_field=&sort=none&pure=';
} else {
$url = $config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/estado_agente&group_id='.$layoutData['id_group'];

View File

@ -1181,8 +1181,16 @@ function add_agent_node(agents) {
$("#agent_name").val("");
$("#dialog_node_add").dialog("close");
const new_id =
Math.max.apply(
Math,
graph.nodes.map(function(o) {
return o.id;
})
) + 1;
var temp_node = {};
temp_node["id"] = graph.nodes.length;
temp_node["id"] = new_id;
temp_node["id_db"] = data["id_node"];
temp_node["id_agent"] = data["id_agent"];
temp_node["id_module"] = "";
@ -2423,7 +2431,13 @@ function refresh_holding_area() {
jQuery.each(holding_area.nodes, function(i, node) {
var temp_node = {};
temp_node["id"] = graph.nodes.length;
temp_node["id"] =
Math.max.apply(
Math,
graph.nodes.map(function(o) {
return o.id;
})
) + 1;
holding_area.nodes[i]["id"] = temp_node["id"];
temp_node["id_db"] = node["id_db"];
@ -2711,6 +2725,20 @@ function set_parent(parent_data) {
url: "ajax.php",
success: function(data) {
if (data["correct"]) {
var child_index = -1;
var parent_index = -1;
// Get indexes of child and parent nodes.
$.each(graph.nodes, function(i, d) {
if (child_data.id == d.id) {
child_index = i;
}
if (parent_data.id == d.id) {
parent_index = i;
}
});
//Add the relationship and paint
item = {};
item["arrow_start"] = "";
@ -2723,11 +2751,11 @@ function set_parent(parent_data) {
item["id_module_end"] = 0;
item["id_db"] = data["id"];
item["source_id_db"] = child_data.id_db;
item["target_id_db"] = parent_data.id;
item["id_agent_start"] = graph.nodes[child_data.id]["id_agent"];
item["id_agent_end"] = graph.nodes[parent_data.id]["id_agent"];
item["target"] = graph.nodes[parent_data.id];
item["source"] = graph.nodes[child_data.id];
item["target_id_db"] = parent_data.id_db;
item["id_agent_start"] = graph.nodes[child_index]["id_agent"];
item["id_agent_end"] = graph.nodes[parent_index]["id_agent"];
item["target"] = graph.nodes[parent_index];
item["source"] = graph.nodes[child_index];
graph.links.push(item);
}
@ -2922,8 +2950,16 @@ function add_fictional_node() {
if (data["correct"]) {
$("#dialog_node_add").dialog("close");
const new_id =
Math.max.apply(
Math,
graph.nodes.map(function(o) {
return o.id;
})
) + 1;
var temp_node = {};
temp_node["id"] = graph.nodes.length;
temp_node["id"] = new_id;
temp_node["id_db"] = data["id_node"];
temp_node["id_agent"] = data["id_agent"];
temp_node["id_module"] = 0;
@ -2951,8 +2987,16 @@ function add_fictional_node() {
} else {
$("#dialog_node_add").dialog("close");
const new_id =
Math.max.apply(
Math,
graph.nodes.map(function(o) {
return o.id;
})
) + 1;
var temp_node = {};
temp_node["id"] = graph.nodes.length;
temp_node["id"] = new_id;
temp_node["id_db"] = data["id_node"];
temp_node["id_agent"] = data["id_agent"];
temp_node["id_module"] = 0;

View File

@ -45,7 +45,7 @@ $(document).ready(function() {
jQuery.post(
"ajax.php",
{
page: "operation/messages/message_list"
page: "operation/messages/message_list",
},
function(data, status) {
$("#dialog_messages")
@ -58,10 +58,10 @@ $(document).ready(function() {
modal: true,
overlay: {
opacity: 0.5,
background: "black"
background: "black",
},
width: 700,
height: 300
height: 300,
})
.show();
},
@ -80,7 +80,7 @@ $(document).ready(function() {
jQuery.post(
"ajax.php",
{
page: "operation/system_alert"
page: "operation/system_alert",
},
function(data, status) {
$("#alert_messages").show();
@ -104,7 +104,7 @@ $(document).ready(function() {
"ajax.php",
{
page: "general/alert_enterprise",
message: elem
message: elem,
},
function(data, status) {
$("#alert_messages").show();
@ -130,7 +130,7 @@ $(document).ready(function() {
"ajax.php",
{
page: "general/alert_enterprise",
message: elem
message: elem,
},
function(data, status) {
$("#alert_messages").show();
@ -155,7 +155,7 @@ $(document).ready(function() {
"ajax.php",
{
page: "general/alert_enterprise",
message: elem
message: elem,
},
function(data, status) {
$("#alert_messages").show();
@ -174,6 +174,11 @@ $(document).ready(function() {
if (typeof show_error_license == "undefined") show_error_license = 0;
if (typeof hide_counter == "undefined") hide_counter = 0;
let height = 300;
if (typeof invalid_license != "undefined") height = 350;
if (process_login_ok || show_error_license) {
$("#license_error_msg_dialog").dialog({
dialogClass: "no-close",
@ -181,29 +186,33 @@ $(document).ready(function() {
resizable: false,
draggable: true,
modal: true,
height: 470,
height: height,
width: 850,
overlay: {
opacity: 0.5,
background: "black"
background: "black",
},
open: function() {
var remaining = 30;
if (hide_counter != 1) {
var remaining = 30;
// Timeout counter.
var count = function() {
if (remaining > 0) {
$("#license_error_remaining").text(remaining);
remaining -= 1;
} else {
$("#license_error_remaining").hide();
$("#ok_buttom").show();
clearInterval(count);
}
};
// Timeout counter.
var count = function() {
if (remaining > 0) {
$("#license_error_remaining").text(remaining);
remaining -= 1;
} else {
$("#license_error_remaining").hide();
$("#ok_buttom").show();
clearInterval(count);
}
};
setInterval(count, 1000);
}
setInterval(count, 1000);
} else {
$("#ok_buttom").show();
}
},
});
$("#submit-hide-license-error-msg").click(function() {
@ -221,8 +230,8 @@ $(document).ready(function() {
width: 620,
overlay: {
opacity: 0.5,
background: "black"
}
background: "black",
},
});
}
@ -235,8 +244,8 @@ $(document).ready(function() {
width: 520,
overlay: {
opacity: 0.5,
background: "black"
}
background: "black",
},
});
}
@ -249,8 +258,8 @@ $(document).ready(function() {
width: 520,
overlay: {
opacity: 0.5,
background: "black"
}
background: "black",
},
});
}
@ -318,7 +327,7 @@ $(document).ready(function() {
left:
+parseInt(screen.width / 2) -
parseInt($("#alert_messages").css("width")) / 2 +
"px"
"px",
});
});

View File

@ -103,6 +103,7 @@ $(document).ready(function() {
url:
"https://pandorafms.com/library/wp-json/wp/v2/categories?per_page=100",
type: "GET",
cache: false,
crossDomain: true,
contentType: "application/json",
success: function(data) {
@ -136,6 +137,7 @@ $(document).ready(function() {
url:
api_url + search_modules + "&orderby=modified&per_page=9&page=" + page,
type: "GET",
cache: false,
crossDomain: true,
contentType: "application/json",
beforeSend: function(xhr) {
@ -238,6 +240,7 @@ function library_main() {
$.ajax({
url: "https://pandorafms.com/library/wp-json/wp/v2/pages/121",
type: "GET",
cache: false,
crossDomain: true,
contentType: "application/json",
beforeSend: function(xhr) {
@ -313,6 +316,7 @@ function get_category(id) {
$.ajax({
url: "https://pandorafms.com/library/wp-json/wp/v2/categories/" + id,
type: "GET",
cache: false,
contentType: "application/json",
success: function(response) {
$("#category_title_result h2").append(

View File

@ -244,8 +244,19 @@ function initialiceLayout(data) {
}
$("#delete-widget-" + id).click(function(event) {
var nodo = event.target.offsetParent;
deleteCell(id, nodo.parentNode);
// eslint-disable-next-line no-undef
confirmDialog({
title: "Are you sure?",
message:
"<h4 style='text-align: center;padding-top: 20px;'>All changes made to this widget will be lost</h4>",
cancel: "Cancel",
ok: "Ok",
onAccept: function() {
// Continue execution.
var nodo = event.target.offsetParent;
deleteCell(id, nodo.parentNode);
}
});
});
$("#configure-widget-" + id).click(function() {

View File

@ -118,30 +118,26 @@ function execute_response(event_id, server_id) {
}
response["target"] = get_response_target(event_id, response_id, server_id);
response["event_id"] = event_id;
response["server_id"] = server_id;
switch (response["type"]) {
case "command":
show_response_dialog(event_id, response_id, response);
break;
case "url":
if (response["new_window"] == 1) {
window.open(response["target"], "_blank");
} else {
show_response_dialog(event_id, response_id, response);
}
break;
if (response["type"] == "url" && response["new_window"] == 1) {
window.open(response["target"], "_blank");
} else {
show_response_dialog(response_id, response);
}
}
//Show the modal window of an event response
function show_response_dialog(event_id, response_id, response) {
function show_response_dialog(response_id, response) {
var params = [];
params.push("page=include/ajax/events");
params.push("dialogue_event_response=1");
params.push("massive=0");
params.push("event_id=" + event_id);
params.push("event_id=" + response["event_id"]);
params.push("target=" + response["target"]);
params.push("response_id=" + response_id);
params.push("server_id=" + response["server_id"]);
jQuery.ajax({
data: params.join("&"),
@ -159,7 +155,7 @@ function show_response_dialog(event_id, response_id, response) {
draggable: true,
modal: false,
open: function() {
perform_response(response["target"], response_id);
perform_response(response, response_id);
},
width: response["modal_width"],
height: response["modal_height"]
@ -171,7 +167,6 @@ function show_response_dialog(event_id, response_id, response) {
//Show the modal window of event responses when multiple events are selected
function show_massive_response_dialog(
event_id,
response_id,
response,
out_iterator,
@ -183,13 +178,14 @@ function show_massive_response_dialog(
params.push("massive=1");
params.push("end=" + end);
params.push("out_iterator=" + out_iterator);
params.push("event_id=" + event_id);
params.push("event_id=" + response["event_id"]);
params.push("target=" + response["target"]);
params.push("response_id=" + response_id);
params.push("server_id=" + response["server_id"]);
jQuery.ajax({
data: params.join("&"),
response_tg: response["target"],
response_tg: response,
response_id: response_id,
out_iterator: out_iterator,
type: "POST",
@ -384,7 +380,7 @@ function get_response_target(
}
// Perform a response and put the output into a div
function perform_response(target, response_id) {
function perform_response(response, response_id) {
$("#re_exec_command").hide();
$("#response_loading_command").show();
$("#response_out").html("");
@ -392,8 +388,10 @@ function perform_response(target, response_id) {
var params = [];
params.push("page=include/ajax/events");
params.push("perform_event_response=1");
params.push("target=" + target);
params.push("target=" + response["target"]);
params.push("response_id=" + response_id);
params.push("event_id=" + response["event_id"]);
params.push("server_id=" + response["server_id"]);
jQuery.ajax({
data: params.join("&"),
@ -413,7 +411,7 @@ function perform_response(target, response_id) {
}
// Perform a response and put the output into a div
function perform_response_massive(target, response_id, out_iterator) {
function perform_response_massive(response, response_id, out_iterator) {
$("#re_exec_command").hide();
$("#response_loading_command_" + out_iterator).show();
$("#response_out_" + out_iterator).html("");
@ -421,8 +419,10 @@ function perform_response_massive(target, response_id, out_iterator) {
var params = [];
params.push("page=include/ajax/events");
params.push("perform_event_response=1");
params.push("target=" + target);
params.push("target=" + response["target"]);
params.push("response_id=" + response_id);
params.push("event_id=" + response["event_id"]);
params.push("server_id=" + response["server_id"]);
jQuery.ajax({
data: params.join("&"),
@ -916,17 +916,24 @@ function check_massive_response_event(
$(".chk_val:checked").each(function() {
var event_id = $(this).val();
var server_id = $("#hidden-server_id_" + event_id).val();
var meta = $("#hidden-meta").val();
var server_id = 0;
if (meta) {
server_id = $("#hidden-server_id_" + event_id).val();
}
response["target"] = get_response_target(
event_id,
response_id,
server_id,
response_command
);
response["server_id"] = server_id;
response["event_id"] = event_id;
if (total_checked - 1 === counter) end = 1;
show_massive_response_dialog(event_id, response_id, response, counter, end);
show_massive_response_dialog(response_id, response, counter, end);
counter++;
});

View File

@ -20,7 +20,7 @@ var TreeController = {
recipient: "",
tree: [],
emptyMessage: "No data found.",
foundMessage: "Found groups",
foundMessage: "Groups found",
errorMessage: "Error",
baseURL: "",
ajaxURL: "ajax.php",
@ -48,9 +48,15 @@ var TreeController = {
.addClass("tree-root")
.hide()
.prepend(
'<img src="' +
'<div class="tree-node flex-row-vcenter">' +
'<img src="' +
(controller.baseURL.length > 0 ? controller.baseURL : "") +
'images/pandora.png" />'
'images/pandora.png" />' +
"<span class='margin-left-1'>" +
(controller.tree.length > 0
? controller.foundMessage + ": " + controller.tree.length
: "") +
"</div>"
);
}
// Normal group
@ -315,7 +321,7 @@ var TreeController = {
_processNodeCounterTitle($totalCounter, type, "total");
// Open the parentheses
$counters.append(" (");
$counters.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [ ");
$counters.append($totalCounter);
@ -409,7 +415,7 @@ var TreeController = {
}
// Close the parentheses
$counters.append(")");
$counters.append(" ]");
hasCounters = true;
}
@ -541,6 +547,7 @@ var TreeController = {
break;
case "agent":
// Is quiet
if (
typeof element.quietImageHTML != "undefined" &&
element.quietImageHTML.length > 0
@ -560,16 +567,6 @@ var TreeController = {
$content.append($statusImage);
}
// Alerts fired image
if (
typeof element.alertImageHTML != "undefined" &&
element.alertImageHTML.length > 0
) {
var $alertImage = $(element.alertImageHTML);
$alertImage.addClass("agent-alerts-fired");
$content.append($alertImage);
}
// Events by agent
if (element.showEventsBtn == 1) {
@ -690,6 +687,8 @@ var TreeController = {
$content.append(" " + element.name);
break;
case "module":
$content.addClass("module");
// Status image
if (
typeof element.statusImageHTML != "undefined" &&
@ -700,17 +699,19 @@ var TreeController = {
$content.append($statusImage);
}
// Server type
if (
typeof element.serverTypeHTML != "undefined" &&
element.serverTypeHTML.length > 0 &&
element.serverTypeHTML != "--"
) {
var $serverTypeImage = $(element.serverTypeHTML);
$serverTypeImage.addClass("module-server-type");
$content.append($serverTypeImage);
}
// Name max 42 chars.
$content.append(
'<span class="module-name">' +
element.name.substring(0, 42) +
(element.name.length > 42 ? "..." : "") +
"</span>"
);
// Value.
$content.append(
'<span class="module-value">' + element.value + "</span>"
);
if (
typeof element.showGraphs != "undefined" &&
@ -832,7 +833,6 @@ var TreeController = {
$content.append($alertsImage);
}
$content.append(element.name);
break;
case "os":
if (
@ -1086,20 +1086,6 @@ var TreeController = {
}
controller.recipient.empty();
if (
controller.tree.length !== undefined &&
controller.foundMessage !== "not"
) {
controller.recipient.html(
"<div> " +
controller.foundMessage +
": " +
controller.tree.length +
"</div>" +
"<br/>"
);
}
var $children = _processGroup(this.recipient, this.tree, true);
$children.show();

View File

@ -1,47 +0,0 @@
function check_new_chats_icon(id_icon) {
if (new_chat) {
$("#" + id_icon).pulsate();
}
}
function check_new_chats_icon_ajax(id_icon) {
var exit = false;
url_chunks = location.href.split("&");
$.each(url_chunks, function(key, chunk) {
if (chunk == "sec2=operation/users/webchat") exit = true;
return;
});
if (exit) {
return;
}
old = global_counter_chat;
get_last_global_counter();
if (old < global_counter_chat) {
$("#" + id_icon).pulsate();
}
setTimeout('check_new_chats_icon("' + id_icon + '")', 5000);
}
function get_last_global_counter() {
var parameters = {};
parameters["page"] = "operation/users/webchat";
parameters["get_last_global_counter"] = 1;
$.ajax({
type: "POST",
url: "ajax.php",
data: parameters,
dataType: "json",
async: false,
success: function(data) {
if (data["correct"] == 1) {
global_counter_chat = data["global_counter"];
}
}
});
}

File diff suppressed because it is too large Load Diff

View File

@ -1042,6 +1042,17 @@ class Manager
$cellData['id_widget'] = $this->widgetId;
}
}
$instance = $this->instanceWidget();
$cellData['options'] = $instance->decoders(
$instance->getOptionsWidget()
);
if (isset($cellData['options']['title']) === false) {
$cellData['options']['title'] = $instance->getDescription();
}
$cellData['options'] = json_encode($cellData['options']);
}
View::render(

View File

@ -59,7 +59,7 @@ class Widget
$cellClass = new Cell($this->cellId, $this->dashboardId);
$this->dataCell = $cellClass->get();
$this->values = $this->getOptionsWidget();
$this->values = $this->decoders($this->getOptionsWidget());
}
return $this;
@ -535,6 +535,34 @@ class Widget
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder):array
{
$values = [];
if (isset($decoder['title']) === true) {
$values['title'] = $decoder['title'];
}
if (isset($decoder['background-color']) === true) {
$values['background'] = $decoder['background-color'];
}
if (isset($decoder['background']) === true) {
$values['background'] = $decoder['background'];
}
return $values;
}
/**
* Size Cell.
*

View File

@ -169,489 +169,11 @@ class AgentModuleWidget extends Widget
// This forces at least a first configuration.
$this->configurationRequired = false;
if (empty($this->values['moduleId']) === true) {
$this->configurationRequired = true;
}
$this->overflow_scrollbars = false;
}
/*
// DO NOT CHANGE THIS VALUE.
$id_group = isset($this->options['search_group_'.$id]) ? $this->options['search_group_'.$id] : 0;
$agent_conf_key = 'id_agent_'.$id;
$id_agent = $this->options[$agent_conf_key];
$module_conf_key = 'id_module_'.$id;
$id_module = $this->options[$module_conf_key];
$recursion_checked = $this->options['recursion'];
$this->add_configuration(
'search_group_'.$id,
__('Group'),
OPTION_TREE_GROUP_SELECT
);
$list_agents = agents_get_group_agents(
$id_group,
false,
'lower',
false,
$recursion_checked
);
if (!isset($this->options['selection_agent_module_'.$id])
|| $this->options['selection_agent_module_'.$id] == ''
|| $this->options['selection_agent_module_'.$id] == null
) {
$selection_agent_module = 'common';
} else {
$selection_agent_module = $this->options['selection_agent_module_'.$id];
}
$limit_common = '';
$sql = false;
if (!empty($id_agent)) {
if ($selection_agent_module == 'common') {
$limit_common = sprintf(
' AND (SELECT count(nombre)
FROM tagente_modulo t2
WHERE t2.delete_pending = 0
AND t1.nombre = t2.nombre
AND t2.id_agente IN (%s)) = (%d)',
implode(',', (array) $id_agent),
count($id_agent)
);
}
$sql = sprintf(
'SELECT DISTINCT nombre
FROM tagente_modulo t1
WHERE id_agente IN (%s)
AND delete_pending = 0 %s ORDER BY nombre',
implode(', ', (array) $id_agent),
$limit_common
);
}
if (empty($id_module)) {
$this->options[$module_conf_key] = index_array(
db_get_all_rows_sql($sql),
'nombre',
'nombre'
);
}
$this->add_configuration(
'recursion',
__('Recursion'),
OPTION_BOOLEAN
);
$this->add_configuration(
$agent_conf_key,
__('Agent'),
OPTION_SELECT_MULTISELECTION,
['values' => $list_agents]
);
$this->add_configuration(
'selection_agent_module_'.$id,
__('Show common modules'),
OPTION_SINGLE_SELECT,
[
'values' => [
'common' => __('Show common modules'),
'all' => __('Show all modules'),
],
]
);
$this->add_configuration(
$module_conf_key,
__('Module'),
OPTION_SELECT_MULTISELECTION,
[
'values' => index_array(
db_get_all_rows_sql($sql),
'nombre',
'nombre'
),
]
);
$this->add_configuration(
'',
'',
OPTION_CUSTOM_INPUT,
[
'widget' => $this,
'entire_row' => true,
'update' => false,
]
);
*/
function print_configuration_custom($return=true)
{
$id = $this->getId();
ob_start();
?>
<script>
$(document).ready(function() {
recalculate_modules_select_agent_module(
$("#selection_agent_module_<?php echo $id; ?>").val()
);
function recalculate_modules_select_agent_module (selection_mode) {
var idAgents = Array();
jQuery.each ($('#id_agent_<?php echo $id; ?> option:selected'), function (i, val) {
idAgents.push($(val).val());
});
jQuery.post ('ajax.php',
{"page": "operation/agentes/ver_agente",
"get_modules_group_value_name_json": 1,
"selection": selection_mode == 'all' ? 1 : 0,
"id_agents[]": idAgents
},
function (data, status) {
$('#id_module_<?php echo $id; ?>').empty ();
if (data) {
jQuery.each (data, function (id, value) {
$('#id_module_<?php echo $id; ?>')
.append ($('<option></option>')
.html(value)
.prop("value", value)
.prop("selected", 'selected'));
});
}
},
"json"
);
}
$('#search_group_<?php echo $id; ?>').on('change',function() {
jQuery.post ("ajax.php",
{
"page" : "operation/agentes/ver_agente",
"get_agents_group_json" : 1,
"id_group" : this.value,
"recursion" : ($('#checkbox-recursion-<?php echo $id; ?>').is(':checked')) ? 1 : 0
},
function (data, status) {
$('#id_agent_<?php echo $id; ?>').html('');
jQuery.each (data, function(id, value) {
// Remove keys_prefix from the index.
option = $("<option></option>")
.prop("value", id)
.prop("selected", 'selected')
.html(value);
$('#id_agent_<?php echo $id; ?>').append (option);
});
recalculate_modules_select_agent_module(
$("#selection_agent_module_<?php echo $id; ?>").val()
);
},
"json"
);
});
$('#checkbox-recursion-<?php echo $id; ?>').on('change', function() {
($('#hidden-recursion_sent').val() === '1') ? $('#hidden-recursion_sent').val('0') : $('#hidden-recursion_sent').val('1');
jQuery.post ("ajax.php",
{
"page" : "operation/agentes/ver_agente",
"get_agents_group_json" : 1,
"id_group" : $('#search_group_<?php echo $id; ?>').val(),
"recursion" : ($('#checkbox-recursion-<?php echo $id; ?>').is(':checked')) ? 1 : 0
},
function (data, status) {
$('#id_agent_<?php echo $id; ?>').html('');
jQuery.each (data, function(id, value) {
// Remove keys_prefix from the index.
option = $("<option></option>")
.prop("value", id)
.prop("selected", 'selected')
.html(value);
$('#id_agent_<?php echo $id; ?>').append (option);
});
recalculate_modules_select_agent_module(
$("#selection_agent_module_<?php echo $id; ?>").val()
);
},
"json"
);
});
$("#id_agent_<?php echo $id; ?>").on('change',function () {
recalculate_modules_select_agent_module(
$("#selection_agent_module_<?php echo $id; ?>").val()
);
});
$("#selection_agent_module_<?php echo $id; ?>").on('change',function(evt) {
recalculate_modules_select_agent_module(
$("#selection_agent_module_<?php echo $id; ?>").val()
);
});
});
</script>
<?php
return ob_get_clean();
}
public function generate_data_agent_module($agents, $all_modules)
{
$return = [];
$cont = 0;
$name = '';
foreach ($all_modules as $key => $module) {
if ($module == $name) {
$modules_by_name[($cont - 1)]['id'][] = $key;
} else {
$name = $module;
$modules_by_name[$cont]['name'] = $name;
$modules_by_name[$cont]['id'][] = $key;
$cont ++;
}
}
foreach ($agents as $agent) {
if (!users_access_to_agent($agent['id_agente'])) {
continue;
}
$row = [];
$row['agent_status'] = agents_get_status($agent['id_agente'], true);
$row['agent_name'] = $agent['nombre'];
$row['agent_alias'] = $agent['alias'];
$agent_modules = agents_get_modules($agent['id_agente']);
$row['modules'] = [];
foreach ($modules_by_name as $module) {
$row['modules'][$module['name']] = null;
foreach ($module['id'] as $module_id) {
if (array_key_exists($module_id, $agent_modules)) {
$row['modules'][$module['name']] = modules_get_agentmodule_status($module_id);
break;
}
}
}
$return[] = $row;
}
return $return;
}
public function generate_view_agent_module($visual_data)
{
$table_data = '<div>';
$table_data .= '<table class="widget_agent_module" cellpadding="1" cellspacing="0" border="0" style="background-color: #EEE;">';
if (!empty($visual_data)) {
$table_data .= '<th>'.__('Agents').' / '.__('Modules').'</th>';
$array_names = [];
foreach ($visual_data as $data) {
foreach ($data['modules'] as $module_name => $module) {
if ($module === null || in_array($module_name, $array_names)) {
continue;
} else {
$array_names[] = $module_name;
}
}
}
natcasesort($array_names);
foreach ($array_names as $module_name) {
$file_name = ui_print_truncate_text(
$module_name,
'module_small',
false,
true,
false,
'...'
);
$table_data .= '<th style="padding: 10px;">'.$file_name.'</th>';
}
foreach ($visual_data as $row) {
$table_data .= "<tr style='height: 35px;'>";
switch ($row['agent_status']) {
case AGENT_STATUS_ALERT_FIRED:
$rowcolor = COL_ALERTFIRED;
$textcolor = '#000';
break;
case AGENT_STATUS_CRITICAL:
$rowcolor = COL_CRITICAL;
$textcolor = '#FFF';
break;
case AGENT_STATUS_WARNING:
$rowcolor = COL_WARNING;
$textcolor = '#000';
break;
case AGENT_STATUS_NORMAL:
$rowcolor = COL_NORMAL;
$textcolor = '#FFF';
break;
case AGENT_STATUS_UNKNOWN:
case AGENT_STATUS_ALL:
default:
$rowcolor = COL_UNKNOWN;
$textcolor = '#FFF';
break;
}
$file_name = ui_print_truncate_text(
$row['agent_alias'],
'agent_small',
false,
true,
false,
'...'
);
$table_data .= "<td style='background-color: ".$rowcolor.";'>".$file_name.'</td>';
foreach ($row['modules'] as $module_name => $module) {
if ($module === null) {
if (in_array($module_name, $array_names)) {
$table_data .= "<td style='background-color: #DDD;'></td>";
} else {
continue;
}
} else {
$table_data .= "<td style='text-align: center; background-color: #DDD;'>";
switch ($module) {
case AGENT_STATUS_NORMAL:
$table_data .= ui_print_status_image(
'module_ok.png',
__(
'%s in %s : NORMAL',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case AGENT_STATUS_CRITICAL:
$table_data .= ui_print_status_image(
'module_critical.png',
__(
'%s in %s : CRITICAL',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case AGENT_STATUS_WARNING:
$table_data .= ui_print_status_image(
'module_warning.png',
__(
'%s in %s : WARNING',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case AGENT_STATUS_UNKNOWN:
$table_data .= ui_print_status_image(
'module_unknown.png',
__(
'%s in %s : UNKNOWN',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case 4:
$table_data .= ui_print_status_image(
'module_no_data.png',
__(
'%s in %s : Not initialize',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case AGENT_STATUS_ALERT_FIRED:
default:
$table_data .= ui_print_status_image(
'module_alertsfired.png',
__(
'%s in %s : ALERTS FIRED',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
}
$table_data .= '</td>';
}
}
$table_data .= '</tr>';
}
} else {
$table_data .= '<tr><td>'.__('Please configure this widget before usage').'</td></tr>';
}
$table_data .= '</table>';
$table_data .= '</div>';
return $table_data;
}
/**
* Generates inputs for form (specific).
*
@ -666,38 +188,12 @@ class AgentModuleWidget extends Widget
// Retrieve global - common inputs.
$inputs = parent::getFormInputs();
// Autocomplete agents.
$inputs[] = [
'label' => __('Agent'),
'arguments' => [
'type' => 'autocomplete_agent',
'name' => 'agentAlias',
'id_agent_hidden' => $values['agentId'],
'name_agent_hidden' => 'agentId',
'server_id_hidden' => $values['metaconsoleId'],
'name_server_hidden' => 'metaconsoleId',
'return' => true,
'module_input' => true,
'module_name' => 'moduleId',
'module_none' => false,
'size' => 0,
],
];
// Autocomplete module.
$inputs[] = [
'label' => __('Module'),
'arguments' => [
'type' => 'autocomplete_module',
'fields' => $fields,
'name' => 'moduleId',
'selected' => $values['moduleId'],
'return' => true,
'sort' => false,
'agent_id' => $values['agentId'],
'metaconsole_id' => $values['metaconsoleId'],
'style' => 'width: inherit;',
],
'label' => \ui_print_error_message(
__('This widget has been removed'),
'',
true
),
];
return $inputs;
@ -714,12 +210,6 @@ class AgentModuleWidget extends Widget
// Retrieve global - common inputs.
$values = parent::getPost();
$values['agentId'] = \get_parameter('agentId', 0);
$values['metaconsoleId'] = \get_parameter('metaconsoleId', 0);
$values['moduleId'] = \get_parameter('moduleId', 0);
$values['period'] = \get_parameter('period', 0);
$values['showLegend'] = \get_parameter_switch('showLegend');
return $values;
}
@ -733,45 +223,14 @@ class AgentModuleWidget extends Widget
{
global $config;
// TODO:XXX WIP.
return 'WIP in this widget';
/*
$this->body = '';
$id_agent = $this->options['id_agent_'.$this->getId()];
if (! check_acl($config['id_user'], 0, 'AR')) {
$this->body = __('You don\'t have access');
return;
}
$id_module = $this->options['id_module_'.$this->getId()];
if ($id_agent) {
$sql = 'SELECT id_agente,nombre,alias
FROM tagente
WHERE id_agente IN ('.implode(',', $id_agent).')
ORDER BY id_agente';
$agents = db_get_all_rows_sql($sql);
if ($agents === false) {
$agents = [];
}
$sql = 'SELECT id_agente_modulo,nombre
FROM tagente_modulo
WHERE id_agente IN ('.implode(',', $id_agent).")
AND nombre IN ('".implode("','", $id_module)."')
AND delete_pending = 0 ORDER BY nombre";
$modules = index_array(db_get_all_rows_sql($sql), 'id_agente_modulo', 'nombre');
if ($modules === false) {
$modules = [];
}
} else {
$agents = [];
$modules = [];
}
$visual_data = $this->generate_data_agent_module($agents, $modules);
$this->body .= $this->generate_view_agent_module($visual_data);
*/
$output .= '<div class="container-center">';
$output .= \ui_print_error_message(
__('This widget has been removed'),
'',
true
);
$output .= '</div>';
return $output;
}

View File

@ -146,7 +146,7 @@ class AlertsFiredWidget extends Widget
$this->gridWidth = $gridWidth;
// Options.
$this->values = $this->getOptionsWidget();
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
@ -176,6 +176,31 @@ class AlertsFiredWidget extends Widget
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['group']) === true) {
$values['groupId'] = $decoder['group'];
}
if (isset($decoder['groupId']) === true) {
$values['groupId'] = $decoder['groupId'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*
@ -234,7 +259,7 @@ class AlertsFiredWidget extends Widget
$output = '';
if ($this->values['groupId'] === 0) {
if ((int) $this->values['groupId'] === 0) {
$groups = users_get_groups(false, 'AR', false);
} else {
$groups = [$this->values['groupId'] => ''];
@ -254,7 +279,7 @@ class AlertsFiredWidget extends Widget
$flag = false;
foreach ($groups as $id_group => $name) {
$alerts_group = get_group_alerts($id_group);
$alerts_group = get_group_alerts([$id_group]);
if (isset($alerts_group['simple']) === true) {
$alerts_group = $alerts_group['simple'];
}

View File

@ -142,7 +142,7 @@ class ClockWidget extends Widget
$this->gridWidth = $gridWidth;
// Options.
$this->values = $this->getOptionsWidget();
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
@ -172,6 +172,31 @@ class ClockWidget extends Widget
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['clock_type']) === true) {
$values['clockType'] = $decoder['clock_type'];
}
if (isset($decoder['clockType']) === true) {
$values['clockType'] = $decoder['clockType'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*

View File

@ -104,6 +104,13 @@ class CustomGraphWidget extends Widget
*/
protected $gridWidth;
/**
* Cell ID.
*
* @var integer
*/
protected $cellId;
/**
* Construct.
@ -141,8 +148,11 @@ class CustomGraphWidget extends Widget
// Grid Width.
$this->gridWidth = $gridWidth;
// Cell Id.
$this->cellId = $cellId;
// Options.
$this->values = $this->getOptionsWidget();
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
@ -173,6 +183,43 @@ class CustomGraphWidget extends Widget
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['id_graph']) === true) {
$values['id_graph'] = $decoder['id_graph'];
}
if (isset($decoder['stacked']) === true) {
$values['type'] = $decoder['stacked'];
}
if (isset($decoder['type']) === true) {
$values['type'] = $decoder['type'];
}
if (isset($decoder['period']) === true) {
$values['period'] = $decoder['period'];
}
if (isset($decoder['showLegend']) === true) {
$values['showLegend'] = $decoder['showLegend'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*

View File

@ -147,7 +147,7 @@ class EventsListWidget extends Widget
$this->gridWidth = $gridWidth;
// Options.
$this->values = $this->getOptionsWidget();
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
@ -177,6 +177,71 @@ class EventsListWidget extends Widget
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['type']) === true) {
$values['eventType'] = $decoder['type'];
}
if (isset($decoder['eventType']) === true) {
$values['eventType'] = $decoder['eventType'];
}
if (isset($decoder['event_view_hr']) === true) {
$values['maxHours'] = $decoder['event_view_hr'];
}
if (isset($decoder['maxHours']) === true) {
$values['maxHours'] = $decoder['maxHours'];
}
if (isset($decoder['limit']) === true) {
$values['limit'] = $decoder['limit'];
}
if (isset($decoder['status']) === true) {
$values['eventStatus'] = $decoder['status'];
}
if (isset($decoder['eventStatus']) === true) {
$values['eventStatus'] = $decoder['eventStatus'];
}
if (isset($decoder['severity']) === true) {
$values['severity'] = $decoder['severity'];
}
if (isset($decoder['id_groups']) === true) {
if (is_array($decoder['id_groups']) === true) {
$decoder['id_groups'][0] = implode(',', $decoder['id_groups']);
}
$values['groupId'] = $decoder['id_groups'];
}
if (isset($decoder['groupId']) === true) {
$values['groupId'] = $decoder['groupId'];
}
if (isset($decoder['tagsId']) === true) {
$values['tagsId'] = $decoder['tagsId'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*
@ -416,13 +481,15 @@ class EventsListWidget extends Widget
$filter['limit'] = $this->values['limit'];
$filter['order'] = '`utimestamp` DESC';
if ((int) $this->values['severity'] === 20) {
$filter['criticity'] = [
EVENT_CRIT_WARNING,
EVENT_CRIT_CRITICAL,
];
} else if ((int) $this->values['severity'] !== -1) {
$filter['criticity'] = $this->values['severity'];
if (isset($this->values['severity']) === true) {
if ((int) $this->values['severity'] === 20) {
$filter['criticity'] = [
EVENT_CRIT_WARNING,
EVENT_CRIT_CRITICAL,
];
} else if ((int) $this->values['severity'] !== -1) {
$filter['criticity'] = $this->values['severity'];
}
}
if (empty($this->values['tagsId']) === false) {

View File

@ -142,7 +142,7 @@ class WelcomeWidget extends Widget
$this->gridWidth = $gridWidth;
// Options.
$this->values = $this->getOptionsWidget();
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
@ -168,6 +168,23 @@ class WelcomeWidget extends Widget
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
return $values;
}
/**
* Generates inputs for form (specific).
*

View File

@ -106,6 +106,13 @@ class GraphModuleHistogramWidget extends Widget
*/
protected $gridWidth;
/**
* Cell ID.
*
* @var integer
*/
protected $cellId;
/**
* Construct.
@ -148,8 +155,11 @@ class GraphModuleHistogramWidget extends Widget
// Grid Width.
$this->gridWidth = $gridWidth;
// Cell Id.
$this->cellId = $cellId;
// Options.
$this->values = $this->getOptionsWidget();
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
@ -179,6 +189,63 @@ class GraphModuleHistogramWidget extends Widget
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['label_'.$this->cellId]) === true) {
$values['label'] = $decoder['label_'.$this->cellId];
}
if (isset($decoder['label']) === true) {
$values['label'] = $decoder['label'];
}
if (isset($decoder['id_agent_'.$this->cellId]) === true) {
$values['agentId'] = $decoder['id_agent_'.$this->cellId];
}
if (isset($decoder['agentId']) === true) {
$values['agentId'] = $decoder['agentId'];
}
if (isset($decoder['metaconsoleId']) === true) {
$values['metaconsoleId'] = $decoder['metaconsoleId'];
}
if (isset($decoder['id_module_'.$this->cellId]) === true) {
$values['moduleId'] = $decoder['id_module_'.$this->cellId];
}
if (isset($decoder['moduleId']) === true) {
$values['moduleId'] = $decoder['moduleId'];
}
if (isset($decoder['size_label_'.$this->cellId]) === true) {
$values['sizeLabel'] = $decoder['size_label_'.$this->cellId];
}
if (isset($decoder['sizeLabel']) === true) {
$values['sizeLabel'] = $decoder['sizeLabel'];
}
if (isset($decoder['period']) === true) {
$values['period'] = $decoder['period'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*

View File

@ -142,7 +142,7 @@ class GroupsStatusWidget extends Widget
$this->gridWidth = $gridWidth;
// Options.
$this->values = $this->getOptionsWidget();
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
@ -172,6 +172,31 @@ class GroupsStatusWidget extends Widget
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['groups']) === true) {
$values['groupId'] = $decoder['groups'];
}
if (isset($decoder['groupId']) === true) {
$values['groupId'] = $decoder['groupId'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*

View File

@ -158,7 +158,7 @@ class MapsMadeByUser extends Widget
$this->cellId = $cellId;
// Options.
$this->values = $this->getOptionsWidget();
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
@ -188,6 +188,31 @@ class MapsMadeByUser extends Widget
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['id_layout']) === true) {
$values['vcId'] = $decoder['id_layout'];
}
if (isset($decoder['vcId']) === true) {
$values['vcId'] = $decoder['vcId'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*

View File

@ -142,7 +142,7 @@ class MapsStatusWidget extends Widget
$this->gridWidth = $gridWidth;
// Options.
$this->values = $this->getOptionsWidget();
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
@ -172,6 +172,31 @@ class MapsStatusWidget extends Widget
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['maps']) === true) {
if (is_array($decoder['maps']) === true) {
$decoder['maps'][0] = implode(',', $decoder['maps']);
}
$values['maps'] = $decoder['maps'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*

View File

@ -114,6 +114,13 @@ class ModuleIconWidget extends Widget
*/
protected $dashboardId;
/**
* Cell ID.
*
* @var integer
*/
protected $cellId;
/**
* Construct.
@ -151,8 +158,11 @@ class ModuleIconWidget extends Widget
// Grid Width.
$this->gridWidth = $gridWidth;
// Cell Id.
$this->cellId = $cellId;
// Options.
$this->values = $this->getOptionsWidget();
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
@ -183,6 +193,83 @@ class ModuleIconWidget extends Widget
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['label_'.$this->cellId]) === true) {
$values['label'] = $decoder['label_'.$this->cellId];
}
if (isset($decoder['label']) === true) {
$values['label'] = $decoder['label'];
}
if (isset($decoder['id_agent_'.$this->cellId]) === true) {
$values['agentId'] = $decoder['id_agent_'.$this->cellId];
}
if (isset($decoder['agentId']) === true) {
$values['agentId'] = $decoder['agentId'];
}
if (isset($decoder['metaconsoleId']) === true) {
$values['metaconsoleId'] = $decoder['metaconsoleId'];
}
if (isset($decoder['id_module_'.$this->cellId]) === true) {
$values['moduleId'] = $decoder['id_module_'.$this->cellId];
}
if (isset($decoder['moduleId']) === true) {
$values['moduleId'] = $decoder['moduleId'];
}
if (isset($decoder['size_value_'.$this->cellId]) === true) {
$values['sizeValue'] = $decoder['size_value_'.$this->cellId];
}
if (isset($decoder['sizeValue']) === true) {
$values['sizeValue'] = $decoder['sizeValue'];
}
if (isset($decoder['size_label_'.$this->cellId]) === true) {
$values['sizeLabel'] = $decoder['size_label_'.$this->cellId];
}
if (isset($decoder['sizeLabel']) === true) {
$values['sizeLabel'] = $decoder['sizeLabel'];
}
if (isset($decoder['size_icon_'.$this->cellId]) === true) {
$values['sizeIcon'] = $decoder['size_icon_'.$this->cellId];
}
if (isset($decoder['sizeIcon']) === true) {
$values['sizeIcon'] = $decoder['sizeIcon'];
}
if (isset($decoder['icon_module_'.$this->cellId]) === true) {
$values['imageSrc'] = $decoder['icon_module_'.$this->cellId];
}
if (isset($decoder['imageSrc']) === true) {
$values['imageSrc'] = $decoder['imageSrc'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*

View File

@ -106,6 +106,13 @@ class ModuleStatusWidget extends Widget
*/
protected $gridWidth;
/**
* Cell ID.
*
* @var integer
*/
protected $cellId;
/**
* Construct.
@ -146,8 +153,11 @@ class ModuleStatusWidget extends Widget
// Grid Width.
$this->gridWidth = $gridWidth;
// Cell Id.
$this->cellId = $cellId;
// Options.
$this->values = $this->getOptionsWidget();
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
@ -177,6 +187,83 @@ class ModuleStatusWidget extends Widget
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['label_'.$this->cellId]) === true) {
$values['label'] = $decoder['label_'.$this->cellId];
}
if (isset($decoder['label']) === true) {
$values['label'] = $decoder['label'];
}
if (isset($decoder['id_agent_'.$this->cellId]) === true) {
$values['agentId'] = $decoder['id_agent_'.$this->cellId];
}
if (isset($decoder['agentId']) === true) {
$values['agentId'] = $decoder['agentId'];
}
if (isset($decoder['metaconsoleId']) === true) {
$values['metaconsoleId'] = $decoder['metaconsoleId'];
}
if (isset($decoder['id_module_'.$this->cellId]) === true) {
$values['moduleId'] = $decoder['id_module_'.$this->cellId];
}
if (isset($decoder['moduleId']) === true) {
$values['moduleId'] = $decoder['moduleId'];
}
if (isset($decoder['size_value_'.$this->cellId]) === true) {
$values['sizeValue'] = $decoder['size_value_'.$this->cellId];
}
if (isset($decoder['sizeValue']) === true) {
$values['sizeValue'] = $decoder['sizeValue'];
}
if (isset($decoder['size_label_'.$this->cellId]) === true) {
$values['sizeLabel'] = $decoder['size_label_'.$this->cellId];
}
if (isset($decoder['sizeLabel']) === true) {
$values['sizeLabel'] = $decoder['sizeLabel'];
}
if (isset($decoder['size_icon_'.$this->cellId]) === true) {
$values['sizeIcon'] = $decoder['size_icon_'.$this->cellId];
}
if (isset($decoder['sizeIcon']) === true) {
$values['sizeIcon'] = $decoder['sizeIcon'];
}
if (isset($decoder['icon_module_'.$this->cellId]) === true) {
$values['imageSrc'] = $decoder['icon_module_'.$this->cellId];
}
if (isset($decoder['imageSrc']) === true) {
$values['imageSrc'] = $decoder['imageSrc'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*

View File

@ -107,6 +107,13 @@ class ModuleTableValueWidget extends Widget
*/
protected $gridWidth;
/**
* Cell ID.
*
* @var integer
*/
protected $cellId;
/**
* Construct.
@ -148,8 +155,11 @@ class ModuleTableValueWidget extends Widget
// Grid Width.
$this->gridWidth = $gridWidth;
// Cell Id.
$this->cellId = $cellId;
// Options.
$this->values = $this->getOptionsWidget();
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
@ -179,6 +189,59 @@ class ModuleTableValueWidget extends Widget
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['id_agent_'.$this->cellId]) === true) {
$values['agentId'] = $decoder['id_agent_'.$this->cellId];
}
if (isset($decoder['agentId']) === true) {
$values['agentId'] = $decoder['agentId'];
}
if (isset($decoder['metaconsoleId']) === true) {
$values['metaconsoleId'] = $decoder['metaconsoleId'];
}
if (isset($decoder['id_module_'.$this->cellId]) === true) {
$values['moduleId'] = $decoder['id_module_'.$this->cellId];
}
if (isset($decoder['moduleId']) === true) {
$values['moduleId'] = $decoder['moduleId'];
}
if (isset($decoder['size_text_'.$this->cellId]) === true) {
$values['sizeLabel'] = $decoder['size_text_'.$this->cellId];
}
if (isset($decoder['sizeLabel']) === true) {
$values['sizeLabel'] = $decoder['sizeLabel'];
}
if (isset($decoder['separator_data_'.$this->cellId]) === true) {
$values['separator'] = $decoder['separator_data_'.$this->cellId];
}
if (isset($decoder['separator']) === true) {
$values['separator'] = $decoder['separator'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*

View File

@ -109,6 +109,13 @@ class ModuleValueWidget extends Widget
*/
protected $gridWidth;
/**
* Cell ID.
*
* @var integer
*/
protected $cellId;
/**
* Construct.
@ -146,8 +153,11 @@ class ModuleValueWidget extends Widget
// Grid Width.
$this->gridWidth = $gridWidth;
// Cell Id.
$this->cellId = $cellId;
// Options.
$this->values = $this->getOptionsWidget();
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
@ -177,6 +187,67 @@ class ModuleValueWidget extends Widget
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['label_'.$this->cellId]) === true) {
$values['label'] = $decoder['label_'.$this->cellId];
}
if (isset($decoder['label']) === true) {
$values['label'] = $decoder['label'];
}
if (isset($decoder['id_agent_'.$this->cellId]) === true) {
$values['agentId'] = $decoder['id_agent_'.$this->cellId];
}
if (isset($decoder['agentId']) === true) {
$values['agentId'] = $decoder['agentId'];
}
if (isset($decoder['metaconsoleId']) === true) {
$values['metaconsoleId'] = $decoder['metaconsoleId'];
}
if (isset($decoder['id_module_'.$this->cellId]) === true) {
$values['moduleId'] = $decoder['id_module_'.$this->cellId];
}
if (isset($decoder['moduleId']) === true) {
$values['moduleId'] = $decoder['moduleId'];
}
if (isset($decoder['size_value_'.$this->cellId]) === true) {
$values['sizeValue'] = $decoder['size_value_'.$this->cellId];
}
if (isset($decoder['sizeValue']) === true) {
$values['sizeValue'] = $decoder['sizeValue'];
}
if (isset($decoder['size_label_'.$this->cellId]) === true) {
$values['sizeLabel'] = $decoder['size_label_'.$this->cellId];
}
if (isset($decoder['sizeLabel']) === true) {
$values['sizeLabel'] = $decoder['sizeLabel'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*

View File

@ -142,7 +142,7 @@ class MonitorHealthWidget extends Widget
$this->gridWidth = $gridWidth;
// Options.
$this->values = $this->getOptionsWidget();
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
@ -164,14 +164,28 @@ class MonitorHealthWidget extends Widget
// This forces at least a first configuration.
$this->configurationRequired = false;
if (isset($this->values['title']) === false) {
$this->configurationRequired = true;
}
$this->overflow_scrollbars = false;
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
return $values;
}
/**
* Generates inputs for form (specific).
*
@ -234,8 +248,11 @@ class MonitorHealthWidget extends Widget
$data['mW'] = (int) $all_data['_monitors_warning_'];
$data['mC'] = (int) $all_data['_monitors_critical_'];
$data['mNN'] = (int) $all_data['_monitor_not_normal_'];
$data['monitor_not_normal'] = (int) $all_data['_monitor_not_normal_'];
$data['monitor_not_init'] = (int) $all_data['_monitors_not_init_'];
$data['monitor_alerts'] = (int) $all_data['_monitors_alerts_'];
$data['mAFired'] = (int) $all_data['_monitors_alerts_fired_'];
$data['monitor_alerts_fired'] = (int) $all_data['_monitors_alerts_fired_'];
$data['total_agents'] = (int) $all_data['_total_agents_'];

View File

@ -154,7 +154,7 @@ class NetworkMapWidget extends Widget
$this->gridWidth = $gridWidth;
// Options.
$this->values = $this->getOptionsWidget();
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
@ -184,6 +184,55 @@ class NetworkMapWidget extends Widget
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['networkmaps']) === true) {
$values['networkmapId'] = $decoder['networkmaps'];
}
if (isset($decoder['networkmapId']) === true) {
$values['networkmapId'] = $decoder['networkmapId'];
}
if (isset($decoder['map_translate_x']) === true) {
$values['xOffset'] = $decoder['map_translate_x'];
}
if (isset($decoder['xOffset']) === true) {
$values['xOffset'] = $decoder['xOffset'];
}
if (isset($decoder['map_translate_y']) === true) {
$values['yOffset'] = $decoder['map_translate_y'];
}
if (isset($decoder['yOffset']) === true) {
$values['yOffset'] = $decoder['yOffset'];
}
if (isset($decoder['zoom_level_dash']) === true) {
$values['zoomLevel'] = $decoder['zoom_level_dash'];
}
if (isset($decoder['zoomLevel']) === true) {
$values['zoomLevel'] = $decoder['zoomLevel'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*

View File

@ -142,7 +142,7 @@ class PostWidget extends Widget
$this->gridWidth = $gridWidth;
// Options.
$this->values = $this->getOptionsWidget();
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
@ -172,6 +172,31 @@ class PostWidget extends Widget
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['textit']) === true) {
$values['text'] = $decoder['textit'];
}
if (isset($decoder['text']) === true) {
$values['text'] = $decoder['text'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*

View File

@ -148,7 +148,7 @@ class ReportsWidget extends Widget
$this->gridWidth = $gridWidth;
// Options.
$this->values = $this->getOptionsWidget();
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
@ -178,6 +178,31 @@ class ReportsWidget extends Widget
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['id_report']) === true) {
$values['reportId'] = $decoder['id_report'];
}
if (isset($decoder['reportId']) === true) {
$values['reportId'] = $decoder['reportId'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*

View File

@ -146,7 +146,7 @@ class ServiceMapWidget extends Widget
$this->gridWidth = $gridWidth;
// Options.
$this->values = $this->getOptionsWidget();
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
@ -176,6 +176,39 @@ class ServiceMapWidget extends Widget
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['service_id']) === true) {
$values['serviceId'] = $decoder['service_id'];
}
if (isset($decoder['serviceId']) === true) {
$values['serviceId'] = $decoder['serviceId'];
}
if (isset($decoder['show_legend']) === true) {
$values['showLegend'] = (int) $decoder['show_legend'];
}
if (isset($decoder['showLegend']) === true) {
$values['showLegend'] = $decoder['showLegend'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*

View File

@ -106,6 +106,13 @@ class SingleGraphWidget extends Widget
*/
protected $gridWidth;
/**
* Cell ID.
*
* @var integer
*/
protected $cellId;
/**
* Construct.
@ -143,8 +150,11 @@ class SingleGraphWidget extends Widget
// Grid Width.
$this->gridWidth = $gridWidth;
// Cell Id.
$this->cellId = $cellId;
// Options.
$this->values = $this->getOptionsWidget();
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
@ -174,6 +184,55 @@ class SingleGraphWidget extends Widget
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['id_agent_'.$this->cellId]) === true) {
$values['agentId'] = $decoder['id_agent_'.$this->cellId];
}
if (isset($decoder['agentId']) === true) {
$values['agentId'] = $decoder['agentId'];
}
if (isset($decoder['metaconsoleId']) === true) {
$values['metaconsoleId'] = $decoder['metaconsoleId'];
}
if (isset($decoder['id_module_'.$this->cellId]) === true) {
$values['moduleId'] = $decoder['id_module_'.$this->cellId];
}
if (isset($decoder['moduleId']) === true) {
$values['moduleId'] = $decoder['moduleId'];
}
if (isset($decoder['period']) === true) {
$values['period'] = $decoder['period'];
}
if (isset($decoder['show_full_legend']) === true) {
$values['showLegend'] = $decoder['show_full_legend'];
}
if (isset($decoder['showLegend']) === true) {
$values['showLegend'] = $decoder['showLegend'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*

View File

@ -110,6 +110,13 @@ class SLAPercentWidget extends Widget
*/
protected $gridWidth;
/**
* Cell ID.
*
* @var integer
*/
protected $cellId;
/**
* Construct.
@ -147,8 +154,11 @@ class SLAPercentWidget extends Widget
// Grid Width.
$this->gridWidth = $gridWidth;
// Cell Id.
$this->cellId = $cellId;
// Options.
$this->values = $this->getOptionsWidget();
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
@ -178,6 +188,71 @@ class SLAPercentWidget extends Widget
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['label_'.$this->cellId]) === true) {
$values['label'] = $decoder['label_'.$this->cellId];
}
if (isset($decoder['label']) === true) {
$values['label'] = $decoder['label'];
}
if (isset($decoder['id_agent_'.$this->cellId]) === true) {
$values['agentId'] = $decoder['id_agent_'.$this->cellId];
}
if (isset($decoder['agentId']) === true) {
$values['agentId'] = $decoder['agentId'];
}
if (isset($decoder['metaconsoleId']) === true) {
$values['metaconsoleId'] = $decoder['metaconsoleId'];
}
if (isset($decoder['id_module_'.$this->cellId]) === true) {
$values['moduleId'] = $decoder['id_module_'.$this->cellId];
}
if (isset($decoder['moduleId']) === true) {
$values['moduleId'] = $decoder['moduleId'];
}
if (isset($decoder['size_value_'.$this->cellId]) === true) {
$values['sizeValue'] = $decoder['size_value_'.$this->cellId];
}
if (isset($decoder['sizeValue']) === true) {
$values['sizeValue'] = $decoder['sizeValue'];
}
if (isset($decoder['size_label_'.$this->cellId]) === true) {
$values['sizeLabel'] = $decoder['size_label_'.$this->cellId];
}
if (isset($decoder['sizeLabel']) === true) {
$values['sizeLabel'] = $decoder['sizeLabel'];
}
if (isset($decoder['period']) === true) {
$values['period'] = $decoder['period'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*
@ -387,7 +462,7 @@ class SLAPercentWidget extends Widget
if (empty($label) === false) {
// Div Label.
$output .= '<div style="flex: 1 1; font-size:'.$sizeLabel.'px;">'.$label.'</div>';
$output .= '<div style="flex: 1 1; font-size:'.$sizeLabel.'px; text-align: left;">'.$label.'</div>';
}
$output .= '</div>';

View File

@ -142,7 +142,7 @@ class SystemGroupStatusWidget extends Widget
$this->gridWidth = $gridWidth;
// Options.
$this->values = $this->getOptionsWidget();
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
@ -164,14 +164,80 @@ class SystemGroupStatusWidget extends Widget
// This forces at least a first configuration.
$this->configurationRequired = false;
if (empty($this->values['groupId']) === true) {
$this->configurationRequired = true;
}
$this->overflow_scrollbars = false;
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['status']) === true) {
if (is_array($decoder['status']) === true) {
$compatibilityStatus = [];
foreach ($decoder['status'] as $key => $value) {
switch ((int) $value) {
case 2:
$compatibilityStatus[] = AGENT_STATUS_WARNING;
break;
case 3:
$compatibilityStatus[] = AGENT_STATUS_CRITICAL;
break;
case 4:
$compatibilityStatus[] = 4;
break;
default:
case 1:
$compatibilityStatus[] = AGENT_STATUS_NORMAL;
break;
}
}
$decoder['status'][0] = implode(',', $compatibilityStatus);
}
$values['status'] = $decoder['status'];
} else {
$values['status'][0] = implode(
',',
[
AGENT_STATUS_NORMAL,
AGENT_STATUS_WARNING,
AGENT_STATUS_CRITICAL,
4,
]
);
}
if (isset($decoder['id_groups']) === true) {
if (is_array($decoder['id_groups']) === true) {
$decoder['id_groups'][0] = implode(',', $decoder['id_groups']);
}
$values['groupId'] = $decoder['id_groups'];
}
if (isset($decoder['groupId']) === true) {
$values['groupId'] = $decoder['groupId'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*
@ -186,6 +252,19 @@ class SystemGroupStatusWidget extends Widget
// Retrieve global - common inputs.
$inputs = parent::getFormInputs();
// Default values.
if (isset($values['status']) === false) {
$values['status'][0] = implode(
',',
[
AGENT_STATUS_NORMAL,
AGENT_STATUS_WARNING,
AGENT_STATUS_CRITICAL,
4,
]
);
}
// Restrict access to group.
$inputs[] = [
'label' => __('Groups'),
@ -439,7 +518,7 @@ class SystemGroupStatusWidget extends Widget
}
}
$height = (count($table->data) * 30);
$height = (count($table->data) * 32);
$style = 'min-width:200px; min-height:'.$height.'px;';
$output = '<div class="container-center" style="'.$style.'">';
if ($flag_groups === true) {

View File

@ -160,7 +160,7 @@ class TacticalWidget extends Widget
$this->pmAccess = \users_can_manage_group_all('PM');
// Options.
$this->values = $this->getOptionsWidget();
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
@ -193,6 +193,43 @@ class TacticalWidget extends Widget
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['statusmonitors']) === true) {
$values['statusMonitor'] = $decoder['statusmonitors'];
}
if (isset($decoder['statusMonitor']) === true) {
$values['statusMonitor'] = $decoder['statusMonitor'];
}
if (isset($decoder['serverperf']) === true) {
$values['serverPerformance'] = $decoder['serverperf'];
}
if (isset($decoder['serverPerformance']) === true) {
$values['serverPerformance'] = $decoder['serverPerformance'];
}
if (isset($decoder['summary']) === true) {
$values['summary'] = $decoder['summary'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*
@ -366,7 +403,7 @@ class TacticalWidget extends Widget
);
}
if ($this->values['statusMonitor'] === 1) {
if ((int) $this->values['statusMonitor'] === 1) {
$table = new \stdClass();
$table->width = '100%';
@ -396,7 +433,7 @@ class TacticalWidget extends Widget
$output .= \html_print_table($table, true);
}
if ($this->values['serverPerformance'] === 1
if ((int) $this->values['serverPerformance'] === 1
&& $this->pmAccess === true
) {
$table = new \stdClass();
@ -414,7 +451,7 @@ class TacticalWidget extends Widget
$output .= \html_print_table($table, true);
}
if ($this->values['summary'] === 1) {
if ((int) $this->values['summary'] === 1) {
$table = new \stdClass();
$table->width = '100%';
$table->class = '';

View File

@ -375,7 +375,7 @@ class TopNWidget extends Widget
}
// This function check ACL.
$agents = agents_get_group_agents(0, ['aliasRegex' => $agentRegex]);
$agents = @agents_get_group_agents(0, ['aliasRegex' => $agentRegex]);
$agentsId = \array_keys($agents);
$agentsIdString = \implode(',', $agentsId);
@ -414,7 +414,7 @@ class TopNWidget extends Widget
$quantity
);
$modules = \db_get_all_rows_sql(
$modules = @db_get_all_rows_sql(
$sql,
$search_in_history_db
);
@ -422,7 +422,7 @@ class TopNWidget extends Widget
if (empty($modules) === true) {
$output .= '<div class="container-center">';
$output .= \ui_print_info_message(
__('There are no Agent/Modules defined'),
__('There are no agents/modules found matching filter set'),
'',
true
);

View File

@ -147,7 +147,7 @@ class TopNEventByGroupWidget extends Widget
$this->gridWidth = $gridWidth;
// Options.
$this->values = $this->getOptionsWidget();
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
@ -177,6 +177,59 @@ class TopNEventByGroupWidget extends Widget
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['amount']) === true) {
$values['amountShow'] = $decoder['amount'];
}
if (isset($decoder['amountShow']) === true) {
$values['amountShow'] = $decoder['amountShow'];
}
if (isset($decoder['event_view_hr']) === true) {
$values['maxHours'] = $decoder['event_view_hr'];
}
if (isset($decoder['maxHours']) === true) {
$values['maxHours'] = $decoder['maxHours'];
}
if (isset($decoder['id_groups']) === true) {
if (is_array($decoder['id_groups']) === true) {
$implode = implode(',', $decoder['id_groups']);
$values['groupId'] = [];
$values['groupId'][0] = $implode;
}
}
if (isset($decoder['groupId']) === true) {
$values['groupId'] = $decoder['groupId'];
}
if (isset($decoder['legend_position']) === true) {
$values['legendPosition'] = $decoder['legend_position'];
}
if (isset($decoder['legendPosition']) === true) {
$values['legendPosition'] = $decoder['legendPosition'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*
@ -320,8 +373,8 @@ class TopNEventByGroupWidget extends Widget
GROUP BY id_agente
ORDER BY count DESC
LIMIT %d',
implode(',', $this->values['groupId']),
$timestamp,
implode(',', $this->values['groupId']),
$this->values['amountShow']
);
} else {

View File

@ -147,7 +147,7 @@ class TopNEventByModuleWidget extends Widget
$this->gridWidth = $gridWidth;
// Options.
$this->values = $this->getOptionsWidget();
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
@ -177,6 +177,59 @@ class TopNEventByModuleWidget extends Widget
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['amount']) === true) {
$values['amountShow'] = $decoder['amount'];
}
if (isset($decoder['amountShow']) === true) {
$values['amountShow'] = $decoder['amountShow'];
}
if (isset($decoder['event_view_hr']) === true) {
$values['maxHours'] = $decoder['event_view_hr'];
}
if (isset($decoder['maxHours']) === true) {
$values['maxHours'] = $decoder['maxHours'];
}
if (isset($decoder['id_groups']) === true) {
if (is_array($decoder['id_groups']) === true) {
$decoder['id_groups'][0] = implode(',', $decoder['id_groups']);
}
$values['groupId'] = $decoder['id_groups'];
}
if (isset($decoder['groupId']) === true) {
$values['groupId'] = $decoder['groupId'];
}
if (isset($decoder['legend_position']) === true) {
$values['legendPosition'] = $decoder['legend_position'];
}
if (isset($decoder['legendPosition']) === true) {
$values['legendPosition'] = $decoder['legendPosition'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*
@ -311,20 +364,26 @@ class TopNEventByModuleWidget extends Widget
if ($all_group === false) {
$sql = sprintf(
'SELECT id_agentmodule, COUNT(*) AS count
'SELECT id_agente,
id_agentmodule,
event_type,
COUNT(*) AS count
FROM tevento
WHERE utimestamp >= %d
AND id_grupo IN (%s)
GROUP BY id_agentmodule, event_type
ORDER BY count DESC
LIMIT %d',
implode(',', $this->values['groupId']),
$timestamp,
implode(',', $this->values['groupId']),
$this->values['amountShow']
);
} else {
$sql = sprintf(
'SELECT id_agentmodule, COUNT(*) AS count
'SELECT id_agente,
id_agentmodule,
event_type,
COUNT(*) AS count
FROM tevento
WHERE utimestamp >= %d
GROUP BY id_agentmodule, event_type
@ -353,8 +412,9 @@ class TopNEventByModuleWidget extends Widget
$name = __('System');
} else {
$name_agent = io_safe_output(
agents_get_alias($row['id_agentmodule'])
agents_get_alias($row['id_agente'])
);
$name_module = io_safe_output(
modules_get_agentmodule_name($row['id_agentmodule'])
);

View File

@ -155,7 +155,7 @@ class TreeViewWidget extends Widget
$this->cellId = $cellId;
// Options.
$this->values = $this->getOptionsWidget();
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
@ -177,14 +177,136 @@ class TreeViewWidget extends Widget
// This forces at least a first configuration.
$this->configurationRequired = false;
if (isset($this->values['groupId']) === false) {
$this->configurationRequired = true;
}
$this->overflow_scrollbars = false;
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['tab']) === true) {
$values['typeTree'] = $decoder['tab'];
}
if (isset($decoder['typeTree']) === true) {
$values['typeTree'] = $decoder['typeTree'];
}
if (isset($decoder['search_group']) === true) {
$values['groupId'] = $decoder['search_group'];
}
if (isset($decoder['groupId']) === true) {
$values['groupId'] = $decoder['groupId'];
}
if (isset($decoder['open_all_nodes']) === true) {
$values['openAllGroups'] = $decoder['open_all_nodes'];
}
if (isset($decoder['openAllGroups']) === true) {
$values['openAllGroups'] = $decoder['openAllGroups'];
}
if (isset($decoder['status_agent']) === true) {
switch ((int) $decoder['status_agent']) {
case 0:
$values['agentStatus'] = AGENT_STATUS_NORMAL;
break;
case 1:
$values['agentStatus'] = AGENT_STATUS_CRITICAL;
break;
case 2:
$values['agentStatus'] = AGENT_STATUS_WARNING;
break;
case 3:
$values['agentStatus'] = AGENT_STATUS_UNKNOWN;
break;
case 5:
$values['agentStatus'] = AGENT_STATUS_NOT_INIT;
break;
default:
case -1:
$values['agentStatus'] = AGENT_STATUS_ALL;
break;
}
}
if (isset($decoder['agentStatus']) === true) {
$values['agentStatus'] = $decoder['agentStatus'];
}
if (isset($decoder['search_agent']) === true) {
$values['filterAgent'] = $decoder['search_agent'];
}
if (isset($decoder['filterAgent']) === true) {
$values['filterAgent'] = $decoder['filterAgent'];
}
if (isset($decoder['status_module']) === true) {
switch ((int) $decoder['status_module']) {
case 0:
$values['moduleStatus'] = AGENT_MODULE_STATUS_NORMAL;
break;
case 1:
$values['moduleStatus'] = AGENT_MODULE_STATUS_CRITICAL_BAD;
break;
case 2:
$values['moduleStatus'] = AGENT_MODULE_STATUS_WARNING;
break;
case 3:
$values['moduleStatus'] = AGENT_MODULE_STATUS_UNKNOWN;
break;
case 5:
$values['moduleStatus'] = AGENT_MODULE_STATUS_NOT_INIT;
break;
default:
case -1:
$values['moduleStatus'] = -1;
break;
}
$values['moduleStatus'] = $decoder['status_module'];
}
if (isset($decoder['moduleStatus']) === true) {
$values['moduleStatus'] = $decoder['moduleStatus'];
}
if (isset($decoder['search_module']) === true) {
$values['filterModule'] = $decoder['search_module'];
}
if (isset($decoder['filterModule']) === true) {
$values['filterModule'] = $decoder['filterModule'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*

View File

@ -142,7 +142,7 @@ class UrlWidget extends Widget
$this->gridWidth = $gridWidth;
// Options.
$this->values = $this->getOptionsWidget();
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
@ -172,6 +172,31 @@ class UrlWidget extends Widget
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
if (isset($decoder['url']) === true) {
$values['urlText'] = $decoder['url'];
}
if (isset($decoder['urlText']) === true) {
$values['urlText'] = $decoder['urlText'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*

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