Merge branch 'develop' into 'ent-6102-edicion-nombre-sincronizacion-alertas-metaconsola'

# Conflicts:
#   pandora_console/extras/mr/40.sql
#   pandora_console/godmode/alerts/configure_alert_template.php
This commit is contained in:
José González 2020-08-07 13:17:41 +02:00
commit 85d8e1f796
145 changed files with 64201 additions and 61373 deletions

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.747, AIX version
# Version 7.0NG.748, 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.747, FreeBSD Version
# Version 7.0NG.748, 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.747, HP-UX Version
# Version 7.0NG.748, 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.747, GNU/Linux
# Version 7.0NG.748, 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.747, GNU/Linux
# Version 7.0NG.748, 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.747, Solaris Version
# Version 7.0NG.748, 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.747
# Version 7.0NG.748
# 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.747, AIX version
# Version 7.0NG.748, 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.747
# Version 7.0NG.748
# 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.747, HPUX Version
# Version 7.0NG.748, HPUX Version
# General Parameters
# ==================

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.747
# Version 7.0NG.748
# 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.747
# Version 7.0NG.748
# 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.747
# Version 7.0NG.748
# 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.747, Solaris version
# Version 7.0NG.748, Solaris version
# General Parameters
# ==================

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.747, AIX version
# Version 7.0NG.748, 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.747-200710
Version: 7.0NG.748-200807
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.747-200710"
pandora_version="7.0NG.748-200807"
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.747, GNU/Linux
# Version 7.0NG.748, 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.747, FreeBSD Version
# Version 7.0NG.748, 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.747, HP-UX Version
# Version 7.0NG.748, 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.747, GNU/Linux
# Version 7.0NG.748, 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.747, GNU/Linux
# Version 7.0NG.748, 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.747, NetBSD Version
# Version 7.0NG.748, 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.747, Solaris Version
# Version 7.0NG.748, 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.747';
use constant AGENT_BUILD => '200710';
use constant AGENT_VERSION => '7.0NG.748';
use constant AGENT_BUILD => '200807';
# 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.747
%define release 200710
%define version 7.0NG.748
%define release 200807
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.747
%define release 200710
%define version 7.0NG.748
%define release 200807
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.747"
PI_BUILD="200710"
PI_VERSION="7.0NG.748"
PI_BUILD="200807"
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.747
# Version 7.0NG.748
# 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,7 +3,7 @@ AllowLanguageSelection
{Yes}
AppName
{Pandora FMS Windows Agent v7.0NG.747}
{Pandora FMS Windows Agent v7.0NG.748}
ApplicationID
{17E3D2CF-CA02-406B-8A80-9D31C17BD08F}
@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{200710}
{200807}
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.747(Build 200710)")
#define PANDORA_VERSION ("7.0NG.748(Build 200807)")
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.747(Build 200710))"
VALUE "ProductVersion", "(7.0NG.748(Build 200807))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 7.0NG.747-200710
Version: 7.0NG.748-200807
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.747-200710"
pandora_version="7.0NG.748-200807"
package_pear=0
package_pandora=1

View File

