Merge remote-tracking branch 'origin/develop' into ent-2133-14061-recursividad-en-la-vista-de-eventos-accelya

Conflicts:
	pandora_console/extras/mr/58.sql
This commit is contained in:
Daniel Barbero 2022-10-18 07:59:26 +02:00
commit 47a2e01a33
130 changed files with 73079 additions and 116249 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
# Base config file for Pandora FMS Windows Agent
# (c) 2006-2021 Artica Soluciones Tecnologicas
# Version 7.0NG.764
# Version 7.0NG.765
# This program is Free Software, you can redistribute it and/or modify it
# under the terms of the GNU General Public Licence as published by the Free Software
# Foundation; either version 2 of the Licence or any later version

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.764-220929
Version: 7.0NG.765-221018
Architecture: all
Priority: optional
Section: admin

View File

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

View File

@ -31,7 +31,7 @@ fi
if [ "$#" -ge 2 ]; then
VERSION="$2"
else
VERSION="7.0NG.764"
VERSION="7.0NG.765"
fi
# Path for the generated DMG file

View File

@ -19,11 +19,11 @@
<choice id="com.pandorafms.pandorafms_src" visible="false">
<pkg-ref id="com.pandorafms.pandorafms_src"/>
</choice>
<pkg-ref id="com.pandorafms.pandorafms_src" version="7.0NG.764" onConclusion="none">pandorafms_src.pdk</pkg-ref>
<pkg-ref id="com.pandorafms.pandorafms_src" version="7.0NG.765" onConclusion="none">pandorafms_src.pdk</pkg-ref>
<choice id="com.pandorafms.pandorafms_uninstall" visible="true" customLocation="/Applications">
<pkg-ref id="com.pandorafms.pandorafms_uninstall"/>
</choice>
<pkg-ref id="com.pandorafms.pandorafms_uninstall" version="7.0NG.764" onConclusion="none">pandorafms_uninstall.pdk</pkg-ref>
<pkg-ref id="com.pandorafms.pandorafms_uninstall" version="7.0NG.765" onConclusion="none">pandorafms_uninstall.pdk</pkg-ref>
<!-- <installation-check script="check()" />
<script>
<![CDATA[

View File

@ -5,9 +5,9 @@
<key>CFBundleIconFile</key> <string>pandorafms.icns</string>
<key>CFBundleIdentifier</key> <string>com.pandorafms.pandorafms_uninstall</string>
<key>CFBundleVersion</key> <string>7.0NG.764</string>
<key>CFBundleGetInfoString</key> <string>7.0NG.764 Pandora FMS Agent uninstaller for MacOS by Artica ST on Aug 2020</string>
<key>CFBundleShortVersionString</key> <string>7.0NG.764</string>
<key>CFBundleVersion</key> <string>7.0NG.765</string>
<key>CFBundleGetInfoString</key> <string>7.0NG.765 Pandora FMS Agent uninstaller for MacOS by Artica ST on Aug 2020</string>
<key>CFBundleShortVersionString</key> <string>7.0NG.765</string>
<key>NSPrincipalClass</key><string>NSApplication</string>
<key>NSMainNibFile</key><string>MainMenu</string>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent
#
%define name pandorafms_agent_unix
%define version 7.0NG.764
%define release 220929
%define version 7.0NG.765
%define release 221018
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent
#
%define name pandorafms_agent_unix
%define version 7.0NG.764
%define release 220929
%define version 7.0NG.765
%define release 221018
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

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

View File

@ -1,6 +1,6 @@
# Base config file for Pandora FMS Windows Agent
# (c) 2006-2021 Artica Soluciones Tecnologicas
# Version 7.0NG.764
# Version 7.0NG.765
# This program is Free Software, you can redistribute it and/or modify it
# under the terms of the GNU General Public Licence as published by the Free Software
# Foundation; either version 2 of the Licence or any later version

View File

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

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.764 Build 220929")
#define PANDORA_VERSION ("7.0NG.765 Build 221018")
string pandora_path;
string pandora_dir;

View File

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

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 7.0NG.764-220929
Version: 7.0NG.765-221018
Architecture: all
Priority: optional
Section: admin

View File

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

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,8 @@
START TRANSACTION;
ALTER TABLE `tmodule_inventory` ADD COLUMN `script_mode` INT NOT NULL DEFAULT 2;
ALTER TABLE `tmodule_inventory` ADD COLUMN `script_path` VARCHAR(1000) DEFAULT '';
ALTER TABLE `tevent_filter` ADD COLUMN `search_recursive_groups` INT NOT NULL DEFAULT 0;
COMMIT;
COMMIT;

View File

@ -187,7 +187,7 @@ if (!$double_auth_enabled
})
.show();
// Don't allow close the dialog with X button
$('.ui-dialog-titlebar-close').css('display', 'none');
// $('.ui-dialog-titlebar-close').css('display', 'none');
</script>
<?php

View File

@ -181,7 +181,7 @@ $module_macros = [];
// Create agent.
if ($create_agent) {
$mssg_warning = 0;
$alias_safe_output = io_safe_output(get_parameter('alias', ''));
$alias_safe_output = strip_tags(io_safe_output(get_parameter('alias', '')));
$alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$]/', '', $alias_safe_output)));
$alias_as_name = (int) get_parameter_post('alias_as_name', 0);
$direccion_agente = (string) get_parameter_post('direccion', '');
@ -935,7 +935,7 @@ if ($update_agent) {
$mssg_warning = 0;
$id_agente = (int) get_parameter_post('id_agente');
$nombre_agente = str_replace('`', '&lsquo;', (string) get_parameter_post('agente', ''));
$alias_safe_output = io_safe_output(get_parameter('alias', ''));
$alias_safe_output = strip_tags(io_safe_output(get_parameter('alias', '')));
$alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$]/', '', $alias_safe_output)));
$alias_as_name = (int) get_parameter_post('alias_as_name', 0);
$direccion_agente = (string) get_parameter_post('direccion', '');
@ -1047,7 +1047,7 @@ if ($update_agent) {
// If there is an agent with the same name, but a different ID.
}
if ($unique_ip && $direccion_agente != '') {
if ($direccion_agente !== $address_list && (bool) $unique_ip === true && $direccion_agente != '') {
$sql = 'SELECT direccion FROM tagente WHERE direccion = "'.$direccion_agente.'"';
$exists_ip = db_get_row_sql($sql);
}

View File

@ -669,13 +669,12 @@ $table_advanced->data[2][3] = __('Max. Value');
$table_advanced->data[2][4] = html_print_input_text('max', $max, '', 5, 15, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy);
$table_advanced->colspan[2][4] = 3;
$table_advanced->data[3][0] = __('Dynamic Threshold Interval');
$table_advanced->data[3][1] = html_print_extended_select_for_time(
'dynamic_interval',
$dynamic_interval,
'',
'None',
__('None'),
'0',
10,
true,

View File

@ -285,13 +285,13 @@ if (is_ajax()) {
$ffield .= '<div name="field'.$i.'_value_container">'.html_print_switch(
[
'name' => 'field'.$i.'_value[]',
'value' => ''
'value' => '',
]
).'</div>';
$rfield .= '<div name="field'.$i.'_recovery_value_container">'.html_print_switch(
[
'name' => 'field'.$i.'_recovery_value[]',
'value' => ''
'value' => '',
]
).'</div>';
@ -379,7 +379,7 @@ if (is_ajax()) {
$filter,
[
'name',
'id_report'
'id_report',
],
$return_all_group,
'RR'
@ -419,7 +419,7 @@ if (is_ajax()) {
$filter,
[
'name',
'id_report'
'id_report',
],
$return_all_group,
'RR'

View File

@ -358,7 +358,7 @@ if (!is_user_admin($config['id_user'])) {
$filter['id_group'] = array_keys(users_get_groups(false, 'LM'));
}
$total_templates = alerts_get_alert_templates($filter, ['COUNT(*) AS total']);
$total_templates = alerts_get_alert_templates($filter, ['COUNT(*) AS total'], true);
$total_templates = $total_templates[0]['total'];
$templates = alerts_get_alert_templates(

View File

@ -881,14 +881,16 @@ if (($create != '') || ($view != '')) {
'class' => 'invert_filter',
]
).'</a>&nbsp;&nbsp;';
echo "<a href='index.php?sec=$sec&sec2=godmode/servers/plugin&tab=$tab&kill_plugin=".$row['id'].'&tab=plugins&pure='.$config['pure']."' onclick='javascript: if (!confirm(\"".__('All the modules that are using this plugin will be deleted').'. '.__('Are you sure?')."\")) return false;'>".html_print_image(
'images/cross.png',
true,
[
'border' => '0',
'class' => 'invert_filter',
]
).'</a>';
if ((bool) $row['no_delete'] === false) {
echo "<a href='index.php?sec=$sec&sec2=godmode/servers/plugin&tab=$tab&kill_plugin=".$row['id'].'&tab=plugins&pure='.$config['pure']."' onclick='javascript: if (!confirm(\"".__('All the modules that are using this plugin will be deleted').'. '.__('Are you sure?')."\")) return false;'>".html_print_image(
'images/cross.png',
true,
[
'border' => '0',
'class' => 'invert_filter',
]
).'</a>';
}
echo '</td>';
}

View File

@ -238,6 +238,17 @@ foreach ($servers as $server) {
$data[8] .= '</a>';
if (($names_servers[$safe_server_name] === true) && ($server['type'] === 'data' || $server['type'] === 'enterprise satellite')) {
$data[8] .= '<a href="'.ui_get_full_url('index.php?sec=gservers&sec2=godmode/servers/modificar_server&server_remote='.$server['id_server'].'&ext='.$ext.'&tab=agent_editor').'">';
$data[8] .= html_print_image(
'images/agent.png',
true,
[
'title' => __('Manage satellite hosts'),
'class' => 'invert_filter',
]
);
$data[8] .= '</a>';
$data[8] .= '<a href="'.ui_get_full_url('index.php?sec=gservers&sec2=godmode/servers/modificar_server&server_remote='.$server['id_server'].'&ext='.$ext).'">';
$data[8] .= html_print_image(
'images/remote_configuration.png',

View File

@ -509,6 +509,10 @@ if ($create_user) {
if (!empty($json_profile)) {
$json_profile = json_decode(io_safe_output($json_profile), true);
foreach ($json_profile as $key => $profile) {
if (is_array($profile) === false) {
$profile = json_decode($profile, true);
}
if (!empty($profile)) {
$group2 = $profile['group'];
$profile2 = $profile['profile'];
@ -532,6 +536,14 @@ if ($create_user) {
$result_profile = profile_create_user_profile($id, $profile2, $group2, false, $tags, $no_hierarchy);
if ($result_profile === false) {
$is_err = true;
$user_info = $values;
$password_new = '';
$password_confirm = '';
$new_user = true;
}
ui_print_result_message(
$result_profile,
__('Profile added successfully'),
@ -824,6 +836,10 @@ if ($add_profile && empty($json_profile)) {
'Profile: '.$profile2.' Group: '.$group2.' Tags: '.$tags
);
$return = profile_create_user_profile($id2, $profile2, $group2, false, $tags, $no_hierarchy);
if ($return === false) {
$is_err = true;
}
ui_print_result_message(
$return,
__('Profile added successfully'),
@ -1492,12 +1508,12 @@ if ($config['admin_can_add_user']) {
echo '</div>';
html_print_input_hidden('json_profile', '');
html_print_input_hidden('json_profile', $json_profile);
echo '</form>';
profile_print_profile_table($id);
profile_print_profile_table($id, io_safe_output($json_profile));
echo '<br />';
@ -1613,13 +1629,18 @@ $(document).ready (function () {
switch_ehorus_conf();
});
$('#checkbox-ehorus_user_level_enabled').trigger('change');
var img_delete = '<?php echo $delete_image; ?>';
var id_user = '<?php echo io_safe_output($id); ?>';
var is_metaconsole = '<?php echo $meta; ?>';
var user_is_global_admin = '<?php echo users_is_admin($id); ?>';
var is_err = '<?php echo $is_err; ?>';
var data = [];
var aux = 0;
if(json_profile.val() != '') {
var data = JSON.parse(json_profile.val());
}
$('input:image[name="add"]').click(function (e) {
e.preventDefault();
var profile = $('#assign_profile').val();
@ -1641,10 +1662,14 @@ $(document).ready (function () {
return;
}
if (id_user === '') {
if (id_user == '' || is_err == 1) {
let new_json = `{"profile":${profile},"group":${group},"tags":[${tags}],"hierarchy":${hierarchy}}`;
data.push(new_json);
json_profile.val('['+data+']');
json_profile.val(JSON.stringify(data));
profile_text = `<a href="index.php?sec2=godmode/users/configure_profile&id=${profile}">${profile_text}</a>`;
group_img = `<img id="img_group_${aux}" src="" data-title="${group_text}" data-use_title_for_force_title="1" class="bot forced_title" alt="${group_text}"/>`;
group_text = `<a href="index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60&group_id=${group}">${group_img}${group_text}</a>`;
$('#table_profiles tr:last').before(
`<tr>
<td>${profile_text}</td>
@ -1654,6 +1679,10 @@ $(document).ready (function () {
<td>${img_delete}</td>
</tr>`
);
getGroupIcon(group, $(`#img_group_${aux}`));
aux++;
} else {
this.form.submit();
}

View File

@ -31,8 +31,6 @@ global $config;
check_login();
enterprise_hook('open_meta_frame');
require_once $config['homedir'].'/include/functions_profile.php';
require_once $config['homedir'].'/include/functions_users.php';
require_once $config['homedir'].'/include/functions_groups.php';
@ -52,8 +50,47 @@ if (is_ajax()) {
$method = get_parameter('method');
$group_id = get_parameter('group_id');
$group_recursion = (bool) get_parameter('group_recursion', 0);
$get_user_profile_group = (bool) get_parameter('get_user_profile_group', false);
$return_all = false;
if ($get_user_profile_group === true) {
$id_user = get_parameter('id_user');
$user_is_admin = users_is_admin();
$user_profiles = [];
if ($user_is_admin === false) {
$group_um = users_get_groups_UM($config['id_user']);
}
// User profiles.
if ($user_is_admin || $id_user == $config['id_user'] || isset($group_um[0])) {
$user_profiles = db_get_all_rows_field_filter(
'tusuario_perfil',
'id_usuario',
$id_user
);
} else {
$user_profiles_aux = users_get_user_profile($id_user);
foreach ($group_um as $key => $value) {
if (isset($user_profiles_aux[$key]) === true) {
$user_profiles[$key] = $user_profiles_aux[$key];
unset($user_profiles_aux[$key]);
}
}
}
foreach ($user_profiles as $key => $value) {
$user_profiles[$key]['id_perfil'] = profile_get_name($value['id_perfil']);
$user_profiles[$key]['id_grupo'] = groups_get_name($value['id_grupo'], true);
}
echo json_encode($user_profiles);
return;
}
if ($group_id == -1) {
$sql = 'SELECT tusuario.id_user FROM tusuario
LEFT OUTER JOIN tusuario_perfil
@ -95,6 +132,8 @@ if (is_ajax()) {
}
}
enterprise_hook('open_meta_frame');
$sortField = get_parameter('sort_field');
$sort = get_parameter('sort', 'none');
$tab = get_parameter('tab', 'user');
@ -265,71 +304,75 @@ $delete_user = (bool) get_parameter('user_del', false);
if ($delete_user === true) {
// Delete user.
$id_user = get_parameter('delete_user', 0);
if (users_is_admin($id_user) === true && users_is_admin() === false) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to delete admininstrator user by non administrator user '.$config['id_user']
);
include 'general/noaccess.php';
exit;
}
// Only allow delete user if is not the actual user.
if ($id_user != $config['id_user']) {
$user_row = users_get_user_by_id($id_user);
$result = delete_user($id_user);
if ($result) {
if ($id_user !== 0) {
if (users_is_admin($id_user) === true && users_is_admin() === false) {
db_pandora_audit(
AUDIT_LOG_USER_MANAGEMENT,
__('Deleted user %s', io_safe_output($id_user))
AUDIT_LOG_ACL_VIOLATION,
'Trying to delete admininstrator user by non administrator user '.$config['id_user']
);
include 'general/noaccess.php';
exit;
}
ui_print_result_message(
$result,
__('Successfully deleted'),
__('There was a problem deleting the user')
);
// Only allow delete user if is not the actual user.
if ($id_user != $config['id_user']) {
$user_row = users_get_user_by_id($id_user);
// Delete the user in all the consoles.
if (is_metaconsole() === true && isset($_GET['delete_all'])) {
$servers = metaconsole_get_servers();
foreach ($servers as $server) {
// Connect to the remote console.
if (metaconsole_connect($server) === NOERR) {
// Delete the user.
$result = delete_user($id_user);
$result = delete_user($id_user);
if ($result) {
db_pandora_audit(
AUDIT_LOG_USER_MANAGEMENT,
__('Deleted user %s', io_safe_output($id_user))
);
}
ui_print_result_message(
$result,
__('Successfully deleted'),
__('There was a problem deleting the user')
);
// Delete the user in all the consoles.
if (is_metaconsole() === true && isset($_GET['delete_all'])) {
$servers = metaconsole_get_servers();
foreach ($servers as $server) {
// Connect to the remote console.
if (metaconsole_connect($server) === NOERR) {
// Delete the user.
$result = delete_user($id_user);
if ($result) {
db_pandora_audit(
AUDIT_LOG_USER_MANAGEMENT,
__('Deleted user %s from metaconsole', io_safe_input($id_user))
);
}
// Restore the db connection.
metaconsole_restore_db();
}
// Log to the metaconsole too.
if ($result) {
db_pandora_audit(
AUDIT_LOG_USER_MANAGEMENT,
__('Deleted user %s from metaconsole', io_safe_input($id_user))
__('Deleted user %s from %s', io_safe_input($id_user), io_safe_input($server['server_name']))
);
}
// Restore the db connection.
metaconsole_restore_db();
}
// Log to the metaconsole too.
if ($result) {
db_pandora_audit(
AUDIT_LOG_USER_MANAGEMENT,
__('Deleted user %s from %s', io_safe_input($id_user), io_safe_input($server['server_name']))
ui_print_result_message(
$result,
__('Successfully deleted from %s', io_safe_input($server['server_name'])),
__('There was a problem deleting the user from %s', io_safe_input($server['server_name']))
);
}
ui_print_result_message(
$result,
__('Successfully deleted from %s', io_safe_input($server['server_name'])),
__('There was a problem deleting the user from %s', io_safe_input($server['server_name']))
);
}
} else {
ui_print_error_message(__('There was a problem deleting the user'));
}
} else {
ui_print_error_message(__('There was a problem deleting the user'));
ui_print_error_message(__('ID user cannot be empty'));
}
} else if (isset($_GET['profile_del'])) {
// Delete profile.
@ -586,15 +629,17 @@ $rowPair = true;
$iterator = 0;
$cont = 0;
foreach ($info as $user_id => $user_info) {
if (empty($user_id) === true) {
continue;
}
// User profiles.
if ($user_is_admin || $user_id == $config['id_user'] || isset($group_um[0])) {
$user_profiles = db_get_all_rows_field_filter(
'tusuario_perfil',
'id_usuario',
$user_id
$user_profiles = db_get_all_rows_sql(
'SELECT * FROM tusuario_perfil where id_usuario LIKE "'.$user_id.'" LIMIT 5'
);
} else {
$user_profiles_aux = users_get_user_profile($user_id);
$user_profiles_aux = users_get_user_profile($user_id, 'LIMIT 5');
$user_profiles = [];
foreach ($group_um as $key => $value) {
if (isset($user_profiles_aux[$key]) === true) {
@ -674,39 +719,35 @@ foreach ($info as $user_id => $user_info) {
if ($user_profiles !== false) {
$total_profile = 0;
$data[4] .= '<div class="text_end">';
$data[4] .= '<div class="text_end">';
foreach ($user_profiles as $row) {
if ($total_profile <= 5) {
$data[4] .= "<div class='float-left'>";
$data[4] .= profile_get_name($row['id_perfil']);
$data[4] .= ' / </div>';
$data[4] .= "<div class='float-left pdd_l_5px'>";
$data[4] .= groups_get_name($row['id_grupo'], true);
$data[4] .= '</div>';
$data[4] .= "<div class='float-left'>";
$data[4] .= profile_get_name($row['id_perfil']);
$data[4] .= ' / </div>';
$data[4] .= "<div class='float-left pdd_l_5px'>";
$data[4] .= groups_get_name($row['id_grupo'], true);
$data[4] .= '</div>';
if ($total_profile == 0 && count($user_profiles) >= 5) {
$data[4] .= '<span onclick="showGroups()" class="pdd_l_15px">
'.html_print_image(
'images/zoom.png',
true,
[
'title' => __('Show'),
'class' => 'invert_filter',
]
).'</span>';
}
if ($total_profile == 0 && count($user_profiles) >= 5) {
$data[4] .= '<span onclick="showGroups(`'.$row['id_usuario'].'`)">'.html_print_image(
'images/zoom.png',
true,
[
'title' => __('Show profiles'),
'class' => 'invert_filter',
]
).'</span>';
$data[4] .= '<br />';
$data[4] .= '<br />';
$data[4] .= '</div>';
} else {
$data[4] .= "<div id='groups_list' class='invisible'>";
$data[4] .= '<div >';
$data[4] .= profile_get_name($row['id_perfil']);
$data[4] .= ' / '.groups_get_name($row['id_grupo'], true).'</div>';
$data[4] .= '<br/>';
$data[4] .= html_print_input_hidden(
'show_groups_'.$row['id_usuario'],
-1,
true
);
}
$data[4] .= '<br/>';
$data[4] .= '<br/>';
$total_profile++;
}
@ -719,6 +760,8 @@ foreach ($info as $user_id => $user_info) {
}
$data[4] .= '</div>';
$data[4] .= '<div class="invisible" id="profiles_'.$user_profiles[0]['id_usuario'].'">';
$data[4] .= '</div>';
} else {
$data[4] .= __('The user doesn\'t have any assigned profile/group');
}
@ -882,16 +925,46 @@ echo '</div>';
enterprise_hook('close_meta_frame');
echo '<script type="text/javascript">
function showGroups(){
var groups_list = document.getElementById("groups_list");
?>
<script type="text/javascript">
function showGroups(id_user) {
if ($(`#hidden-show_groups_${id_user}`).val() === '-1') {
var request = $.ajax({
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
type: 'GET',
dataType: 'json',
data: {
page: 'godmode/users/user_list',
get_user_profile_group: 1,
id_user: id_user
},
success: function (data, textStatus, xhr) {
let count = 1;
data.forEach( function(valor, indice, array) {
if (count >= 6) {
let main_div = $(`#profiles_${id_user}`);
main_div.append(
`<div id="left_${id_user}_${count}" class='float-left'>${valor.id_perfil} / </div>`,
`<div id="right_${id_user}_${count}" class='float-left pdd_l_5px'>${valor.id_grupo}</div>`,
`<br/><br/>`
);
}
count ++;
});
},
error: function (e, textStatus) {
console.error(textStatus);
}
});
$(`#hidden-show_groups_${id_user}`).val('1');
$(`#profiles_${id_user}`).show();
} else if ($(`#hidden-show_groups_${id_user}`).val() === '1') {
$(`#hidden-show_groups_${id_user}`).val('0');
$(`#profiles_${id_user}`).hide();
} else {
$(`#hidden-show_groups_${id_user}`).val('1');
$(`#profiles_${id_user}`).show();
}
}
if(groups_list.style.display == "none"){
document.querySelectorAll("[id=groups_list]").forEach(element=>
element.style.display = "block");
}else{
document.querySelectorAll("[id=groups_list]").forEach(element=>
element.style.display = "none");
};
}
</script>';
</script>

View File

@ -941,6 +941,7 @@ class HostDevices extends Wizard
'return' => true,
'class' => 'discovery_list_input',
'simple_multiple_options' => true,
'required' => true,
]
);
@ -1001,6 +1002,7 @@ class HostDevices extends Wizard
$("#text-interval_text").val(10);
$("#hidden-interval").val('.$interval.');
$("#interval_units").val('.$unit.');
$("#interval_units").trigger("change");
}
}).change();

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -892,34 +892,6 @@ if ($get_agent_alerts_datatable === true) {
// Order and pagination metacosole.
if (is_metaconsole() === true) {
/**
* Auxiliar Ordenation function
*
* @param string $sort Direction of sort.
* @param string $sortField Field for perform the sorting.
*/
function arrayOutputSorting($sort, $sortField)
{
return function ($a, $b) use ($sort, $sortField) {
if ($sort === 'asc') {
if (is_string($a[$sortField]) === true) {
return strnatcasecmp($a[$sortField], $b[$sortField]);
} else {
return ($a[$sortField] - $b[$sortField]);
}
} else {
if (is_string($a[$sortField]) === true) {
return strnatcasecmp($b[$sortField], $a[$sortField]);
} else {
return ($a[$sortField] + $b[$sortField]);
}
}
};
}
// Status order.
if ($sortField === 'status') {
foreach ($alerts['alerts_simple'] as $i => $alert) {

View File

@ -64,9 +64,9 @@ $add_comment = (bool) get_parameter('add_comment');
$dialogue_event_response = (bool) get_parameter('dialogue_event_response');
$perform_event_response = (bool) get_parameter('perform_event_response');
$get_response = (bool) get_parameter('get_response');
$get_response_target = (bool) get_parameter('get_response_target');
$get_response_params = (bool) get_parameter('get_response_params');
$get_response_description = (bool) get_parameter('get_response_description');
$get_response_massive = (bool) get_parameter('get_response_massive');
$get_row_response_action = (bool) get_parameter('get_row_response_action');
$draw_row_response_info = (bool) get_parameter('draw_row_response_info', false);
$meta = get_parameter('meta', 0);
$history = get_parameter('history', 0);
$table_events = get_parameter('table_events', 0);
@ -373,8 +373,8 @@ if ($save_event_filter) {
$values['custom_data'] = get_parameter('custom_data');
$values['custom_data_filter_type'] = get_parameter('custom_data_filter_type');
if (is_metaconsole()) {
$values['server_id'] = get_parameter('server_id');
if (is_metaconsole() === true) {
$values['server_id'] = implode(',', get_parameter('server_id'));
}
$exists = (bool) db_get_value_filter(
@ -432,7 +432,7 @@ if ($update_event_filter) {
$values['custom_data_filter_type'] = get_parameter('custom_data_filter_type');
if (is_metaconsole() === true) {
$values['server_id'] = get_parameter('server_id');
$values['server_id'] = implode(',', get_parameter('server_id'));
}
if (io_safe_output($values['tag_with']) == '["0"]') {
@ -1061,87 +1061,6 @@ $(document).ready(function (){
}
if ($get_response_description) {
$response_id = get_parameter('response_id');
$description = db_get_value('description', 'tevent_response', 'id', $response_id);
if ($description === false) {
return;
}
$description = io_safe_output($description);
$description = str_replace("\r\n", '<br>', $description);
echo $description;
return;
}
if ($get_response_params) {
if (! check_acl($config['id_user'], 0, 'EW')) {
echo 'unauthorized';
return;
}
$response_id = get_parameter('response_id');
$params = db_get_value('params', 'tevent_response', 'id', $response_id);
if ($params === false) {
return;
}
echo json_encode(explode(',', $params));
return;
}
if ($get_response_target === true) {
if (! check_acl($config['id_user'], 0, 'EW')) {
echo 'unauthorized';
return;
}
$response_id = (int) get_parameter('response_id');
$event_id = (int) get_parameter('event_id');
$server_id = (int) get_parameter('server_id');
try {
if (is_metaconsole() === true
&& $server_id > 0
) {
$node = new Node($server_id);
$node->connect();
}
$event_response = db_get_row('tevent_response', 'id', $response_id);
if (empty($event_response) === true) {
return;
}
echo events_get_response_target($event_id, $response_id);
} catch (\Exception $e) {
// Unexistent agent.
if (is_metaconsole() === true
&& $server_id > 0
) {
$node->disconnect();
}
return;
} finally {
if (is_metaconsole() === true
&& $server_id > 0
) {
$node->disconnect();
}
}
return;
}
if ($get_response === true) {
if (! check_acl($config['id_user'], 0, 'EW')) {
echo 'unauthorized';
@ -1149,62 +1068,27 @@ if ($get_response === true) {
}
$response_id = get_parameter('response_id');
$server_id = (int) get_parameter('server_id');
$server_id = (int) get_parameter('server_id', 0);
$event_id = (int) get_parameter('event_id', 0);
$response_parameters = json_decode(
io_safe_output(
get_parameter('response_parameters', '')
),
true
);
try {
if (is_metaconsole() === true
&& $server_id > 0
) {
$node = new Node($server_id);
$node->connect();
}
$event_response = db_get_row(
'tevent_response',
'id',
$response_id
);
} catch (\Exception $e) {
// Unexistent agent.
if (is_metaconsole() === true
&& $server_id > 0
) {
$node->disconnect();
}
return;
} finally {
if (is_metaconsole() === true
&& $server_id > 0
) {
$node->disconnect();
}
}
$event_response = db_get_row(
'tevent_response',
'id',
$response_id
);
if (empty($event_response) === true) {
return;
return [];
}
echo json_encode($event_response);
return;
}
if ($perform_event_response === true) {
global $config;
if (! check_acl($config['id_user'], 0, 'EW')) {
echo 'unauthorized';
return;
}
$target = get_parameter('target', '');
$response_id = get_parameter('response_id');
$event_id = (int) get_parameter('event_id');
$server_id = (int) get_parameter('server_id', 0);
$event_response = false;
if (empty($target) === true) {
if (empty($event_id) === false) {
try {
if (is_metaconsole() === true
&& $server_id > 0
@ -1213,20 +1097,12 @@ if ($perform_event_response === true) {
$node->connect();
}
$event_response = db_get_row(
'tevent_response',
'id',
$response_id
);
if (empty($event_response) === true) {
return;
}
$command = events_get_response_target(
$event_response['target'] = events_get_response_target(
$event_id,
$response_id,
$server_id
$event_response,
$response_parameters,
$server_id,
($server_id !== 0) ? $node->server_name() : 'Metaconsole'
);
} catch (\Exception $e) {
// Unexistent agent.
@ -1244,10 +1120,130 @@ if ($perform_event_response === true) {
$node->disconnect();
}
}
} else {
$command = $target;
}
echo json_encode($event_response);
return;
}
if ($get_response_massive === true) {
if (! check_acl($config['id_user'], 0, 'EW')) {
echo 'unauthorized';
return;
}
$response_id = get_parameter('response_id');
$event_response = db_get_row(
'tevent_response',
'id',
$response_id
);
if (empty($event_response) === true) {
return [];
}
$events = json_decode(
io_safe_output(
get_parameter('events', '')
),
true
);
$response_parameters = json_decode(
io_safe_output(
get_parameter('response_parameters', '')
),
true
);
$event_response_targets = [];
if (is_metaconsole() === true) {
foreach ($events as $server_id => $idEvents) {
foreach ($idEvents as $idEvent) {
$event_response_targets[$idEvent.'|'.$server_id]['target'] = get_events_get_response_target(
$idEvent,
$event_response,
$server_id,
$response_parameters
);
}
}
} else {
foreach ($events as $idEvent) {
$event_response_targets[$idEvent]['target'] = get_events_get_response_target(
$idEvent,
$event_response,
0,
$response_parameters
);
}
}
$result = [
'event_response' => $event_response,
'event_response_targets' => $event_response_targets,
];
echo json_encode($result);
return;
}
if ($get_row_response_action === true) {
$response_id = get_parameter('response_id');
$response = json_decode(
io_safe_output(
get_parameter('response', '')
),
true
);
$end = (bool) get_parameter('end', false);
$index = $response['event_id'];
if (is_metaconsole() === true) {
$index .= '-'.$response['server_id'];
}
echo get_row_response_action(
$response,
$response_id,
$end,
$index
);
return;
}
if ($perform_event_response === true) {
global $config;
if (! check_acl($config['id_user'], 0, 'EW')) {
echo __('unauthorized');
return;
}
$target = get_parameter('target', '');
$response_id = get_parameter('response_id');
$event_id = (int) get_parameter('event_id');
$server_id = (int) get_parameter('server_id', 0);
$response = json_decode(
io_safe_output(
get_parameter('response', '')
),
true
);
$event_response = $response;
if (empty($event_response) === true) {
echo __('No data');
return;
}
$command = $event_response['target'];
$command_timeout = ($event_response !== false) ? $event_response['command_timeout'] : 90;
if (enterprise_installed() === true) {
if ($event_response !== false
@ -1327,7 +1323,7 @@ if ($perform_event_response === true) {
break;
}
system($timeout_bin.' '.$command_timeout.' '.io_safe_output($command).' 2>&1', $ret_val);
system($timeout_bin.' '.$command_timeout.' '.io_safe_output($command).' 2>&1', $ret_val);
}
if ($ret_val != 0) {
@ -1350,78 +1346,19 @@ if ($dialogue_event_response) {
$event_id = get_parameter('event_id');
$response_id = get_parameter('response_id');
$command = get_parameter('target');
$massive = get_parameter('massive');
$end = get_parameter('end');
$show_execute_again_btn = get_parameter('show_execute_again_btn');
$out_iterator = get_parameter('out_iterator');
$event_response = db_get_row('tevent_response', 'id', $response_id);
$server_id = get_parameter('server_id');
$event_response = json_decode(
io_safe_output(
get_parameter('response', '')
),
true
);
$event = db_get_row('tevento', 'id_evento', $event_id);
$prompt = '<br>> ';
switch ($event_response['type']) {
case 'command':
$display_command = (bool) $event_response['display_command'];
$command_str = ($display_command === true) ? $command : '';
if ($massive) {
echo "<div class='left'>";
echo $prompt.sprintf(
'(Event #'.$event_id.') '.__(
'Executing command: %s',
$command_str
)
);
echo '</div><br>';
echo "<div id='response_loading_command_".$out_iterator."' style='display: none'>";
echo html_print_image(
'images/spinner.gif',
true
);
echo '</div><br>';
echo "<br><div id='response_out_".$out_iterator."'><br><br></div><br>";
if ($end) {
echo "<br><div id='re_exec_command_".$out_iterator."' style='display: none'><br>";
html_print_button(
__('Execute again'),
'btn_str',
false,
'execute_event_response(false);',
"class='sub next'"
);
echo "<span id='execute_again_loading' style='display: none'>";
echo html_print_image(
'images/spinner.gif',
true
);
echo '</span>';
echo '</div>';
}
} else {
echo "<div class='left'>";
echo $prompt.'Executing command: '.$command_str;
echo '</div><br>';
echo "<div id='response_loading_command' style='display:none'>";
echo html_print_image('images/spinner.gif', true);
echo '</div>';
echo "<br><br><br><div id='response_out' class='left'></div>";
echo "<br><div id='re_exec_command' style='display:none'><br><br>";
html_print_button(
__('Execute again'),
'btn_str',
false,
"perform_response({'target':'".$command."','event_id':".$event_id.",'server_id':".$server_id.'}, '.$response_id.');',
"class='sub next'"
);
echo '</div>';
}
echo get_row_response_action(
$event_response,
$response_id
);
break;
case 'url':
@ -2542,3 +2479,75 @@ if ($get_events_fired) {
echo io_json_mb_encode($return);
return;
}
if ($draw_row_response_info === true) {
$event_response = json_decode(
io_safe_output(
get_parameter('response', '')
),
true
);
$massive = (bool) get_parameter('massive', false);
$output .= '';
if ($massive === true) {
$output .= '<div>';
$output .= '<h5>';
$output .= $event_response['description'];
$output .= '</h5>';
$output .= '</div>';
} else {
$output .= '<tr class="params_rows">';
$output .= '<td>';
$output .= __('Description');
$output .= '</td>';
$output .= '<td class="height_30px" colspan="2">';
$output .= $event_response['description'];
$output .= '</td>';
$output .= '</tr>';
}
if (empty($event_response['params']) === false) {
$response_params = explode(',', $event_response['params']);
if (is_array($response_params) === true) {
if ($massive === true) {
$output .= '<div>';
} else {
$output .= '<tr class="params_rows">';
$output .= '<td class="left pdd_l_20px height_30px" colspan="3">';
$output .= __('Parameters');
$output .= '</td>';
$output .= '</tr>';
}
foreach ($response_params as $param) {
$param = trim(io_safe_output($param));
if ($massive === true) {
$output .= '<div>';
$output .= '<label>';
$output .= $param;
$output .= '</label>';
$output .= '<input type="text" name="values_params_'.$param.'" />';
$output .= '</div>';
} else {
$output .= '<tr class="params_rows">';
$output .= '<td style="text-align:left; padding-left:40px; font-weight: normal; font-style: italic;">';
$output .= $param;
$output .= '</td>';
$output .= '<td style="text-align:left" colspan="2">';
$output .= '<input type="text" name="values_params_'.$param.'" />';
$output .= '</td>';
$output .= '</tr>';
}
}
if ($massive === true) {
$output .= '</div>';
}
}
}
echo $output;
return;
}

View File

@ -1916,12 +1916,21 @@ class AgentWizard extends HTML
$values['configuration_data'] = io_safe_input($cfData);
} else {
$values['id_module'] = MODULE_PLUGIN;
$fieldsPlugin = db_get_value_sql(
sprintf(
'SELECT macros FROM tplugin WHERE id=%d',
(int) $infoMacros['server_plugin']
)
);
if ((int) $infoMacros['server_plugin'] === 12) {
// Search plugin by execute.
$plugin_wmi = db_get_row_sql(
'SELECT id, macros FROM tplugin WHERE execute like "%wizard_wmi_module%"'
);
$fieldsPlugin = $plugin_wmi['macros'];
$infoMacros['server_plugin'] = $plugin_wmi['id'];
} else {
$fieldsPlugin = db_get_value_sql(
sprintf(
'SELECT macros FROM tplugin WHERE id=%d',
(int) $infoMacros['server_plugin']
)
);
}
if ($fieldsPlugin !== false) {
$fieldsPlugin = json_decode($fieldsPlugin, true);
@ -2360,12 +2369,21 @@ class AgentWizard extends HTML
);
} else {
$tmp->id_modulo(MODULE_PLUGIN);
$fieldsPlugin = db_get_value_sql(
sprintf(
'SELECT macros FROM tplugin WHERE id=%d',
(int) $infoMacros['server_plugin']
)
);
if ((int) $infoMacros['server_plugin'] === 12) {
// Search plugin by execute.
$plugin_wmi = db_get_row_sql(
'SELECT id, macros FROM tplugin WHERE execute like "%wizard_wmi_module%"'
);
$fieldsPlugin = $plugin_wmi['macros'];
$infoMacros['server_plugin'] = $plugin_wmi['id'];
} else {
$fieldsPlugin = db_get_value_sql(
sprintf(
'SELECT macros FROM tplugin WHERE id=%d',
(int) $infoMacros['server_plugin']
)
);
}
if ($fieldsPlugin !== false) {
$fieldsPlugin = json_decode($fieldsPlugin, true);

View File

@ -44,7 +44,7 @@ class AuditLog extends HTML
*
* @var array
*/
public $AJAXMethods = [ 'draw' ];
public $AJAXMethods = ['draw'];
/**
* Ajax page.
@ -78,7 +78,6 @@ class AuditLog extends HTML
// Set the ajax controller.
$this->ajaxController = $ajaxController;
}
@ -232,7 +231,6 @@ class AuditLog extends HTML
// Load own javascript file.
echo $this->loadJS();
}
@ -368,39 +366,38 @@ class AuditLog extends HTML
// Javascript content.
?>
<script type="text/javascript">
function format ( d ) {
var output = '';
<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;
if (d.extendedInfo === '') {
output = "<?php echo __('There is no additional information to display'); ?>";
} else {
output = d.extendedInfo;
}
$(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>
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 $this->tableId; ?>").DataTable();
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

@ -594,6 +594,7 @@ class CustomNetScan extends Wizard
$("#text-interval_text").val(10);
$("#hidden-interval").val('.$interval.');
$("#interval_units").val('.$unit.');
$("#interval_units").trigger("change");
}
}).change();
';

View File

@ -2102,39 +2102,91 @@ class NetworkMap
$i++;
}
if (!$this->relations) {
// Search for relations.
foreach ($this->nodes as $k => $item) {
$target = $this->calculateRelations($k);
// Search for relations.
foreach ($this->nodes as $k => $item) {
$target = $this->calculateRelations($k);
// Adopt all orphan nodes but pandora one.
if (empty($target)) {
if (isset($this->noPandoraNode) === false
|| $this->noPandoraNode == false
) {
if ($item['id_node'] != 0) {
$rel = [];
$rel['id_parent'] = 0;
$rel['id_child'] = $item['id_node'];
$rel['parent_type'] = NODE_PANDORA;
$rel['child_type'] = $item['node_type'];
$rel['id_child_source_data'] = $item['id_source_data'];
// Adopt all orphan nodes but pandora one.
if (empty($target) === true) {
if (isset($this->noPandoraNode) === false
|| $this->noPandoraNode == false
) {
if ($item['id_node'] != 0) {
$rel = [];
$rel['id_parent'] = 0;
$rel['id_child'] = $item['id_node'];
$rel['parent_type'] = NODE_PANDORA;
$rel['child_type'] = $item['node_type'];
$rel['id_child_source_data'] = $item['id_source_data'];
$orphans[] = $rel;
}
}
} else {
// Flattern edges.
foreach ($target as $rel) {
$edges[] = $rel;
$orphans[] = $rel;
}
}
} else {
// Flattern edges.
foreach ($target as $rel) {
$edges[] = $rel;
}
}
} else {
$edges = $this->relations;
}
if (is_array($edges)) {
$array_aux = $edges;
$target_aux = $edges;
foreach ($edges as $key => $rel) {
foreach ($array_aux as $key2 => $rel2) {
if ($key2 <= $key) {
continue;
}
if ($rel['child_type'] == 1 && $rel['parent_type'] == 1
&& $rel2['child_type'] == 1 && $rel2['parent_type'] == 1
) {
if ($rel['id_parent'] == $rel2['id_parent'] && $rel['id_child'] == $rel2['id_child']) {
if ($rel['id_parent_source_data'] == $rel2['id_parent_source_data']) {
if (modules_get_agentmodule_type($rel['id_child_source_data']) === 6) {
unset($target_aux[$key]);
} else if (modules_get_agentmodule_type($rel2['id_child_source_data']) === 6) {
unset($target_aux[$key2]);
}
} else if ($rel['id_child_source_data'] == $rel2['id_child_source_data']) {
if (modules_get_agentmodule_type($rel['id_parent_source_data']) === 6) {
unset($target_aux[$key]);
} else if (modules_get_agentmodule_type($rel2['id_parent_source_data']) === 6) {
unset($target_aux[$key2]);
}
}
} else if ($rel['id_parent'] == $rel2['id_child'] && $rel['id_child'] == $rel2['id_parent']) {
if ($rel['id_parent_source_data'] == $rel2['id_child_source_data']
&& $rel['id_child_source_data'] == $rel2['id_parent_source_data']
) {
unset($target_aux[$key2]);
continue;
}
if ($rel['id_parent_source_data'] == $rel2['id_child_source_data']) {
if (modules_get_agentmodule_type($rel['id_child_source_data']) === 6) {
unset($target_aux[$key]);
} else if (modules_get_agentmodule_type($rel2['id_parent_source_data']) === 6) {
unset($target_aux[$key2]);
}
} else if ($rel['id_child_source_data'] == $rel2['id_parent_source_data']) {
if (modules_get_agentmodule_type($rel['id_parent_source_data']) === 6) {
unset($target_aux[$key]);
} else if (modules_get_agentmodule_type($rel2['id_child_source_data']) === 6) {
unset($target_aux[$key2]);
}
}
}
}
}
}
$edges = [];
foreach ($target_aux as $key => $value) {
$edges[] = $value;
}
foreach ($edges as $rel) {
$graph .= $this->createDotEdge(
[
@ -2628,6 +2680,79 @@ class NetworkMap
}
/**
* Regenerates a nodes - relationships array using graphviz dot
* schema and stores nodes&relations into $this->graph.
*
* @return object
*/
public function recalculateCoords()
{
global $config;
include_once 'include/functions_os.php';
$map_filter = $this->mapOptions['map_filter'];
/*
* Let graphviz place the nodes.
*/
if ($map_filter['empty_map']) {
$this->generateEmptyDotGraph();
} else if (!isset($this->dotGraph)) {
$this->generateDotGraph();
}
$graph = $this->calculateCoords();
if (is_array($graph) === true) {
$nodes = $graph['nodes'];
} else {
return [];
}
$nodes_aux = [];
// Prepare graph nodes.
foreach ($nodes as $id => $coords) {
$node_tmp['id'] = $id;
$source = $this->getNodeData($id);
$node_tmp['type'] = $source['node_type'];
$node_tmp['x'] = $coords['x'];
$node_tmp['y'] = $coords['y'];
switch ($node_tmp['type']) {
case NODE_AGENT:
$node_tmp['source_data'] = $source['id_agente'];
break;
case NODE_MODULE:
$node_tmp['source_data'] = $source['id_agente_modulo'];
break;
case NODE_PANDORA:
$node_tmp['source_data'] = 0;
$node_center['x'] = ($coords['x'] - MAP_X_CORRECTION);
$node_center['y'] = ($coords['y'] - MAP_Y_CORRECTION);
break;
case NODE_GENERIC:
default:
$node_tmp['source_data'] = $source['id_source'];
break;
}
$nodes_aux[$index] = $node_tmp;
$index++;
}
return $nodes_aux;
}
/**
* Transform node information into JS data.
*
@ -2799,7 +2924,6 @@ class NetworkMap
$output .= "var add_node_menu = '".__('Add node')."';\n";
$output .= "var set_center_menu = '".__('Set center')."';\n";
$output .= "var refresh_menu = '".__('Refresh')."';\n";
$output .= "var refresh_holding_area_menu = '".__('Refresh Holding area')."';\n";
$output .= "var ok_button = '".__('Proceed')."';\n";
$output .= "var message_to_confirm = '".__('Resetting the map will delete all customizations you have done, including manual relationships between elements, new items, etc.')."';\n";
$output .= "var warning_message = '".__('WARNING')."';\n";
@ -3066,8 +3190,8 @@ class NetworkMap
$table->data['template_row']['node_target'] = '';
$table->data['template_row']['edit'] = '';
$table->data['template_row']['edit'] .= '<span class="edit_icon_correct" style="display: none">'.html_print_image('images/dot_green.png', true).'</span><span class="edit_icon_fail" style="display: none" >'.html_print_image('images/dot_red.png', true).'</span><span class="edit_icon_progress" style="display: none">'.html_print_image('images/spinner.gif', true).'</span><span class="edit_icon"><a class="edit_icon_link" title="'.__('Update').'" href="#">'.html_print_image('images/config.png', true, ['class' => 'invert_filter']).'</a></span>';
$table->data['template_row']['edit'] .= '<span class="edit_icon_correct" style="display: none">'.html_print_image('images/dot_green.png', true).'</span><span class="edit_icon_fail" style="display: none" >'.html_print_image('images/dot_red.png', true).'</span><span class="edit_icon_progress" style="display: none">'.html_print_image('images/spinner.gif', true).'</span>';
// <span class="edit_icon"><a class="edit_icon_link" title="'.__('Update').'" href="#">'.html_print_image('images/config.png', true, ['class' => 'invert_filter']).'</a></span>';
$table->data['template_row']['edit'] .= '<a class="delete_icon" href="#">'.html_print_image('images/delete.png', true, ['class' => 'invert_filter']).'</a>';
$table->colspan['no_relations']['0'] = 5;
@ -3278,7 +3402,7 @@ class NetworkMap
$table->data[1][1] = html_print_select(
$list_networkmaps,
'networkmap_to_link',
'',
0,
'',
'',
0,
@ -3318,6 +3442,10 @@ class NetworkMap
*/
public function loadController(?bool $return=true)
{
if (isset($this->mapOptions['refresh_time']) === false) {
$this->mapOptions['refresh_time'] = 0;
}
$output = '';
if ($this->useTooltipster
@ -3359,13 +3487,34 @@ class NetworkMap
node_radius: node_radius,
holding_area_dimensions: networkmap_holding_area_dimensions,
url_background_grid: url_background_grid,
refresh_time: '.$this->mapOptions['refresh_time'].',
font_size: '.$this->mapOptions['font_size'].',
base_url_homedir: "'.ui_get_full_url(false).'"
});
init_drag_and_drop();
init_minimap();
function_open_minimap();
if ('.$this->mapOptions['refresh_time'].' > 0) {
var startCountDown = function (duration, cb) {
$("div.vc-countdown").countdown("destroy");
if (!duration) return;
var t = new Date();
t.setTime(t.getTime() + duration * 1000);
$("div.vc-countdown").countdown({
until: t,
format: "MS",
layout: "(%M%nn%M:%S%nn%S '.__('Until refresh').') ",
alwaysExpire: true,
onExpiry: function () {
refresh();
}
});
}
startCountDown('.($this->mapOptions['refresh_time']).', false);
}
$(document.body).on("mouseleave",
".context-menu-list",
function(e) {
@ -3504,6 +3653,10 @@ class NetworkMap
$output .= ' style="width: '.$this->mapOptions['width'].'px; height: '.$this->mapOptions['height'].'px;position: relative; overflow: hidden; background: #FAFAFA">';
}
$output .= '<div id="spinner_networkmap" style="position: absolute; width: 100%;height: 100%; z-index:1; justify-content: center; align-items: center; display:none; background-color:rgba(0, 0, 0, 0.2);">';
$output .= html_print_image('/images/spinner.gif', true, ['style' => 'width: 22px; height: 22px']);
$output .= '</div>';
$output .= '<div style="display: '.$minimap_display.';">';
$output .= '<canvas id="minimap_'.$networkmap['id'].'"';
$output .= ' class="minimap">';

View File

@ -56,6 +56,7 @@ class SatelliteAgent extends HTML
'draw',
'addAgent',
'deleteAgent',
'disableAgent',
'loadModal',
];
@ -97,7 +98,6 @@ class SatelliteAgent extends HTML
$this->satellite_name = servers_get_name($this->satellite_server);
$this->satellite_config = (array) config_satellite_get_config_file($this->satellite_name);
}
}
@ -108,27 +108,53 @@ class SatelliteAgent extends HTML
*/
public function run()
{
global $config;
// Javascript.
ui_require_jquery_file('pandora');
// CSS.
ui_require_css_file('wizard');
ui_require_css_file('discovery');
global $config;
$this->createBlock();
// Datatables list.
try {
$checkbox_all = html_print_checkbox(
'all_validate_box',
1,
false,
true
);
$columns = [
[
'text' => 'm',
'extra' => $checkbox_all,
'class' => 'mw60px',
],
'name',
'address',
'actions',
];
$column_names = [
[
'text' => 'm',
'extra' => $checkbox_all,
'class' => 'w20px no-text-imp',
],
__('Agent Name'),
__('IP Adrress'),
__('Actions'),
];
$show_agents = [
0 => __('Everyone'),
1 => __('Only disabled'),
2 => __('Only deleted'),
3 => __('Only added'),
];
$this->tableId = 'satellite_agents';
if (is_metaconsole() === true) {
@ -154,6 +180,7 @@ class SatelliteAgent extends HTML
0,
1,
2,
3,
],
'search_button_class' => 'sub filter float-right',
'form' => [
@ -167,7 +194,15 @@ class SatelliteAgent extends HTML
'name' => 'filter_search',
'size' => 12,
],
[
'label' => __('Show agents'),
'type' => 'select',
'id' => 'filter_agents',
'name' => 'filter_agents',
'fields' => $show_agents,
'return' => true,
'selected' => 0,
],
],
],
]
@ -186,7 +221,34 @@ class SatelliteAgent extends HTML
$msg = '<div id="msg" class="invisible"></div>';
$aux = '<div id="aux" class="invisible"></div>';
echo $modal.$msg.$aux;
echo $modal.$msg.$aux;
echo '<div id="satellite_actions" class="action-buttons" style="width: 100%">';
html_print_select(
[
'0' => 'Disable / Enable selected agents',
'1' => 'Delete / Create selected agents',
],
'satellite_action',
'',
'',
'',
0,
false,
false,
false
);
html_print_submit_button(
__('Execute action'),
'submit_satellite_action',
false,
'class="sub next"'
);
echo '</div>';
echo '</br></br>';
// Create button.
echo '<div class="w100p flex-content-right">';
@ -200,7 +262,6 @@ class SatelliteAgent extends HTML
echo '</div>';
// Load own javascript file.
echo $this->loadJS();
}
@ -212,8 +273,7 @@ class SatelliteAgent extends HTML
public function draw()
{
global $config;
// Initialice filter.
$filter = '1=1';
// Init data.
$data = [];
// Count of total records.
@ -228,8 +288,24 @@ class SatelliteAgent extends HTML
ob_start();
$data = [];
$agents_db = db_get_all_rows_sql(
sprintf(
'SELECT id_agente, alias AS name, direccion AS address,
IF(disabled = 0, INSERT("add_host", 0 , 0, ""),
IF(modo = 1, INSERT("ignore_host", 0 , 0, ""), INSERT("delete_host", 0, 0, ""))) AS type
FROM tagente WHERE `satellite_server` = %d',
$this->satellite_server
)
);
if (empty($agents_db) === false) {
$data = $agents_db;
}
foreach ($this->satellite_config as $line) {
$re = '/^#*add_host \b(\S+) (\S*)$/m';
$re = '/^#*add_host \b(\S+) (\S*)/m';
$re_disable = '/^ignore_host \b(\S+)/m';
$re_delete = '/^delete_host \b(\S+)/m';
if (preg_match($re, $line, $matches, PREG_OFFSET_CAPTURE, 0) > 0) {
$agent['address'] = $matches[1][0];
@ -239,17 +315,64 @@ class SatelliteAgent extends HTML
$agent['name'] = $matches[2][0];
}
if (empty($filters['filter_search']) === false) {
if (empty(preg_grep('/'.$filters['filter_search'].'?/mi', array_values($agent))) === true) {
continue;
}
}
$agent['type'] = 'add_host';
array_push($data, $agent);
}
if (preg_match($re_disable, $line, $matches, PREG_OFFSET_CAPTURE, 0) > 0) {
$agent['name'] = $matches[1][0];
$agent['type'] = 'ignore_host';
array_push($data, $agent);
}
if (preg_match($re_delete, $line, $matches, PREG_OFFSET_CAPTURE, 0) > 0) {
$agent['name'] = $matches[1][0];
$agent['type'] = 'delete_host';
array_push($data, $agent);
}
}
if (empty($data) === false) {
$data = $this->uniqueMultidimArray($data, ['name', 'address']);
if (empty($filters['filter_agents']) === false || empty($filters['filter_search']) === false) {
foreach ($data as $key => $value) {
switch ($filters['filter_agents']) {
case 1:
if ($value['type'] !== 'ignore_host') {
unset($data[$key]);
}
break;
case 2:
if ($value['type'] !== 'delete_host') {
unset($data[$key]);
}
break;
case 3:
if ($value['type'] !== 'add_host') {
unset($data[$key]);
}
break;
default:
// Everyone.
break;
}
if (empty($filters['filter_search']) === false) {
if (empty(preg_grep('/'.$filters['filter_search'].'?/mi', array_values($value))) === true) {
unset($data[$key]);
}
}
}
}
$data = array_reduce(
$data,
function ($carry, $item) {
@ -258,14 +381,50 @@ class SatelliteAgent extends HTML
// of objects, making a post-process of certain fields.
$tmp = (object) $item;
$tmp->actions .= html_print_image(
'images/cross.png',
true,
[
'border' => '0',
'class' => 'action_button_img invert_filter',
'onclick' => 'delete_agent(\''.$tmp->address.'\',\''.$tmp->name.'\')',
]
$disable = ($tmp->type === 'ignore_host');
$delete = ($tmp->type === 'delete_host');
if ($disable === true) {
$tmp->name = '<i class="italic_a">'.$tmp->name.'</i>';
}
if ($delete === true) {
$tmp->name = '<del>'.$tmp->name.'</del>';
}
$id_agente = (isset($tmp->id_agente) === true) ? $tmp->id_agente : 0;
$tmp->actions = '';
if ($delete === false) {
$tmp->actions .= html_print_image(
($disable === true) ? 'images/lightbulb_off.png' : 'images/lightbulb.png',
true,
[
'border' => '0',
'class' => 'action_button_img mrgn_lft_05em invert_filter',
'onclick' => 'disable_agent(\''.$tmp->address.'\',\''.strip_tags($tmp->name).'\',\''.(int) $disable.'\',\''.$id_agente.'\')',
]
);
}
if ($disable === false) {
$tmp->actions .= html_print_image(
($delete === true) ? 'images/add.png' : 'images/cross.png',
true,
[
'border' => '0',
'class' => 'action_button_img mrgn_lft_05em invert_filter',
'onclick' => 'delete_agent(\''.$tmp->address.'\',\''.strip_tags($tmp->name).'\',\''.(int) $delete.'\',\''.$id_agente.'\')',
]
);
}
$tmp->m = html_print_checkbox(
'check_'.strip_tags($tmp->name),
$tmp->address.','.strip_tags($tmp->name).','.(int) $delete.','.(int) $disable.','.$id_agente,
false,
true
);
$carry[] = $tmp;
@ -274,8 +433,13 @@ class SatelliteAgent extends HTML
);
}
$data = array_slice($data, $start, $length, true);
$total = count($data);
if (empty($data) === true) {
$total = 0;
$data = [];
} else {
$total = count($data);
$data = array_slice($data, $start, $length, false);
}
echo json_encode(
[
@ -333,12 +497,6 @@ class SatelliteAgent extends HTML
$values = [];
}
$return_all_group = false;
if (users_can_manage_group_all('AR') === true) {
$return_all_group = true;
}
$form = [
'action' => '#',
'id' => 'modal_form',
@ -392,6 +550,16 @@ class SatelliteAgent extends HTML
$values['address'] = get_parameter('address');
$values['name'] = get_parameter('name');
if ($this->checkAddressExists($values['address']) === true) {
$this->ajaxMsg('error', __('Error saving agent. The address already exists'));
exit;
}
if ($this->checkNameExists($values['name']) === true) {
$this->ajaxMsg('error', __('Error saving agent. The Name already exists'));
exit;
}
if ($this->parseSatelliteConf('save', $values) === false) {
$this->ajaxMsg('error', __('Error saving agent'));
} else {
@ -412,11 +580,82 @@ class SatelliteAgent extends HTML
{
$values['address'] = get_parameter('address', '');
$values['name'] = get_parameter('name', '');
$values['delete'] = get_parameter('delete', '');
$values['id'] = get_parameter('id', 0);
$no_msg = (bool) get_parameter('no_msg', 0);
if ((bool) $values['id'] === true) {
db_process_sql_update(
'tagente',
[
'disabled' => ($values['delete'] === '0') ? 1 : 0,
'modo' => ($values['delete'] === '0') ? 2 : 1,
],
['id_agente' => (int) $values['id']]
);
}
if ($this->parseSatelliteConf('delete', $values) === false) {
$this->ajaxMsg('error', __('Error saving agent'));
if ($no_msg === false) {
$this->ajaxMsg('error', ($values['delete'] === '0') ? __('Error delete agent') : __('Error add agent'));
}
} else {
$this->ajaxMsg('result', _('Host '.$values['addres'].' added.'));
if ($no_msg === false) {
$this->ajaxMsg(
'result',
($values['delete'] === '0')
? _('Host '.$values['address'].' deleted.')
: _('Host '.$values['address'].' added.'),
true
);
}
}
exit;
}
/**
* Disable agent from satellite conf.
*
* @return void
*/
public function disableAgent()
{
$values['address'] = get_parameter('address', '');
$values['name'] = get_parameter('name', '');
$values['disable'] = get_parameter('disable', '');
$values['id'] = get_parameter('id', 0);
$no_msg = (bool) get_parameter('no_msg', 0);
if ((bool) $values['id'] === true) {
db_process_sql_update(
'tagente',
['disabled' => ($values['disable'] === '0') ? 1 : 0],
['id_agente' => (int) $values['id']]
);
}
if ($this->parseSatelliteConf('disable', $values) === false) {
if ($no_msg === false) {
$this->ajaxMsg(
'error',
($values['disable'] === '0') ? __('Error disable agent') : __('Error enable agent')
);
}
} else {
if ($no_msg === false) {
$this->ajaxMsg(
'result',
($values['disable'] === '0')
? _('Host '.$values['address'].' disabled.')
: _('Host '.$values['address'].' enabled.'),
false,
true
);
}
}
exit;
@ -426,38 +665,173 @@ class SatelliteAgent extends HTML
/**
* Parse satellite configuration .
*
* @param string $action Action to perform (save, delete).
* @param array $values.
* @return void
* @param string $action Action to perform (save, delete).
* @param array $values Values.
*
* @return boolean
*/
private function parseSatelliteConf(string $action, array $values)
{
switch ($action) {
case 'save':
if (isset($values['address']) === true && empty($values['address']) === false) {
$string_hosts = 'add_host '.$values['address'].' '.$values['name']."\n";
$pos = preg_grep('/^\#INIT ignore_host/', $this->satellite_config);
if (empty($pos) === false) {
$string_hosts = 'add_host '.$values['address'].' '.$values['name']."\n";
// Add host to conf
array_push($this->satellite_config, $string_hosts);
$key_pos = 0;
foreach ($pos as $key => $value) {
$key_pos = $key;
break;
}
// Check config.
if (empty($this->satellite_config)) {
return false;
$array1 = array_slice($this->satellite_config, 0, $key_pos);
$array2 = array_slice($this->satellite_config, $key_pos);
// Add host to conf.
$array_merge = array_merge($array1, [$string_hosts], $array2);
$this->satellite_config = $array_merge;
// Check config.
if (empty($this->satellite_config)) {
return false;
}
$conf = implode('', $this->satellite_config);
}
$conf = implode('', $this->satellite_config);
} else {
return false;
}
break;
case 'disable':
if ((bool) $values['disable'] === true) {
$pos = preg_grep('/^\#INIT ignore_host/', $this->satellite_config);
if (empty($pos) === false) {
$string_hosts = 'add_host '.$values['address'].' '.$values['name']."\n";
$key_pos = 0;
foreach ($pos as $key => $value) {
$key_pos = $key;
break;
}
$array1 = array_slice($this->satellite_config, 0, $key_pos);
$array2 = array_slice($this->satellite_config, $key_pos);
// Add host to conf.
$array_merge = array_merge($array1, [$string_hosts], $array2);
$this->satellite_config = $array_merge;
// Remove ignore_host.
$pattern = io_safe_expreg('ignore_host '.$values['name']);
$pos = preg_grep('/'.$pattern.'/', $this->satellite_config);
$key_pos = 0;
foreach ($pos as $key => $value) {
$key_pos = $key;
break;
}
if (empty($pos) === false) {
unset($this->satellite_config[$key_pos]);
}
$conf = implode('', $this->satellite_config);
}
} else {
$pos = preg_grep('/^\#INIT delete_host/', $this->satellite_config);
if (empty($pos) === false) {
$string_hosts = 'ignore_host '.$values['name']."\n";
$key_pos = 0;
foreach ($pos as $key => $value) {
$key_pos = $key;
break;
}
$array1 = array_slice($this->satellite_config, 0, $key_pos);
$array2 = array_slice($this->satellite_config, $key_pos);
// Add host to conf.
$array_merge = array_merge($array1, [$string_hosts], $array2);
$this->satellite_config = $array_merge;
// Remove add_host.
$pattern = io_safe_expreg('add_host '.$values['address'].' '.$values['name']);
$pos = preg_grep('/'.$pattern.'/', $this->satellite_config);
$key_pos = 0;
foreach ($pos as $key => $value) {
$key_pos = $key;
break;
}
if (empty($pos) === false) {
unset($this->satellite_config[$key_pos]);
}
$conf = implode('', $this->satellite_config);
}
}
break;
case 'delete':
$conf = implode('', $this->satellite_config);
// Find agent to mark for deletion.
$pattern = io_safe_expreg($values['address'].' '.$values['name']);
$re = "/add_host ($pattern)/m";
$subst = 'delete_host $1';
$conf = preg_replace($re, $subst, $conf);
if ((bool) $values['delete'] === true) {
$pos = preg_grep('/^\#INIT ignore_host/', $this->satellite_config);
if (empty($pos) === false) {
$string_hosts = 'add_host '.$values['address'].' '.$values['name']."\n";
$key_pos = 0;
foreach ($pos as $key => $value) {
$key_pos = $key;
break;
}
$array1 = array_slice($this->satellite_config, 0, $key_pos);
$array2 = array_slice($this->satellite_config, $key_pos);
// Add host to conf.
$array_merge = array_merge($array1, [$string_hosts], $array2);
$this->satellite_config = $array_merge;
// Remove delete_host.
$pattern = io_safe_expreg('delete_host '.$values['name']);
$pos = preg_grep('/'.$pattern.'/', $this->satellite_config);
$key_pos = 0;
foreach ($pos as $key => $value) {
$key_pos = $key;
break;
}
unset($this->satellite_config[$key_pos]);
$conf = implode('', $this->satellite_config);
}
} else {
// Find agent to mark for deletion.
$pattern = io_safe_expreg('add_host '.$values['address'].' '.$values['name']);
$pos = preg_grep('/'.$pattern.'/', $this->satellite_config);
if (empty($pos) === false) {
$key_pos = 0;
foreach ($pos as $key => $value) {
$key_pos = $key;
break;
}
unset($this->satellite_config[$key_pos]);
}
$string_hosts = 'delete_host '.$values['name']."\n";
$pos = preg_grep('/delete_host/', $this->satellite_config);
if (empty($pos) === false) {
$key_pos = array_keys($pos)[(count($pos) - 1)];
$array1 = array_slice($this->satellite_config, 0, ($key_pos + 1));
$array2 = array_slice($this->satellite_config, ($key_pos + 1));
$array_merge = array_merge($array1, [$string_hosts], $array2);
$this->satellite_config = $array_merge;
}
$conf = implode('', $this->satellite_config);
}
break;
default:
@ -469,11 +843,37 @@ class SatelliteAgent extends HTML
}
public function checkAddressExists($address)
{
$pos_address = preg_grep('/.*_host\s('.$address.')\s.*/', $this->satellite_config);
if (empty($pos_address) === false) {
return true;
}
return false;
}
public function checkNameExists($name)
{
$pos_name = preg_grep('/.*_host.*('.$name.')$/', $this->satellite_config);
if (empty($pos_name) === false) {
return true;
}
return false;
}
/**
* Saves agent to satellite cofiguration file.
*
* @param array $values
* @return void
* @param string $new_conf Config file.
*
* @return boolean|void
*/
private function saveAgent(string $new_conf)
{
@ -483,13 +883,13 @@ class SatelliteAgent extends HTML
return false;
}
db_pandora_audit(
AUDIT_LOG_SYSTEM,
'Update remote config for server '.$this->satellite_name
);
db_pandora_audit(
AUDIT_LOG_SYSTEM,
'Update remote config for server '.$this->satellite_name
);
// Convert to config file encoding.
$encoding = config_satellite_get_encoding($new_conf);
// Convert to config file encoding.
$encoding = config_satellite_get_encoding($new_conf);
if ($encoding !== false) {
$converted_server_config = mb_convert_encoding($new_conf, $encoding, 'UTF-8');
if ($converted_server_config !== false) {
@ -497,7 +897,7 @@ class SatelliteAgent extends HTML
}
}
// Get filenames.
// Get filenames.
if ($this->satellite_server !== false) {
$files = config_satellite_get_satellite_config_filenames($this->satellite_name);
} else {
@ -506,16 +906,40 @@ class SatelliteAgent extends HTML
$files['md5'] = $config['remote_config'].'/md5/'.md5($this->satellite_name).'.srv.md5';
}
// Save configuration
$result = file_put_contents($files['conf'], $new_conf);
// Save configuration.
$result = file_put_contents($files['conf'], $new_conf);
if ($result === false) {
return false;
}
// Save configuration md5
$result = file_put_contents($files['md5'], md5($new_conf));
// Save configuration md5.
$result = file_put_contents($files['md5'], md5($new_conf));
}
/**
* Creates add_host, ignore_host and delete_host blocks
*
* @return void
*/
public function createBlock()
{
$init = preg_grep('/^\#INIT/', $this->satellite_config);
if (empty($init) === true) {
$add_host = "#INIT add_host\n";
$ignore_host = "#INIT ignore_host\n";
$delete_host = "#INIT delete_host\n";
array_push($this->satellite_config, "\n");
array_push($this->satellite_config, $add_host);
array_push($this->satellite_config, $ignore_host);
array_push($this->satellite_config, $delete_host);
$conf = implode('', $this->satellite_config);
$this->saveAgent($conf);
}
}
@ -532,33 +956,36 @@ class SatelliteAgent extends HTML
}
/**
* Minor function to dump json message as ajax response.
*
* @param string $type Type: result || error.
* @param string $msg Message.
* @param boolean $delete Deletion messages.
*
* @return void
*/
private function ajaxMsg($type, $msg, $delete=false)
/**
* Minor function to dump json message as ajax response.
*
* @param string $type Type: result || error.
* @param string $msg Message.
* @param boolean $delete Deletion messages.
* @param boolean $disable Disable messages.
*
* @return void
*/
private function ajaxMsg($type, $msg, $delete=false, $disable=false)
{
$msg_err = 'Failed while saving: %s';
$msg_ok = 'Successfully saved agent ';
if ($delete) {
if ($delete === true) {
$msg_err = 'Failed while removing: %s';
$msg_ok = 'Successfully deleted ';
}
if ($disable === true) {
$msg_err = 'Failed while disabling: %s';
$msg_ok = 'Successfully disabled';
}
if ($type == 'error') {
echo json_encode(
[
$type => ui_print_error_message(
__(
$msg_err,
$msg
),
__($msg),
'',
true
),
@ -568,10 +995,7 @@ class SatelliteAgent extends HTML
echo json_encode(
[
$type => ui_print_success_message(
__(
$msg_ok,
$msg
),
__($msg),
'',
true
),
@ -583,6 +1007,35 @@ class SatelliteAgent extends HTML
}
/**
* Removes duplicate values from a multidimensional array
*
* @param array $array Input array.
* @param array $key Keys.
*
* @return array
*/
public function uniqueMultidimArray($array, $key)
{
$temp_array = [];
$i = 0;
$key_array_name = [];
$key_array_address = [];
foreach ($array as $val) {
if (!in_array($val[$key[0]], $key_array_name) && !in_array($val[$key[1]], $key_array_address)) {
$key_array_name[$i] = $val[$key[0]];
$key_array_address[$i] = $val[$key[1]];
$temp_array[$i] = $val;
}
$i++;
}
return $temp_array;
}
/**
* Load Javascript code.
*
@ -707,11 +1160,11 @@ class SatelliteAgent extends HTML
/**
* Delete selected agent
*/
function delete_agent(address, name) {
function delete_agent(address, name, deleted, id_agente) {
$('#aux').empty();
$('#aux').text('<?php echo __('Are you sure?'); ?>');
$('#aux').dialog({
title: '<?php echo __('Delete'); ?> ' + address,
title: (deleted == 0) ? '<?php echo __('Delete'); ?> '+address : '<?php echo __('Add'); ?>'+address,
buttons: [
{
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel',
@ -723,7 +1176,7 @@ class SatelliteAgent extends HTML
}
},
{
text: 'Delete',
text: (deleted == 0) ? 'Delete' : 'Add',
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next',
click: function(e) {
$.ajax({
@ -734,6 +1187,56 @@ class SatelliteAgent extends HTML
method: 'deleteAgent',
address: address,
name: name,
id: id_agente,
delete: deleted,
server_remote: <?php echo $this->satellite_server; ?>,
},
datatype: "json",
success: function (data) {
showMsg(data);
},
error: function(e) {
showMsg(e);
}
});
}
}
]
});
}
/**
* Disable selected agent
*/
function disable_agent(address, name, disabled, id_agente) {
$('#aux').empty();
$('#aux').text('<?php echo __('Are you sure?'); ?>');
$('#aux').dialog({
title: (disabled == 0) ? '<?php echo __('Disable'); ?>'+address : '<?php echo __('Enable'); ?>'+address,
buttons: [
{
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel',
text: '<?php echo __('Cancel'); ?>',
click: function(e) {
$(this).dialog('close');
cleanupDOM();
}
},
{
text: (disabled == 0) ? 'Disable' : 'Enable',
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next',
click: function(e) {
$.ajax({
method: 'post',
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
data: {
page: 'enterprise/godmode/servers/agents_satellite',
method: 'disableAgent',
address: address,
disable: disabled,
id: id_agente,
name: name,
server_remote: <?php echo $this->satellite_server; ?>,
},
datatype: "json",
@ -752,12 +1255,77 @@ class SatelliteAgent extends HTML
$(document).ready(function() {
$("#submit-create").on('click', function(){
$("#submit-create").on('click', function() {
show_form();
});
$("#checkbox-all_validate_box").click(function() {
const check = $("#checkbox-all_validate_box").is(":checked");
$('input[name*=check_]').prop('checked', check);
});
$('#submit-submit_satellite_action').click(function() {
const checks = $('input[name*=check_]:checked');
const action = $('#satellite_action').val();
$.each(checks, function(i, val) {
const params = val.value.split(",");
if (action === '0') {
if (params[2] === '0') {
$.ajax({
method: 'post',
async: false,
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
data: {
page: 'enterprise/godmode/servers/agents_satellite',
method: 'disableAgent',
address: params[0],
disable: params[3],
id: params[4],
name: params[1],
no_msg: 1,
server_remote: <?php echo $this->satellite_server; ?>,
},
datatype: "json",
success: function (data) {
},
error: function(e) {
console.error(e);
}
});
}
} else {
if (params[3] === '0') {
$.ajax({
method: 'post',
async: false,
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
data: {
page: 'enterprise/godmode/servers/agents_satellite',
method: 'deleteAgent',
address: params[0],
name: params[1],
id: params[4],
delete: params[2],
no_msg: 1,
server_remote: <?php echo $this->satellite_server; ?>,
},
datatype: "json",
success: function (data) {
},
error: function(e) {
console.error(e);
}
});
}
}
});
var dt_satellite_agents = $("#satellite_agents").DataTable();
dt_satellite_agents.draw();
});
});
</script>
<?php
// EOF Javascript content.

View File

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

View File

@ -57,11 +57,17 @@ function mysql_connect_db(
$port = $config['dbport'];
}
if ($ssl === null && (bool) $config['dbssl'] === true) {
if ($ssl === null
&& isset($config['dbssl']) === true
&& (bool) $config['dbssl'] === true
) {
$ssl = $config['dbsslcafile'];
}
if ($verify === null && (bool) $config['sslverifyservercert'] === true) {
if ($verify === null
&& isset($config['sslverifyservercert']) === true
&& (bool) $config['sslverifyservercert'] === true
) {
$verify = 'verified';
}

View File

@ -1007,6 +1007,30 @@ function get_parameter_post($name, $default='')
}
/**
* Get header.
*
* @param string $key Key.
* @param string|null $default Default.
*
* @return string|null
*/
function get_header(string $key, ?string $default=null): ?string
{
static $headers;
if (!isset($headers)) {
$headers = getAllHeaders();
}
$adjust_key = ucwords(strtolower($key));
if (isset($headers[$adjust_key])) {
return $headers[$adjust_key];
}
return $default;
}
/**
* Get name of a priority value.
*
@ -6217,3 +6241,31 @@ function notify_reporting_console_node()
return $return;
}
/**
* Auxiliar Ordenation function
*
* @param string $sort Direction of sort.
* @param string $sortField Field for perform the sorting.
*
* @return mixed
*/
function arrayOutputSorting($sort, $sortField)
{
return function ($a, $b) use ($sort, $sortField) {
if ($sort === 'up' || $sort === 'asc') {
if (is_string($a[$sortField]) === true) {
return strnatcasecmp($a[$sortField], $b[$sortField]);
} else {
return ($a[$sortField] - $b[$sortField]);
}
} else {
if (is_string($a[$sortField]) === true) {
return strnatcasecmp($b[$sortField], $a[$sortField]);
} else {
return ($a[$sortField] + $b[$sortField]);
}
}
};
}

View File

@ -795,7 +795,7 @@ function alerts_delete_alert_template($id_alert_template)
*
* @return mixed Array with selected alert templates or false if something goes wrong.
*/
function alerts_get_alert_templates($filter=false, $fields=false)
function alerts_get_alert_templates($filter=false, $fields=false, $total=false)
{
global $config;
@ -811,32 +811,17 @@ function alerts_get_alert_templates($filter=false, $fields=false)
$templates_sql = @db_get_all_rows_filter('talert_templates', $filter, $fields, 'AND', false, true);
switch ($config['dbtype']) {
case 'mysql':
case 'postgresql':
$limit_sql = '';
if (isset($offset) && isset($limit)) {
$limit_sql = " LIMIT $offset, $limit ";
} else {
$limit_sql = '';
}
$sql = sprintf('%s %s', $templates_sql, $limit_sql);
$alert_templates = db_get_all_rows_sql($sql);
break;
case 'oracle':
$set = [];
if (isset($offset) && isset($limit)) {
$set['limit'] = $limit;
$set['offset'] = $offset;
}
$alert_templates = oracle_recode_query($templates_sql, $set, 'AND', false);
break;
$limit_sql = '';
if (isset($offset) && isset($limit) && $total === false) {
$limit_sql = " LIMIT $offset, $limit ";
} else {
$limit_sql = '';
}
$sql = sprintf('%s %s', $templates_sql, $limit_sql);
$alert_templates = db_get_all_rows_sql($sql);
return $alert_templates;
}

View File

@ -1990,12 +1990,10 @@ function api_set_create_os($thrash1, $thrash2, $other, $thrash3)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
$values = [];
@ -2030,12 +2028,10 @@ function api_set_update_os($id_os, $thrash2, $other, $thrash3)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
$values = [];
@ -2209,8 +2205,8 @@ function api_set_delete_agent($id, $thrash1, $other, $returnType)
}
} else {
// Delete only if the centralised mode is disabled.
$headers = getallheaders();
if (isset($headers['idk']) === false && is_management_allowed($headers['idk']) === false) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
exit;
}
@ -5079,12 +5075,10 @@ function api_set_new_network_component($id, $thrash1, $other, $thrash2)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
if ($id == '') {
@ -5181,12 +5175,10 @@ function api_set_new_plugin_component($id, $thrash1, $other, $thrash2)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
if ($id == '') {
@ -5456,12 +5448,10 @@ function api_set_new_local_component($id, $thrash1, $other, $thrash2)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
if ($id == '') {
@ -5628,12 +5618,10 @@ function api_set_create_alert_template($name, $thrash1, $other, $thrash3)
{
global $config;
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
if ($name == '') {
@ -5771,12 +5759,10 @@ function api_set_update_alert_template($id_template, $thrash1, $other, $thrash3)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
if ($id_template == '') {
@ -5923,12 +5909,10 @@ function api_set_delete_alert_template($id_template, $thrash1, $other, $thrash3)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
if ($id_template == '') {
@ -7117,12 +7101,10 @@ function api_set_tag($id, $thrash1, $other, $thrash3)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
$values = [];
@ -7691,8 +7673,7 @@ function api_set_planned_downtimes_delete_agents($id, $thrash1, $other, $thrash3
}
if (!empty($other['data'][0])) {
$agents = io_safe_input($other['data']);
$agents = explode(';', $agents);
$agents = $other['data'];
$results = false;
foreach ($agents as $agent) {
if (db_get_value_sql(sprintf('SELECT id from tplanned_downtime_agents WHERE id_agent = %d AND id_downtime = %d', $agent, $id)) !== false) {
@ -7768,8 +7749,7 @@ function api_set_planned_downtimes_add_agents($id, $thrash1, $other, $thrash3)
}
if (!empty($other['data'][0])) {
$agents = io_safe_input($other['data']);
$agents = explode(';', $agents);
$agents = $other['data'];
$results = false;
foreach ($agents as $agent) {
if (db_get_value_sql(sprintf('SELECT id from tplanned_downtime_agents tpd WHERE tpd.id_agent = %d AND id_downtime = %d', $agent, $id)) === false) {
@ -7827,12 +7807,10 @@ function api_set_update_data_module_policy($id, $thrash1, $other, $thrash3)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
if ($id == '') {
@ -7947,12 +7925,10 @@ function api_set_add_network_module_policy($id, $thrash1, $other, $thrash3)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
if ($id == '') {
@ -8070,12 +8046,10 @@ function api_set_update_network_module_policy($id, $thrash1, $other, $thrash3)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
if ($id == '') {
@ -8177,12 +8151,10 @@ function api_set_add_plugin_module_policy($id, $thrash1, $other, $thrash3)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
if ($id == '') {
@ -8311,12 +8283,10 @@ function api_set_update_plugin_module_policy($id, $thrash1, $other, $thrash3)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
if ($id == '') {
@ -8607,12 +8577,10 @@ function api_set_add_snmp_module_policy($id, $thrash1, $other, $thrash3)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
if ($id == '') {
@ -8774,12 +8742,10 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
if ($id == '') {
@ -8939,12 +8905,10 @@ function api_set_remove_agent_from_policy_by_id($id, $thrash1, $other, $thrash2)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
if ($other['data'][0] == '' || !$other['data'][0]) {
@ -8980,12 +8944,10 @@ function api_set_remove_agent_from_policy_by_name($id, $thrash1, $other, $thrash
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
if ($other['data'][0] == '' || !$other['data'][0]) {
@ -9024,12 +8986,10 @@ function api_set_create_group($id, $thrash1, $other, $thrash3)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
$group_name = $id;
@ -9147,12 +9107,10 @@ function api_set_update_group($id_group, $thrash2, $other, $thrash3)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
if (db_get_value('id_grupo', 'tgrupo', 'id_grupo', $id_group) === false) {
@ -9224,12 +9182,10 @@ function api_set_delete_group($id_group, $thrash2, $other, $thrash3)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
$group = db_get_row_filter('tgrupo', ['id_grupo' => $id_group]);
@ -9541,22 +9497,22 @@ function api_set_new_user($id, $thrash2, $other, $thrash3)
{
global $config;
// if (defined ('METACONSOLE')) {
// return;
// }
if (!check_acl($config['id_user'], 0, 'UM')) {
returnError('forbidden', 'string');
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
returnError('centralized');
if (empty($id) === true) {
returnError('Id cannot be empty.');
return;
}
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
exit;
}
$values = [];
$values['fullname'] = $other['data'][0];
$values['firstname'] = $other['data'][1];
@ -9572,6 +9528,11 @@ function api_set_new_user($id, $thrash2, $other, $thrash3)
$values['section'] = $other['data'][11];
$values['session_time'] = $other['data'][12];
if (empty($password) === true) {
returnError('Password cannot be empty.');
return;
}
if (!create_user($id, $password, $values)) {
returnError('The user could not created');
} else {
@ -9607,12 +9568,10 @@ function api_set_update_user($id, $thrash2, $other, $thrash3)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
$fields_user = [
@ -9707,12 +9666,10 @@ function api_set_enable_disable_user($id, $thrash2, $other, $thrash3)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
if ($id == '') {
@ -9986,12 +9943,10 @@ function api_set_new_alert_template($id, $id2, $other, $trash1)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
if ($other['type'] == 'string') {
@ -10212,7 +10167,7 @@ function api_set_module_data($id, $thrash2, $other, $trash1)
$xmlTemplate,
io_safe_output(get_os_name($agent['id_os'])),
io_safe_output($agent['os_version']),
$agent['intervalo'],
$agentModule['module_interval'],
io_safe_output($agent['agent_version']),
date('Y/m/d H:i:s', $time),
io_safe_output($agent['nombre']),
@ -10409,12 +10364,10 @@ function api_set_alert_actions($id, $id2, $other, $trash1)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
if ($other['type'] == 'string') {
@ -10565,12 +10518,10 @@ function api_set_new_module_group($id, $thrash2, $other, $trash1)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
if (!check_acl($config['id_user'], 0, 'PM')) {
@ -10639,12 +10590,10 @@ function api_set_alert_commands($id, $thrash2, $other, $trash1)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
$name = db_get_value('id', 'talert_commands', 'name', $id);
@ -11790,22 +11739,22 @@ function api_set_delete_user($id, $thrash1, $thrash2, $thrash3)
{
global $config;
// if (defined ('METACONSOLE')) {
// return;
// }
if (!check_acl($config['id_user'], 0, 'UM')) {
returnError('forbidden', 'string');
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
returnError('centralized');
if (empty($id) === true) {
returnError('Id cannot be empty.');
return;
}
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
exit;
}
if (!delete_user($id)) {
returnError('The user could not be deleted');
} else {
@ -11841,12 +11790,10 @@ function api_set_add_user_profile($id, $thrash1, $other, $thrash2)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
$group = (int) $other['data'][0];
@ -11902,12 +11849,10 @@ function api_set_delete_user_profile($id, $thrash1, $other, $thrash2)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
$group = $other['data'][0];
@ -12017,12 +11962,10 @@ function api_set_create_user_profile_info($thrash1, $thrash2, $other, $returnTyp
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
$values = [
@ -12078,12 +12021,10 @@ function api_set_update_user_profile_info($id_profile, $thrash1, $other, $return
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
$profile = db_get_row('tperfil', 'id_perfil', $id_profile);
@ -12145,12 +12086,10 @@ function api_set_delete_user_profile_info($id_profile, $thrash1, $thrash2, $retu
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
$profile = db_get_value('id_perfil', 'tperfil', 'id_perfil', $id_profile);
@ -13037,12 +12976,10 @@ function api_set_create_tag($id, $trash1, $other, $returnType)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
$data = [];
@ -13368,12 +13305,6 @@ function api_set_add_event_comment($id, $thrash2, $other, $thrash3)
{
global $config;
if (defined('METACONSOLE')) {
$meta = true;
} else {
$meta = $other['data'][1];
}
if (!check_acl($config['id_user'], 0, 'EW')) {
returnError('forbidden', 'string');
return;
@ -13384,13 +13315,46 @@ function api_set_add_event_comment($id, $thrash2, $other, $thrash3)
return;
} else if ($other['type'] == 'array') {
$comment = $other['data'][0];
$history = $other['data'][2];
$status = events_comment(
$id,
$comment,
'Added comment'
);
$node_int = 0;
if (is_metaconsole() === true) {
if (isset($other['data'][1]) === true
&& empty($other['data'][1]) === false
) {
$node_int = $other['data'][1];
}
}
try {
if (is_metaconsole() === true
&& (int) $node_int > 0
) {
$node = new Node($node_int);
$node->connect();
}
$status = events_comment(
$id,
$comment,
'Added comment'
);
} catch (\Exception $e) {
// Unexistent agent.
if (is_metaconsole() === true
&& $node_int > 0
) {
$node->disconnect();
}
$status = false;
} finally {
if (is_metaconsole() === true
&& $node_int > 0
) {
$node->disconnect();
}
}
if (is_error($status)) {
returnError(
'The event comment could not be added.'
@ -17130,12 +17094,10 @@ function api_set_delete_user_permission($thrash1, $thrash2, $other, $returnType)
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
if ($other['data'][0] != '') {
@ -17191,12 +17153,10 @@ function api_set_add_permission_user_to_group($thrash1, $thrash2, $other, $retur
return;
}
$headers = getallheaders();
if (isset($headers['idk']) === false
&& is_management_allowed($headers['idk']) === false
) {
$idk = get_header('idk');
if (is_management_allowed($idk) === false) {
returnError('centralized');
return;
exit;
}
$sql = 'SELECT id_up
@ -17554,9 +17514,11 @@ function api_set_enable_disable_discovery_task($id_task, $thrash2, $other)
}
}
/**
* Make report (PDF, CSV or XML) and send it via e-mail (this method is intended to be used by server's execution
* of alert actions that involve sending reports by e-mail).
*
* @param [string] $server_id id server (Node)
* @param [string] $console_event_id console Id node event in tevent
* @param [string] $trash2 don't use
@ -17603,15 +17565,12 @@ function api_set_send_report($thrash1, $thrash2, $other, $returnType)
$date_today = preg_split('/[\s,]+/', io_safe_output($date_today));
$date_today = __($date_today[0]).' '.$date_today[1].' '.$date_today[2].' '.$date_today[3].' '.$date_today[4];
if ($make_report_from_template === true) {
$filter['id_report'] = $id_item;
$template = reports_get_report_templates(
$filter,
[
'description'
],
['description'],
$return_all_group,
'RR'
)[0];
@ -17619,15 +17578,16 @@ function api_set_send_report($thrash1, $thrash2, $other, $returnType)
$description = $template['description'];
// Report macros post-process.
$body_email = str_replace([
$body_email = str_replace(
[
'_report_description_',
'_report_generated_date_',
'_report_date_'
'_report_date_',
],
[
$description,
$date_today,
$date_today
$date_today,
],
$body_email
);
@ -17641,7 +17601,7 @@ function api_set_send_report($thrash1, $thrash2, $other, $returnType)
$template_regex_agents,
false,
'',
$email,
$email,
$subject_email,
$body_email,
$report_type,
@ -17656,15 +17616,16 @@ function api_set_send_report($thrash1, $thrash2, $other, $returnType)
}
// Report macros post-process.
$body_email = str_replace([
$body_email = str_replace(
[
'_report_description_',
'_report_generated_date_',
'_report_date_'
'_report_date_',
],
[
$report['description'],
$date_today,
$date_today
$date_today,
],
$body_email
);
@ -17851,4 +17812,3 @@ function api_set_send_report($thrash1, $thrash2, $other, $returnType)
returnData($returnType, $data, ';');
}
}

View File

@ -467,7 +467,7 @@ function config_update_config()
break;
case 'pass':
if (isset($config['enterprise_installed']) === true && (bool) $config['enterprise_installed'] === 1) {
if (isset($config['enterprise_installed']) === true && (bool) $config['enterprise_installed'] === true) {
if (config_update_value('enable_pass_policy', get_parameter('enable_pass_policy'), true) === false) {
$error_update[] = __('Enable password policy');
}
@ -784,14 +784,7 @@ function config_update_config()
case 'perf':
// PERFORMANCE SETUP.
if (config_update_value('event_purge', get_parameter('event_purge'), true) === false) {
$check_metaconsole_events_history = get_parameter('metaconsole_events_history', -1);
$error_update[] = $check_metaconsole_events_history;
}
if ($check_metaconsole_events_history != -1) {
if (config_update_value('metaconsole_events_history', get_parameter('metaconsole_events_history'), true) === false) {
$error_update[] = __('Max. days before delete events');
}
$error_update[] = __('Event purge');
}
if (config_update_value('trap_purge', get_parameter('trap_purge'), true) === false) {
@ -2107,10 +2100,6 @@ function config_process_config()
config_update_value('event_purge', 15);
}
if (!isset($config['metaconsole_events_history'])) {
config_update_value('metaconsole_events_history', 0);
}
if (!isset($config['realtimestats'])) {
config_update_value('realtimestats', 1);
}

View File

@ -1385,7 +1385,7 @@ function events_get_all(
// Pagination.
$pagination = '';
if (is_metaconsole() === true
&& empty($id_server) === true
&& (empty($id_server) === true || is_array($id_server) === true)
&& isset($filter['csv_all']) === false
) {
// TODO: XXX TIP. captura el error.
@ -1476,7 +1476,6 @@ function events_get_all(
// Secondary groups.
$event_lj = '';
if (!$user_is_admin || ($user_is_admin && isset($groups) === true && $groups > 0)) {
db_process_sql('SET group_concat_max_len = 9999999');
if ((bool) $filter['search_secondary_groups'] === true) {
$event_lj = events_get_secondary_groups_left_join($table);
}
@ -1490,6 +1489,8 @@ function events_get_all(
unset($fields[$idx]);
}
db_process_sql('SET group_concat_max_len = 9999999');
$group_selects = sprintf(
',COUNT(id_evento) AS event_rep,
%s
@ -1660,7 +1661,9 @@ function events_get_all(
if ($count === true
&& (is_metaconsole() === false
|| (is_metaconsole() === true && empty($filter['server_id']) === false))
|| (is_metaconsole() === true
&& empty($filter['server_id']) === false
&& is_array($filter['server_id']) === false))
) {
$sql = 'SELECT count(*) as nitems FROM ('.$sql.') tt';
}
@ -1676,14 +1679,27 @@ function events_get_all(
$metaconsole_connections = array_flip($metaconsole_connections);
$metaconsole_connections['meta'] = 0;
} else {
$only_id_server[$metaconsole_connections[$id_server]] = $id_server;
$metaconsole_connections = $only_id_server;
if (is_array($id_server) === false) {
$only_id_server[$metaconsole_connections[$id_server]] = $id_server;
$metaconsole_connections = $only_id_server;
} else {
$metaConnections = [];
foreach ($id_server as $idser) {
if ((int) $idser === 0) {
$metaConnections['meta'] = 0;
} else {
$metaConnections[$metaconsole_connections[$idser]] = $idser;
}
}
$metaconsole_connections = $metaConnections;
}
}
$result_meta = Promise\wait(
parallelMap(
$metaconsole_connections,
function ($node_int) use ($sql) {
function ($node_int) use ($sql, $history) {
try {
if (is_metaconsole() === true
&& (int) $node_int > 0
@ -1692,7 +1708,7 @@ function events_get_all(
$node->connect();
}
$res = db_get_all_rows_sql($sql);
$res = db_get_all_rows_sql($sql, $history);
if ($res === false) {
$res = [];
}
@ -1751,7 +1767,7 @@ function events_get_all(
}
}
if (empty($filter['server_id']) === true) {
if ($count === false) {
if ($sort_field !== 'agent_name'
&& $sort_field !== 'server_name'
&& $sort_field !== 'timestamp'
@ -1823,7 +1839,7 @@ function events_get_all(
}
}
return db_get_all_rows_sql($sql);
return db_get_all_rows_sql($sql, $history);
}
@ -3498,7 +3514,7 @@ function events_page_responses($event)
__('Execute'),
'custom_response_button',
false,
'execute_response('.$event['id_evento'].','.$server_id.')',
'execute_response('.$event['id_evento'].','.$server_id.',0)',
"class='sub next w70p'",
true
);
@ -3509,27 +3525,15 @@ function events_page_responses($event)
$responses_js = "<script>
$('#select_custom_response').change(function() {
var id_response = $('#select_custom_response').val();
var params = get_response_params(id_response);
var description = get_response_description(id_response);
$('.params_rows').remove();
$('#responses_table')
.append('<tr class=\"params_rows\"><td>".__('Description')."</td><td class=\"height_30px\" colspan=\"2\">'+description+'</td></tr>');
if (params.length == 1 && params[0] == '') {
return;
}
$('#responses_table')
.append('<tr class=\"params_rows\"><td class=\"left pdd_l_20px height_30px\" colspan=\"3\">".__('Parameters')."</td></tr>');
for (i = 0; i < params.length; i++) {
add_row_param('responses_table',params[i]);
}
table_info_response_event(id_response,".$event['id_evento'].','.$event['server_id'].");
});
$('#select_custom_response').trigger('change');
</script>";
$responses = '<div id="extended_event_responses_page" class="extended_event_pages">'.html_print_table($table_responses, true).$responses_js.'</div>';
$responses = '<div id="extended_event_responses_page" class="extended_event_pages">';
$responses .= html_print_table($table_responses, true);
$responses .= $responses_js;
$responses .= '</div>';
return $responses;
}
@ -3538,14 +3542,20 @@ function events_page_responses($event)
/**
* Replace macros in the target of a response and return it.
*
* @param integer $event_id Event identifier.
* @param integer $response_id Event response identifier.
* @param integer $event_id Event identifier.
* @param array $event_response Event Response.
* @param array|null $response_parameters If parameters response values.
* @param integer|null $server_id Server Id.
* @param string|null $server_name Name server.
*
* @return string The response text with the macros applied.
*/
function events_get_response_target(
int $event_id,
int $response_id
array $event_response,
?array $response_parameters=null,
?int $server_id=0,
?string $server_name=''
) {
global $config;
@ -3558,9 +3568,36 @@ function events_get_response_target(
}
$event = db_get_row('tevento', 'id_evento', $event_id);
$event_response = db_get_row('tevent_response', 'id', $response_id);
$target = io_safe_output($event_response['target']);
// Replace parameters response.
if (isset($response_parameters) === true
&& empty($response_parameters) === false
) {
$response_parameters = array_reduce(
$response_parameters,
function ($carry, $item) {
$carry[$item['name']] = $item['value'];
return $carry;
}
);
}
if (empty($event_response['params']) === false) {
$response_params = explode(',', $event_response['params']);
if (is_array($response_params) === true) {
foreach ($response_params as $param) {
$param = trim(io_safe_output($param));
$target = str_replace(
'_'.$param.'_',
$response_parameters['values_params_'.$param],
$target
);
}
}
}
// Replace macros.
if (strpos($target, '_agent_alias_') !== false) {
$agente_table_name = 'tagente';
$filter = ['id_agente' => $event['id_agente']];
@ -3886,6 +3923,26 @@ function events_get_response_target(
);
}
if (is_metaconsole() === true
&& strpos($target, '_node_id_') !== false
) {
$target = str_replace(
'_node_id_',
$server_id,
$target
);
}
if (is_metaconsole() === true
&& strpos($target, '_node_name_') !== false
) {
$target = str_replace(
'_node_name_',
$server_name,
$target
);
}
return $target;
}
@ -5532,3 +5589,114 @@ function events_get_criticity_class($criticity)
return 'datos_blue';
}
}
/**
* Draw row response events.
*
* @param array $event_response Response.
* @param integer|null $response_id Id .
* @param boolean $end End block.
* @param integer|null $index Index block.
*
* @return string Html output.
*/
function get_row_response_action(
array $event_response,
?int $response_id,
$end=false,
$index=null
) {
$output = '<div class="container-massive-events-response-cell">';
$display_command = (bool) $event_response['display_command'];
$command_str = ($display_command === true) ? $event_response['target'] : '';
// String command.
$output .= '<div class="container-massive-events-response-command">';
$output .= '<b>';
$output .= __('Event # %d', $event_response['event_id']);
if (empty($command_str) === false) {
$output .= ' ';
$output .= __('Executing command: ');
}
$output .= '</b>';
$output .= '<span>'.$command_str.'</span>';
$output .= '</div>';
// Spinner.
$output .= '<div id="response_loading_command'.$index.'" style="display:none">';
$output .= html_print_image(
'images/spinner.gif',
true
);
$output .= '</div>';
// Output.
$output .= '<div id="response_out'.$index.'" class="container-massive-events-response-output"></div>';
// Butom.
$output .= '<div id="re_exec_command'.$index.'" style="display:none" class="container-massive-events-response-execute">';
$output .= html_print_button(
__('Execute again'),
'btn_str',
false,
'perform_response(\''.base64_encode(json_encode($event_response)).'\','.$response_id.',\''.trim($index).'\')',
"class='sub next'",
true
);
$output .= '</div>';
$output .= '</div>';
return $output;
}
/**
* Get evet get response target.
*
* @param integer $event_id Id event.
* @param array $event_response Response.
* @param integer $server_id Server id.
*
* @return string
*/
function get_events_get_response_target(
$event_id,
$event_response,
$server_id=0,
$response_parameters=[]
) {
try {
if (is_metaconsole() === true
&& $server_id > 0
) {
$node = new Node($server_id);
$node->connect();
}
return events_get_response_target(
$event_id,
$event_response,
$response_parameters,
$server_id,
($server_id !== 0) ? $node->server_name() : 'Metaconsole'
);
} catch (\Exception $e) {
// Unexistent agent.
if (is_metaconsole() === true
&& $server_id > 0
) {
$node->disconnect();
}
return '';
} finally {
if (is_metaconsole() === true
&& $server_id > 0
) {
$node->disconnect();
}
}
}

View File

@ -1664,44 +1664,31 @@ function html_print_select_multiple_modules_filtered(array $data):string
]
);
// Show common modules.
$selection = [
0 => __('Show common modules'),
1 => __('Show all modules'),
];
if (true) {
$output .= html_print_input(
[
'label' => __('Only common modules'),
'type' => 'switch',
'value' => 'checked',
'id' => 'filtered-module-show-common-modules-'.$uniqId,
'return' => true,
'onchange' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')',
]
);
} else {
$output .= html_print_input(
[
'label' => __('Show common modules'),
'type' => 'select',
'fields' => $selection,
'name' => 'filtered-module-show-common-modules-'.$uniqId,
'return' => true,
'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')',
]
);
$commonModules = 0;
if (empty($data['mShowCommonModules']) === false) {
$commonModules = 1;
}
$output .= html_print_input(
[
'label' => __('Only common modules'),
'type' => 'switch',
'checked' => $commonModules,
'value' => $commonModules,
'name' => 'filtered-module-show-common-modules-'.$uniqId,
'id' => 'filtered-module-show-common-modules-'.$uniqId,
'return' => true,
'onchange' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')',
]
);
if (empty($data['mAgents']) === false
&& empty($data['mModuleGroup'] === false)
) {
$all_modules = get_modules_agents(
$data['mModuleGroup'],
explode(',', $data['mAgents']),
$data['mShowCommonModules'],
!$commonModules,
false,
true
);
@ -1709,10 +1696,18 @@ function html_print_select_multiple_modules_filtered(array $data):string
$all_modules = [];
}
$mModules = $data['mModules'];
if (is_array($data['mModules']) === false) {
$result = explode(((is_metaconsole() === true) ? SEPARATOR_META_MODULE : ','), $data['mModules']);
} else {
$result = $data['mModules'];
$mModules = explode(
',',
$data['mModules']
);
}
$result = [];
// Clean double safe input.
foreach ($mModules as $name) {
$result[] = io_safe_output($name);
}
$output .= html_print_input(
@ -2075,7 +2070,7 @@ function html_print_extended_select_for_time(
$custom_fields=false,
$style_icon='',
$no_change=false,
$allow_zero=false
$allow_zero=0
) {
global $config;
$admin = is_user_admin($config['id_user']);
@ -2089,32 +2084,21 @@ function html_print_extended_select_for_time(
$fields['-2'] = __('No change');
}
if (! $selected) {
foreach ($fields as $t_key => $t_value) {
if ($t_key != -1) {
if ($nothing == '') {
// -1 means 'custom'
$selected = $t_key;
break;
} else {
$selected = $nothing;
break;
}
}
}
}
// Allow the use of the value zero.
if ($allow_zero === true) {
$selected_zero = true;
} else {
$selected_zero = ($selected != 0) ? true : false;
}
if (($selected !== false) && (!isset($fields[$selected]) && $selected_zero)) {
if (empty($selected) === false
&& $selected !== '0'
&& isset($fields[$selected]) === false
) {
$allow_zero = false;
$fields[$selected] = human_time_description_raw($selected, true);
}
if (empty($nothing) === true
&& (empty($selected) === true
|| $selected === '0')
) {
$selected = 300;
}
$units = [
1 => __('seconds'),
SECONDS_1MINUTE => __('minutes'),
@ -2180,14 +2164,23 @@ function html_print_extended_select_for_time(
$uniq_name.'_units',
'1',
''.$script,
$nothing,
$nothing_value,
'',
0,
false,
false,
false,
$class,
$readonly,
'font-size: xx-small;'.$select_style
'padding: 7px 3px;'.$select_style,
false,
false,
false,
'',
false,
false,
false,
false,
false
);
echo ' <a href="javascript:">'.html_print_image(
'images/list.png',
@ -2202,7 +2195,7 @@ function html_print_extended_select_for_time(
echo '</div>';
echo "<script type='text/javascript'>
$(document).ready (function () {
period_select_init('".$uniq_name."', ".(($allow_zero) ? 'true' : 'null').");
period_select_init('".$uniq_name."', ".(($allow_zero) ? 1 : 0).");
period_select_events('".$uniq_name."');
});
function period_select_".$name."_update(seconds) {
@ -4956,7 +4949,7 @@ function html_print_input($data, $wrapper='div', $input_only=false)
$output = '';
if (($data['label'] ?? false) && $input_only === false) {
$output = '<'.$wrapper.' id="'.$wrapper.'-'.$data['name'].'" ';
$output = '<'.$wrapper.' id="'.$wrapper.'-'.($data['name'] ?? '').'" ';
$output .= ' class="'.($data['input_class'] ?? '').'">';
$output .= '<label '.$style.' class="'.($data['label_class'] ?? '').'">';
$output .= ($data['label'] ?? '');
@ -4977,7 +4970,7 @@ function html_print_input($data, $wrapper='div', $input_only=false)
if (isset($data['wrapper']) === true) {
$output = '<'.$data['wrapper'].' '.$wrapper_attributes.' id="wr_'.$data['name'].'" ';
$output .= ' class="'.$data['input_class'].'">';
$output .= ' class="'.($data['input_class'] ?? '').'">';
}
switch (($data['type'] ?? null)) {
@ -5097,7 +5090,7 @@ function html_print_input($data, $wrapper='div', $input_only=false)
$output .= html_print_input_color(
$data['name'],
$data['value'],
$data['id'],
($data['id'] ?? ''),
((isset($data['class']) === true) ? $data['class'] : false),
((isset($data['return']) === true) ? $data['return'] : false)
);

View File

@ -3656,7 +3656,7 @@ function get_modules_agents($id_module_group, $id_agents, $selection, $select_mo
$id_agents,
$selection,
false,
false,
$useName,
true
);
@ -3684,8 +3684,8 @@ function get_modules_agents($id_module_group, $id_agents, $selection, $select_mo
if ($occurrences === $nodes_consulted) {
// Module already present in ALL nodes.
$modules[] = [
'id_agente_modulo' => $module_name,
'nombre' => $module_name,
'id_agente_modulo' => io_safe_output($module_name),
'nombre' => io_safe_output($module_name),
];
}
}
@ -3730,7 +3730,7 @@ function get_modules_agents($id_module_group, $id_agents, $selection, $select_mo
function ($carry, $item) use ($useName) {
// Only works in select mode.
if ($useName === true) {
$carry[io_safe_input($item['nombre'])] = $item['nombre'];
$carry[$item['id_node'].'|'.$item['nombre']] = $item['nombre'];
} else {
$carry[$item['id_node'].'|'.$item['id_agente_modulo']] = $item['nombre'];
}
@ -3744,6 +3744,8 @@ function get_modules_agents($id_module_group, $id_agents, $selection, $select_mo
$id_module_group,
$id_agents,
$selection,
false,
$useName,
false
);
}
@ -4191,6 +4193,11 @@ function modules_get_counter_by_states($state)
function modules_get_state_condition($state, $prefix='tae')
{
// Not use empty state 0 -> AGENT_MODULE_STATUS_NORMAL.
if ($state === '') {
return '1=1';
}
switch ($state) {
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
case AGENT_MODULE_STATUS_CRITICAL_BAD:

View File

@ -2702,7 +2702,7 @@ function networkmap_clean_duplicate_links($id)
{
global $config;
$sql_duplicate_links = 'SELECT id, id_parent, id_child
$sql_duplicate_links = 'SELECT *
FROM trel_item t1
WHERE t1.deleted = 0 AND t1.id_child IN (
SELECT t2.id_child
@ -2712,7 +2712,7 @@ function networkmap_clean_duplicate_links($id)
AND t1.id_parent = t2.id_parent
AND t2.id_map = '.$id.')
AND t1.id_map = '.$id.'
ORDER BY id_parent, id_child';
ORDER BY id_parent, id_child, id_parent_source_data desc, id_child_source_data desc';
$rows = db_get_all_rows_sql($sql_duplicate_links);
if (empty($rows) === true) {
@ -2721,28 +2721,49 @@ function networkmap_clean_duplicate_links($id)
$pre_parent = -1;
$pre_child = -1;
$pre_parent_source = -1;
$pre_child_source = -1;
foreach ($rows as $row) {
if (($pre_parent === (int) $row['id_parent'])
&& ($pre_child === (int) $row['id_child'])
) {
// Delete the duplicate row.
db_process_sql_delete(
'trel_item',
['id' => $row['id']]
);
// Agent <-> Agent.
if ((int) $row['parent_type'] === 0 && (int) $row['child_type'] === 0) {
// Delete the duplicate row.
db_process_sql_delete(
'trel_item',
['id' => $row['id']]
);
} else {
// Agent <-> Module or Module <-> Agent or Module <-> Module.
if ($pre_parent_source === (int) $row['id_parent_source_data']
&& $pre_child_source === (int) $row['id_child_source_data']
) {
// Delete the duplicate row.
db_process_sql_delete(
'trel_item',
['id' => $row['id']]
);
} else {
$pre_parent_source = (int) $row['id_parent_source_data'];
$pre_child_source = (int) $row['id_child_source_data'];
}
}
} else {
$pre_parent = $row['id_parent'];
$pre_child = $row['id_child'];
$pre_parent = (int) $row['id_parent'];
$pre_child = (int) $row['id_child'];
if ((int) $row['parent_type'] === 1 || (int) $row['child_type'] === 1) {
$pre_parent_source = (int) $row['id_parent_source_data'];
$pre_child_source = (int) $row['id_child_source_data'];
}
}
}
db_process_sql($sql_duplicate_links);
do {
db_clean_cache();
$sql_duplicate_links_parent_as_children = '
SELECT id, id_parent, id_child
SELECT *
FROM trel_item t1
WHERE t1.deleted = 0 AND t1.id_child IN (
SELECT t2.id_parent
@ -2765,14 +2786,51 @@ function networkmap_clean_duplicate_links($id)
if (($row['id'] != $row2['id'])
&& ($row['id_child'] == $row2['id_parent'])
&& ($row['id_parent'] == $row2['id_child'])
&& ($row['parent_type'] == $row2['child_type'])
&& ($row['child_type'] == $row2['parent_type'])
) {
db_process_sql_delete(
'trel_item',
['id' => $row2['id']]
);
// Agent <-> Agent.
if ((int) $row2['parent_type'] === 0 && (int) $row2['child_type'] === 0) {
db_process_sql_delete(
'trel_item',
['id' => $row2['id']]
);
$found = true;
break;
$found = true;
break;
} else {
// Agent <-> Module or Module <-> Agent or Module <-> Module.
if ((int) $row['id_child_source_data'] === (int) $row2['id_parent_source_data']
&& (int) $row['id_parent_source_data'] === (int) $row2['id_child_source_data']
) {
db_process_sql_delete(
'trel_item',
['id' => $row2['id']]
);
$found = true;
break;
}
}
} else {
// Si no son del mismo tipo pero hay un parent_type = 0 y child_type = 0 borrar.
if ((int) $row['parent_type'] === 0 && (int) $row['child_type'] === 0) {
db_process_sql_delete(
'trel_item',
['id' => $row['id']]
);
$found = true;
break;
} else if ((int) $row2['parent_type'] === 0 && (int) $row2['child_type'] === 0) {
db_process_sql_delete(
'trel_item',
['id' => $row2['id']]
);
$found = true;
break;
}
}
}
@ -3020,53 +3078,96 @@ function networkmap_delete_link(
function erase_node($id)
{
$node = db_get_row('titem', 'id', $id['id']);
if ($node['type'] !== '2') {
$return = db_process_sql_update(
'titem',
['deleted' => 1],
[
'id' => (int) $node['id'],
'id_map' => (int) $node['id_map'],
]
);
$return = db_process_sql_update(
'titem',
['deleted' => 1],
['id' => $node['id']]
);
db_process_sql_update(
'trel_item',
['deleted' => 1],
[
'id_parent' => (int) $node['id'],
'id_map' => (int) $node['id_map'],
]
);
db_process_sql_update(
'trel_item',
['deleted' => 1],
['id_parent' => (int) $node['id']]
);
db_process_sql_update(
'trel_item',
['deleted' => 1],
[
'id_child' => (int) $node['id'],
'id_map' => (int) $node['id_map'],
]
);
db_process_sql_update(
'trel_item',
['deleted' => 1],
['id_child' => (int) $node['id']]
);
$node_modules = db_get_all_rows_filter(
'titem',
[
'id_map' => $node['id_map'],
'type' => 1,
]
);
$node_modules = db_get_all_rows_filter(
'titem',
[
'id_map' => $node['id_map'],
'type' => 1,
]
);
foreach ($node_modules as $node_module) {
$style = json_decode($node_module['style'], true);
foreach ($node_modules as $node_module) {
$style = json_decode($node_module['style'], true);
if ($style['id_agent'] == $node['source_data']) {
db_process_sql_update(
'titem',
['deleted' => 1],
['id' => $node_module['id']]
);
db_process_sql_update(
'trel_item',
['deleted' => 1],
['id_parent_source_data' => (int) $node_module['source_data']]
);
db_process_sql_update(
'trel_item',
['deleted' => 1],
['id_child_source_data' => (int) $node_module['source_data']]
);
if ($style['id_agent'] == $node['source_data']) {
db_process_sql_update(
'titem',
['deleted' => 1],
[
'id' => (int) $node_module['id'],
'id_map' => (int) $node_module['id_map'],
]
);
db_process_sql_update(
'trel_item',
['deleted' => 1],
[
'id_parent_source_data' => (int) $node_module['source_data'],
'id_map' => (int) $node_module['id_map'],
]
);
db_process_sql_update(
'trel_item',
['deleted' => 1],
[
'id_child_source_data' => (int) $node_module['source_data'],
'id_map' => (int) $node_module['id_map'],
]
);
}
}
} else {
$return = db_process_sql_delete(
'titem',
[
'id' => (int) $node['id'],
'id_map' => (int) $node['id_map'],
]
);
db_process_sql_delete(
'trel_item',
[
'parent_type' => 2,
'id_map' => (int) $node['id_map'],
]
);
db_process_sql_delete(
'trel_item',
[
'child_type' => 2,
'id_map' => (int) $node['id_map'],
]
);
}
if ($return === false) {
@ -3504,6 +3605,7 @@ function update_node($node, $holding_area_x, $holding_area_y)
$values = [];
$values['x'] = $node['x'];
$values['y'] = $node['y'];
$values['refresh'] = 0;
if ($node['state'] === 'holding_area') {
$networkmap_node = db_get_row_filter(
@ -3526,14 +3628,9 @@ function update_node($node, $holding_area_x, $holding_area_y)
) {
// Inside holding area.
$return['state'] = 'holding_area';
$values['refresh'] = 1;
} else {
// The user move the node out the holding area.
db_process_sql_update(
'titem',
['refresh' => 0],
['id' => $node['id_db']]
);
$return['state'] = '';
}
}
@ -4053,6 +4150,7 @@ function add_agent_node_in_option($id_networkmap, $id_agent, $x, $y)
function networkmap_get_new_nodes_and_links($networkmap, $x, $y)
{
$id_networkmap = $networkmap['id'];
$id_recon = $networkmap['source_data'];
$map_filter = $networkmap['filter'];
if (is_array($map_filter) === false) {
@ -4060,11 +4158,11 @@ function networkmap_get_new_nodes_and_links($networkmap, $x, $y)
}
if ((int) $networkmap['source'] === SOURCE_TASK) {
$agents = get_discovery_agents($networkmap, true);
$agents = get_discovery_agents($id_recon, true);
} else if ((int) $networkmap['source'] === SOURCE_NETWORK) {
// Network map, based on direct network.
$agents = networkmap_get_nodes_from_ip_mask(
$networkmap['source_data'],
$id_recon,
true
);
} else {
@ -4274,290 +4372,291 @@ function networkmap_get_new_nodes_and_links($networkmap, $x, $y)
}
}
// Get L2 interface relations.
$interfaces = modules_get_interfaces(
$node['source_data'],
// foreach ($interfaces as $interface) {
// $relations = modules_get_relations(
// ['id_module' => $interface['id_agente_modulo']]
// );
// if (empty($relations) === true) {
// $relations = [];
// }
// foreach ($relations as $relation) {
// Get the links althought they are deleted (for to
// avoid to add)
// Check if the module is ping.
// if (modules_get_agentmodule_type($relation['module_a']) === '6') {
// The pings modules are not exist as interface
// the link is with the agent.
// $node_a = db_get_value_filter(
// 'id',
// 'titem',
// [
// 'source_data' => modules_get_agentmodule_agent(
// $relation['module_a']
// ),
// 'id_map' => $id_networkmap,
// ]
// );
// } else {
// $node_a = db_get_value_filter(
// 'id',
// 'titem',
// [
// 'source_data' => $relation['module_a'],
// 'type' => 1,
// 'id_map' => $id_networkmap,
// ]
// );
// }
// Check if the module is ping.
// if (modules_get_agentmodule_type($relation['module_b']) == 6) {
// The pings modules are not exist as interface
// the link is with the agent.
// $node_b = db_get_value_filter(
// 'id',
// 'titem',
// [
// 'source_data' => modules_get_agentmodule_agent(
// $relation['module_b']
// ),
// 'id_map' => $id_networkmap,
// ]
// );
// } else {
// $node_b = db_get_value_filter(
// 'id',
// 'titem',
// [
// 'source_data' => $relation['module_b'],
// 'type' => 1,
// 'id_map' => $id_networkmap,
// ]
// );
// }
// $exist = db_get_row_filter(
// 'trel_item',
// [
// 'id_map' => $id_networkmap,
// 'id_parent_source_data' => $relation['module_a'],
// 'id_child_source_data' => $relation['module_b'],
// 'deleted' => 0,
// ]
// );
// $exist_reverse = db_get_row_filter(
// 'trel_item',
// [
// 'id_map' => $id_networkmap,
// 'id_parent_source_data' => $relation['module_b'],
// 'id_child_source_data' => $relation['module_a'],
// 'deleted' => 0,
// ]
// );
// if (empty($exist) && empty($exist_reverse)) {
// Create the nodes for interfaces
// Ag1 ----- I1 ------ I2 ----- Ag2
// * 2 interfaces nodes
// * 3 relations
// * I1 between I2
// * Ag1 between I1
// * Ag2 between I2
//
// But check if it exists the relations
// agent between interface.
// if ($interface['id_agente_modulo'] == $relation['module_a']) {
// $agent_a = $interface['id_agente'];
// $agent_b = modules_get_agentmodule_agent(
// $relation['module_b']
// );
// } else {
// $agent_a = modules_get_agentmodule_agent(
// $relation['module_a']
// );
// $agent_b = $interface['id_agente'];
// }
// $item_a = db_get_value(
// 'id',
// 'titem',
// 'source_data',
// $agent_a
// );
// $item_b = db_get_value(
// 'id',
// 'titem',
// 'source_data',
// $agent_b
// );
// hd('----------------------', true);
// hd($agent_a, true);
// hd($agent_b, true);
// foreach ($interfaces as $interface) {
// $relations = modules_get_relations(
// ['id_module' => $interface['id_agente_modulo']]
// );
// if (empty($relations) === true) {
// $relations = [];
// }
// foreach ($relations as $relation) {hd($item_a. '<->'. $item_b, true);
// hd('----------------------', true);
// continue;
// $exist_node_interface1 = db_get_row_filter(
// 'titem',
// [
// 'id_map' => $id_networkmap,
// 'type' => 0,
// 'source_data' => $relation['module_a'],
// ]
// );
// if (empty($exist_node_interface1) === true) {
// Crete the interface node
// and create the relation between agent and
// interface.
// $style = [];
// $style['id_agent'] = $agent_a;
// $style['shape'] = 'circle';
// $style['image'] = 'images/mod_snmp_proc.png';
// $style['width'] = 50;
// $style['height'] = 16;
// $style['label'] = modules_get_agentmodule_name($relation['module_a']);
// $id_int1 = db_process_sql_insert(
// 'titem',
// [
// 'id_map' => $id_networkmap,
// 'x' => 666,
// 'y' => 666,
// 'z' => 0,
// 'deleted' => 0,
// 'type' => 1,
// 'refresh' => 0,
// 'source' => 0,
// 'source_data' => $relation['module_a'],
// 'style' => json_encode($style),
// ]
// );
// $node_interface1 = db_get_row_filter(
// 'titem',
// [
// 'id_map' => $id_networkmap,
// 'type' => 1,
// 'id' => $id_int1,
// ]
// );
// $node_agent1 = db_get_value(
// 'id',
// 'titem',
// 'source_data',
// $agent_a
// );
// db_process_sql_insert(
// 'trel_item',
// [
// 'id_map' => $id_networkmap,
// 'id_parent' => $node_agent1,
// 'id_child' => $node_interface1,
// 'id_parent-source_data' => $agent_a,
// 'id_child-source_data' => $relation['module_a'],
// 'parent_type' => 0,
// 'child_type' => 1,
// ]
// );
// } else {
// $node_interface1 = $exist_node_interface1;
// }
// $exist_node_interface2 = db_get_row_filter(
// 'titem',
// [
// 'id_map' => $id_networkmap,
// 'type' => 1,
// 'source_data' => $relation['module_b'],
// ]
// );
// if (empty($exist_node_interface2) === true) {
// Crete the interface node
// and create the relation between agent and
// interface.
// $style = [];
// $style['id_agent'] = $agent_a;
// $style['shape'] = 'circle';
// $style['image'] = 'images/mod_snmp_proc.png';
// $style['width'] = 50;
// $style['height'] = 16;
// $style['label'] = modules_get_agentmodule_name($relation['module_b']);
// $id_int2 = db_process_sql_insert(
// 'titem',
// [
// 'id_map' => $id_networkmap,
// 'x' => 666,
// 'y' => 666,
// 'z' => 0,
// 'deleted' => 0,
// 'type' => 1,
// 'refresh' => 0,
// 'source' => 0,
// 'source_data' => $relation['module_b'],
// 'style' => json_encode($style),
// ]
// );
// $node_interface2 = db_get_row_filter(
// 'titem',
// [
// 'id_map' => $id_networkmap,
// 'type' => 1,
// 'id' => $id_int1,
// ]
// );
// $node_agent1 = db_get_value(
// 'id',
// 'titem',
// 'source_data',
// $agent_a
// );
// db_process_sql_insert(
// 'trel_item',
// [
// 'id_map' => $id_networkmap,
// 'id_parent' => $node_agent1,
// 'id_child' => $node_interface1,
// 'id_parent-source_data' => $agent_a,
// 'id_child-source_data' => $relation['module_b'],
// 'parent_type' => 0,
// 'child_type' => 1,
// ]
// );
// } else {
// $node_interface2 = $exist_node_interface2;
// }
// if (empty($node_interface1) === false && empty($node_interface2) === false) {
// if (is_array($node_interface1) === true) {
// $node_interface1 = $node_interface1['id'];
// }
// if (is_array($node_interface2) === true) {
// $node_interface2 = $node_interface2['id'];
// }
// db_process_sql_insert(
// 'trel_item',
// [
// 'id_map' => $id_networkmap,
// 'id_parent' => $node_interface2,
// 'id_child' => $node_interface1,
// 'id_parent_source_data' => $relation['module_b'],
// 'id_child_source_data' => $relation['module_a'],
// 'parent_type' => 1,
// 'child_type' => 1,
// ]
// );
// }
// }
// }
// }
$relations = modules_get_relations(
[
'id_agente',
'id_agente_modulo',
'id_agent' => $node['source_data'],
'networkmap' => true,
]
);
if (empty($interfaces) === true) {
$interfaces = [];
}
foreach ($interfaces as $interface) {
$relations = modules_get_relations(
['id_module' => $interface['id_agente_modulo']]
);
if (empty($relations) === true) {
$relations = [];
}
foreach ($relations as $relation) {
// Get the links althought they are deleted (for to
// avoid to add)
// Check if the module is ping.
if (modules_get_agentmodule_type($relation['module_a']) === '6') {
// The pings modules are not exist as interface
// the link is with the agent.
$node_a = db_get_value_filter(
'id',
'titem',
[
'source_data' => modules_get_agentmodule_agent(
$relation['module_a']
),
'id_map' => $id_networkmap,
]
);
} else {
$node_a = db_get_value_filter(
'id',
'titem',
[
'source_data' => $relation['module_a'],
'type' => 1,
'id_map' => $id_networkmap,
]
);
}
// Check if the module is ping.
if (modules_get_agentmodule_type($relation['module_b']) == 6) {
// The pings modules are not exist as interface
// the link is with the agent.
$node_b = db_get_value_filter(
'id',
'titem',
[
'source_data' => modules_get_agentmodule_agent(
$relation['module_b']
),
'id_map' => $id_networkmap,
]
);
} else {
$node_b = db_get_value_filter(
'id',
'titem',
[
'source_data' => $relation['module_b'],
'type' => 1,
'id_map' => $id_networkmap,
]
);
}
$exist = db_get_row_filter(
'trel_item',
[
'id_map' => $id_networkmap,
'id_parent_source_data' => $relation['module_a'],
'id_child_source_data' => $relation['module_b'],
'deleted' => 0,
]
);
$exist_reverse = db_get_row_filter(
'trel_item',
[
'id_map' => $id_networkmap,
'id_parent_source_data' => $relation['module_b'],
'id_child_source_data' => $relation['module_a'],
'deleted' => 0,
]
);
if (empty($exist) && empty($exist_reverse)) {
// Create the nodes for interfaces
// Ag1 ----- I1 ------ I2 ----- Ag2
// * 2 interfaces nodes
// * 3 relations
// * I1 between I2
// * Ag1 between I1
// * Ag2 between I2
//
// But check if it exists the relations
// agent between interface.
if ($interface['id_agente_modulo'] == $relation['module_a']) {
$agent_a = $interface['id_agente'];
$agent_b = modules_get_agentmodule_agent(
$relation['module_b']
);
} else {
$agent_a = modules_get_agentmodule_agent(
$relation['module_a']
);
$agent_b = $interface['id_agente'];
}
$exist_node_interface1 = db_get_row_filter(
'titem',
[
'id_map' => $id_networkmap,
'type' => 1,
'source_data' => $relation['module_a'],
]
);
if (empty($exist_node_interface1) === true) {
// Crete the interface node
// and create the relation between agent and
// interface.
$style = [];
$style['id_agent'] = $agent_a;
$style['shape'] = 'circle';
$style['image'] = 'images/mod_snmp_proc.png';
$style['width'] = 50;
$style['height'] = 16;
$style['label'] = modules_get_agentmodule_name($relation['module_a']);
$id_int1 = db_process_sql_insert(
'titem',
[
'id_map' => $id_networkmap,
'x' => 666,
'y' => 666,
'z' => 0,
'deleted' => 0,
'type' => 1,
'refresh' => 0,
'source' => 0,
'source_data' => $relation['module_a'],
'style' => json_encode($style),
]
);
$node_interface1 = db_get_row_filter(
'titem',
[
'id_map' => $id_networkmap,
'type' => 1,
'id' => $id_int1,
]
);
$node_agent1 = db_get_value(
'id',
'titem',
'source_data',
$agent_a
);
db_process_sql_insert(
'trel_item',
[
'id_map' => $id_networkmap,
'id_parent' => $node_agent1,
'id_child' => $node_interface1,
'id_parent-source_data' => $agent_a,
'id_child-source_data' => $relation['module_a'],
'parent_type' => 0,
'child_type' => 1,
]
);
} else {
$node_interface1 = $exist_node_interface1;
}
$exist_node_interface2 = db_get_row_filter(
'titem',
[
'id_map' => $id_networkmap,
'type' => 1,
'source_data' => $relation['module_b'],
]
);
if (empty($exist_node_interface2) === true) {
// Crete the interface node
// and create the relation between agent and
// interface.
$style = [];
$style['id_agent'] = $agent_a;
$style['shape'] = 'circle';
$style['image'] = 'images/mod_snmp_proc.png';
$style['width'] = 50;
$style['height'] = 16;
$style['label'] = modules_get_agentmodule_name($relation['module_b']);
$id_int2 = db_process_sql_insert(
'titem',
[
'id_map' => $id_networkmap,
'x' => 666,
'y' => 666,
'z' => 0,
'deleted' => 0,
'type' => 1,
'refresh' => 0,
'source' => 0,
'source_data' => $relation['module_b'],
'style' => json_encode($style),
]
);
$node_interface2 = db_get_row_filter(
'titem',
[
'id_map' => $id_networkmap,
'type' => 1,
'id' => $id_int1,
]
);
$node_agent1 = db_get_value(
'id',
'titem',
'source_data',
$agent_a
);
db_process_sql_insert(
'trel_item',
[
'id_map' => $id_networkmap,
'id_parent' => $node_agent1,
'id_child' => $node_interface1,
'id_parent-source_data' => $agent_a,
'id_child-source_data' => $relation['module_b'],
'parent_type' => 0,
'child_type' => 1,
]
);
} else {
$node_interface2 = $exist_node_interface2;
}
if (empty($node_interface1) === false && empty($node_interface2) === false) {
if (is_array($node_interface1) === true) {
$node_interface1 = $node_interface1['id'];
}
if (is_array($node_interface2) === true) {
$node_interface2 = $node_interface2['id'];
}
db_process_sql_insert(
'trel_item',
[
'id_map' => $id_networkmap,
'id_parent' => $node_interface2,
'id_child' => $node_interface1,
'id_parent_source_data' => $relation['module_b'],
'id_child_source_data' => $relation['module_a'],
'parent_type' => 1,
'child_type' => 1,
]
);
}
}
}
}
$relations = modules_get_relations(['id_agent' => $node['source_data']]);
if ($relations === false) {
$relations = [];
}
// Relations Module <-> Module.
foreach ($relations as $key => $relation) {
$module_a = $relation['module_a'];
$agent_a = modules_get_agentmodule_agent($module_a);
@ -4584,58 +4683,26 @@ function networkmap_get_new_nodes_and_links($networkmap, $x, $y)
);
if (empty($exist) === true && empty($exist_reverse) === true) {
$style = [];
$style['id_agent'] = $agent_a;
$style['shape'] = 'circle';
$style['image'] = 'images/mod_snmp_proc.png';
$style['width'] = 50;
$style['height'] = 16;
$style['label'] = modules_get_agentmodule_name($module_a);
$id_int1 = db_process_sql_insert(
$item_a = db_get_value(
'id',
'titem',
[
'id_map' => $id_networkmap,
'x' => 666,
'y' => 666,
'z' => 0,
'deleted' => 0,
'type' => 1,
'refresh' => 0,
'source' => 0,
'source_data' => $module_a,
'style' => json_encode($style),
]
'source_data',
$agent_a
);
$style = [];
$style['id_agent'] = $agent_b;
$style['shape'] = 'circle';
$style['image'] = 'images/mod_snmp_proc.png';
$style['width'] = 50;
$style['height'] = 16;
$style['label'] = modules_get_agentmodule_name($module_b);
$id_int2 = db_process_sql_insert(
$item_b = db_get_value(
'id',
'titem',
[
'id_map' => $id_networkmap,
'x' => 666,
'y' => 666,
'z' => 0,
'deleted' => 0,
'type' => 1,
'refresh' => 0,
'source' => 0,
'source_data' => $module_b,
'style' => json_encode($style),
]
'source_data',
$agent_b
);
db_process_sql_insert(
'trel_item',
[
'id_map' => $id_networkmap,
'id_parent' => $id_int1,
'id_child' => $id_int2,
'id_parent' => $item_a,
'id_child' => $item_b,
'id_parent_source_data' => $module_a,
'id_child_source_data' => $module_b,
'parent_type' => 1,
@ -4644,6 +4711,30 @@ function networkmap_get_new_nodes_and_links($networkmap, $x, $y)
);
}
}
// Get L2 interface relations.
$interfaces = modules_get_interfaces(
$node['source_data'],
[
'id_agente',
'id_agente_modulo',
]
);
if (empty($interfaces) === true) {
$interfaces = [];
}
// hd('interfaces', true);
// foreach ($interfaces as $interface) {
// $relations = modules_get_relations(
// ['id_module' => $interface['id_agente_modulo']]
// );
// if (empty($relations) === true) {
// $relations = [];
// }
// foreach ($relations as $relation) {
// }
// }
}
}

View File

@ -181,7 +181,7 @@ function profile_delete_profile_and_clean_users($id_profile)
* @param int User id
* @param bool Show the tags select or not
*/
function profile_print_profile_table($id)
function profile_print_profile_table($id, $json_profile=false, $return=false)
{
global $config;
@ -243,7 +243,23 @@ function profile_print_profile_table($id)
}
if ($result === false) {
$result = [];
if ($json_profile !== false && empty($json_profile) !== true) {
$profile_decoded = json_decode($json_profile);
foreach ($profile_decoded as $profile) {
if (is_object($profile) === false) {
$profile = json_decode($profile);
}
$result[] = [
'id_grupo' => $profile->group,
'id_perfil' => $profile->profile,
'tags' => $profile->tags,
'hierarchy' => $profile->hierarchy,
];
}
} else {
$result = [];
}
}
foreach ($result as $profile) {
@ -268,7 +284,12 @@ function profile_print_profile_table($id)
if (empty($profile['tags'])) {
$data['tags'] = '';
} else {
$tags_ids = explode(',', $profile['tags']);
if (is_array($profile['tags'] === false)) {
$tags_ids = explode(',', $profile['tags']);
} else {
$tags_ids = $profile['tags'];
}
$tags = tags_get_tags($tags_ids);
$data['tags'] = tags_get_tags_formatted($tags);
}
@ -276,10 +297,10 @@ function profile_print_profile_table($id)
$data['hierarchy'] = $profile['no_hierarchy'] ? __('Yes') : __('No');
$data['actions'] = '<form method="post" onsubmit="if (!confirm (\''.__('Are you sure?').'\')) return false">';
$data['actions'] .= html_print_input_image('del', 'images/cross.png', 1, ['class' => 'invert_filter'], true);
$data['actions'] .= html_print_input_hidden('delete_profile', 1, true);
$data['actions'] .= html_print_input_hidden('id_user_profile', $profile['id_up'], true);
$data['actions'] .= html_print_input_hidden('id_user', $id, true);
$data['actions'] .= html_print_input_image('del', 'images/cross.png', 1, ['class' => 'invert_filter'], true);
$data['actions'] .= '</form>';
array_push($table->data, $data);
@ -345,8 +366,7 @@ function profile_print_profile_table($id)
$data['actions'] .= '</form>';
array_push($table->data, $data);
html_print_table($table);
html_print_table($table, $return);
if (!is_metaconsole()) {
echo '</div>';
}

View File

@ -1409,6 +1409,7 @@ function custom_fields_macros_report($macro, $key_macro)
return $result;
}
/**
* Get a list of the reports the user can view.
*
@ -1481,4 +1482,3 @@ function reports_get_report_templates(
return $templates;
}

View File

@ -3402,7 +3402,7 @@ function ui_print_datatable(array $parameters)
$filter .= '</li>';
$filter .= '</ul><div id="both"></div></form>';
if (isset($parameters['form']['no_toggle']) === false && ($parameters['form']['no_toggle'] !== true)) {
if (isset($parameters['form']['no_toggle']) === false) {
$filter = ui_toggle(
$filter,
__('Filter'),
@ -3466,7 +3466,10 @@ function ui_print_datatable(array $parameters)
foreach ($names as $column) {
if (is_array($column)) {
$table .= '<th id="'.$column['id'].'" class="'.$column['class'].'" ';
$table .= 'title="'.__($column['title']).'" ';
if (isset($column['title']) === true) {
$table .= 'title="'.__($column['title']).'" ';
}
$table .= ' style="'.$column['style'].'">'.__($column['text']);
$table .= $column['extra'];
$table .= '</th>';
@ -3655,7 +3658,7 @@ function ui_print_datatable(array $parameters)
order: [[ '.$order.' ]]
};
var dt_'.$table_id.' = $("#'.$table_id.'").DataTable(settings_datatable);
dt_'.$table_id.' = $("#'.$table_id.'").DataTable(settings_datatable);
$("#'.$form_id.'_search_bt").click(function (){
dt_'.$table_id.'.draw().page(0)

View File

@ -838,13 +838,14 @@ function users_has_profile_without_UM($id_user, $id_groups)
}
function users_get_user_profile($id_user)
function users_get_user_profile($id_user, $limit='')
{
$sql = sprintf(
"SELECT * FROM tusuario_perfil
INNER JOIN tperfil ON tperfil.id_perfil = tusuario_perfil.id_perfil
WHERE tusuario_perfil.id_usuario like '%s'",
$id_user
WHERE tusuario_perfil.id_usuario like '%s' %s",
$id_user,
$limit
);
$aux = db_get_all_rows_sql($sql);

View File

@ -3788,7 +3788,6 @@ function visual_map_get_user_layouts(
unset($filter['can_manage_group_all']);
}
$where = '';
if ($check_user_groups === true && !empty($groups)) {
if (empty($where)) {
$where = '';

View File

@ -192,7 +192,8 @@ function delete_link(
source_module_id,
target_id,
target_module_id,
id_link
id_link,
table_row = null
) {
var params = [];
params.push("delete_link=1");
@ -241,8 +242,22 @@ function delete_link(
draw_elements_graph();
init_drag_and_drop();
set_positions_graph();
if (typeof table_row !== "undefined" && table_row !== null) {
$(`#relations_table-template_row_${table_row}`).animate(
{ backgroundColor: "#e6e6e6" },
500,
function() {
$(`#relations_table-template_row_${table_row}`).remove();
const rowCount = $(".relation_link_row").length;
if (rowCount === 0) {
$("#relations_table-no_relations").show();
$(`#update_relations_button`).remove();
}
}
);
}
}
$("#dialog_node_edit").dialog("close");
}
});
}
@ -378,11 +393,7 @@ function change_shape(id_db_node) {
})
.on("click", selected_node)
.on("dblclick", function(d) {
if (d.type == 3) {
move_to_networkmap(d);
} else {
edit_node(d, true);
}
edit_node(d, true);
})
.on("contextmenu", function(d) {
show_menu("node", d);
@ -419,11 +430,7 @@ function change_shape(id_db_node) {
})
.on("click", selected_node)
.on("dblclick", function(d) {
if (d.type == 3) {
move_to_networkmap(d);
} else {
edit_node(d, true);
}
edit_node(d, true);
})
.on("contextmenu", function(d) {
show_menu("node", d);
@ -446,11 +453,7 @@ function change_shape(id_db_node) {
})
.on("click", selected_node)
.on("dblclick", function(d) {
if (d.type == 3) {
move_to_networkmap(d);
} else {
edit_node(d, true);
}
edit_node(d, true);
})
.on("contextmenu", function(d) {
show_menu("node", d);
@ -487,11 +490,7 @@ function change_shape(id_db_node) {
})
.on("click", selected_node)
.on("dblclick", function(d) {
if (d.type == 3) {
move_to_networkmap(d);
} else {
edit_node(d, true);
}
edit_node(d, true);
})
.on("contextmenu", function(d) {
show_menu("node", d);
@ -515,11 +514,7 @@ function change_shape(id_db_node) {
})
.on("click", selected_node)
.on("dblclick", function(d) {
if (d.type == 3) {
move_to_networkmap(d);
} else {
edit_node(d, true);
}
edit_node(d, true);
})
.on("contextmenu", function(d) {
show_menu("node", d);
@ -556,11 +551,7 @@ function change_shape(id_db_node) {
})
.on("click", selected_node)
.on("dblclick", function(d) {
if (d.type == 3) {
move_to_networkmap(d);
} else {
edit_node(d, true);
}
edit_node(d, true);
})
.on("contextmenu", function(d) {
show_menu("node", d);
@ -607,6 +598,10 @@ function update_link(row_index, id_link) {
$(".edit_icon_progress_" + row_index).css("display", "");
$(".edit_icon_" + row_index).css("display", "none");
$(".edit_icon_" + row_index).css("display", "none");
let result = false;
var params = [];
params.push("update_link=1");
params.push("networkmap_id=" + networkmap_id);
@ -621,6 +616,7 @@ function update_link(row_index, id_link) {
data: params.join("&"),
dataType: "json",
type: "POST",
async: false,
url: window.base_url_homedir + "/ajax.php",
success: function(data) {
$(".edit_icon_progress_" + row_index).css("display", "none");
@ -726,11 +722,14 @@ function update_link(row_index, id_link) {
draw_elements_graph();
init_drag_and_drop();
set_positions_graph();
result = data["id_db_link"];
} else {
$(".edit_icon_fail_" + row_index).css("display", "");
}
}
});
return result;
}
function delete_link_from_id(index) {
@ -826,51 +825,81 @@ function edit_node(data_node, dblClick) {
"update_node_name(" + node_selected.id_db + ");"
);
var params = [];
params.push("get_agent_info=1");
params.push("id_agent=" + node_selected["id_agent"]);
params.push("page=operation/agentes/pandora_networkmap.view");
jQuery.ajax({
data: params.join("&"),
dataType: "json",
type: "POST",
url: window.base_url_homedir + "/ajax.php",
success: function(data) {
if (node_selected.type === "3") {
$("#node_details-0-0").html("<strong>Link to map</strong>");
if (node_selected.networkmap_id > 0) {
$("#node_details-0-1").html(
'<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' +
node_selected["id_agent"] +
'<a href="index.php?sec=network&sec2=operation/agentes/pandora_networkmap&tab=view&id_networkmap=' +
node_selected.networkmap_id +
'">' +
data["alias"] +
$(
`#edit_networkmap_to_link option[value='${node_selected.networkmap_id}']`
).text() +
"</a>"
);
var addresses = "";
if (data["adressess"] instanceof Array) {
for (var i; i < data["adressess"].length; i++) {
addresses += data["adressess"][i] + "<br>";
}
} else {
for (var address in data["adressess"]) {
addresses += address + "<br>";
}
}
$("#node_details-1-1").html(addresses);
$("#node_details-2-1").html(data["os"]);
$("#node_details-3-1").html(data["group"]);
$("[aria-describedby=dialog_node_edit]").css({ top: "200px" });
$("#foot").css({
top: parseInt(
$("[aria-describedby=dialog_node_edit]").css("height") +
$("[aria-describedby=dialog_node_edit]").css("top")
),
position: "relative"
});
get_interface_data_to_table(node_selected, selected_links);
} else {
$("#node_details-0-1").html(
$(
`#edit_networkmap_to_link option[value='${node_selected.networkmap_id}']`
).text()
);
}
});
$("#node_details-1").hide();
$("#node_details-2").hide();
$("#node_details-3").hide();
} else {
$("#node_details-0-0").html("<strong>Agent</strong>");
$("#node_details-1").show();
$("#node_details-2").show();
$("#node_details-3").show();
var params = [];
params.push("get_agent_info=1");
params.push("id_agent=" + node_selected["id_agent"]);
params.push("page=operation/agentes/pandora_networkmap.view");
jQuery.ajax({
data: params.join("&"),
dataType: "json",
type: "POST",
url: window.base_url_homedir + "/ajax.php",
success: function(data) {
$("#node_details-0-1").html(
'<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' +
node_selected["id_agent"] +
'">' +
data["alias"] +
"</a>"
);
var addresses = "";
if (data["adressess"] instanceof Array) {
for (var i; i < data["adressess"].length; i++) {
addresses += data["adressess"][i] + "<br>";
}
} else {
for (var address in data["adressess"]) {
addresses += address + "<br>";
}
}
$("#node_details-1-1").html(addresses);
$("#node_details-2-1").html(data["os"]);
$("#node_details-3-1").html(data["group"]);
$("[aria-describedby=dialog_node_edit]").css({ top: "200px" });
$("#foot").css({
top: parseInt(
$("[aria-describedby=dialog_node_edit]").css("height") +
$("[aria-describedby=dialog_node_edit]").css("top")
),
position: "relative"
});
get_interface_data_to_table(node_selected, selected_links);
}
});
}
$("#dialog_node_edit").dialog(
"option",
@ -887,6 +916,7 @@ function edit_node(data_node, dblClick) {
$("input[name='edit_name_fictional_node']").val(node_selected.text); // It doesn't eval the possible XSS so it's ok
$("#node_options-fictional_node_networkmap_link").css("display", "");
$("#edit_networkmap_to_link").val(node_selected.networkmap_id);
$("#edit_networkmap_to_link").trigger("change");
$("#node_options-fictional_node_update_button").css("display", "");
$("#node_options-node_name").css("display", "none");
$("#node_options-node_update_button").css("display", "none");
@ -957,6 +987,7 @@ function get_interface_data_to_table(node_selected, selected_links) {
function load_interfaces(selected_links) {
//Clean
$("#relations_table .relation_link_row").remove();
$("#update_relations_button").remove();
//Show the no relations
$("#relations_table-loading").css("display", "none");
$("#relations_table-no_relations").css("display", "");
@ -969,6 +1000,7 @@ function load_interfaces(selected_links) {
$(template_relation_row).css("display", "");
$(template_relation_row).attr("class", "relation_link_row");
$(template_relation_row).attr("id", `relations_table-template_row_${i}`);
$("select[name='interface_source']", template_relation_row)
.attr("name", "interface_source_" + i)
@ -989,11 +1021,6 @@ function load_interfaces(selected_links) {
"class",
"edit_icon_fail_" + i
);
$(".edit_icon_link", template_relation_row)
.attr("class", "edit_icon_link_" + i)
.click(function() {
update_link(i, link_each.id_db);
});
var params3 = [];
params3.push("get_intefaces=1");
@ -1093,6 +1120,17 @@ function load_interfaces(selected_links) {
"align",
"center"
);
$("#relations_table-template_row-edit", template_relation_row).css({
display: "flex",
"align-items": "center",
"justify-content": "center"
});
$(
"#relations_table-template_row-edit .delete_icon",
template_relation_row
).attr("id", `delete_icon_${i}`);
$(
"#relations_table-template_row-edit .delete_icon",
template_relation_row
@ -1109,6 +1147,8 @@ function load_interfaces(selected_links) {
link_each.id_module_end +
"," +
link_each.id_db +
"," +
i +
");"
);
$("#relations_table tbody").append(template_relation_row);
@ -1119,6 +1159,42 @@ function load_interfaces(selected_links) {
template_relation_row = null;
});
if (selected_links.length > 0) {
$("#relations_table")
.parent()
.append(
`<div class='action-buttons w100p'>
<input id='update_relations_button' class='sub upd' type='button' value='update relations'>
</div>`
);
$("#update_relations_button").click(function() {
jQuery.each(selected_links, function(i, link_each) {
const new_id_db = update_link(i, link_each.id_db);
if (new_id_db !== false) {
selected_links[i]["id_db"] = new_id_db;
$(`#delete_icon_${i}`).attr(
"href",
"javascript: " +
"delete_link(" +
link_each.source.id_db +
"," +
link_each.id_module_start +
"," +
link_each.target.id_db +
"," +
link_each.id_module_end +
"," +
new_id_db +
"," +
i +
");"
);
}
});
});
}
}
function add_node() {
@ -1303,11 +1379,6 @@ function function_close_minimap() {
function delete_nodes() {
var selection = d3.selectAll(".node_selected");
selection.each(function(d) {
//Avoid to delete pandora node center
if (d.id_agent == 0) {
return;
}
var params = [];
params.push("id=" + d.id_db);
params.push("delete_node=1");
@ -1973,17 +2044,14 @@ function show_menu(item, data) {
};
}
// Avoid deletion if Pandora FMS node.
if (data.type != 2) {
items_list["delete"] = {
name: delete_menu,
icon: "delete",
disabled: false,
callback: function(key, options) {
delete_nodes();
}
};
}
items_list["delete"] = {
name: delete_menu,
icon: "delete",
disabled: false,
callback: function(key, options) {
delete_nodes();
}
};
$.contextMenu("destroy");
$.contextMenu({
@ -2030,15 +2098,7 @@ function show_menu(item, data) {
icon: "refresh",
disabled: false,
callback: function(key, options) {
update_networkmap();
}
};
items_list["refresh_holding_area"] = {
name: refresh_holding_area_menu,
icon: "refresh_holding_area",
disabled: false,
callback: function(key, options) {
refresh_holding_area();
refresh();
}
};
items_list["restart_map"] = {
@ -2398,6 +2458,99 @@ function refresh_holding_area() {
});
}
function refresh() {
$("#spinner_networkmap").css("display", "flex");
var holding_pos_x = d3.select("#holding_area_" + networkmap_id).attr("x");
var holding_pos_y = d3.select("#holding_area_" + networkmap_id).attr("y");
var pos_x = parseInt(holding_pos_x) + parseInt(node_radius);
var pos_y = parseInt(holding_pos_y) + parseInt(node_radius);
var params = [];
params.push("refresh_holding_area=1");
params.push("id=" + networkmap_id);
params.push("x=" + pos_x);
params.push("y=" + pos_y);
params.push("page=operation/agentes/pandora_networkmap.view");
$.ajax({
data: {
page: "operation/agentes/pandora_networkmap.view",
refresh_holding_area: 1,
id: networkmap_id,
x: pos_x,
y: pos_y
},
dataType: "json",
type: "POST",
url: window.base_url_homedir + "/ajax.php",
success: function(data) {
if (data["correct"]) {
const array_nodes = data["holding_area"]["nodes"];
let array_links = data["holding_area"]["links"];
jQuery.each(graph.links, function(j, g_link) {
for (var i = 0; i < array_links.length; i++) {
if (g_link["id_db"] == array_links[i]["id_db"]) {
array_links.splice(i, 1);
}
}
});
let location = "";
if ($("#main").height()) {
location = `index.php?sec=network&sec2=operation/agentes/pandora_networkmap&tab=view&id_networkmap=${networkmap_id}`;
} else {
location = `index.php?sec=network&sec2=operation/agentes/pandora_networkmap&tab=view&pure=1&id_networkmap=${networkmap_id}`;
}
if (array_nodes.length === 0 && array_links.length === 0) {
update_networkmap();
$("#spinner_networkmap").css("display", "none");
startCountDown(refresh_time);
} else {
if (array_nodes.length > 0) {
$.ajax({
data: {
page: "operation/agentes/pandora_networkmap.view",
refresh_map: 1,
id: networkmap_id
},
dataType: "json",
type: "POST",
url: window.base_url_homedir + "/ajax.php",
success: function(data) {
$("#spinner_networkmap").css("display", "none");
window.location = location;
}
});
} else if (array_links.length > 0) {
$("#spinner_networkmap").css("display", "none");
window.location = location;
}
}
}
},
error: function(e) {
$("#spinner_networkmap").css("display", "none");
}
});
}
function startCountDown(duration) {
$("div.vc-countdown").countdown("destroy");
if (!duration) return;
var t = new Date();
t.setTime(t.getTime() + duration * 1000);
$("div.vc-countdown").countdown({
until: t,
format: "MS",
layout: "(%M%nn%M:%S%nn%S Until refreshed) ",
alwaysExpire: true,
onExpiry: function() {
refresh();
}
});
}
function restart_map() {
$(
"<div id='restart_map_confirm' class='dialog ui-dialog-content' title='" +
@ -2935,6 +3088,10 @@ function init_graph(parameter_object) {
window.url_background_grid = "";
}
if (typeof parameter_object.refresh_time != "undefined") {
window.refresh_time = parameter_object.refresh_time;
}
var rect_center_x = graph.nodes[0].x;
var rect_center_y = graph.nodes[0].y;
@ -3644,11 +3801,7 @@ function draw_elements_graph() {
})
.on("click", selected_node)
.on("dblclick", function(d) {
if (d.type == 3) {
move_to_networkmap(d);
} else {
edit_node(d, true);
}
edit_node(d, true);
})
.on("contextmenu", function(d) {
show_menu("node", d);
@ -3685,11 +3838,7 @@ function draw_elements_graph() {
})
.on("click", selected_node)
.on("dblclick", function(d) {
if (d.type == 3) {
move_to_networkmap(d);
} else {
edit_node(d, true);
}
edit_node(d, true);
})
.on("contextmenu", function(d) {
show_menu("node", d);
@ -3721,11 +3870,7 @@ function draw_elements_graph() {
})
.on("click", selected_node)
.on("dblclick", function(d) {
if (d.type == 3) {
move_to_networkmap(d);
} else {
edit_node(d, true);
}
edit_node(d, true);
})
.on("contextmenu", function(d) {
show_menu("node", d);
@ -3767,11 +3912,7 @@ function draw_elements_graph() {
})
.on("click", selected_node)
.on("dblclick", function(d) {
if (d.type == 3) {
move_to_networkmap(d);
} else {
edit_node(d, true);
}
edit_node(d, true);
})
.on("contextmenu", function(d) {
show_menu("node", d);
@ -3804,11 +3945,7 @@ function draw_elements_graph() {
})
.on("click", selected_node)
.on("dblclick", function(d) {
if (d.type == 3) {
move_to_networkmap(d);
} else {
edit_node(d, true);
}
edit_node(d, true);
})
.on("contextmenu", function(d) {
show_menu("node", d);
@ -3850,11 +3987,7 @@ function draw_elements_graph() {
})
.on("click", selected_node)
.on("dblclick", function(d) {
if (d.type == 3) {
move_to_networkmap(d);
} else {
edit_node(d, true);
}
edit_node(d, true);
})
.on("contextmenu", function(d) {
show_menu("node", d);

View File

@ -886,7 +886,6 @@ function period_select_init(name, allow_zero) {
// Manual mode is hidden by default
$("#" + name + "_manual").css("display", "none");
$("#" + name + "_default").css("display", "inline");
// If the text input is empty, we put on it 5 minutes by default
if ($("#text-" + name + "_text").val() == "") {
$("#text-" + name + "_text").val(300);
@ -897,7 +896,7 @@ function period_select_init(name, allow_zero) {
} else {
$("#" + name + "_select option:eq(1)").prop("selected", true);
}
} else if ($("#text-" + name + "_text").val() == 0 && allow_zero != true) {
} else if ($("#text-" + name + "_text").val() == 0 && allow_zero == 1) {
$("#" + name + "_units option:last").prop("selected", false);
$("#" + name + "_manual").css("display", "inline");
$("#" + name + "_default").css("display", "none");
@ -1041,10 +1040,10 @@ function adjustTextUnits(name) {
var restInt = parseInt(rest).toString();
if (rest != restInt && unitsSelected == false) {
$("#" + name + "_units option:eq(" + ($(this).index() - 1) + ")").prop(
"selected",
true
);
var value_selected = $(
"#" + name + "_units option:eq(" + ($(this).index() - 1) + ")"
).val();
$("#" + name + "_units").val(value_selected);
$("#text-" + name + "_text").val(restPrev);
unitsSelected = true;

View File

@ -85,29 +85,6 @@ function show_event_dialog(event, dialog_page) {
$("#refrcounter").countdown("pause");
$("div.vc-countdown").countdown("pause");
/*
switch (result) {
case "comment_ok":
$("#notification_comment_success").show();
break;
case "comment_error":
$("#notification_comment_error").show();
break;
case "status_ok":
$("#notification_status_success").show();
break;
case "status_error":
$("#notification_status_error").show();
break;
case "owner_ok":
$("#notification_owner_success").show();
break;
case "owner_error":
$("#notification_owner_error").show();
break;
}
*/
forced_title_callback();
},
"html"
@ -119,37 +96,152 @@ function show_event_dialog(event, dialog_page) {
function execute_response(event_id, server_id) {
var response_id = $("#select_custom_response option:selected").val();
var response = get_response(response_id, server_id);
// If cannot get response abort it
if (response == null) {
return;
var response_parameters_list = $('input[name^="values_params_"]');
var response_parameters = [];
if (response_parameters_list.length > 0) {
response_parameters_list.each(function() {
var acum = {
name: $(this).attr("name"),
value: $(this).val()
};
response_parameters.push(acum);
});
}
response["target"] = get_response_target(event_id, response_id, server_id);
response["event_id"] = event_id;
response["server_id"] = server_id;
var params = [];
params.push({ name: "page", value: "include/ajax/events" });
params.push({ name: "get_response", value: 1 });
params.push({ name: "response_id", value: response_id });
params.push({ name: "server_id", value: server_id });
params.push({ name: "event_id", value: event_id });
params.push({
name: "response_parameters",
value: JSON.stringify(response_parameters)
});
if (response["type"] == "url" && response["new_window"] == 1) {
window.open(response["target"], "_blank");
} else {
show_response_dialog(response_id, response);
}
jQuery.ajax({
data: params,
type: "POST",
url: $("#hidden-ajax_file").val(),
dataType: "json",
success: function(response) {
// If cannot get response abort it
if (response == null) {
return [];
}
response["event_id"] = event_id;
response["server_id"] = server_id;
if (response["type"] == "url" && response["new_window"] == 1) {
window.open(response["target"], "_blank");
} else {
show_response_dialog(response_id, response);
}
}
});
}
// Check the response type and open it in a modal dialog or new window
function execute_response_massive(events, response_id, response_parameters) {
var params = [];
params.push({ name: "page", value: "include/ajax/events" });
params.push({ name: "get_response_massive", value: 1 });
params.push({ name: "response_id", value: response_id });
params.push({ name: "events", value: JSON.stringify(events) });
params.push({ name: "response_parameters", value: response_parameters });
jQuery.ajax({
data: params,
type: "POST",
url: $("#hidden-ajax_file").val(),
dataType: "json",
success: function(data) {
// If cannot get response abort it
if (data == null) {
return [];
}
$(".container-massive-events-response").empty();
// Convert to array.
var array_data = Object.entries(data.event_response_targets);
var total_count = array_data.length;
// Each input checkeds.
array_data.forEach(function(element, index) {
var id = element[0];
var target = element[1].target;
var meta = $("#hidden-meta").val();
var event_id = id;
var server_id = 0;
if (meta != 0) {
var split_id = id.split("|");
event_id = split_id[0];
server_id = split_id[1];
}
var end = 0;
if (total_count - 1 === index) {
end = 1;
}
var response = data.event_response;
response["event_id"] = event_id;
response["server_id"] = server_id;
response["target"] = target;
if (response["type"] == "url" && response["new_window"] == 1) {
window.open(response["target"], "_blank");
} else {
var params = [];
params.push({ name: "page", value: "include/ajax/events" });
params.push({ name: "get_row_response_action", value: 1 });
params.push({ name: "response_id", value: response_id });
params.push({ name: "server_id", value: response.server_id });
params.push({ name: "end", value: end });
params.push({ name: "response", value: JSON.stringify(response) });
jQuery.ajax({
data: params,
type: "POST",
url: $("#hidden-ajax_file").val(),
dataType: "html",
success: function(data) {
$(".container-massive-events-response").append(data);
response["event_id"] = event_id;
response["server_id"] = server_id;
response["target"] = target;
var indexstr = event_id;
if (meta != 0) {
indexstr += "-" + server_id;
}
perform_response(
btoa(JSON.stringify(response)),
response_id,
indexstr
);
}
});
}
});
}
});
}
//Show the modal window of an event response
function show_response_dialog(response_id, response) {
var params = [];
params.push("page=include/ajax/events");
params.push("dialogue_event_response=1");
params.push("massive=0");
params.push("event_id=" + response["event_id"]);
params.push("target=" + encodeURIComponent(response["target"]));
params.push("response_id=" + response_id);
params.push("server_id=" + response["server_id"]);
params.push({ name: "page", value: "include/ajax/events" });
params.push({ name: "dialogue_event_response", value: 1 });
params.push({ name: "event_id", value: response.event_id });
params.push({ name: "target", value: response.target });
params.push({ name: "response_id", value: response_id });
params.push({ name: "server_id", value: response.server_id });
params.push({ name: "response", value: JSON.stringify(response) });
jQuery.ajax({
data: params.join("&"),
data: params,
type: "POST",
url: $("#hidden-ajax_file").val(),
dataType: "html",
@ -164,271 +256,49 @@ function show_response_dialog(response_id, response) {
draggable: true,
modal: false,
open: function() {
perform_response(response, response_id);
perform_response(btoa(JSON.stringify(response)), response_id, "");
},
width: response["modal_width"],
height: response["modal_height"]
height: response["modal_height"],
buttons: []
})
.show();
}
});
}
//Show the modal window of event responses when multiple events are selected
function show_massive_response_dialog(
response_id,
response,
out_iterator,
end
) {
var params = [];
params.push("page=include/ajax/events");
params.push("dialogue_event_response=1");
params.push("massive=1");
params.push("end=" + end);
params.push("out_iterator=" + out_iterator);
params.push("event_id=" + response["event_id"]);
params.push("target=" + response["target"]);
params.push("response_id=" + response_id);
params.push("server_id=" + response["server_id"]);
// Perform a response and put the output into a div
function perform_response(response, response_id, index) {
$("#re_exec_command" + index).hide();
$("#response_loading_command" + index).show();
$("#response_out" + index).html("");
jQuery.ajax({
data: params.join("&"),
response_tg: response,
response_id: response_id,
out_iterator: out_iterator,
type: "POST",
url: $("#hidden-ajax_file").val(),
dataType: "html",
success: function(data) {
if (out_iterator === 0) $("#event_response_window").empty();
$("#event_response_window")
.hide()
.append(data)
.dialog({
title: $("#select_custom_response option:selected").html(),
resizable: true,
draggable: true,
modal: false,
open: function() {
$("#response_loading_dialog").hide();
$("#button-submit_event_response").show();
},
close: function() {
$("#checkbox-all_validate_box").prop("checked", false);
$(".chk_val").prop("checked", false);
},
width: response["modal_width"],
height: response["modal_height"]
})
.show();
perform_response_massive(
this.response_tg,
this.response_id,
this.out_iterator
);
}
});
}
// Get an event response from db
function get_response(response_id, server_id) {
var response = "";
var params = [];
params.push("page=include/ajax/events");
params.push("get_response=1");
params.push("response_id=" + response_id);
params.push("server_id=" + server_id);
jQuery.ajax({
data: params.join("&"),
type: "POST",
url: $("#hidden-ajax_file").val(),
async: false,
dataType: "json",
success: function(data) {
response = data;
}
});
return response;
}
// Get an event response params from db
function get_response_params(response_id) {
var response_params;
var params = [];
params.push("page=include/ajax/events");
params.push("get_response_params=1");
params.push("response_id=" + response_id);
jQuery.ajax({
data: params.join("&"),
type: "POST",
url: $("#hidden-ajax_file").val(),
async: false,
dataType: "json",
success: function(data) {
response_params = data;
}
});
return response_params;
}
// Get an event response description from db
function get_response_description(response_id) {
var response_description = "";
var params = [];
params.push("page=include/ajax/events");
params.push("get_response_description=1");
params.push("response_id=" + response_id);
jQuery.ajax({
data: params.join("&"),
type: "POST",
url: $("#hidden-ajax_file").val(),
async: false,
dataType: "html",
success: function(data) {
response_description = data;
}
});
return response_description;
}
function add_row_param(id_table, param) {
$("#" + id_table).append(
'<tr class="params_rows"><td style="text-align:left; padding-left:40px; font-weight: normal; font-style: italic;">' +
param +
'</td><td style="text-align:left" colspan="2"><input type="text" name="' +
param +
'" id="' +
param +
'"></td></tr>'
);
}
// Get an event response from db
function get_response_target(
event_id,
response_id,
server_id,
response_command
) {
var target = "";
// Replace the main macros
var params = [];
params.push("page=include/ajax/events");
params.push("get_response_target=1");
params.push("event_id=" + event_id);
params.push("response_id=" + response_id);
params.push("server_id=" + server_id);
jQuery.ajax({
data: params.join("&"),
type: "POST",
url: $("#hidden-ajax_file").val(),
async: false,
dataType: "html",
success: function(data) {
target = data;
}
});
// Replace the custom params macros.
var response_params = get_response_params(response_id);
if (response_params.length > 1 || response_params[0] != "") {
for (var i = 0; i < response_params.length; i++) {
if (!response_command) {
var response_param = "_" + response_params[i] + "_";
if (
response_params[i].startsWith("_") &&
response_params[i].endsWith("_")
) {
response_param = response_params[i];
}
target = target.replace(
response_param,
$("#" + response_params[i]).val()
);
} else {
target = target.replace(
"_" + response_params[i] + "_",
response_command[response_params[i] + "-" + i]
);
}
}
try {
response = JSON.parse(atob(response));
} catch (e) {
console.error(e);
return;
}
return target;
}
// Perform a response and put the output into a div
function perform_response(response, response_id) {
$("#re_exec_command").hide();
$("#response_loading_command").show();
$("#response_out").html("");
var params = [];
params.push("page=include/ajax/events");
params.push("perform_event_response=1");
params.push("target=" + encodeURIComponent(response["target"]));
params.push("response_id=" + response_id);
params.push("event_id=" + response["event_id"]);
params.push("server_id=" + response["server_id"]);
params.push({ name: "page", value: "include/ajax/events" });
params.push({ name: "perform_event_response", value: 1 });
params.push({ name: "target", value: response["target"] });
params.push({ name: "response_id", value: response_id });
params.push({ name: "event_id", value: response["event_id"] });
params.push({ name: "server_id", value: response["server_id"] });
params.push({ name: "response", value: JSON.stringify(response) });
jQuery.ajax({
data: params.join("&"),
data: params,
type: "POST",
url: $("#hidden-ajax_file").val(),
async: true,
dataType: "html",
success: function(data) {
var out = data.replace(/[\n|\r]/g, "<br>");
$("#response_out").html(out);
$("#response_loading_command").hide();
$("#re_exec_command").show();
}
});
return false;
}
// Perform a response and put the output into a div
function perform_response_massive(response, response_id, out_iterator) {
$("#re_exec_command").hide();
$("#response_loading_command_" + out_iterator).show();
$("#response_out_" + out_iterator).html("");
var params = [];
params.push("page=include/ajax/events");
params.push("perform_event_response=1");
params.push("target=" + response["target"]);
params.push("response_id=" + response_id);
params.push("event_id=" + response["event_id"]);
params.push("server_id=" + response["server_id"]);
jQuery.ajax({
data: params.join("&"),
type: "POST",
url: $("#hidden-ajax_file").val(),
async: true,
dataType: "html",
success: function(data) {
var out = data.replace(/[\n|\r]/g, "<br>");
$("#response_out_" + out_iterator).html(out);
$("#response_loading_command_" + out_iterator).hide();
$("#re_exec_command_" + out_iterator).show();
$("#response_out" + index).html(out);
$("#response_loading_command" + index).hide();
$("#re_exec_command" + index).show();
}
});
@ -600,54 +470,6 @@ function event_comment(current_event) {
return false;
}
function show_event_response_command_dialog(id, response, total_checked) {
var params = [];
params.push("page=include/ajax/events");
params.push("get_table_response_command=1");
params.push("event_response_id=" + id);
jQuery.ajax({
data: params.join("&"),
type: "POST",
url: $("#hidden-ajax_file").val(),
dataType: "html",
success: function(data) {
$("#event_response_command_window")
.hide()
.empty()
.append(data)
.dialog({
resizable: true,
draggable: true,
modal: false,
open: function() {
$("#response_loading_dialog").hide();
$("#button-submit_event_response").show();
},
width: 600,
height: 300
})
.show();
$("#submit-enter_command").on("click", function(e) {
e.preventDefault();
var response_command = [];
$(".response_command_input").each(function() {
response_command[$(this).attr("name")] = $(this).val();
});
check_massive_response_event(
id,
response,
total_checked,
response_command
);
});
}
});
}
var processed = 0;
function update_event(table, id_evento, type, event_rep, row, server_id) {
var inputs = $("#events_form :input");
@ -820,8 +642,13 @@ function execute_delete_event_reponse(
// Imported from old files.
function execute_event_response(event_list_btn) {
var response_id = $("select[name=response_id]").val();
if (!isNaN(response_id)) {
table_info_response_event(response_id, 0, 0, true);
}
var message =
"<h4 style = 'text-align: center; color:black' > Are you sure?</h4> ";
"<h4 style = 'text-align: center; color:black' > Are you sure?</h4> <div id='massive-parameters-response'></div> ";
confirmDialog({
title: "ATTENTION",
message: message,
@ -833,8 +660,6 @@ function execute_event_response(event_list_btn) {
$("#max_custom_event_resp_msg").hide();
$("#max_custom_selected").hide();
var response_id = $("select[name=response_id]").val();
var total_checked = $(".chk_val:checked").length;
// Check select an event.
@ -844,58 +669,28 @@ function execute_event_response(event_list_btn) {
}
if (!isNaN(response_id)) {
// It is a custom response
var response = get_response(response_id);
// If cannot get response abort it
if (response == null) {
return;
var response_parameters_list = $('input[name^="values_params_"]');
var response_parameters = [];
if (response_parameters_list.length > 0) {
response_parameters_list.each(function() {
var acum = {
name: $(this).attr("name"),
value: $(this).val()
};
response_parameters.push(acum);
});
}
// Limit number of events to apply custom responses
// due performance reasons.
if (total_checked > $("#max_execution_event_response").val()) {
$("#max_custom_event_resp_msg").show();
return;
}
var response_command = [];
$(".response_command_input").each(function() {
response_command[$(this).attr("name")] = $(this).val();
});
response_parameters = JSON.stringify(response_parameters);
if (event_list_btn) {
$("#button-submit_event_response").hide(function() {
$("#response_loading_dialog").show(function() {
var check_params = get_response_params(response_id);
if (check_params[0] !== "") {
show_event_response_command_dialog(
response_id,
response,
total_checked
);
} else {
check_massive_response_event(
response_id,
response,
total_checked,
response_command
);
}
show_response_dialog_massive(response_id, response_parameters);
});
});
} else {
$("#button-btn_str").hide(function() {
$("#execute_again_loading").show(function() {
check_massive_response_event(
response_id,
response,
total_checked,
response_command
);
});
});
check_execute_response_massive(response_id, response_parameters);
}
} else {
// It is not a custom response
@ -970,15 +765,63 @@ function execute_event_response(event_list_btn) {
});
}
function check_massive_response_event(
response_id,
response,
total_checked,
response_command
) {
var counter = 0;
var end = 0;
function show_response_dialog_massive(response_id, response_parameters) {
var params = [];
params.push({ name: "page", value: "include/ajax/events" });
params.push({ name: "get_response", value: 1 });
params.push({ name: "response_id", value: response_id });
jQuery.ajax({
data: params,
type: "POST",
url: $("#hidden-ajax_file").val(),
dataType: "json",
success: function(response) {
// If cannot get response abort it
if (response == null) {
return [];
}
$("#event_response_window")
.hide()
.empty()
.append('<div class="container-massive-events-response"></div>')
.dialog({
title: $("#response_id option:selected").html(),
resizable: true,
draggable: true,
modal: false,
open: function() {
check_execute_response_massive(response_id, response_parameters);
},
close: function() {
$("#checkbox-all_validate_box").prop("checked", false);
$(".chk_val").prop("checked", false);
$("#response_loading_dialog").hide();
$("#button-submit_event_response").show();
},
buttons: [
{
text: "Execute All",
id: "execute-again-all",
class:
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
click: function() {
execute_event_response(false);
}
}
],
width: response["modal_width"],
height: response["modal_height"]
})
.show();
}
});
}
function check_execute_response_massive(response_id, response_parameters) {
var events = [];
$(".container-massive-events-response").empty();
$(".chk_val:checked").each(function() {
var event_id = $(this).val();
var meta = $("#hidden-meta").val();
@ -987,23 +830,18 @@ function check_massive_response_event(
var split_id = event_id.split("|");
event_id = split_id[0];
server_id = split_id[1];
if (events[server_id] === undefined) {
events[server_id] = [];
}
events[server_id].push(event_id);
} else {
events.push(event_id);
}
response["target"] = get_response_target(
event_id,
response_id,
server_id,
response_command
);
response["server_id"] = server_id;
response["event_id"] = event_id;
if (total_checked - 1 === counter) end = 1;
show_massive_response_dialog(response_id, response, counter, end);
counter++;
});
execute_response_massive(events, response_id, response_parameters);
}
function event_widget_options() {
@ -1287,3 +1125,43 @@ function check_event_sound(settings) {
"json"
);
}
function table_info_response_event(response_id, event_id, server_id, massive) {
var params = [];
params.push({ name: "page", value: "include/ajax/events" });
params.push({ name: "get_response", value: 1 });
params.push({ name: "response_id", value: response_id });
params.push({ name: "server_id", value: server_id });
params.push({ name: "event_id", value: event_id });
jQuery.ajax({
data: params,
type: "POST",
url: $("#hidden-ajax_file").val(),
dataType: "json",
success: function(response) {
if (response) {
var params = [];
params.push({ name: "page", value: "include/ajax/events" });
params.push({ name: "draw_row_response_info", value: 1 });
params.push({ name: "massive", value: massive === true ? 1 : 0 });
params.push({ name: "response", value: JSON.stringify(response) });
jQuery.ajax({
data: params,
type: "POST",
url: $("#hidden-ajax_file").val(),
dataType: "html",
success: function(output) {
if (massive === true) {
$("#massive-parameters-response").append(output);
} else {
$(".params_rows").remove();
$("#responses_table").append(output);
}
}
});
}
}
});
}

View File

@ -740,3 +740,26 @@ function reveal_password(name) {
revealElement.attr("src", imagesPath + "eye_show.png");
}
}
/**
* Returns html img group icon.
* @param {int} $id_group
*/
function getGroupIcon(id_group, img_container) {
$.ajax({
type: "POST",
url: "ajax.php",
dataType: "json",
data: {
page: "godmode/groups/group_list",
get_group_json: 1,
id_group: id_group
},
success: function(data) {
img_container.attr("src", "images/groups_small/" + data["icon"] + ".png");
},
error: function() {
img_container.attr("src", "");
}
});
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -338,22 +338,6 @@ class AgentModuleWidget extends Widget
)
);
if (is_metaconsole() === true) {
$values['mModules'] = implode(
SEPARATOR_META_MODULE,
array_reduce(
$values['mModules'],
function ($carry, $item) {
$d = explode('|', $item);
$carry[] = (isset($d[1]) === true) ? $d[1] : $item;
return $carry;
},
[]
)
);
}
return $values;
}
@ -670,64 +654,34 @@ class AgentModuleWidget extends Widget
return $output;
}
// Extract info all modules selected.
$target_modules = $this->values['mModules'];
if (is_metaconsole() === true) {
$target_modules = explode(
SEPARATOR_META_MODULE,
$this->values['mModules']
);
$reduceAllModules = array_reduce(
$this->values['mModules'],
function ($carry, $item) {
if ($item === null) {
return $carry;
}
$all_modules = $target_modules;
} else {
if (is_array($target_modules) === true
|| is_numeric($target_modules) === true
) {
$target_modules = array_reduce(
$target_modules,
function ($carry, $item) {
$carry[] = io_safe_output($item);
return $carry;
if (is_metaconsole() === true) {
$item = explode('|', $item);
$serverId = $item[0];
$fullname = $item[1];
if ($this->values['mShowCommonModules'] !== 'on') {
$item = explode('&#x20;&raquo;&#x20;', $fullname);
$name = $item[1];
$carry['modules_selected'][$serverId][$name] = null;
$carry['modules'][$name] = null;
} else {
$carry['modules'][$fullname] = null;
}
);
} else {
$carry['modules'][$item] = null;
}
$all_modules = Module::search(
['nombre' => $target_modules]
);
} else {
// From previous definitions.
$all_modules = Module::search(
['id_agente_modulo' => explode(',', $target_modules)]
);
return $carry;
}
}
if ($all_modules !== null) {
if (is_metaconsole() === true
&& $this->values['mShowCommonModules'] === '1'
) {
$reduceAllModules = [];
} else {
$reduceAllModules = array_reduce(
$all_modules,
function ($carry, $item) {
if ($item === null) {
return $carry;
}
if (is_object($item) === true) {
$carry[$item->name()] = null;
} else {
$carry[io_safe_output($item)] = null;
}
return $carry;
}
);
}
}
);
$allModules = $reduceAllModules['modules'];
$visualData = [];
// Extract info agents selected.
$target_agents = explode(',', $this->values['mAgents']);
@ -754,54 +708,33 @@ class AgentModuleWidget extends Widget
$visualData[$agent_id]['agent_alias'] = $agent->alias();
$visualData[$agent_id]['modules'] = [];
if (is_metaconsole() === true
&& $this->values['mShowCommonModules'] === '1'
) {
// MC should connect to nodes and retrieve information
// 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(
['nombre' => array_keys($tmpModules)]
);
foreach ($modules as $module) {
if ($module === null) {
$reduceAllModules[] = null;
} else {
$reduceAllModules[$module->name()] = null;
}
}
} else {
if (empty($reduceAllModules) === false) {
if (empty($allModules) === false) {
if (is_metaconsole() === true && $this->values['mShowCommonModules'] !== 'on') {
$modules = $agent->searchModules(
['nombre' => array_keys($reduceAllModules)]
['nombre' => array_keys($reduceAllModules['modules_selected'][$tserver])]
);
} else {
$modules = $agent->searchModules(
['nombre' => array_keys($allModules)]
);
}
}
$visualData[$agent_id]['modules'] = $reduceAllModules;
$visualData[$agent_id]['modules'] = $allModules;
foreach ($modules as $module) {
if ($module === null) {
continue;
}
$key_name_module = $module->name();
if ($this->values['mTypeShow'] === '1') {
$mod = $module->toArray();
$mod['datos'] = $module->lastValue();
$module_last_value = modules_get_agentmodule_data_for_humans($mod);
$visualData[$agent_id]['modules'][$module->name()] = $module_last_value;
$visualData[$agent_id]['modules'][$key_name_module] = $module_last_value;
} else {
$visualData[$agent_id]['modules'][$module->name()] = $module->getStatus()->estado();
$visualData[$agent_id]['modules'][$key_name_module] = $module->getStatus()->estado();
}
}
@ -813,17 +746,9 @@ class AgentModuleWidget extends Widget
}
}
if (empty($reduceAllModules) === false) {
$allModules = array_keys($reduceAllModules);
}
if ($allModules === null) {
$allModules = [];
}
$output = $this->generateViewAgentModule(
$visualData,
$allModules
array_keys($allModules)
);
return $output;

View File

@ -328,7 +328,7 @@ class ServiceMapWidget extends Widget
];
$inputs[] = [
'label' => __('Enable sunburst'),
'label' => __('Show sunburst by default'),
'arguments' => [
'type' => 'switch',
'name' => 'sunburst',

View File

@ -749,6 +749,10 @@ class Module extends Entity
$updates = $this->fields;
$updates['id_tipo_modulo'] = $this->moduleType()->id_tipo();
if (empty($updates['debug_content']) === false) {
$updates['debug_content'] = str_replace("'", '"', $updates['debug_content']);
}
// In the case of the webserver modules, debug_content special characters must be handled.
if ($updates['id_tipo_modulo'] >= MODULE_TYPE_WEB_ANALYSIS
&& $updates['id_tipo_modulo'] <= MODULE_TYPE_WEB_CONTENT_STRING

View File

@ -396,3 +396,59 @@ div.multi-response-buttons {
.white_table_graph_header {
align-items: center;
}
.container-massive-events-response {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: flex-start;
}
.container-massive-events-response-cell {
margin-bottom: 10px;
width: 100%;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-content: flex-start;
}
.container-massive-events-response-command > span {
font-style: italic;
}
.container-massive-events-response-output {
/*border: 2px dashed #ddd;*/
/*padding: 10px;*/
margin: 10px;
}
.container-massive-events-response-execute {
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
}
#massive-parameters-response {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
#massive-parameters-response > div {
width: 80%;
}
#massive-parameters-response > div h5 {
text-align: center;
}
#massive-parameters-response > div div {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
margin-bottom: 5px;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -323,7 +323,7 @@ if (isset($config['id_user']) === false) {
$userIP,
$nick
),
$userIP
$nick
);
while (ob_get_length() > 0) {
ob_end_flush();

File diff suppressed because it is too large Load Diff

View File

@ -128,8 +128,8 @@
</div>
<div style='height: 10px'>
<?php
$version = '7.0NG.764';
$build = '220929';
$version = '7.0NG.765';
$build = '221018';
$banner = "v$version Build $build";
error_reporting(0);

View File

@ -28,7 +28,7 @@
global $config;
// Login check
// Login check.
check_login();
if (is_ajax()) {
@ -37,7 +37,7 @@ if (is_ajax()) {
$get_alert_fired = get_parameter('get_alert_fired', 0);
if ($get_alert_fired) {
// Calculate alerts fired
// Calculate alerts fired.
$data_reporting = reporting_get_group_stats();
echo $data_reporting['monitor_alerts_fired'];
}

View File

@ -564,7 +564,10 @@ for ($i = 0; $i < $custom_fields_count; $i++) {
$columns = array_merge($first_column, $second_column);
} else {
$columns = $first_column;
$filas = count($table_data->data);
if ($table_data->data !== null) {
$filas = count($table_data->data);
}
$table_data->colspan[$filas][1] = 3;
}

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