Merge branch 'ent-9592-Problema-de-seguridad-con-la-gestion-de-sesiones-Limited-Authentication-bypass-in-ajax-php' of brutus.artica.es:artica/pandorafms into ent-9592-Problema-de-seguridad-con-la-gestion-de-sesiones-Limited-Authentication-bypass-in-ajax-php
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
# ==================
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
# ==================
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
# ==================
|
||||
|
@ -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
|
||||
|
@ -1,5 +1,5 @@
|
||||
package: pandorafms-agent-unix
|
||||
Version: 7.0NG.764-220926
|
||||
Version: 7.0NG.765-221018
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
@ -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-220926"
|
||||
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
|
||||
|
@ -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
|
||||
|
@ -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[
|
||||
|
@ -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>
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
@ -165,9 +165,15 @@ remote_config 0
|
||||
# should consider changing the temporal directory, since /tmp is world writable.
|
||||
xml_buffer 1
|
||||
|
||||
# Minimum available bytes in the temporal directory to enable the XML buffer
|
||||
# Minimum available megabytes in the temporal directory to enable the XML buffer
|
||||
temporal_min_size 1024
|
||||
|
||||
# Maximum size (in megabytes) allowed for the XML buffer.
|
||||
temporal_max_size 1024
|
||||
|
||||
# Maximum number of files allowed for the XML buffer.
|
||||
temporal_max_files 1024
|
||||
|
||||
# Agent mode: Learn (default), No-learn, Autodisable
|
||||
# agent_mode autodisable
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 => '220926';
|
||||
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;
|
||||
@ -1145,7 +1145,9 @@ my %DefaultConf = (
|
||||
'secondary_server_opts' => '',
|
||||
'secondary_temporal' => '/var/spool/pandora',
|
||||
'autotime' => 0,
|
||||
'temporal_min_size' => 1,
|
||||
'temporal_min_size' => 1024,
|
||||
'temporal_max_files' => 1024,
|
||||
'temporal_max_size' => 1024,
|
||||
'timezone_offset' => 0,
|
||||
'pandora_exec' => 'pandora_agent_exec',
|
||||
'agent_threads' => 1,
|
||||
@ -2110,13 +2112,13 @@ sub send_xml_file ($) {
|
||||
swap_servers();
|
||||
|
||||
# Secondary buffer.
|
||||
if ($rc_sec != 0 && $Conf{'xml_buffer'} == 1 && temporal_freedisk () > $Conf{'temporal_min_size'}) {
|
||||
if ($rc_sec != 0 && write_to_buffer($Conf{'secondary_temporal'}) == 1) {
|
||||
copy($file, $Conf{'secondary_temporal'}) || die("Error copying file $file to " . $Conf{'secondary_temporal'} . ": $!");
|
||||
}
|
||||
}
|
||||
|
||||
# Primary buffer.
|
||||
if ($rc == 0 || $Conf{'xml_buffer'} == 0 || temporal_freedisk () <= $Conf{'temporal_min_size'}) {
|
||||
if ($rc == 0 || write_to_buffer($Conf{'temporal'}) == 0) {
|
||||
if ($Conf{'debug'} eq '1') {
|
||||
rename($file, $file . "sent");
|
||||
} else {
|
||||
@ -3761,20 +3763,45 @@ sub kill_signal_handler (){
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Get the free disk space in the temporal directory (in bytes).
|
||||
# Get the free disk space in the temporal directory (in megabytes).
|
||||
################################################################################
|
||||
sub temporal_freedisk () {
|
||||
sub temporal_freedisk {
|
||||
my ($temporal) = @_;
|
||||
|
||||
# Call df
|
||||
return 0 unless defined (DF_CMDS->{$OS});
|
||||
my $cmd = DF_CMDS->{$OS} . ' ' . $Conf{'temporal'} . ' | awk \'NR > 1 {print $4}\'';
|
||||
my $cmd = DF_CMDS->{$OS} . ' ' . $temporal . ' | awk \'NR > 1 {print $4}\'';
|
||||
my $temporal_freedisk = `$cmd`;
|
||||
|
||||
# Check for errors
|
||||
return 0 unless ($? eq 0);
|
||||
|
||||
# Convert to bytes
|
||||
return 1024 * int ($temporal_freedisk);
|
||||
# Convert from KB to MB.
|
||||
return $temporal_freedisk / 1024;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Return the number of data files in the temporal directory and their total
|
||||
# size (in megabytes).
|
||||
################################################################################
|
||||
sub temporal_stats {
|
||||
my ($temporal) = @_;
|
||||
|
||||
my $file_count = 0;
|
||||
my $file_size = 0;
|
||||
opendir(my $dir, $temporal) or die($!);
|
||||
while (my $f = readdir($dir)) {
|
||||
if ($f =~ m/.data$/ || $f =~ m/.datasent$/) {
|
||||
$file_count += 1;
|
||||
$file_size += (stat $temporal . '/' . $f)[7];
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
|
||||
# Convert from B to MB.
|
||||
$file_size /= 1048576;
|
||||
|
||||
return ($file_count, $file_size);
|
||||
}
|
||||
|
||||
################################################################################
|
||||
@ -3960,6 +3987,27 @@ sub get_ehkey {
|
||||
return '';
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Return 1 if XML files should be written to the buffer. 0 otherwise.
|
||||
################################################################################
|
||||
sub write_to_buffer {
|
||||
my ($temporal) = @_;
|
||||
|
||||
# The XML buffer is disabled.
|
||||
return 0 if ($Conf{'xml_buffer'} == 0);
|
||||
|
||||
# Check available disk space.
|
||||
return 0 if ($Conf{'temporal_min_size'} != 0 && temporal_freedisk($temporal) < $Conf{'temporal_min_size'});
|
||||
|
||||
# Check buffer file count and size limits.
|
||||
my ($file_count, $file_size) = temporal_stats($temporal);
|
||||
return 0 if ($Conf{'temporal_max_files'} != 0 && $file_count > $Conf{'temporal_max_files'});
|
||||
return 0 if ($Conf{'temporal_max_size'} != 0 && $file_size > $Conf{'temporal_max_size'});
|
||||
|
||||
# It's OK to write to the buffer.
|
||||
return 1;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Main.
|
||||
################################################################################
|
||||
|
@ -2,8 +2,8 @@
|
||||
#Pandora FMS Linux Agent
|
||||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.764
|
||||
%define release 220926
|
||||
%define version 7.0NG.765
|
||||
%define release 221018
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
@ -2,8 +2,8 @@
|
||||
#Pandora FMS Linux Agent
|
||||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.764
|
||||
%define release 220926
|
||||
%define version 7.0NG.765
|
||||
%define release 221018
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
@ -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="220926"
|
||||
PI_VERSION="7.0NG.765"
|
||||
PI_BUILD="221018"
|
||||
OS_NAME=`uname -s`
|
||||
|
||||
FORCE=0
|
||||
|
@ -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
|
||||
@ -55,9 +55,15 @@ address auto
|
||||
# or setting a fixed IP address, like for example:
|
||||
#address 192.168.36.73
|
||||
|
||||
# This limits operation if temporal dir has not enough free disk.
|
||||
# This limits operation if temporal dir has not enough free disk (in megabytes).
|
||||
#temporal_min_size 1024
|
||||
|
||||
# Maximum size (in megabytes) allowed for the XML buffer.
|
||||
temporal_max_size 1024
|
||||
|
||||
# Maximum number of files allowed for the XML buffer.
|
||||
temporal_max_files 1024
|
||||
|
||||
# Delay start execution X second before start to monitoring nothing
|
||||
#startup_delay 30
|
||||
|
||||
|
@ -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
|
||||
{220926}
|
||||
{221018}
|
||||
|
||||
ViewReadme
|
||||
{Yes}
|
||||
|
@ -30,7 +30,7 @@ using namespace Pandora;
|
||||
using namespace Pandora_Strutils;
|
||||
|
||||
#define PATH_SIZE _MAX_PATH+1
|
||||
#define PANDORA_VERSION ("7.0NG.764 Build 220926")
|
||||
#define PANDORA_VERSION ("7.0NG.765 Build 221018")
|
||||
|
||||
string pandora_path;
|
||||
string pandora_dir;
|
||||
|
@ -1696,7 +1696,7 @@ Pandora_Windows_Service::checkConfig (string file) {
|
||||
|
||||
int
|
||||
Pandora_Windows_Service::sendXml (Pandora_Module_List *modules, string extra /* = ""*/) {
|
||||
int rc = 0, rc_sec = 0, xml_buffer;
|
||||
int rc = 0, rc_sec = 0, xml_buffer;
|
||||
string data_xml;
|
||||
string xml_filename, random_integer;
|
||||
string tmp_filename, tmp_filepath;
|
||||
@ -1705,12 +1705,10 @@ Pandora_Windows_Service::sendXml (Pandora_Module_List *modules, string extra /*
|
||||
string ehorus_conf, eh_key;
|
||||
static HANDLE mutex = 0;
|
||||
ULARGE_INTEGER free_bytes;
|
||||
double min_free_bytes = 0;
|
||||
Pandora_Agent_Conf *conf = NULL;
|
||||
FILE *conf_fh = NULL;
|
||||
|
||||
conf = this->getConf ();
|
||||
min_free_bytes = 1024 * atoi (conf->getValue ("temporal_min_size").c_str ());
|
||||
xml_buffer = atoi (conf->getValue ("xml_buffer").c_str ());
|
||||
|
||||
if (mutex == 0) {
|
||||
@ -1814,14 +1812,14 @@ Pandora_Windows_Service::sendXml (Pandora_Module_List *modules, string extra /*
|
||||
rc_sec = this->copyToSecondary (tmp_filename, false);
|
||||
|
||||
/* Secondary buffer. */
|
||||
if (rc_sec != 0 && xml_buffer == 1 && (GetDiskFreeSpaceEx (conf->getValue ("secondary_temporal").c_str (), &free_bytes, NULL, NULL) != 0 && free_bytes.QuadPart >= min_free_bytes)) {
|
||||
if (rc_sec != 0 && this->writeToBuffer(conf->getValue ("secondary_temporal").c_str ())) {
|
||||
secondary_filepath = conf->getValue ("secondary_temporal") + "\\" + tmp_filename;
|
||||
CopyFile (tmp_filepath.c_str(), secondary_filepath.c_str(), false);
|
||||
}
|
||||
}
|
||||
|
||||
/* Primary buffer. Delete the file if successfully copied, buffer disabled or not enough space available. */
|
||||
if (rc == 0 || xml_buffer == 0 || (GetDiskFreeSpaceEx (tmp_filepath.c_str (), &free_bytes, NULL, NULL) != 0 && free_bytes.QuadPart < min_free_bytes)) {
|
||||
if (rc == 0 || !writeToBuffer(conf->getValue ("temporal").c_str ())) {
|
||||
/* Rename the file if debug mode is enabled*/
|
||||
if (getPandoraDebug ()) {
|
||||
string tmp_filepath_sent = tmp_filepath;
|
||||
@ -2218,3 +2216,60 @@ Pandora_Windows_Service::generateAgentName () {
|
||||
sha256(data.str().c_str(), digest);
|
||||
return std::string(digest);
|
||||
}
|
||||
|
||||
bool
|
||||
Pandora_Windows_Service::writeToBuffer (string temporal) {
|
||||
int xml_buffer;
|
||||
long int temporal_max_files;
|
||||
double temporal_min_size, temporal_max_size;
|
||||
string dir, file_name;
|
||||
ULARGE_INTEGER free_bytes;
|
||||
Pandora_Agent_Conf *conf = NULL;
|
||||
|
||||
conf = this->getConf ();
|
||||
|
||||
dir = temporal;
|
||||
if (dir[dir.length () - 1] != '\\') {
|
||||
dir += "\\";
|
||||
}
|
||||
file_name = dir + "*.data";
|
||||
|
||||
// Is the XML buffer disabled?
|
||||
xml_buffer = atoi (conf->getValue ("xml_buffer").c_str ());
|
||||
if (xml_buffer == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check available disk space.
|
||||
temporal_min_size = atoi (conf->getValue ("temporal_min_size").c_str ());
|
||||
if (GetDiskFreeSpaceEx (dir.c_str (), &free_bytes, NULL, NULL) && (free_bytes.QuadPart / 1048576) < temporal_min_size) { // Convert free_bytes.QuadPart from B to MB.
|
||||
pandoraLog ("[writeToBuffer] Disk full.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check buffer file count and size limits.
|
||||
temporal_max_size = atoi (conf->getValue ("temporal_max_size").c_str ());
|
||||
temporal_max_files = atol (conf->getValue ("temporal_max_files").c_str ());
|
||||
if (temporal_max_size != 0 || temporal_max_files != 0) {
|
||||
long int file_count = 0;
|
||||
ULONGLONG file_size = 0;
|
||||
HANDLE hFind;
|
||||
WIN32_FIND_DATA FindFileData;
|
||||
if ((hFind = FindFirstFile(file_name.c_str(), &FindFileData)) != INVALID_HANDLE_VALUE) {
|
||||
do {
|
||||
file_count += 1;
|
||||
file_size += (FindFileData.nFileSizeHigh * (MAXDWORD + 1)) + FindFileData.nFileSizeLow;
|
||||
} while (FindNextFile(hFind, &FindFileData));
|
||||
FindClose(hFind);
|
||||
}
|
||||
|
||||
file_size /= 1048576; // Convert from B to MB.
|
||||
if ((temporal_max_size != 0 && file_size > temporal_max_size) ||
|
||||
(temporal_max_files != 0 && file_count > temporal_max_files)) {
|
||||
pandoraLog ("[writeToBuffer] Too many files or buffer full.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -124,6 +124,7 @@ namespace Pandora {
|
||||
long getInterval ();
|
||||
long getIntensiveInterval ();
|
||||
string generateAgentName ();
|
||||
bool writeToBuffer (string temporal);
|
||||
|
||||
};
|
||||
}
|
||||
|
@ -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 220926))"
|
||||
VALUE "ProductVersion", "(7.0NG.765(Build 221018))"
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
END
|
||||
END
|
||||
|
@ -1,5 +1,5 @@
|
||||
package: pandorafms-console
|
||||
Version: 7.0NG.764-220926
|
||||
Version: 7.0NG.765-221018
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
@ -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-220926"
|
||||
pandora_version="7.0NG.765-221018"
|
||||
|
||||
package_pear=0
|
||||
package_pandora=1
|
||||
|
@ -2,4 +2,7 @@ START TRANSACTION;
|
||||
|
||||
ALTER TABLE `tusuario` ADD COLUMN `auth_token_secret` VARCHAR(45) DEFAULT NULL;
|
||||
|
||||
COMMIT;
|
||||
ALTER TABLE `tmodule_inventory` ADD COLUMN `script_mode` INT NOT NULL DEFAULT 2;
|
||||
ALTER TABLE `tmodule_inventory` ADD COLUMN `script_path` VARCHAR(1000) DEFAULT '';
|
||||
|
||||
COMMIT;
|
||||
|
@ -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
|
||||
|
@ -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('`', '‘', (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);
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -15,6 +15,7 @@
|
||||
global $config;
|
||||
|
||||
require_once $config['homedir'].'/include/functions_alerts.php';
|
||||
require_once $config['homedir'].'/include/functions_reports.php';
|
||||
enterprise_include_once('meta/include/functions_alerts_meta.php');
|
||||
|
||||
check_login();
|
||||
@ -349,9 +350,94 @@ if (is_ajax()) {
|
||||
);
|
||||
} else {
|
||||
$fields_value_select = [];
|
||||
$fv = explode(';', $field_value);
|
||||
$force_print_select = false;
|
||||
|
||||
if (count($fv) > 1) {
|
||||
// Exception for dynamically filled select boxes.
|
||||
if (preg_match('/^_reports_$/i', $field_value)) {
|
||||
// Filter normal and metaconsole reports.
|
||||
if (is_metaconsole() === true) {
|
||||
$filter['metaconsole'] = 1;
|
||||
} else {
|
||||
$filter['metaconsole'] = 0;
|
||||
}
|
||||
|
||||
$own_info = get_user_info($config['id_user']);
|
||||
if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'RM') || check_acl($config['id_user'], 0, 'RR')) {
|
||||
$return_all_group = true;
|
||||
} else {
|
||||
$return_all_group = false;
|
||||
}
|
||||
|
||||
if (is_user_admin($config['id_user']) === false) {
|
||||
$filter[] = sprintf(
|
||||
'private = 0 OR (private = 1 AND id_user = "%s")',
|
||||
$config['id_user']
|
||||
);
|
||||
}
|
||||
|
||||
$reports = reports_get_reports(
|
||||
$filter,
|
||||
[
|
||||
'name',
|
||||
'id_report',
|
||||
],
|
||||
$return_all_group,
|
||||
'RR'
|
||||
);
|
||||
|
||||
$fv = array_map(
|
||||
function ($report) {
|
||||
return $report['id_report'].','.$report['name'];
|
||||
},
|
||||
$reports
|
||||
);
|
||||
|
||||
$force_print_select = true;
|
||||
} else if (preg_match('/^_report_templates_$/i', $field_value)) {
|
||||
// Filter normal and metaconsole reports.
|
||||
if (is_metaconsole() === true) {
|
||||
$filter['metaconsole'] = 1;
|
||||
} else {
|
||||
$filter['metaconsole'] = 0;
|
||||
}
|
||||
|
||||
$own_info = get_user_info($config['id_user']);
|
||||
if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'RM') || check_acl($config['id_user'], 0, 'RR')) {
|
||||
$return_all_group = true;
|
||||
} else {
|
||||
$return_all_group = false;
|
||||
}
|
||||
|
||||
if (is_user_admin($config['id_user']) === false) {
|
||||
$filter[] = sprintf(
|
||||
'private = 0 OR (private = 1 AND id_user = "%s")',
|
||||
$config['id_user']
|
||||
);
|
||||
}
|
||||
|
||||
$templates = reports_get_report_templates(
|
||||
$filter,
|
||||
[
|
||||
'name',
|
||||
'id_report',
|
||||
],
|
||||
$return_all_group,
|
||||
'RR'
|
||||
);
|
||||
|
||||
$fv = array_map(
|
||||
function ($template) {
|
||||
return $template['id_report'].','.$template['name'];
|
||||
},
|
||||
$templates
|
||||
);
|
||||
|
||||
$force_print_select = true;
|
||||
} else {
|
||||
$fv = explode(';', $field_value);
|
||||
}
|
||||
|
||||
if (count($fv) > 1 || $force_print_select === true) {
|
||||
if (!empty($fv)) {
|
||||
foreach ($fv as $fv_option) {
|
||||
$fv_option = explode(',', $fv_option);
|
||||
|
@ -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(
|
||||
|
@ -881,14 +881,16 @@ if (($create != '') || ($view != '')) {
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
).'</a> ';
|
||||
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>';
|
||||
}
|
||||
|
@ -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',
|
||||
|
@ -59,6 +59,8 @@ if (is_metaconsole()) {
|
||||
enterprise_include_once('include/functions_license.php');
|
||||
}
|
||||
|
||||
enterprise_include_once('include/functions_crypto.php');
|
||||
|
||||
if ($renew_license_result !== null) {
|
||||
echo $renew_license_result;
|
||||
}
|
||||
@ -74,8 +76,32 @@ if ($update_settings) {
|
||||
);
|
||||
}
|
||||
|
||||
$customer_key = $_POST['keys']['customer_key'];
|
||||
|
||||
$license_encryption_key = get_parameter('license_encryption_key', '');
|
||||
$check = db_get_value_sql('SELECT `key` FROM tupdate_settings WHERE `key` LIKE "license_encryption_key"');
|
||||
if ($check === false) {
|
||||
db_process_sql_insert(
|
||||
'tupdate_settings',
|
||||
[
|
||||
db_escape_key_identifier('value') => $license_encryption_key,
|
||||
db_escape_key_identifier('key') => 'license_encryption_key',
|
||||
]
|
||||
);
|
||||
} else {
|
||||
db_process_sql_update(
|
||||
'tupdate_settings',
|
||||
[db_escape_key_identifier('value') => $license_encryption_key],
|
||||
[db_escape_key_identifier('key') => 'license_encryption_key']
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($license_encryption_key) === false) {
|
||||
$customer_key = openssl_blowfish_encrypt_hex($customer_key, io_safe_output($license_encryption_key));
|
||||
}
|
||||
|
||||
// Update the license file.
|
||||
$result = file_put_contents($config['remote_config'].'/'.LICENSE_FILE, $_POST['keys']['customer_key']);
|
||||
$result = file_put_contents($config['remote_config'].'/'.LICENSE_FILE, $customer_key);
|
||||
if ($result === false) {
|
||||
ui_print_error_message(__('Failed to Update license file'));
|
||||
}
|
||||
@ -153,8 +179,24 @@ $table->data[7][1] = html_print_input_text('expires', ($license['nms'] == 1 ? __
|
||||
$table->data[8][0] = '<strong>'.__('Satellite').'</strong>';
|
||||
$table->data[8][1] = html_print_input_text('expires', ($license['dhpm'] == 1 ? __('enabled') : __('disabled')), '', 10, 255, true, true);
|
||||
|
||||
$table->data[9][0] = '<strong>'.__('Licensed to').'</strong>';
|
||||
$table->data[9][1] = html_print_input_text('licensed_to', $license['licensed_to'], '', 64, 255, true, true);
|
||||
if ($license['dhpm'] == 1) {
|
||||
$table->data[9][0] = '<strong>'.__('License encryption key').'</strong>'.ui_print_help_tip(
|
||||
__('This key is used to encrypt your Pandora FMS license when it is shared with other Pandora FMS components'),
|
||||
true
|
||||
);
|
||||
$table->data[9][1] = html_print_input_password(
|
||||
'license_encryption_key',
|
||||
io_safe_output($settings->license_encryption_key),
|
||||
'',
|
||||
10,
|
||||
255,
|
||||
true,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
$table->data[10][0] = '<strong>'.__('Licensed to').'</strong>';
|
||||
$table->data[10][1] = html_print_input_text('licensed_to', $license['licensed_to'], '', 64, 255, true, true);
|
||||
|
||||
html_print_table($table);
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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>
|
||||
|
@ -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();
|
||||
|
||||
|
BIN
pandora_console/images/console/icons/europemap_bad.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
pandora_console/images/console/icons/europemap_ok.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
pandora_console/images/console/icons/europemap_warning.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
pandora_console/images/console/icons/spainmap_bad.png
Normal file
After Width: | Height: | Size: 9.0 KiB |
BIN
pandora_console/images/console/icons/spainmap_ok.png
Normal file
After Width: | Height: | Size: 9.1 KiB |
BIN
pandora_console/images/console/icons/spainmap_warning.png
Normal file
After Width: | Height: | Size: 8.9 KiB |
BIN
pandora_console/images/console/icons/worldmap_bad.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
pandora_console/images/console/icons/worldmap_ok.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
pandora_console/images/console/icons/worldmap_warning.png
Normal file
After Width: | Height: | Size: 14 KiB |
@ -647,7 +647,12 @@ if ($get_agent_alerts_datatable === true) {
|
||||
$order = get_datatable_order(true);
|
||||
$url = get_parameter('url', '#');
|
||||
|
||||
$free_search_alert = $filter_alert['free_search_alert'];
|
||||
if (empty($filter_alert['free_search']) === false) {
|
||||
$free_search_alert = $filter_alert['free_search'];
|
||||
} else {
|
||||
$free_search_alert = $filter_alert['free_search_alert'];
|
||||
}
|
||||
|
||||
$idGroup = $filter_alert['ag_group'];
|
||||
$tag_filter = $filter_alert['tag_filter'];
|
||||
$action_filter = $filter_alert['action'];
|
||||
@ -676,7 +681,7 @@ if ($get_agent_alerts_datatable === true) {
|
||||
$selectLastFiredDown = false;
|
||||
|
||||
switch ($sortField) {
|
||||
case 'module':
|
||||
case 'agent_module_name':
|
||||
switch ($sort) {
|
||||
case 'asc':
|
||||
$selectModuleasc = $selected;
|
||||
@ -696,7 +701,7 @@ if ($get_agent_alerts_datatable === true) {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'template':
|
||||
case 'template_name':
|
||||
switch ($sort) {
|
||||
case 'asc':
|
||||
$selectTemplateasc = $selected;
|
||||
@ -736,7 +741,7 @@ if ($get_agent_alerts_datatable === true) {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'agent':
|
||||
case 'agent_name':
|
||||
switch ($sort) {
|
||||
case 'asc':
|
||||
$selectLastFiredasc = $selected;
|
||||
@ -857,7 +862,7 @@ if ($get_agent_alerts_datatable === true) {
|
||||
if (is_metaconsole() === true) {
|
||||
include_once $config['homedir'].'/enterprise/meta/include/functions_alerts_meta.php';
|
||||
if ($idAgent != 0) {
|
||||
$alerts['alerts_simple'] = alerts_meta_get_alerts($agents, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter);
|
||||
$alerts['alerts_simple'] = alerts_meta_get_alerts($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter);
|
||||
|
||||
$countAlertsSimple = alerts_meta_get_alerts($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter);
|
||||
} else {
|
||||
@ -865,7 +870,7 @@ if ($get_agent_alerts_datatable === true) {
|
||||
users_get_groups($config['id_user'], 'AR', false)
|
||||
);
|
||||
|
||||
$alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter);
|
||||
$alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter);
|
||||
|
||||
$countAlertsSimple = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter);
|
||||
}
|
||||
@ -885,12 +890,32 @@ if ($get_agent_alerts_datatable === true) {
|
||||
}
|
||||
}
|
||||
|
||||
// Order and pagination metacosole.
|
||||
if (is_metaconsole() === true) {
|
||||
// Status order.
|
||||
if ($sortField === 'status') {
|
||||
foreach ($alerts['alerts_simple'] as $i => $alert) {
|
||||
if ($alert['times_fired'] > 0) {
|
||||
$alerts['alerts_simple'][$i]['status'] = '3';
|
||||
} else if ($alert['disabled'] > 0) {
|
||||
$alerts['alerts_simple'][$i]['status'] = '1';
|
||||
} else {
|
||||
$alerts['alerts_simple'][$i]['status'] = '2';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
usort($alerts['alerts_simple'], arrayOutputSorting($sort, $sortField));
|
||||
$alerts['alerts_simple'] = array_slice($alerts['alerts_simple'], $start, $length);
|
||||
}
|
||||
|
||||
$data = [];
|
||||
if ($alerts['alerts_simple']) {
|
||||
foreach ($alerts['alerts_simple'] as $alert) {
|
||||
$data[] = ui_format_alert_row($alert, true, $url, 'font-size: 7pt;');
|
||||
}
|
||||
|
||||
|
||||
$data = array_reduce(
|
||||
$data,
|
||||
function ($carry, $row) {
|
||||
@ -902,11 +927,11 @@ if ($get_agent_alerts_datatable === true) {
|
||||
$tmp->policy = $row[0];
|
||||
$tmp->standby = $row[1];
|
||||
$tmp->force = $row[2];
|
||||
$tmp->agent = $row[3];
|
||||
$tmp->module = $row[4];
|
||||
$tmp->template = $row[5];
|
||||
$tmp->agent_name = $row[3];
|
||||
$tmp->agent_module_name = $row[4];
|
||||
$tmp->template_name = $row[5];
|
||||
$tmp->action = $row[6];
|
||||
$tmp->lastFired = $row[7];
|
||||
$tmp->last_fired = $row[7];
|
||||
$tmp->status = $row[8];
|
||||
$tmp->validate = $row[9];
|
||||
|
||||
@ -916,6 +941,7 @@ if ($get_agent_alerts_datatable === true) {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Datatables format: RecordsTotal && recordsfiltered.
|
||||
echo json_encode(
|
||||
[
|
||||
|
@ -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);
|
||||
@ -372,8 +372,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(
|
||||
@ -430,7 +430,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"]') {
|
||||
@ -1054,87 +1054,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';
|
||||
@ -1142,62 +1061,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
|
||||
@ -1206,20 +1090,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.
|
||||
@ -1237,10 +1113,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
|
||||
@ -1320,7 +1316,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) {
|
||||
@ -1343,78 +1339,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':
|
||||
@ -2534,3 +2471,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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
';
|
||||
|
@ -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">';
|
||||
|
@ -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.
|
||||
|
@ -20,8 +20,8 @@
|
||||
/**
|
||||
* Pandora build version and version
|
||||
*/
|
||||
$build_version = 'PC220926';
|
||||
$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();
|
||||
|
@ -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';
|
||||
}
|
||||
|
||||
|
@ -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]);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -1381,7 +1381,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.
|
||||
@ -1472,7 +1472,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);
|
||||
}
|
||||
@ -1486,6 +1485,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
|
||||
@ -1494,6 +1495,15 @@ function events_get_all(
|
||||
MAX(id_evento) as max_id_evento',
|
||||
($idx !== false) ? 'GROUP_CONCAT(DISTINCT user_comment SEPARATOR "<br>") AS comments,' : ''
|
||||
);
|
||||
|
||||
$group_selects_trans = sprintf(
|
||||
',tmax_event.event_rep,
|
||||
%s
|
||||
tmax_event.timestamp_last,
|
||||
tmax_event.timestamp_first,
|
||||
tmax_event.max_id_evento',
|
||||
($idx !== false) ? 'tmax_event.comments,' : ''
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$idx = array_search('te.user_comment', $fields);
|
||||
@ -1502,43 +1512,107 @@ function events_get_all(
|
||||
}
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
'SELECT %s
|
||||
if ((int) $filter['group_rep'] === 1 && $count === false) {
|
||||
$sql = sprintf(
|
||||
'SELECT %s
|
||||
%s
|
||||
FROM %s
|
||||
INNER JOIN (
|
||||
SELECT te.id_evento %s
|
||||
FROM %s
|
||||
%s
|
||||
%s
|
||||
%s JOIN %s ta
|
||||
ON ta.%s = te.id_agente
|
||||
%s
|
||||
%s
|
||||
%s JOIN tgrupo tg
|
||||
ON %s
|
||||
WHERE 1=1
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
) tmax_event
|
||||
ON te.id_evento = tmax_event.max_id_evento
|
||||
%s
|
||||
FROM %s
|
||||
%s
|
||||
%s
|
||||
%s JOIN %s ta
|
||||
ON ta.%s = te.id_agente
|
||||
%s
|
||||
%s
|
||||
%s JOIN tgrupo tg
|
||||
ON %s
|
||||
WHERE 1=1
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
',
|
||||
join(',', $fields),
|
||||
$group_selects,
|
||||
$tevento,
|
||||
$event_lj,
|
||||
$agentmodule_join,
|
||||
$tagente_join,
|
||||
$tagente_table,
|
||||
$tagente_field,
|
||||
$conditionMetaconsole,
|
||||
join(' ', $agent_join_filters),
|
||||
$tgrupo_join,
|
||||
join(' ', $tgrupo_join_filters),
|
||||
join(' ', $sql_filters),
|
||||
$group_by,
|
||||
$order_by,
|
||||
$pagination,
|
||||
$having
|
||||
);
|
||||
%s
|
||||
%s JOIN %s ta
|
||||
ON ta.%s = te.id_agente
|
||||
%s
|
||||
%s
|
||||
%s JOIN tgrupo tg
|
||||
ON %s',
|
||||
join(',', $fields),
|
||||
$group_selects_trans,
|
||||
$tevento,
|
||||
$group_selects,
|
||||
$tevento,
|
||||
$event_lj,
|
||||
$agentmodule_join,
|
||||
$tagente_join,
|
||||
$tagente_table,
|
||||
$tagente_field,
|
||||
$conditionMetaconsole,
|
||||
join(' ', $agent_join_filters),
|
||||
$tgrupo_join,
|
||||
join(' ', $tgrupo_join_filters),
|
||||
join(' ', $sql_filters),
|
||||
$group_by,
|
||||
$order_by,
|
||||
$pagination,
|
||||
$having,
|
||||
$event_lj,
|
||||
$agentmodule_join,
|
||||
$tagente_join,
|
||||
$tagente_table,
|
||||
$tagente_field,
|
||||
$conditionMetaconsole,
|
||||
join(' ', $agent_join_filters),
|
||||
$tgrupo_join,
|
||||
join(' ', $tgrupo_join_filters),
|
||||
join(' ', $sql_filters)
|
||||
);
|
||||
} else {
|
||||
$sql = sprintf(
|
||||
'SELECT %s
|
||||
%s
|
||||
FROM %s
|
||||
%s
|
||||
%s
|
||||
%s JOIN %s ta
|
||||
ON ta.%s = te.id_agente
|
||||
%s
|
||||
%s
|
||||
%s JOIN tgrupo tg
|
||||
ON %s
|
||||
WHERE 1=1
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
',
|
||||
join(',', $fields),
|
||||
$group_selects,
|
||||
$tevento,
|
||||
$event_lj,
|
||||
$agentmodule_join,
|
||||
$tagente_join,
|
||||
$tagente_table,
|
||||
$tagente_field,
|
||||
$conditionMetaconsole,
|
||||
join(' ', $agent_join_filters),
|
||||
$tgrupo_join,
|
||||
join(' ', $tgrupo_join_filters),
|
||||
join(' ', $sql_filters),
|
||||
$group_by,
|
||||
$order_by,
|
||||
$pagination,
|
||||
$having
|
||||
);
|
||||
}
|
||||
|
||||
if ($return_sql === true) {
|
||||
return $sql;
|
||||
@ -1583,7 +1657,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';
|
||||
}
|
||||
@ -1599,14 +1675,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
|
||||
@ -1615,7 +1704,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 = [];
|
||||
}
|
||||
@ -1674,7 +1763,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'
|
||||
@ -1746,7 +1835,7 @@ function events_get_all(
|
||||
}
|
||||
}
|
||||
|
||||
return db_get_all_rows_sql($sql);
|
||||
return db_get_all_rows_sql($sql, $history);
|
||||
}
|
||||
|
||||
|
||||
@ -2005,7 +2094,7 @@ function events_change_owner(
|
||||
events_comment(
|
||||
$id_event,
|
||||
'',
|
||||
'Change owner to '.$new_owner
|
||||
'Change owner to '.get_user_fullname($new_owner).' ('.$new_owner.')'
|
||||
);
|
||||
}
|
||||
|
||||
@ -3211,18 +3300,9 @@ function events_page_responses($event)
|
||||
|
||||
foreach ($users as $u) {
|
||||
$owners[$u['id_user']] = $u['id_user'];
|
||||
}
|
||||
|
||||
if (empty($event['owner_user']) === true) {
|
||||
$owner_name = __('None');
|
||||
} else {
|
||||
$owner_name = db_get_value(
|
||||
'id_user',
|
||||
'tusuario',
|
||||
'id_user',
|
||||
$event['owner_user']
|
||||
);
|
||||
$owners[$event['owner_user']] = $owner_name;
|
||||
if (empty($u['fullname']) === false) {
|
||||
$owners[$u['id_user']] = $u['fullname'].' ('.$u['id_user'].')';
|
||||
}
|
||||
}
|
||||
|
||||
$data[1] = html_print_select(
|
||||
@ -3430,7 +3510,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
|
||||
);
|
||||
@ -3441,27 +3521,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;
|
||||
}
|
||||
@ -3470,14 +3538,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;
|
||||
|
||||
@ -3490,9 +3564,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']];
|
||||
@ -3818,6 +3919,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;
|
||||
}
|
||||
|
||||
@ -4831,7 +4952,7 @@ function events_page_comments($event, $ajax=false, $groupedComments=[])
|
||||
'<b>%s %s %s%s</b>',
|
||||
$c['action'],
|
||||
__('by'),
|
||||
$c['id_user'],
|
||||
get_user_fullname($c['id_user']).' ('.$c['id_user'].')',
|
||||
$eventIdExplanation
|
||||
);
|
||||
|
||||
@ -5464,3 +5585,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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,8 @@ function groupview_get_modules_counters($groups_ids=false)
|
||||
WHERE tasg.id_group IN ($groups_ids)
|
||||
GROUP BY tasg.id_group
|
||||
) x GROUP BY g";
|
||||
return db_get_all_rows_sql($sql);
|
||||
$data = db_get_all_rows_sql($sql);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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)
|
||||
);
|
||||
|
@ -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:
|
||||
|
@ -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) {
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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>';
|
||||
}
|
||||
|
@ -11537,7 +11537,7 @@ function reporting_get_group_stats_resume($id_group=0, $access='AR', $ignore_per
|
||||
$data['status'] = 'critical';
|
||||
} else if ($data['monitor_warning'] > 0) {
|
||||
$data['status'] = 'warning';
|
||||
} else if (($data['monitor_unknown'] > 0) || ($data['agents_unknown'] > 0)) {
|
||||
} else if (($data['monitor_unknown'] > 0) || ($data['agent_unknown'] > 0)) {
|
||||
$data['status'] = 'unknown';
|
||||
} else if ($data['monitor_ok'] > 0) {
|
||||
$data['status'] = 'ok';
|
||||
|
@ -1408,3 +1408,77 @@ function custom_fields_macros_report($macro, $key_macro)
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of the reports the user can view.
|
||||
*
|
||||
* A user can view a report by two ways:
|
||||
* - The user created the report (id_user field in treport)
|
||||
* - The report is not private and the user has reading privileges on
|
||||
* the group associated to the report
|
||||
*
|
||||
* @param array Extra filter to retrieve reports. All reports are returned by
|
||||
* default
|
||||
* @param array Fields to be fetched on every report.
|
||||
*
|
||||
* @return array An array with all the reports the user can view.
|
||||
*/
|
||||
function reports_get_report_templates(
|
||||
$filter=false,
|
||||
$fields=false,
|
||||
$returnAllGroup=true,
|
||||
$privileges='RR',
|
||||
$group=false,
|
||||
$strict_user=false
|
||||
) {
|
||||
global $config;
|
||||
|
||||
if (is_array($filter) === false) {
|
||||
$filter = [];
|
||||
}
|
||||
|
||||
if (is_array($fields) === false) {
|
||||
$fields[] = 'id_group';
|
||||
$fields[] = 'id_user';
|
||||
}
|
||||
|
||||
$templates = [];
|
||||
$all_templates = @db_get_all_rows_filter('treport_template', $filter, $fields);
|
||||
|
||||
if (empty($all_templates) === true) {
|
||||
$all_templates = [];
|
||||
}
|
||||
|
||||
if ($group) {
|
||||
$groups = $group;
|
||||
} else {
|
||||
$groups = users_get_groups($config['id_user'], $privileges, $returnAllGroup);
|
||||
if ($strict_user) {
|
||||
$groups = users_get_strict_mode_groups($config['id_user'], $returnAllGroup);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($all_templates as $template) {
|
||||
// If the template is not in all group.
|
||||
if ($template['id_group'] != 0) {
|
||||
if (!in_array($template['id_group'], array_keys($groups))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($config['id_user'] != $template['id_user']
|
||||
&& !check_acl($config['id_user'], $template['id_group'], $privileges)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if ($returnAllGroup === false) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
array_push($templates, $template);
|
||||
}
|
||||
|
||||
return $templates;
|
||||
}
|
||||
|
@ -1075,7 +1075,7 @@ function ui_format_alert_row(
|
||||
}
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
if (is_metaconsole() === true && (int) $server_id !== 0) {
|
||||
$server = db_get_row('tmetaconsole_setup', 'id', $alert['server_data']['id']);
|
||||
|
||||
if (metaconsole_connect($server) == NOERR) {
|
||||
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -4080,7 +4080,7 @@ function visual_map_get_layout_status($layout_id, $status_data=[], $depth=0)
|
||||
// When the status calculation type is 'default', only one critical
|
||||
// element is required to set the layout status as critical, so we can
|
||||
// return the critical status right now.
|
||||
if ($status_data['linked_layout_status_type'] === 'default'
|
||||
if ((isset($status_data['linked_layout_status_type']) === true && $status_data['linked_layout_status_type'] === 'default')
|
||||
&& ($status == VISUAL_MAP_STATUS_CRITICAL_BAD
|
||||
|| $status == VISUAL_MAP_STATUS_CRITICAL_ALERT)
|
||||
) {
|
||||
@ -4104,71 +4104,73 @@ function visual_map_get_layout_status($layout_id, $status_data=[], $depth=0)
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
|
||||
// Status calculation.
|
||||
switch ($status_data['linked_layout_status_type']) {
|
||||
default:
|
||||
case 'default':
|
||||
$num_items_critical_alert = $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_ALERT];
|
||||
$num_items_critical = $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_BAD];
|
||||
$num_items_warning_alert = $num_elements_by_status[VISUAL_MAP_STATUS_WARNING_ALERT];
|
||||
$num_items_warning = $num_elements_by_status[VISUAL_MAP_STATUS_WARNING];
|
||||
$num_items_unknown = $num_elements_by_status[VISUAL_MAP_STATUS_UNKNOWN];
|
||||
if (isset($status_data['linked_layout_status_type']) === true) {
|
||||
// Status calculation.
|
||||
switch ($status_data['linked_layout_status_type']) {
|
||||
default:
|
||||
case 'default':
|
||||
$num_items_critical_alert = $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_ALERT];
|
||||
$num_items_critical = $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_BAD];
|
||||
$num_items_warning_alert = $num_elements_by_status[VISUAL_MAP_STATUS_WARNING_ALERT];
|
||||
$num_items_warning = $num_elements_by_status[VISUAL_MAP_STATUS_WARNING];
|
||||
$num_items_unknown = $num_elements_by_status[VISUAL_MAP_STATUS_UNKNOWN];
|
||||
|
||||
if ($num_items_critical_alert > 0) {
|
||||
return VISUAL_MAP_STATUS_CRITICAL_ALERT;
|
||||
} else if ($num_items_critical > 0) {
|
||||
return VISUAL_MAP_STATUS_CRITICAL_BAD;
|
||||
} else if ($num_items_warning_alert > 0) {
|
||||
return VISUAL_MAP_STATUS_WARNING_ALERT;
|
||||
} else if ($num_items_warning > 0) {
|
||||
return VISUAL_MAP_STATUS_WARNING;
|
||||
} else if ($num_items_unknown > 0) {
|
||||
return VISUAL_MAP_STATUS_UNKNOWN;
|
||||
} else {
|
||||
return VISUAL_MAP_STATUS_NORMAL;
|
||||
}
|
||||
break;
|
||||
case 'weight':
|
||||
$weight = $status_data['id_layout_linked_weight'];
|
||||
$num_items = count($valid_layout_items);
|
||||
$num_items_critical_alert = $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_ALERT];
|
||||
$num_items_critical = $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_BAD];
|
||||
$num_items_warning_alert = $num_elements_by_status[VISUAL_MAP_STATUS_WARNING_ALERT];
|
||||
$num_items_warning = $num_elements_by_status[VISUAL_MAP_STATUS_WARNING];
|
||||
$num_items_unknown = $num_elements_by_status[VISUAL_MAP_STATUS_UNKNOWN];
|
||||
if ($num_items_critical_alert > 0) {
|
||||
return VISUAL_MAP_STATUS_CRITICAL_ALERT;
|
||||
} else if ($num_items_critical > 0) {
|
||||
return VISUAL_MAP_STATUS_CRITICAL_BAD;
|
||||
} else if ($num_items_warning_alert > 0) {
|
||||
return VISUAL_MAP_STATUS_WARNING_ALERT;
|
||||
} else if ($num_items_warning > 0) {
|
||||
return VISUAL_MAP_STATUS_WARNING;
|
||||
} else if ($num_items_unknown > 0) {
|
||||
return VISUAL_MAP_STATUS_UNKNOWN;
|
||||
} else {
|
||||
return VISUAL_MAP_STATUS_NORMAL;
|
||||
}
|
||||
break;
|
||||
case 'weight':
|
||||
$weight = $status_data['id_layout_linked_weight'];
|
||||
$num_items = count($valid_layout_items);
|
||||
$num_items_critical_alert = $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_ALERT];
|
||||
$num_items_critical = $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_BAD];
|
||||
$num_items_warning_alert = $num_elements_by_status[VISUAL_MAP_STATUS_WARNING_ALERT];
|
||||
$num_items_warning = $num_elements_by_status[VISUAL_MAP_STATUS_WARNING];
|
||||
$num_items_unknown = $num_elements_by_status[VISUAL_MAP_STATUS_UNKNOWN];
|
||||
|
||||
if (($num_items_critical > 0 || $num_items_critical_alert > 0)
|
||||
&& ((($num_items_critical_alert + $num_items_critical) * 100) / $num_items) >= $weight
|
||||
) {
|
||||
return ($num_items_critical_alert > 0) ? VISUAL_MAP_STATUS_CRITICAL_ALERT : VISUAL_MAP_STATUS_CRITICAL_BAD;
|
||||
} else if (($num_items_warning > 0 || $num_items_warning_alert > 0)
|
||||
&& (($num_items_warning_alert + $num_items_warning * 100) / $num_items) >= $weight
|
||||
) {
|
||||
return ($num_items_warning_alert > 0) ? VISUAL_MAP_STATUS_WARNING_ALERT : VISUAL_MAP_STATUS_WARNING;
|
||||
} else if ($num_items_unknown > 0
|
||||
&& (($num_items_unknown * 100) / $num_items) >= $weight
|
||||
) {
|
||||
return VISUAL_MAP_STATUS_UNKNOWN;
|
||||
} else {
|
||||
return VISUAL_MAP_STATUS_NORMAL;
|
||||
}
|
||||
break;
|
||||
if (($num_items_critical > 0 || $num_items_critical_alert > 0)
|
||||
&& ((($num_items_critical_alert + $num_items_critical) * 100) / $num_items) >= $weight
|
||||
) {
|
||||
return ($num_items_critical_alert > 0) ? VISUAL_MAP_STATUS_CRITICAL_ALERT : VISUAL_MAP_STATUS_CRITICAL_BAD;
|
||||
} else if (($num_items_warning > 0 || $num_items_warning_alert > 0)
|
||||
&& (($num_items_warning_alert + $num_items_warning * 100) / $num_items) >= $weight
|
||||
) {
|
||||
return ($num_items_warning_alert > 0) ? VISUAL_MAP_STATUS_WARNING_ALERT : VISUAL_MAP_STATUS_WARNING;
|
||||
} else if ($num_items_unknown > 0
|
||||
&& (($num_items_unknown * 100) / $num_items) >= $weight
|
||||
) {
|
||||
return VISUAL_MAP_STATUS_UNKNOWN;
|
||||
} else {
|
||||
return VISUAL_MAP_STATUS_NORMAL;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'service':
|
||||
$num_items_critical = ($num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_BAD] + $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_ALERT]);
|
||||
$critical_percentage = (($num_items_critical * 100) / count($valid_layout_items));
|
||||
case 'service':
|
||||
$num_items_critical = ($num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_BAD] + $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_ALERT]);
|
||||
$critical_percentage = (($num_items_critical * 100) / count($valid_layout_items));
|
||||
|
||||
$num_items_warning = ($num_elements_by_status[VISUAL_MAP_STATUS_WARNING] + $num_elements_by_status[VISUAL_MAP_STATUS_WARNING_ALERT]);
|
||||
$warning_percentage = (($num_items_warning * 100) / count($valid_layout_items));
|
||||
$num_items_warning = ($num_elements_by_status[VISUAL_MAP_STATUS_WARNING] + $num_elements_by_status[VISUAL_MAP_STATUS_WARNING_ALERT]);
|
||||
$warning_percentage = (($num_items_warning * 100) / count($valid_layout_items));
|
||||
|
||||
if ($critical_percentage >= $status_data['linked_layout_status_as_service_critical'] && $critical_percentage !== 0) {
|
||||
return VISUAL_MAP_STATUS_CRITICAL_BAD;
|
||||
} else if ($warning_percentage >= $status_data['linked_layout_status_as_service_warning'] && $warning_percentage !== 0) {
|
||||
return VISUAL_MAP_STATUS_WARNING;
|
||||
} else {
|
||||
return VISUAL_MAP_STATUS_NORMAL;
|
||||
}
|
||||
break;
|
||||
if ($critical_percentage >= $status_data['linked_layout_status_as_service_critical'] && $critical_percentage !== 0) {
|
||||
return VISUAL_MAP_STATUS_CRITICAL_BAD;
|
||||
} else if ($warning_percentage >= $status_data['linked_layout_status_as_service_warning'] && $warning_percentage !== 0) {
|
||||
return VISUAL_MAP_STATUS_WARNING;
|
||||
} else {
|
||||
return VISUAL_MAP_STATUS_NORMAL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -526,8 +526,7 @@ function print_clock_analogic_1(
|
||||
$color,
|
||||
$title=true
|
||||
) {
|
||||
global $config;
|
||||
$output .= '<style type="text/css">
|
||||
$output = '<style type="text/css">
|
||||
#rim {
|
||||
fill: none;
|
||||
stroke: #999;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
});
|
||||
|
||||
@ -466,9 +336,12 @@ function event_change_status(event_ids, server_id) {
|
||||
}
|
||||
|
||||
if (data.status == "status_ok") {
|
||||
if (typeof dt_events !== "undefined") {
|
||||
dt_events.draw(false);
|
||||
}
|
||||
// if (typeof dt_events !== "undefined") {
|
||||
// dt_events.draw(false);
|
||||
// }
|
||||
$("#table_events")
|
||||
.DataTable()
|
||||
.draw(false);
|
||||
$("#notification_status_success").show();
|
||||
if (new_status == 1) {
|
||||
$("#extended_event_general_page table td.general_acknowleded").text(
|
||||
@ -526,9 +399,12 @@ function event_change_owner(event_id, server_id) {
|
||||
}
|
||||
|
||||
if (data == "owner_ok") {
|
||||
if (typeof dt_events !== "undefined") {
|
||||
dt_events.draw(false);
|
||||
}
|
||||
// if (typeof dt_events !== "undefined") {
|
||||
// dt_events.draw(false);
|
||||
// }
|
||||
$("#table_events")
|
||||
.DataTable()
|
||||
.draw(false);
|
||||
$("#notification_owner_success").show();
|
||||
if (new_owner == -1) {
|
||||
$("#extended_event_general_page table td.general_owner").html(
|
||||
@ -594,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");
|
||||
@ -814,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,
|
||||
@ -827,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.
|
||||
@ -838,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
|
||||
@ -964,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();
|
||||
@ -981,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() {
|
||||
@ -1281,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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -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", "");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -387,17 +387,17 @@ class BlockHistogram extends Widget
|
||||
$output = '';
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
$modules_nodes = array_reduce(
|
||||
$this->values['moduleBlockHistogram'],
|
||||
function ($carry, $item) {
|
||||
$explode = explode('|', $item);
|
||||
$carry[$explode[0]][] = $explode[1];
|
||||
return $carry;
|
||||
},
|
||||
[]
|
||||
);
|
||||
$modules_nodes = array_reduce(
|
||||
$this->values['moduleBlockHistogram'],
|
||||
function ($carry, $item) {
|
||||
$explode = explode('|', $item);
|
||||
$carry[$explode[0]][] = $explode[1];
|
||||
return $carry;
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
$modules = [];
|
||||
$modules = [];
|
||||
foreach ($modules_nodes as $n => $mod) {
|
||||
try {
|
||||
$node = new Node((int) $n);
|
||||
@ -475,7 +475,8 @@ class BlockHistogram extends Widget
|
||||
private function getInfoModules(array $modules): array
|
||||
{
|
||||
$where = sprintf(
|
||||
'tagente_modulo.id_agente_modulo IN (%s)',
|
||||
'tagente_modulo.id_agente_modulo IN (%s)
|
||||
AND tagente_modulo.delete_pending = 0',
|
||||
implode(',', $modules)
|
||||
);
|
||||
|
||||
|
@ -426,7 +426,8 @@ class ColorModuleTabs extends Widget
|
||||
private function getInfoModules(array $modules): array
|
||||
{
|
||||
$where = sprintf(
|
||||
'tagente_modulo.id_agente_modulo IN (%s)',
|
||||
'tagente_modulo.id_agente_modulo IN (%s)
|
||||
AND tagente_modulo.delete_pending = 0',
|
||||
implode(',', $modules)
|
||||
);
|
||||
|
||||
|
@ -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(' » ', $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('» ', $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;
|
||||
|
@ -170,6 +170,17 @@ class AlertsFiredWidget extends Widget
|
||||
$this->configurationRequired = false;
|
||||
if (isset($this->values['groupId']) === false) {
|
||||
$this->configurationRequired = true;
|
||||
} else {
|
||||
$check_exist = \db_get_value(
|
||||
'id_grupo',
|
||||
'tgrupo',
|
||||
'id_grupo',
|
||||
$this->values['groupId']
|
||||
);
|
||||
|
||||
if ($check_exist === false) {
|
||||
$this->loadError = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->overflow_scrollbars = false;
|
||||
|
@ -28,6 +28,8 @@
|
||||
|
||||
namespace PandoraFMS\Dashboard;
|
||||
|
||||
use PandoraFMS\Enterprise\Metaconsole\Node;
|
||||
|
||||
/**
|
||||
* Custom graph Widgets
|
||||
*/
|
||||
@ -178,6 +180,41 @@ class CustomGraphWidget extends Widget
|
||||
$this->configurationRequired = false;
|
||||
if (empty($this->values['id_graph']) === true) {
|
||||
$this->configurationRequired = true;
|
||||
} else {
|
||||
try {
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['node'] > 0
|
||||
) {
|
||||
$node = new Node($this->values['node']);
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
$check_exist = \db_get_value(
|
||||
'name',
|
||||
'tgraph',
|
||||
'id_graph',
|
||||
$this->values['id_graph']
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['node'] > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
||||
$check_exist = false;
|
||||
} finally {
|
||||
if (is_metaconsole() === true
|
||||
&& $this->values['node'] > 0
|
||||
) {
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
if ($check_exist === false) {
|
||||
$this->loadError = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|