Merge remote-tracking branch 'origin/develop' into ent-3943-Plantillas-de-alerta-con-varios-horarios

Conflicts:
	pandora_console/include/styles/pandora.css
This commit is contained in:
Daniel Barbero Martin 2022-01-25 10:40:37 +01:00
commit 2519335637
114 changed files with 2102 additions and 1296 deletions

View File

@ -1,14 +1,14 @@
#docker build -t pandorafms/pandorafms-open-base-el8 -f $HOME/code/pandorafms/extras/docker/centos8/base/Dockerfile $HOME/code/pandorafms/extras/docker/centos8/base/ #docker build -t pandorafms/pandorafms-open-base-el8 -f $HOME/code/pandorafms/extras/docker/centos8/base/Dockerfile $HOME/code/pandorafms/extras/docker/centos8/base/
#docker push pandorafms/pandorafms-open-base-el8 #docker push pandorafms/pandorafms-open-base-el8
FROM centos:8 FROM rockylinux:8
RUN dnf install -y --setopt=tsflags=nodocs \ RUN dnf install -y --setopt=tsflags=nodocs \
epel-release \ epel-release \
dnf-utils \ dnf-utils \
http://rpms.remirepo.net/enterprise/remi-release-8.rpm http://rpms.remirepo.net/enterprise/remi-release-8.rpm
RUN dnf module reset -y php && dnf module install -y php:remi-7.3 RUN dnf module reset -y php && dnf module install -y php:remi-7.4
RUN dnf config-manager --set-enabled powertools RUN dnf config-manager --set-enabled powertools
# Install console dependencies # Install console dependencies

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.759-211217 Version: 7.0NG.759-220125
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

@ -1015,7 +1015,7 @@ my $Sem = undef;
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.759'; use constant AGENT_VERSION => '7.0NG.759';
use constant AGENT_BUILD => '211217'; use constant AGENT_BUILD => '220125';
# Agent log default file size maximum and instances # Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000; use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.759 %define version 7.0NG.759
%define release 211217 %define release 220125
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.759 %define version 7.0NG.759
%define release 211217 %define release 220125
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -10,7 +10,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.759" PI_VERSION="7.0NG.759"
PI_BUILD="211217" PI_BUILD="220125"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

@ -1,59 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Fandora FMS - Generate SSH keys step-by-step</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="resource-type" content="document" />
<meta name="distribution" content="global" />
<meta name="author" content="Sancho Lerena, Raul Mateos and others" />
<meta
name="copyright"
content="This is GPL software. Created by Sancho Lerena and others"
/>
</head>
<body>
<center>
<img src="images/logo.png" alt="" />
</center>
<h2>Step-by-step generating SSH keys</h2>
From
<a
href="https://pandorafms.com/docs/index.php?title=Pandora:FAQ#How_to_generate_a_pair_of_SSH_keys_for_Pandora_Windows_agent.3F_.28SSH_Transfer_only.29"
>Pandora FMS FAQ</a
>.
<ol>
<li>
Go to <code>.\util</code> of your Pandora FMS agent for Windows and run
<code>puttygen.exe</code>.<br />
Generate keys, SSH-2_DSA, 1024:<br /><br />
<img src="images/1.jpg" /><br /><br />
</li>
<li>
Press Generate<br />
Export key to OpenSSH key (Cygwin uses a port of OpenSSH)<br /><br />
<img src="images/2.jpg" /><br /><br />
</li>
<li>
We have no chosen password, so press YES:<br /><br />
<img src="images/3.jpg" /><br /><br />
</li>
<li>
Save it as <code>c:\pandora\keys\id_dsa:</code><br /><br />
<img src="images/4.jpg" /><br /><br />
</li>
<li>
Now let's copy the public key to clipboard:<br /><br />
<img src="images/5.jpg" /><br /><br />
</li>
<li>
and paste it as <code>c:\pandora_agent\keys\id_dsa.pub</code>, and also
to the <code>/home/pandora/.ssh/authorized_keys</code> file.
<br /><br />
<img src="images/6.jpg" /><br /><br />
</li>
</ol>
</body>
</html>

View File

@ -1,62 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>
Pandora FMS - Generación de claves SSH en Windows paso por paso
</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="resource-type" content="document" />
<meta name="distribution" content="global" />
<meta name="author" content="Sancho Lerena, Raul Mateos y otros" />
<meta
name="copyright"
content="This is GPL software. Created by Sancho Lerena and others"
/>
</head>
<body>
<center>
<img src="images/logo.png" alt="" />
</center>
<h2 class="print">Generación de claves SSH en Windows paso por paso</h2>
Extraído de las
<a
href="https://pandorafms.com/docs/index.php?title=Pandora:FAQ_ES#.C2.BFC.C3.B3mo_puedo_generar_un_par_de_claves_SHH_para_el_agente_para_Windows_.28SSH_Transfer.29_.3F"
>
FAQ</a
>.
<ol>
<li>
Desde el directorio <code>.\util</code> del agente Pandora FMS para
windows ejecutamos <code>puttygen.exe</code>.<br />
Generamos claves SSH-2_DSA, 1024:<br /><br />
<img src="images/1.jpg" /><br /><br />
</li>
<li>
Pulsamos «Generate» para generar la clave.<br />
Exportamos la clave a formato OpenSSH<br /><br />
<img src="images/2.jpg" /><br /><br />
</li>
<li>
No elegimos contraseña, con lo cual pulsamos «Sí»:<br /><br />
<img src="images/3.jpg" /><br /><br />
</li>
<li>
Guardamos la clave como <code>C:\pandora\keys\id_dsa:</code><br /><br />
<img src="images/4.jpg" /><br /><br />
</li>
<li>
Ahora copiamos la clave pública al portapapeles:<br /><br />
<img src="images/5.jpg" /><br /><br />
</li>
<li>
Pegamos la clave en un nuevo fichero
<code>C:\pandora_agent\keys\id_dsa.pub</code>, y debemos también
añadirla al fichero <code>/home/pandora/.ssh/authorized_keys</code>.
<br /><br />
<img src="images/6.jpg" /><br /><br />
</li>
</ol>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{211217} {220125}
ViewReadme ViewReadme
{Yes} {Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils; using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1 #define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.759 Build 211217") #define PANDORA_VERSION ("7.0NG.759 Build 220125")
string pandora_path; string pandora_path;
string pandora_dir; string pandora_dir;

View File

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

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 7.0NG.759-211217 Version: 7.0NG.759-220125
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

@ -202,9 +202,7 @@ function extension_api_checker()
echo '</fieldset>'; echo '</fieldset>';
echo "<div class='right'>"; echo "<div class='right'>";
echo '</div>'; echo '</div>';
echo '</form>';
echo "<form method='post'>";
echo '<fieldset>'; echo '<fieldset>';
echo '<legend>'.__('Custom URL').'</legend>'; echo '<legend>'.__('Custom URL').'</legend>';
html_print_table($table3); html_print_table($table3);

View File

@ -115,3 +115,6 @@ enterprise/include/styles/tooltipster.bundle.min.css
mobile/include/javascript/jquery.mobile-1.3.1.js mobile/include/javascript/jquery.mobile-1.3.1.js
mobile/include/style/jquery.mobile-1.3.1.css mobile/include/style/jquery.mobile-1.3.1.css
godmode/alerts/configure_alert_special_days.php godmode/alerts/configure_alert_special_days.php
godmode/admin_access_logs.php
enterprise/extensions/backup/main.php
enterprise/extensions/backup.php

View File

@ -0,0 +1,5 @@
START TRANSACTION;
ALTER TABLE `tpolicy_queue` MODIFY COLUMN `progress` int(10) NOT NULL default '0';
CREATE INDEX `IDX_tservice_element` ON `tservice_element`(`id_service`,`id_agente_modulo`);
COMMIT;

View File

@ -480,7 +480,8 @@ CREATE TABLE IF NOT EXISTS `tservice_element` (
`id_agent` int(10) unsigned NOT NULL default 0, `id_agent` int(10) unsigned NOT NULL default 0,
`id_service_child` int(10) unsigned NOT NULL default 0, `id_service_child` int(10) unsigned NOT NULL default 0,
`id_server_meta` int(10) unsigned NOT NULL default 0, `id_server_meta` int(10) unsigned NOT NULL default 0,
PRIMARY KEY (`id`) PRIMARY KEY (`id`),
INDEX `IDX_tservice_element` (`id_service`,`id_agente_modulo`)
) ENGINE=InnoDB ) ENGINE=InnoDB
COMMENT = 'Table to define the modules and the weights of the modules that define a service' COMMENT = 'Table to define the modules and the weights of the modules that define a service'
DEFAULT CHARSET=utf8; DEFAULT CHARSET=utf8;
@ -578,7 +579,7 @@ CREATE TABLE IF NOT EXISTS `tpolicy_queue` (
`id_policy` int(10) unsigned NOT NULL default '0', `id_policy` int(10) unsigned NOT NULL default '0',
`id_agent` int(10) unsigned NOT NULL default '0', `id_agent` int(10) unsigned NOT NULL default '0',
`operation` varchar(15) default '', `operation` varchar(15) default '',
`progress` int(10) unsigned NOT NULL default '0', `progress` int(10) NOT NULL default '0',
`end_utimestamp` int(10) unsigned NOT NULL default 0, `end_utimestamp` int(10) unsigned NOT NULL default 0,
`priority` int(10) unsigned NOT NULL default '0', `priority` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
@ -1450,13 +1451,13 @@ ALTER TABLE `ttag` MODIFY COLUMN `name` text NOT NULL default '';
INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 50); INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 51);
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_docs_logo', 'default_docs.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_docs_logo', 'default_docs.png');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.png');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png');
UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager'; UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager';
DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise'; DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise';
INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package', 758); INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package', 759);
INSERT INTO `tconfig` (`token`, `value`) VALUES ('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp');
UPDATE `tconfig` SET `value` = 'mini_severity,evento,id_agente,estado,timestamp' WHERE `token` LIKE 'event_fields'; UPDATE `tconfig` SET `value` = 'mini_severity,evento,id_agente,estado,timestamp' WHERE `token` LIKE 'event_fields';
DELETE FROM `tconfig` WHERE `token` LIKE 'integria_api_password'; DELETE FROM `tconfig` WHERE `token` LIKE 'integria_api_password';

View File

@ -330,8 +330,30 @@ if ($config['enterprise_installed']) {
$reset_pass_link = 'reset_pass.php'; $reset_pass_link = 'reset_pass.php';
// Reset password link. // Reset password link.
echo '<div class="reset_password">'; echo '<div class="reset_password">';
if ((!$config['centralized_management'])) {
echo '<a href="index.php?reset=true&first=true">'.__('Forgot your password?'); echo '<a href="index.php?reset=true&first=true">'.__('Forgot your password?');
echo '</a>'; echo '</a>';
} else {
echo '<a href="javascript:centralized_mode_reset_dialog();">'.__('Forgot your password?');
echo '</a>';
echo '<div id="centralized_mode_reset_dialog" title="'.__('Password reset').'" style="display:none">';
echo '<div class="content_alert">';
echo '<div class="icon_message_alert">';
echo html_print_image('images/icono_stop.png', true, ['alt' => __('Password reset'), 'border' => 0]);
echo '</div>';
echo '<div class="content_message_alert">';
echo '<div class="text_message_alert">';
echo '<p>'.__('This node is configured with centralized mode. Go to metaconsole to reset the password').'</p>';
echo '</div>';
echo '<div class="button_message_alert">';
html_print_submit_button('Ok', 'centralized_mode_reset_button', false);
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
}
echo '</div>'; echo '</div>';
} }
} }
@ -826,5 +848,23 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', '
}); });
}); });
function centralized_mode_reset_dialog() {
$("#centralized_mode_reset_dialog").dialog({
resizable: true,
draggable: true,
modal: true,
height: 220,
width: 528,
overlay: {
opacity: 0.5,
background: "black"
}
});
$("#submit-centralized_mode_reset_button").click (function () {
$("#centralized_mode_reset_dialog").dialog('close');
});
}
/* ]]> */ /* ]]> */
</script> </script>

View File

@ -1,277 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config;
require_once $config['homedir'].'/include/functions_graph.php';
check_login();
$enterprise_include = enterprise_include_once('godmode/admin_access_logs.php');
if (! check_acl($config['id_user'], 0, 'PM')) {
db_pandora_audit('ACL Violation', 'Trying to access audit view');
include 'general/noaccess.php';
exit;
}
$offset = (int) get_parameter('offset');
$filter_type = (string) get_parameter('filter_type');
$filter_user = (string) get_parameter('filter_user');
$filter_text = (string) get_parameter('filter_text');
$filter_period = get_parameter('filter_period', null);
$filter_period = ($filter_period !== null) ? (int) $filter_period : 24;
$filter_ip = (string) get_parameter('filter_ip');
$filter_query = '&filter_type='.$filter_type.'&filter_user='.$filter_user.'&filter_text='.$filter_text.'&filter_period='.$filter_period.'&filter_ip='.$filter_ip;
$csv_url = ui_get_full_url(
false,
false,
false,
false
).'index.php?sec=gextensions&sec2=godmode/audit_log_csv'.$filter_query;
$csv_img = html_print_image(
'images/csv.png',
true,
[
'title' => __(
'Export to CSV'
),'class' => 'invert_filter',
]
);
$header_buttons = [
'csv' => [
'active' => false,
'text' => '<a href="'.$csv_url.'">'.$csv_img.'</a>',
],
];
ui_print_page_header(__('%s audit', get_product_name()).' &raquo; '.__('Review Logs'), 'images/gm_log.png', false, '', true, $header_buttons);
$table = new stdClass();
$table->class = 'databox filters';
$table->cellstyle = [];
$table->cellstyle[0] = [];
$table->cellstyle[1] = [];
$table->cellstyle[0][0] = 'text-align: right;';
$table->cellstyle[0][1] = 'text-align: left;';
$table->cellstyle[0][2] = 'text-align: right;';
$table->cellstyle[0][3] = 'text-align: left;';
$table->cellstyle[0][4] = 'text-align: right;';
$table->cellstyle[0][5] = 'text-align: left;';
$table->cellstyle[1][0] = 'text-align: right;';
$table->cellstyle[1][1] = 'text-align: left;';
$table->cellstyle[1][2] = 'text-align: right;';
$table->cellstyle[1][3] = 'text-align: left;';
$table->cellstyle[1][5] = 'text-align: right;';
$table->data = [];
$data = [];
$data[0] = '<b>'.__('Search').'</b>';
$data[1] = html_print_input_text('filter_text', $filter_text, __('Free text for search (*)'), 20, 40, true);
$data[2] = '<b>'.__('Max. hours old').'</b>';
$data[3] = html_print_input_text('filter_period', $filter_period, __('Max. hours old'), 3, 6, true);
$data[4] = '<b>'.__('IP').'</b>';
$data[5] = html_print_input_text('filter_ip', $filter_ip, __('IP'), 15, 15, true);
$table->data[0] = $data;
$data = [];
$actions_sql = 'SELECT DISTINCT(accion), accion AS text FROM tsesion';
$data[0] = '<b>'.__('Action').'</b>';
$data[1] = html_print_select_from_sql($actions_sql, 'filter_type', $filter_type, '', __('All'), '', true);
$users_sql = 'SELECT id_user, id_user AS text FROM tusuario';
$data[2] = '<b>'.__('User').'</b>';
$data[3] = html_print_select_from_sql($users_sql, 'filter_user', $filter_user, '', __('All'), '', true);
$data[4] = '';
$data[5] = html_print_submit_button(__('Filter'), 'filter', false, 'class="sub search"', true);
$table->data[1] = $data;
$form = '<form name="query_sel" method="post" action="index.php?sec=glog&sec2=godmode/admin_access_logs">';
$form .= html_print_table($table, true);
$form .= '</form>';
ui_toggle($form, __('Filter'), '', '', false);
$filter = '1=1';
if (!empty($filter_type)) {
$filter .= sprintf(" AND accion = '%s'", $filter_type);
}
if (!empty($filter_user)) {
$filter .= sprintf(" AND id_usuario = '%s'", $filter_user);
}
if (!empty($filter_text)) {
$filter .= sprintf(" AND (accion LIKE '%%%s%%' OR descripcion LIKE '%%%s%%')", $filter_text, $filter_text);
}
if (!empty($filter_ip)) {
$filter .= sprintf(" AND ip_origen LIKE '%%%s%%'", $filter_ip);
}
if (!empty($filter_period)) {
switch ($config['dbtype']) {
case 'mysql':
$filter .= ' AND fecha >= DATE_ADD(NOW(), INTERVAL -'.$filter_period.' HOUR)';
break;
case 'postgresql':
$filter .= ' AND fecha >= NOW() - INTERVAL \''.$filter_period.' HOUR \'';
break;
case 'oracle':
$filter .= ' AND fecha >= (SYSTIMESTAMP - INTERVAL \''.$filter_period.'\' HOUR)';
break;
}
}
$count_sql = sprintf('SELECT COUNT(*) FROM tsesion WHERE %s', $filter);
$count = (int) db_get_value_sql($count_sql);
$url = 'index.php?sec=godmode&sec2=godmode/admin_access_logs'.$filter_query;
ui_pagination($count, $url);
switch ($config['dbtype']) {
case 'mysql':
$sql = sprintf(
'SELECT *
FROM tsesion
WHERE %s
ORDER BY fecha DESC
LIMIT %d, %d',
$filter,
$offset,
$config['block_size']
);
break;
case 'postgresql':
$sql = sprintf(
'SELECT *
FROM tsesion
WHERE %s
ORDER BY fecha DESC
LIMIT %d OFFSET %d',
$filter,
$config['block_size'],
$offset
);
break;
case 'oracle':
$set = [];
$set['limit'] = $config['block_size'];
$set['offset'] = $offset;
$sql = sprintf(
'SELECT *
FROM tsesion
WHERE %s
ORDER BY fecha DESC',
$filter
);
$result = oracle_recode_query($sql, $set);
break;
}
$result = db_get_all_rows_sql($sql);
if (empty($result)) {
$result = [];
}
$table = new stdClass();
$table->cellpadding = 0;
$table->cellspacing = 0;
$table->width = '100%';
$table->class = 'info_table';
$table->size = [];
$table->data = [];
$table->head = [];
$table->align = [];
$table->rowclass = [];
$table->head[0] = __('User');
$table->head[1] = __('Action');
$table->head[2] = __('Date');
$table->head[3] = __('Source IP');
$table->head[4] = __('Comments');
if ($enterprise_include !== ENTERPRISE_NOT_HOOK) {
$table->head[5] = enterprise_hook('tableHeadEnterpriseAudit', ['title1']);
$table->head[6] = enterprise_hook('tableHeadEnterpriseAudit', ['title2']);
}
$table->size[0] = 80;
$table->size[2] = 130;
$table->size[3] = 100;
$table->size[4] = 200;
if ($enterprise_include !== ENTERPRISE_NOT_HOOK) {
$table->size[5] = enterprise_hook('tableHeadEnterpriseAudit', ['size1']);
$table->size[6] = enterprise_hook('tableHeadEnterpriseAudit', ['size2']);
$table->align[5] = enterprise_hook('tableHeadEnterpriseAudit', ['align']);
$table->align[6] = enterprise_hook('tableHeadEnterpriseAudit', ['align2']);
}
$table->colspan = [];
$table->rowstyle = [];
$rowPair = true;
$iterator = 0;
// Get data
foreach ($result as $row) {
$iterator++;
$table->rowclass[] = $rowPair ? 'rowPair' : 'rowOdd';
$rowPair = !$rowPair;
$data = [];
$data[0] = io_safe_output($row['id_usuario']);
$data[1] = ui_print_session_action_icon($row['accion'], true).$row['accion'];
$data[2] = ui_print_help_tip(date($config['date_format'], $row['utimestamp']), true).ui_print_timestamp($row['utimestamp'], true);
$data[3] = io_safe_output($row['ip_origen']);
$data[4] = io_safe_output($row['descripcion']);
if ($enterprise_include !== ENTERPRISE_NOT_HOOK) {
$data[5] = enterprise_hook('cell1EntepriseAudit', [$row['id_sesion']]);
$data[6] = enterprise_hook('cell2EntepriseAudit', [$row['id_sesion']]);
}
$table->data[] = $data;
if ($enterprise_include !== ENTERPRISE_NOT_HOOK) {
rowEnterpriseAudit($table, $iterator, $row['id_sesion']);
}
}
foreach ($table->rowclass as $key => $value) {
if (strpos($value, 'limit_scroll') !== false) {
$table->colspan[$key] = [7];
} else {
if ($enterprise_include !== ENTERPRISE_NOT_HOOK) {
$table->cellclass[$key][6] = 'action_buttons';
}
}
}
html_print_table($table);
ui_pagination($count, $url, 0, 0, false, 'offset', true, 'pagination-bottom');
if ($enterprise_include !== ENTERPRISE_NOT_HOOK) {
enterprise_hook('enterpriseAuditFooter');
}

View File