@ -41,7 +41,9 @@ if (__PAN_XHPROF__ === 1) {
}
}
if ((! file_exists('include/config.php')) || (! is_readable('include/config.php'))) {
if ((! file_exists('include/config.php'))
|| (! is_readable('include/config.php'))
) {
exit;
}
@ -52,7 +54,9 @@ require_once 'include/functions.php';
require_once 'include/functions_db.php';
require_once 'include/auth/mysql.php';
if (isset($config['console_log_enabled']) && $config['console_log_enabled'] == 1) {
if (isset($config['console_log_enabled']) === true
&& $config['console_log_enabled'] == 1
) {
ini_set('log_errors', 1);
ini_set('error_log', $config['homedir'].'/log/console.log');
} else {
@ -60,14 +64,15 @@ if (isset($config['console_log_enabled']) && $config['console_log_enabled'] == 1
ini_set('error_log', 0);
}
// Hash login process
if (isset($_GET['loginhash'])) {
// Hash login process.
if (isset($_GET['loginhash']) === true) {
$loginhash_data = get_parameter('loginhash_data', '');
$loginhash_user = str_rot13(get_parameter('loginhash_user', ''));
if ($config['loginhash_pwd'] != ''
&& $loginhash_data == md5($loginhash_user.io_output_password($config['loginhash_pwd']))
&& $loginhash_data == md5(
$loginhash_user.io_output_password($config['loginhash_pwd'])
)
) {
db_logon($loginhash_user, $_SERVER['REMOTE_ADDR']);
$_SESSION['id_usuario'] = $loginhash_user;
@ -76,14 +81,38 @@ if (isset($_GET['loginhash'])) {
include_once 'general/login_page.php';
db_pandora_audit('Logon Failed (loginhash', '', 'system');
while (@ob_end_flush()) {
// Dumping...
continue;
}
exit('</html>');
}
}
$auth_class = io_safe_output(
get_parameter('auth_class', 'PandoraFMS\Dashboard\Manager')
);
$public_hash = get_parameter('auth_hash', false);
$public_login = false;
// Check user.
check_login();
if (class_exists($auth_class) === false || $public_hash === false) {
check_login();
} else {
if ($auth_class::validatePublicHash($public_hash) === false) {
db_pandora_audit(
'Invalid public hash',
'Trying to access public dashboard'
);
include 'general/noaccess.php';
exit;
}
// OK. Simulated user log in. If you want to use your own auth_class
// remember to set $config['force_instant_logout'] to true to avoid
// persistent user login.
}
ob_start();
// Enterprise support.
if (file_exists(ENTERPRISE_DIR.'/load_enterprise.php')) {
@ -98,7 +127,10 @@ $page .= '.php';
$config['id_user'] = $_SESSION['id_usuario'];
$isFunctionSkins = enterprise_include_once('include/functions_skins.php');
if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) {
$config['relative_path'] = enterprise_hook('skins_set_image_skin_path', [$config['id_user']]);
$config['relative_path'] = enterprise_hook(
'skins_set_image_skin_path',
[$config['id_user']]
);
}
if (is_metaconsole()) {
@ -115,3 +147,29 @@ if (file_exists($page)) {
if (__PAN_XHPROF__ === 1) {
pandora_xhprof_display_result('ajax', 'console');
}
if ($config['force_instant_logout'] === true) {
// Force user logout.
if (session_status() !== PHP_SESSION_ACTIVE) {
session_start();
}
$iduser = $_SESSION['id_usuario'];
$_SESSION = [];
session_destroy();
header_remove('Set-Cookie');
setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/');
if ($config['auth'] == 'saml') {
include_once $config['saml_path'].'simplesamlphp/lib/_autoload.php';
$as = new SimpleSAML_Auth_Simple('PandoraFMS');
$as->logout();
}
}
while (@ob_end_flush()) {
// Dumping...
continue;
}

View File

@ -6,8 +6,11 @@ ALTER TABLE `talert_commands` ADD COLUMN `previous_name` text;
ALTER TABLE `ttag` ADD COLUMN `previous_name` text default '';
ALTER TABLE `tconfig_os` ADD COLUMN `previous_name` text default '';
UPDATE `talert_commands` SET name='Monitoring&#x20;Event' WHERE name='Pandora FMS Event';
ALTER TABLE `tservice_element` ADD COLUMN `rules` text;
ALTER TABLE `tservice` ADD COLUMN `unknown_as_critical` tinyint(1) NOT NULL default 0 AFTER `warning`;
ALTER TABLE `tserver` MODIFY COLUMN `version` varchar(25) NOT NULL DEFAULT '';
UPDATE `tservice` SET `auto_calculate`=0;
UPDATE `tservice` SET `cps`= `cps` - 1 WHERE `cps` > 0;

View File

@ -1271,6 +1271,7 @@ ALTER TABLE talert_snmp_action ADD COLUMN `al_field15` TEXT NOT NULL DEFAULT "";
-- ----------------------------------------------------------------------
ALTER TABLE tserver ADD COLUMN `server_keepalive` int(11) DEFAULT 0;
ALTER TABLE `tserver` MODIFY COLUMN `server_keepalive` int(11) NOT NULL DEFAULT '0';
ALTER TABLE `tserver` MODIFY COLUMN `version` varchar(25) NOT NULL DEFAULT '';
-- ----------------------------------------------------------------------
-- Table `tagente_estado`

View File

@ -165,7 +165,12 @@ if (check_login()) {
break;
case 'monitorcheckmodal':
echo __('This system has too many modules per agent. OpenSource version could manage thousands of modules, but is not recommended to have more than 40 modules per agent. This configuration has B/A modules per agent. Checkout the Enterprise Version for a professional supported system.');
// Get agent/module average.
$agentCount = db_get_value_sql('SELECT count(*) FROM tagente');
$modulesCount = db_get_value_sql('SELECT count(*) FROM tagente_modulo');
$average = ($modulesCount / $agentCount);
echo __('This system has too many modules per agent. OpenSource version could manage thousands of modules, but is not recommended to have more than 100 modules per agent. This configuration has %d modules per agent. Checkout the Enterprise Version for a professional supported system.', $average);
break;
case 'remotemodulesmodal':

View File

@ -106,7 +106,7 @@ img.modalclose {
<span class='modalheadertex'>
<?php echo __('Database error'); ?>
</span>
<img class='modalclose' src='<?php echo $config['homeurl']; ?>images/icono_cerrar.png'>
<img class='modalclose' src='<?php echo $config['homeurl']; ?>/images/icono_cerrar.png'>
</div>
<div class='modalconten'>

View File

@ -24,7 +24,16 @@ require_once $config['homedir'].'/include/functions_modules.php';
require_once $config['homedir'].'/include/functions_agents.php';
require_once $config['homedir'].'/include/functions_servers.php';
$search_string = io_safe_output(urldecode(trim(get_parameter('search_string', ''))));
$search_string = io_safe_output(
urldecode(
trim(
get_parameter(
'search_string',
''
)
)
)
);
global $policy_page;
@ -32,17 +41,27 @@ if (!isset($policy_page)) {
$policy_page = false;
}
// Search string filter form
echo '<form id="create_module_type" method="post" action="'.$url.'">';
echo '<table width="100%" cellpadding="2" cellspacing="2" class="databox filters" >';
echo "<tr><td class='datos' style='width:20%; font-weight: bold;'>";
echo __('Search').' '.html_print_input_text(
'search_string',
$search_string,
'',
15,
255,
true
);
html_print_input_hidden('search', 1);
// Search string filter form.
if (($policy_page) || (isset($agent))) {
echo '<form id="" method="post" action="">';
} else {
echo '<form id="create_module_type" method="post" action="'.$url.'">';
}
echo '<table width="100%" cellpadding="2" cellspacing="2" class="databox filters" >';
echo "<tr><td class='datos' style='width:20%; font-weight: bold;'>";
echo __('Search').' '.html_print_input_text('search_string', $search_string, '', 15, 255, true);
html_print_input_hidden('search', 1);
echo '</td>';
echo "<td class='datos' style='width:10%'>";
html_print_submit_button(__('Filter'), 'filter', false, 'class="sub search"');
@ -50,38 +69,38 @@ echo '</td>';
echo "<td class='datos' style='width:10%'></td>";
echo '</form>';
// Check if there is at least one server of each type available to assign that
// kind of modules. If not, do not show server type in combo
// kind of modules. If not, do not show server type in combo.
$network_available = db_get_sql(
'SELECT count(*)
FROM tserver
WHERE server_type = 1'
);
// POSTGRESQL AND ORACLE COMPATIBLE
// POSTGRESQL AND ORACLE COMPATIBLE.
$wmi_available = db_get_sql(
'SELECT count(*)
FROM tserver
WHERE server_type = 6'
);
// POSTGRESQL AND ORACLE COMPATIBLE
// POSTGRESQL AND ORACLE COMPATIBLE.
$plugin_available = db_get_sql(
'SELECT count(*)
FROM tserver
WHERE server_type = 4'
);
// POSTGRESQL AND ORACLE COMPATIBLE
// POSTGRESQL AND ORACLE COMPATIBLE.
$prediction_available = db_get_sql(
'SELECT count(*)
FROM tserver
WHERE server_type = 5'
);
// POSTGRESQL AND ORACLE COMPATIBLE
// Development mode to use all servers
// POSTGRESQL AND ORACLE COMPATIBLE.
// Development mode to use all servers.
if ($develop_bypass || is_metaconsole()) {
$network_available = 1;
$wmi_available = 1;
$plugin_available = 1;
// FIXME when prediction predictions server modules can be configured
// on metaconsole
// FIXME when prediction predictions server modules can be configured.
// on metaconsole.
$prediction_available = is_metaconsole() ? 0 : 1;
}
@ -140,7 +159,7 @@ if (($policy_page) || (isset($agent))) {
}
if ($show_creation) {
// Create module/type combo
// Create module/type combo.
echo '<form id="create_module_type" method="post" action="'.$url.'">';
if (!$policy_page) {
echo '<td class="datos" style="font-weight: bold; width:20%;">';
@ -151,13 +170,33 @@ if (($policy_page) || (isset($agent))) {
$checked = false;
}
html_print_checkbox('status_hierachy_mode', '', $checked, false, false, 'onChange=change_mod_filter();');
html_print_checkbox(
'status_hierachy_mode',
'',
$checked,
false,
false,
'onChange=change_mod_filter();'
);
echo '</td>';
}
echo '<td class="datos" style="font-weight: bold; width:20%;">';
echo __('<p>Type</p>');
html_print_select($modules, 'moduletype', '', '', '', '', false, false, false, '', false, 'max-width:300px;');
html_print_select(
$modules,
'moduletype',
'',
'',
'',
'',
false,
false,
false,
'',
false,
'max-width:300px;'
);
html_print_input_hidden('edit_module', 1);
echo '</td>';
echo '<td class="datos" style="width:10%;">';
@ -212,7 +251,13 @@ if ($multiple_delete) {
}
enterprise_include_once('include/functions_config_agents.php');
enterprise_hook('config_agents_delete_module_in_conf', [modules_get_agentmodule_agent($id_agent_module_del), modules_get_agentmodule_name($id_agent_module_del)]);
enterprise_hook(
'config_agents_delete_module_in_conf',
[
modules_get_agentmodule_agent($id_agent_module_del),
modules_get_agentmodule_name($id_agent_module_del),
]
);
$error = 0;
@ -220,7 +265,12 @@ if ($multiple_delete) {
// error. NOTICE that we don't delete all data here, just marking for deletion
// and delete some simple data.
$status = '';
$agent_id_of_module = db_get_value('id_agente', 'tagente_modulo', 'id_agente_modulo', (int) $id_agent_module_del);
$agent_id_of_module = db_get_value(
'id_agente',
'tagente_modulo',
'id_agente_modulo',
(int) $id_agent_module_del
);
if (db_process_sql(
"UPDATE tagente_modulo
@ -235,7 +285,7 @@ if ($multiple_delete) {
) {
$error++;
} else {
// Set flag to update module status count
// Set flag to update module status count.
if ($agent_id_of_module !== false) {
db_process_sql(
'UPDATE tagente
@ -286,32 +336,48 @@ if ($multiple_delete) {
break;
}
// Trick to detect if we are deleting a synthetic module (avg or arithmetic)
// If result is empty then module doesn't have this type of submodules
$ops_json = enterprise_hook('modules_get_synthetic_operations', [$id_agent_module_del]);
// Trick to detect if we are deleting a synthetic module (avg or arithmetic).
// If result is empty then module doesn't have this type of submodules.
$ops_json = enterprise_hook(
'modules_get_synthetic_operations',
[$id_agent_module_del]
);
$result_ops_synthetic = json_decode($ops_json);
if (!empty($result_ops_synthetic)) {
$result = enterprise_hook('modules_delete_synthetic_operations', [$id_agent_module_del]);
$result = enterprise_hook(
'modules_delete_synthetic_operations',
[$id_agent_module_del]
);
if ($result === false) {
$error++;
}
} //end if
else {
$result_components = enterprise_hook('modules_get_synthetic_components', [$id_agent_module_del]);
} else {
$result_components = enterprise_hook(
'modules_get_synthetic_components',
[$id_agent_module_del]
);
$count_components = 1;
if (!empty($result_components)) {
// Get number of components pending to delete to know when it's needed to update orders
// Get number of components pending to delete to know when it's needed to update orders.
$num_components = count($result_components);
$last_target_module = 0;
foreach ($result_components as $id_target_module) {
// Detects change of component or last component to update orders
if (($count_components == $num_components) or ($last_target_module != $id_target_module)) {
// Detects change of component or last component to update orders.
if (($count_components == $num_components) || ($last_target_module != $id_target_module)
) {
$update_orders = true;
} else {
$update_orders = false;
}
$result = enterprise_hook('modules_delete_synthetic_operations', [$id_target_module, $id_agent_module_del, $update_orders]);
$result = enterprise_hook(
'modules_delete_synthetic_operations',
[
$id_target_module,
$id_agent_module_del,
$update_orders,
]
);
if ($result === false) {
$error++;
}
@ -323,7 +389,7 @@ if ($multiple_delete) {
}
// Check for errors
// Check for errors.
if ($error != 0) {
} else {
$count_correct_delete_modules++;
@ -509,7 +575,7 @@ switch ($sortField) {
}
// Build the order sql
// Build the order sql.
if (!empty($order)) {
$order_sql = ' ORDER BY ';
}
@ -525,7 +591,7 @@ foreach ($order as $ord) {
$order_sql .= $ord['field'].' '.$ord['order'];
}
// Get limit and offset parameters
// Get limit and offset parameters.
$limit = (int) $config['block_size'];
$offset = (int) get_parameter('offset');
@ -559,9 +625,15 @@ $where = sprintf('delete_pending = 0 AND id_agente = %s', $id_agente);
$search_string_entities = io_safe_input($search_string);
$basic_where = sprintf("(nombre LIKE '%%%s%%' OR nombre LIKE '%%%s%%' OR descripcion LIKE '%%%s%%' OR descripcion LIKE '%%%s%%') AND", $search_string, $search_string_entities, $search_string, $search_string_entities);
$basic_where = sprintf(
"(nombre LIKE '%%%s%%' OR nombre LIKE '%%%s%%' OR descripcion LIKE '%%%s%%' OR descripcion LIKE '%%%s%%') AND",
$search_string,
$search_string_entities,
$search_string,
$search_string_entities
);
// Tags acl
// Tags acl.
$agent_tags = tags_get_user_applied_agent_tags($id_agente);
if ($agent_tags !== true) {
$where_tags = ' AND ttag_module.id_tag IN ('.implode(',', $agent_tags).')';
@ -619,7 +691,7 @@ if ($modules === false) {
return;
}
// Prepare pagination
// Prepare pagination.
$url = '?'.'sec=gagente&'.'tab=module&'.'sec2=godmode/agentes/configurar_agente&'.'id_agente='.$id_agente.'&'.'sort_field='.$sortField.'&'.'&sort='.$sort.'&'.'search_string='.urlencode($search_string);
if ($paginate_module) {
@ -635,17 +707,48 @@ $table = new stdClass();
$table->width = '100%';
$table->class = 'info_table';
$table->head = [];
$table->head['checkbox'] = html_print_checkbox('all_delete', 0, false, true, false);
$table->head[0] = __('Name').ui_get_sorting_arrows($url_name.'up', $url_name.'down', $selectNameUp, $selectNameDown);
$table->head['checkbox'] = html_print_checkbox(
'all_delete',
0,
false,
true,
false
);
$table->head[0] = __('Name').ui_get_sorting_arrows(
$url_name.'up',
$url_name.'down',
$selectNameUp,
$selectNameDown
);
// The access to the policy is granted only with AW permission
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK && check_acl($config['id_user'], $agent['id_grupo'], 'AW')) {
// The access to the policy is granted only with AW permission.
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK && check_acl(
$config['id_user'],
$agent['id_grupo'],
'AW'
)
) {
$table->head[1] = "<span title='".__('Policy')."'>".__('P.').'</span>';
}
$table->head[2] = "<span title='".__('Server')."'>".__('S.').'</span>'.ui_get_sorting_arrows($url_server.'up', $url_server.'down', $selectServerUp, $selectServerDown);
$table->head[3] = __('Type').ui_get_sorting_arrows($url_type.'up', $url_type.'down', $selectTypeUp, $selectTypeDown);
$table->head[4] = __('Interval').ui_get_sorting_arrows($url_interval.'up', $url_interval.'down', $selectIntervalUp, $selectIntervalDown);
$table->head[2] = "<span title='".__('Server')."'>".__('S.').'</span>'.ui_get_sorting_arrows(
$url_server.'up',
$url_server.'down',
$selectServerUp,
$selectServerDown
);
$table->head[3] = __('Type').ui_get_sorting_arrows(
$url_type.'up',
$url_type.'down',
$selectTypeUp,
$selectTypeDown
);
$table->head[4] = __('Interval').ui_get_sorting_arrows(
$url_interval.'up',
$url_interval.'down',
$selectIntervalUp,
$selectIntervalDown
);
$table->head[5] = __('Description');
$table->head[6] = __('Status');
$table->head[7] = __('Warn');
@ -690,7 +793,16 @@ if ($checked) {
}
foreach ($modules as $module) {
if (! check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') && ! check_acl_one_of_groups($config['id_user'], $all_groups, 'AD')) {
if (! check_acl_one_of_groups(
$config['id_user'],
$all_groups,
'AW'
) && ! check_acl_one_of_groups(
$config['id_user'],
$all_groups,
'AD'
)
) {
continue;
}
@ -712,7 +824,9 @@ foreach ($modules as $module) {
if (!$checked) {
if ($module['id_module_group'] != $last_modulegroup) {
$last_modulegroup = $module['id_module_group'];
$data[0] = '<strong>'.modules_get_modulegroup_name($last_modulegroup).'</strong>';
$data[0] = '<strong>'.modules_get_modulegroup_name(
$last_modulegroup
).'</strong>';
$i = array_push($table->data, $data);
$table->rowstyle[($i - 1)] = 'text-align: center';
$table->rowclass[($i - 1)] = 'datos3';
@ -727,14 +841,23 @@ foreach ($modules as $module) {
}
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) {
$data['checkbox'] = html_print_checkbox('id_delete[]', $module['id_agente_modulo'], false, true);
$data['checkbox'] = html_print_checkbox(
'id_delete[]',
$module['id_agente_modulo'],
false,
true
);
}
$data[0] = '';
if (isset($module['deep']) && ($module['deep'] != 0)) {
$data[0] .= str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $module['deep']);
$data[0] .= html_print_image('images/icono_escuadra.png', true, ['style' => 'padding-bottom: inherit;']).'&nbsp;&nbsp;';
$data[0] .= html_print_image(
'images/icono_escuadra.png',
true,
['style' => 'padding-bottom: inherit;']
).'&nbsp;&nbsp;';
}
if ($module['quiet']) {
@ -754,17 +877,38 @@ foreach ($modules as $module) {
}
if ($module['disabled']) {
$data[0] .= '<em class="disabled_module">'.ui_print_truncate_text($module['nombre'], 'module_medium', false, true, true, '[&hellip;]', 'font-size: 7.2pt').'</em>';
$data[0] .= '<em class="disabled_module">'.ui_print_truncate_text(
$module['nombre'],
'module_medium',
false,
true,
true,
'[&hellip;]',
'font-size: 7.2pt'
).'</em>';
} else {
$data[0] .= ui_print_truncate_text($module['nombre'], 'module_medium', false, true, true, '[&hellip;]', 'font-size: 7.2pt');
$data[0] .= ui_print_truncate_text(
$module['nombre'],
'module_medium',
false,
true,
true,
'[&hellip;]',
'font-size: 7.2pt'
);
}
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) {
$data[0] .= '</a>';
}
// The access to the policy is granted only with AW permission
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK && check_acl($config['id_user'], $agent['id_grupo'], 'AW')) {
// The access to the policy is granted only with AW permission.
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK && check_acl(
$config['id_user'],
$agent['id_grupo'],
'AW'
)
) {
$policyInfo = policies_info_module_policy($module['id_agente_modulo']);
if ($policyInfo === false) {
$data[1] = '';
@ -798,17 +942,27 @@ foreach ($modules as $module) {
}
}
// Module type (by server type )
// Module type (by server type ).
$data[2] = '';
if ($module['id_modulo'] > 0) {
$data[2] = servers_show_type($module['id_modulo']);
}
$module_status = db_get_row('tagente_estado', 'id_agente_modulo', $module['id_agente_modulo']);
$module_status = db_get_row(
'tagente_estado',
'id_agente_modulo',
$module['id_agente_modulo']
);
modules_get_status($module['id_agente_modulo'], $module_status['estado'], $module_status['datos'], $status, $title);
modules_get_status(
$module['id_agente_modulo'],
$module_status['estado'],
$module_status['datos'],
$status,
$title
);
// This module is initialized ? (has real data)
// This module is initialized ? (has real data).
if ($status == STATUS_MODULE_NO_DATA) {
$data[2] .= html_print_image(
'images/error.png',
@ -817,13 +971,13 @@ foreach ($modules as $module) {
);
}
// Module type (by data type)
// Module type (by data type).
$data[3] = '';
if ($type) {
$data[3] = ui_print_moduletype_icon($type, true);
}
// Module interval
// Module interval.
if ($module['module_interval']) {
$data[4] = human_time_description_raw($module['module_interval']);
} else {
@ -831,12 +985,23 @@ foreach ($modules as $module) {
}
if ($module['id_modulo'] == MODULE_DATA && $module['id_policy_module'] != 0) {
$data[4] .= ui_print_help_tip(__('The policy modules of data type will only update their intervals when policy is applied.'), true);
$data[4] .= ui_print_help_tip(
__('The policy modules of data type will only update their intervals when policy is applied.'),
true
);
}
$data[5] = ui_print_truncate_text($module['descripcion'], 'description', false);
$data[5] = ui_print_truncate_text(
$module['descripcion'],
'description',
false
);
$data[6] = ui_print_status_image($status, htmlspecialchars($title), true);
$data[6] = ui_print_status_image(
$status,
htmlspecialchars($title),
true
);
// MAX / MIN values.
if ($module['id_tipo_modulo'] != 25) {
@ -884,7 +1049,7 @@ foreach ($modules as $module) {
);
$data[8] .= '</a> ';
// Make a data normalization
// Make a data normalization.
if (isset($numericModules[$type])) {
if ($numericModules[$type] === true) {
$data[8] .= '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&tab=module&fix_module='.$module['id_agente_modulo'].'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
@ -904,7 +1069,7 @@ foreach ($modules as $module) {
$data[8] .= '&nbsp;&nbsp;';
}
// create network component action
// Create network component action.
if ((is_user_admin($config['id_user']))
&& ($module['id_modulo'] == MODULE_NETWORK)
) {
@ -927,7 +1092,7 @@ foreach ($modules as $module) {
}
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) {
// Delete module
// Delete module.
$data[9] = '<a href="index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&delete_module='.$module['id_agente_modulo'].'"
onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
$data[9] .= html_print_image(
@ -959,7 +1124,12 @@ html_print_table($table);
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) {
echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_input_hidden('multiple_delete', 1);
html_print_submit_button(__('Delete'), 'multiple_delete', false, 'class="sub delete"');
html_print_submit_button(
__('Delete'),
'multiple_delete',
false,
'class="sub delete"'
);
echo '</div>';
echo '</form>';
}

View File

@ -1290,7 +1290,7 @@ ui_require_jquery_file('json');
<script type="text/javascript">
/* <![CDATA[ */
$(document).ready (function () {
var disabledBecauseInPolicy = '<?php echo $disabledBecauseInPolicy; ?>';
var disabledBecauseInPolicy = <?php echo '\''.(empty($disabledBecauseInPolicy) === true ? '0' : '1').'\''; ?>;
$("#right").click (function () {
jQuery.each($("select[name='id_tag_available[]'] option:selected"), function (key, value) {
tag_name = $(value).html();
@ -1551,7 +1551,10 @@ $(document).ready (function () {
//readonly and add class input
function disabled_status (disabledBecauseInPolicy) {
if($('#dynamic_interval_select').val() != 0 && $('#dynamic_interval').val() != 0){
var dynamic_interval_select_value = $('#dynamic_interval_select').val();
var dynamic_interval_value = $('#dynamic_interval_select').val();
if(typeof dynamic_interval_select_value != "undefined" && typeof dynamic_interval_value != "undefined"
&& dynamic_interval_select_value != 0 && dynamic_interval_value != 0){
$('#text-min_warning').prop('readonly', true);
$('#text-min_warning').addClass('readonly');
$('#text-max_warning').prop('readonly', true);

View File

@ -464,6 +464,8 @@ $data[1] = html_print_select(
$disabledBecauseInPolicy
);
$data[1] .= '<br> <br><a class="info_cell" href="'.ui_get_full_url('index.php?sec=gagente&sec2=godmode/groups/group_list&tab=credbox').'">'.__('Manage credentials').'</a>';
$array_os = [
'inherited' => __('Inherited'),
'linux' => __('SSH'),

View File

@ -171,6 +171,11 @@ if ($delete_action) {
);
}
if (is_central_policies_on_node() === true) {
ui_print_warning_message(
__('This node is configured with centralized mode. All alerts templates information is read only. Go to metaconsole to manage it.')
);
}
$search_string = (string) get_parameter('search_string', '');
$group = (int) get_parameter('group', 0);
@ -224,8 +229,11 @@ $table->data = [];
$table->head = [];
$table->head[0] = __('Name');
$table->head[1] = __('Group');
$table->head[2] = __('Copy');
$table->head[3] = __('Delete');
if (is_central_policies_on_node() === false) {
$table->head[2] = __('Copy');
$table->head[3] = __('Delete');
}
$table->style = [];
$table->style[0] = 'font-weight: bold';
$table->size = [];
@ -292,7 +300,9 @@ foreach ($actions as $action) {
);
}
if (check_acl($config['id_user'], $action['id_group'], 'LM')) {
if (is_central_policies_on_node() === false
&& check_acl($config['id_user'], $action['id_group'], 'LM')
) {
$table->cellclass[] = [
2 => 'action_buttons',
3 => 'action_buttons',
@ -318,12 +328,14 @@ if (isset($data)) {
ui_print_info_message(['no_close' => true, 'message' => __('No alert actions configured') ]);
}
echo '<div class="action-buttons" style="width: '.$table->width.'">';
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_action&pure='.$pure.'">';
html_print_submit_button(__('Create'), 'create', false, 'class="sub next"');
html_print_input_hidden('create_alert', 1);
echo '</form>';
echo '</div>';
if (is_central_policies_on_node() === false) {
echo '<div class="action-buttons" style="width: '.$table->width.'">';
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_action&pure='.$pure.'">';
html_print_submit_button(__('Create'), 'create', false, 'class="sub next"');
html_print_input_hidden('create_alert', 1);
echo '</form>';
echo '</div>';
}
enterprise_hook('close_meta_frame');
?>

View File

@ -46,6 +46,8 @@ if (is_ajax()) {
$id = (int) get_parameter('id', 0);
$get_recovery_fields = (int) get_parameter('get_recovery_fields', 1);
$is_central_policies_on_node = is_central_policies_on_node();
// If command ID is not provided, check for action id.
if ($id == 0) {
$id_action = (int) get_parameter('id_action');
@ -124,40 +126,142 @@ if (is_ajax()) {
// HTML type.
if (preg_match('/^_html_editor_$/i', $field_value)) {
$editor_type_chkbx = '<div style="padding: 4px 0px;"><b><small>';
$editor_type_chkbx .= __('Basic').ui_print_help_tip(__('For sending emails, text must be HTML format, if you want to use plain text, type it between the following labels: <pre></pre>'), true);
$editor_type_chkbx .= html_print_radio_button_extended('editor_type_value_'.$i, 0, '', false, false, "removeTinyMCE('textarea_field".$i."_value')", '', true);
$editor_type_chkbx .= __('Basic');
$editor_type_chkbx .= ui_print_help_tip(
__('For sending emails, text must be HTML format, if you want to use plain text, type it between the following labels: <pre></pre>'),
true
);
$editor_type_chkbx .= html_print_radio_button_extended(
'editor_type_value_'.$i,
0,
'',
false,
$is_central_policies_on_node,
"removeTinyMCE('textarea_field".$i."_value')",
'',
true
);
$editor_type_chkbx .= '&nbsp;&nbsp;&nbsp;&nbsp;';
$editor_type_chkbx .= __('Advanced').'&nbsp;&nbsp;';
$editor_type_chkbx .= html_print_radio_button_extended('editor_type_value_'.$i, 0, '', true, false, "addTinyMCE('textarea_field".$i."_value')", '', true);
$editor_type_chkbx .= html_print_radio_button_extended(
'editor_type_value_'.$i,
0,
'',
true,
$is_central_policies_on_node,
"addTinyMCE('textarea_field".$i."_value')",
'',
true
);
$editor_type_chkbx .= '</small></b></div>';
$ffield = $editor_type_chkbx;
$ffield .= html_print_textarea('field'.$i.'_value', 1, 1, '', 'class="fields"', true);
$ffield .= html_print_textarea(
'field'.$i.'_value',
1,
1,
'',
'class="fields"',
true,
'',
$is_central_policies_on_node
);
$editor_type_chkbx = '<div style="padding: 4px 0px;"><b><small>';
$editor_type_chkbx .= __('Basic').'&nbsp;&nbsp;';
$editor_type_chkbx .= html_print_radio_button_extended('editor_type_recovery_value_'.$i, 0, '', false, false, "removeTinyMCE('textarea_field".$i."_recovery_value')", '', true);
$editor_type_chkbx .= html_print_radio_button_extended(
'editor_type_recovery_value_'.$i,
0,
'',
false,
$is_central_policies_on_node,
"removeTinyMCE('textarea_field".$i."_recovery_value')",
'',
true
);
$editor_type_chkbx .= '&nbsp;&nbsp;&nbsp;&nbsp;';
$editor_type_chkbx .= __('Advanced').'&nbsp;&nbsp;';
$editor_type_chkbx .= html_print_radio_button_extended('editor_type_recovery_value_'.$i, 0, '', true, false, "addTinyMCE('textarea_field".$i."_recovery_value')", '', true);
$editor_type_chkbx .= html_print_radio_button_extended(
'editor_type_recovery_value_'.$i,
0,
'',
true,
$is_central_policies_on_node,
"addTinyMCE('textarea_field".$i."_recovery_value')",
'',
true
);
$editor_type_chkbx .= '</small></b></div>';
$rfield = $editor_type_chkbx;
$rfield .= html_print_textarea('field'.$i.'_recovery_value', 1, 1, '', 'class="fields_recovery"', true);
$rfield .= html_print_textarea(
'field'.$i.'_recovery_value',
1,
1,
'',
'class="fields_recovery"',
true,
'',
$is_central_policies_on_node
);
} else if (preg_match('/^_content_type_$/i', $field_value)) {
$editor_type_chkbx = '<div style="padding: 4px 0px;"><b><small>';
$editor_type_chkbx .= __('Text/plain').ui_print_help_tip(__('For sending emails only text plain'), true);
$editor_type_chkbx .= html_print_radio_button_extended('field'.$i.'_value', 'text/plain', '', '', false, '', '', true);
$editor_type_chkbx .= __('Text/plain');
$editor_type_chkbx .= ui_print_help_tip(
__('For sending emails only text plain'),
true
);
$editor_type_chkbx .= html_print_radio_button_extended(
'field'.$i.'_value',
'text/plain',
'',
'',
$is_central_policies_on_node,
'',
'',
true
);
$editor_type_chkbx .= '&nbsp;&nbsp;&nbsp;&nbsp;';
$editor_type_chkbx .= __('Text/html').'&nbsp;&nbsp;';
$editor_type_chkbx .= html_print_radio_button_extended('field'.$i.'_value', 'text/html', '', 'text/html', false, '', '', true);
$editor_type_chkbx .= html_print_radio_button_extended(
'field'.$i.'_value',
'text/html',
'',
'text/html',
$is_central_policies_on_node,
'',
'',
true
);
$editor_type_chkbx .= '</small></b></div>';
$ffield = $editor_type_chkbx;
$editor_type_chkbx = '<div style="padding: 4px 0px;"><b><small>';
$editor_type_chkbx .= __('Text/plain').ui_print_help_tip(__('For sending emails only text plain'), true);
$editor_type_chkbx .= html_print_radio_button_extended('field'.$i.'_recovery_value', 'text/plain', '', '', false, '', '', true);
$editor_type_chkbx .= __('Text/plain');
$editor_type_chkbx .= ui_print_help_tip(
__('For sending emails only text plain'),
true
);
$editor_type_chkbx .= html_print_radio_button_extended(
'field'.$i.'_recovery_value',
'text/plain',
'',
'',
$is_central_policies_on_node,
'',
'',
true
);
$editor_type_chkbx .= '&nbsp;&nbsp;&nbsp;&nbsp;';
$editor_type_chkbx .= __('Text/html').'&nbsp;&nbsp;';
$editor_type_chkbx .= html_print_radio_button_extended('field'.$i.'_recovery_value', 'text/html', '', 'text/html', false, '', '', true);
$editor_type_chkbx .= html_print_radio_button_extended(
'field'.$i.'_recovery_value',
'text/html',
'',
'text/html',
$is_central_policies_on_node,
'',
'',
true
);
$editor_type_chkbx .= '</small></b></div>';
$rfield = $editor_type_chkbx;
// Select type.
@ -192,7 +296,8 @@ if (is_ajax()) {
true,
false,
false,
'fields'
'fields',
$is_central_policies_on_node
);
$rfield = html_print_select(
$fields_value_select,
@ -204,7 +309,8 @@ if (is_ajax()) {
true,
false,
false,
'fields_recovery'
'fields_recovery',
$is_central_policies_on_node
);
} else {
$ffield = html_print_textarea(
@ -213,7 +319,9 @@ if (is_ajax()) {
1,
$fv[0],
'style="min-height:40px; '.$style.'" class="fields"',
true
true,
'',
$is_central_policies_on_node
);
$rfield = html_print_textarea(
'field'.$i.'_recovery_value',
@ -221,7 +329,9 @@ if (is_ajax()) {
1,
$fv[0],
'style="min-height:40px; '.$style.'" class="fields_recovery',
true
true,
'',
$is_central_policies_on_node
);
}
}
@ -232,7 +342,9 @@ if (is_ajax()) {
1,
'',
'style="min-height:40px; '.$style.'" class="fields"',
true
true,
'',
$is_central_policies_on_node
);
$rfield = html_print_textarea(
'field'.$i.'_recovery_value',
@ -240,7 +352,9 @@ if (is_ajax()) {
1,
'',
'style="min-height:40px; '.$style.'" class="fields_recovery"',
true
true,
'',
$is_central_policies_on_node
);
}
@ -404,6 +518,15 @@ if ($copy_command) {
}
}
$is_central_policies_on_node = is_central_policies_on_node();
if ($is_central_policies_on_node === true) {
ui_print_warning_message(
__('This node is configured with centralized mode. All alerts templates information is read only. Go to metaconsole to manage it.')
);
}
$table = new stdClass;
$table->width = '100%';
$table->class = 'info_table';
@ -457,7 +580,7 @@ foreach ($commands as $command) {
);
$data['action'] = '';
$table->cellclass[]['action'] = 'action_buttons';
if (! $command['internal']) {
if ($is_central_policies_on_node === false && !$command['internal']) {
$data['action'] = '<span style="display: inline-flex">';
$data['action'] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_commands&amp;copy_command=1&id='.$command['id'].'&pure='.$pure.'"
onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/copy.png', true).'</a>';
@ -475,11 +598,13 @@ if (count($table->data) > 0) {
ui_print_info_message(['no_close' => true, 'message' => __('No alert commands configured') ]);
}
echo '<div class="action-buttons" style="width: '.$table->width.'">';
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_command&pure='.$pure.'">';
html_print_submit_button(__('Create'), 'create', false, 'class="sub next"');
html_print_input_hidden('create_alert', 1);
echo '</form>';
echo '</div>';
if ($is_central_policies_on_node === false) {
echo '<div class="action-buttons" style="width: '.$table->width.'">';
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_command&pure='.$pure.'">';
html_print_submit_button(__('Create'), 'create', false, 'class="sub next"');
html_print_input_hidden('create_alert', 1);
echo '</form>';
echo '</div>';
}
enterprise_hook('close_meta_frame');

View File

@ -203,7 +203,7 @@ if ($searchFlag) {
}
if ($actionID != -1 && $actionID != '') {
$where .= ' AND talert_template_modules.id IN (SELECT id_alert_template_module FROM talert_template_module_actions WHERE id_alert_action = '.$actionID.')';
$where .= ' AND talert_template_modules.id IN (SELECT id_alert_template_module FROM talert_template_module_actions WHERE id_alert_action = '.$actionID.') OR talert_template_modules.id IN (SELECT id FROM talert_template_modules ttm WHERE ttm.id_alert_template IN (SELECT tat.id FROM talert_templates tat WHERE tat.id_alert_action = '.$actionID.'))';
}
if ($enabledisable != -1 && $enabledisable != '') {

View File

@ -125,13 +125,13 @@ if (defined('METACONSOLE')) {
$sec = 'galertas';
}
// This prevents to duplicate the header in case delete_templete action is performed
// This prevents to duplicate the header in
// case delete_templete action is performed.
if (!$delete_template) {
// Header
// Header.
if (defined('METACONSOLE')) {
alerts_meta_print_header();
} else {
// ~ ui_print_page_header (__('Alerts')." &raquo; ". __('Alert templates'), "images/gm_alerts.png", false, "alerts_config", true);
ui_print_page_header(
__('Alerts').' &raquo; '.__('Alert templates'),
'images/gm_alerts.png',
@ -142,7 +142,6 @@ if (!$delete_template) {
}
}
if ($update_template) {
$id = (int) get_parameter('id');
@ -151,7 +150,7 @@ if ($update_template) {
$fields_recovery = [];
for ($i = 1; $i <= 10; $i++) {
$values['field'.$i] = (string) get_parameter('field'.$i);
$values['field'.$i.'_recovery'] = $recovery_notify ? (string) get_parameter('field'.$i.'_recovery') : '';
$values['field'.$i.'_recovery'] = ($recovery_notify) ? (string) get_parameter('field'.$i.'_recovery') : '';
}
$values['recovery_notify'] = $recovery_notify;
@ -164,13 +163,15 @@ if ($update_template) {
);
}
// If user tries to delete a template with group=ALL then must have "PM" access privileges
// If user tries to delete a template with group=ALL
// then must have "PM" access privileges.
if ($delete_template) {
$id = get_parameter('id');
$al_template = alerts_get_alert_template($id);
if ($al_template !== false) {
// If user tries to delete a template with group=ALL then must have "PM" access privileges
// If user tries to delete a template with group=ALL
// then must have "PM" access privileges.
if ($al_template['id_group'] == 0) {
if (! check_acl($config['id_user'], 0, 'PM')) {
db_pandora_audit(
@ -192,8 +193,7 @@ if ($delete_template) {
);
}
}
} //end if
else {
} else {
$own_info = get_user_info($config['id_user']);
if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) {
$own_groups = array_keys(users_get_groups($config['id_user'], 'LM'));
@ -202,7 +202,7 @@ if ($delete_template) {
}
$is_in_group = in_array($al_template['id_group'], $own_groups);
// Then template group have to be is his own groups
// Then template group have to be is his own groups.
if ($is_in_group) {
if (defined('METACONSOLE')) {
alerts_meta_print_header();
@ -241,9 +241,15 @@ if ($delete_template) {
$result = alerts_delete_alert_template($id);
if ($result) {
db_pandora_audit('Template alert management', 'Delete alert template #'.$id);
db_pandora_audit(
'Template alert management',
'Delete alert template #'.$id
);
} else {
db_pandora_audit('Template alert management', 'Fail try to delete alert template #'.$id);
db_pandora_audit(
'Template alert management',
'Fail try to delete alert template #'.$id
);
}
ui_print_result_message(
@ -253,6 +259,11 @@ if ($delete_template) {
);
}
if (is_central_policies_on_node() === true) {
ui_print_warning_message(
__('This node is configured with centralized mode. All alerts templates information is read only. Go to metaconsole to manage it.')
);
}
$search_string = (string) get_parameter('search_string');
$search_type = (string) get_parameter('search_type');
@ -269,7 +280,7 @@ $url = ui_get_url_refresh(
$table = new stdClass();
$table->width = '100%';
$table->class = 'databox filters';
if (defined('METACONSOLE')) {
if (is_metaconsole() === true) {
$table->cellspacing = 0;
$table->cellpadding = 0;
}
@ -313,7 +324,7 @@ $table->data[0][4] .= html_print_submit_button(
);
$table->data[0][4] .= '</div>';
if (defined('METACONSOLE')) {
if (is_metaconsole() === true) {
$filter = '<form class="" method="post" action="'.$url.'">';
$filter .= html_print_table($table, true);
$filter .= '</form>';
@ -395,18 +406,34 @@ foreach ($templates as $template) {
$data[1] = ui_print_group_icon($template['id_group'], true);
$data[3] = alerts_get_alert_templates_type_name($template['type']);
if (check_acl($config['id_user'], $template['id_group'], 'LM')) {
if (is_central_policies_on_node() === false
&& check_acl($config['id_user'], $template['id_group'], 'LM')
) {
$table->cellclass[][4] = 'action_buttons';
$data[4] = '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_template&pure='.$pure.'" style="display: inline; float: left">';
$data[4] .= html_print_input_hidden('duplicate_template', 1, true);
$data[4] .= html_print_input_hidden('source_id', $template['id'], true);
$data[4] .= html_print_input_image('dup', 'images/copy.png', 1, '', true, ['title' => __('Duplicate')]);
$data[4] .= html_print_input_image(
'dup',
'images/copy.png',
1,
'',
true,
['title' => __('Duplicate')]
);
$data[4] .= '</form> ';
$data[4] .= '<form method="post" style="display: inline; float: right" onsubmit="if (!confirm(\''.__('Are you sure?').'\')) return false;">';
$data[4] .= html_print_input_hidden('delete_template', 1, true);
$data[4] .= html_print_input_hidden('id', $template['id'], true);
$data[4] .= html_print_input_image('del', 'images/cross.png', 1, '', true, ['title' => __('Delete')]);
$data[4] .= html_print_input_image(
'del',
'images/cross.png',
1,
'',
true,
['title' => __('Delete')]
);
$data[4] .= '</form> ';
} else {
$data[4] = '';
@ -416,18 +443,34 @@ foreach ($templates as $template) {
}
ui_pagination($total_templates, $url);
if (isset($data)) {
if (isset($data) === true) {
html_print_table($table);
ui_pagination($total_templates, $url, 0, 0, false, 'offset', true, 'pagination-bottom');
ui_pagination(
$total_templates,
$url,
0,
0,
false,
'offset',
true,
'pagination-bottom'
);
} else {
ui_print_info_message(['no_close' => true, 'message' => __('No alert templates defined') ]);
ui_print_info_message(
[
'no_close' => true,
'message' => __('No alert templates defined'),
]
);
}
echo '<div class="action-buttons" style="width: '.$table->width.'">';
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_template&pure='.$pure.'">';
html_print_submit_button(__('Create'), 'create', false, 'class="sub next"');
html_print_input_hidden('create_alert', 1);
echo '</form>';
echo '</div>';
if (is_central_policies_on_node() === false) {
echo '<div class="action-buttons" style="width: '.$table->width.'">';
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_template&pure='.$pure.'">';
html_print_submit_button(__('Create'), 'create', false, 'class="sub next"');
html_print_input_hidden('create_alert', 1);
echo '</form>';
echo '</div>';
}
enterprise_hook('close_meta_frame');

View File

@ -60,7 +60,7 @@ if ($al_action !== false) {
__('Alerts').' &raquo; '.__('Configure alert action'),
'images/gm_alerts.png',
false,
'',
'alert_config',
true
);
}
@ -73,19 +73,27 @@ if ($al_action !== false) {
__('Alerts').' &raquo; '.__('Configure alert action'),
'images/gm_alerts.png',
false,
'',
'alert_config',
true
);
}
}
$is_central_policies_on_node = is_central_policies_on_node();
if ($is_central_policies_on_node === true) {
ui_print_warning_message(
__('This node is configured with centralized mode. All alerts templates information is read only. Go to metaconsole to manage it.')
);
}
$name = '';
$id_command = '';
$group = 0;
// All group is 0
$action_threshold = 0;
// All group is 0
// All group is 0.
if ($id) {
$action = alerts_get_alert_action($id);
$name = $action['name'];
@ -95,7 +103,7 @@ if ($id) {
$action_threshold = $action['action_threshold'];
}
// Hidden div with help hint to fill with javascript
// Hidden div with help hint to fill with javascript.
html_print_div(
[
'id' => 'help_alert_macros_hint',
@ -126,7 +134,26 @@ $table->size = [];
$table->size[0] = '20%';
$table->data = [];
$table->data[0][0] = __('Name');
$table->data[0][1] = html_print_input_text('name', $name, '', 35, 255, true);
$table->data[0][1] = html_print_input_text(
'name',
$name,
'',
35,
255,
true,
false,
false,
'',
'',
'',
'',
false,
'',
'',
'',
$is_central_policies_on_node
);
if (io_safe_output($name) == 'Monitoring Event') {
$table->data[0][1] .= '&nbsp;&nbsp;'.ui_print_help_tip(
__('This action may stop working, if you change its name.'),
@ -141,7 +168,21 @@ $table->data[1][0] = __('Group');
$own_info = get_user_info($config['id_user']);
$table->data[1][1] = html_print_select_groups(false, 'LW', true, 'group', $group, '', '', 0, true);
$table->data[1][1] = html_print_select_groups(
false,
'LW',
true,
'group',
$group,
'',
'',
0,
true,
false,
true,
'',
$is_central_policies_on_node
);
$table->colspan[1][1] = 2;
$table->data[2][0] = __('Command');
@ -163,10 +204,15 @@ $table->data[2][1] = html_print_select_from_sql(
'',
__('None'),
0,
true
true,
false,
false,
$is_central_policies_on_node
);
$table->data[2][1] .= ' ';
if (check_acl($config['id_user'], 0, 'PM')) {
if ($is_central_policies_on_node === false
&& check_acl($config['id_user'], 0, 'PM')
) {
$table->data[2][1] .= __('Create Command');
$table->data[2][1] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_command&pure='.$pure.'">';
$table->data[2][1] .= html_print_image('images/add.png', true);
@ -188,7 +234,7 @@ $table->data[3][1] = html_print_extended_select_for_time(
false,
true,
'',
false,
$is_central_policies_on_node,
false,
'',
false,
@ -237,12 +283,12 @@ for ($i = 1; $i <= $config['max_macro_fields']; $i++) {
// Store the value in a hidden to keep it on first execution
$table->data['field'.$i][1] .= html_print_input_hidden(
'field'.$i.'_value',
!empty($action['field'.$i]) ? $action['field'.$i] : '',
(!empty($action['field'.$i]) || $action['field'.$i] == 0) ? $action['field'.$i] : '',
true
);
$table->data['field'.$i][2] .= html_print_input_hidden(
'field'.$i.'_recovery_value',
!empty($action['field'.$i.'_recovery']) ? $action['field'.$i.'_recovery'] : '',
(!empty($action['field'.$i.'_recovery']) || $action['field'.$i] == 0) ? $action['field'.$i.'_recovery'] : '',
true
);
}
@ -251,46 +297,44 @@ for ($i = 1; $i <= $config['max_macro_fields']; $i++) {
echo '<form method="post" action="'.'index.php?sec='.$sec.'&'.'sec2=godmode/alerts/alert_actions&'.'pure='.$pure.'">';
$table_html = html_print_table($table, true);
//
// Hack to hook the bubble dialog of clippy in any place, the intro.js
// fails with new elements in the dom from javascript code
// ----------------------------------------------------------------------
/*
$table_html = str_replace(
"</table>",
"</div>",
$table_html);
$table_html = str_replace(
'<tr id="table_macros-field1" style="" class="datos2">',
"</tbody></table>
<div id=\"clippy_fields\">
<table>
<tbody>
<tr id=\"table_macros-field1\" class=\"datos\">",
$table_html);
*/
//
echo $table_html;
echo '<div class="action-buttons" style="width: '.$table->width.'">';
if ($id) {
html_print_input_hidden('id', $id);
if ($al_action['id_group'] == 0) {
// then must have "PM" access privileges
if (check_acl($config['id_user'], 0, 'PM')) {
if ($is_central_policies_on_node === false) {
echo '<div class="action-buttons" style="width: '.$table->width.'">';
if ($id) {
html_print_input_hidden('id', $id);
if ($al_action['id_group'] == 0) {
// Then must have "PM" access privileges.
if (check_acl($config['id_user'], 0, 'PM')) {
html_print_input_hidden('update_action', 1);
html_print_submit_button(
__('Update'),
'create',
false,
'class="sub upd"'
);
}
} else {
html_print_input_hidden('update_action', 1);
html_print_submit_button(__('Update'), 'create', false, 'class="sub upd"');
html_print_submit_button(
__('Update'),
'create',
false,
'class="sub upd"'
);
}
} else {
html_print_input_hidden('update_action', 1);
html_print_submit_button(__('Update'), 'create', false, 'class="sub upd"');
html_print_input_hidden('create_action', 1);
html_print_submit_button(
__('Create'),
'create',
false,
'class="sub wand"'
);
}
} else {
html_print_input_hidden('create_action', 1);
html_print_submit_button(__('Create'), 'create', false, 'class="sub wand"');
echo '</div>';
}
echo '</div>';
echo '</form>';
enterprise_hook('close_meta_frame');

View File

@ -36,7 +36,7 @@ $pure = get_parameter('pure', 0);
$alert = [];
// Header.
if (defined('METACONSOLE')) {
if (is_metaconsole() === true) {
alerts_meta_print_header();
} else {
ui_print_page_header(
@ -139,30 +139,39 @@ if ($id) {
$fields_hidden = $alert['fields_hidden'];
}
if (!empty($fields_descriptions)) {
if (empty($fields_descriptions) === false) {
$fields_descriptions = json_decode($fields_descriptions, true);
}
if (!empty($fields_values)) {
if (empty($fields_values) === false) {
$fields_values = json_decode($fields_values, true);
}
if (!empty($fields_hidden)) {
if (empty($fields_hidden) === false) {
$fields_hidden = json_decode($fields_hidden, true);
}
$is_central_policies_on_node = is_central_policies_on_node();
if ($is_central_policies_on_node === true) {
ui_print_warning_message(
__('This node is configured with centralized mode. All alerts templates information is read only. Go to metaconsole to manage it.')
);
}
$table = new stdClass();
$table->width = '100%';
$table->class = 'databox filters';
if (defined('METACONSOLE')) {
if (is_metaconsole() === true) {
$table->head[0] = ($id) ? __('Update Command') : __('Create Command');
$table->head_colspan[0] = 4;
$table->headstyle[0] = 'text-align: center';
}
$table->style = [];
if (!defined('METACONSOLE')) {
if (is_metaconsole() === false) {
$table->style[0] = 'font-weight: bold';
$table->style[2] = 'font-weight: bold';
$table->style[4] = 'font-weight: bold';
@ -174,11 +183,38 @@ $table->data = [];
$table->colspan['name'][1] = 3;
$table->data['name'][0] = __('Name');
$table->data['name'][2] = html_print_input_text('name', $name, '', 35, 255, true);
$table->data['name'][2] = html_print_input_text(
'name',
$name,
'',
35,
255,
true,
false,
false,
'',
'',
'',
'',
false,
'',
'',
'',
$is_central_policies_on_node
);
$table->colspan['command'][1] = 3;
$table->data['command'][0] = __('Command');
$table->data['command'][1] = html_print_textarea('command', 8, 30, $command, '', true);
$table->data['command'][1] = html_print_textarea(
'command',
8,
30,
$command,
'',
true,
'',
$is_central_policies_on_node
);
$table->colspan['group'][1] = 3;
$table->data['group'][0] = __('Group');
@ -191,60 +227,124 @@ $table->data['group'][1] = html_print_select_groups(
false,
'',
0,
true
true,
false,
true,
'',
$is_central_policies_on_node
);
$table->colspan['description'][1] = 3;
$table->data['description'][0] = __('Description');
$table->data['description'][1] = html_print_textarea('description', 10, 30, $description, '', true);
$table->data['description'][1] = html_print_textarea(
'description',
10,
30,
$description,
'',
true,
'',
$is_central_policies_on_node
);
for ($i = 1; $i <= $config['max_macro_fields']; $i++) {
$table->data['field'.$i][0] = sprintf(__('Field %s description'), $i);
if (!empty($fields_descriptions)) {
if (empty($fields_descriptions) === false) {
$field_description = $fields_descriptions[($i - 1)];
} else {
$field_description = '';
}
$table->data['field'.$i][1] = html_print_input_text('field'.$i.'_description', $field_description, '', 30, 255, true);
$table->data['field'.$i][1] = html_print_input_text(
'field'.$i.'_description',
$field_description,
'',
30,
255,
true,
false,
false,
'',
'',
'',
'',
false,
'',
'',
'',
$is_central_policies_on_node
);
$table->data['field'.$i][2] = sprintf(__('Field %s values'), $i).ui_print_help_tip(__('value1,tag1;value2,tag2;value3,tag3'), true);
$table->data['field'.$i][2] = sprintf(__('Field %s values'), $i);
$table->data['field'.$i][2] .= ui_print_help_tip(
__('value1,tag1;value2,tag2;value3,tag3'),
true
);
if (!empty($fields_values)) {
if (empty($fields_values) === false) {
$field_values = $fields_values[($i - 1)];
} else {
$field_values = '';
}
if (!empty($fields_hidden)) {
if (empty($fields_hidden) === false) {
$selected = (bool) $fields_hidden[($i - 1)];
} else {
$selected = false;
}
$table->data['field'.$i][3] = html_print_input_text('field'.$i.'_values', $field_values, '', 55, 255, true, false, false, '', 'field_value');
$table->data['field'.$i][3] = html_print_input_text(
'field'.$i.'_values',
$field_values,
'',
55,
255,
true,
false,
false,
'',
'field_value',
'',
'',
false,
'',
'',
'',
$is_central_policies_on_node
);
$table->data['field'.$i][4] = __('Hide');
$table->data['field'.$i][5] = html_print_checkbox_extended('field'.$i.'_hide', 1, $selected, false, 'cursor: \'pointer\'', 'class="hide_inputs"', true);
$table->data['field'.$i][5] = html_print_checkbox_extended(
'field'.$i.'_hide',
1,
$selected,
$is_central_policies_on_node,
'cursor: \'pointer\'',
'class="hide_inputs"',
true
);
}
echo '<form method="post" action="index.php?sec=galertas&sec2=godmode/alerts/alert_commands&pure='.$pure.'">';
html_print_table($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
if ($id) {
html_print_input_hidden('id', $id);
html_print_input_hidden('update_command', 1);
html_print_submit_button(__('Update'), 'create', false, 'class="sub upd"');
} else {
html_print_input_hidden('create_command', 1);
html_print_submit_button(__('Create'), 'create', false, 'class="sub wand"');
if ($is_central_policies_on_node === false) {
echo '<div class="action-buttons" style="width: '.$table->width.'">';
if ($id) {
html_print_input_hidden('id', $id);
html_print_input_hidden('update_command', 1);
html_print_submit_button(__('Update'), 'create', false, 'class="sub upd"');
} else {
html_print_input_hidden('create_command', 1);
html_print_submit_button(__('Create'), 'create', false, 'class="sub wand"');
}
echo '</div>';
}
echo '</div>';
echo '</form>';
enterprise_hook('close_meta_frame');
@ -255,20 +355,20 @@ $(document).ready (function () {
$(".hide_inputs").each(function(index) {
var $input_in_row = $(this).closest('tr').find('.field_value');
if($(this).is(':checked')) {
if($(this).is(':checked')) {
$input_in_row.prop('style', '-webkit-text-security: disc;');
} else {
} else {
$input_in_row.prop('style', '');
}
});
$(".hide_inputs").click(function() {
var $input_in_row = $(this).closest('tr').find('.field_value');
if($(this).is(':checked')) {
if($(this).is(':checked')) {
$input_in_row.prop('style', '-webkit-text-security: disc;');
} else {
} else {
$input_in_row.prop('style', '');
}
}
});
});
</script>

View File

@ -360,6 +360,19 @@ function update_template($step)
}
$is_central_policies_on_node = is_central_policies_on_node();
if ($is_central_policies_on_node === true) {
ui_print_warning_message(
__('This node is configured with centralized mode. All alerts templates information is read only. Go to metaconsole to manage it.')
);
}
// We set here the number of steps.
define('LAST_STEP', 3);
$step = (int) get_parameter('step', 1);
$create_alert = (bool) get_parameter('create_alert');
$create_template = (bool) get_parameter('create_template');
$update_template = (bool) get_parameter('update_template');
@ -571,27 +584,74 @@ if ($step == 2) {
$show_matches = false;
}
// Firing conditions and events
// Firing conditions and events.
$table->colspan = [];
// $table->colspan[4][1] = 1;
$table->data[0][0] = __('Days of week');
$table->data[0][1] = __('Mon');
$table->data[0][1] .= html_print_checkbox('monday', 1, $monday, true);
$table->data[0][1] .= html_print_checkbox(
'monday',
1,
$monday,
true,
$is_central_policies_on_node
);
$table->data[0][1] .= __('Tue');
$table->data[0][1] .= html_print_checkbox('tuesday', 1, $tuesday, true);
$table->data[0][1] .= html_print_checkbox(
'tuesday',
1,
$tuesday,
true,
$is_central_policies_on_node
);
$table->data[0][1] .= __('Wed');
$table->data[0][1] .= html_print_checkbox('wednesday', 1, $wednesday, true);
$table->data[0][1] .= html_print_checkbox(
'wednesday',
1,
$wednesday,
true,
$is_central_policies_on_node
);
$table->data[0][1] .= __('Thu');
$table->data[0][1] .= html_print_checkbox('thursday', 1, $thursday, true);
$table->data[0][1] .= html_print_checkbox(
'thursday',
1,
$thursday,
true,
$is_central_policies_on_node
);
$table->data[0][1] .= __('Fri');
$table->data[0][1] .= html_print_checkbox('friday', 1, $friday, true);
$table->data[0][1] .= html_print_checkbox(
'friday',
1,
$friday,
true,
$is_central_policies_on_node
);
$table->data[0][1] .= __('Sat');
$table->data[0][1] .= html_print_checkbox('saturday', 1, $saturday, true);
$table->data[0][1] .= html_print_checkbox(
'saturday',
1,
$saturday,
true,
$is_central_policies_on_node
);
$table->data[0][1] .= __('Sun');
$table->data[0][1] .= html_print_checkbox('sunday', 1, $sunday, true);
$table->data[0][1] .= html_print_checkbox(
'sunday',
1,
$sunday,
true,
$is_central_policies_on_node
);
$table->data[0][2] = __('Use special days list');
$table->data[0][3] = html_print_checkbox('special_day', 1, $special_day, true);
$table->data[0][3] = html_print_checkbox(
'special_day',
1,
$special_day,
true,
$is_central_policies_on_node
);
$table->data[1][0] = __('Time from');
$table->data[1][1] = html_print_input_text(
@ -600,7 +660,18 @@ if ($step == 2) {
'',
7,
8,
true
true,
false,
false,
'',
'',
'',
'',
false,
'',
'',
'',
$is_central_policies_on_node
);
$table->data[1][2] = __('Time to');
$table->data[1][3] = html_print_input_text(
@ -609,7 +680,18 @@ if ($step == 2) {
'',
7,
8,
true
true,
false,
false,
'',
'',
'',
'',
false,
'',
'',
'',
$is_central_policies_on_node
);
$table->colspan['threshold'][1] = 3;
@ -621,7 +703,11 @@ if ($step == 2) {
'',
'',
false,
true
true,
false,
true,
'',
$is_central_policies_on_node
);
$table->data[3][0] = __('Min. number of alerts');
@ -631,11 +717,32 @@ if ($step == 2) {
'',
5,
7,
true
true,
false,
false,
'',
'',
'',
'',
false,
'',
'',
'',
$is_central_policies_on_node
);
$table->data[3][2] = __('Reset counter for non-sustained alerts').ui_print_help_tip(__('Enable this option if you want the counter to be reset when the alert is not being fired consecutively, even if it\'s within the time threshold'), true);
$table->data[3][3] = html_print_checkbox('min_alerts_reset_counter', 1, $min_alerts_reset_counter, true);
$table->data[3][2] = __('Reset counter for non-sustained alerts');
$table->data[3][2] .= ui_print_help_tip(
__('Enable this option if you want the counter to be reset when the alert is not being fired consecutively, even if it\'s within the time threshold'),
true
);
$table->data[3][3] = html_print_checkbox(
'min_alerts_reset_counter',
1,
$min_alerts_reset_counter,
true,
$is_central_policies_on_node
);
$table->data[4][0] = __('Max. number of alerts');
$table->data[4][1] = html_print_input_text(
@ -644,39 +751,43 @@ if ($step == 2) {
'',
5,
7,
true
true,
false,
false,
'',
'',
'',
'',
false,
'',
'',
'',
$is_central_policies_on_node
);
$table->data[4][2] = __('Disable event');
$table->data[4][3] = html_print_checkbox('disable_event', 1, $disable_event, true);
$table->data[4][3] = html_print_checkbox(
'disable_event',
1,
$disable_event,
true,
$is_central_policies_on_node
);
$table->data[5][0] = __('Default action');
$usr_groups = implode(',', array_keys(users_get_groups($config['id_user'], 'LM', true)));
switch ($config['dbtype']) {
case 'mysql':
case 'postgresql':
$sql_query = sprintf(
'
SELECT id, name
FROM talert_actions
WHERE id_group IN (%s)
ORDER BY name',
$usr_groups
);
break;
$usr_groups = implode(
',',
array_keys(users_get_groups($config['id_user'], 'LM', true))
);
case 'oracle':
$sql_query = sprintf(
'
SELECT id,
dbms_lob.substr(name,4000,1) AS nombre
FROM talert_actions
WHERE id_group IN (%s)
ORDER BY dbms_lob.substr(name,4000,1)',
$usr_groups
);
break;
}
$sql_query = sprintf(
'
SELECT id, name
FROM talert_actions
WHERE id_group IN (%s)
ORDER BY name',
$usr_groups
);
$table->data[5][1] = html_print_select_from_sql(
$sql_query,
@ -688,11 +799,12 @@ if ($step == 2) {
true,
false,
false,
false,
$is_central_policies_on_node,
false,
false,
0
).ui_print_help_tip(
);
$table->data[5][1] .= ui_print_help_tip(
__('Unless they\'re left blank, the fields from the action will override those set on the template.'),
true
);
@ -707,7 +819,9 @@ if ($step == 2) {
0,
true,
false,
false
false,
'',
$is_central_policies_on_node
);
$table->data[6][1] .= '<span id="matches_value" '.($show_matches ? '' : 'style="display: none"').'>';
$table->data[6][1] .= '&nbsp;'.html_print_checkbox('matches_value', 1, $matches, true);
@ -752,7 +866,7 @@ if ($step == 2) {
$table->data['value'][1] .= '</span>';
$table->colspan['value'][1] = 3;
// Min first, then max, that's more logical
// Min first, then max, that's more logical.
$table->data['min'][0] = __('Min.');
$table->data['min'][1] = html_print_input_text(
'min',
@ -790,25 +904,12 @@ if ($step == 2) {
$table->size[1] = '45%';
$table->size[2] = '45%';
// Alert recover
// Alert recover.
if (! $recovery_notify) {
$table->cellstyle['label_fields'][2] = 'display:none;';
for ($i = 1; $i <= $config['max_macro_fields']; $i++) {
$table->cellstyle['field'.$i][2] = 'display:none;';
}
/*
$table->cellstyle['field1'][2] = 'display:none;';
$table->cellstyle['field2'][2] = 'display:none;';
$table->cellstyle['field3'][2] = 'display:none;';
$table->cellstyle['field4'][2] = 'display:none;';
$table->cellstyle['field5'][2] = 'display:none;';
$table->cellstyle['field6'][2] = 'display:none;';
$table->cellstyle['field7'][2] = 'display:none;';
$table->cellstyle['field8'][2] = 'display:none;';
$table->cellstyle['field9'][2] = 'display:none;';
$table->cellstyle['field10'][2] = 'display:none;';
*/
}
$table->data[0][0] = __('Alert recovery');
@ -825,7 +926,9 @@ if ($step == 2) {
'',
true,
false,
false
false,
'',
$is_central_policies_on_node
);
$table->colspan[0][1] = 2;
@ -834,45 +937,98 @@ if ($step == 2) {
$table->data['label_fields'][2] = __('Recovery fields');
for ($i = 1; $i <= $config['max_macro_fields']; $i++) {
if (isset($template[$name])) {
if (isset($template[$name]) === true) {
$value = $template[$name];
} else {
$value = '';
}
// $table->rowclass['field'.$i] = 'row_field';
$table->data['field'.$i][0] = sprintf(__('Field %s'), $i);
// TinyMCE
// triggering fields
// basic
$table->data['field'.$i][1] = '<div style="padding: 4px 0px;"><b><small>';
$table->data['field'.$i][1] .= __('Basic').'&nbsp;&nbsp;';
$table->data['field'.$i][1] .= html_print_radio_button_extended('editor_type_value_'.$i, 0, '', false, false, "removeTinyMCE('textarea_field".$i."')", '', true);
// Advanced
$table->data['field'.$i][1] .= '&nbsp;&nbsp;&nbsp;&nbsp;';
$table->data['field'.$i][1] .= __('Advanced').'&nbsp;&nbsp;';
$table->data['field'.$i][1] .= html_print_radio_button_extended('editor_type_value_'.$i, 0, '', true, false, "addTinyMCE('textarea_field".$i."')", '', true);
$table->data['field'.$i][1] .= '</small></b></div>';
// TinyMCE.
// triggering fields.
// Basic.
$table->data['field'.$i][1] = '<div style="padding: 4px 0px;"><b><small>';
$table->data['field'.$i][1] .= __('Basic').'&nbsp;&nbsp;';
$table->data['field'.$i][1] .= html_print_radio_button_extended(
'editor_type_value_'.$i,
0,
'',
false,
$is_central_policies_on_node,
"removeTinyMCE('textarea_field".$i."')",
'',
true
);
// Advanced.
$table->data['field'.$i][1] .= '&nbsp;&nbsp;&nbsp;&nbsp;';
$table->data['field'.$i][1] .= __('Advanced').'&nbsp;&nbsp;';
$table->data['field'.$i][1] .= html_print_radio_button_extended(
'editor_type_value_'.$i,
0,
'',
true,
$is_central_policies_on_node,
"addTinyMCE('textarea_field".$i."')",
'',
true
);
$table->data['field'.$i][1] .= '</small></b></div>';
// Texarea
$table->data['field'.$i][1] .= html_print_textarea('field'.$i, 1, 1, isset($fields[$i]) ? $fields[$i] : '', 'style="min-height:40px;" class="fields"', true);
// Texarea.
$table->data['field'.$i][1] .= html_print_textarea(
'field'.$i,
1,
1,
isset($fields[$i]) ? $fields[$i] : '',
'style="min-height:40px;" class="fields"',
true,
'',
$is_central_policies_on_node
);
// Recovery
// basic
$table->data['field'.$i][2] = '<div style="padding: 4px 0px;"><b><small>';
$table->data['field'.$i][2] .= __('Basic').'&nbsp;&nbsp;';
$table->data['field'.$i][2] .= html_print_radio_button_extended('editor_type_recovery_value_'.$i, 0, '', false, false, "removeTinyMCE('textarea_field".$i."_recovery')", '', true);
// advanced
$table->data['field'.$i][2] .= '&nbsp;&nbsp;&nbsp;&nbsp;';
$table->data['field'.$i][2] .= __('Advanced').'&nbsp;&nbsp;';
$table->data['field'.$i][2] .= html_print_radio_button_extended('editor_type_recovery_value_'.$i, 0, '', true, false, "addTinyMCE('textarea_field".$i."_recovery')", '', true);
$table->data['field'.$i][2] .= '</small></b></div>';
// Recovery.
// Basic.
$table->data['field'.$i][2] = '<div style="padding: 4px 0px;"><b><small>';
$table->data['field'.$i][2] .= __('Basic').'&nbsp;&nbsp;';
$table->data['field'.$i][2] .= html_print_radio_button_extended(
'editor_type_recovery_value_'.$i,
0,
'',
false,
$is_central_policies_on_node,
"removeTinyMCE('textarea_field".$i."_recovery')",
'',
true
);
// Advanced.
$table->data['field'.$i][2] .= '&nbsp;&nbsp;&nbsp;&nbsp;';
$table->data['field'.$i][2] .= __('Advanced').'&nbsp;&nbsp;';
$table->data['field'.$i][2] .= html_print_radio_button_extended(
'editor_type_recovery_value_'.$i,
0,
'',
true,
$is_central_policies_on_node,
"addTinyMCE('textarea_field".$i."_recovery')",
'',
true
);
$table->data['field'.$i][2] .= '</small></b></div>';
// Texarea
$table->data['field'.$i][2] .= html_print_textarea('field'.$i.'_recovery', 1, 1, isset($fields_recovery[$i]) ? $fields_recovery[$i] : '', 'style="min-height:40px" class="fields"', true);
// Texarea.
$table->data['field'.$i][2] .= html_print_textarea(
'field'.$i.'_recovery',
1,
1,
isset($fields_recovery[$i]) ? $fields_recovery[$i] : '',
'style="min-height:40px" class="fields"',
true,
'',
$is_central_policies_on_node
);
}
} else {
// Step 1 by default
// Step 1 by default.
$table->size = [];
$table->size[0] = '20%';
$table->data = [];
@ -908,20 +1064,53 @@ if ($step == 2) {
}
$table->data[0][0] = __('Name');
$table->data[0][1] = html_print_input_text('name', $name, '', 35, 255, true);
$table->data[0][1] = html_print_input_text(
'name',
$name,
'',
35,
255,
true,
false,
false,
'',
'',
'',
'',
false,
'',
'',
'',
$is_central_policies_on_node
);
$table->data[0][1] .= '&nbsp;&nbsp;'.__('Group');
$groups = users_get_groups();
$own_info = get_user_info($config['id_user']);
// Only display group "All" if user is administrator or has "PM" privileges
// Only display group "All" if user is administrator or has "PM" privileges.
if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) {
$display_all_group = true;
} else {
$display_all_group = false;
}
$table->data[0][1] .= '&nbsp;'.html_print_select_groups(false, 'AR', $display_all_group, 'id_group', $id_group, '', '', 0, true);
$table->data[0][1] .= '&nbsp;';
$table->data[0][1] .= html_print_select_groups(
false,
'AR',
$display_all_group,
'id_group',
$id_group,
'',
'',
0,
true,
false,
true,
'',
$is_central_policies_on_node
);
$table->data[1][0] = __('Description');
@ -931,7 +1120,9 @@ if ($step == 2) {
30,
$description,
'',
true
true,
'',
$is_central_policies_on_node
);
$table->data[2][0] = __('Priority');
@ -944,7 +1135,9 @@ if ($step == 2) {
0,
true,
false,
false
false,
'',
$is_central_policies_on_node
);
if (defined('METACONSOLE')) {
@ -992,25 +1185,32 @@ if (!$create_alert && !$create_template) {
}
if (!$disabled) {
if ($step >= LAST_STEP) {
html_print_submit_button(__('Finish'), 'finish', false, 'class="sub upd"');
} else {
html_print_input_hidden('step', ($step + 1));
if ($step == 2) {
// Javascript onsubmit to avoid min = 0 and max = 0
if ($is_central_policies_on_node === false) {
if ($step >= LAST_STEP) {
html_print_submit_button(
__('Next'),
'next',
__('Finish'),
'finish',
false,
'class="sub next" onclick="return check_fields_step2();"'
'class="sub upd"'
);
} else {
html_print_submit_button(
__('Next'),
'next',
false,
'class="sub next"'
);
html_print_input_hidden('step', ($step + 1));
if ($step == 2) {
// Javascript onsubmit to avoid min = 0 and max = 0
html_print_submit_button(
__('Next'),
'next',
false,
'class="sub next" onclick="return check_fields_step2();"'
);
} else {
html_print_submit_button(
__('Next'),
'next',
false,
'class="sub next"'
);
}
}
}
}
@ -1033,7 +1233,7 @@ var matches_not = <?php echo '"'.__("The alert would fire when the value doesn\'
var is = <?php echo "'".__('The alert would fire when the value is <span id="value"></span>')."'"; ?>;
var is_not = <?php echo "'".__('The alert would fire when the value is not <span id="value"></span>')."'"; ?>;
var between = <?php echo "'".__('The alert would fire when the value is between <span id="min"></span> and <span id="max"></span>')."'"; ?>;
var between_not = <?php echo '"'.__("The alert would fire when the value is not between <span id=\'min\'></span> and <span id=\'max\'></span>").'"'; ?>;
var between_not = <?php echo '"'.__('The alert would fire when the value is not between <span id=min></span> and <span id=max></span>').'"'; ?>;
var under = <?php echo "'".__('The alert would fire when the value is below <span id="min"></span>')."'"; ?>;
var over = <?php echo "'".__('The alert would fire when the value is above <span id="max"></span>')."'"; ?>;
var warning = <?php echo "'".__('The alert would fire when the module is in warning status')."'"; ?>;

View File

@ -35,12 +35,15 @@ global $config;
check_login();
enterprise_hook('open_meta_frame');
require_once $config['homedir'].'/include/functions_groups.php';
require_once $config['homedir'].'/include/functions_agents.php';
require_once $config['homedir'].'/include/functions_users.php';
enterprise_include_once('meta/include/functions_agents_meta.php');
if (is_metaconsole()) {
enterprise_include_once('include/functions_metaconsole.php');
enterprise_include_once('meta/include/functions_agents_meta.php');
enterprise_hook('open_meta_frame');
}
if (is_ajax()) {
if (! check_acl($config['id_user'], 0, 'AR')) {
@ -714,7 +717,12 @@ if ($tab == 'tree') {
foreach ($groups as $key => $group) {
$url = 'index.php?sec=gagente&sec2=godmode/groups/configure_group&id_group='.$group['id_grupo'];
$url_delete = 'index.php?sec=gagente&sec2=godmode/groups/group_list&delete_group=1&id_group='.$group['id_grupo'];
if (is_metaconsole()) {
$url_delete = 'index.php?sec=gagente&sec2=godmode/groups/group_list&delete_group=1&id_group='.$group['id_grupo'].'&tab=groups';
} else {
$url_delete = 'index.php?sec=gagente&sec2=godmode/groups/group_list&delete_group=1&id_group='.$group['id_grupo'];
}
$table->data[$key][0] = $group['id_grupo'];
$table->data[$key][1] = '<a href="'.$url.'">'.$group['nombre'].'</a>';
if ($group['icon'] != '') {

View File

@ -46,14 +46,15 @@ if (defined('METACONSOLE')) {
$sec = 'gmodules';
}
$create = (bool) get_parameter('create');
$update = (bool) get_parameter('update');
$delete = (bool) get_parameter('delete');
$new = (bool) get_parameter('new');
$id = (int) get_parameter('id');
$multiple_delete = (bool) get_parameter('multiple_delete', 0);
$pure = get_parameter('pure', 0);
if (is_management_allowed() === true) {
$create = (bool) get_parameter('create');
$update = (bool) get_parameter('update');
$delete = (bool) get_parameter('delete');
$new = (bool) get_parameter('new');
$id = (int) get_parameter('id');
$multiple_delete = (bool) get_parameter('multiple_delete', 0);
$pure = get_parameter('pure', 0);
}
if ($create) {
$name = (string) get_parameter('name');
@ -186,7 +187,7 @@ if ($multiple_delete) {
);
}
if (($id || $new) && !$delete && !$multiple_delete) {
if (($id || $new) && !$delete && !$multiple_delete && is_management_allowed() === true) {
include_once 'manage_nc_groups_form.php';
return;
}
@ -229,7 +230,10 @@ $table->class = 'info_table';
$table->head = [];
$table->head['checkbox'] = html_print_checkbox('all_delete', 0, false, true, false);
$table->head[0] = __('Name');
$table->head[1] = __('Action');
if (is_management_allowed() === true) {
$table->head[1] = __('Action');
}
$table->style = [];
$table->style[0] = 'font-weight: bold';
$table->align = [];
@ -258,31 +262,42 @@ foreach ($groups as $group) {
}
$table->cellclass[][1] = 'action_buttons';
$data[1] = "<a onclick='if(confirm(\"".__('Are you sure?')."\")) return true; else return false;'
if (is_management_allowed() === true) {
$data[1] = "<a onclick='if(confirm(\"".__('Are you sure?')."\")) return true; else return false;'
href='index.php?sec=".$sec.'&sec2=godmode/modules/manage_nc_groups&delete=1&id='.$group['id_sg']."&offset=0'>".html_print_image('images/cross.png', true, ['title' => __('Delete')]).'</a>';
}
array_push($table->data, $data);
}
if (is_management_allowed() === false) {
ui_print_warning_message(__('This node is configured with centralized mode. This page is for read only. Go to metaconsole to manage the component groups.'));
}
if (isset($data)) {
echo "<form method='post' action='index.php?sec=".$sec."&sec2=godmode/modules/manage_nc_groups'>";
html_print_input_hidden('multiple_delete', 1);
html_print_table($table);
echo "<div style='padding-left: 10px; float: right;'>";
html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"');
echo '</div>';
if (is_management_allowed() === true) {
echo "<div style='padding-left: 10px; float: right;'>";
html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"');
echo '</div>';
}
echo '</form>';
} else {
ui_print_info_message(['no_close' => true, 'message' => __('There are no defined component groups') ]);
}
if (is_management_allowed() === true) {
echo '<form method="post" action='.$url.'>';
echo '<div class="" style="float:right;">';
html_print_input_hidden('new', 1);
html_print_submit_button(__('Create'), 'crt', false, 'class="sub next"');
echo '</div>';
echo '</form>';
}
echo '<form method="post" action='.$url.'>';
echo '<div class="" style="float:right;">';
html_print_input_hidden('new', 1);
html_print_submit_button(__('Create'), 'crt', false, 'class="sub next"');
echo '</div>';
echo '</form>';
enterprise_hook('close_meta_frame');
?>

View File

@ -180,7 +180,7 @@ $data[1] = html_print_extended_select_for_post_process(
'post_process',
$post_process,
'',
__('Empty'),
'',
'0',
false,
true,

View File

@ -190,8 +190,20 @@ if ($editGraph) {
$weights = implode(',', $weight_array);
}
$count_module_array = count($module_array);
if ($count_module_array > 10) {
ui_print_warning_message(
__(
'The maximum number of items in a chart is 10. You have %s elements, only first 10 will be displayed.',
$count_module_array
)
);
}
// Modules table.
if (count($module_array) > 0) {
if ($count_module_array > 0) {
echo "<table width='100%' cellpadding=4 cellpadding=4 class='databox filters'>";
echo '<tr>
<th>'.__('P.').'</th>
@ -202,7 +214,7 @@ if (count($module_array) > 0) {
<th>'.__('Delete').'</th>
<th>'.__('Sort').'</th>';
$color = 0;
for ($a = 0; $a < count($module_array); $a++) {
for ($a = 0; $a < $count_module_array; $a++) {
// Calculate table line color.
if ($color == 1) {
$tdcolor = 'datos';

View File

@ -164,9 +164,9 @@ echo '</div></td></tr>';
echo "<tr><td class='datos2'><b>".__('Percentil').'</b></td>';
echo "<td class='datos2'>".html_print_checkbox('percentil', 1, $percentil, true).'</td>';
echo "<td class='datos2'><div id='thresholdDiv' name='thresholdDiv'><b>".__('Equalize maximum thresholds').'</b>';
html_print_checkbox('threshold', CUSTOM_GRAPH_BULLET_CHART_THRESHOLD, $check, false, false, '', false);
echo '</div></td></tr>';
echo "<td class='datos2 thresholdDiv'><b>".__('Equalize maximum thresholds').'</b></td>';
echo "<td class='datos2 thresholdDiv'>".html_print_checkbox('threshold', CUSTOM_GRAPH_BULLET_CHART_THRESHOLD, $check, true, false, '', false);
echo '</td></tr>';
echo "<tr><td class='datos2'><b>".__('Add summatory series').'</b></td>';
echo "<td class='datos2'>".html_print_checkbox('summatory_series', 1, $summatory_series, true)."</td>
<td class='datos2'><b>".__('Add average series').'</b></td>';
@ -175,6 +175,7 @@ echo "<tr><td class='datos2'><b>".__('Modules and series').'</b></td>';
echo "<td class='datos2'>".html_print_checkbox('modules_series', 1, $modules_series, true).'</td>';
echo "<td class='datos2'><b>".__('Show full scale graph (TIP)').'</td>';
echo "<td class='datos2'>".html_print_checkbox('fullscale', 1, $fullscale, true).'</td>';
echo '</tr>';
echo '</table>';
@ -190,9 +191,9 @@ echo '</form>';
echo '<script type="text/javascript">
$(document).ready(function() {
if ($("#stacked").val() == '.CUSTOM_GRAPH_BULLET_CHART.') {
$("#thresholdDiv").show();
$(".thresholdDiv").show();
}else{
$("#thresholdDiv").hide();
$(".thresholdDiv").hide();
}
if(!$("#checkbox-summatory_series").is(":checked") && !$("#checkbox-average_series").is(":checked")){
@ -207,16 +208,16 @@ echo '<script type="text/javascript">
$("[name=threshold]").prop("checked", false);
$(".stacked").hide();
$("input[name=\'width\']").hide();
$("#thresholdDiv").hide();
$(".thresholdDiv").hide();
} else if ($(this).val() == '.CUSTOM_GRAPH_BULLET_CHART.') {
$("#thresholdDiv").show();
$(".thresholdDiv").show();
$(".stacked").show();
$("input[name=\'width\']").show();
} else {
$("[name=threshold]").prop("checked", false);
$(".stacked").show();
$("input[name=\'width\']").show();
$("#thresholdDiv").hide();
$(".thresholdDiv").hide();
}
});

View File

@ -71,12 +71,6 @@ if ($is_enterprise !== ENTERPRISE_NOT_HOOK && $vconsoles_manage) {
'active' => false,
'text' => '<a href="'.$url_visual_console_template_wizard.'">'.html_print_image('images/wand.png', true, ['title' => __('Visual Console Template Wizard')]).'</a>',
];
if ($is_metaconsole) {
$buttons['visual_console_manager'] = [
'active' => false,
'text' => '<a href="'.$url_visual_console_manager.'">'.html_print_image('images/builder.png', true, ['title' => __('Visual Console Manager')]).'</a>',
];
}
}
if (!$is_metaconsole) {

View File

@ -170,6 +170,7 @@ if ($schedule_report != '') {
$parameters[4] = get_parameter('report_type', '');
$parameters['first_execution'] = strtotime($date.' '.$time);
$values = [
'id_usuario' => $config['id_user'],
'id_user_task' => $id_user_task,
@ -180,9 +181,11 @@ if ($schedule_report != '') {
$result = db_process_sql_insert('tuser_task_scheduled', $values);
$report_type = $parameters[4];
ui_print_result_message(
$result,
__('Your report has been planned, and the system will email you a PDF with the report as soon as its finished'),
__('Your report has been planned, and the system will email you a '.$report_type.' file with the report as soon as its finished'),
__('An error has ocurred')
);
echo '<br>';

View File

@ -64,13 +64,6 @@ if ($is_enterprise !== ENTERPRISE_NOT_HOOK && $vconsoles_manage) {
'active' => false,
'text' => '<a href="'.$url_visual_console_template_wizard.'">'.html_print_image('images/wand.png', true, ['title' => __('Visual Console Template Wizard')]).'</a>',
];
if ($is_metaconsole) {
$buttons['visual_console_manager'] = [
'active' => false,
'text' => '<a href="'.$url_visual_console_manager.'">'.html_print_image('images/builder.png', true, ['title' => __('Visual Console Manager')]).'</a>',
];
}
}
if (!$is_metaconsole) {

View File

@ -140,8 +140,8 @@ if (isset($_GET['server'])) {
ui_print_error_message(__('There was a problem deleting the server'));
}
} else if (isset($_GET['update'])) {
$address = get_parameter_post('address');
$description = get_parameter_post('description');
$address = trim(get_parameter_post('address'), '&#x20;');
$description = trim(get_parameter_post('description'), '&#x20;');
$id_server = get_parameter_post('server');
$exec_proxy = get_parameter_post('exec_proxy');
$port = get_parameter_post('port');

View File

@ -870,8 +870,8 @@ $row++;
$table_chars->data[$row][0] = __('Show only average');
$options_soft_graphs = [];
$options_soft_graphs[0] = __('Standard mode');
$options_soft_graphs[1] = __('Classic mode');
$options_soft_graphs[0] = __('Show only average by default');
$options_soft_graphs[1] = __('Show MAX/AVG/MIN by default');
$table_chars->data[$row][1] = html_print_select($options_soft_graphs, 'type_mode_graph', $config['type_mode_graph'], '', '', 0, true, false, false);
$row++;
@ -1342,6 +1342,15 @@ $row++;
$row++;
$decimal_separator = [
'.' => '.',
',' => ',',
];
$table_other->data[$row][0] = __('CSV decimal separator').ui_print_help_tip(__('Only for csv reports'), true);
$table_other->data[$row][1] = html_print_select($decimal_separator, 'csv_decimal_separator', $config['csv_decimal_separator'], '', '', '', true, false, false);
$row++;
$table_other->data[$row][0] = __('Data multiplier to use in graphs/data');
$options_data_multiplier = [];
$options_data_multiplier[0] = __('Use 1024 when module unit are bytes');

View File

@ -35,6 +35,10 @@ if ($delete != 0 && is_metaconsole()) {
open_meta_frame();
}
if ($tag_name != '' && is_metaconsole()) {
open_meta_frame();
}
// Metaconsole nodes
$servers = false;
if (is_metaconsole()) {
@ -182,7 +186,7 @@ $row[] = $filter_button;
$table->data[] = $row;
$filter_form = '<form method="POST" action="index.php?sec='.$sec.'&sec2=godmode/tag/tag&delete_tag=0">';
$filter_form = '<form method="POST" action="index.php?sec='.$sec.'&sec2=godmode/tag/tag&tag_name="'.$tag_name.'>';
$filter_form .= html_print_table($table, true);
$filter_form .= '</form>';
// End of filter form

View File

@ -112,14 +112,88 @@ if (! check_acl($config['id_user'], 0, 'UM')) {
return;
}
/*
* Disabled at the moment.
if (!check_referer()) {
require ("general/noaccess.php");
if (is_ajax()) {
$delete_profile = (bool) get_parameter('delete_profile');
if ($delete_profile) {
$id2 = (string) get_parameter('id_user');
$id_up = (int) get_parameter('id_user_profile');
return;
$perfilUser = db_get_row('tusuario_perfil', 'id_up', $id_up);
$id_perfil = $perfilUser['id_perfil'];
$perfil = db_get_row('tperfil', 'id_perfil', $id_perfil);
db_pandora_audit(
'User management',
'Deleted profile for user '.io_safe_input($id2),
false,
false,
'The profile with id '.$id_perfil.' in the group '.$perfilUser['id_grupo']
);
$return = profile_delete_user_profile($id2, $id_up);
ui_print_result_message(
$return,
__('Successfully deleted'),
__('Could not be deleted')
);
$has_profile = db_get_row('tusuario_perfil', 'id_usuario', $id2);
if ($has_profile == false) {
$result = delete_user($id2);
if ($result) {
db_pandora_audit(
'User management',
__('Deleted user %s', io_safe_input($id_user))
);
}
ui_print_result_message(
$result,
__('Successfully deleted'),
__('There was a problem deleting the user')
);
// Delete the user in all the consoles
if (defined('METACONSOLE')) {
$servers = metaconsole_get_servers();
foreach ($servers as $server) {
// Connect to the remote console
metaconsole_connect($server);
// Delete the user
$result = delete_user($id_user);
if ($result) {
db_pandora_audit(
'User management',
__('Deleted user %s from metaconsole', io_safe_input($id_user))
);
}
// Restore the db connection
metaconsole_restore_db();
// Log to the metaconsole too
if ($result) {
db_pandora_audit(
'User management',
__('Deleted user %s from %s', io_safe_input($id_user), io_safe_input($server['server_name']))
);
}
ui_print_result_message(
$result,
__('Successfully deleted from %s', io_safe_input($server['server_name'])),
__('There was a problem deleting the user from %s', io_safe_input($server['server_name']))
);
}
}
}
return;
}
*/
}
$tab = get_parameter('tab', 'user');
@ -168,9 +242,9 @@ if ($config['user_can_update_info']) {
$new_user = (bool) get_parameter('new_user');
$create_user = (bool) get_parameter('create_user');
$add_profile = (bool) get_parameter('add_profile');
$delete_profile = (bool) get_parameter('delete_profile');
$update_user = (bool) get_parameter('update_user');
$status = get_parameter('status', -1);
$json_profile = get_parameter('json_profile', '');
// Reset status var if current action is not update_user
if ($new_user || $create_user || $add_profile
@ -372,6 +446,41 @@ if ($create_user) {
$user_info = get_user_info($id);
$new_user = false;
if (!empty($json_profile)) {
$json_profile = json_decode(io_safe_output($json_profile), true);
foreach ($json_profile as $key => $profile) {
if (!empty($profile)) {
$group2 = $profile['group'];
$profile2 = $profile['profile'];
$tags = $profile['tags'];
foreach ($tags as $k => $tag) {
if (empty($tag)) {
unset($tags[$k]);
}
}
$tags = implode(',', $tags);
$no_hierarchy = $profile['hierarchy'];
db_pandora_audit(
'User management',
'Added profile for user '.io_safe_input($id2),
false,
false,
'Profile: '.$profile2.' Group: '.$group2.' Tags: '.$tags
);
$result_profile = profile_create_user_profile($id, $profile2, $group2, false, $tags, $no_hierarchy);
ui_print_result_message(
$result_profile,
__('Profile added successfully'),
__('Profile cannot be added')
);
}
}
}
} else {
$user_info = $values;
$new_user = true;
@ -598,7 +707,7 @@ if ($status != -1) {
);
}
if ($add_profile) {
if ($add_profile && empty($json_profile)) {
$id2 = (string) get_parameter('id');
$group2 = (int) get_parameter('assign_group');
$profile2 = (int) get_parameter('assign_profile');
@ -628,34 +737,38 @@ if ($add_profile) {
);
}
if ($delete_profile) {
$id2 = (string) get_parameter('id_user');
$id_up = (int) get_parameter('id_user_profile');
$perfilUser = db_get_row('tusuario_perfil', 'id_up', $id_up);
$id_perfil = $perfilUser['id_perfil'];
$perfil = db_get_row('tperfil', 'id_perfil', $id_perfil);
db_pandora_audit(
'User management',
'Deleted profile for user '.io_safe_input($id2),
false,
false,
'The profile with id '.$id_perfil.' in the group '.$perfilUser['id_grupo']
);
$return = profile_delete_user_profile($id2, $id_up);
ui_print_result_message(
$return,
__('Successfully deleted'),
__('Could not be deleted')
);
}
if ($values) {
$user_info = $values;
}
if (!users_is_admin() && $config['id_user'] != $id && !$new_user) {
$group_um = users_get_groups_UM($config['id_user']);
if (isset($group_um[0])) {
$group_um_string = implode(',', array_keys(users_get_groups($config['id_user'], 'um', true)));
} else {
$group_um_string = implode(',', array_keys($group_um));
}
$sql = sprintf(
"SELECT tusuario_perfil.* FROM tusuario_perfil
INNER JOIN tperfil ON tperfil.id_perfil = tusuario_perfil.id_perfil
WHERE id_usuario like '%s' AND id_grupo IN (%s) AND user_management = 0",
$id,
$group_um_string
);
$result = db_get_all_rows_sql($sql);
if ($result == false || $user_info['is_admin']) {
db_pandora_audit(
'ACL Violation',
'Trying to access User Management'
);
include 'general/noaccess.php';
return;
}
}
if (defined('METACONSOLE')) {
if ($id) {
echo '<div class="user_form_title">'.__('Update User').'</div>';
@ -762,19 +875,22 @@ if ($config['user_can_update_password']) {
$own_info = get_user_info($config['id_user']);
$global_profile = '<div class="label_select_simple user_global_profile" ><span class="input_label" style="margin:0;">'.__('Global Profile').'</span>';
$global_profile .= '<div class="switch_radio_button">';
$global_profile .= html_print_radio_button_extended(
'is_admin',
1,
[
'label' => __('Administrator'),
'help_tip' => __('This user has permissions to manage all. An admin user should not requiere additional group permissions, except for using Enterprise ACL.'),
],
$user_info['is_admin'],
false,
'',
'',
true
);
if (users_is_admin()) {
$global_profile .= html_print_radio_button_extended(
'is_admin',
1,
[
'label' => __('Administrator'),
'help_tip' => __('This user has permissions to manage all. An admin user should not requiere additional group permissions, except for using Enterprise ACL.'),
],
$user_info['is_admin'],
false,
'',
'',
true
);
}
$global_profile .= html_print_radio_button_extended(
'is_admin',
0,
@ -1027,7 +1143,7 @@ if ($meta) {
$metaconsole_access_node .= html_print_checkbox('metaconsole_access_node', 1, $user_info['metaconsole_access_node'], true).'</div>';
}
echo '<form method="post" autocomplete="off">';
echo '<form id="user_profile_form" method="post" autocomplete="off">';
if (!$id) {
@ -1067,14 +1183,19 @@ if (!is_metaconsole()) {
echo $search_custom_fields_view.$metaconsole_agents_manager.$metaconsole_assigned_server.$metaconsole_access_node;
}
echo '</div>
</div>
echo '</div>
</div>
<div class="user_edit_third_row white_box">
<div class="edit_user_comments">'.$comments.'</div>
</div>
<div class="user_edit_third_row white_box">'.$ehorus.'</div>
</div>';
if (!empty($ehorus)) {
echo '<div class="user_edit_third_row white_box">'.$ehorus.'</div>';
}
echo '</div>';
profile_print_profile_table($id);
echo '<div style="width: 100%" class="action-buttons">';
if ($config['admin_can_add_user']) {
@ -1088,16 +1209,15 @@ if ($config['admin_can_add_user']) {
}
}
html_print_input_hidden('json_profile', '');
echo '</div>';
echo '</form>';
echo '<br />';
// Don't show anything else if we're creating an user
if (!empty($id) && !$new_user) {
profile_print_profile_table($id);
}
enterprise_hook('close_meta_frame');
$delete_image = html_print_input_image('del', 'images/cross.png', 1, '', true, ['onclick' => 'delete_profile(event, this)']);
if (!is_metaconsole()) {
?>
@ -1132,13 +1252,14 @@ if (!is_metaconsole()) {
?>
<script type="text/javascript">
var json_profile = $('#hidden-json_profile');
/* <![CDATA[ */
$(document).ready (function () {
$('input:radio[name="is_admin"]').change(function() {
if($('#radiobtn0002').prop('checked')) {
$('#metaconsole_agents_manager_div').show();
$('#metaconsole_access_node_div').show();
if($('#checkbox-metaconsole_agents_manager').prop('checked')) {
if($('#checkbox-metaconsole_agents_manager').prop('checked')) {
$('#metaconsole_assigned_server_div').show();
}
}
@ -1167,8 +1288,105 @@ $(document).ready (function () {
});
$('#checkbox-ehorus_user_level_enabled').trigger('change');
var img_delete = '<?php echo $delete_image; ?>';
var id_user = '<?php echo $id; ?>';
var data = [];
$('input:image[name="add"]').click(function (e) {
e.preventDefault();
var profile = $('#assign_profile').val();
var profile_text = $('#assign_profile option:selected').text();
var group = $('#assign_group').val();
var group_text = $('#assign_group option:selected').text();
var tags = $('#assign_tags').val();
var tags_text = $('#assign_tags option:selected').toArray().map(item => item.text).join();
if ( $('#checkbox-no_hierarchy').is(':checked')) {
var hierarchy = 1;
var hierarchy_text = '<?php echo __('yes'); ?>';
} else {
var hierarchy = 0;
var hierarchy_text = '<?php echo __('no'); ?>';
}
if (profile === '0' || group === '-1') {
alert('<?php echo __('please select profile and group'); ?>');
return;
}
if (id_user === '') {
let new_json = `{"profile":${profile},"group":${group},"tags":[${tags}],"hierarchy":${hierarchy}}`;
data.push(new_json);
json_profile.val('['+data+']');
$('#table_profiles tr:last').before(
`<tr>
<td>${profile_text}</td>
<td>${group_text}</td>
<td>${tags_text}</td>
<td>${hierarchy_text}</td>
<td>${img_delete}</td>
</tr>`
);
} else {
this.form.submit();
}
});
$('input:image[name="del"]').click(function (e) {
e.preventDefault();
var rows = $("#table_profiles tr").length;
if (rows <= 3) {
if (!confirm('<?php echo __('Deleting last profile'); ?>' + '. ' + '<?php echo __('Are you sure?'); ?>')) {
return;
}
}
var id_user_profile = $(this).siblings();
id_user_profile = id_user_profile[1].value;
var row = $(this).closest('tr');
var params = [];
params.push("delete_profile=1");
params.push("id_user=" + id_user);
params.push("id_user_profile=" + id_user_profile);
params.push("page=godmode/users/configure_user");
jQuery.ajax ({
data: params.join ("&"),
type: 'POST',
url: action="<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
success: function (data) {
row.remove();
var rows = $("#table_profiles tr").length;
if (rows <= 2) {
window.location.replace("<?php echo ui_get_full_url('index.php?sec=gusuarios&sec2=godmode/users/user_list&tab=user&pure=0', false, false, false); ?>");
}
}
});
});
$('#submit-crtbutton').click(function (e) {
e.preventDefault();
var rows = $("#table_profiles tr").length;
if (rows <= 2) {
alert('<?php echo __('please add a profile'); ?>');
} else {
this.form.submit();
}
});
});
function delete_profile(event, btn) {
event.preventDefault();
var row = btn.parentNode.parentNode;
var position = row.rowIndex;
row.parentNode.removeChild(row);
var json = json_profile.val();
var test = JSON.parse(json);
delete test[position-1];
json_profile.val(JSON.stringify(test));
}
function show_data_section () {
section = $("#section").val();

View File

@ -356,10 +356,23 @@ if (!defined('METACONSOLE')) {
$table->valign[6] = 'top';
}
$group_um = users_get_groups_UM($config['id_user']);
if (isset($group_um[0])) {
$group_um_string = implode(',', array_keys(users_get_groups($config['id_user'], 'um', true)));
} else {
$group_um_string = implode(',', array_keys($group_um));
}
$info1 = [];
$info1 = get_users($order);
// Is admin or has group permissions all.
if (users_is_admin() || isset($group_um[0])) {
$info1 = get_users($order);
} else {
foreach ($group_um as $group => $value) {
$info1 = array_merge($info1, users_get_users_by_group($group, $value));
}
}
// Filter the users
if ($search) {
@ -400,33 +413,7 @@ if ($search) {
}
}
// ~
// ~ $filter_group
// ~ $filter_search
// ~
$info = [];
$own_info = get_user_info($config['id_user']);
$own_groups = users_get_groups($config['id_user'], 'AR', $own_info['is_admin']);
if ($own_info['is_admin']) {
$info = $info1;
}
// If user is not admin then don't display admin users and user of others groups.
else {
foreach ($info1 as $key => $usr) {
$u = get_user_info($key);
$g = users_get_groups($key, false, $u['is_admin']);
$result = array_intersect($g, $own_groups);
// Show users without profile too.
if (!empty($result) || (db_get_all_rows_field_filter('tusuario_perfil', 'id_usuario', $usr['id_user']) === false)) {
$info[$key] = $usr;
}
unset($u);
unset($g);
}
}
$info = $info1;
// Prepare pagination
ui_pagination(count($info));
@ -438,9 +425,41 @@ $rowPair = true;
$iterator = 0;
$cont = 0;
foreach ($info as $user_id => $user_info) {
if (!users_is_admin() && $user_info['is_admin']) {
// If user is not admin then don't display admin users.
continue;
}
// User profiles.
if (users_is_admin() || $user_id == $config['id_user']) {
$user_profiles = db_get_all_rows_field_filter('tusuario_perfil', 'id_usuario', $user_id);
} else {
$user_profiles_aux = users_get_user_profile($user_id);
$user_profiles = [];
foreach ($group_um as $key => $value) {
if (isset($user_profiles_aux[$key])) {
$user_profiles[$key] = $user_profiles_aux[$key];
if ($user_profiles_aux[$key]['user_management'] == 1) {
$user_info['edit'] = 0;
} else {
$user_info['edit'] = 1;
}
unset($user_profiles_aux[$key]);
}
}
if (!empty($user_profiles_aux)) {
$user_info['not_delete'] = 1;
}
if ($user_profiles == false) {
continue;
}
}
$cont++;
//
// Manual pagination due the complicated process of the ACL data
if ($cont <= $offset) {
continue;
@ -464,12 +483,14 @@ foreach ($info as $user_id => $user_info) {
$iterator++;
$data[0] = '<a href="index.php?sec='.$sec.'&amp;sec2=godmode/users/configure_user&pure='.$pure.'&amp;id='.$user_id.'">'.$user_id.'</a>';
if (users_is_admin() || $config['id_user'] == $user_info['id_user'] || (!$user_info['is_admin'] && (!isset($user_info['edit']) || (isset($user_info['edit']) && $user_info['edit'])))) {
$data[0] = '<a href="index.php?sec='.$sec.'&amp;sec2=godmode/users/configure_user&pure='.$pure.'&amp;id='.$user_id.'">'.$user_id.'</a>';
} else {
$data[0] = $user_id;
}
$data[1] = '<ul style="margin-top: 0 !important; margin-left: auto !important; padding-left: 10px !important; list-style-type: none !important;">';
$data[1] .= '<li>'.$user_info['fullname'].'</li>';
/*
$data[1] .= '<li><b>' . __('First name') . ':</b> ' . $user_info["firstname"] . '</li>';
$data[1] .= '<li><b>' . __('Last name') . ':</b> ' . $user_info["lastname"] . '</li>';*/
$data[1] .= '<li>'.$user_info['phone'].'</li>';
$data[1] .= '<li>'.$user_info['email'].'</li>';
$data[1] .= '</ul>';
@ -485,20 +506,14 @@ foreach ($info as $user_id => $user_info) {
]
).'&nbsp;';
} else {
/*
$data[3] = html_print_image ("images/user_green.png", true,
array ("alt" => __('User'),
"title" => __('Standard User'))) . '&nbsp;';
*/
$data[3] = '';
}
$data[4] = '';
$result = db_get_all_rows_field_filter('tusuario_perfil', 'id_usuario', $user_id);
if ($result !== false) {
if ($user_profiles !== false) {
if (defined('METACONSOLE')) {
$data[4] .= "<div width='100%'>";
foreach ($result as $row) {
foreach ($user_profiles as $row) {
$data[4] .= "<div style='float:left;'>";
$data[4] .= profile_get_name($row['id_perfil']);
$data[4] .= ' / </div>';
@ -512,7 +527,7 @@ foreach ($info as $user_id => $user_info) {
$data[4] .= '</div>';
} else {
$data[4] .= "<table width='100%'>";
foreach ($result as $row) {
foreach ($user_profiles as $row) {
$data[4] .= '<tr>';
$data[4] .= '<td>';
$data[4] .= profile_get_name($row['id_perfil']);
@ -531,21 +546,26 @@ foreach ($info as $user_id => $user_info) {
$data[5] = ui_print_string_substr($user_info['comments'], 24, true);
$table->cellclass[][6] = 'action_buttons';
if ($user_info['disabled'] == 0) {
$data[6] = '<a href="index.php?sec='.$sec.'&amp;sec2=godmode/users/user_list&amp;disable_user=1&pure='.$pure.'&amp;id='.$user_info['id_user'].'">'.html_print_image('images/lightbulb.png', true, ['title' => __('Disable')]).'</a>';
} else {
$data[6] = '<a href="index.php?sec='.$sec.'&amp;sec2=godmode/users/user_list&amp;disable_user=0&pure='.$pure.'&amp;id='.$user_info['id_user'].'">'.html_print_image('images/lightbulb_off.png', true, ['title' => __('Enable')]).'</a>';
}
$data[6] .= '<a href="index.php?sec='.$sec.'&amp;sec2=godmode/users/configure_user&pure='.$pure.'&amp;id='.$user_id.'">'.html_print_image('images/config.png', true, ['title' => __('Edit')]).'</a>';
if ($config['admin_can_delete_user'] && $user_info['id_user'] != $config['id_user']) {
$data[6] .= "<a href='index.php?sec=".$sec.'&sec2=godmode/users/user_list&user_del=1&pure='.$pure.'&delete_user='.$user_info['id_user']."'>".html_print_image('images/cross.png', true, ['title' => __('Delete'), 'onclick' => "if (! confirm ('".__('Deleting User').' '.$user_info['id_user'].'. '.__('Are you sure?')."')) return false"]).'</a>';
if (defined('METACONSOLE')) {
$data[6] .= "<a href='index.php?sec=".$sec.'&sec2=godmode/users/user_list&user_del=1&pure='.$pure.'&delete_user='.$user_info['id_user']."&delete_all=1'>".html_print_image('images/cross_double.png', true, ['title' => __('Delete from all consoles'), 'onclick' => "if (! confirm ('".__('Deleting User %s from all consoles', $user_info['id_user']).'. '.__('Are you sure?')."')) return false"]).'</a>';
$data[6] = '';
if (users_is_admin() || $config['id_user'] == $user_info['id_user'] || (!$user_info['is_admin'] && (!isset($user_info['edit']) || (isset($user_info['edit']) && $user_info['edit'])))) {
if (!isset($user_info['not_delete'])) {
if ($user_info['disabled'] == 0) {
$data[6] = '<a href="index.php?sec='.$sec.'&amp;sec2=godmode/users/user_list&amp;disable_user=1&pure='.$pure.'&amp;id='.$user_info['id_user'].'">'.html_print_image('images/lightbulb.png', true, ['title' => __('Disable')]).'</a>';
} else {
$data[6] = '<a href="index.php?sec='.$sec.'&amp;sec2=godmode/users/user_list&amp;disable_user=0&pure='.$pure.'&amp;id='.$user_info['id_user'].'">'.html_print_image('images/lightbulb_off.png', true, ['title' => __('Enable')]).'</a>';
}
}
$data[6] .= '<a href="index.php?sec='.$sec.'&amp;sec2=godmode/users/configure_user&pure='.$pure.'&amp;id='.$user_id.'">'.html_print_image('images/config.png', true, ['title' => __('Edit')]).'</a>';
if ($config['admin_can_delete_user'] && $user_info['id_user'] != $config['id_user'] && !isset($user_info['not_delete'])) {
$data[6] .= "<a href='index.php?sec=".$sec.'&sec2=godmode/users/user_list&user_del=1&pure='.$pure.'&delete_user='.$user_info['id_user']."'>".html_print_image('images/cross.png', true, ['title' => __('Delete'), 'onclick' => "if (! confirm ('".__('Deleting User').' '.$user_info['id_user'].'. '.__('Are you sure?')."')) return false"]).'</a>';
if (defined('METACONSOLE')) {
$data[6] .= "<a href='index.php?sec=".$sec.'&sec2=godmode/users/user_list&user_del=1&pure='.$pure.'&delete_user='.$user_info['id_user']."&delete_all=1'>".html_print_image('images/cross_double.png', true, ['title' => __('Delete from all consoles'), 'onclick' => "if (! confirm ('".__('Deleting User %s from all consoles', $user_info['id_user']).'. '.__('Are you sure?')."')) return false"]).'</a>';
}
} else {
$data[6] .= '';
// Delete button not in this mode
}
} else {
$data[6] .= '';
// Delete button not in this mode
}
array_push($table->data, $data);

View File

@ -871,6 +871,11 @@ if ($get_response_description) {
}
if ($get_response_params) {
if (! check_acl($config['id_user'], 0, 'EW')) {
echo 'unauthorized';
return;
}
$response_id = get_parameter('response_id');
$params = db_get_value('params', 'tevent_response', 'id', $response_id);
@ -885,6 +890,11 @@ if ($get_response_params) {
}
if ($get_response_target) {
if (! check_acl($config['id_user'], 0, 'EW')) {
echo 'unauthorized';
return;
}
$response_id = (int) get_parameter('response_id');
$event_id = (int) get_parameter('event_id');
$server_id = (int) get_parameter('server_id');
@ -901,6 +911,11 @@ if ($get_response_target) {
}
if ($get_response) {
if (! check_acl($config['id_user'], 0, 'EW')) {
echo 'unauthorized';
return;
}
$response_id = get_parameter('response_id');
$event_response = db_get_row('tevent_response', 'id', $response_id);
@ -917,6 +932,11 @@ if ($get_response) {
if ($perform_event_response) {
global $config;
if (! check_acl($config['id_user'], 0, 'EW')) {
echo 'unauthorized';
return;
}
$response_id = get_parameter('response_id');
$event_id = (int) get_parameter('event_id');
$server_id = (int) get_parameter('server_id', 0);
@ -1011,6 +1031,11 @@ if ($perform_event_response) {
if ($dialogue_event_response) {
global $config;
if (! check_acl($config['id_user'], 0, 'EW')) {
echo 'unauthorized';
return;
}
$event_id = get_parameter('event_id');
$response_id = get_parameter('response_id');
$command = get_parameter('target');

View File

@ -25,7 +25,7 @@ if (is_ajax()) {
$method = (string) get_parameter('method', '');
$action = (string) get_parameter('action', '');
$target_ip = (string) get_parameter('target_ip', '');
$community = (string) get_parameter('community', '');
$community = (string) io_safe_output((get_parameter('community', '')));
$snmp_version = (string) get_parameter('snmp_browser_version', '');
$snmp3_auth_user = io_safe_output(get_parameter('snmp3_browser_auth_user'));
$snmp3_security_level = get_parameter('snmp3_browser_security_level');

View File

@ -189,6 +189,7 @@ if (file_exists('languages/'.$user_language.'.mo') === true) {
echo '<div>';
switch ($type_graph_pdf) {
case 'combined':
$params['pdf'] = true;
echo graphic_combined_module(
$module_list,
$params,

View File

@ -1221,6 +1221,9 @@ class ConsoleSupervisor
// At this point there's no servers with issues.
$this->cleanNotifications('NOTIF.SERVER.STATUS%');
return;
} else {
// Clean notifications. Only show notif for down servers.
$this->cleanNotifications('NOTIF.SERVER.STATUS%');
}
foreach ($servers as $server) {

View File

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

View File

@ -3209,7 +3209,7 @@ function get_refresh_time_array()
}
function date2strftime_format($date_format)
function date2strftime_format($date_format, $timestamp=null)
{
$replaces_list = [
'D' => '%a',
@ -3232,11 +3232,14 @@ function date2strftime_format($date_format)
'A' => '%p',
'i' => '%M',
's' => '%S',
'u' => '%s',
'O' => '%z',
'T' => '%Z',
'%' => '%%',
'G' => '%k',
'z' => '%j',
'U' => '%s',
'c' => '%FT%T%z',
'r' => '%d %b %Y %H:%M:%S %z',
];
$return = '';
@ -3249,7 +3252,30 @@ function date2strftime_format($date_format)
if (isset($replaces_list[$c])) {
$return .= $replaces_list[$c];
} else {
$return .= $c;
// Check extra formats.
switch ($date_format) {
default: $return .= date($date_format, $timestamp);
break;
case 'n':
if (stristr(PHP_OS, 'win')) {
$return .= '%#m';
} else {
$return .= '%-m';
}
case 'u':
if (preg_match('/^[0-9]*\\.([0-9]+)$/', $timestamp, $reg)) {
$decimal = substr(str_pad($reg[1], 6, '0'), 0, 6);
} else {
$decimal = '000000';
}
$return .= $decimal;
break;
break;
}
}
}
@ -3623,6 +3649,14 @@ function color_graph_array()
}
/**
* Label graph Sparse.
*
* @param array $data Data chart.
* @param array $show_elements_graph Data visual styles chart.
*
* @return array Array label.
*/
function series_type_graph_array($data, $show_elements_graph)
{
global $config;
@ -3645,7 +3679,13 @@ function series_type_graph_array($data, $show_elements_graph)
$color_series = color_graph_array();
if ($show_elements_graph['id_widget_dashboard']) {
$opcion = unserialize(db_get_value_filter('options', 'twidget_dashboard', ['id' => $show_elements_graph['id_widget_dashboard']]));
$opcion = unserialize(
db_get_value_filter(
'options',
'twidget_dashboard',
['id' => $show_elements_graph['id_widget_dashboard']]
)
);
if ($show_elements_graph['graph_combined']) {
foreach ($show_elements_graph['modules_id'] as $key => $value) {
$color_series[$key] = [
@ -3674,13 +3714,15 @@ function series_type_graph_array($data, $show_elements_graph)
if (strpos($key, 'summatory') !== false) {
$data_return['series_type'][$key] = $type_graph;
$data_return['legend'][$key] = __('Summatory series').' '.$str;
$data_return['color'][$key] = $color_series['summatory'];
$data_return['legend'][$key] = __('Summatory series').' '.$str;
$data_return['color'][$key] = $color_series['summatory'];
} else if (strpos($key, 'average') !== false) {
$data_return['series_type'][$key] = $type_graph;
$data_return['legend'][$key] = __('Average series').' '.$str;
$data_return['color'][$key] = $color_series['average'];
} else if (strpos($key, 'sum') !== false || strpos($key, 'baseline') !== false) {
$data_return['legend'][$key] = __('Average series').' '.$str;
$data_return['color'][$key] = $color_series['average'];
} else if (strpos($key, 'sum') !== false
|| strpos($key, 'baseline') !== false
) {
switch ($value['id_module_type']) {
case 21:
case 2:
@ -3702,28 +3744,56 @@ function series_type_graph_array($data, $show_elements_graph)
&& (count($show_elements_graph['labels']) > 0)
) {
if ($show_elements_graph['unit']) {
$name_legend = $show_elements_graph['labels'][$value['agent_module_id']].' / '.__('Unit ').' '.$show_elements_graph['unit'].': ';
$data_return['legend'][$key] = $show_elements_graph['labels'][$value['agent_module_id']].' / '.__('Unit ').' '.$show_elements_graph['unit'].': ';
$name_legend = $show_elements_graph['labels'][$value['agent_module_id']];
$name_legend .= ' / ';
$name_legend .= __('Unit ').' ';
$name_legend .= $show_elements_graph['unit'].': ';
} else {
$name_legend = $show_elements_graph['labels'][$value['agent_module_id']].': ';
$data_return['legend'][$key] = $show_elements_graph['labels'][$value['agent_module_id']].': ';
}
} else {
if (strpos($key, 'baseline') !== false) {
if ($value['unit']) {
$name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].' / '.__('Unit ').' '.$value['unit'].'Baseline ';
$name_legend = $value['agent_alias'];
$name_legend .= ' / ';
$name_legend .= $value['module_name'];
$name_legend .= ' / ';
$name_legend .= __('Unit ').' ';
$name_legend .= $value['unit'].'Baseline ';
} else {
$name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].'Baseline ';
$name_legend = $value['agent_alias'];
$name_legend .= ' / ';
$name_legend .= $value['module_name'].'Baseline ';
}
} else {
$name_legend = '';
if ((int) $config['type_mode_graph'] === 1) {
$name_legend .= 'Avg: ';
}
if ($value['unit']) {
$name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].' / '.__('Unit ').' '.$value['unit'].': ';
$name_legend .= $value['agent_alias'];
$name_legend .= ' / ';
$name_legend .= $value['module_name'];
$name_legend .= ' / ';
$name_legend .= __('Unit ').' ';
$name_legend .= $value['unit'].': ';
} else {
$name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].': ';
$name_legend .= $value['agent_alias'];
$name_legend .= ' / ';
$name_legend .= $value['module_name'].': ';
}
}
}
if (isset($value['weight']) === true
&& empty($value['weight']) === false
) {
$name_legend .= ' ('.__('Weight');
$name_legend .= ' * '.$value['weight'].') ';
}
$data_return['legend'][$key] = $name_legend;
if ((int) $value['min'] === PHP_INT_MAX) {
$value['min'] = 0;
}
@ -3749,36 +3819,63 @@ function series_type_graph_array($data, $show_elements_graph)
)
).' '.$str;
if ($show_elements_graph['compare'] == 'overlapped' && $key == 'sum2') {
if ($show_elements_graph['compare'] == 'overlapped'
&& $key == 'sum2'
) {
$data_return['color'][$key] = $color_series['overlapped'];
} else {
$data_return['color'][$key] = $color_series[$i];
$i++;
}
} else if (!$show_elements_graph['fullscale'] && strpos($key, 'min') !== false
|| !$show_elements_graph['fullscale'] && strpos($key, 'max') !== false
} else if (!$show_elements_graph['fullscale']
&& strpos($key, 'min') !== false
|| !$show_elements_graph['fullscale']
&& strpos($key, 'max') !== false
) {
$data_return['series_type'][$key] = $type_graph;
$name_legend = '';
if ((int) $config['type_mode_graph'] === 1) {
if (strpos($key, 'min') !== false) {
$name_legend .= 'Min: ';
}
if (strpos($key, 'max') !== false) {
$name_legend .= 'Max: ';
}
}
if ($show_elements_graph['unit']) {
$name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].' / '.__('Unit ').' '.$show_elements_graph['unit'].': ';
$name_legend .= $value['agent_alias'];
$name_legend .= ' / ';
$name_legend .= $value['module_name'];
$name_legend .= ' / ';
$name_legend .= __('Unit ').' ';
$name_legend .= $show_elements_graph['unit'].': ';
} else {
$name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].': ';
$name_legend .= $value['agent_alias'];
$name_legend .= ' / ';
$name_legend .= $value['module_name'].': ';
}
$data_return['legend'][$key] = $name_legend;
if ($show_elements_graph['type_mode_graph']) {
$data_return['legend'][$key] .= __('Min:').remove_right_zeros(
$data_return['legend'][$key] .= __('Min:');
$data_return['legend'][$key] .= remove_right_zeros(
number_format(
$value['min'],
$config['graph_precision']
)
).' '.__('Max:').remove_right_zeros(
);
$data_return['legend'][$key] .= ' '.__('Max:');
$data_return['legend'][$key] .= remove_right_zeros(
number_format(
$value['max'],
$config['graph_precision']
)
).' '._('Avg:').remove_right_zeros(
);
$data_return['legend'][$key] .= ' '._('Avg:');
$data_return['legend'][$key] .= remove_right_zeros(
number_format(
$value['avg'],
$config['graph_precision']
@ -3786,7 +3883,9 @@ function series_type_graph_array($data, $show_elements_graph)
).' '.$str;
}
if ($show_elements_graph['compare'] == 'overlapped' && $key == 'sum2') {
if ($show_elements_graph['compare'] == 'overlapped'
&& $key == 'sum2'
) {
$data_return['color'][$key] = $color_series['overlapped'];
} else {
$data_return['color'][$key] = $color_series[$i];

View File

@ -12286,12 +12286,29 @@ function api_set_create_event($id, $trash1, $other, $returnType)
return;
}
if (!empty($other['data'][17]) && is_metaconsole()) {
$id_server = db_get_row_filter('tmetaconsole_setup', ['id' => $other['data'][17]]);
if ($id_server === false) {
returnError('error_create_event', __('Server id does not exist in database.'));
return;
}
$values['server_id'] = $other['data'][17];
} else {
$values['server_id'] = 0;
}
$error_msg = '';
if ($other['data'][2] != '') {
$id_agent = $other['data'][2];
if (is_metaconsole()) {
// On metaconsole, connect with the node to check the permissions
$agent_cache = db_get_row('tmetaconsole_agent', 'id_tagente', $id_agent);
if (empty($values['server_id'])) {
$agent_cache = db_get_row('tmetaconsole_agent', 'id_tagente', $id_agent);
} else {
$agent_cache = db_get_row_filter('tmetaconsole_agent', ['id_tagente' => $id_agent, 'id_tmetaconsole_setup' => $values['server_id']]);
}
if ($agent_cache === false) {
returnError('id_not_found', 'string');
return;
@ -12420,12 +12437,6 @@ function api_set_create_event($id, $trash1, $other, $returnType)
$values['custom_data'] = '';
}
if ($other['data'][17] != '') {
$values['server_id'] = $other['data'][17];
} else {
$values['server_id'] = 0;
}
if ($other['data'][18] != '') {
$values['id_extra'] = $other['data'][18];
$sql_validation = 'SELECT id_evento FROM tevento where estado IN (0,2) and id_extra ="'.$other['data'][18].'";';
@ -16151,3 +16162,38 @@ function api_get_event_mcid($server_id, $console_event_id, $trash2, $returnType)
return;
}
}
/**
* Function to set events in progress status.
*
* @param [int] $event_id Id event (Node or Meta).
* @param [string] $trash2 don't use.
* @param [string] $returnType
*
* Example
* http://127.0.0.1/pandora_console/include/api.php?op=set&op2=event_in_progress&return_type=json&id=0&apipass=1234&user=admin&pass=pandora
*
* @return void
*/
function api_set_event_in_progress($event_id, $trash2, $returnType)
{
global $config;
if (is_metaconsole()) {
$table = 'tmetaconsole_event';
} else {
$table = 'tevento';
}
$event = db_process_sql_update(
$table,
['estado' => 2],
['id_evento' => $event_id]
);
if ($event !== false) {
returnData('string', ['data' => $event]);
} else {
returnError('id_not_found', 'string');
}
}

View File

@ -1340,6 +1340,10 @@ function config_update_config()
$error_update[] = __('CSV divider');
}
if (!config_update_value('csv_decimal_separator', (string) get_parameter('csv_decimal_separator', '.'))) {
$error_update[] = __('CSV decimal separator');
}
if (!config_update_value('use_data_multiplier', get_parameter('use_data_multiplier', '1'))) {
$error_update[] = __('Use data multiplier');
}
@ -2875,6 +2879,10 @@ function config_process_config()
config_update_value('csv_divider', ';');
}
if (!isset($config['csv_decimal_separator'])) {
config_update_value('csv_decimal_separator', '.');
}
if (!isset($config['use_data_multiplier'])) {
config_update_value('use_data_multiplier', '1');
}

View File

@ -2118,7 +2118,7 @@ function events_comment(
switch ($comments_format) {
case 'new':
$comment_for_json['comment'] = $comment;
$comment_for_json['comment'] = io_safe_input($comment);
$comment_for_json['action'] = $action;
$comment_for_json['id_user'] = $config['id_user'];
$comment_for_json['utimestamp'] = time();
@ -2141,7 +2141,7 @@ function events_comment(
$comment = str_replace(["\r\n", "\r", "\n"], '<br>', $comment);
if ($comment != '') {
$commentbox = '<div style="border:1px dotted #CCC; min-height: 10px;">'.$comment.'</div>';
$commentbox = '<div style="border:1px dotted #CCC; min-height: 10px;">'.io_safe_input($comment).'</div>';
} else {
$commentbox = '';
}
@ -3377,7 +3377,7 @@ function events_page_responses($event, $childrens_ids=[])
);
if ($strict_user) {
$user_name = db_get_value(
'fullname',
'id_user',
'tusuario',
'id_user',
$config['id_user']
@ -3395,14 +3395,14 @@ function events_page_responses($event, $childrens_ids=[])
}
foreach ($users as $u) {
$owners[$u['id_user']] = $u['fullname'];
$owners[$u['id_user']] = $u['id_user'];
}
if ($event['owner_user'] == '') {
$owner_name = __('None');
} else {
$owner_name = db_get_value(
'fullname',
'id_user',
'tusuario',
'id_user',
$event['owner_user']
@ -3424,7 +3424,7 @@ function events_page_responses($event, $childrens_ids=[])
'owner_button',
false,
'event_change_owner();',
'class="sub next"',
'class="sub next w70p"',
true
);
@ -3504,7 +3504,7 @@ function events_page_responses($event, $childrens_ids=[])
'status_button',
false,
'event_change_status(\''.$event['similar_ids'].'\');',
'class="sub next"',
'class="sub next w70p"',
true
);
}
@ -3520,7 +3520,7 @@ function events_page_responses($event, $childrens_ids=[])
'comment_button',
false,
'$(\'#link_comments\').trigger(\'click\');',
'class="sub next"',
'class="sub next w70p"',
true
);
@ -3544,7 +3544,7 @@ function events_page_responses($event, $childrens_ids=[])
'delete_button',
false,
'if(!confirm(\''.__('Are you sure?').'\')) { return false; } this.form.submit();',
'class="sub cancel"',
'class="sub cancel w70p"',
true
);
$data[2] .= html_print_input_hidden('delete', 1, true);
@ -3599,7 +3599,7 @@ function events_page_responses($event, $childrens_ids=[])
'custom_response_button',
false,
'execute_response('.$event['id_evento'].','.$server_id.')',
"class='sub next'",
"class='sub next w70p'",
true
);
}

View File

@ -36,7 +36,8 @@ function forecast_projection_graph(
$prediction_period,
$max_value=false,
$min_value=false,
$csv=false
$csv=false,
$server_name=''
) {
global $config;
@ -55,7 +56,7 @@ function forecast_projection_graph(
'projection' => true,
];
$module_data = grafico_modulo_sparse($params);
$module_data = grafico_modulo_sparse($params, $server_name);
if (empty($module_data)) {
return [];
@ -252,12 +253,13 @@ function forecast_prediction_date(
$module_id,
$period=SECONDS_2MONTHS,
$max_value=0,
$min_value=0
$min_value=0,
$server_name=''
) {
// Checks interval
if ($min_value > $max_value) {
return false;
}
return forecast_projection_graph($module_id, $period, false, $max_value, $min_value);
return forecast_projection_graph($module_id, $period, false, $max_value, $min_value, false, $server_name);
}

View File

@ -616,7 +616,7 @@ function grafico_modulo_sparse_data(
*
* @return string html Content graphs.
*/
function grafico_modulo_sparse($params)
function grafico_modulo_sparse($params, $server_name='')
{
global $config;
@ -812,6 +812,12 @@ function grafico_modulo_sparse($params)
$date_array['final_date'] = $params['date'];
$date_array['start_date'] = ($params['date'] - $params['period']);
if (is_metaconsole()) {
$id_meta = metaconsole_get_id_server($server_name);
$server = metaconsole_get_connection_by_id($id_meta);
metaconsole_connect($server);
}
if ($agent_module_id) {
$module_data = db_get_row_sql(
'SELECT * FROM tagente_modulo
@ -1022,6 +1028,10 @@ function grafico_modulo_sparse($params)
}
}
if (is_metaconsole()) {
metaconsole_restore_db();
}
return $return;
}
@ -1483,6 +1493,11 @@ function graphic_combined_module(
continue;
}
// Only 10 item for chart.
if ($i > 9) {
break;
}
if (is_metaconsole()) {
$server = metaconsole_get_connection_by_id(
$agent_module_id['server']
@ -1560,15 +1575,19 @@ function graphic_combined_module(
foreach ($value['data'] as $k => $v) {
if ($v[1] != false) {
$array_data[$key]['data'][$k][1] = ($v[1] * $params_combined['weight_list'][$i]);
$array_data[$key]['slice_data'][$v[0]]['avg'] *= $params_combined['weight_list'][$i];
$array_data[$key]['slice_data'][$v[0]]['min'] *= $params_combined['weight_list'][$i];
$array_data[$key]['slice_data'][$v[0]]['max'] *= $params_combined['weight_list'][$i];
}
}
$array_data[$key]['max'] *= $params_combined['weight_list'][$i];
$array_data[$key]['min'] *= $params_combined['weight_list'][$i];
$array_data[$key]['avg'] *= $params_combined['weight_list'][$i];
$array_data[$key]['weight'] = $params_combined['weight_list'][$i];
}
}
$max = $array_data['sum'.$i]['max'];
$min = $array_data['sum'.$i]['min'];
$avg = $array_data['sum'.$i]['avg'];
if ($config['fixed_graph'] == false) {
$water_mark = [
'file' => $config['homedir'].'/images/logo_vertical_water.png',
@ -1822,28 +1841,23 @@ function graphic_combined_module(
}
foreach ($module_list as $module_item) {
$automatic_custom_graph_meta = false;
if ($config['metaconsole']) {
if (is_metaconsole() === true) {
// Automatic custom graph from the report
// template in metaconsole.
if (is_array($module_list[$i])) {
$server = metaconsole_get_connection_by_id(
$module_item['server']
);
metaconsole_connect($server);
$automatic_custom_graph_meta = true;
}
}
if ($automatic_custom_graph_meta) {
$module = $module_item['module'];
} else {
$module = $module_item;
$server = metaconsole_get_connection_by_id(
$module_item['server']
);
metaconsole_connect($server);
}
$module = $module_item['module'];
$search_in_history_db = db_search_in_history_db($datelimit);
$temp[$module] = io_safe_output(modules_get_agentmodule($module));
$temp[$module] = io_safe_output(
modules_get_agentmodule($module)
);
$query_last_value = sprintf(
'
SELECT datos
@ -1908,12 +1922,8 @@ function graphic_combined_module(
$temp[$module]['min'] = ($temp_min === false) ? 0 : $temp_min;
if ($config['metaconsole']) {
// Automatic custom graph from the
// report template in metaconsole.
if (is_array($module_list[0])) {
metaconsole_restore_db();
}
if (is_metaconsole() === true) {
metaconsole_restore_db();
}
}
@ -1958,25 +1968,15 @@ function graphic_combined_module(
$i = 0;
$number_elements = count($module_list);
foreach ($module_list as $module_item) {
$automatic_custom_graph_meta = false;
if ($config['metaconsole']) {
// Automatic custom graph from
// the report template in metaconsole.
if (is_array($module_list[$i])) {
$server = metaconsole_get_connection_by_id(
$module_item['server']
);
metaconsole_connect($server);
$automatic_custom_graph_meta = true;
}
}
if ($automatic_custom_graph_meta) {
$module = $module_item['module'];
} else {
$module = $module_item;
if (is_metaconsole() === true) {
$server = metaconsole_get_connection_by_id(
$module_item['server']
);
metaconsole_connect($server);
}
$module = $module_item['module'];
$temp[$module] = modules_get_agentmodule($module);
$query_last_value = sprintf(
'
@ -2032,12 +2032,8 @@ function graphic_combined_module(
$temp[$module]['gauge'] = uniqid('gauge_');
if ($config['metaconsole']) {
// Automatic custom graph from the report
// template in metaconsole.
if (is_array($module_list[0])) {
metaconsole_restore_db();
}
if (is_metaconsole() === true) {
metaconsole_restore_db();
}
$i++;
@ -2062,6 +2058,12 @@ function graphic_combined_module(
}
}
if (isset($params['pdf']) === true && $params['pdf'] === true) {
$transitionDuration = 0;
} else {
$transitionDuration = 500;
}
$output = stacked_gauge(
$graph_values,
$new_width,
@ -2077,7 +2079,8 @@ function graphic_combined_module(
$config['fontpath'],
$fixed_font_size,
'',
$homeurl
$homeurl,
$transitionDuration
);
break;
@ -2085,25 +2088,15 @@ function graphic_combined_module(
case CUSTOM_GRAPH_VBARS:
$label = '';
foreach ($module_list as $module_item) {
$automatic_custom_graph_meta = false;
if (is_metaconsole() === true) {
// Automatic custom graph from the report
// template in metaconsole.
if (is_array($module_list[$i]) === true) {
$server = metaconsole_get_connection_by_id(
$module_item['server']
);
metaconsole_connect($server);
$automatic_custom_graph_meta = true;
}
}
if ($automatic_custom_graph_meta === true) {
$module = $module_item['module'];
} else {
$module = $module_item;
$server = metaconsole_get_connection_by_id(
$module_item['server']
);
metaconsole_connect($server);
}
$module = $module_item['module'];
$module_data = modules_get_agentmodule($module);
$query_last_value = sprintf(
'SELECT datos
@ -2152,11 +2145,7 @@ function graphic_combined_module(
}
if (is_metaconsole() === true) {
// Automatic custom graph from the report
// template in metaconsole.
if (is_array($module_list[0]) === true) {
metaconsole_restore_db();
}
metaconsole_restore_db();
}
}
@ -2226,29 +2215,18 @@ function graphic_combined_module(
case CUSTOM_GRAPH_PIE:
$total_modules = 0;
foreach ($module_list as $module_item) {
$automatic_custom_graph_meta = false;
if ($config['metaconsole']) {
// Automatic custom graph from the report
// template in metaconsole.
if (is_array($module_list[$i])) {
$server = metaconsole_get_connection_by_id(
$module_item['server']
);
metaconsole_connect($server);
$automatic_custom_graph_meta = true;
}
}
if ($automatic_custom_graph_meta) {
$module = $module_item['module'];
} else {
$module = $module_item;
if (is_metaconsole() === true) {
$server = metaconsole_get_connection_by_id(
$module_item['server']
);
metaconsole_connect($server);
}
$module = $module_item['module'];
$data_module = modules_get_agentmodule($module);
$query_last_value = sprintf(
'
SELECT datos
'SELECT datos
FROM tagente_datos
WHERE id_agente_modulo = %d
AND utimestamp > %d
@ -2293,12 +2271,9 @@ function graphic_combined_module(
'value' => $value,
'unit' => $data_module['unit'],
];
if ($config['metaconsole']) {
// Automatic custom graph from the report
// template in metaconsole.
if (is_array($module_list[0])) {
metaconsole_restore_db();
}
if (is_metaconsole() === true) {
metaconsole_restore_db();
}
}

View File

@ -737,7 +737,11 @@ function html_print_select_multiple_filtered(
array $sections=[]
) {
ui_require_css_file('multiselect_filtered');
ui_require_javascript_file('multiselect_filtered');
if (is_ajax() === true) {
ui_require_javascript_file('multiselect_filtered', 'include/javascript/', true);
} else {
ui_require_javascript_file('multiselect_filtered');
}
if (empty($name) === true) {
$rid = uniqid();
@ -1833,13 +1837,14 @@ function html_print_input_text_extended(
$alt,
$size,
$maxlength,
$disabled,
$readonly,
$script,
$attributes,
$return=false,
$password=false,
$function='',
$autocomplete='off'
$autocomplete='off',
$disabled=false
) {
static $idcounter = 0;
@ -1895,10 +1900,14 @@ function html_print_input_text_extended(
$output = '<input '.($password ? 'type="password" autocomplete="'.$autocomplete.'" ' : 'type="text" ');
if ($disabled && (!is_array($attributes) || !array_key_exists('disabled', $attributes))) {
if ($readonly && (!is_array($attributes) || !array_key_exists('readonly', $attributes))) {
$output .= 'readonly="readonly" ';
}
if ($disabled && (!is_array($attributes) || !array_key_exists('disabled', $attributes))) {
$output .= 'disabled="disabled" ';
}
if (is_array($attributes)) {
foreach ($attributes as $attribute => $attr_value) {
if (! in_array($attribute, $valid_attrs)) {
@ -2102,7 +2111,7 @@ function html_print_input_text(
$size=50,
$maxlength=255,
$return=false,
$disabled=false,
$readonly=false,
$required=false,
$function='',
$class='',
@ -2111,7 +2120,8 @@ function html_print_input_text(
$autofocus=false,
$onKeyDown='',
$formTo='',
$onKeyUp=''
$onKeyUp='',
$disabled=false
) {
if ($maxlength == 0) {
$maxlength = 255;
@ -2163,12 +2173,14 @@ function html_print_input_text(
$alt,
$size,
$maxlength,
$disabled,
$readonly,
'',
$attr,
$return,
false,
$function
$function,
'off',
$disabled
);
}
@ -2661,8 +2673,16 @@ 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='', $disable=false)
{
function html_print_textarea(
$name,
$rows,
$columns,
$value='',
$attributes='',
$return=false,
$class='',
$disable=false
) {
$disabled = ($disable) ? 'disabled' : '';
$output = '<textarea id="textarea_'.$name.'" name="'.$name.'" cols="'.$columns.'" rows="'.$rows.'" '.$attributes.' class="'.$class.'" '.$disabled.'>';
$output .= ($value);
@ -3023,7 +3043,11 @@ function html_print_table(&$table, $return=false)
$style[$key] = '';
}
$output .= '<td id="'.$tableid.'-'.$keyrow.'-'.$key.'" style="'.$cellstyle[$keyrow][$key].$style[$key].$valign[$key].$align[$key].$size[$key].$wrap[$key].'" '.$colspan[$keyrow][$key].' '.$rowspan[$keyrow][$key].' class="'.$class.' '.$cellclass[$keyrow][$key].'">'.$item.'</td>'."\n";
if ($class === 'datos5' && $key === 1) {
$output .= '<td id="'.$tableid.'-'.$keyrow.'-'.$key.'" style="'.$cellstyle[$keyrow][$key].$style[$key].$valign[$key].$align[$key].$size[$key].$wrap[$key].$colspan[$keyrow][$key].' '.$rowspan[$keyrow][$key].' class="'.$class.' '.$cellclass[$keyrow][$key].'">'.$item.'</td>'."\n";
} else {
$output .= '<td id="'.$tableid.'-'.$keyrow.'-'.$key.'" style="'.$cellstyle[$keyrow][$key].$style[$key].$valign[$key].$align[$key].$size[$key].$wrap[$key].'" '.$colspan[$keyrow][$key].' '.$rowspan[$keyrow][$key].' class="'.$class.' '.$cellclass[$keyrow][$key].'">'.$item.'</td>'."\n";
}
}
$output .= '</tr>'."\n";
@ -3855,21 +3879,16 @@ function html_print_timezone_select($name, $selected='')
* Enclose a text into a result_div
*
* @param string Text to enclose
* @param boolean Return formatted text without html tags.
*
* @return string Text inside the result_div
*/
function html_print_result_div($text, $text_only)
function html_print_result_div($text)
{
$text = preg_replace('/</', '&lt;', $text);
$text = preg_replace('/>/', '&gt;', $text);
$text = preg_replace('/\n/i', '<br>', $text);
$text = preg_replace('/\s/i', '&nbsp;', $text);
if ($text_only) {
return $text;
}
$enclose = "<div id='result_div' style='width: 100%; height: 100%; overflow: auto; padding: 10px; font-size: 14px; line-height: 16px; font-family: mono,monospace; text-align: left'>";
$enclose .= $text;
$enclose .= '</div>';

View File

@ -188,6 +188,7 @@ function profile_print_profile_table($id)
$title = __('Profiles/Groups assigned to this user');
$table = new stdClass();
$table->id = 'table_profiles';
$table->width = '100%';
$table->class = 'info_table';
if (defined('METACONSOLE')) {
@ -216,10 +217,30 @@ function profile_print_profile_table($id)
$table->head['actions'] = __('Action');
$table->align['actions'] = 'center';
$result = db_get_all_rows_filter(
'tusuario_perfil',
['id_usuario' => $id]
);
if (users_is_admin()) {
$result = db_get_all_rows_filter(
'tusuario_perfil',
['id_usuario' => $id]
);
} else {
// Only profiles that can be viewed by the user.
$group_um = users_get_groups_UM($config['id_user']);
if (isset($group_um[0])) {
$group_um_string = implode(',', array_keys(users_get_groups($config['id_user'], 'um', true)));
} else {
$group_um_string = implode(',', array_keys($group_um));
}
$sql = sprintf(
"SELECT tusuario_perfil.* FROM tusuario_perfil
INNER JOIN tperfil ON tperfil.id_perfil = tusuario_perfil.id_perfil
WHERE id_usuario like '%s' AND id_grupo IN (%s) AND user_management = 0",
$id,
$group_um_string
);
$result = db_get_all_rows_sql($sql);
}
if ($result === false) {
$result = [];
@ -285,6 +306,7 @@ function profile_print_profile_table($id)
[
'pandora_management' => '<> 1',
'db_management' => '<> 1',
'user_management' => '<> 1',
]
),
'assign_profile',

View File

@ -4664,7 +4664,7 @@ function reporting_prediction_date($report, $content)
$max_interval = $intervals_text[0];
$min_interval = $intervals_text[1];
$value = forecast_prediction_date($content['id_agent_module'], $content['period'], $max_interval, $min_interval);
$value = forecast_prediction_date($content['id_agent_module'], $content['period'], $max_interval, $min_interval, $content['server_name']);
if ($value === false) {
$return['data']['value'] = __('Unknown');
@ -7506,40 +7506,57 @@ function reporting_general($report, $content)
if ($content['period'] == 0) {
$data_res[$index] = modules_get_last_value($row['id_agent_module']);
} else {
if (is_numeric($type_mod) && !$is_string[$index]) {
switch ($row['operation']) {
case 'sum':
$data_res[$index] = reporting_get_agentmodule_data_sum(
$row['id_agent_module'],
$content['period'],
$report['datetime']
);
break;
$data_sum = reporting_get_agentmodule_data_sum(
$row['id_agent_module'],
$content['period'],
$report['datetime']
);
case 'max':
$data_res[$index] = reporting_get_agentmodule_data_max(
$row['id_agent_module'],
$content['period']
);
break;
$data_max = reporting_get_agentmodule_data_max(
$row['id_agent_module'],
$content['period']
);
case 'min':
$data_res[$index] = reporting_get_agentmodule_data_min(
$row['id_agent_module'],
$content['period']
);
break;
$data_min = reporting_get_agentmodule_data_min(
$row['id_agent_module'],
$content['period']
);
case 'avg':
default:
$data_res[$index] = reporting_get_agentmodule_data_average(
$row['id_agent_module'],
$content['period']
);
break;
}
$data_avg = reporting_get_agentmodule_data_average(
$row['id_agent_module'],
$content['period']
);
if ($content['style']['show_in_same_row'] && $content['group_by_agent'] == REPORT_GENERAL_NOT_GROUP_BY_AGENT) {
$data_res[$index] = [
$data_avg,
$data_max,
$data_min,
$data_sum,
];
} else {
$data_res[$index] = $type_mod;
if (is_numeric($type_mod) && !$is_string[$index]) {
switch ($row['operation']) {
case 'sum':
$data_res[$index] = $data_sum;
break;
case 'max':
$data_res[$index] = $data_max;
break;
case 'min':
$data_res[$index] = $data_min;
break;
case 'avg':
default:
$data_res[$index] = $data_avg;
break;
}
} else {
$data_res[$index] = $type_mod;
}
}
}
@ -7581,44 +7598,89 @@ function reporting_general($report, $content)
break;
}
// Calculate the avg, min and max
if (is_numeric($data_res[$index]) && !$is_string[$index]) {
$change_min = false;
if (is_null($return['min']['value'])) {
$change_min = true;
} else {
if ($return['min']['value'] > $data_res[$index]) {
if ($content['style']['show_in_same_row']) {
foreach ($data_res[$index] as $val) {
// Calculate the avg, min and max
if (is_numeric($val)) {
$change_min = false;
if (is_null($return['min']['value'])) {
$change_min = true;
} else {
if ($return['min']['value'] > $val) {
$change_min = true;
}
}
if ($change_min) {
$return['min']['value'] = $val;
$return['min']['formated_value'] = format_for_graph($val, 2, '.', ',', $divisor, $unit);
$return['min']['agent'] = $ag_name;
$return['min']['module'] = $mod_name;
}
$change_max = false;
if (is_null($return['max']['value'])) {
$change_max = true;
} else {
if ($return['max']['value'] < $val) {
$change_max = true;
}
}
if ($change_max) {
$return['max']['value'] = $val;
$return['max']['formated_value'] = format_for_graph($val, 2, '.', ',', $divisor, $unit);
$return['max']['agent'] = $ag_name;
$return['max']['module'] = $mod_name;
}
if ($i == 0) {
$return['avg_value'] = $val;
} else {
$return['avg_value'] = ((($return['avg_value'] * $i) / ($i + 1)) + ($val / ($i + 1)));
}
}
}
} else {
// Calculate the avg, min and max
if (is_numeric($data_res[$index]) && !$is_string[$index]) {
$change_min = false;
if (is_null($return['min']['value'])) {
$change_min = true;
} else {
if ($return['min']['value'] > $data_res[$index]) {
$change_min = true;
}
}
}
if ($change_min) {
$return['min']['value'] = $data_res[$index];
$return['min']['formated_value'] = format_for_graph($data_res[$index], 2, '.', ',', $divisor, $unit);
$return['min']['agent'] = $ag_name;
$return['min']['module'] = $mod_name;
}
if ($change_min) {
$return['min']['value'] = $data_res[$index];
$return['min']['formated_value'] = format_for_graph($data_res[$index], 2, '.', ',', $divisor, $unit);
$return['min']['agent'] = $ag_name;
$return['min']['module'] = $mod_name;
}
$change_max = false;
if (is_null($return['max']['value'])) {
$change_max = true;
} else {
if ($return['max']['value'] < $data_res[$index]) {
$change_max = false;
if (is_null($return['max']['value'])) {
$change_max = true;
} else {
if ($return['max']['value'] < $data_res[$index]) {
$change_max = true;
}
}
}
if ($change_max) {
$return['max']['value'] = $data_res[$index];
$return['max']['formated_value'] = format_for_graph($data_res[$index], 2, '.', ',', $divisor, $unit);
$return['max']['agent'] = $ag_name;
$return['max']['module'] = $mod_name;
}
if ($change_max) {
$return['max']['value'] = $data_res[$index];
$return['max']['formated_value'] = format_for_graph($data_res[$index], 2, '.', ',', $divisor, $unit);
$return['max']['agent'] = $ag_name;
$return['max']['module'] = $mod_name;
}
if ($i == 0) {
$return['avg_value'] = $data_res[$index];
} else {
$return['avg_value'] = ((($return['avg_value'] * $i) / ($i + 1)) + ($data_res[$index] / ($i + 1)));
if ($i == 0) {
$return['avg_value'] = $data_res[$index];
} else {
$return['avg_value'] = ((($return['avg_value'] * $i) / ($i + 1)) + ($data_res[$index] / ($i + 1)));
}
}
}
@ -7693,50 +7755,87 @@ function reporting_general($report, $content)
$data['id_module_type'] = $id_module_types[$i];
$data['operator'] = '';
if ($content['period'] != 0) {
switch ($operations[$i]) {
case 'sum':
$data['operator'] = __('Summatory');
break;
if ($content['style']['show_in_same_row']) {
$data['operator'] = 'all';
} else {
switch ($operations[$i]) {
case 'sum':
$data['operator'] = __('Summatory');
break;
case 'min':
$data['operator'] = __('Minimum');
break;
case 'min':
$data['operator'] = __('Minimum');
break;
case 'max':
$data['operator'] = __('Maximum');
break;
case 'max':
$data['operator'] = __('Maximum');
break;
case 'avg':
default:
$data['operator'] = __('Rate');
break;
case 'avg':
default:
$data['operator'] = __('Rate');
break;
}
}
}
if ($d === false) {
$data['value'] = null;
} else {
switch ($config['dbtype']) {
case 'mysql':
case 'postgresql':
break;
if ($content['style']['show_in_same_row']) {
foreach ($d as $val) {
if ($val === false) {
$data['value'][] = null;
} else {
switch ($config['dbtype']) {
case 'mysql':
case 'postgresql':
break;
case 'oracle':
if (preg_match('/[0-9]+,[0-9]E+[+-][0-9]+/', $d)) {
$d = oracle_format_float_to_php($d);
case 'oracle':
if (preg_match('/[0-9]+,[0-9]E+[+-][0-9]+/', $val)) {
$val = oracle_format_float_to_php($val);
}
break;
}
break;
$divisor = get_data_multiplier($units[$i]);
if (!is_numeric($val) || $is_string[$i]) {
$data['value'][] = $val;
// to see the chains on the table
$data['formated_value'][] = $val;
} else {
$data['value'][] = $val;
$data['formated_value'][] = format_for_graph($val, 2, '.', ',', $divisor, $units[$i]);
}
}
}
$divisor = get_data_multiplier($units[$i]);
if (!is_numeric($d) || $is_string[$i]) {
$data['value'] = $d;
// to see the chains on the table
$data['formated_value'] = $d;
} else {
if ($d === false) {
$data['value'] = null;
} else {
$data['value'] = $d;
$data['formated_value'] = format_for_graph($d, 2, '.', ',', $divisor, $units[$i]);
switch ($config['dbtype']) {
case 'mysql':
case 'postgresql':
break;
case 'oracle':
if (preg_match('/[0-9]+,[0-9]E+[+-][0-9]+/', $d)) {
$d = oracle_format_float_to_php($d);
}
break;
}
$divisor = get_data_multiplier($units[$i]);
if (!is_numeric($d) || $is_string[$i]) {
$data['value'] = $d;
// to see the chains on the table
$data['formated_value'] = $d;
} else {
$data['value'] = $d;
$data['formated_value'] = format_for_graph($d, 2, '.', ',', $divisor, $units[$i]);
}
}
}
@ -11640,7 +11739,6 @@ function reporting_get_stats_servers()
$table_srv->style[1] = $table_srv->style[3] = 'text-align: left; padding: 5px;';
$tdata = [];
'<span class="big_data">'.format_numeric($server_performance['total_local_modules']).'</span>';
$tdata[0] = html_print_image('images/module.png', true, ['title' => __('Total running modules')]);
$tdata[1] = '<span class="big_data">'.format_numeric($server_performance['total_modules']).'</span>';
$tdata[2] = '<span class="med_data">'.format_numeric($server_performance['total_modules_rate'], 2).'</span>';
@ -11747,12 +11845,6 @@ function reporting_get_stats_servers()
);
$tdata[1] = '<span class="big_data" id="total_events">'.html_print_image('images/spinner.gif', true).'</span>';
/*
Hello there! :)
We added some of what seems to be "buggy" messages to the openSource version recently. This is not to force open-source users to move to the enterprise version, this is just to inform people using Pandora FMS open source that it requires skilled people to maintain and keep it running smoothly without professional support. This does not imply open-source version is limited in any way. If you check the recently added code, it contains only warnings and messages, no limitations except one: we removed the option to add custom logo in header. In the Update Manager section, it warns about the 'danger of applying automated updates without a proper backup, remembering in the process that the Enterprise version comes with a human-tested package. Maintaining an OpenSource version with more than 500 agents is not so easy, that's why someone using a Pandora with 8000 agents should consider asking for support. It's not a joke, we know of many setups with a huge number of agents, and we hate to hear that “its becoming unstable and slow” :(
You can of course remove the warnings, that's why we include the source and do not use any kind of trick. And that's why we added here this comment, to let you know this does not reflect any change in our opensource mentality of does the last 14 years.
*/
if ($system_events > 50000 && !enterprise_installed()) {
$tdata[2] = "<div id='monitoreventsmodal' class='publienterprise' title='Community version' style='text-align:left'><img data-title='Enterprise version' class='img_help forced_title' data-use_title_for_force_title='1' src='images/alert_enterprise.png'></div>";
} else {
@ -11766,7 +11858,7 @@ function reporting_get_stats_servers()
$output = '<fieldset class="databox tactical_set">
<legend>'.__('Server performance').'</legend>'.html_print_table($table_srv, true).'</fieldset>';
$public_hash = get_parameter('hash', false);
$public_hash = get_parameter('auth_hash', false);
if ($public_hash === false) {
$output .= '<script type="text/javascript">';
$output .= '$(document).ready(function () {';

View File

@ -2884,7 +2884,7 @@ function reporting_html_agent_configuration(
$row['description'] = $module['description'];
$row['interval'] = $module['interval'];
$row['unit'] = $module['unit'];
$row['status'] = $module['status_icon'];
$row['status'] = ($pdf === 0) ? $module['status_icon'] : explode(':', $module['status'])[0];
$row['tags'] = implode(',', $module['tags']);
$table1->data[] = $row;
@ -3928,10 +3928,10 @@ function reporting_html_general($table, $item, $pdf=0)
$table1->data[] = [
agents_get_alias($id_agent),
modules_get_agentmodule_name($id_module),
$row2['Rate'],
$row2['Maximum'],
$row2['Minimum'],
$row2['Summatory'],
$row2['all'][0],
$row2['all'][1],
$row2['all'][2],
$row2['all'][3],
];
}
}
@ -4014,7 +4014,7 @@ function reporting_html_general($table, $item, $pdf=0)
$table_summary->data[0][0] = $item['min']['agent'].' - '.$item['min']['module'].str_repeat('&nbsp;', 20).$item['min']['formated_value'];
$table_summary->data[0][1] = '';
$table_summary->data[0][2] = format_for_graph($item['avg_value'], 2);
$table_summary->data[0][2] = $item['avg_value'];
$table_summary->data[0][3] = $item['max']['agent'].' - '.$item['max']['module'].str_repeat('&nbsp;', 20).$item['max']['formated_value'];
$table_summary->data[0][4] = '';

View File

@ -273,7 +273,7 @@ function snmp_browser_get_tree(
break;
case '2':
$snmp_version = SNMP::VERSION_2c;
$snmp_version = SNMP::VERSION_2C;
break;
case '2c':
@ -286,7 +286,7 @@ function snmp_browser_get_tree(
break;
default:
$snmp_version = SNMP::VERSION_2c;
$snmp_version = SNMP::VERSION_2C;
break;
}
@ -421,6 +421,10 @@ function snmp_browser_get_oid(
return;
}
if ($version == '2') {
$version = '2c';
}
$output = get_snmpwalk(
$target_ip,
$version,

View File

@ -19,7 +19,7 @@ function treeview_printModuleTable($id_module, $server_data=false, $no_head=fals
$server_name = '';
$server_id = '';
$url_hash = '';
$console_url = '';
$console_url = ui_get_full_url('/');
} else {
$server_name = $server_data['server_name'];
$server_id = $server_data['id'];
@ -500,7 +500,7 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false)
$server_name = '';
$server_id = '';
$url_hash = '';
$console_url = '';
$console_url = ui_get_full_url('/');
} else {
$server_name = $server_data['server_name'];
$server_id = $server_data['id'];
@ -567,7 +567,7 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false)
$table->head = [];
$table->data = [];
// Agent name
// Agent name.
if ($agent['disabled']) {
$cellName = '<em>';
} else {
@ -576,10 +576,10 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false)
if (is_metaconsole()) {
$pwd = $server_data['auth_token'];
// Create HASH login info
// Create HASH login info.
$user = $config['id_user'];
// Extract auth token from serialized field
// Extract auth token from serialized field.
$pwd_deserialiced = json_decode($pwd, true);
$hashdata = $user.$pwd_deserialiced['auth_token'];
@ -588,7 +588,11 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false)
$cellName .= '<a href="'.$url.'">'.'<b><span style="font-weight:bold;text-transform:uppercase;" title="'.$agent['nombre'].'">'.$agent['alias'].'</span></b></a>';
} else {
$cellName .= '<a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$agent['id_agente'].'">'.'<b><span style="font-weight:bold;text-transform:uppercase;" title="'.$agent['nombre'].'">'.$agent['alias'].'</span></b></a>';
$url = ui_get_full_url(
'index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$agent['id_agente']
);
$cellName .= '<a href="'.$url.'">';
$cellName .= '<b><span style="font-weight:bold;text-transform:uppercase;" title="'.$agent['nombre'].'">'.$agent['alias'].'</span></b></a>';
}
if ($agent['disabled']) {
@ -600,7 +604,7 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false)
$row['data'] = $cellName;
$table->data['name'] = $row;
// Addresses
// Addresses.
$ips = [];
$addresses = agents_get_addresses($id_agente);
$address = agents_get_address($id_agente);
@ -611,8 +615,11 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false)
}
}
if (!empty($addresses)) {
$address .= ui_print_help_tip(__('Other IP addresses').': <br>'.implode('<br>', $addresses), true);
if (empty($addresses) === false) {
$address .= ui_print_help_tip(
__('Other IP addresses').': <br>'.implode('<br>', $addresses),
true
);
}
$row = [];
@ -620,25 +627,27 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false)
$row['data'] = $address;
$table->data['address'] = $row;
// Agent Interval
// Agent Interval.
$row = [];
$row['title'] = __('Interval');
$row['data'] = human_time_description_raw($agent['intervalo']);
$table->data['interval'] = $row;
// Comments
// Comments.
$row = [];
$row['title'] = __('Description');
$row['data'] = $agent['comentarios'];
$table->data['description'] = $row;
// Last contact
// Last contact.
$last_contact = ui_print_timestamp($agent['ultimo_contacto'], true);
if ($agent['ultimo_contacto_remoto'] == '01-01-1970 00:00:00') {
$last_remote_contact = __('Never');
} else {
$last_remote_contact = date_w_fixed_tz($agent['ultimo_contacto_remoto']);
$last_remote_contact = date_w_fixed_tz(
$agent['ultimo_contacto_remoto']
);
}
$row = [];
@ -646,7 +655,7 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false)
$row['data'] = "$last_contact / $last_remote_contact";
$table->data['contact'] = $row;
// Next contact (agent)
// Next contact (agent).
$progress = agents_get_next_contact($id_agente);
$row = [];
@ -660,7 +669,7 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false)
);
$table->data['next_contact'] = $row;
// End of table
// End of table.
$agent_table = html_print_table($table, true);
if ($user_access_node && check_acl($config['id_user'], $agent['id_grupo'], 'AW')) {

View File

@ -541,8 +541,9 @@ function ui_print_timestamp($unixtime, $return=false, $option=[])
pandora_setlocale();
$title = human_time_comparation($unixtime);
$strf_format = date2strftime_format($config['date_format'], $unixtime);
$data = strftime(
date2strftime_format($config['date_format']),
$strf_format,
$unixtime
);
} else if ($prominent == 'compact') {
@ -1708,9 +1709,8 @@ function ui_process_page_head($string, $bitfield)
<meta name="author" content="'.get_copyright_notice().'" />
<meta name="copyright" content="(c) '.get_copyright_notice().'" />
<meta name="robots" content="index, follow" />';
$output .= '<link rel="icon" href="'.ui_get_favicon().'" type="image/ico" />';
$output .= '
<link rel="shortcut icon" href="'.ui_get_favicon().'" type="image/x-icon" />
$output .= '<link rel="icon" href="'.ui_get_full_url('/').ui_get_favicon().'" type="image/ico" />';
$output .= '<link rel="shortcut icon" href="'.ui_get_full_url('/').ui_get_favicon().'" type="image/x-icon" />
<link rel="alternate" href="operation/events/events_rss.php" title="Pandora RSS Feed" type="application/rss+xml" />';
if ($config['language'] != 'en') {
@ -3408,6 +3408,14 @@ function ui_print_datatable(array $parameters)
$js .= $parameters['drawCallback'];
}
for ($i = 1; $i <= (count($parameters['columns']) - 3); $i++) {
if ($i != (count($parameters['columns']) - 3)) {
$columns .= $i.',';
} else {
$columns .= $i;
}
}
$js .= '
if (dt_'.$table_id.'.page.info().pages > 1) {
$("#'.$table_id.'_wrapper > .dataTables_paginate.paging_simple_numbers").show()
@ -3438,7 +3446,8 @@ function ui_print_datatable(array $parameters)
order : "current",
page : "All",
search : "applied"
}
},
columns: [1,'.$columns.']
}
}
],
@ -6089,3 +6098,26 @@ function ui_get_full_external_url(string $url)
return $url;
}
function ui_print_message_dialog($title, $text, $id='', $img='', $text_button='', $hidden=true)
{
if ($hidden == true) {
$style = 'display:none';
}
echo '<div id="message_dialog_'.$id.'" title="'.$title.'" style="'.$style.'">';
echo '<div class="content_dialog">';
echo '<div class="icon_message_dialog">';
echo html_print_image($img, true, ['alt' => $title, 'border' => 0]);
echo '</div>';
echo '<div class="content_message_dialog">';
echo '<div class="text_message_dialog">';
echo '<h1>'.$title.'</h1>';
echo '<p>'.$text.'</p>';
echo '<div id="err_msg"></div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
}

View File

@ -53,6 +53,23 @@ function update_manager_verify_registration()
return false;
}
/**
* Check if a trial license is in use.
*
* @return boolean true if a trial license is in use, false otherwise.
*/
function update_manager_verify_trial()
{
global $config;
if (isset($config['license_licensed_to'])
&& strstr($config['license_licensed_to'], 'info@pandorafms.com') !== FALSE
) {
return true;
}
return false;
}
/**
* Parses responses from configuration wizard.
@ -440,6 +457,11 @@ function registration_wiz_modal(
global $config;
$output = '';
// Do not show the wizard for trial licenses.
if (update_manager_verify_trial()) {
return '';
}
$product_name = get_product_name();
$output .= '<div id="registration_wizard" title="';

View File

@ -668,3 +668,106 @@ function get_name_admin():string
return $mail;
}
/**
* Obtiene una matriz con los grupos como clave y si tiene o no permiso UM sobre ese grupo(valor)
*
* @param string User id
* @return array Return .
*/
function users_get_groups_UM($id_user)
{
$sql = sprintf(
"SELECT id_grupo, user_management FROM tusuario_perfil
LEFT JOIN tperfil ON tperfil.id_perfil = tusuario_perfil.id_perfil
WHERE id_usuario like '%s' AND user_management = 1 ORDER BY id_grupo",
$id_user
);
$groups = db_get_all_rows_sql($sql);
$return = [];
foreach ($groups as $key => $group) {
if (!isset($return[$group['id_grupo']]) || (isset($return[$group['id_grupo']]) && $group['user_management'] != 0)) {
$return[$group['id_grupo']] = $group['user_management'];
}
}
return $return;
}
/**
* Obtiene una matriz con los grupos como clave y si tiene o no permiso UM sobre ese grupo(valor)
*
* @param string User id
* @return array Return .
*/
function users_get_users_by_group($id_group, $um=false)
{
$sql = sprintf(
"SELECT tusuario.* FROM tusuario
INNER JOIN tusuario_perfil ON tusuario_perfil.id_usuario = tusuario.id_user
AND tusuario_perfil.id_grupo = '%s'",
$id_group
);
$users = db_get_all_rows_sql($sql);
$return = [];
foreach ($users as $key => $user) {
$return[$user['id_user']] = $user;
$return[$user['id_user']]['edit'] = $um;
}
return $return;
}
function users_has_profile_without_UM($id_user, $id_groups)
{
$sql = sprintf(
"SELECT id_usuario, tperfil.user_management FROM tusuario_perfil
INNER JOIN tperfil ON tperfil.id_perfil = tusuario_perfil.id_perfil AND tperfil.user_management = 0
WHERE tusuario_perfil.id_usuario like '%s' AND tusuario_perfil.id_grupo IN (%s)
ORDER BY tperfil.user_management DESC",
$id_user,
$id_groups
);
$without_um = db_get_all_rows_sql($sql);
if (isset($without_um[0])) {
$sql = sprintf(
"SELECT id_grupo, tperfil.* FROM tusuario_perfil
INNER JOIN tperfil ON tperfil.id_perfil = tusuario_perfil.id_perfil
WHERE tusuario_perfil.id_usuario like '%s'
ORDER BY tperfil.user_management DESC",
$id_user
);
$um = db_get_all_rows_sql($sql);
return 1;
} else {
return 0;
}
}
function users_get_user_profile($id_user)
{
$sql = sprintf(
"SELECT * FROM tusuario_perfil
INNER JOIN tperfil ON tperfil.id_perfil = tusuario_perfil.id_perfil
WHERE tusuario_perfil.id_usuario like '%s'",
$id_user
);
$aux = db_get_all_rows_sql($sql);
$user_profiles = [];
foreach ($aux as $key => $value) {
$user_profiles[$value['id_grupo']] = $value;
}
return $user_profiles;
}

View File

@ -47,6 +47,7 @@ if ($file === '' || $hash === '' || $hash !== md5($file_raw.$config['dbpass']) |
if ($parse_sec2_query[0] === 'sec2') {
switch ($parse_sec2_query[1]) {
case $main_file_manager:
case 'operation/snmpconsole/snmp_mib_uploader':
$downloadable_file = $_SERVER['DOCUMENT_ROOT'].'/pandora_console/'.$file;
break;

View File

@ -638,7 +638,8 @@ function stacked_gauge(
$font='',
$font_size='',
$unit='',
$homeurl=''
$homeurl='',
$transitionDuration=500
) {
include_once 'functions_d3.php';
@ -656,7 +657,8 @@ function stacked_gauge(
$unit,
$font,
($font_size + 2),
$no_data_image
$no_data_image,
$transitionDuration
);
}

View File

@ -2432,7 +2432,7 @@ function pandoraFlotArea(
if (!value[x]) {
x = x + 1;
}
if (value[x].min) {
if (typeof value[x].min !== "undefined" && value[x].min) {
min_y_array = format_unit_yaxes(value[x].min);
min_y = min_y_array["y"];
min_bigger = min_y_array["unit"];
@ -2441,7 +2441,7 @@ function pandoraFlotArea(
min_bigger = "";
}
if (value[x].max) {
if (typeof value[x].max !== "undefined" && value[x].max) {
max_y_array = format_unit_yaxes(value[x].max);
max_y = max_y_array["y"];
max_bigger = max_y_array["unit"];
@ -2450,7 +2450,7 @@ function pandoraFlotArea(
max_bigger = "";
}
if (value[x].avg) {
if (typeof value[x].avg !== "undefined" && value[x].avg) {
avg_y_array = format_unit_yaxes(value[x].avg);
avg_y = avg_y_array["y"];
avg_bigger = avg_y_array["unit"];

View File

@ -294,7 +294,8 @@ function d3_gauges(
$unit,
$font,
$font_size,
$no_data_image
$no_data_image,
$transitionDuration
) {
global $config;
@ -310,7 +311,7 @@ function d3_gauges(
$output .= "<script language=\"javascript\" type=\"text/javascript\">
var data = $data;
createGauges(data, '$width', '$height','$font_size','$no_data_image','$font');
createGauges(data, '$width', '$height','$font_size','$no_data_image','$font', '$transitionDuration');
</script>";
return $output;

View File

@ -14,7 +14,7 @@
global $config;
function include_javascript_dependencies_flot_graph($return=false)
function include_javascript_dependencies_flot_graph($return=false, $mobile=false)
{
global $config;
@ -28,8 +28,16 @@ function include_javascript_dependencies_flot_graph($return=false)
$metaconsole_hack = '../../';
}
$output = '';
if ($mobile === true) {
$output .= '
<script language="javascript" type="text/javascript" src="'.ui_get_full_url($metaconsole_hack.'/mobile/include/javascript/jquery.js').'"></script>
<script language="javascript" type="text/javascript" src="'.ui_get_full_url($metaconsole_hack.'/mobile/include/javascript/jquery.mobile-1.3.1.js').'"></script>';
}
// NOTE: jquery.flot.threshold is not te original file. Is patched to allow multiple thresholds and filled area
$output = '
$output .= '
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="'.ui_get_full_url($metaconsole_hack.'/include/graphs/flot/excanvas.js').'"></script><![endif]-->
<script language="javascript" type="text/javascript" src="'.ui_get_full_url($metaconsole_hack.'/include/graphs/flot/jquery.flot.js').'"></script>
<script language="javascript" type="text/javascript" src="'.ui_get_full_url($metaconsole_hack.'/include/graphs/flot/jquery.flot.min.js').'"></script>

View File

@ -1005,7 +1005,8 @@ function createGauge(
critical_inverse,
font_size,
height,
font
font,
transitionDuration
) {
var gauges;
@ -1014,7 +1015,8 @@ function createGauge(
label: etiqueta,
min: undefined != min ? min : 0,
max: undefined != max ? max : 100,
font_size: font_size
font_size: font_size,
transitionDuration: transitionDuration
};
if (value == null) {
@ -1128,7 +1130,7 @@ function createGauge(
gauges = new Gauge(name, config, font);
gauges.render();
gauges.redraw(value);
gauges.redraw(value, config.transitionDuration);
$(".gauge>text").each(function() {
label = $(this).text();
@ -1155,12 +1157,17 @@ function createGauge(
$(this).text(text);
}
});
config = false;
max_warning2 = false;
min_warning2 = false;
}
function createGauges(data, width, height, font_size, no_data_image, font) {
function createGauges(
data,
width,
height,
font_size,
no_data_image,
font,
transitionDuration
) {
var nombre,
label,
minimun_warning,
@ -1211,7 +1218,8 @@ function createGauges(data, width, height, font_size, no_data_image, font) {
critical_inverse,
font_size,
height,
font
font,
transitionDuration
);
}
}
@ -1247,7 +1255,7 @@ function Gauge(placeholderName, configuration, font) {
this.config.yellowColor = configuration.yellowColor || "#FF9900";
this.config.redColor = configuration.redColor || "#DC3912";
this.config.transitionDuration = configuration.transitionDuration || 500;
this.config.transitionDuration = configuration.transitionDuration;
};
this.render = function() {
@ -1481,11 +1489,7 @@ function Gauge(placeholderName, configuration, font) {
var pointer = pointerContainer.selectAll("path");
pointer
.transition()
.duration(
undefined != transitionDuration
? transitionDuration
: this.config.transitionDuration
)
.duration(undefined != transitionDuration ? transitionDuration : 0)
//.delay(0)
//.ease("linear")
//.attr("transform", function(d)

View File

@ -1865,3 +1865,120 @@ function ajaxRequest(id, settings) {
}
});
}
/**
* -------------------------------------
* Connection Check
* --------------------------------------
*/
checkConnection(1);
/**
* Performs connection tests every minutes and add connection listeners
* @param {integer} time in minutes
*/
function checkConnection(minutes) {
var cicle = minutes * 60 * 1000;
var checkConnection = setInterval(handleConnection, cicle);
// Connection listeters.
window.addEventListener("online", handleConnection);
window.addEventListener("offline", handleConnection);
}
/**
* Handle connection status test.
*
* Test conectivity with server and shows modal message.
*/
function handleConnection() {
var connected;
var msg = "online";
if (navigator.onLine) {
isReachable(getServerUrl())
.then(function(online) {
if (online) {
// handle online status
connected = true;
showConnectionMessage(connected, msg);
} else {
connected = false;
msg = "No connectivity with server";
showConnectionMessage(connected, msg);
}
})
.catch(function(err) {
connected = false;
msg = err;
showConnectionMessage(connected, msg);
});
} else {
// handle offline status
connected = false;
msg = "Connection offline";
showConnectionMessage(connected, msg);
}
}
/**
* Test server reachibilty and get response.
*
* @param {String} url
*
* Return {promise}
*/
function isReachable(url) {
/**
* Note: fetch() still "succeeds" for 404s on subdirectories,
* which is ok when only testing for domain reachability.
*
* Example:
* https://google.com/noexist does not throw
* https://noexist.com/noexist does throw
*/
return fetch(url, { method: "HEAD", mode: "no-cors" })
.then(function(resp) {
return resp && (resp.ok || resp.type === "opaque");
})
.catch(function(error) {
console.warn("[conn test failure]:", error);
});
}
/**
* Gets server origin url
*/
function getServerUrl() {
var server_url;
try {
server_url = get_php_value("homeurl");
} catch (SyntaxError) {
console.warn("Pandora homeurl cannot be found.");
server_url = window.location.origin + "/pandora_console";
}
return server_url;
}
/**
* Shows or hide connection infoMessage.
*
* @param {bool} conn
* @param {string} msg
*/
function showConnectionMessage(conn = true, msg = "") {
var data = {};
if (conn) {
$("div#message_dialog_connection")
.closest(".ui-dialog-content")
.dialog("close");
} else {
data.title = "Connection with server has been lost";
data.text = "Connection status: " + msg;
infoMessage(data, "message_dialog_connection");
}
}

View File

@ -86,11 +86,14 @@ function initialiceLayout(data) {
data: {
page: data.page,
method: "getCellsLayout",
dashboardId: data.dashboardId
dashboardId: data.dashboardId,
auth_class: data.auth.class,
auth_hash: data.auth.hash,
id_user: data.auth.user
},
dataType: "json",
success: function(data) {
loadLayout(data);
success: function(d) {
loadLayout(d);
},
error: function(error) {
console.error(error);
@ -136,7 +139,8 @@ function initialiceLayout(data) {
position.maxWidth,
position.minHeight,
position.maxHeight,
widgetId
widgetId,
false
);
});
// Commit.
@ -167,7 +171,10 @@ function initialiceLayout(data) {
dashboardId: data.dashboardId,
cellId: id,
widgetId: widgetId,
gridWidth: gridWidth
gridWidth: gridWidth,
auth_class: data.auth.class,
auth_hash: data.auth.hash,
id_user: data.auth.user
},
dataType: "html",
success: function(cellData) {
@ -205,7 +212,10 @@ function initialiceLayout(data) {
widgetId: widgetId,
newWidth: newWidth,
newHeight: newHeight,
gridWidth: gridWidth
gridWidth: gridWidth,
auth_class: data.auth.class,
auth_hash: data.auth.hash,
id_user: data.auth.user
},
dataType: "html",
success: function(widgetData) {
@ -291,7 +301,10 @@ function initialiceLayout(data) {
page: data.page,
method: "saveLayout",
dashboardId: data.dashboardId,
items: items
items: items,
auth_class: data.auth.class,
auth_hash: data.auth.hash,
id_user: data.auth.user
},
dataType: "html",
success: function(data) {
@ -313,11 +326,14 @@ function initialiceLayout(data) {
page: data.page,
dashboardId: data.dashboardId,
method: "deleteCell",
cellId: cellId
cellId: cellId,
auth_class: data.auth.class,
auth_hash: data.auth.hash,
id_user: data.auth.user
},
dataType: "json",
success: function(data) {
// For defect x and y = 0
// By default x and y = 0
// width and height = 4
// position auto = true.
if (data.result !== 0) {
@ -338,11 +354,14 @@ function initialiceLayout(data) {
data: {
page: data.page,
method: "insertCellLayout",
dashboardId: data.dashboardId
dashboardId: data.dashboardId,
auth_class: data.auth.class,
auth_hash: data.auth.hash,
id_user: data.auth.user
},
dataType: "json",
success: function(data) {
// For defect x and y = 0
// By default x and y = 0
// width and height = 4
// position auto = true.
if (data.cellId !== 0) {
@ -373,7 +392,7 @@ function initialiceLayout(data) {
dashboardId: data.dashboardId,
widgetId: widgetId
},
width: 450,
width: widgetId == 14 ? 750 : 450,
maxHeight: 600,
minHeight: 400
},
@ -536,7 +555,10 @@ function initialiceLayout(data) {
method: "drawAddWidget",
cellId: cellId,
offset: offset,
search: search
search: search,
auth_class: data.auth.class,
auth_hash: data.auth.hash,
id_user: data.auth.user
},
dataType: "html",
success: function(data) {
@ -606,7 +628,10 @@ function initialiceLayout(data) {
cellId: cellId,
widgetId: widgetId,
gridWidth: gridWidth,
redraw: true
redraw: true,
auth_class: data.auth.class,
auth_hash: data.auth.hash,
id_user: data.auth.user
},
dataType: "html",
success: function(cellData) {
@ -633,7 +658,10 @@ function initialiceLayout(data) {
newWidth: newWidth,
newHeight: newHeight,
gridWidth: gridWidth,
widgetId: widgetId
widgetId: widgetId,
auth_class: data.auth.class,
auth_hash: data.auth.hash,
id_user: data.auth.user
},
dataType: "html",
success: function(dataWidget) {
@ -755,8 +783,9 @@ function dashboardLoadNetworkMap(settings) {
x_offset: settings.x_offset,
y_offset: settings.y_offset,
zoom_dash: settings.zoom_dash,
id_user: settings.id_user,
hash: settings.hash
auth_class: settings.auth_class,
auth_hash: settings.auth_hash,
id_user: settings.id_user
},
dataType: "html",
success: function(data) {
@ -784,6 +813,8 @@ function dashboardLoadWuxStats(settings) {
id_agent: settings.id_agent,
transaction: settings.transaction,
view_all_stats: settings.view_all_stats,
auth_class: settings.auth_class,
auth_hash: settings.auth_hash,
id_user: settings.id_user
},
dataType: "html",
@ -821,9 +852,10 @@ function processTreeSearch(settings) {
data: {
getChildren: 1,
page: settings.page,
id_user: settings.user,
hash: settings.hash,
type: settings.type,
auth_class: settings.auth_class,
auth_hash: settings.auth_hash,
id_user: settings.id_user,
filter: filters
},
success: function(data) {
@ -858,8 +890,11 @@ function processTreeSearch(settings) {
emptyMessage: settings.translate.emptyMessage,
foundMessage: settings.translate.foundMessage,
tree: data.tree,
baseURL: settings.baseURL,
auth_hash: settings.auth_hash,
auth_class: settings.auth_class,
id_user: settings.id_user,
ajaxURL: settings.ajaxUrl,
baseURL: settings.baseUrl,
filter: filters,
counterTitles: {
total: {

View File

@ -713,7 +713,6 @@ function update_event(table, id_evento, type, event_rep, row) {
});
var t1 = new Date();
// Update events matching current filters and id_evento selected.
$.ajax({
async: true,
type: "POST",
@ -751,6 +750,7 @@ function update_event(table, id_evento, type, event_rep, row) {
}
});
}
// Update events matching current filters and id_evento selected.
function validate_event(table, id_evento, event_rep, row) {
var button = document.getElementById("val-" + id_evento);
@ -791,7 +791,39 @@ function delete_event(table, id_evento, event_rep, row) {
processed += 1;
return;
}
var message =
"<h4 style = 'text-align: center; color: black;' > Are you sure?</h4> ";
confirmDialog({
title: "ATTENTION",
message: message,
cancel: "Cancel",
ok: "Ok",
onAccept: function() {
button.children[0];
button.children[0].src = "images/spinner.gif";
return update_event(
table,
id_evento,
{ delete_event: 1 },
event_rep,
row
);
},
onDeny: function() {
button.children[0];
button.children[0].src = "images/cross.png";
return;
}
});
}
function execute_delete_event_reponse(table, id_evento, event_rep, row) {
var button = document.getElementById("del-" + id_evento);
if (!button) {
// Button does not exist. Ignore.
processed += 1;
return;
}
button.children[0];
button.children[0].src = "images/spinner.gif";
return update_event(table, id_evento, { delete_event: 1 }, event_rep, row);
@ -799,110 +831,126 @@ function delete_event(table, id_evento, event_rep, row) {
// Imported from old files.
function execute_event_response(event_list_btn) {
processed = 0;
$("#max_custom_event_resp_msg").hide();
$("#max_custom_selected").hide();
var message =
"<h4 style = 'text-align: center; color: black;' > Are you sure?</h4> ";
confirmDialog({
title: "ATTENTION",
message: message,
cancel: "Cancel",
ok: "Ok",
onAccept: function() {
// Continue execution.
processed = 0;
$("#max_custom_event_resp_msg").hide();
$("#max_custom_selected").hide();
var response_id = $("select[name=response_id]").val();
var response_id = $("select[name=response_id]").val();
var total_checked = $(".chk_val:checked").length;
var total_checked = $(".chk_val:checked").length;
// Check select an event.
if (total_checked == 0) {
$("#max_custom_selected").show();
return;
}
// Check select an event.
if (total_checked == 0) {
$("#max_custom_selected").show();
return;
}
if (!isNaN(response_id)) {
// It is a custom response
var response = get_response(response_id);
if (!isNaN(response_id)) {
// It is a custom response
var response = get_response(response_id);
// If cannot get response abort it
if (response == null) {
// If cannot get response abort it
if (response == null) {
return;
}
// Limit number of events to apply custom responses
// due performance reasons.
if (total_checked > $("#max_execution_event_response").val()) {
$("#max_custom_event_resp_msg").show();
return;
}
var response_command = [];
$(".response_command_input").each(function() {
response_command[$(this).attr("name")] = $(this).val();
});
if (event_list_btn) {
$("#button-submit_event_response").hide(function() {
$("#response_loading_dialog").show(function() {
var check_params = get_response_params(response_id);
if (check_params[0] !== "") {
show_event_response_command_dialog(
response_id,
response,
total_checked
);
} else {
check_massive_response_event(
response_id,
response,
total_checked,
response_command
);
}
});
});
} else {
$("#button-btn_str").hide(function() {
$("#execute_again_loading").show(function() {
check_massive_response_event(
response_id,
response,
total_checked,
response_command
);
});
});
}
} else {
// It is not a custom response
switch (response_id) {
case "in_progress_selected":
$(".chk_val:checked").each(function() {
// Parent: TD. GrandParent: TR.
in_process_event(
dt_events,
$(this).val(),
$(this).attr("event_rep"),
this.parentElement.parentElement
);
});
break;
case "validate_selected":
$(".chk_val:checked").each(function() {
validate_event(
dt_events,
$(this).val(),
$(this).attr("event_rep"),
this.parentElement.parentElement
);
});
break;
case "delete_selected":
console.log($(this));
$(".chk_val:checked").each(function() {
execute_delete_event_reponse(
dt_events,
$(this).val(),
$(this).attr("event_rep"),
this.parentElement.parentElement
);
});
break;
}
}
},
onDeny: function() {
processed += 1;
return;
}
// Limit number of events to apply custom responses
// due performance reasons.
if (total_checked > $("#max_execution_event_response").val()) {
$("#max_custom_event_resp_msg").show();
return;
}
var response_command = [];
$(".response_command_input").each(function() {
response_command[$(this).attr("name")] = $(this).val();
});
if (event_list_btn) {
$("#button-submit_event_response").hide(function() {
$("#response_loading_dialog").show(function() {
var check_params = get_response_params(response_id);
if (check_params[0] !== "") {
show_event_response_command_dialog(
response_id,
response,
total_checked
);
} else {
check_massive_response_event(
response_id,
response,
total_checked,
response_command
);
}
});
});
} else {
$("#button-btn_str").hide(function() {
$("#execute_again_loading").show(function() {
check_massive_response_event(
response_id,
response,
total_checked,
response_command
);
});
});
}
} else {
// It is not a custom response
switch (response_id) {
case "in_progress_selected":
$(".chk_val:checked").each(function() {
// Parent: TD. GrandParent: TR.
in_process_event(
dt_events,
$(this).val(),
$(this).attr("event_rep"),
this.parentElement.parentElement
);
});
break;
case "validate_selected":
$(".chk_val:checked").each(function() {
validate_event(
dt_events,
$(this).val(),
$(this).attr("event_rep"),
this.parentElement.parentElement
);
});
break;
case "delete_selected":
$(".chk_val:checked").each(function() {
delete_event(
dt_events,
$(this).val(),
$(this).attr("event_rep"),
this.parentElement.parentElement
);
});
break;
}
}
});
}
function check_massive_response_event(

View File

@ -494,3 +494,61 @@ function generalShowMsg(data, idMsg) {
]
});
}
function infoMessage(data, idMsg) {
var title = data.title;
var err_messge = data.text;
if (idMsg == null) {
idMsg = uniqId();
}
if ($("#" + idMsg).length === 0) {
$("body").append('<div title="' + title + '" id="' + idMsg + '"></div>');
$("#" + idMsg).empty();
}
$("#err_msg").empty();
$("#err_msg").html("\n\n" + err_messge);
$("#" + idMsg)
.dialog({
height: 250,
width: 528,
opacity: 1,
modal: true,
position: {
my: "center",
at: "center",
of: window,
collision: "fit"
},
title: data.title,
buttons: [
{
class:
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
text: "Retry",
click: function(e) {
handleConnection();
}
},
{
class:
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-cancel",
text: "Close",
click: function() {
$(this).dialog("close");
}
}
],
open: function(event, ui) {
$(".ui-widget-overlay").addClass("error-modal-opened");
},
close: function(event, ui) {
$(".ui-widget-overlay").removeClass("error-modal-opened");
}
})
.show();
}

View File

@ -450,7 +450,10 @@ var TreeController = {
var postData = {
page: controller.ajaxPage,
getDetail: 1,
type: type
type: type,
auth_class: controller.auth_class,
id_user: controller.id_user,
auth_hash: controller.auth_hash
};
if (typeof id !== "undefined") postData.id = id;
@ -970,11 +973,6 @@ var TreeController = {
});
}
}
// Get hash and user.
var public_hash = $("#hidden-publi_dash_tree_view_hash").val();
if (typeof public_hash === "undefined") public_hash = 0;
var public_user = $("#hidden-publi_dash_tree_view_id_user").val();
if (typeof public_user === "undefined") public_user = 0;
if (
typeof element.searchChildren != "undefined" &&
@ -1014,8 +1012,9 @@ var TreeController = {
rootType: element.rootType,
metaID: element.metaID,
filter: controller.filter,
hash: public_hash,
id_user: public_user
auth_class: controller.auth_class,
id_user: controller.id_user,
auth_hash: controller.auth_hash
},
complete: function(xhr, textStatus) {
$node.removeClass("leaf-loading");
@ -1150,6 +1149,16 @@ var TreeController = {
this.filter = data.filter;
}
if (typeof data.auth_class !== "undefined") {
this.auth_class = data.auth_class;
}
if (typeof data.id_user !== "undefined") {
this.id_user = data.id_user;
}
if (typeof data.auth_hash !== "undefined") {
this.auth_hash = data.auth_hash;
}
this.load();
},
remove: function() {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -183,8 +183,25 @@ class Manager
{
global $config;
// Check access.
check_login();
// Check ACL.
$hash = get_parameter('hash', false);
// Check user access.
if ($hash === false) {
check_login();
if (check_acl($config['id_user'], 0, 'RR') === 0) {
include 'general/noaccess.php';
return;
}
} else {
if (self::validatePublicHash($hash) === false) {
db_pandora_audit(
'Invalid public hash',
'Trying to access public dashboard'
);
include 'general/noaccess.php';
exit;
}
}
// User is admin.
$this->isAdmin = (bool) \is_user_admin($config['id_user']);
@ -259,6 +276,86 @@ class Manager
}
/**
* Generates a hash to authenticate in public dashboards.
*
* @param string|null $other_secret To authenticate some parts
* of public dashboards (like visual consoles or wux widgets)
* another hash is needed. Other secret avoid
* to reuse the main hash to view other components.
*
* @return string Returns a hash with the authenticaction.
*/
public static function generatePublicHash(?string $other_secret=''):string
{
global $config;
$str = $config['dbpass'];
$str .= $config['id_user'];
$str .= $other_secret;
return hash('sha256', $str);
}
/**
* Validates a hash to authenticate in public dashboards.
*
* @param string $hash Hash to be checked.
* @param string $other_secret Yo need to provide it to
* authenticate some parts of widgets.
*
* @return boolean Returns true if hash is valid.
*/
public static function validatePublicHash(
string $hash,
string $other_secret=''
):bool {
global $config;
if (isset($config['id_user']) === true) {
// Already logged in.
return true;
}
$userFromParams = false;
// Try to get id_user from parameters if it is missing.
if (isset($config['id_user']) === false) {
$userFromParams = true;
$config['id_user'] = get_parameter('id_user', false);
// It is impossible to authenticate without an id user.
if ($config['id_user'] === false) {
unset($config['id_user']);
return false;
}
} else {
$config['public_dashboard'] = false;
}
// Build a hash to check.
$hashCheck = self::generatePublicHash($other_secret);
if ($hashCheck === $hash) {
// "Log" user in.
if (session_status() !== PHP_SESSION_ACTIVE) {
session_start();
}
$_SESSION['id_usuario'] = $config['id_user'];
session_write_close();
$config['public_dashboard'] = true;
$config['force_instant_logout'] = true;
return true;
}
// Remove id user from config array if authentication has failed.
if ($userFromParams === true) {
unset($config['id_user']);
}
return false;
}
/**
* Instance Widget.
*
@ -854,7 +951,7 @@ class Manager
'dashboardId' => $this->dashboardId,
];
exit(json_encode($result));
echo json_encode($result);
}
@ -889,6 +986,7 @@ class Manager
'refr' => $this->refr,
'url' => $this->url,
'dashboardName' => $this->dashboardFields['name'],
'hash' => self::generatePublicHash(),
]
);
} else {
@ -920,7 +1018,9 @@ class Manager
'url' => \ui_get_full_url('ajax.php'),
'createDashboard' => $this->createDashboard,
'updateDashboard' => $this->updateDashboard,
'cellIdCreate' => get_parameter('cellIdCreate', 0),
'cellIdCreate' => \get_parameter('cellIdCreate', 0),
'class' => (($config['public_dashboard'] === true) ? quotemeta(__CLASS__) : ''),
'hash' => (($config['public_dashboard'] === true) ? self::generatePublicHash() : ''),
]
);
} else {
@ -938,9 +1038,6 @@ class Manager
'widgetId' => $cellData['id_widget'],
'cellId' => $this->cellId,
];
} else {
// TODO:XXX
$output = 'no tiene widget';
}
View::render(
@ -991,7 +1088,7 @@ class Manager
);
}
exit(json_encode($result));
echo json_encode($result);
}
@ -1016,7 +1113,7 @@ class Manager
$result = ['cellId' => $dataCell['id']];
exit(json_encode($result));
echo json_encode($result);
}
@ -1149,7 +1246,7 @@ class Manager
}
}
exit(json_encode($result));
echo json_encode($result);
}
@ -1171,7 +1268,7 @@ class Manager
$result = ['result' => $res];
exit(json_encode($result));
echo json_encode($result);
}
@ -1264,7 +1361,7 @@ class Manager
];
}
exit(json_encode($result));
echo json_encode($result);
}

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