@ -1385,9 +1385,15 @@ if ($update_module || $create_module) {
$custom_integer_2_default = $module['custom_integer_2']; $custom_integer_2_default = $module['custom_integer_2'];
} }
if ($id_module_type == 25) { if ($id_module_type === 25) {
// Web analysis, from MODULE_WUX. // Web analysis, from MODULE_WUX.
$custom_string_1 = base64_encode((string) get_parameter('custom_string_1', $custom_string_1_default)); $custom_string_1 = base64_encode((string) get_parameter('custom_string_1'));
// If the custom_string_1 parameter come empty, set the content
// of the module (it is base64_encoded).
if (empty($custom_string_1) === true) {
$custom_string_1 = $custom_string_1_default;
}
$custom_integer_1 = (int) get_parameter('custom_integer_1', $custom_integer_1_default); $custom_integer_1 = (int) get_parameter('custom_integer_1', $custom_integer_1_default);
} else { } else {
$custom_string_1 = (string) get_parameter('custom_string_1', $custom_string_1_default); $custom_string_1 = (string) get_parameter('custom_string_1', $custom_string_1_default);
@ -1402,7 +1408,7 @@ if ($update_module || $create_module) {
$macros = (string) get_parameter('macros'); $macros = (string) get_parameter('macros');
$macros_names = (array) get_parameter('macro_name', []); $macros_names = (array) get_parameter('macro_name', []);
if (!empty($macros)) { if (empty($macros) === false) {
$macros = json_decode(base64_decode($macros), true); $macros = json_decode(base64_decode($macros), true);
foreach ($macros as $k => $m) { foreach ($macros as $k => $m) {
@ -2422,7 +2428,7 @@ switch ($tab) {
var aget_id_os = '<?php echo agents_get_os(modules_get_agentmodule_agent(get_parameter('id_agent_module'))); ?>'; var aget_id_os = '<?php echo agents_get_os(modules_get_agentmodule_agent(get_parameter('id_agent_module'))); ?>';
if('<?php echo modules_get_agentmodule_name(get_parameter('id_agent_module')); ?>' != $('#text-name').val() && if('<?php echo io_safe_output(modules_get_agentmodule_name(get_parameter('id_agent_module'))); ?>' != $('#text-name').val() &&
'<?php echo agents_get_os(modules_get_agentmodule_agent(get_parameter('id_agent_module'))); ?>' == 19){ '<?php echo agents_get_os(modules_get_agentmodule_agent(get_parameter('id_agent_module'))); ?>' == 19){
event.preventDefault(); event.preventDefault();
@ -2456,7 +2462,7 @@ switch ($tab) {
var module_type_snmp = '<?php echo modules_get_agentmodule_type(get_parameter('id_agent_module')); ?>'; var module_type_snmp = '<?php echo modules_get_agentmodule_type(get_parameter('id_agent_module')); ?>';
if('<?php echo modules_get_agentmodule_name(get_parameter('id_agent_module')); ?>' != $('#text-name').val() && ( if('<?php echo io_safe_output(modules_get_agentmodule_name(get_parameter('id_agent_module'))); ?>' != $('#text-name').val() && (
module_type_snmp == 15 || module_type_snmp == 16 || module_type_snmp == 17 || module_type_snmp == 18)){ module_type_snmp == 15 || module_type_snmp == 16 || module_type_snmp == 17 || module_type_snmp == 18)){
event.preventDefault(); event.preventDefault();

View File

@ -253,6 +253,7 @@ $module_action = (string) get_parameter('module_action');
if ($module_action === 'delete') { if ($module_action === 'delete') {
$id_agent_modules_delete = (array) get_parameter('id_delete'); $id_agent_modules_delete = (array) get_parameter('id_delete');
$print_result_msg = true;
$count_correct_delete_modules = 0; $count_correct_delete_modules = 0;
foreach ($id_agent_modules_delete as $id_agent_module_del) { foreach ($id_agent_modules_delete as $id_agent_module_del) {
$id_grupo = (int) agents_get_agent_group($id_agente); $id_grupo = (int) agents_get_agent_group($id_agente);
@ -268,12 +269,19 @@ if ($module_action === 'delete') {
} }
if ($id_agent_module_del < 1) { if ($id_agent_module_del < 1) {
db_pandora_audit( if (count($id_agent_modules_delete) === 1) {
'HACK Attempt', ui_print_error_message(
'Expected variable from form is not correct' __('No modules selected')
); );
die(__('Nice try buddy'));
exit; $print_result_msg = false;
} else {
ui_print_error_message(
__('There was a problem completing the operation')
);
}
continue;
} }
enterprise_include_once('include/functions_config_agents.php'); enterprise_include_once('include/functions_config_agents.php');
@ -421,6 +429,7 @@ if ($module_action === 'delete') {
} }
} }
if ($print_result_msg === true) {
$count_modules_to_delete = count($id_agent_modules_delete); $count_modules_to_delete = count($id_agent_modules_delete);
if ($count_correct_delete_modules == 0) { if ($count_correct_delete_modules == 0) {
ui_print_error_message( ui_print_error_message(
@ -442,6 +451,7 @@ if ($module_action === 'delete') {
); );
} }
} }
}
} else if ($module_action === 'disable') { } else if ($module_action === 'disable') {
$id_agent_modules_disable = (array) get_parameter('id_delete'); $id_agent_modules_disable = (array) get_parameter('id_delete');

View File

@ -250,6 +250,7 @@ if ($create_downtime || $update_downtime) {
} else if ($type_execution == 'periodically' } else if ($type_execution == 'periodically'
&& $type_periodicity == 'monthly' && $type_periodicity == 'monthly'
&& $periodically_day_from == $periodically_day_to && $periodically_day_from == $periodically_day_to
&& $periodically_time_from >= $periodically_time_to
) { ) {
ui_print_error_message( ui_print_error_message(
__('Not created. Error inserting data').'. '.__('The end time must be higher than the start time') __('Not created. Error inserting data').'. '.__('The end time must be higher than the start time')
@ -946,9 +947,7 @@ if (empty($downtimes_agents)) {
if (!$running) { if (!$running) {
$data[5] = ''; $data[5] = '';
if ($type_downtime != 'disable_agents_alerts' if ($type_downtime !== 'disable_agents') {
&& $type_downtime != 'disable_agents'
) {
$data[5] = '<a href="javascript:show_editor_module('.$downtime_agent['id_agente'].');">'.html_print_image('images/config.png', true, ['border' => '0', 'alt' => __('Delete'), 'class' => 'invert_filter']).'</a>'; $data[5] = '<a href="javascript:show_editor_module('.$downtime_agent['id_agente'].');">'.html_print_image('images/config.png', true, ['border' => '0', 'alt' => __('Delete'), 'class' => 'invert_filter']).'</a>';
} }

View File

@ -235,7 +235,7 @@ $search_string = (string) get_parameter('search_string', '');
$group = (int) get_parameter('group', 0); $group = (int) get_parameter('group', 0);
$group_search = (int) get_parameter('group_search', 0); $group_search = (int) get_parameter('group_search', 0);
$id_command_search = (int) get_parameter('id_command_search', 0); $id_command_search = (int) get_parameter('id_command_search', 0);
$url = 'index.php?sec='.$sec.'&sec2=godmode/alerts/alert_actions'; $url = 'index.php?sec='.$sec.'&sec2=godmode/alerts/alert_actions&search_string='.$search_string.'&group_search='.$group_search.'&id_command_search='.$id_command_search;
// Filter table. // Filter table.
$table_filter = new stdClass(); $table_filter = new stdClass();

View File

@ -1134,7 +1134,7 @@ function show_add_action(id_alert) {
}, },
open: function() { open: function() {
$(`#add_action-div-${id_alert}`).css('overflow', 'hidden'); $(`#add_action-div-${id_alert}`).css('overflow', 'hidden');
$("#action_select, #action_select").select2({ $("select[id^='action_select'], select[id^='action_select']").select2({
tags: true, tags: true,
dropdownParent: $("#add_action-div-" + id_alert) dropdownParent: $("#add_action-div-" + id_alert)
}); });

View File

@ -21,8 +21,6 @@ enterprise_include_once('meta/include/functions_alerts_meta.php');
check_login(); check_login();
enterprise_hook('open_meta_frame');
if (! check_acl($config['id_user'], 0, 'LM')) { if (! check_acl($config['id_user'], 0, 'LM')) {
db_pandora_audit( db_pandora_audit(
'ACL Violation', 'ACL Violation',
@ -50,6 +48,8 @@ if (is_ajax()) {
} }
} }
enterprise_hook('open_meta_frame');
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
$sec = 'advanced'; $sec = 'advanced';
} else { } else {
@ -694,8 +694,19 @@ $(document).ready (function () {
} }
} }
else { else {
var is_element_select = $("[name=field" + i + "_value]").is("select");
$("[name=field" + i + "_value]").val(old_value); $("[name=field" + i + "_value]").val(old_value);
if (is_element_select === true) {
$("[name=field" + i + "_value]").trigger('change');
}
$("[name=field" + i + "_recovery_value]").val(old_recovery_value); $("[name=field" + i + "_recovery_value]").val(old_recovery_value);
if (is_element_select === true) {
$("[name=field" + i + "_recovery_value]").trigger('change');
}
} }
} }
else { else {
@ -747,6 +758,7 @@ $(document).ready (function () {
if ($('#field5_value').val() !== '') { if ($('#field5_value').val() !== '') {
ajax_get_integria_custom_fields($('#field5_value').val(), integria_custom_fields_values, integria_custom_fields_rvalues); ajax_get_integria_custom_fields($('#field5_value').val(), integria_custom_fields_values, integria_custom_fields_rvalues);
$('#field5_value').trigger('change');
} }
$('#field5_value').on('change', function() { $('#field5_value').on('change', function() {

View File

@ -0,0 +1,71 @@
<?php
/**
* Audit log View.
*
* @category Audit log
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
global $config;
require_once $config['homedir'].'/include/class/AuditLog.class.php';
$ajaxPage = 'godmode/audit_log';
// Control call flow.
try {
// User access and validation is being processed on class constructor.
$controller = new AuditLog($ajaxPage);
} catch (Exception $e) {
if ((bool) is_ajax() === true) {
echo json_encode(['error' => '[AuditLog]'.$e->getMessage() ]);
exit;
} else {
echo '[AuditLog]'.$e->getMessage();
}
// Stop this execution, but continue 'globally'.
return;
}
// AJAX controller.
if ((bool) is_ajax() === true) {
$method = get_parameter('method');
if (method_exists($controller, $method) === true) {
if ($controller->ajaxMethod($method) === true) {
$controller->{$method}();
} else {
$controller->error('Unavailable method.');
}
} else {
$controller->error('Method not found. ['.$method.']');
}
// Stop any execution.
exit;
} else {
// Run.
$controller->run();
}

View File

@ -463,21 +463,12 @@ foreach ($listConnectionTemp as $connectionTemp) {
} }
$table->data[1][0] = __('Add Map connection').$iconError; $table->data[1][0] = __('Add Map connection').$iconError;
$table->data[1][1] = "<table class='no-class' border='0' id='map_connection'> $table->data[1][1] = ".html_print_select($listConnection, 'map_connection_list', '', '', '', '0', true)."
<tr> < / td > < td > < a href = 'javascript: addConnectionMap();' > ".html_print_image(
<td >
".html_print_select($listConnection, 'map_connection_list', '', '', '', '0', true)."
</td>
<td >
<a href='javascript: addConnectionMap();'>".html_print_image(
'images/add.png', 'images/add.png',
true, true,
['class' => 'invert_filter'] ['class' => 'invert_filter']
)."</a> )." < / a > < input type = 'hidden' name = 'map_connection_list' value = '' id = 'map_connection_list' / > < input type = 'hidden' name = 'layer_list' value = '' id = 'layer_list' / > < / td > < / tr > (".gis_add_conection_maps_in_form($map_connection_list).'
<input type='hidden' name='map_connection_list' value='' id='map_connection_list' />
<input type='hidden' name='layer_list' value='' id='layer_list' />
</td>
</tr> ".gis_add_conection_maps_in_form($map_connection_list).'
</table>'; </table>';
$own_info = get_user_info($config['id_user']); $own_info = get_user_info($config['id_user']);
@ -539,6 +530,8 @@ $table->data[9][1] = html_print_input_text('map_default_altitude', $map_default_
html_print_table($table); html_print_table($table);
$user_groups = users_get_groups($config['user'], 'AR', false);
echo '<h3>'.__('Layers').'</h3>'; echo '<h3>'.__('Layers').'</h3>';
$table->width = '100%'; $table->width = '100%';
@ -551,9 +544,9 @@ $table->data = [];
$table->data[0][0] = '<h4>'.__('List of layers').'</h4>'; $table->data[0][0] = '<h4>'.__('List of layers').'</h4>';
$table->data[0][1] = '<div class="right">'.html_print_button(__('New layer'), 'new_layer', false, 'newLayer();', 'class="sub add "', true).'</div>'; $table->data[0][1] = '<div class="right">'.html_print_button(__('New layer'), 'new_layer', false, 'newLayer();', 'class="sub add "', true).'</div>';
$table->data[1][0] = '<table class="databox" border="0" cellpadding="4" cellspacing="4" id="list_layers"></table>'; $table->data[1][0] = '<table class="databox' border='0' cellpadding='4' cellspacing='4' id='list_layers"></table>';
$table->data[1][1] = '<div id="form_layer" class="invisible"> $table->data[1][1] = '<div id="form_layer' class='invisible'>
<table id="form_layer_table" class="" border="0" cellpadding="4" cellspacing="4"> <table id='form_layer_table' class="" border='0' cellpadding='4' cellspacing='4">
<tr> <tr>
<td>'.__('Layer name').':</td> <td>'.__('Layer name').':</td>
<td>'.html_print_input_text('layer_name_form', '', '', 20, 40, true).'</td> <td>'.html_print_input_text('layer_name_form', '', '', 20, 40, true).'</td>
@ -562,7 +555,7 @@ $table->data[1][1] = '<div id="form_layer" class="invisible">
</tr> </tr>
<tr> <tr>
<td>'.__('Show agents from group').':</td> <td>'.__('Show agents from group').':</td>
<td colspan="3">'.html_print_select_groups(false, $access, $display_all_group, 'layer_group_form', '-1', '', __('None'), '-1', true).'</td> <td colspan="3">'.html_print_select($user_groups, 'layer_group_form', '-1', '', __('none'), '-1', true).'</td>
</tr> </tr>
<tr> <tr>
<td colspan="4"><hr /></td> <td colspan="4"><hr /></td>
@ -596,7 +589,7 @@ $table->data[1][1] .= '</td>
<tr> <tr>
<td colspan="4"> <td colspan="4">
<h4>'.__('List of Agents to be shown in the layer').'</h4> <h4>'.__('List of Agents to be shown in the layer').'</h4>
<table class="databox" border="0" cellpadding="4" cellspacing="4" id="list_agents"> <table class="databox' border='0' cellpadding='4' cellspacing='4' id='list_agents">
</table> </table>
</td> </td>
</tr>'; </tr>';
@ -630,18 +623,18 @@ $table->data[1][1] .= '<tr><td colspan="4"><hr /></td></tr>
<td colspan="3">'.$agent_for_group_input.'</td> <td colspan="3">'.$agent_for_group_input.'</td>
</tr> </tr>
<tr> <tr>
<td colspan="4" align="right">'.$add_group_btn.'</td> <td colspan="4' align='right">'.$add_group_btn.'</td>
</tr> </tr>
<tr> <tr>
<td colspan="4"> <td colspan="4">
<h4>'.__('List of groups to be shown in the layer').'</h4> <h4>'.__('List of groups to be shown in the layer').'</h4>
<table class="databox" border="0" cellpadding="4" cellspacing="4" id="list_groups"> <table class="databox' border='0' cellpadding='4' cellspacing='4' id='list_groups">
</table> </table>
</td> </td>
</tr>'; </tr>';
$table->data[1][1] .= '<tr> $table->data[1][1] .= '<tr>
<td align="right" colspan="4">'.html_print_button(__('Save Layer'), 'save_layer', false, 'javascript:saveNewLayer();', 'class="sub wand"', true).' <td align="right' colspan='4">'.html_print_button(__('Save Layer'), 'save_layer', false, 'javascript:saveNewLayer();', 'class="sub wand"', true).'
'.html_print_input_hidden('current_edit_layer_id', '', true).' '.html_print_input_hidden('current_edit_layer_id', '', true).'
</td> </td>
</tr> </tr>
@ -651,7 +644,7 @@ $table->data[1][1] .= '<tr>
html_print_table($table); html_print_table($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<div class="action - buttons' style=')width: '.$table->width.'">';
switch ($action) { switch ($action) {
case 'save_new': case 'save_new':
case 'edit_map': case 'edit_map':
@ -676,12 +669,12 @@ echo '</form>';
// -------------------------INI CHUNKS--------------------------------------- // -------------------------INI CHUNKS---------------------------------------
?> ?>
<table style="visibility: hidden;"> <table style="visibility: hidden;('>
<tbody id="chunk_map_connection"> <tbody id='chunk_map_connection'>
<tr class="row_0"> <tr class='row_0">
<td><?php html_print_input_text('map_connection_name', $map_name, '', 20, 40, false, true); ?></td> <td><?php html_print_input_text('map_connection_name', $map_name, '', 20, 40, false, true); ?></td>
<td><?php html_print_radio_button_extended('map_connection_default', '', '', true, false, 'changeDefaultConection(this.value)', ''); ?></td> <td><?php html_print_radio_button_extended('map_connection_default', '', '', true, false, 'changeDefaultConection(this.value)', ''); ?></td>
<td><a id="delete_row" href="none"> <td><a id="delete_row' href='none">
<?php <?php
html_print_image( html_print_image(
'images/cross.png', 'images/cross.png',
@ -704,36 +697,43 @@ ui_require_jquery_file('cluetip');
ui_require_jquery_file('pandora.controls'); ui_require_jquery_file('pandora.controls');
ui_require_jquery_file('json'); ui_require_jquery_file('json');
?> ?>
<script type="text/javascript"> <script type="text / javascript'>
function active_button_add_agent() { function active_button_add_agent() {
$("#button-add_agent").prop("disabled", false); $(')
// button-add_agent").prop("disabled", false);
} }
function addAgentClick (event) {
var $layerFormAgentIdInput = $("#hidden-agent_id"); function addAgentClick(event)
var $layerFormAgentAliasInput = $("#text-agent_alias"); {
var $layerFormAgentIdInput = $('#hidden-agent_id');
var $layerFormAgentAliasInput = $('#text-agent_alias');
var agentId = Number.parseInt($layerFormAgentIdInput.val()); var agentId = Number.parseInt($layerFormAgentIdInput.val());
var agentAlias = $layerFormAgentAliasInput.val(); var agentAlias = $layerFormAgentAliasInput.val();
var layerId = $("input#hidden-current_edit_layer_id").val(); var layerId = $('input#hidden-current_edit_layer_id').val();
if (Number.isNaN(agentId) || agentId === 0 || agentAlias.length === 0) return; if (Number.isNaN(agentId) || agentId === 0 || agentAlias.length === 0) {
return;
}
addAgentRow(layerId, agentId, agentAlias); addAgentRow(layerId, agentId, agentAlias);
// Clear agent inputs // Clear agent inputs
$layerFormAgentIdInput.val(""); $layerFormAgentIdInput.val('');
$layerFormAgentAliasInput.val(""); $layerFormAgentAliasInput.val('');
$("#button-add_agent").prop("disabled", true); $('#button-add_agent').prop('disabled', true);
} }
function toggleAddGroupBtn () {
var groupId = Number.parseInt($("select#layer_group_id").val()); function toggleAddGroupBtn()
{
var groupId = Number.parseInt($('select#layer_group_id').val());
var existGroupId = $("table#list_groups tr.groups_list_item[data-group-id='" + groupId + "']").length > 0; var existGroupId = $("table#list_groups tr.groups_list_item[data-group-id='" + groupId + "']").length > 0;
var agentId = Number.parseInt($("input#hidden-agent_id_for_data").val()); var agentId = Number.parseInt($('input#hidden-agent_id_for_data').val());
var agentAlias = $("input#text-agent_alias_for_data").val(); var agentAlias = $('input#text-agent_alias_for_data').val();
var enabled = ( var enabled = (
!existGroupId !existGroupId
@ -744,17 +744,19 @@ function toggleAddGroupBtn () {
&& agentAlias.length > 0 && agentAlias.length > 0
); );
$("#button-add_group").prop("disabled", !enabled); $('#button-add_group').prop('disabled', !enabled);
} }
function addGroupClick (event) {
var $layerFormGroupIdInput = $("select#layer_group_id");
var $layerFormAgentIdInput = $("input#hidden-agent_id_for_data");
var $layerFormAgentAliasInput = $("input#text-agent_alias_for_data");
var layerId = $("input#hidden-current_edit_layer_id").val(); function addGroupClick(event)
{
var $layerFormGroupIdInput = $('select#layer_group_id');
var $layerFormAgentIdInput = $('input#hidden-agent_id_for_data');
var $layerFormAgentAliasInput = $('input#text-agent_alias_for_data');
var layerId = $('input#hidden-current_edit_layer_id').val();
var groupId = Number.parseInt($layerFormGroupIdInput.val()); var groupId = Number.parseInt($layerFormGroupIdInput.val());
var groupName = $layerFormGroupIdInput.find(":selected").text(); var groupName = $layerFormGroupIdInput.find(':selected').text();
var agentId = Number.parseInt($layerFormAgentIdInput.val()); var agentId = Number.parseInt($layerFormAgentIdInput.val());
var agentAlias = $layerFormAgentAliasInput.val(); var agentAlias = $layerFormAgentAliasInput.val();
@ -767,46 +769,61 @@ function addGroupClick (event) {
&& agentAlias.length > 0 && agentAlias.length > 0
); );
if (!valid) return; if (!valid) {
return;
}
addGroupRow(layerId, groupId, groupName, agentId, agentAlias); addGroupRow(layerId, groupId, groupName, agentId, agentAlias);
// Clear inputs // Clear inputs
// $layerFormGroupIdInput.val(0); // $layerFormGroupIdInput.val(0);
$layerFormAgentIdInput.val(""); $layerFormAgentIdInput.val('');
$layerFormAgentAliasInput.val(""); $layerFormAgentAliasInput.val('');
$("#button-add_group").prop("disabled", true); $('#button-add_group').prop('disabled', true);
} }
function moveLayerRowUpOnClick (event) {
function moveLayerRowUpOnClick(event)
{
var $row = $(event.currentTarget).parent().parent(); var $row = $(event.currentTarget).parent().parent();
$row.insertBefore($row.prev()); $row.insertBefore($row.prev());
} }
function moveLayerRowDownOnClick (event) {
function moveLayerRowDownOnClick(event)
{
var $row = $(event.currentTarget).parent().parent(); var $row = $(event.currentTarget).parent().parent();
$row.insertAfter($row.next()); $row.insertAfter($row.next());
} }
function removeLayerRowOnClick (event) {
function removeLayerRowOnClick(event)
{
var $layerRow = $(event.currentTarget).parent().parent(); var $layerRow = $(event.currentTarget).parent().parent();
var layerRowId = $layerRow.find("input.layer_id").val(); var layerRowId = $layerRow.find('input.layer_id').val();
var layerEditorId = $("input#hidden-current_edit_layer_id").val(); var layerEditorId = $('input#hidden-current_edit_layer_id').val();
if (layerRowId == layerEditorId) hideLayerEditor(); if (layerRowId == layerEditorId) {
hideLayerEditor();
}
// Remove row // Remove row
$(event.currentTarget).parent().parent().remove(); $(event.currentTarget).parent().parent().remove();
} }
function hideLayerEditor () {
function hideLayerEditor()
{
// Clean editor // Clean editor
cleanLayerEditor(); cleanLayerEditor();
// Hide editor // Hide editor
$("div#form_layer").hide(); $('div#form_layer').hide();
} }
function showLayerEditor (layerId) {
var $layerSaveBtn = $("input#button-save_layer"); function showLayerEditor(layerId)
{
var $layerSaveBtn = $('input#button-save_layer');
// Clean editor // Clean editor
cleanLayerEditor(); cleanLayerEditor();
@ -830,33 +847,39 @@ function showLayerEditor (layerId) {
} }
// Show editor (if hidden) // Show editor (if hidden)
$("div#form_layer").show(); $('div#form_layer').show();
} }
function getLayerData (layerId) {
var $layerRow = $("tr#layer_row_" + layerId); function getLayerData(layerId)
var layerName = $layerRow.find("input.layer_name").val(); {
var layerVisible = $layerRow.find("input.layer_visible").val() == 1; var $layerRow = $('tr#layer_row_' + layerId);
var layerAgentsFromGroup = $layerRow.find("input.layer_agents_from_group").val(); var layerName = $layerRow.find('input.layer_name').val();
var layerAgents = $layerRow.find("input.layer_agent_alias").map(function () { var layerVisible = $layerRow.find('input.layer_visible').val() == 1;
var layerAgentsFromGroup = $layerRow.find('input.layer_agents_from_group').val();
var layerAgents = $layerRow.find('input.layer_agent_alias').map(
function () {
return { return {
"id": $(this).data("agent-id"), 'id': $(this).data('agent-id'),
"alias": $(this).val() 'alias': $(this).val()
}; };
}).get(); }
var layerGroups = $layerRow.find("input.layer_group_id").map(function () { ).get();
var layerGroups = $layerRow.find('input.layer_group_id').map(
function () {
var groupId = $(this).val(); var groupId = $(this).val();
var groupName = $(this).siblings("input.layer_group_name[data-group-id='" + groupId + "']").val(); var groupName = $(this).siblings(("input.layer_group_name[data-group-id='" + groupId + "']")).val();
var agentId = $(this).siblings("input.layer_agent_id_for_data[data-group-id='" + groupId + "']").val(); var agentId = $(this).siblings(("input.layer_agent_id_for_data[data-group-id='" + groupId + "']")).val();
var agentAlias = $(this).siblings("input.layer_agent_alias_for_data[data-group-id='" + groupId + "']").val(); var agentAlias = $(this).siblings(("input.layer_agent_alias_for_data[data-group-id='" + groupId + "']")).val();
return { return {
"id": groupId, 'id': groupId,
"name": groupName, 'name': groupName,
"agentId": agentId, 'agentId': agentId,
"agentAlias": agentAlias 'agentAlias': agentAlias
}; };
}).get(); }
).get();
return { return {
id: layerId, id: layerId,
@ -868,141 +891,185 @@ function getLayerData (layerId) {
} }
} }
function setLayerEditorData (data) {
if (data == null) data = {}; function setLayerEditorData(data)
{
if (data == null) {
data = {};
}
// Set defaults // Set defaults
data = { data = {
id: data.id || 0, id: data.id || 0,
name: data.name || "", name: data.name || '',
visible: data.visible != null ? !!data.visible : true, visible: data.visible != null ? !!data.visible : true,
agentsFromGroup: data.agentsFromGroup || -1, agentsFromGroup: data.agentsFromGroup || -1,
agents: data.agents || [], agents: data.agents || [],
groups: data.groups || [] groups: data.groups || []
} }
var $layerFormIdInput = $("input#hidden-current_edit_layer_id"); var $layerFormIdInput = $('input#hidden-current_edit_layer_id');
var $layerFormNameInput = $("input#text-layer_name_form"); var $layerFormNameInput = $('input#text-layer_name_form');
var $layerFormVisibleCheckbox = $("input#checkbox-layer_visible_form"); var $layerFormVisibleCheckbox = $('input#checkbox-layer_visible_form');
var $layerFormAgentsFromGroupSelect = $("select#layer_group_form"); var $layerFormAgentsFromGroupSelect = $('#layer_group_form');
var $layerFormAgentInput = $("input#text-agent_alias"); var $layerFormAgentInput = $('input#text-agent_alias');
var $layerFormAgentButton = $("input#button-add_agent"); var $layerFormAgentButton = $('input#button-add_agent');
var $layerFormAgentsListItems = $("tr.agents_list_item"); var $layerFormAgentsListItems = $('tr.agents_list_item');
var $layerFormGroupsListItems = $("tr.groups_list_item"); var $layerFormGroupsListItems = $('tr.groups_list_item');
$layerFormIdInput.val(data.id); $layerFormIdInput.val(data.id);
$layerFormNameInput.val(data.name); $layerFormNameInput.val(data.name);
$layerFormVisibleCheckbox.prop("checked", data.visible); $layerFormVisibleCheckbox.prop('checked', data.visible);
$layerFormAgentsFromGroupSelect.val(data.agentsFromGroup); $(`#layer_group_form option[value=${data.agentsFromGroup
$layerFormAgentInput.val(""); }]`).attr('selected', 'selected');
$layerFormAgentButton.prop("disabled", true);
$(`#layer_group_form`).trigger('change');
$layerFormAgentInput.val('');
$layerFormAgentButton.prop('disabled', true);
$layerFormAgentsListItems.remove(); $layerFormAgentsListItems.remove();
$layerFormGroupsListItems.remove(); $layerFormGroupsListItems.remove();
var $tableAgents = $("table#list_agents"); var $tableAgents = $('table#list_agents');
data.agents.forEach(function (agent) { data.agents.foreach (function (agent) {
addAgentRow(data.id, agent.id, agent.alias); addAgentRow(data.id, agent.id, agent.alias);
}); }) {
}
var $tableGroups = $("table#list_groups"); var $tableGroups = $('table#list_groups');
data.groups.forEach(function (group) { data.groups.foreach (function (group) {
addGroupRow(data.id, group.id, group.name, group.agentId, group.agentAlias); addGroupRow(data.id, group.id, group.name, group.agentId, group.agentAlias);
}); }) {
} }
function newLayer () { }
function newLayer()
{
showLayerEditor(null); showLayerEditor(null);
} }
function saveNewLayer () {
var $layerFormNameInput = $("input#text-layer_name_form");
var $layerFormVisibleCheckbox = $("input#checkbox-layer_visible_form");
var $layerFormAgentsFromGroupSelect = $("select#layer_group_form");
var $layerFormAgentsListItems = $("tr.agents_list_item > td > span.agent_alias");
var $layerFormGroupsListItems = $("tr.groups_list_item");
var newLayerId = "new_" + ($("tr.layer_row").length + 1);
addLayerRow(newLayerId, { function saveNewLayer()
{
var $layerFormNameInput = $('input#text-layer_name_form');
var $layerFormVisibleCheckbox = $('input#checkbox-layer_visible_form');
var $layerFormAgentsFromGroupSelect = $('select#layer_group_form');
var $layerFormAgentsListItems = $('tr.agents_list_item > td > span.agent_alias');
var $layerFormGroupsListItems = $('tr.groups_list_item');
var newLayerId = ('new_' + ($('tr.layer_row').length + 1));
addLayerRow(
newLayerId,
{
id: newLayerId, id: newLayerId,
name: $layerFormNameInput.val(), name: $layerFormNameInput.val(),
visible: $layerFormVisibleCheckbox.prop("checked"), visible: $layerFormVisibleCheckbox.prop('checked'),
agentsFromGroup: $layerFormAgentsFromGroupSelect.val(), agentsFromGroup: $layerFormAgentsFromGroupSelect.val(),
agents: $layerFormAgentsListItems.map(function () { agents: $layerFormAgentsListItems.map(
function () {
return { return {
"id": $(this).data("agent-id"), 'id': $(this).data('agent-id'),
"alias": $(this).text() 'alias': $(this).text()
}; };
}).get(), }
groups: $layerFormGroupsListItems.map(function () { ).get(),
groups: $layerFormGroupsListItems.map(
function () {
return { return {
"id": $(this).data("group-id"), 'id': $(this).data('group-id'),
"name": $(this).data("group-name"), 'name': $(this).data('group-name'),
"agentId": $(this).data("agent-id"), 'agentId': $(this).data('agent-id'),
"agentAlias": $(this).data("agent-alias") 'agentAlias': $(this).data('agent-alias')
}; };
}).get() }
}); ).get()
} }
);
}
function cleanLayerEditor () {
function cleanLayerEditor()
{
// Clear editor events // Clear editor events
unbindLayerEditorEvents(); unbindLayerEditorEvents();
// Add default data to the editor // Add default data to the editor
setLayerEditorData(); setLayerEditorData();
} }
function bindLayerEditorEvents (layerId) {
var $layerFormNameInput = $("input#text-layer_name_form");
var $layerFormVisibleCheckbox = $("input#checkbox-layer_visible_form");
var $layerFormAgentsFromGroupSelect = $("select#layer_group_form");
var $layerRow = $("tr#layer_row_" + layerId); function bindLayerEditorEvents(layerId)
{
var $layerFormNameInput = $('input#text-layer_name_form');
var $layerFormVisibleCheckbox = $('input#checkbox-layer_visible_form');
var $layerFormAgentsFromGroupSelect = $('select#layer_group_form');
if ($layerRow.length === 0) return; var $layerRow = $('tr#layer_row_' + layerId);
$layerFormNameInput.bind("change", function (event) { if ($layerRow.length === 0) {
return;
}
$layerFormNameInput.bind(
'change',
function (event) {
var name = event.currentTarget.value; var name = event.currentTarget.value;
$layerRow.find("span.layer_name").html(name); $layerRow.find('span.layer_name').html(name);
$layerRow.find("input.layer_name").val(name); $layerRow.find('input.layer_name').val(name);
}); }
$layerFormVisibleCheckbox.bind("click", function (event) { );
var visible = $(event.currentTarget).prop("checked"); $layerFormVisibleCheckbox.bind(
$layerRow.find("input.layer_visible").val(visible ? 1 : 0); 'click',
}); function (event) {
$layerFormAgentsFromGroupSelect.bind("change", function (event) { var visible = $(event.currentTarget).prop('checked');
$layerRow.find('input.layer_visible').val(visible ? 1 : 0);
}
);
$layerFormAgentsFromGroupSelect.bind(
'change',
function (event) {
var group = event.currentTarget.value; var group = event.currentTarget.value;
$layerRow.find("input.layer_agents_from_group").val(group); $layerRow.find('input.layer_agents_from_group').val(group);
}); }
} );
}
function unbindLayerEditorEvents () {
var $layerFormNameInput = $("input#text-layer_name_form");
var $layerFormVisibleCheckbox = $("input#checkbox-layer_visible_form");
var $layerFormAgentsFromGroupSelect = $("select#layer_group_form");
$layerFormNameInput.unbind("change"); function unbindLayerEditorEvents()
$layerFormVisibleCheckbox.unbind("click"); {
$layerFormAgentsFromGroupSelect.unbind("change"); var $layerFormNameInput = $('input#text-layer_name_form');
} var $layerFormVisibleCheckbox = $('input#checkbox-layer_visible_form');
var $layerFormAgentsFromGroupSelect = $('select#layer_group_form');
function getAgentRow (layerId, agentId, agentAlias) { $layerFormNameInput.unbind('change');
var $row = $("<tr class=\"agents_list_item\" />"); $layerFormVisibleCheckbox.unbind('click');
var $nameCol = $("<td />"); $layerFormAgentsFromGroupSelect.val('-1');
var $deleteCol = $("<td />"); }
var $agentAlias = $("<span class=\"agent_alias\" data-agent-id=\"" + agentId + "\">" + agentAlias + "</span>");
var $removeBtn = $('<a class="delete_row" href="javascript:" <?php echo html_print_image('images/cross.png', true, ['class' => 'invert_filter']); ?> </a>');
$removeBtn.click(function (event) { function getAgentRow(layerId, agentId, agentAlias)
var $layerRow = $("tr#layer_row_" + layerId); {
var $row = $('<tr class="agents_list_item" />');
var $nameCol = $('<td />');
var $deleteCol = $('<td />');
var $agentAlias = $('<span class="agent_alias" data-agent-id="' + agentId + '">' + agentAlias + '</span>');
var $removeBtn = $('<a class="delete_row" href="javascript:" <?php echo html_print_image('images / cross.png', false, ['class' => 'invert_filter']); ?> </a>');
$removeBtn.click(
function (event) {
var $layerRow = $('tr#layer_row_' + layerId);
if ($layerRow.length > 0) { if ($layerRow.length > 0) {
$layerRow.find("input.layer_agent_id[data-agent-id='" + agentId + "']").remove(); $layerRow.find(("input.layer_agent_id[data-agent-id='" + agentId + "']")).remove();
$layerRow.find("input.layer_agent_alias[data-agent-id='" + agentId + "']").remove(); $layerRow.find(("input.layer_agent_alias[data-agent-id='" + agentId + "']")).remove();
} }
var $agentListItemRow = $(event.currentTarget).parent().parent(); var $agentListItemRow = $(event.currentTarget).parent().parent();
$agentListItemRow.remove(); $agentListItemRow.remove();
}); }
);
$nameCol.append($agentAlias); $nameCol.append($agentAlias);
$deleteCol.append($removeBtn); $deleteCol.append($removeBtn);
@ -1010,57 +1077,66 @@ function getAgentRow (layerId, agentId, agentAlias) {
$row.append($nameCol).append($deleteCol); $row.append($nameCol).append($deleteCol);
return $row; return $row;
}
function addAgentRow (layerId, agentId, agentAlias) {
if (agentId == null || agentId == 0 || agentAlias.length === 0) return;
var $layerRow = $("tr#layer_row_" + layerId);
if ($layerRow && $layerRow.find("input.layer_agent_id[value='" + agentId + "']").length === 0) {
$layerRow
.find("td:first-child")
.append(getLayerAgentIdInput(layerId, agentId))
.append(getLayerAgentAliasInput(layerId, agentId, agentAlias));
} }
$("table#list_agents").append(getAgentRow(layerId, agentId, agentAlias));
}
function getLayerAgentIdInput (layerId, agentId) { function addAgentRow(layerId, agentId, agentAlias)
return $("<input class=\"layer_agent_id\" type=\"hidden\" data-agent-id=\"" + agentId + "\" name=\"layers[" + layerId + "][agents][" + agentId + "][id]\" value=\"" + agentId + "\">"); {
} if (agentId == null || agentId == 0 || agentAlias.length === 0) {
return;
}
function getLayerAgentAliasInput (layerId, agentId, agentAlias) { var $layerRow = $('tr#layer_row_' + layerId);
return $("<input class=\"layer_agent_alias\" type=\"hidden\" data-agent-id=\"" + agentId + "\" name=\"layers[" + layerId + "][agents][" + agentId + "][alias]\" value=\"" + agentAlias + "\">"); if ($layerRow && $layerRow.find(("input.layer_agent_id[value='" + agentId + "']")).length === 0) {
} $layerRow.find('td:first-child').append(getLayerAgentIdInput(layerId, agentId)).append(getLayerAgentAliasInput(layerId, agentId, agentAlias));
}
function getGroupRow (layerId, groupId, groupName, agentId, agentAlias) { $('table#list_agents').append(getAgentRow(layerId, agentId, agentAlias));
var $row = $("<tr class=\"groups_list_item\" data-group-id=\"" + groupId + "\" data-group-name=\"" + groupName + "\" data-agent-id=\"" + agentId + "\" data-agent-alias=\"" + agentAlias + "\" />"); }
var $nameCol = $("<td />");
var $deleteCol = $("<td />");
var $groupName = $("<span class=\"group_desc\">"
function getLayerAgentIdInput(layerId, agentId)
{
return $('<input class="layer_agent_id" type="hidden" data-agent-id="' + agentId + '" name="layers[' + layerId + '][agents][' + agentId + '][id]" value="' + agentId + '">');
}
function getLayerAgentAliasInput(layerId, agentId, agentAlias)
{
return $('<input class="layer_agent_alias" type="hidden" data-agent-id="' + agentId + '" name="layers[' + layerId + '][agents][' + agentId + '][alias]" value="' + agentAlias + '">');
}
function getGroupRow(layerId, groupId, groupName, agentId, agentAlias)
{
var $row = $('<tr class="groups_list_item" data-group-id="' + groupId + '" data-group-name="' + groupName + '" data-agent-id="' + agentId + '" data-agent-alias="' + agentAlias + '" />');
var $nameCol = $('<td />');
var $deleteCol = $('<td />');
var $groupName = $('<span class="group_desc">'
+ groupName + groupName
+ " (" + ' ('
+ "<?php echo __('Using data from'); ?> " + "<?php echo __('Using data from'); ?> "
+ "<i>" + agentAlias + "</i>" + '<i>' + agentAlias + '</i>'
+ ")" + ')'
+ "</span>"); + '</span>');
var $removeBtn = $('<a class="delete_row" href="javascript:;"><?php echo html_print_image('images/cross.png', true, ['class' => 'invert_filter']); ?></a>'); var $removeBtn = $('<a class="delete_row" href="javascript:;"><?php echo html_print_image('images / cross.png', true, ['class' => 'invert_filter']); ?></a>');
$removeBtn.click(function (event) { $removeBtn.click(
var $layerRow = $("tr#layer_row_" + layerId); function (event) {
var $layerRow = $('tr#layer_row_' + layerId);
if ($layerRow.length > 0) { if ($layerRow.length > 0) {
$layerRow.find("input.layer_group_id[data-group-id='" + groupId + "']").remove(); $layerRow.find(("input.layer_group_id[data-group-id='" + groupId + "']")).remove();
$layerRow.find("input.layer_group_name[data-group-id='" + groupId + "']").remove(); $layerRow.find(("input.layer_group_name[data-group-id='" + groupId + "']")).remove();
$layerRow.find("input.layer_agent_id_for_data[data-group-id='" + groupId + "']").remove(); $layerRow.find(("input.layer_agent_id_for_data[data-group-id='" + groupId + "']")).remove();
$layerRow.find("input.layer_agent_alias_for_data[data-group-id='" + groupId + "']").remove(); $layerRow.find(("input.layer_agent_alias_for_data[data-group-id='" + groupId + "']")).remove();
} }
var $groupListItemRow = $(event.currentTarget).parent().parent(); var $groupListItemRow = $(event.currentTarget).parent().parent();
$groupListItemRow.remove(); $groupListItemRow.remove();
}); }
);
$nameCol.append($groupName); $nameCol.append($groupName);
$deleteCol.append($removeBtn); $deleteCol.append($removeBtn);
@ -1068,134 +1144,146 @@ function getGroupRow (layerId, groupId, groupName, agentId, agentAlias) {
$row.append($nameCol).append($deleteCol); $row.append($nameCol).append($deleteCol);
return $row; return $row;
}
function addGroupRow (layerId, groupId, groupName, agentId, agentAlias) {
if (
groupId == null ||
groupId == 0 ||
groupName.length === 0 ||
agentId == null ||
agentId == 0 ||
agentAlias.length === 0
) return;
var $layerRow = $("tr#layer_row_" + layerId);
if ($layerRow && $layerRow.find("input.layer_group_id[value='" + groupId + "']").length === 0) {
$layerRow
.find("td:first-child")
.append(getLayerGroupIdInput(layerId, groupId))
.append(getLayerGroupNameInput(layerId, groupId, groupName))
.append(getLayerAgentIdForDataInput(layerId, groupId, agentId))
.append(getLayerAgentAliasForDataInput(layerId, groupId, agentAlias));
} }
$("table#list_groups").append(getGroupRow(layerId, groupId, groupName, agentId, agentAlias));
}
function getLayerGroupIdInput (layerId, groupId) { function addGroupRow(layerId, groupId, groupName, agentId, agentAlias)
return $("<input class=\"layer_group_id\" type=\"hidden\" data-group-id=\"" + groupId + "\" name=\"layers[" + layerId + "][groups][" + groupId + "][id]\" value=\"" + groupId + "\">"); {
} if (groupId == null
|| groupId == 0
|| groupName.length === 0
|| agentId == null
|| agentId == 0
|| agentAlias.length === 0
) {
return;
}
function getLayerGroupNameInput (layerId, groupId, groupName) { var $layerRow = $('tr#layer_row_' + layerId);
return $("<input class=\"layer_group_name\" type=\"hidden\" data-group-id=\"" + groupId + "\" name=\"layers[" + layerId + "][groups][" + groupId + "][name]\" value=\"" + groupName + "\">"); if ($layerRow && $layerRow.find(("input.layer_group_id[value='" + groupId + "']")).length === 0) {
} $layerRow.find('td:first-child').append(getLayerGroupIdInput(layerId, groupId)).append(getLayerGroupNameInput(layerId, groupId, groupName)).append(getLayerAgentIdForDataInput(layerId, groupId, agentId)).append(getLayerAgentAliasForDataInput(layerId, groupId, agentAlias));
}
function getLayerAgentIdForDataInput (layerId, groupId, agentId) { $('table#list_groups').append(getGroupRow(layerId, groupId, groupName, agentId, agentAlias));
return $("<input class=\"layer_agent_id_for_data\" type=\"hidden\" data-group-id=\"" + groupId + "\" name=\"layers[" + layerId + "][groups][" + groupId + "][agent_id]\" value=\"" + agentId + "\">"); }
}
function getLayerAgentAliasForDataInput (layerId, groupId, agentAlias) {
return $("<input class=\"layer_agent_alias_for_data\" type=\"hidden\" data-group-id=\"" + groupId + "\" name=\"layers[" + layerId + "][groups][" + groupId + "][agent_alias]\" value=\"" + agentAlias + "\">");
}
function getLayerRow (layerId, layerData) { function getLayerGroupIdInput(layerId, groupId)
var $row = $("<tr id=\"layer_row_" + layerId + "\" class=\"layer_row\" />"); {
var $nameCol = $("<td />"); return $('<input class="layer_group_id" type="hidden" data-group-id="' + groupId + '" name="layers[' + layerId + '][groups][' + groupId + '][id]" value="' + groupId + '">');
var $sortCol = $("<td />"); }
var $editCol = $("<td />");
var $deleteCol = $("<td />");
var $layerIdInput = $("<input class=\"layer_id\" type=\"hidden\" name=\"layer_ids[]\" value=\"" + layerId + "\">");
var $layerNameInput = $("<input class=\"layer_name\" type=\"hidden\" name=\"layers[" + layerId + "][name]\" value=\"" + layerData.name + "\">");
var $layerVisibleInput = $("<input class=\"layer_visible\" type=\"hidden\" name=\"layers[" + layerId + "][visible]\" value=\"" + (layerData.visible ? 1 : 0) + "\">");
var $layerAgentsFromGroupInput = $("<input class=\"layer_agents_from_group\" type=\"hidden\" name=\"layers[" + layerId + "][agents_from_group]\" value=\"" + layerData.agentsFromGroup + "\">");
var $layerName = $("<span class=\"layer_name\">" + layerData.name + "</span>"); function getLayerGroupNameInput(layerId, groupId, groupName)
var $sortUpBtn = $("<a class=\"up_arrow\" href=\"javascript:;\" />"); {
var $sortDownBtn = $("<a class=\"down_arrow\" href=\"javascript:;\" />"); return $('<input class="layer_group_name" type="hidden" data-group-id="' + groupId + '" name="layers[' + layerId + '][groups][' + groupId + '][name]" value="' + groupName + '">');
var $editBtn = $('<a class="edit_layer" href="javascript:;"><?php echo html_print_image('images/config.png', true, ['class' => 'invert_filter']); ?></a>'); }
var $removeBtn = $('<a class="delete_row" href="javascript:;"><?php echo html_print_image('images/cross.png', true, ['class' => 'invert_filter']); ?></a>');
function getLayerAgentIdForDataInput(layerId, groupId, agentId)
{
return $('<input class="layer_agent_id_for_data" type="hidden" data-group-id="' + groupId + '" name="layers[' + layerId + '][groups][' + groupId + '][agent_id]" value="' + agentId + '">');
}
function getLayerAgentAliasForDataInput(layerId, groupId, agentAlias)
{
return $('<input class="layer_agent_alias_for_data" type="hidden" data-group-id="' + groupId + '" name="layers[' + layerId + '][groups][' + groupId + '][agent_alias]" value="' + agentAlias + '">');
}
function getLayerRow(layerId, layerData)
{
var $row = $('<tr id="layer_row_' + layerId + '" class="layer_row" />');
var $nameCol = $('<td />');
var $sortCol = $('<td />');
var $editCol = $('<td />');
var $deleteCol = $('<td />');
var $layerIdInput = $('<input class="layer_id" type="hidden" name="layer_ids[]" value="' + layerId + '">');
var $layerNameInput = $('<input class="layer_name" type="hidden" name="layers[' + layerId + '][name]" value="' + layerData.name + '">');
var $layerVisibleInput = $('<input class="layer_visible" type="hidden" name="layers[' + layerId + '][visible]" value="' + (layerData.visible ? 1 : 0) + '">');
var $layerAgentsFromGroupInput = $('<input class="layer_agents_from_group" type="hidden" name="layers[' + layerId + '][agents_from_group]" value="' + layerData.agentsFromGroup + '">');
var $layerName = $('<span class="layer_name">' + layerData.name + '</span>');
var $sortUpBtn = $('<a class="up_arrow" href="javascript:;" />');
var $sortDownBtn = $('<a class="down_arrow" href="javascript:;" />');
var $editBtn = $('<a class="edit_layer" href="javascript:;"><?php echo html_print_image('images / config.png', true, ['class' => 'invert_filter']); ?></a>');
var $removeBtn = $('<a class="delete_row" href="javascript:;"><?php echo html_print_image('images / cross.png', true, ['class' => 'invert_filter']); ?></a>');
$sortUpBtn.click(moveLayerRowUpOnClick); $sortUpBtn.click(moveLayerRowUpOnClick);
$sortDownBtn.click(moveLayerRowDownOnClick); $sortDownBtn.click(moveLayerRowDownOnClick);
$editBtn.click(function () { showLayerEditor(layerId); }); $editBtn.click(
function () {
showLayerEditor(layerId);
}
);
$removeBtn.click(removeLayerRowOnClick); $removeBtn.click(removeLayerRowOnClick);
$nameCol $nameCol.append($layerName).append($layerIdInput).append($layerNameInput).append($layerVisibleInput).append($layerAgentsFromGroupInput);
.append($layerName)
.append($layerIdInput)
.append($layerNameInput)
.append($layerVisibleInput)
.append($layerAgentsFromGroupInput);
if (layerData.agents && layerData.agents.length > 0) { if (layerData.agents && layerData.agents.length > 0) {
layerData.agents.forEach(function (agent) { layerData.agents.foreach (function (agent) {
$nameCol.append(getLayerAgentIdInput(layerId, agent.id)); $nameCol.append(getLayerAgentIdInput(layerId, agent.id));
$nameCol.append(getLayerAgentAliasInput(layerId, agent.id, agent.alias)); $nameCol.append(getLayerAgentAliasInput(layerId, agent.id, agent.alias));
}); }) {
}
} }
if (layerData.groups && layerData.groups.length > 0) { if (layerData.groups && layerData.groups.length > 0) {
layerData.groups.forEach(function (group) { layerData.groups.foreach (function (group) {
$nameCol.append(getLayerGroupIdInput(layerId, group.id)); $nameCol.append(getLayerGroupIdInput(layerId, group.id));
$nameCol.append(getLayerGroupNameInput(layerId, group.id, group.name)); $nameCol.append(getLayerGroupNameInput(layerId, group.id, group.name));
$nameCol.append(getLayerAgentIdForDataInput(layerId, group.id, group.agentId)); $nameCol.append(getLayerAgentIdForDataInput(layerId, group.id, group.agentId));
$nameCol.append(getLayerAgentAliasForDataInput(layerId, group.id, group.agentAlias)); $nameCol.append(getLayerAgentAliasForDataInput(layerId, group.id, group.agentAlias));
}); }) {
}
} }
$sortCol $sortCol.append($sortUpBtn).append($sortDownBtn);
.append($sortUpBtn) $editCol.append($editBtn);
.append($sortDownBtn); $deleteCol.append($removeBtn);
$editCol
.append($editBtn);
$deleteCol
.append($removeBtn);
$row $row.append($nameCol).append($sortCol).append($editCol).append($deleteCol);
.append($nameCol)
.append($sortCol)
.append($editCol)
.append($deleteCol);
return $row; return $row;
} }
function addLayerRow (layerId, layerData) {
$("table#list_layers").append(getLayerRow(layerId, layerData)); function addLayerRow(layerId, layerData)
{
$('table#list_layers').append(getLayerRow(layerId, layerData));
showLayerEditor(layerId); showLayerEditor(layerId);
} }
function hightlightRow (layerId) {
var highlightColor = "#E9F3D2";
$("tr.layer_row").css("background", "");
$("tr#layer_row_" + layerId).css("background", highlightColor);
}
function existInvalidLayerNames () { function hightlightRow(layerId)
{
var highlightColor = '#E9F3D2';
$('tr.layer_row').css('background', '');
$('tr#layer_row_' + layerId).css('background', highlightColor);
}
function existInvalidLayerNames()
{
var exist = false; var exist = false;
$("table#list_layers input.layer_name").each(function () { $('table#list_layers input.layer_name').each(
function () {
if ($(this).val().trim().length === 0) { if ($(this).val().trim().length === 0) {
exist = true; exist = true;
return false; // Break jQuery object each return false;
// Break jQuery object each
} }
}); }
);
return exist; return exist;
} }
function onFormSubmit (event) {
function onFormSubmit(event)
{
// Validate layer names // Validate layer names
if (existInvalidLayerNames()) { if (existInvalidLayerNames()) {
event.preventDefault(); event.preventDefault();
@ -1203,25 +1291,31 @@ function onFormSubmit (event) {
alert("<?php echo __('Empty layer names are not supported'); ?>"); alert("<?php echo __('Empty layer names are not supported'); ?>");
return false; return false;
} }
// Save connection list // Save connection list
$('#map_connection_list').val(connectionMaps.toString()); $('#map_connection_list').val(connectionMaps.toString());
} }
function onLayerGroupIdChange (event) {
function onLayerGroupIdChange(event)
{
// Clear agent inputs // Clear agent inputs
$("input#hidden-agent_id_for_data").val(0); $('input#hidden-agent_id_for_data').val(0);
$("input#text-agent_alias_for_data").val(""); $('input#text-agent_alias_for_data').val('');
toggleAddGroupBtn(); toggleAddGroupBtn();
} }
// Bind events
$("form#form_setup").submit(onFormSubmit);
$("input#button-add_agent").click(addAgentClick);
$("select#layer_group_id").change(onLayerGroupIdChange);
$("input#button-add_group").click(addGroupClick);
// Populate layer list // Bind events
var layers = <?php echo json_encode($layer_list); ?>; $('form#form_setup').submit(onFormSubmit);
$('input#button-add_agent').click(addAgentClick);
$('select#layer_group_id').change(onLayerGroupIdChange);
$('input#button-add_group').click(addGroupClick);
// Populate layer list
var layers = < ? php echo json_encode($layer_list);
?>
;
layers.forEach(function (layer) { layers.forEach(function (layer) {
$("table#list_layers").append( $("table#list_layers").append(
getLayerRow(layer["id"], { getLayerRow(layer["id"], {

View File

@ -385,8 +385,8 @@ if (check_acl($config['id_user'], 0, 'PM') || check_acl($config['id_user'], 0, '
if (check_acl($config['id_user'], 0, 'PM')) { if (check_acl($config['id_user'], 0, 'PM')) {
// Audit //meter en extensiones. // Audit //meter en extensiones.
$sub['godmode/admin_access_logs']['text'] = __('System audit log'); $sub['godmode/audit_log']['text'] = __('System audit log');
$sub['godmode/admin_access_logs']['id'] = 'System audit log'; $sub['godmode/audit_log']['id'] = 'System audit log';
$sub['godmode/setup/links']['text'] = __('Links'); $sub['godmode/setup/links']['text'] = __('Links');
$sub['godmode/setup/links']['id'] = 'Links'; $sub['godmode/setup/links']['id'] = 'Links';
$sub['tools/diagnostics']['text'] = __('Diagnostic info'); $sub['tools/diagnostics']['text'] = __('Diagnostic info');
@ -406,6 +406,7 @@ if (check_acl($config['id_user'], 0, 'PM') || check_acl($config['id_user'], 0, '
$sub['extensions/dbmanager']['text'] = __('DB Interface'); $sub['extensions/dbmanager']['text'] = __('DB Interface');
$sub['extensions/dbmanager']['id'] = 'DB Interface'; $sub['extensions/dbmanager']['id'] = 'DB Interface';
$sub['extensions/dbmanager']['sec'] = 'gbman'; $sub['extensions/dbmanager']['sec'] = 'gbman';
enterprise_hook('dbBackupManager');
enterprise_hook('elasticsearch_interface_menu'); enterprise_hook('elasticsearch_interface_menu');
} }
} }

View File

@ -211,7 +211,7 @@ switch ($action) {
$failover_type = REPORT_FAILOVER_TYPE_NORMAL; $failover_type = REPORT_FAILOVER_TYPE_NORMAL;
$server_name = ''; $server_name = '';
$server_id = 0; $server_id = 0;
$dyn_height = 230; $dyn_height = (empty($config['graph_image_height']) === false) ? $config['graph_image_height'] : REPORT_ITEM_DYNAMIC_HEIGHT;
$landscape = false; $landscape = false;
$pagebreak = false; $pagebreak = false;
$summary = 0; $summary = 0;
@ -252,7 +252,7 @@ switch ($action) {
$server_name = ''; $server_name = '';
$server_id = 0; $server_id = 0;
$get_data_editor = false; $get_data_editor = false;
$dyn_height = 230; $dyn_height = (empty($config['graph_image_height']) === false) ? $config['graph_image_height'] : REPORT_ITEM_DYNAMIC_HEIGHT;
break; break;
} }

View File

@ -1362,6 +1362,10 @@ if ($get_extended_event) {
$timestamp_first = $event['min_timestamp']; $timestamp_first = $event['min_timestamp'];
$timestamp_last = $event['max_timestamp']; $timestamp_last = $event['max_timestamp'];
$server_id = $event['server_id']; $server_id = $event['server_id'];
if (empty($server_id) && !empty($event['server_name']) && is_metaconsole()) {
$server_id = metaconsole_get_id_server($event['server_name']);
}
$comments = $event['comments']; $comments = $event['comments'];
$event['similar_ids'] = $similar_ids; $event['similar_ids'] = $similar_ids;
@ -1537,7 +1541,7 @@ if ($get_extended_event) {
$console_url = ''; $console_url = '';
// If metaconsole switch to node to get details and custom fields. // If metaconsole switch to node to get details and custom fields.
if ($meta) { if ($meta || (is_metaconsole() && !empty($server_id))) {
$server = metaconsole_get_connection_by_id($server_id); $server = metaconsole_get_connection_by_id($server_id);
} else { } else {
$server = ''; $server = '';
@ -1550,7 +1554,7 @@ if ($get_extended_event) {
} }
$connected = true; $connected = true;
if ($meta) { if ($meta || (is_metaconsole() && !empty($server_id))) {
if (metaconsole_connect($server) === NOERR) { if (metaconsole_connect($server) === NOERR) {
$connected = true; $connected = true;
} else { } else {

View File

@ -36,6 +36,7 @@ $ajax = true;
$render_map = (bool) get_parameter('render_map', false); $render_map = (bool) get_parameter('render_map', false);
$graph_javascript = (bool) get_parameter('graph_javascript', false); $graph_javascript = (bool) get_parameter('graph_javascript', false);
$force_remote_check = (bool) get_parameter('force_remote_check', false);
if ($render_map) { if ($render_map) {
$width = (int) get_parameter('width', '400'); $width = (int) get_parameter('width', '400');
@ -55,3 +56,36 @@ if ($render_map) {
); );
return; return;
} }
if ($force_remote_check) {
$id_layout = (int) get_parameter('id_layout', false);
$data = db_get_all_rows_sql(
sprintf(
'SELECT id_agent FROM tlayout_data WHERE id_layout = %d AND id_agent <> 0',
$id_layout
)
);
if (empty($data)) {
echo '0';
} else {
$ids = [];
foreach ($data as $key => $value) {
$ids[] = $value['id_agent'];
}
$sql = sprintf(
'UPDATE `tagente_modulo` SET flag = 1 WHERE `id_agente` IN (%s)',
implode(',', $ids)
);
$result = db_process_sql($sql);
if ($result) {
echo true;
} else {
echo '0';
}
}
return;
}

View File

@ -1389,7 +1389,10 @@ class AgentWizard extends HTML
foreach (array_keys($data) as $k) { foreach (array_keys($data) as $k) {
foreach ($modulesActivated as $key => $value) { foreach ($modulesActivated as $key => $value) {
$valueStr = preg_replace('/\//', '\/', $value); $valueStr = preg_replace('/\//', '\/', $value);
if (empty(preg_match('/-'.$valueStr.'$/', $k)) === false) {
if (empty(preg_match('/-'.$valueStr.'$/', $k)) === false
|| empty(preg_match('/-'.$valueStr.'_sent$/', $k)) === false
) {
if (empty(preg_match('/module-name-set/', $k)) === false) { if (empty(preg_match('/module-name-set/', $k)) === false) {
$result[$value]['name'] = $data[$k]; $result[$value]['name'] = $data[$k];
} else if (empty(preg_match('/module-description-set/', $k)) === false) { } else if (empty(preg_match('/module-description-set/', $k)) === false) {
@ -1417,6 +1420,42 @@ class AgentWizard extends HTML
continue; continue;
} else if (empty(preg_match('/module-unit/', $k)) === false) { } else if (empty(preg_match('/module-unit/', $k)) === false) {
$result[$value]['unit'] = $data['module-unit-'.$key]; $result[$value]['unit'] = $data['module-unit-'.$key];
continue;
} else if (empty(preg_match('/module-warning-min/', $k)) === false) {
$result[$value]['warningMin'] = $data['module-warning-min-0_0-0'];
continue;
} else if (empty(preg_match('/module-warning-max/', $k)) === false) {
$result[$value]['warningMax'] = $data['module-warning-max-0_0-0'];
continue;
} else if (empty(preg_match('/module-critical-min/', $k)) === false) {
$result[$value]['criticalMin'] = $data['module-critical-min-0_0-0'];
continue;
} else if (empty(preg_match('/module-critical-max/', $k)) === false) {
$result[$value]['criticalMax'] = $data['module-critical-max-0_0-0'];
continue;
} else if (empty(preg_match('/module-critical-inv/', $k)) === false) {
if (isset($data['module-critical-inv-0_0-0'])) {
$result[$value]['criticalInv'] = $data['module-critical-inv-0_0-0_sent'];
}
continue;
} else if (empty(preg_match('/module-warning-inv/', $k)) === false) {
if (isset($data['module-warning-inv-0_0-0'])) {
$result[$value]['warningInv'] = $data['module-warning-inv-0_0-0_sent'];
}
continue;
} else if (empty(preg_match('/module-warning-perc/', $k)) === false) {
if (isset($data['module-warning-perc-0_0-0'])) {
$result[$value]['warningPerc'] = $data['module-warning-perc-0_0-0_sent'];
}
continue;
} else if (empty(preg_match('/module-critical-perc/', $k)) === false) {
if (isset($data['module-critical-perc-0_0-0'])) {
$result[$value]['criticalPerc'] = $data['module-critical-perc-0_0-0_sent'];
}
continue; continue;
} }
@ -1429,6 +1468,10 @@ class AgentWizard extends HTML
} }
} }
if (empty(preg_match('/-'.$valueStr.'_sent$/', $k)) === false) {
continue;
}
if (empty(preg_match('/module-warning-min/', $k)) === false) { if (empty(preg_match('/module-warning-min/', $k)) === false) {
$result[$value]['warningMin'] = $data[$k]; $result[$value]['warningMin'] = $data[$k];
} else if (empty(preg_match('/module-warning-max/', $k)) === false) { } else if (empty(preg_match('/module-warning-max/', $k)) === false) {
@ -1438,9 +1481,9 @@ class AgentWizard extends HTML
} else if (empty(preg_match('/module-critical-max/', $k)) === false) { } else if (empty(preg_match('/module-critical-max/', $k)) === false) {
$result[$value]['criticalMax'] = $data[$k]; $result[$value]['criticalMax'] = $data[$k];
} else if (empty(preg_match('/module-critical-inv/', $k)) === false) { } else if (empty(preg_match('/module-critical-inv/', $k)) === false) {
$result[$value]['criticalInv'] = $data[$k]; $result[$value]['criticalInv'] = $data[$k.'_sent'];
} else if (empty(preg_match('/module-warning-inv/', $k)) === false) { } else if (empty(preg_match('/module-warning-inv/', $k)) === false) {
$result[$value]['warningInv'] = $data[$k]; $result[$value]['warningInv'] = $data[$k.'_sent'];
} else if (empty(preg_match('/module-warning-perc/', $k)) === false) { } else if (empty(preg_match('/module-warning-perc/', $k)) === false) {
$result[$value]['warningPerc'] = $data[$k.'_sent']; $result[$value]['warningPerc'] = $data[$k.'_sent'];
} else if (empty(preg_match('/module-critical-perc/', $k)) === false) { } else if (empty(preg_match('/module-critical-perc/', $k)) === false) {

View File

@ -0,0 +1,410 @@
<?php
// phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
/**
* Controller for Audit Logs
*
* @category Controller
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
global $config;
// Necessary classes for extends.
require_once $config['homedir'].'/include/class/HTML.class.php';
enterprise_include_once('godmode/admin_access_logs.php');
/**
* Class AuditLog
*/
class AuditLog extends HTML
{
/**
* Allowed methods to be called using AJAX request.
*
* @var array
*/
public $AJAXMethods = [ 'draw' ];
/**
* Ajax page.
*
* @var string
*/
private $ajaxController;
/**
* Class constructor
*
* @param string $ajaxController Ajax controller.
*/
public function __construct(string $ajaxController)
{
global $config;
check_login();
if (check_acl($config['id_user'], 0, 'PM') === false
&& is_user_admin($config['id_user']) === true
) {
db_pandora_audit(
'ACL Violation',
'Trying to access Audit Logs'
);
include 'general/noaccess.php';
return;
}
// Set the ajax controller.
$this->ajaxController = $ajaxController;
}
/**
* Run view
*
* @return void
*/
public function run()
{
// Javascript.
ui_require_jquery_file('pandora');
// CSS.
ui_require_css_file('wizard');
ui_require_css_file('discovery');
// Datatables list.
try {
$columns = [
'id_usuario',
'accion',
'fecha',
'ip_origen',
'descripcion',
];
$column_names = [
__('User'),
__('Action'),
__('Date'),
__('Source IP'),
__('Comments'),
];
if (enterprise_installed() === true) {
array_push(
$columns,
[
'text' => 'security',
'class' => 'w80px action_buttons show_security_info',
],
[
'text' => 'action',
'class' => 'w80px action_buttons show_extended_info',
]
);
array_push($column_names, __('S.'), __('A.'));
}
$this->tableId = 'audit_logs';
// Header (only in Node).
if (is_metaconsole() === false) {
ui_print_standard_header(
__('%s audit', get_product_name()).' &raquo; '.__('Review Logs'),
'images/gm_log.png',
false,
'',
false,
[],
[
[
'link' => '',
'label' => __('Admin Tools'),
],
[
'link' => '',
'label' => __('System Audit log'),
],
]
);
}
if (is_metaconsole() === true) {
// Only in case of Metaconsole, format the frame.
open_meta_frame();
}
// Load datatables user interface.
ui_print_datatable(
[
'id' => $this->tableId,
'class' => 'info_table',
'style' => 'width: 100%',
'columns' => $columns,
'column_names' => $column_names,
'ajax_url' => $this->ajaxController,
'ajax_data' => ['method' => 'draw'],
'ajax_postprocces' => 'process_datatables_item(item)',
'no_sortable_columns' => [-1],
'order' => [
'field' => 'date',
'direction' => 'asc',
],
'search_button_class' => 'sub filter float-right',
'form' => [
'inputs' => [
[
'label' => __('Search'),
'type' => 'text',
'class' => 'w200px',
'id' => 'filter_text',
'name' => 'filter_text',
],
[
'label' => __('Max. hours old'),
'type' => 'text',
'class' => 'w100px',
'id' => 'filter_period',
'name' => 'filter_period',
],
[
'label' => __('IP'),
'type' => 'text',
'class' => 'w100px',
'id' => 'filter_ip',
'name' => 'filter_ip',
],
[
'label' => __('Action'),
'type' => 'select_from_sql',
'nothing' => __('All'),
'nothing_value' => '-1',
'sql' => 'SELECT DISTINCT(accion), accion AS text FROM tsesion',
'class' => 'mw250px',
'id' => 'filter_type',
'name' => 'filter_type',
],
[
'label' => __('User'),
'type' => 'select_from_sql',
'nothing' => __('All'),
'nothing_value' => '-1',
'sql' => 'SELECT id_user, id_user AS text FROM tusuario',
'class' => 'mw250px',
'id' => 'filter_user',
'name' => 'filter_user',
],
],
],
]
);
} catch (Exception $e) {
echo $e->getMessage();
}
if (is_metaconsole() === true) {
// Close the frame.
close_meta_frame();
}
// Load own javascript file.
echo $this->loadJS();
}
/**
* Get the data for draw the table.
*
* @return void.
*/
public function draw()
{
global $config;
// Initialice filter.
$filter = '1=1';
// Init data.
$data = [];
// Count of total records.
$count = 0;
// Catch post parameters.
$start = get_parameter('start', 0);
$length = get_parameter('length', $config['block_size']);
$order = get_datatable_order();
$filters = get_parameter('filter', []);
$this->filterType = $filters['filter_type'];
$this->filterUser = $filters['filter_user'];
$this->filterText = $filters['filter_text'];
$this->filterPeriod = (empty($filters['filter_period']) === false) ? $filters['filter_period'] : 24;
$this->filterIp = $filters['filter_ip'];
if (empty($this->filterType) === false && $this->filterType !== '-1') {
$filter .= sprintf(" AND accion = '%s'", $this->filterType);
}
if (empty($this->filterUser) === false && $this->filterUser !== '-1') {
$filter .= sprintf(" AND id_usuario = '%s'", $this->filterUser);
}
if (empty($this->filterText) === false) {
$filter .= sprintf(
" AND (accion LIKE '%%%s%%' OR descripcion LIKE '%%%s%%')",
$this->filterText,
$this->filterText
);
}
if (empty($this->filterIp) === false) {
$filter .= sprintf(" AND ip_origen LIKE '%%%s%%'", $this->filterIp);
}
if (empty($this->filterPeriod) === false) {
$filter .= sprintf(' AND fecha >= DATE_ADD(NOW(), INTERVAL -%d HOUR)', $this->filterPeriod);
}
$count = (int) db_get_value_sql(sprintf('SELECT COUNT(*) as "total" FROM tsesion WHERE %s', $filter));
$sql = sprintf(
'SELECT *
FROM tsesion
WHERE %s
ORDER BY %s
LIMIT %d, %d',
$filter,
$order,
$start,
$length
);
$data = db_get_all_rows_sql($sql);
if (empty($data) === false) {
$data = array_reduce(
$data,
function ($carry, $item) {
global $config;
// Transforms array of arrays $data into an array
// of objects, making a post-process of certain fields.
$tmp = (object) $item;
$tmp->id_usuario = io_safe_output($tmp->id_usuario);
$tmp->ip_origen = io_safe_output($tmp->ip_origen);
$tmp->descripcion = io_safe_output($tmp->descripcion);
$tmp->accion = ui_print_session_action_icon($tmp->accion, true).$tmp->accion;
$tmp->utimestamp = ui_print_help_tip(
date(
$config['date_format'],
$tmp->utimestamp
),
true
).ui_print_timestamp($tmp->utimestamp, true);
if (enterprise_installed() === true) {
$tmp->security = enterprise_hook('cell1EntepriseAudit', [$tmp->id_sesion]);
$tmp->action = enterprise_hook('cell2EntepriseAudit', []);
$tmp->extendedInfo = enterprise_hook('rowEnterpriseAudit', [$tmp->id_sesion]);
}
$carry[] = $tmp;
return $carry;
}
);
}
echo json_encode(
[
'data' => $data,
'recordsTotal' => $count,
'recordsFiltered' => $count,
]
);
}
/**
* Checks if target method is available to be called using AJAX.
*
* @param string $method Target method.
*
* @return boolean True allowed, false not.
*/
public function ajaxMethod(string $method)
{
return in_array($method, $this->AJAXMethods);
}
/**
* Load Javascript code.
*
* @return string.
*/
public function loadJS()
{
// Nothing for this moment.
ob_start();
// Javascript content.
?>
<script type="text/javascript">
function format ( d ) {
var output = '';
if (d.extendedInfo === '') {
output = "<?php echo __('There is no additional information to display'); ?>";
} else {
output = d.extendedInfo;
}
return output;
}
$(document).ready(function() {
// Add event listener for opening and closing details
$('#audit_logs tbody').on('click', 'td.show_extended_info', function () {
var tr = $(this).closest('tr');
var table = <?php echo 'dt_'.$this->tableId; ?>;
var row = table.row( tr );
if ( row.child.isShown() ) {
// This row is already open - close it
row.child.hide();
tr.removeClass('shown');
}
else {
// Open this row
row.child( format(row.data()) ).show();
tr.addClass('shown');
}
} );
} );
</script>
<?php
// EOF Javascript content.
return ob_get_clean();
}
}

View File

@ -1256,8 +1256,7 @@ class ConsoleSupervisor
unix_timestamp() - unix_timestamp(keepalive) as downtime unix_timestamp() - unix_timestamp(keepalive) as downtime
FROM tserver FROM tserver
WHERE WHERE
unix_timestamp() - unix_timestamp(keepalive) > server_keepalive unix_timestamp() - unix_timestamp(keepalive) > server_keepalive'
OR status = 0'
); );
if ($servers === false) { if ($servers === false) {
@ -1298,13 +1297,12 @@ class ConsoleSupervisor
FROM tserver FROM tserver
WHERE WHERE
unix_timestamp() - unix_timestamp(keepalive) <= server_keepalive unix_timestamp() - unix_timestamp(keepalive) <= server_keepalive
OR status != 0' AND status = 1'
); );
if (is_array($servers_working) === true) { if (is_array($servers_working) === true) {
foreach ($servers_working as $server) { foreach ($servers_working as $server) {
$this->cleanNotifications( $this->cleanNotifications(
'NOTIF.SERVER.STATUS'.$server['id_server'] 'NOTIF.SERVER.STATUS.'.$server['id_server']
); );
} }
} }

View File

@ -20,7 +20,7 @@
/** /**
* Pandora build version and version * Pandora build version and version
*/ */
$build_version = 'PC211217'; $build_version = 'PC220125';
$pandora_version = 'v7.0NG.759'; $pandora_version = 'v7.0NG.759';
// Do not overwrite default timezone set if defined. // Do not overwrite default timezone set if defined.

View File

@ -113,6 +113,7 @@ define('SECONDS_3YEARS', 94608000);
// Separator constats. // Separator constats.
define('SEPARATOR_COLUMN', ';'); define('SEPARATOR_COLUMN', ';');
define('SEPARATOR_ROW', chr(10)); define('SEPARATOR_ROW', chr(10));
define('SEPARATOR_META_MODULE', '|-|-|-|');
// Chr(10) is \n. // Chr(10) is \n.
define('SEPARATOR_COLUMN_CSV', '#'); define('SEPARATOR_COLUMN_CSV', '#');
define('SEPARATOR_ROW_CSV', "@\n"); define('SEPARATOR_ROW_CSV', "@\n");
@ -456,6 +457,8 @@ define('REPORT_ITEM_ORDER_BY_ASCENDING', 2);
define('REPORT_ITEM_ORDER_BY_DESCENDING', 1); define('REPORT_ITEM_ORDER_BY_DESCENDING', 1);
define('REPORT_ITEM_ORDER_BY_UNSORT', 0); define('REPORT_ITEM_ORDER_BY_UNSORT', 0);
define('REPORT_ITEM_DYNAMIC_HEIGHT', 230);
define('REPORT_OLD_TYPE_SIMPLE_GRAPH', 1); define('REPORT_OLD_TYPE_SIMPLE_GRAPH', 1);
define('REPORT_OLD_TYPE_CUSTOM_GRAPH', 2); define('REPORT_OLD_TYPE_CUSTOM_GRAPH', 2);
define('REPORT_OLD_TYPE_SLA', 3); define('REPORT_OLD_TYPE_SLA', 3);

View File

@ -874,10 +874,10 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa
* *
* @return the first value of the first row of a table result from query. * @return the first value of the first row of a table result from query.
*/ */
function mysql_db_get_value_sql($sql, $dbconnection=false) function mysql_db_get_value_sql($sql, $dbconnection=false, $search_history_db=false)
{ {
$sql .= ' LIMIT 1'; $sql .= ' LIMIT 1';
$result = mysql_db_get_all_rows_sql($sql, false, true, $dbconnection); $result = mysql_db_get_all_rows_sql($sql, $search_history_db, true, $dbconnection);
if ($result === false) { if ($result === false) {
return false; return false;

View File

@ -977,10 +977,10 @@ function oracle_recode_query($sql, $values, $join='AND', $return=true)
* *
* @return the first value of the first row of a table result from query. * @return the first value of the first row of a table result from query.
*/ */
function oracle_db_get_value_sql($sql, $dbconnection=false) function oracle_db_get_value_sql($sql, $dbconnection=false, $search_history_db=false)
{ {
$sql = 'SELECT * FROM ('.$sql.') WHERE rownum < 2'; $sql = 'SELECT * FROM ('.$sql.') WHERE rownum < 2';
$result = oracle_db_get_all_rows_sql($sql, false, true, $dbconnection); $result = oracle_db_get_all_rows_sql($sql, $search_history_db, true, $dbconnection);
if ($result === false) { if ($result === false) {
return false; return false;

View File

@ -686,10 +686,10 @@ function postgresql_db_format_array_where_clause_sql($values, $join='AND', $pref
* *
* @return the first value of the first row of a table result from query. * @return the first value of the first row of a table result from query.
*/ */
function postgresql_db_get_value_sql($sql, $dbconnection=false) function postgresql_db_get_value_sql($sql, $dbconnection=false, $search_history_db=false)
{ {
$sql .= ' LIMIT 1'; $sql .= ' LIMIT 1';
$result = postgresql_db_get_all_rows_sql($sql, false, true, $dbconnection); $result = postgresql_db_get_all_rows_sql($sql, $search_history_db, true, $dbconnection);
if ($result === false) { if ($result === false) {
return false; return false;

View File

@ -5966,3 +5966,24 @@ function send_test_email(
return $result; return $result;
} }
if (function_exists('str_contains') === false) {
/**
* Checks if $needle is found in $haystack and returns a boolean value.
* For lower than PHP8 versions.
*
* @param string $haystack The string who can have the needle.
* @param string $needle The needle.
*
* @return boolean True if haystack contains the needle.
*/
function str_contains(string $haystack, string $needle)
{
return $needle !== '' && mb_strpos($haystack, $needle) !== false;
}
}

View File

@ -162,9 +162,13 @@ function agents_locate_agent(string $field)
* *
* @return array|boolean Agents ids or false if error. * @return array|boolean Agents ids or false if error.
*/ */
function agents_get_agent_id_by_alias($alias) function agents_get_agent_id_by_alias($alias, $is_metaconsole=false)
{ {
if ($is_metaconsole === true) {
return db_get_all_rows_sql("SELECT id_tagente FROM tmetaconsole_agent WHERE upper(alias) LIKE upper('%$alias%')");
} else {
return db_get_all_rows_sql("SELECT id_agente FROM tagente WHERE upper(alias) LIKE upper('%$alias%')"); return db_get_all_rows_sql("SELECT id_agente FROM tagente WHERE upper(alias) LIKE upper('%$alias%')");
}
} }

View File

@ -9925,12 +9925,19 @@ function otherParameter2Filter($other, $return_as_array=false, $use_agent_name=f
if (isset($other['data'][2]) && $other['data'][2] != '') { if (isset($other['data'][2]) && $other['data'][2] != '') {
if ($use_agent_name === false) { if ($use_agent_name === false) {
$idAgents = agents_get_agent_id_by_alias($other['data'][2]); $idAgents = agents_get_agent_id_by_alias($other['data'][2], is_metaconsole());
if (!empty($idAgents)) { if (!empty($idAgents)) {
$idAgent = []; $idAgent = [];
$id_agent_field = 'id_agente';
if (is_metaconsole() === true) {
$id_agent_field = 'id_tagente';
}
foreach ($idAgents as $key => $value) { foreach ($idAgents as $key => $value) {
$idAgent[] .= $value['id_agente']; $idAgent[] .= $value[$id_agent_field];
} }
$filter[] = 'id_agente IN ('.implode(',', $idAgent).')'; $filter[] = 'id_agente IN ('.implode(',', $idAgent).')';
@ -9985,6 +9992,10 @@ function otherParameter2Filter($other, $return_as_array=false, $use_agent_name=f
} }
} }
if (isset($idTemplate) && $idTemplate != '') {
$filter['id_alert_template'] = $idTemplate;
}
if (isset($other['data'][5]) && $other['data'][5] != '') { if (isset($other['data'][5]) && $other['data'][5] != '') {
$filter['id_usuario'] = $other['data'][5]; $filter['id_usuario'] = $other['data'][5];
} }
@ -11434,7 +11445,7 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
global $config; global $config;
$table_events = 'tevento'; $table_events = 'tevento';
if (defined('METACONSOLE')) { if (is_metaconsole() === true) {
$table_events = 'tmetaconsole_event'; $table_events = 'tmetaconsole_event';
} }
@ -11451,10 +11462,9 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
$event_view_hr = 0; $event_view_hr = 0;
$tag = ''; $tag = '';
$group_rep = 0; $group_rep = 0;
$offset = 0;
$pagination = 40;
$utimestamp_upper = 0; $utimestamp_upper = 0;
$utimestamp_bottom = 0; $utimestamp_bottom = 0;
$id_alert_template = -1;
$use_agent_name = ($other['data'][16] === '1') ? true : false; $use_agent_name = ($other['data'][16] === '1') ? true : false;
@ -11469,7 +11479,7 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
} }
if (isset($filter['id_agentmodule'])) { if (isset($filter['id_agentmodule'])) {
$id_agentmodule = $filter['id_agentmodule']; $id_agentmodule = $filter['id_agentmodule'][0];
} }
if (isset($filter['id_alert_am'])) { if (isset($filter['id_alert_am'])) {
@ -11488,12 +11498,8 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
$search = $filter['evento']; $search = $filter['evento'];
} }
if (isset($filter['limit'])) { if (isset($filter['id_alert_template'])) {
$pagination = $filter['limit']; $id_alert_template = $filter['id_alert_template'];
}
if (isset($filter['offset'])) {
$offset = $filter['offset'];
} }
$id_group = (int) $filter['id_group']; $id_group = (int) $filter['id_group'];
@ -11611,10 +11617,6 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
$sql_post .= ' AND id_agentmodule = '.$id_agentmodule; $sql_post .= ' AND id_agentmodule = '.$id_agentmodule;
} }
if ($id_alert_am != -1) {
$sql_post .= ' AND id_alert_am = '.$id_alert_am;
}
if ($id_event != -1) { if ($id_event != -1) {
$sql_post .= ' AND id_evento = '.$id_event; $sql_post .= ' AND id_evento = '.$id_event;
} }
@ -11647,6 +11649,21 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
$sql_post .= ' AND ('.$filter['sql'].') '; $sql_post .= ' AND ('.$filter['sql'].') ';
} }
// Inject agent ID filter (it is set as the first numeric key in filter array).
if (isset($filter[0]) === true) {
$sql_post .= ' AND '.$filter[0];
}
if ($id_alert_template !== -1) {
$sql_post .= ' AND talert_template_modules.id_alert_template = '.$id_alert_template;
}
$alert_join = '';
if ($id_alert_template !== -1) {
$alert_join = ' INNER JOIN talert_template_modules ON '.$table_events.'.id_alert_am=talert_template_modules.id';
}
if ($group_rep == 0) { if ($group_rep == 0) {
switch ($config['dbtype']) { switch ($config['dbtype']) {
case 'mysql': case 'mysql':
@ -11661,7 +11678,7 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
ORDER BY criticity DESC ORDER BY criticity DESC
LIMIT 1'; LIMIT 1';
} else { } else {
if (defined('METACONSOLE')) { if (is_metaconsole() === true) {
$sql = 'SELECT *, $sql = 'SELECT *,
(SELECT t2.nombre (SELECT t2.nombre
FROM tgrupo t2 FROM tgrupo t2
@ -11669,10 +11686,9 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
(SELECT t2.icon (SELECT t2.icon
FROM tgrupo t2 FROM tgrupo t2
WHERE t2.id_grupo = '.$table_events.'.id_grupo) AS group_icon WHERE t2.id_grupo = '.$table_events.'.id_grupo) AS group_icon
FROM '.$table_events.' FROM '.$table_events.$alert_join.'
WHERE 1=1 '.$sql_post.' WHERE 1=1 '.$sql_post.'
ORDER BY utimestamp DESC ORDER BY utimestamp DESC';
LIMIT '.$offset.','.$pagination;
} else { } else {
$sql = 'SELECT *, $sql = 'SELECT *,
(SELECT t1.alias (SELECT t1.alias
@ -11690,10 +11706,9 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
SELECT tagente_modulo.id_modulo SELECT tagente_modulo.id_modulo
FROM tagente_modulo FROM tagente_modulo
WHERE tagente_modulo.id_agente_modulo=tevento.id_agentmodule)) AS module_name WHERE tagente_modulo.id_agente_modulo=tevento.id_agentmodule)) AS module_name
FROM '.$table_events.' FROM '.$table_events.$alert_join.'
WHERE 1=1 '.$sql_post.' WHERE 1=1 '.$sql_post.'
ORDER BY utimestamp DESC ORDER BY utimestamp DESC';
LIMIT '.$offset.','.$pagination;
} }
} }
break; break;
@ -11718,15 +11733,12 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
WHERE tagente_modulo.id_agente_modulo=tevento.id_agentmodule)) AS module_name WHERE tagente_modulo.id_agente_modulo=tevento.id_agentmodule)) AS module_name
FROM tevento FROM tevento
WHERE 1=1 '.$sql_post.' WHERE 1=1 '.$sql_post.'
ORDER BY utimestamp DESC ORDER BY utimestamp DESC';
LIMIT '.$pagination.' OFFSET '.$offset;
break; break;
case 'oracle': case 'oracle':
// TODO TOTAL // TODO TOTAL
$set = []; $set = [];
$set['limit'] = $pagination;
$set['offset'] = $offset;
$sql = 'SELECT *, $sql = 'SELECT *,
(SELECT t1.alias (SELECT t1.alias
@ -11764,8 +11776,7 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
FROM ".$table_events.' FROM ".$table_events.'
WHERE 1=1 '.$sql_post.' WHERE 1=1 '.$sql_post.'
GROUP BY evento, id_agentmodule GROUP BY evento, id_agentmodule
ORDER BY timestamp_rep DESC ORDER BY timestamp_rep DESC';
LIMIT '.$offset.','.$pagination;
break; break;
case 'postgresql': case 'postgresql':
@ -11776,14 +11787,11 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
FROM ".$table_events.' FROM ".$table_events.'
WHERE 1=1 '.$sql_post.' WHERE 1=1 '.$sql_post.'
GROUP BY evento, id_agentmodule GROUP BY evento, id_agentmodule
ORDER BY timestamp_rep DESC ORDER BY timestamp_rep DESC';
LIMIT '.$pagination.' OFFSET '.$offset;
break; break;
case 'oracle': case 'oracle':
$set = []; $set = [];
$set['limit'] = $pagination;
$set['offset'] = $offset;
// TODO: Remove duplicate user comments // TODO: Remove duplicate user comments
$sql = 'SELECT a.*, b.event_rep, b.timestamp_rep $sql = 'SELECT a.*, b.event_rep, b.timestamp_rep
FROM (SELECT * FROM (SELECT *
@ -11971,7 +11979,7 @@ function api_set_event($id_event, $unused1, $params, $unused2, $unused3)
* @param $returnType * @param $returnType
* @param $user_in_db * @param $user_in_db
*/ */
function api_get_events($trash1, $trash2, $other, $returnType, $user_in_db=null) function api_get_events($node_id, $trash2, $other, $returnType, $user_in_db=null)
{ {
if ($user_in_db !== null) { if ($user_in_db !== null) {
$correct = get_events_with_user( $correct = get_events_with_user(
@ -12016,6 +12024,10 @@ function api_get_events($trash1, $trash2, $other, $returnType, $user_in_db=null)
} }
if (is_metaconsole()) { if (is_metaconsole()) {
if ((int) $node_id !== 0) {
$filterString .= ' AND server_id = '.$node_id;
}
$dataRows = db_get_all_rows_filter('tmetaconsole_event', $filterString); $dataRows = db_get_all_rows_filter('tmetaconsole_event', $filterString);
} else { } else {
$dataRows = db_get_all_rows_filter('tevento', $filterString); $dataRows = db_get_all_rows_filter('tevento', $filterString);
@ -15159,12 +15171,24 @@ function api_set_add_cluster_item($thrash1, $thrash2, $other, $thrash3)
} }
if ($element['type'] == 'AA') { if ($element['type'] == 'AA') {
$id_agent = db_get_value_sql('SELECT id_agent FROM tcluster WHERE id = '.$element['id_cluster']);
$module_exists_sql = sprintf(
'SELECT id_agente_modulo FROM tagente_modulo tam INNER JOIN tcluster_agent tca WHERE tam.id_agente=tca.id_agent AND tca.id_cluster=%d AND tam.nombre="%s"',
$element['id_cluster'],
io_safe_input($element['name'])
);
$module_exists = db_process_sql($module_exists_sql);
if ($module_exists === false) {
continue;
}
$tcluster_module = db_process_sql_insert('tcluster_item', ['name' => io_safe_input($element['name']), 'id_cluster' => $element['id_cluster'], 'critical_limit' => $element['critical_limit'], 'warning_limit' => $element['warning_limit']]); $tcluster_module = db_process_sql_insert('tcluster_item', ['name' => io_safe_input($element['name']), 'id_cluster' => $element['id_cluster'], 'critical_limit' => $element['critical_limit'], 'warning_limit' => $element['warning_limit']]);
$id_agent = db_process_sql('select id_agent from tcluster where id = '.$element['id_cluster']);
$id_parent_modulo = db_process_sql( $id_parent_modulo = db_process_sql(
'select id_agente_modulo from tagente_modulo where id_agente = '.$id_agent[0]['id_agent'].' and nombre = "'.io_safe_input('Cluster status').'"' 'select id_agente_modulo from tagente_modulo where id_agente = '.$id_agent.' and nombre = "'.io_safe_input('Cluster status').'"'
); );
$get_module_type = db_process_sql('select id_tipo_modulo,descripcion,min_warning,min_critical,module_interval from tagente_modulo where nombre = "'.io_safe_input($element['name']).'" limit 1'); $get_module_type = db_process_sql('select id_tipo_modulo,descripcion,min_warning,min_critical,module_interval from tagente_modulo where nombre = "'.io_safe_input($element['name']).'" limit 1');
@ -15179,7 +15203,7 @@ function api_set_add_cluster_item($thrash1, $thrash2, $other, $thrash3)
'nombre' => io_safe_input($element['name']), 'nombre' => io_safe_input($element['name']),
'id_modulo' => 0, 'id_modulo' => 0,
'prediction_module' => 6, 'prediction_module' => 6,
'id_agente' => $id_agent[0]['id_agent'], 'id_agente' => $id_agent,
'parent_module_id' => $id_parent_modulo[0]['id_agente_modulo'], 'parent_module_id' => $id_parent_modulo[0]['id_agente_modulo'],
'custom_integer_1' => $element['id_cluster'], 'custom_integer_1' => $element['id_cluster'],
'custom_integer_2' => $tcluster_module, 'custom_integer_2' => $tcluster_module,
@ -15203,15 +15227,27 @@ function api_set_add_cluster_item($thrash1, $thrash2, $other, $thrash3)
db_pandora_audit('Report management', 'Failed to assign AA item module to cluster '.$element['name']); db_pandora_audit('Report management', 'Failed to assign AA item module to cluster '.$element['name']);
} }
} else if ($element['type'] == 'AP') { } else if ($element['type'] == 'AP') {
$id_agent = db_process_sql('select id_agent from tcluster where id = '.$element['id_cluster']); $id_agent = db_get_value_sql('SELECT id_agent FROM tcluster WHERE id = '.$element['id_cluster']);
$id_parent_modulo = db_process_sql( $module_exists_sql = sprintf(
'select id_agente_modulo from tagente_modulo where id_agente = '.$id_agent[0]['id_agent'].' and nombre = "'.io_safe_input('Cluster status').'"' 'SELECT id_agente_modulo FROM tagente_modulo tam INNER JOIN tcluster_agent tca WHERE tam.id_agente=tca.id_agent AND tca.id_cluster=%d AND tam.nombre="%s"',
$element['id_cluster'],
io_safe_input($element['name'])
); );
$tcluster_balanced_module = db_process_sql_insert('tcluster_item', ['name' => $element['name'], 'id_cluster' => $element['id_cluster'], 'item_type' => 'AP', 'is_critical' => $element['is_critical']]); $module_exists = db_process_sql($module_exists_sql);
$get_module_type = db_process_sql('select id_tipo_modulo,descripcion,min_warning,min_critical,module_interval from tagente_modulo where nombre = "'.io_safe_input($element['name']).'" limit 1'); if ($module_exists === false) {
continue;
}
$id_parent_modulo = db_process_sql(
'select id_agente_modulo from tagente_modulo where id_agente = '.$id_agent.' and nombre = "'.io_safe_input('Cluster status').'"'
);
$tcluster_balanced_module = db_process_sql_insert('tcluster_item', ['name' => io_safe_input($element['name']), 'id_cluster' => $element['id_cluster'], 'item_type' => 'AP', 'is_critical' => $element['is_critical']]);
$get_module_type = db_process_sql('select id_tipo_modulo,descripcion,min_warning,min_critical,module_interval,ip_target,id_module_group from tagente_modulo where nombre = "'.io_safe_input($element['name']).'" limit 1');
$get_module_type_value = $get_module_type[0]['id_tipo_modulo']; $get_module_type_value = $get_module_type[0]['id_tipo_modulo'];
$get_module_description_value = $get_module_type[0]['descripcion']; $get_module_description_value = $get_module_type[0]['descripcion'];
@ -15220,33 +15256,28 @@ function api_set_add_cluster_item($thrash1, $thrash2, $other, $thrash3)
$get_module_interval_value = $get_module_type[0]['module_interval']; $get_module_interval_value = $get_module_type[0]['module_interval'];
$get_module_type_nombre = db_process_sql('select nombre from ttipo_modulo where id_tipo = '.$get_module_type_value); $get_module_type_nombre = db_process_sql('select nombre from ttipo_modulo where id_tipo = '.$get_module_type_value);
$get_module_type_nombre_value = $get_module_type_nombre[0]['nombre']; $get_module_type_nombre_value = $get_module_type_nombre[0]['nombre'];
$get_module_ip_target = $get_module_type[0]['ip_target'];
if (strpos($get_module_type_nombre_value, 'inc') != false) { $get_module_id_module_group = $get_module_type[0]['id_module_group'];
$get_module_type_value_normal = 4; $get_module_id_flag = $get_module_type[0]['flag'];
} else if (strpos($get_module_type_nombre_value, 'proc') != false) { $get_module_dynamic_two_tailed = $get_module_type[0]['dynamic_two_tailed'];
$get_module_type_value_normal = 2;
} else if (strpos($get_module_type_nombre_value, 'data') != false) {
$get_module_type_value_normal = 1;
} else if (strpos($get_module_type_nombre_value, 'string') != false) {
$get_module_type_value_normal = 3;
} else {
$get_module_type_value_normal = 1;
}
$values_module = [ $values_module = [
'nombre' => $element['name'], 'nombre' => $element['name'],
'id_modulo' => 5, 'id_modulo' => 0,
'prediction_module' => 7, 'prediction_module' => 7,
'id_agente' => $id_agent[0]['id_agent'], 'id_agente' => $id_agent,
'parent_module_id' => $id_parent_modulo[0]['id_agente_modulo'], 'parent_module_id' => $id_parent_modulo[0]['id_agente_modulo'],
'custom_integer_1' => $element['id_cluster'], 'custom_integer_1' => $element['id_cluster'],
'custom_integer_2' => $tcluster_balanced_module, 'custom_integer_2' => $tcluster_balanced_module,
'id_tipo_modulo' => $get_module_type_value_normal, 'id_tipo_modulo' => 1,
'descripcion' => $get_module_description_value, 'descripcion' => $get_module_description_value,
'min_warning' => $get_module_warning_value, 'min_warning' => $get_module_warning_value,
'min_critical' => $get_module_critical_value, 'min_critical' => $get_module_critical_value,
'tcp_port' => $element['is_critical'], 'tcp_port' => $element['is_critical'],
'module_interval' => $get_module_interval_value, 'module_interval' => $get_module_interval_value,
'ip_target' => $get_module_ip_target,
'tcp_port' => 1,
'id_module_group' => $get_module_id_module_group,
]; ];
$id_module = modules_create_agent_module($values_module['id_agente'], $values_module['nombre'], $values_module, true); $id_module = modules_create_agent_module($values_module['id_agente'], $values_module['nombre'], $values_module, true);

View File

@ -414,21 +414,21 @@ function db_get_value_filter($field, $table, $filter, $where_join='AND', $search
* *
* @return mixed the first value of the first row of a table result from query. * @return mixed the first value of the first row of a table result from query.
*/ */
function db_get_value_sql($sql, $dbconnection=false) function db_get_value_sql($sql, $dbconnection=false, $search_history_db=false)
{ {
global $config; global $config;
switch ($config['dbtype']) { switch ($config['dbtype']) {
case 'mysql': case 'mysql':
return mysql_db_get_value_sql($sql, $dbconnection); return mysql_db_get_value_sql($sql, $dbconnection, $search_history_db);
break; break;
case 'postgresql': case 'postgresql':
return postgresql_db_get_value_sql($sql, $dbconnection); return postgresql_db_get_value_sql($sql, $dbconnection, $search_history_db);
break; break;
case 'oracle': case 'oracle':
return oracle_db_get_value_sql($sql, $dbconnection); return oracle_db_get_value_sql($sql, $dbconnection, $search_history_db);
break; break;
} }

View File

@ -1157,7 +1157,7 @@ function events_get_all(
} }
if ($tags[0] === $id_tag) { if ($tags[0] === $id_tag) {
$_tmp .= ' AND ( '; $_tmp .= ' AND (( ';
} else { } else {
$_tmp .= ' OR ( '; $_tmp .= ' OR ( ';
} }
@ -1185,7 +1185,7 @@ function events_get_all(
$_tmp .= ') '; $_tmp .= ') ';
} }
$sql_filters[] = $_tmp; $sql_filters[] = $_tmp.')';
} }
} }

View File

@ -609,24 +609,15 @@ function groups_get_groups_tree_recursive($groups, $trash=0, $trash2=0)
* *
* @return integer Status of the agents. * @return integer Status of the agents.
*/ */
function groups_get_status($id_group=0, $strict_user=false) function groups_get_status($id_group=0, $ignore_alerts=false)
{ {
global $config; global $config;
include_once $config['homedir'].'/include/functions_reporting.php'; include_once $config['homedir'].'/include/functions_reporting.php';
if ($strict_user) {
$acltags = tags_get_user_groups_and_tags($config['id_user'], 'AR', $strict_user);
$group_status = group_get_data($config['id_user'], $strict_user, $acltags, false, 'group');
$data['monitor_alerts_fired'] = $groups_status['_monitors_alerts_fired_'];
$data['agent_critical'] = $groups_status['_agents_critical_'];
$data['agent_warning'] = $groups_status['_agents_warning_'];
$data['agent_unknown'] = $groups_status['_agents_unknown_'];
} else {
$data = reporting_get_group_stats_resume($id_group); $data = reporting_get_group_stats_resume($id_group);
}
if ($data['monitor_alerts_fired'] > 0) { if ($data['monitor_alerts_fired'] > 0 && $ignore_alerts == false) {
return AGENT_STATUS_ALERT_FIRED; return AGENT_STATUS_ALERT_FIRED;
} else if ($data['agent_critical'] > 0) { } else if ($data['agent_critical'] > 0) {
return AGENT_STATUS_CRITICAL; return AGENT_STATUS_CRITICAL;
@ -991,31 +982,31 @@ function groups_get_agents_counter($group, $agent_filter=[], $module_filter=[],
switch ($agent_status) { switch ($agent_status) {
case AGENT_STATUS_CRITICAL: case AGENT_STATUS_CRITICAL:
if ($critical > 0) { if ($critical > 0) {
$count ++; $count++;
} }
break; break;
case AGENT_STATUS_WARNING: case AGENT_STATUS_WARNING:
if (($total > 0) && ($critical == 0) && ($warning > 0)) { if (($total > 0) && ($critical == 0) && ($warning > 0)) {
$count ++; $count++;
} }
break; break;
case AGENT_STATUS_UNKNOWN: case AGENT_STATUS_UNKNOWN:
if ($critical == 0 && $warning == 0 && $unknown > 0) { if ($critical == 0 && $warning == 0 && $unknown > 0) {
$count ++; $count++;
} }
break; break;
case AGENT_STATUS_NOT_INIT: case AGENT_STATUS_NOT_INIT:
if ($total == 0 || $total == $not_init) { if ($total == 0 || $total == $not_init) {
$count ++; $count++;
} }
break; break;
case AGENT_STATUS_NORMAL: case AGENT_STATUS_NORMAL:
if ($critical == 0 && $warning == 0 && $unknown == 0 && $normal > 0) { if ($critical == 0 && $warning == 0 && $unknown == 0 && $normal > 0) {
$count ++; $count++;
} }
break; break;
@ -1026,23 +1017,23 @@ function groups_get_agents_counter($group, $agent_filter=[], $module_filter=[],
} else { } else {
if (array_search(AGENT_STATUS_CRITICAL, $agent_status) !== false) { if (array_search(AGENT_STATUS_CRITICAL, $agent_status) !== false) {
if ($critical > 0) { if ($critical > 0) {
$count ++; $count++;
} }
} else if (array_search(AGENT_STATUS_WARNING, $agent_status) !== false) { } else if (array_search(AGENT_STATUS_WARNING, $agent_status) !== false) {
if ($total > 0 && $critical = 0 && $warning > 0) { if ($total > 0 && $critical = 0 && $warning > 0) {
$count ++; $count++;
} }
} else if (array_search(AGENT_STATUS_UNKNOWN, $agent_status) !== false) { } else if (array_search(AGENT_STATUS_UNKNOWN, $agent_status) !== false) {
if ($critical == 0 && $warning == 0 && $unknown > 0) { if ($critical == 0 && $warning == 0 && $unknown > 0) {
$count ++; $count++;
} }
} else if (array_search(AGENT_STATUS_NOT_INIT, $agent_status) !== false) { } else if (array_search(AGENT_STATUS_NOT_INIT, $agent_status) !== false) {
if ($total == 0 || $total == $not_init) { if ($total == 0 || $total == $not_init) {
$count ++; $count++;
} }
} else if (array_search(AGENT_STATUS_NORMAL, $agent_status) !== false) { } else if (array_search(AGENT_STATUS_NORMAL, $agent_status) !== false) {
if ($critical == 0 && $warning == 0 && $unknown == 0 && $normal > 0) { if ($critical == 0 && $warning == 0 && $unknown == 0 && $normal > 0) {
$count ++; $count++;
} }
} }
// Invalid status // Invalid status

View File

@ -1181,6 +1181,7 @@ function html_print_select_multiple_filtered(
) { ) {
$output .= '<div class="item-filter flex-row-vcenter">'; $output .= '<div class="item-filter flex-row-vcenter">';
$output .= '<div style="display:none">';
$output .= html_print_input( $output .= html_print_input(
[ [
'style' => 'display:none;', 'style' => 'display:none;',
@ -1190,6 +1191,7 @@ function html_print_select_multiple_filtered(
'return' => true, 'return' => true,
] ]
); );
$output .= '</div>';
$f = "filterAvailableItems(this.value,'".$rid."','".__('None')."')"; $f = "filterAvailableItems(this.value,'".$rid."','".__('None')."')";
$output .= html_print_input( $output .= html_print_input(
@ -1312,7 +1314,7 @@ function html_print_select_multiple_filtered(
'input_class' => 'flex-row-vcenter', 'input_class' => 'flex-row-vcenter',
'label' => __('Group recursion'), 'label' => __('Group recursion'),
'name' => 'id-group-recursion-selected-select-'.$rid, 'name' => 'id-group-recursion-selected-select-'.$rid,
'type' => 'checkbox', 'type' => 'switch',
'script' => $reload_content, 'script' => $reload_content,
'return' => true, 'return' => true,
] ]
@ -1329,6 +1331,8 @@ function html_print_select_multiple_filtered(
) { ) {
$output .= '<div class="item-filter flex-row-vcenter">'; $output .= '<div class="item-filter flex-row-vcenter">';
$output .= '<div style="display:none">';
$output .= html_print_input( $output .= html_print_input(
[ [
'style' => 'display:none;', 'style' => 'display:none;',
@ -1338,6 +1342,7 @@ function html_print_select_multiple_filtered(
'return' => true, 'return' => true,
] ]
); );
$output .= '</div>';
$f = "filterSelectedItems(this.value,'".$rid."','".__('None')."')"; $f = "filterSelectedItems(this.value,'".$rid."','".__('None')."')";
$output .= html_print_input( $output .= html_print_input(
@ -1475,7 +1480,7 @@ function html_print_select_multiple_modules_filtered(array $data):string
'return' => true, 'return' => true,
'nothing' => __('All'), 'nothing' => __('All'),
'nothing_value' => 0, 'nothing_value' => 0,
'script' => 'fmModuleChange(\''.$uniqId.'\')', 'script' => 'fmModuleChange(\''.$uniqId.'\', '.is_metaconsole().')',
] ]
); );
$output .= '</div>'; $output .= '</div>';
@ -1528,7 +1533,7 @@ function html_print_select_multiple_modules_filtered(array $data):string
'return' => true, 'return' => true,
'multiple' => true, 'multiple' => true,
'style' => 'min-width: 200px;max-width:200px;', 'style' => 'min-width: 200px;max-width:200px;',
'script' => 'fmModuleChange(\''.$uniqId.'\')', 'script' => 'fmModuleChange(\''.$uniqId.'\', '.is_metaconsole().')',
] ]
); );
@ -1545,39 +1550,29 @@ function html_print_select_multiple_modules_filtered(array $data):string
'name' => 'filtered-module-show-common-modules-'.$uniqId, 'name' => 'filtered-module-show-common-modules-'.$uniqId,
'selected' => $data['mShowCommonModules'], 'selected' => $data['mShowCommonModules'],
'return' => true, 'return' => true,
'script' => 'fmModuleChange(\''.$uniqId.'\')', 'script' => 'fmModuleChange(\''.$uniqId.'\', '.is_metaconsole().')',
] ]
); );
if ($data['mAgents'] !== null) { if ($data['mAgents'] !== null) {
$all_modules = select_modules_for_agent_group( $all_modules = get_modules_agents(
$data['mModuleGroup'], $data['mModuleGroup'],
explode(',', $data['mAgents']), explode(',', $data['mAgents']),
$data['mShowCommonModules'], $data['mShowCommonModules'],
false false,
true
); );
} else { } else {
$all_modules = []; $all_modules = [];
} }
if ($data['mShowSelectedOtherGroups']) {
$selected_modules_ids = explode(',', $data['mModules']);
foreach ($selected_modules_ids as $id) {
if (!array_key_exists($id, $all_modules)) {
$module_data = modules_get_agentmodule($id);
$all_modules[$id] = $module_data['nombre'];
}
}
}
$output .= html_print_input( $output .= html_print_input(
[ [
'label' => __('Modules'), 'label' => __('Modules'),
'type' => 'select', 'type' => 'select',
'fields' => $all_modules, 'fields' => $all_modules,
'name' => 'filtered-module-modules-'.$uniqId, 'name' => 'filtered-module-modules-'.$uniqId,
'selected' => explode(',', $data['mModules']), 'selected' => explode((is_metaconsole() === true) ? SEPARATOR_META_MODULE : ',', $data['mModules']),
'return' => true, 'return' => true,
'multiple' => true, 'multiple' => true,
'style' => 'min-width: 200px;max-width:200px;', 'style' => 'min-width: 200px;max-width:200px;',
@ -2430,6 +2425,38 @@ function html_print_div(
} }
/**
* Render an <pre> tag for show code.
* For debug purposes, see for `hd()` function.
*
* @param string $content Content of tag.
* @param boolean $return Return the tag string formed.
* @param array $attributes Attributes availables for pre tags.
*
* @return string
*/
function html_print_code(
string $content,
bool $return=true,
array $attributes=[]
) {
$output = '<pre';
if (empty($attributes) === false) {
foreach ($attributes as $attribute => $value) {
$output .= ' '.$attribute.'="'.io_safe_input_html($value).'"';
}
}
$output .= sprintf('>%s</pre>', $content);
if ($return === true) {
return $output;
} else {
echo $output;
}
}
/** /**
* Render an anchor <a> html element. * Render an anchor <a> html element.
* *

View File

@ -158,6 +158,56 @@ function integria_api_call($api_hostname=null, $user=null, $user_pass=null, $api
{ {
global $config; global $config;
if (is_metaconsole()) {
$servers = metaconsole_get_connection_names();
foreach ($servers as $key => $server) {
$connection = metaconsole_get_connection($server);
if (metaconsole_connect($connection) != NOERR) {
continue;
}
$integria_enabled = db_get_sql(
'SELECT `value` FROM tconfig WHERE `token` = "integria_enabled"'
);
if (!$integria_enabled) {
metaconsole_restore_db();
continue;
}
// integria_user_level_conf, integria_hostname, integria_api_pass, integria_user, integria_user_level_user, integria_pass, integria_user_level_pass
$config_aux = db_get_all_rows_sql('SELECT `token`, `value` FROM `tconfig` WHERE `token` IN ("integria_user_level_conf", "integria_hostname", "integria_api_pass", "integria_user", "integria_user_level_user", "integria_pass", "integria_user_level_pass")');
$user_info = users_get_user_by_id($config['id_user']);
foreach ($config_aux as $key => $conf) {
if ($conf['token'] === 'integria_user_level_conf') {
$user_level_conf = $conf['value'];
}
if ($conf['token'] === 'integria_hostname') {
$api_hostname = $conf['value'];
}
if ($conf['token'] === 'integria_api_pass') {
$api_pass = $conf['value'];
}
if ($conf['token'] === 'integria_user') {
$user = $conf['value'];
}
if ($conf['token'] === 'integria_pass') {
$user_pass = $conf['value'];
}
}
if ($user_level_conf == true) {
$user = $user_info['integria_user_level_user'];
$user_pass = $user_info['integria_user_level_pass'];
}
metaconsole_restore_db();
}
} else {
if ($user_level_conf === null) { if ($user_level_conf === null) {
$user_level_conf = (bool) $config['integria_user_level_conf']; $user_level_conf = (bool) $config['integria_user_level_conf'];
} }
@ -189,6 +239,7 @@ function integria_api_call($api_hostname=null, $user=null, $user_pass=null, $api
$user_pass = $user_info['integria_user_level_pass']; $user_pass = $user_info['integria_user_level_pass'];
} }
} }
}
if (is_array($params)) { if (is_array($params)) {
$params = implode($token, $params); $params = implode($token, $params);

View File

@ -545,11 +545,12 @@ function io_input_password($password)
* Process the given password read from the Pandora FMS Database, * Process the given password read from the Pandora FMS Database,
* decrypting it if necessary. * decrypting it if necessary.
* *
* @param string password Password read from the DB. * @param string $password Password read from the DB.
* @param string $wrappedBy Wrap the password with the informed character.
* *
* @return string The processed password. * @return string The processed password.
*/ */
function io_output_password($password) function io_output_password($password, $wrappedBy='')
{ {
global $config; global $config;
@ -562,11 +563,14 @@ function io_output_password($password)
] ]
); );
if ($plaintext === ENTERPRISE_NOT_HOOK) { $output = ($plaintext === ENTERPRISE_NOT_HOOK) ? $password : $plaintext;
return io_safe_output($password);
}
return io_safe_output($plaintext); return sprintf(
'%s%s%s',
$wrappedBy,
io_safe_output($output),
$wrappedBy
);
} }

View File

@ -3231,9 +3231,10 @@ function modules_get_first_date($id_agent_module, $datelimit=0)
{ {
global $config; global $config;
// check datatype string or normal // Check datatype string or normal.
$table = 'tagente_datos'; $table = 'tagente_datos';
$module_type_str = modules_get_agentmodule_type($id_agent_module); $module_type = modules_get_agentmodule_type($id_agent_module);
$module_type_str = modules_get_type_name($module_type);
if (strstr($module_type_str, 'string') !== false) { if (strstr($module_type_str, 'string') !== false) {
$table = 'tagente_datos_string'; $table = 'tagente_datos_string';
} }
@ -3555,7 +3556,7 @@ function modules_get_agentmodule_mininterval_no_async($id_agent)
} }
function get_modules_agents($id_module_group, $id_agents, $selection, $select_mode=true) function get_modules_agents($id_module_group, $id_agents, $selection, $select_mode=true, $useName=false)
{ {
if ((bool) is_metaconsole() === true) { if ((bool) is_metaconsole() === true) {
if ($select_mode === true) { if ($select_mode === true) {
@ -3675,8 +3676,14 @@ function get_modules_agents($id_module_group, $id_agents, $selection, $select_mo
$modules = array_reduce( $modules = array_reduce(
$modules, $modules,
function ($carry, $item) { function ($carry, $item) use ($useName) {
// Only works in select mode.
if ($useName === true) {
$carry[io_safe_input($item['nombre'])] = $item['nombre'];
} else {
$carry[$item['id_node'].'|'.$item['id_agente_modulo']] = $item['nombre']; $carry[$item['id_node'].'|'.$item['id_agente_modulo']] = $item['nombre'];
}
return $carry; return $carry;
}, },
[] []

View File

@ -8775,6 +8775,8 @@ function reporting_increment($report, $content)
$return['data'] = []; $return['data'] = [];
$search_in_history_db = db_search_in_history_db($return['from']);
if (is_metaconsole()) { if (is_metaconsole()) {
$sql1 = 'SELECT datos FROM tagente_datos WHERE id_agente_modulo = '.$id_agent_module.' $sql1 = 'SELECT datos FROM tagente_datos WHERE id_agente_modulo = '.$id_agent_module.'
AND utimestamp <= '.(time() - $period).' ORDER BY utimestamp DESC'; AND utimestamp <= '.(time() - $period).' ORDER BY utimestamp DESC';
@ -8801,17 +8803,23 @@ function reporting_increment($report, $content)
$connection = false; $connection = false;
} }
$old_data = db_get_value_sql($sql1); $old_data = db_get_value_sql($sql1, false, $search_in_history_db);
$last_data = db_get_value_sql($sql2); $last_data = db_get_value_sql($sql2, false, $search_in_history_db);
} }
} else { } else {
$old_data = db_get_value_sql( $old_data = db_get_value_sql(
'SELECT datos FROM tagente_datos WHERE id_agente_modulo = '.$id_agent_module.' 'SELECT datos FROM tagente_datos WHERE id_agente_modulo = '.$id_agent_module.'
AND utimestamp <= '.(time() - $period).' ORDER BY utimestamp DESC' AND utimestamp <= '.(time() - $period).' ORDER BY utimestamp DESC',
false,
$search_in_history_db
); );
$last_data = db_get_value_sql('SELECT datos FROM tagente_datos WHERE id_agente_modulo = '.$id_agent_module.' ORDER BY utimestamp DESC'); $last_data = db_get_value_sql(
'SELECT datos FROM tagente_datos WHERE id_agente_modulo = '.$id_agent_module.' ORDER BY utimestamp DESC',
false,
$search_in_history_db
);
} }
if (!is_metaconsole()) { if (!is_metaconsole()) {
@ -9374,7 +9382,7 @@ function reporting_custom_graph(
$modules = []; $modules = [];
foreach ($module_source as $key => $value) { foreach ($module_source as $key => $value) {
$modules[$key]['module'] = $value['id_agent_module']; $modules[$key]['module'] = $value['id_agent_module'];
$modules[$key]['server'] = $value['id_server']; $modules[$key]['id_server'] = $value['id_server'];
} }
} }
} }
@ -9817,19 +9825,21 @@ function reporting_set_conf_charts(
$content, $content,
&$ttl &$ttl
) { ) {
global $config;
switch ($type) { switch ($type) {
case 'dinamic': case 'dinamic':
default: default:
$only_image = false; $only_image = false;
$width = 900; $width = 900;
$height = isset($content['style']['dyn_height']) ? $content['style']['dyn_height'] : 230; $height = isset($content['style']['dyn_height']) ? $content['style']['dyn_height'] : $config['graph_image_height'];
$ttl = 1; $ttl = 1;
break; break;
case 'static': case 'static':
$ttl = 2; $ttl = 2;
$only_image = true; $only_image = true;
$height = isset($content['style']['dyn_height']) ? $content['style']['dyn_height'] : 230; $height = isset($content['style']['dyn_height']) ? $content['style']['dyn_height'] : $config['graph_image_height'];
$width = 650; $width = 650;
break; break;

View File

@ -5346,7 +5346,7 @@ function reporting_get_agents_by_status($data, $graph_width=250, $graph_height=1
$agent_data = []; $agent_data = [];
$agent_data[0] = html_print_image('images/agent_notinit.png', true, ['title' => __('Agents not init')]); $agent_data[0] = html_print_image('images/agent_notinit.png', true, ['title' => __('Agents not init')]);
$agent_data[1] = "<a style='color: ".COL_NOTINIT.";' href='".$links['agents_not_init']."'><b><span class='blue_color_ligther font_12pt bolder big_data'>".format_numeric($data['agent_not_init']).'</span></b></a>'; $agent_data[1] = "<a style='color: ".COL_NOTINIT.";' href='".$links['agents_not_init']."'><b><span class='blue_color font_12pt bolder big_data'>".format_numeric($data['agent_not_init']).'</span></b></a>';
$agent_data[2] = ''; $agent_data[2] = '';
$agent_data[3] = ''; $agent_data[3] = '';

View File

@ -1347,7 +1347,16 @@ function servers_get_server_string_name(int $server)
return __('WUX server'); return __('WUX server');
case SERVER_TYPE_ENTERPRISE_SATELLITE: case SERVER_TYPE_ENTERPRISE_SATELLITE:
return __('Satellite'); return __('Satellite server');
case SERVER_TYPE_ENTERPRISE_TRANSACTIONAL:
return __('Transactional server');
case SERVER_TYPE_ALERT:
return __('Alert server');
case SERVER_TYPE_NCM:
return __('NCM server');
default: default:
return __('N/A'); return __('N/A');

View File

@ -2850,9 +2850,6 @@ function get_donut_module_data($id_module)
foreach ($values as $val) { foreach ($values as $val) {
if ($index < $max_elements) { if ($index < $max_elements) {
$data = explode(',', $val); $data = explode(',', $val);
if ($data[1] == 0) {
$data[1] = __('No data');
}
if ($no_data_to_show) { if ($no_data_to_show) {
$values_to_return[$index]['tag_name'] = $data[0]; $values_to_return[$index]['tag_name'] = $data[0];
@ -2865,10 +2862,6 @@ function get_donut_module_data($id_module)
$total += (int) $data[1]; $total += (int) $data[1];
$index++; $index++;
} else { } else {
if ($data[1] == 0) {
$data[1] = __('No data');
}
$data = explode(',', $val); $data = explode(',', $val);
$values_to_return[$index]['tag_name'] = __('Others').': '.$data[1]; $values_to_return[$index]['tag_name'] = __('Others').': '.$data[1];
$values_to_return[$index]['color'] = $colors[$index]; $values_to_return[$index]['color'] = $colors[$index];
@ -2881,6 +2874,7 @@ function get_donut_module_data($id_module)
$values_to_return[$ind]['percent'] = (($donut_data['value'] * 100) / $total); $values_to_return[$ind]['percent'] = (($donut_data['value'] * 100) / $total);
} }
// sort array
$new_values_to_return = []; $new_values_to_return = [];
while (!empty($values_to_return)) { while (!empty($values_to_return)) {
$first = true; $first = true;
@ -3426,7 +3420,7 @@ function visual_map_get_status_element($layoutData)
break; break;
case GROUP_ITEM: case GROUP_ITEM:
$group_status = groups_get_status($layoutData['id_group']); $group_status = groups_get_status($layoutData['id_group'], true);
switch ($group_status) { switch ($group_status) {
case AGENT_STATUS_ALERT_FIRED: case AGENT_STATUS_ALERT_FIRED:

View File

@ -335,7 +335,7 @@ function pandoraFlotHBars(
"#e63c52", "#e63c52",
"#FFA631", "#FFA631",
"#f3b200", "#f3b200",
"#5BB6E5", "#4a83f3",
"#F2919D", "#F2919D",
"#82b92e" "#82b92e"
]; ];
@ -437,25 +437,23 @@ function pandoraFlotHBars(
var format = new Array(); var format = new Array();
for (var i = 0; i < labels_total.length; i++) { for (var i = 0; i < labels_total.length; i++) {
var label = labels_total[i][1]; var label = labels_total[i][1];
// var shortLabel = reduceText(label, 25);
var title = label;
if (label.length > 30) {
label = reduceText(label, 30);
}
var div_attributes = var div_attributes =
'style="font-size:' + 'style="font-size:' +
font_size + font_size +
"pt !important;" + "pt !important;" +
" margin: 0; max-width: 150px;" + "margin: 0; max-width: 200px;" +
"margin-right:5px"; "margin-right:5px;" +
+"margin-left: -1.5em"; "margin-left: -1.5em" +
+"text-align: right"; "text-align: right" +
"text-overflow: ellipsis;" +
"overflow: hidden;" +
"white-space: pre;";
if (label.indexOf("<br>") != -1) { if (label.indexOf("<br>") != -1) {
div_attributes += "min-height: 2.5em;"; div_attributes += "min-height: 2.5em;";
} }
div_attributes += '" title="' + title + '" style="overflow: hidden;"'; div_attributes += '" title="' + label + '" style="overflow: hidden;"';
format.push([i, "<div " + div_attributes + ">" + label + "</div>"]); format.push([i, "<div " + div_attributes + ">" + label + "</div>"]);
} }
@ -3270,5 +3268,6 @@ function reduceText(text, maxLength) {
if (text.length <= maxLength) return text; if (text.length <= maxLength) return text;
var firstSlideEnd = parseInt((maxLength - 3) / 1.6); var firstSlideEnd = parseInt((maxLength - 3) / 1.6);
var str_cut = text.substr(0, firstSlideEnd); var str_cut = text.substr(0, firstSlideEnd);
return str_cut + "...<br>" + text.substr(-firstSlideEnd - 3); //return str_cut + "...<br>" + text.substr(-firstSlideEnd - 3);
return str_cut + "..." + text.substr(-firstSlideEnd - 3);
} }

View File

@ -683,10 +683,10 @@ function update_link(row_index, id_link) {
temp_link["text_end"] = data["text_end"]; temp_link["text_end"] = data["text_end"];
$.each(graph.nodes, function(k, node) { $.each(graph.nodes, function(k, node) {
if (node["id_agent"] == data["id_db_target"]) { if (node["id_db"] == data["id_db_target"]) {
temp_link["target"] = graph.nodes[k]; temp_link["target"] = graph.nodes[k];
} }
if (node["id_agent"] == data["id_db_source"]) { if (node["id_db"] == data["id_db_source"]) {
temp_link["source"] = graph.nodes[k]; temp_link["source"] = graph.nodes[k];
} }
}); });
@ -703,9 +703,21 @@ function update_link(row_index, id_link) {
.append("g") .append("g")
.attr("id", "layer_graph_nodes_" + networkmap_id); .attr("id", "layer_graph_nodes_" + networkmap_id);
var graph_links_aux = graph.links.filter(function(d, i) {
if (typeof d["source"] === "undefined") {
return false;
}
if (typeof d["target"] === "undefined") {
return false;
}
return d;
});
force force
.nodes(graph.nodes) .nodes(graph.nodes)
.links(graph.links) .links(graph_links_aux)
.start(); .start();
window.node = layer_graph_nodes.selectAll(".node"); window.node = layer_graph_nodes.selectAll(".node");
@ -2353,9 +2365,21 @@ function refresh_holding_area() {
.append("g") .append("g")
.attr("id", "layer_graph_nodes_" + networkmap_id); .attr("id", "layer_graph_nodes_" + networkmap_id);
var graph_links_aux = graph.links.filter(function(d, i) {
if (typeof d["source"] === "undefined") {
return false;
}
if (typeof d["target"] === "undefined") {
return false;
}
return d;
});
force force
.nodes(graph.nodes) .nodes(graph.nodes)
.links(graph.links) .links(graph_links_aux)
.start(); .start();
window.node = layer_graph_nodes.selectAll(".node"); window.node = layer_graph_nodes.selectAll(".node");

View File

@ -211,7 +211,7 @@ function fmAgentChange(uniqId) {
} }
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
function fmModuleChange(uniqId) { function fmModuleChange(uniqId, isMeta) {
var idModuleGroup = $("#filtered-module-module-group-" + uniqId).val(); var idModuleGroup = $("#filtered-module-module-group-" + uniqId).val();
var idAgents = $("#filtered-module-agents-" + uniqId).val(); var idAgents = $("#filtered-module-agents-" + uniqId).val();
var showCommonModules = $( var showCommonModules = $(
@ -230,7 +230,9 @@ function fmModuleChange(uniqId) {
$("#filtered-module-modules-" + uniqId).html(""); $("#filtered-module-modules-" + uniqId).html("");
if (data) { if (data) {
jQuery.each(data, function(id, value) { jQuery.each(data, function(id, value) {
var option = $("<option></option>") var option = $("<option></option>");
if (isMeta === true) {
option
.attr( .attr(
"value", "value",
value["id_node"] value["id_node"]
@ -238,6 +240,10 @@ function fmModuleChange(uniqId) {
: value["id_agente_modulo"] : value["id_agente_modulo"]
) )
.html(value["nombre"]); .html(value["nombre"]);
} else {
option.attr("value", value).html(value);
}
$("#filtered-module-modules-" + uniqId).append(option); $("#filtered-module-modules-" + uniqId).append(option);
}); });
} }

View File

@ -388,8 +388,8 @@ function initialiceLayout(data) {
dashboardId: data.dashboardId, dashboardId: data.dashboardId,
widgetId: widgetId widgetId: widgetId
}, },
width: widgetId == 14 || widgetId == 2 ? 750 : 450, width: widgetId == 14 || widgetId == 2 || widgetId == 23 ? 750 : 450,
maxHeight: 600, maxHeight: 610,
minHeight: 400 minHeight: 400
}, },
onsubmit: { onsubmit: {

View File

@ -942,7 +942,9 @@ function add_macro_field(macro, row_model_id, type_copy, k) {
.children() .children()
.eq(1) .eq(1)
.children() .children()
.attr("type", "password"); .attr("type", "password")
.removeAttr("value")
.val(macro_value);
} else { } else {
$("#" + row_id) $("#" + row_id)
.children() .children()
@ -955,7 +957,9 @@ function add_macro_field(macro, row_model_id, type_copy, k) {
$("#" + row_id) $("#" + row_id)
.children() .children()
.eq(1) .eq(1)
.attr("type", "password"); .attr("type", "password")
.removeAttr("value")
.val(macro_value);
} else { } else {
$("#" + row_id) $("#" + row_id)
.children() .children()

View File

@ -976,6 +976,11 @@ var TreeController = {
"</span>" "</span>"
); );
// Avoiding 'undefined' text.
if (typeof element.value === "undefined") {
element.value = "";
}
// Value. // Value.
$content.append( $content.append(
'<span class="module-value">' + element.value + "</span>" '<span class="module-value">' + element.value + "</span>"

View File

@ -35,7 +35,6 @@ use PandoraFMS\Module;
*/ */
class AgentModuleWidget extends Widget class AgentModuleWidget extends Widget
{ {
const MODULE_SEPARATOR = '|-|-|-|';
/** /**
* Name widget. * Name widget.
@ -309,16 +308,12 @@ class AgentModuleWidget extends Widget
if (is_metaconsole() === true) { if (is_metaconsole() === true) {
$values['mModules'] = implode( $values['mModules'] = implode(
self::MODULE_SEPARATOR, SEPARATOR_META_MODULE,
array_reduce( array_reduce(
$values['mModules'], $values['mModules'],
function ($carry, $item) { function ($carry, $item) {
$d = explode('|', $item); $d = explode('|', $item);
if (isset($d[1]) === true) { $carry[] = (isset($d[1]) === true) ? $d[1] : $item;
$carry[] = \io_safe_output($d[1]);
} else {
$carry[] = \io_safe_output($item);
}
return $carry; return $carry;
}, },
@ -639,7 +634,7 @@ class AgentModuleWidget extends Widget
$target_modules = $this->values['mModules']; $target_modules = $this->values['mModules'];
if (is_metaconsole() === true) { if (is_metaconsole() === true) {
$target_modules = explode( $target_modules = explode(
self::MODULE_SEPARATOR, SEPARATOR_META_MODULE,
$this->values['mModules'] $this->values['mModules']
); );
@ -648,8 +643,17 @@ class AgentModuleWidget extends Widget
if (is_array($target_modules) === true if (is_array($target_modules) === true
|| is_numeric($target_modules) === true || is_numeric($target_modules) === true
) { ) {
$target_modules = array_reduce(
$target_modules,
function ($carry, $item) {
$carry[] = io_safe_output($item);
return $carry;
}
);
$all_modules = Module::search( $all_modules = Module::search(
['id_agente_modulo' => $target_modules] ['nombre' => $target_modules]
); );
} else { } else {
// From previous definitions. // From previous definitions.
@ -660,6 +664,11 @@ class AgentModuleWidget extends Widget
} }
if ($all_modules !== null) { if ($all_modules !== null) {
if (is_metaconsole() === true
&& $this->values['mShowCommonModules'] === '1'
) {
$reduceAllModules = [];
} else {
$reduceAllModules = array_reduce( $reduceAllModules = array_reduce(
$all_modules, $all_modules,
function ($carry, $item) { function ($carry, $item) {
@ -670,19 +679,13 @@ class AgentModuleWidget extends Widget
if (is_object($item) === true) { if (is_object($item) === true) {
$carry[$item->name()] = null; $carry[$item->name()] = null;
} else { } else {
if ((is_metaconsole() === true $carry[io_safe_output($item)] = null;
&& $this->values['mShowCommonModules'] !== '1')
|| is_metaconsole() === false
) {
$carry[$item] = null;
}
} }
return $carry; return $carry;
} }
); );
} else { }
$reduceAllModules = [];
} }
$visualData = []; $visualData = [];
@ -709,14 +712,26 @@ class AgentModuleWidget extends Widget
$visualData[$agent_id]['agent_status'] = $agent->lastStatus(); $visualData[$agent_id]['agent_status'] = $agent->lastStatus();
$visualData[$agent_id]['agent_name'] = $agent->name(); $visualData[$agent_id]['agent_name'] = $agent->name();
$visualData[$agent_id]['agent_alias'] = $agent->alias(); $visualData[$agent_id]['agent_alias'] = $agent->alias();
$visualData[$agent_id]['modules'] = [];
if (is_metaconsole() === true if (is_metaconsole() === true
&& $this->values['mShowCommonModules'] === '1' && $this->values['mShowCommonModules'] === '1'
) { ) {
// MC should connect to nodes and retrieve information // MC should connect to nodes and retrieve information
// from targets. // from targets.
$tmpModules = array_reduce(
$target_modules,
function ($carry, $item) {
// In this case, the modules come with '» ' chain.
$tmpCarry = explode('&raquo;&#x20;', $item);
$carry[trim($tmpCarry[1])] = null;
return $carry;
}
);
$modules = $agent->searchModules( $modules = $agent->searchModules(
['id_agente_modulo' => $target_modules] ['nombre' => array_keys($tmpModules)]
); );
foreach ($modules as $module) { foreach ($modules as $module) {

View File

@ -350,7 +350,7 @@ class GroupsStatusWidget extends Widget
// Agent Not Init. // Agent Not Init.
$table->data[2][1] = $this->getCellCounter( $table->data[2][1] = $this->getCellCounter(
$stats['agent_not_init'], $stats['agent_not_init'],
'#5bb6e5' '#4a83f3'
); );
$data .= html_print_table($table, true); $data .= html_print_table($table, true);
@ -424,7 +424,7 @@ class GroupsStatusWidget extends Widget
// Modules Not Init. // Modules Not Init.
$table->data[2][1] = $this->getCellCounter( $table->data[2][1] = $this->getCellCounter(
$stats['monitor_not_init'], $stats['monitor_not_init'],
'#5bb6e5' '#4a83f3'
); );
$data .= html_print_table($table, true); $data .= html_print_table($table, true);

View File

@ -323,11 +323,22 @@ class MapsStatusWidget extends Widget
$data = []; $data = [];
$url = $config['homeurl']; $url = $config['homeurl'];
$url .= 'index.php?sec=visualc'; if (\is_metaconsole() === true) {
$url .= '&sec2=operation/visual_console/render_view&refr=60'; $url .= sprintf(
'index.php?sec=screen&sec2=screens/screens&action=visualmap&pure=0&refr=%s&id_visualmap=%s',
$config['vc_refr'],
$id_layout
);
} else {
$url .= sprintf(
'index.php?sec=visualc&sec2=operation/visual_console/render_view&refr=%s&id=%s',
$config['vc_refr'],
$id_layout
);
}
// This will give us the group name. // This will give us the group name.
$data[0] = '<a href="'.$url.'&id='.$id_layout.'">'; $data[0] = '<a href="'.$url.'">';
$data[0] .= $user_layouts[$id_layout]['name']; $data[0] .= $user_layouts[$id_layout]['name'];
$data[0] .= '</a>'; $data[0] .= '</a>';

View File

@ -253,6 +253,14 @@ class NetworkMapWidget extends Widget
// Retrieve global - common inputs. // Retrieve global - common inputs.
$inputs = parent::getFormInputs(); $inputs = parent::getFormInputs();
$inputs[] = [
'label' => \ui_print_info_message(
__('It is recommended to have only one such widget in the control panel.'),
'',
true
),
];
// Default values. // Default values.
if (isset($values['xOffset']) === false) { if (isset($values['xOffset']) === false) {
$values['xOffset'] = 0; $values['xOffset'] = 0;
@ -317,7 +325,7 @@ class NetworkMapWidget extends Widget
'type' => 'select', 'type' => 'select',
'fields' => $fields, 'fields' => $fields,
'name' => 'networkmapId', 'name' => 'networkmapId',
'selected' => $values['networkmapId'], 'selected' => $selected,
'return' => true, 'return' => true,
], ],
]; ];

View File

@ -455,6 +455,7 @@ class TopNWidget extends Widget
$data_hbar = []; $data_hbar = [];
foreach ($modules as $module) { foreach ($modules as $module) {
$module['aliasAgent'] = ui_print_truncate_text($module['aliasAgent'], 20);
$item_name = ''; $item_name = '';
$item_name = $module['aliasAgent'].' - '.$module['nameModule']; $item_name = $module['aliasAgent'].' - '.$module['nameModule'];
$data_hbar[$item_name]['g'] = $module[$display]; $data_hbar[$item_name]['g'] = $module[$display];

View File

@ -346,9 +346,7 @@ final class Group extends Item
$countStatus = \db_get_row_sql($sql); $countStatus = \db_get_row_sql($sql);
if ($countStatus['fired'] > 0) { if ($countStatus['critical'] > 0) {
$status = AGENT_STATUS_ALERT_FIRED;
} else if ($countStatus['critical'] > 0) {
$status = AGENT_STATUS_CRITICAL; $status = AGENT_STATUS_CRITICAL;
} else if ($countStatus['warning'] > 0) { } else if ($countStatus['warning'] > 0) {
$status = AGENT_STATUS_WARNING; $status = AGENT_STATUS_WARNING;
@ -359,7 +357,7 @@ final class Group extends Item
} }
} else { } else {
// Get the status img src. // Get the status img src.
$status = \groups_get_status($groupId); $status = \groups_get_status($groupId, true);
} }
$imagePath = \visual_map_get_image_status_element($data, $status); $imagePath = \visual_map_get_image_status_element($data, $status);
@ -408,7 +406,7 @@ final class Group extends Item
$html .= '<div class="group-item-title">'; $html .= '<div class="group-item-title">';
$html .= $groupName; $html .= $groupName;
$html .= '</div>'; $html .= '</div>';
$html .= '<div class="group-item-info">'; $html .= '<div class="group-item-info" style="padding:0%;width: 96%">';
// Critical. // Critical.
$html .= '<div class="group-item-info-container">'; $html .= '<div class="group-item-info-container">';
$html .= '<div class="value-style red_background">'; $html .= '<div class="value-style red_background">';

View File

@ -411,6 +411,14 @@ table.widget_agent_module tbody tr td {
padding: 5px; padding: 5px;
} }
table.widget_agent_module tbody tr:first-child > th {
background-color: #373737;
color: #fff;
font-size: 7.5pt;
letter-spacing: 0.3pt;
line-height: 16pt;
}
.container-center .widget-histogram-chart .flot-text .flot-x-axis div { .container-center .widget-histogram-chart .flot-text .flot-x-axis div {
white-space: nowrap; white-space: nowrap;
font-family: inherit !important; font-family: inherit !important;

View File

@ -1357,7 +1357,7 @@ td.datos2f9 {
font-weight: bold; font-weight: bold;
} }
.blue { .blue {
color: #5ab7e5; color: #4a83f3;
font-weight: bold; font-weight: bold;
} }
.black { .black {
@ -2506,7 +2506,7 @@ tr.group_view_ok,
tr.group_view_not_init, tr.group_view_not_init,
.group_view_not_init { .group_view_not_init {
background-color: #5bb6e5; background-color: #4a83f3;
color: #fff; color: #fff;
} }
@ -7301,6 +7301,10 @@ div.graph div.legend table {
background-color: #5bb6e5; background-color: #5bb6e5;
} }
.bg_4a83f3 {
background-color: #4a83f3;
}
.bg_aaaaaa { .bg_aaaaaa {
background-color: #aaaaaa; background-color: #aaaaaa;
} }
@ -8434,3 +8438,24 @@ div.stat-win-spinner img {
.fc-col-header-cell-cushion { .fc-col-header-cell-cushion {
color: #fff; color: #fff;
} }
/* For backups dt, can be useful for others */
#backups_list > thead > tr > th:last-child,
#backups_list > tbody > tr > td:last-child {
text-align: center;
}
/* err_msg_centralised */
div#err_msg_centralised div {
margin-top: 1em;
font-size: 14px;
}
div#err_msg_centralised img {
width: 100px;
margin-right: 3em;
}
div#err_msg_centralised {
display: flex;
flex-direction: row;
}

View File

@ -301,6 +301,7 @@ a.pandora_pagination.current:hover {
display: inline; display: inline;
padding: 7pt; padding: 7pt;
margin-left: 10px; margin-left: 10px;
background-color: transparent;
} }
.dt-button.buttons-csv.buttons-html5 span { .dt-button.buttons-csv.buttons-html5 span {
font-size: 0; font-size: 0;

View File

@ -454,6 +454,10 @@ div.label strong span {
color: inherit; color: inherit;
} }
.zindex999 {
z-index: 999;
}
/*.termframe{ /*.termframe{
background-color: #82b92e; background-color: #82b92e;
}*/ }*/

View File

@ -424,6 +424,8 @@ if (! isset($config['id_user'])) {
// Process logout. // Process logout.
include 'general/logoff.php'; include 'general/logoff.php';
} }
$validatedCSRF = true;
} else { } else {
// process_user_login is a virtual function which should be defined in each auth file. // process_user_login is a virtual function which should be defined in each auth file.
// It accepts username and password. The rest should be internal to the auth file. // It accepts username and password. The rest should be internal to the auth file.
@ -1121,6 +1123,63 @@ if ($config['pure'] == 0) {
include 'godmode/menu.php'; include 'godmode/menu.php';
} }
if (has_metaconsole() === true
&& (bool) $config['centralized_management'] === true
) {
$MR = (float) $config['MR'];
// Node attached to a metaconsole.
$server_id = $config['metaconsole_node_id'];
// Connect to meta.
metaconsole_load_external_db(
[
'dbhost' => $config['replication_dbhost'],
'dbuser' => $config['replication_dbuser'],
'dbpass' => io_output_password($config['replication_dbpass']),
'dbname' => $config['replication_dbname'],
]
);
$metaMR = (float) db_get_value(
'value',
'tconfig',
'token',
'MR',
false,
false
);
// Return connection to node.
metaconsole_restore_db();
if ($MR !== $metaMR) {
$err = '<div id="err_msg_centralised">'.html_print_image(
'/images/warning_modern.png',
true
);
$err .= '<div>'.__(
'Metaconsole MR (%d) is different than this one (%d)',
$metaMR,
$MR
);
$err .= '<br>';
$err .= __('Please keep all environment updated to same version.');
$err .= '</div>';
?>
<script type="text/javascript">
$(document).ready(function () {
infoMessage({
title: '<?php echo __('Warning'); ?>',
text: '<?php echo $err; ?>',
simple: true,
})
})
</script>
<?php
}
}
/* /*
* Session locking concurrency speedup! * Session locking concurrency speedup!
* http://es2.php.net/manual/en/ref.session.php#64525 * http://es2.php.net/manual/en/ref.session.php#64525
@ -1362,8 +1421,6 @@ echo "\n<!-- Page generated in ".$run_time." seconds -->\n";
// Values from PHP to be recovered from JAVASCRIPT. // Values from PHP to be recovered from JAVASCRIPT.
require 'include/php_to_js_values.php'; require 'include/php_to_js_values.php';
?> ?>
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">

View File

@ -129,7 +129,7 @@
<div style='height: 10px'> <div style='height: 10px'>
<?php <?php
$version = '7.0NG.759'; $version = '7.0NG.759';
$build = '211217'; $build = '220125';
$banner = "v$version Build $build"; $banner = "v$version Build $build";
error_reporting(0); error_reporting(0);

View File

@ -175,7 +175,7 @@ tr.group_view_crit,
.group_view_not_init, .group_view_not_init,
.group_view_not_init * { .group_view_not_init * {
background-color: #5ab7e5 !important; background-color: #4a83f3 !important;
color: #fff !important; color: #fff !important;
} }

View File

@ -186,14 +186,14 @@ echo '<table cellpadding="0" cellspacing="0" border="0" width="100%" class="data
echo "<span id='sumary' class='yellow_background'>".$total_agent_warning.'%</span>'; echo "<span id='sumary' class='yellow_background'>".$total_agent_warning.'%</span>';
echo "<span id='sumary' class='green_background'>".$total_agent_ok.'%</span>'; echo "<span id='sumary' class='green_background'>".$total_agent_ok.'%</span>';
echo "<span id='sumary' class='bg_B2B2B2'>".$total_agent_unknown.'%</span>'; echo "<span id='sumary' class='bg_B2B2B2'>".$total_agent_unknown.'%</span>';
echo "<span id='sumary' class='bg_5bb6e5'>".$total_not_init.'%</span>'; echo "<span id='sumary' class='blue'>".$total_not_init.'%</span>';
echo '</td>'; echo '</td>';
echo "<td align='center'>"; echo "<td align='center'>";
echo "<span id='sumary' class='red_background'>".$total_critical.'%</span>'; echo "<span id='sumary' class='red_background'>".$total_critical.'%</span>';
echo "<span id='sumary' class='yellow_background'>".$total_warning.'%</span>'; echo "<span id='sumary' class='yellow_background'>".$total_warning.'%</span>';
echo "<span id='sumary' class='green_background'>".$total_ok.'%</span>'; echo "<span id='sumary' class='green_background'>".$total_ok.'%</span>';
echo "<span id='sumary' class='bg_B2B2B2'>".$total_unknown.'%</span>'; echo "<span id='sumary' class='bg_B2B2B2'>".$total_unknown.'%</span>';
echo "<span id='sumary' class='bg_5bb6e5'>".$total_monitor_not_init.'%</span>'; echo "<span id='sumary' class='bg_4a83f3'>".$total_monitor_not_init.'%</span>';
echo '</td>'; echo '</td>';
echo '</tr>'; echo '</tr>';
echo '</table>'; echo '</table>';

View File

@ -480,7 +480,7 @@ if (is_ajax() === true) {
$return = []; $return = [];
$return['correct'] = false; $return['correct'] = false;
// ACL for the network map // ACL for the network map.
$id_group = db_get_value('id_group', 'tmap', 'id', $networkmap_id); $id_group = db_get_value('id_group', 'tmap', 'id', $networkmap_id);
// $networkmap_read = check_acl ($config['id_user'], $id_group, "MR"); // $networkmap_read = check_acl ($config['id_user'], $id_group, "MR");
$networkmap_write = check_acl($config['id_user'], $id_group, 'MW'); $networkmap_write = check_acl($config['id_user'], $id_group, 'MW');
@ -497,9 +497,7 @@ if (is_ajax() === true) {
$return['correct'] = networkmap_delete_link( $return['correct'] = networkmap_delete_link(
$networkmap_id, $networkmap_id,
$source_id,
$source_module_id, $source_module_id,
$target_id,
$target_module_id, $target_module_id,
$id_link $id_link
); );
@ -1028,12 +1026,12 @@ if (is_ajax() === true) {
// Source_value is id_agente. // Source_value is id_agente.
$source_text = ''; $source_text = '';
$source_agent = $interface_source; $source_agent = $interface_source;
$source_type = NODE_AGENT; $source_type = ($interface_source == 0) ? NODE_PANDORA : NODE_AGENT;
$source_link_value = $source_agent; $source_link_value = $source_agent;
} }
// Search node id in map. // Search node id in map.
$child_id = db_get_value_filter( $parent_id = db_get_value_filter(
'id', 'id',
'titem', 'titem',
[ [
@ -1075,7 +1073,7 @@ if (is_ajax() === true) {
} }
// Search node id in map. // Search node id in map.
$parent_id = db_get_value_filter( $child_id = db_get_value_filter(
'id', 'id',
'titem', 'titem',
[ [
@ -1091,10 +1089,10 @@ if (is_ajax() === true) {
$link['id_item'] = 0; $link['id_item'] = 0;
$link['deleted'] = 0; $link['deleted'] = 0;
$link['id_map'] = $networkmap_id; $link['id_map'] = $networkmap_id;
$link['parent_type'] = $target_type; $link['parent_type'] = $source_type;
$link['id_parent_source_data'] = $target_link_value; $link['id_parent_source_data'] = $source_link_value;
$link['child_type'] = $source_type; $link['child_type'] = $target_type;
$link['id_child_source_data'] = $source_link_value; $link['id_child_source_data'] = $target_link_value;
$insert_result = db_process_sql_insert('trel_item', $link); $insert_result = db_process_sql_insert('trel_item', $link);
@ -1125,8 +1123,8 @@ if (is_ajax() === true) {
$return['text_start'] = $source_text; $return['text_start'] = $source_text;
$return['text_end'] = $target_text; $return['text_end'] = $target_text;
$return['id_db_link'] = $insert_result; $return['id_db_link'] = $insert_result;
$return['id_db_source'] = $source_agent; $return['id_db_source'] = $parent_id;
$return['id_db_target'] = $target_agent; $return['id_db_target'] = $child_id;
$return['type_source'] = $source_type; $return['type_source'] = $source_type;
$return['type_target'] = $target_type; $return['type_target'] = $target_type;
} else { } else {

View File

@ -168,7 +168,9 @@ if ($ag_freestring !== '' || $moduletype !== '' || $datatype !== ''
$autosearch = true; $autosearch = true;
} }
if (!is_metaconsole()) { $is_metaconsole = is_metaconsole();
if (!$is_metaconsole) {
$ag_group = (int) get_parameter('ag_group', 0); $ag_group = (int) get_parameter('ag_group', 0);
} else { } else {
$ag_group = get_parameter('ag_group', 0); $ag_group = get_parameter('ag_group', 0);
@ -219,7 +221,7 @@ if (is_numeric($ag_group)) {
} }
// Agent group selector. // Agent group selector.
if (!is_metaconsole()) { if (!$is_metaconsole) {
if ($ag_group > 0 && check_acl($config['id_user'], $ag_group, 'AR')) { if ($ag_group > 0 && check_acl($config['id_user'], $ag_group, 'AR')) {
if ($recursion) { if ($recursion) {
$all_groups = groups_get_children_ids($ag_group, true); $all_groups = groups_get_children_ids($ag_group, true);
@ -272,7 +274,7 @@ if (!is_metaconsole()) {
} }
// Module group. // Module group.
if (is_metaconsole()) { if ($is_metaconsole) {
if ($modulegroup != '-1') { if ($modulegroup != '-1') {
$sql_conditions .= sprintf(' AND tagente_modulo.id_module_group '.$not_condition.' IN (%s)', $modulegroup); $sql_conditions .= sprintf(' AND tagente_modulo.id_module_group '.$not_condition.' IN (%s)', $modulegroup);
} }
@ -370,7 +372,7 @@ if (!empty($ag_custom_fields)) {
// Filter by tag. // Filter by tag.
if ($tag_filter !== 0) { if ($tag_filter !== 0) {
if (is_metaconsole()) { if ($is_metaconsole) {
$sql_conditions .= ' AND tagente_modulo.id_agente_modulo IN ( $sql_conditions .= ' AND tagente_modulo.id_agente_modulo IN (
SELECT ttag_module.id_agente_modulo SELECT ttag_module.id_agente_modulo
FROM ttag_module FROM ttag_module
@ -415,7 +417,7 @@ if (!defined('METACONSOLE')) {
} }
// Get limit_sql depend of the metaconsole or standard mode. // Get limit_sql depend of the metaconsole or standard mode.
if (is_metaconsole()) { if ($is_metaconsole) {
// Offset will be used to get the subset of modules. // Offset will be used to get the subset of modules.
$inferior_limit = $offset; $inferior_limit = $offset;
$superior_limit = ($config['block_size'] + $offset); $superior_limit = ($config['block_size'] + $offset);
@ -514,7 +516,7 @@ $table->data[0][3] = html_print_select(
$rows_select = []; $rows_select = [];
$table->data[0][4] = __('Module group'); $table->data[0][4] = __('Module group');
$rows_select[0] = __('Not assigned'); $rows_select[0] = __('Not assigned');
if (!is_metaconsole()) { if (!$is_metaconsole) {
$rows = db_get_all_rows_sql( $rows = db_get_all_rows_sql(
'SELECT * 'SELECT *
FROM tmodule_group ORDER BY name' FROM tmodule_group ORDER BY name'
@ -617,27 +619,29 @@ if ($develop_bypass) {
$prediction_available = 1; $prediction_available = 1;
} }
$typemodules = [];
$typemodules[1] = __('Data server module');
if ($network_available) { $typemodules = [];
$typemodules[1] = __('Data server module');
if ($network_available || $is_metaconsole) {
$typemodules[2] = __('Network server module'); $typemodules[2] = __('Network server module');
} }
if ($plugin_available) { if ($plugin_available || $is_metaconsole) {
$typemodules[4] = __('Plugin server module'); $typemodules[4] = __('Plugin server module');
} }
if ($wmi_available) { if ($wmi_available || $is_metaconsole) {
$typemodules[6] = __('WMI server module'); $typemodules[6] = __('WMI server module');
} }
if ($prediction_available) { if ($prediction_available || $is_metaconsole) {
$typemodules[5] = __('Prediction server module'); $typemodules[5] = __('Prediction server module');
} }
if (enterprise_installed()) { if (enterprise_installed()) {
$typemodules[7] = __('Web server module'); $typemodules[7] = __('Web server module');
if ($wux_available) { if ($wux_available || $is_metaconsole) {
$typemodules[8] = __('Wux server module'); $typemodules[8] = __('Wux server module');
} }
} }
@ -795,11 +799,11 @@ $table->data[4][0] .= __('Not condition').'&nbsp;'.ui_print_help_tip(__('If you
$table_custom_fields->style[0] = 'font-weight: bold;'; $table_custom_fields->style[0] = 'font-weight: bold;';
// Style is different in metaconsole. // Style is different in metaconsole.
if (is_metaconsole() === false) { if ($is_metaconsole === false) {
$table_custom_fields->style[0] = 'font-weight: bold; width: 150px;'; $table_custom_fields->style[0] = 'font-weight: bold; width: 150px;';
} }
if (is_metaconsole() === true) { if ($is_metaconsole === true) {
$table_custom_fields->styleTable = 'margin-left:0px; margin-top:15px;'; $table_custom_fields->styleTable = 'margin-left:0px; margin-top:15px;';
$table_custom_fields->cellpadding = '0'; $table_custom_fields->cellpadding = '0';
$table_custom_fields->cellspacing = '0'; $table_custom_fields->cellspacing = '0';

View File

@ -102,6 +102,8 @@ $default_filter = [
$fb64 = get_parameter('fb64', null); $fb64 = get_parameter('fb64', null);
if (isset($fb64)) { if (isset($fb64)) {
$filter = json_decode(base64_decode($fb64), true); $filter = json_decode(base64_decode($fb64), true);
$filter['tag_with'] = [];
$filter['tag_without'] = [];
} else { } else {
$filter = get_parameter( $filter = get_parameter(
'filter', 'filter',
@ -261,11 +263,6 @@ if (is_ajax() === true) {
if ($get_events) { if ($get_events) {
try { try {
ob_start(); ob_start();
$order = get_datatable_order(true);
if (is_array($order) === true && $order['field'] === 'mini_severity') {
$order['field'] = 'te.criticity';
}
$fields = [ $fields = [
'te.id_evento', 'te.id_evento',
@ -296,6 +293,20 @@ if (is_ajax() === true) {
'ta.direccion', 'ta.direccion',
]; ];
$order = get_datatable_order(true);
if (is_array($order) === true && $order['field'] === 'mini_severity') {
$order['field'] = 'te.criticity';
}
// Find the order field and set the table and field name.
foreach ($fields as $field) {
if (str_contains($field, $order['field']) === true) {
$order['field'] = $field;
break;
}
}
if (is_metaconsole() === false) { if (is_metaconsole() === false) {
$fields[] = 'am.nombre as module_name'; $fields[] = 'am.nombre as module_name';
$fields[] = 'am.id_agente_modulo as id_agentmodule'; $fields[] = 'am.id_agente_modulo as id_agentmodule';
@ -345,7 +356,8 @@ if (is_ajax() === true) {
$tmp = (object) $item; $tmp = (object) $item;
$tmp->meta = is_metaconsole(); $tmp->meta = is_metaconsole();
if (is_metaconsole()) { // phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
if ($tmp->meta === true) {
if ($tmp->server_name !== null) { if ($tmp->server_name !== null) {
$tmp->data_server = metaconsole_get_servers($tmp->server_id); $tmp->data_server = metaconsole_get_servers($tmp->server_id);
$tmp->server_url_hash = metaconsole_get_servers_url_hash($tmp->data_server); $tmp->server_url_hash = metaconsole_get_servers_url_hash($tmp->data_server);
@ -371,7 +383,7 @@ if (is_ajax() === true) {
sprintf( sprintf(
'SELECT criticity, timestamp FROM %s 'SELECT criticity, timestamp FROM %s
WHERE id_evento = %s', WHERE id_evento = %s',
($tmp->meta) ? 'tmetaconsole_event' : 'tevento', ($tmp->meta === true) ? 'tmetaconsole_event' : 'tevento',
$tmp->max_id_evento $tmp->max_id_evento
) )
); );
@ -538,7 +550,7 @@ if (is_array($tag_without) === false) {
} }
foreach ($tags as $id_tag => $tag) { foreach ((array) $tags as $id_tag => $tag) {
if (is_array($tag_with) === true if (is_array($tag_with) === true
&& ((array_search($id_tag, $tag_with) === false) || (array_search($id_tag, $tag_with) === null)) && ((array_search($id_tag, $tag_with) === false) || (array_search($id_tag, $tag_with) === null))
) { ) {
@ -2415,7 +2427,6 @@ function reorder_tags_inputs() {
}); });
$("#tag_with_temp option").remove(); $("#tag_with_temp option").remove();
$('#select_without option[value="' + val_none + '"]').remove(); $('#select_without option[value="' + val_none + '"]').remove();
jQuery.each($("#tag_without_temp option"), function(key, element) { jQuery.each($("#tag_without_temp option"), function(key, element) {
val = $(element).val(); val = $(element).val();
@ -2428,7 +2439,6 @@ function reorder_tags_inputs() {
}); });
$("#tag_without_temp option").remove(); $("#tag_without_temp option").remove();
tags_base64 = $("#hidden-tag_with").val(); tags_base64 = $("#hidden-tag_with").val();
if (tags_base64.length > 0) { if (tags_base64.length > 0) {
tags = jQuery.parseJSON(Base64.decode(tags_base64)); tags = jQuery.parseJSON(Base64.decode(tags_base64));

View File

@ -246,6 +246,7 @@ if ($view_graph) {
]; ];
} }
if (!is_ajax()) {
// Header. // Header.
ui_print_standard_header( ui_print_standard_header(
$graph['name'], $graph['name'],
@ -265,6 +266,7 @@ if ($view_graph) {
], ],
] ]
); );
}
$width = null; $width = null;
$height = null; $height = null;
@ -294,16 +296,32 @@ if ($view_graph) {
$params_combined $params_combined
); );
if (is_ajax()) {
echo $graph_return;
return;
}
if ($graph_return) { if ($graph_return) {
echo "<table class='databox filters' cellpadding='0' cellspacing='0' width='100%'>"; echo "<table id='graph-container' class='databox filters' cellpadding='0' cellspacing='0' width='100%'>";
echo '<tr><td>'; echo '<tr><td>';
if (!is_ajax()) {
echo '<div id="spinner_loading" class="loading invisible" style="display:flex;flex-direction:column-reverse;justify-content:center;align-items:center">';
echo html_print_image('images/spinner.gif', true, ['width' => '20px']);
echo __('Loading').'&hellip;';
echo '</div>';
}
if ($stacked == CUSTOM_GRAPH_VBARS) { if ($stacked == CUSTOM_GRAPH_VBARS) {
echo '<div class="w100p height_600px">'; echo '<div class="w100p height_600px">';
echo '<div id="div-container" class="w100p height_600px">';
} else {
echo '<div id="div-container">';
} }
echo $graph_return; echo $graph_return;
echo '</div>';
if ($stacked == CUSTOM_GRAPH_VBARS) { if ($stacked == CUSTOM_GRAPH_VBARS) {
echo '<div>'; echo '</div>';
} }
echo '</td></tr></table>'; echo '</td></tr></table>';
@ -316,12 +334,12 @@ if ($view_graph) {
} }
$period_label = human_time_description_raw($period); $period_label = human_time_description_raw($period);
echo "<form method='POST' action='index.php?sec=reporting&sec2=operation/reporting/graph_viewer&view_graph=1&id=$id_graph'>"; echo '<form method="POST" action="index.php?sec=reporting&sec2=operation/reporting/graph_viewer&view_graph=1&id=$id_graph">';
echo "<table class='databox filters w100p' cellpadding='4' cellspacing='4'>"; echo "<table class='databox filters w100p' cellpadding='4' cellspacing='4'>";
echo '<tr>'; echo '<tr>';
echo '<td>'; echo '<td>';
echo '<b>'.__('Date').'</b>'.' '; echo '<b>'.__('Date').'</b>';
echo '</td>'; echo '</td>';
echo '<td>'; echo '<td>';
@ -372,15 +390,17 @@ if ($view_graph) {
echo '</td>'; echo '</td>';
echo "<td class='datos'>"; echo "<td class='datos'>";
echo "<input type=submit value='".__('Refresh')."' class='sub upd'>"; echo "<input id='submit-refresh' type=submit value='".__('Refresh')."' class='sub upd'>";
echo '</td>'; echo '</td>';
echo '</tr>'; echo '</tr>';
echo '</table>'; echo '</table>';
echo '</form>'; echo '</form>';
/* /*
We must add javascript here. Otherwise, the date picker won't We must add javascript here. Otherwise, the date picker won't
work if the date is not correct because php is returning. */ work if the date is not correct because php is returning.
*/
ui_include_time_picker(); ui_include_time_picker();
ui_require_jquery_file('ui.datepicker-'.get_user_language(), 'include/javascript/i18n/'); ui_require_jquery_file('ui.datepicker-'.get_user_language(), 'include/javascript/i18n/');
@ -389,6 +409,7 @@ if ($view_graph) {
<script language="javascript" type="text/javascript"> <script language="javascript" type="text/javascript">
$(document).ready (function () { $(document).ready (function () {
$("#spinner_loading").hide();
$("#loading").slideUp (); $("#loading").slideUp ();
$("#text-time").timepicker({ $("#text-time").timepicker({
showSecond: true, showSecond: true,
@ -415,6 +436,46 @@ if ($view_graph) {
$("#thresholdDiv").hide(); $("#thresholdDiv").hide();
} }
$("#submit-refresh").click(function(e) {
e.preventDefault();
$("#spinner_loading").show();
var data = {
page: "operation/reporting/graph_viewer",
view_graph: 1,
id: '<?php echo $id_graph; ?>',
zoom: $('#zoom').val(),
date: $('#text-date').val(),
time: $('#text-time').val(),
period: $('select[id^=period][id$=select]').val(),
stacked: $('#stacked').val(),
}
if (data['stacked'] == 4 && $('#checkbox-threshold').is(':checked')) {
data['threshold'] = 1;
}
(function (stacked) {
$.ajax({
type: "POST",
url: "ajax.php",
dataType: "html",
data: data,
success: function (data) {
if (stacked === "<?php echo CUSTOM_GRAPH_VBARS; ?>") {
document.getElementById("div-container").classList.add('w100p', 'height_600px');
}
document.getElementById("div-container").innerHTML = "";
$("#spinner_loading").hide();
$("#div-container").append(data);
},
error: function (data) {
console.error("Fatal error")
}
});
})(data['stacked']);
});
}); });
@ -442,7 +503,7 @@ if ($view_graph) {
return; return;
} }
// Header // Header.
ui_print_page_header(__('Reporting').' &raquo; '.__('Custom graph viewer'), 'images/op_reporting.png', false, '', false, ''); ui_print_page_header(__('Reporting').' &raquo; '.__('Custom graph viewer'), 'images/op_reporting.png', false, '', false, '');

View File

@ -18,7 +18,7 @@ require_once $config['homedir'].'/include/functions_reporting.php';
enterprise_include('operation/reporting/custom_reporting.php'); enterprise_include('operation/reporting/custom_reporting.php');
$searchAgents = $searchAlerts = $searchModules = check_acl($config['id_user'], 0, 'AR'); $searchAgents = $searchAlerts = $searchModules = check_acl($config['id_user'], 0, 'AR');
$searchUsers = $searchPolicies = check_acl($config['id_user'], 0, 'AR'); $searchUsers = $searchPolicies = (check_acl($config['id_user'], 0, 'AR') && enterprise_installed());
$searchReports = $searchGraphs = check_acl($config['id_user'], 0, 'RR'); $searchReports = $searchGraphs = check_acl($config['id_user'], 0, 'RR');
$searchMaps = check_acl($config['id_user'], 0, 'VR'); $searchMaps = check_acl($config['id_user'], 0, 'VR');
$searchMain = true; $searchMain = true;

View File

@ -186,6 +186,8 @@ if (isset($_GET['modified']) && !$view_mode) {
} else { } else {
if (!empty($password_new) && !empty($password_confirm)) { if (!empty($password_new) && !empty($password_confirm)) {
$success_msg = __('Password successfully updated'); $success_msg = __('Password successfully updated');
} else if ($upd_info['id_skin'] !== $user_info['id_skin']) {
$success_msg = __('Skin successfully updated');
} else { } else {
$return = false; $return = false;
$error_msg = __('No changes have been made'); $error_msg = __('No changes have been made');

View File

@ -398,6 +398,17 @@ if ($pure === false) {
echo '</div>'; echo '</div>';
if ($aclWrite === true || $aclManage === true) { if ($aclWrite === true || $aclManage === true) {
if (!is_metaconsole()) {
echo '<a id ="force_check" href="" style="margin-right: 25px;">'.html_print_image(
'images/target.png',
true,
[
'title' => __('Force remote checks'),
'class' => 'invert_filter',
]
).'</a>';
}
echo html_print_checkbox_switch('edit-mode', 1, false, true); echo html_print_checkbox_switch('edit-mode', 1, false, true);
} }
@ -671,12 +682,14 @@ if ($edit_capable === true) {
if ($(this).prop('checked')) { if ($(this).prop('checked')) {
visualConsoleManager.visualConsole.enableEditMode(); visualConsoleManager.visualConsole.enableEditMode();
visualConsoleManager.changeUpdateInterval(0); visualConsoleManager.changeUpdateInterval(0);
$('#force_check').hide();
$('#edit-controls').css('visibility', ''); $('#edit-controls').css('visibility', '');
} else { } else {
visualConsoleManager.visualConsole.disableEditMode(); visualConsoleManager.visualConsole.disableEditMode();
visualConsoleManager.visualConsole.unSelectItems(); visualConsoleManager.visualConsole.unSelectItems();
visualConsoleManager.changeUpdateInterval(<?php echo ($refr * 1000); ?>); // To ms. visualConsoleManager.changeUpdateInterval(<?php echo ($refr * 1000); ?>); // To ms.
$('#edit-controls').css('visibility', 'hidden'); $('#edit-controls').css('visibility', 'hidden');
$('#force_check').show();
} }
}); });
<?php <?php
@ -750,6 +763,37 @@ if ($edit_capable === true) {
}); });
$('#force_check').click(function (e) {
e.preventDefault();
visualConsoleManager.changeUpdateInterval(0);
const id_layout = '<?php echo $visualConsoleId; ?>';
$.ajax({
type: "GET",
url: "ajax.php",
dataType: "json",
data: {
page: "include/ajax/visual_console.ajax",
force_remote_check: true,
id_layout: id_layout
},
success: function (data) {
if (data == 1) {
visualConsoleManager.changeUpdateInterval(5000);
setTimeout(resetInterval, 6000);
} else {
resetInterval();
}
},
error: function (data) {
resetInterval();
}
});
});
function resetInterval() {
visualConsoleManager.changeUpdateInterval(<?php echo ($refr * 1000); ?>);
}
/** /**
* Process ajax responses and shows a dialog with results. * Process ajax responses and shows a dialog with results.
*/ */

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.759 %define version 7.0NG.759
%define release 211217 %define release 220125
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.759 %define version 7.0NG.759
%define release 211217 %define release 220125
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.759 %define version 7.0NG.759
%define release 211217 %define release 220125
%define httpd_name httpd %define httpd_name httpd
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name apache2 %define httpd_name apache2

View File

@ -2856,7 +2856,8 @@ CREATE TABLE IF NOT EXISTS `tservice_element` (
`id_service_child` int(10) unsigned NOT NULL default 0, `id_service_child` int(10) unsigned NOT NULL default 0,
`id_server_meta` int(10) unsigned NOT NULL default 0, `id_server_meta` int(10) unsigned NOT NULL default 0,
`rules` text, `rules` text,
PRIMARY KEY (`id`) PRIMARY KEY (`id`),
INDEX `IDX_tservice_element` (`id_service`,`id_agente_modulo`)
) ENGINE=InnoDB ) ENGINE=InnoDB
COMMENT = 'Table to define the modules and the weights of the modules that define a service' COMMENT = 'Table to define the modules and the weights of the modules that define a service'
DEFAULT CHARSET=utf8; DEFAULT CHARSET=utf8;
@ -2951,7 +2952,7 @@ CREATE TABLE IF NOT EXISTS `tpolicy_queue` (
`id_policy` int(10) unsigned NOT NULL default '0', `id_policy` int(10) unsigned NOT NULL default '0',
`id_agent` int(10) unsigned NOT NULL default '0', `id_agent` int(10) unsigned NOT NULL default '0',
`operation` varchar(15) default '', `operation` varchar(15) default '',
`progress` int(10) unsigned NOT NULL default '0', `progress` int(10) NOT NULL default '0',
`end_utimestamp` int(10) unsigned NOT NULL default 0, `end_utimestamp` int(10) unsigned NOT NULL default 0,
`priority` int(10) unsigned NOT NULL default '0', `priority` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)

View File

@ -109,10 +109,10 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
('custom_report_front_logo', 'images/pandora_logo_white.jpg'), ('custom_report_front_logo', 'images/pandora_logo_white.jpg'),
('custom_report_front_header', ''), ('custom_report_front_header', ''),
('custom_report_front_footer', ''), ('custom_report_front_footer', ''),
('MR', 50), ('MR', 51),
('identification_reminder', 1), ('identification_reminder', 1),
('identification_reminder_timestamp', 0), ('identification_reminder_timestamp', 0),
('current_package', 758), ('current_package', 759),
('post_process_custom_values', '{"0.00000038580247":"Seconds&#x20;to&#x20;months","0.00000165343915":"Seconds&#x20;to&#x20;weeks","0.00001157407407":"Seconds&#x20;to&#x20;days","0.01666666666667":"Seconds&#x20;to&#x20;minutes","0.00000000093132":"Bytes&#x20;to&#x20;Gigabytes","0.00000095367432":"Bytes&#x20;to&#x20;Megabytes","0.00097656250000":"Bytes&#x20;to&#x20;Kilobytes","0.00000001653439":"Timeticks&#x20;to&#x20;weeks","0.00000011574074":"Timeticks&#x20;to&#x20;days"}'), ('post_process_custom_values', '{"0.00000038580247":"Seconds&#x20;to&#x20;months","0.00000165343915":"Seconds&#x20;to&#x20;weeks","0.00001157407407":"Seconds&#x20;to&#x20;days","0.01666666666667":"Seconds&#x20;to&#x20;minutes","0.00000000093132":"Bytes&#x20;to&#x20;Gigabytes","0.00000095367432":"Bytes&#x20;to&#x20;Megabytes","0.00097656250000":"Bytes&#x20;to&#x20;Kilobytes","0.00000001653439":"Timeticks&#x20;to&#x20;weeks","0.00000011574074":"Timeticks&#x20;to&#x20;days"}'),
('custom_docs_logo', 'default_docs.png'), ('custom_docs_logo', 'default_docs.png'),
('custom_support_logo', 'default_support.png'), ('custom_support_logo', 'default_support.png'),

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