Merge remote-tracking branch 'origin/develop' into ent-5524-backups-de-la-base-de-datos-desde-la-consola
This commit is contained in:
commit
7f282c668d
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.744, AIX version
|
||||
# Version 7.0NG.745, AIX version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.744, FreeBSD Version
|
||||
# Version 7.0NG.745, FreeBSD Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.744, HP-UX Version
|
||||
# Version 7.0NG.745, HP-UX Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.744, GNU/Linux
|
||||
# Version 7.0NG.745, GNU/Linux
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.744, GNU/Linux
|
||||
# Version 7.0NG.745, GNU/Linux
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.744, Solaris Version
|
||||
# Version 7.0NG.745, Solaris Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Base config file for Pandora FMS Windows Agent
|
||||
# (c) 2006-2010 Artica Soluciones Tecnologicas
|
||||
# Version 7.0NG.744
|
||||
# Version 7.0NG.745
|
||||
|
||||
# This program is Free Software, you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public Licence as published by the Free Software
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Fichero de configuracion base de agentes de Pandora
|
||||
# Base config file for Pandora agents
|
||||
# Version 7.0NG.744, AIX version
|
||||
# Version 7.0NG.745, AIX version
|
||||
|
||||
# General Parameters
|
||||
# ==================
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Fichero de configuracion base de agentes de Pandora
|
||||
# Base config file for Pandora agents
|
||||
# Version 7.0NG.744
|
||||
# Version 7.0NG.745
|
||||
# FreeBSD/IPSO version
|
||||
# Licenced under GPL licence, 2003-2007 Sancho Lerena
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Fichero de configuracion base de agentes de Pandora
|
||||
# Base config file for Pandora agents
|
||||
# Version 7.0NG.744, HPUX Version
|
||||
# Version 7.0NG.745, HPUX Version
|
||||
|
||||
# General Parameters
|
||||
# ==================
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.744
|
||||
# Version 7.0NG.745
|
||||
# Licensed under GPL license v2,
|
||||
# (c) 2003-2010 Artica Soluciones Tecnologicas
|
||||
# please visit http://pandora.sourceforge.net
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.744
|
||||
# Version 7.0NG.745
|
||||
# Licensed under GPL license v2,
|
||||
# (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# please visit http://pandora.sourceforge.net
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.744
|
||||
# Version 7.0NG.745
|
||||
# Licensed under GPL license v2,
|
||||
# please visit http://pandora.sourceforge.net
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Fichero de configuracion base de agentes de Pandora
|
||||
# Base config file for Pandora agents
|
||||
# Version 7.0NG.744, Solaris version
|
||||
# Version 7.0NG.745, Solaris version
|
||||
|
||||
# General Parameters
|
||||
# ==================
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.744, AIX version
|
||||
# Version 7.0NG.745, AIX version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-agent-unix
|
||||
Version: 7.0NG.744-200407
|
||||
Version: 7.0NG.745-200511
|
||||
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.744-200407"
|
||||
pandora_version="7.0NG.745-200511"
|
||||
|
||||
echo "Test if you has the tools for to make the packages."
|
||||
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.744, GNU/Linux
|
||||
# Version 7.0NG.745, GNU/Linux
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2012 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.744, FreeBSD Version
|
||||
# Version 7.0NG.745, FreeBSD Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2016 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.744, HP-UX Version
|
||||
# Version 7.0NG.745, HP-UX Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.744, GNU/Linux
|
||||
# Version 7.0NG.745, GNU/Linux
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2014 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.744, GNU/Linux
|
||||
# Version 7.0NG.745, GNU/Linux
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.744, NetBSD Version
|
||||
# Version 7.0NG.745, NetBSD Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Base config file for Pandora FMS agents
|
||||
# Version 7.0NG.744, Solaris Version
|
||||
# Version 7.0NG.745, Solaris Version
|
||||
# Licensed under GPL license v2,
|
||||
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
|
||||
# http://www.pandorafms.com
|
||||
|
|
|
@ -54,8 +54,8 @@ my $Sem = undef;
|
|||
# Semaphore used to control the number of threads
|
||||
my $ThreadSem = undef;
|
||||
|
||||
use constant AGENT_VERSION => '7.0NG.744';
|
||||
use constant AGENT_BUILD => '200407';
|
||||
use constant AGENT_VERSION => '7.0NG.745';
|
||||
use constant AGENT_BUILD => '200511';
|
||||
|
||||
# Agent log default file size maximum and instances
|
||||
use constant DEFAULT_MAX_LOG_SIZE => 600000;
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
#Pandora FMS Linux Agent
|
||||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.744
|
||||
%define release 200407
|
||||
%define version 7.0NG.745
|
||||
%define release 200511
|
||||
|
||||
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.744
|
||||
%define release 200407
|
||||
%define version 7.0NG.745
|
||||
%define release 200511
|
||||
|
||||
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.744"
|
||||
PI_BUILD="200407"
|
||||
PI_VERSION="7.0NG.745"
|
||||
PI_BUILD="200511"
|
||||
OS_NAME=`uname -s`
|
||||
|
||||
FORCE=0
|
||||
|
|
Binary file not shown.
|
@ -1,6 +1,6 @@
|
|||
# Base config file for Pandora FMS Windows Agent
|
||||
# (c) 2006-2017 Artica Soluciones Tecnologicas
|
||||
# Version 7.0NG.744
|
||||
# Version 7.0NG.745
|
||||
|
||||
# This program is Free Software, you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public Licence as published by the Free Software
|
||||
|
|
Binary file not shown.
|
@ -3,13 +3,18 @@
|
|||
# The installer will be placed in ./installer/output/.
|
||||
# InstallJammer must be installed and in the PATH.
|
||||
|
||||
ARCH=`uname -m`
|
||||
# ARCH may be set by other build scripts.
|
||||
if [ "$ARCH" == "" ]; then
|
||||
ARCH=`uname -m`
|
||||
fi
|
||||
|
||||
# Set the target host.
|
||||
if [ "$ARCH" == "x86_64" ]; then
|
||||
HOST="x86_64-w64-mingw32"
|
||||
else
|
||||
HOST="i686-w64-mingw32"
|
||||
fi
|
||||
|
||||
#./autogen.sh && ./configure --host=$HOST && make clean && make && cp PandoraAgent.exe bin/ && installjammer --build installer/pandora.mpi
|
||||
# Compile and update the Pandora FMS Agent binary.
|
||||
./autogen.sh && ./configure --host=$HOST && make clean && make && cp PandoraAgent.exe bin/
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ AllowLanguageSelection
|
|||
{Yes}
|
||||
|
||||
AppName
|
||||
{Pandora FMS Windows Agent v7.0NG.744}
|
||||
{Pandora FMS Windows Agent v7.0NG.745}
|
||||
|
||||
ApplicationID
|
||||
{17E3D2CF-CA02-406B-8A80-9D31C17BD08F}
|
||||
|
@ -186,7 +186,7 @@ UpgradeApplicationID
|
|||
{}
|
||||
|
||||
Version
|
||||
{200407}
|
||||
{200511}
|
||||
|
||||
ViewReadme
|
||||
{Yes}
|
||||
|
|
|
@ -30,7 +30,7 @@ using namespace Pandora;
|
|||
using namespace Pandora_Strutils;
|
||||
|
||||
#define PATH_SIZE _MAX_PATH+1
|
||||
#define PANDORA_VERSION ("7.0NG.744(Build 200407)")
|
||||
#define PANDORA_VERSION ("7.0NG.745(Build 200511)")
|
||||
|
||||
string pandora_path;
|
||||
string pandora_dir;
|
||||
|
|
|
@ -11,7 +11,7 @@ BEGIN
|
|||
VALUE "LegalCopyright", "Artica ST"
|
||||
VALUE "OriginalFilename", "PandoraAgent.exe"
|
||||
VALUE "ProductName", "Pandora FMS Windows Agent"
|
||||
VALUE "ProductVersion", "(7.0NG.744(Build 200407))"
|
||||
VALUE "ProductVersion", "(7.0NG.745(Build 200511))"
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
END
|
||||
END
|
||||
|
|
|
@ -1,2 +1,8 @@
|
|||
# pandora disable listing
|
||||
Options -Indexes
|
||||
Options -Indexes
|
||||
|
||||
<Files ~ "\.log$">
|
||||
Order Allow,Deny
|
||||
Deny from All
|
||||
</Files>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-console
|
||||
Version: 7.0NG.744-200407
|
||||
Version: 7.0NG.745-200511
|
||||
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.744-200407"
|
||||
pandora_version="7.0NG.745-200511"
|
||||
|
||||
package_pear=0
|
||||
package_pandora=1
|
||||
|
|
|
@ -188,9 +188,10 @@ function quickShell()
|
|||
} else if ($method == 'telnet') {
|
||||
// Telnet.
|
||||
$port = $config['gotty_telnet_port'];
|
||||
$username = preg_replace('/[^a-zA-Z0-9\-\.]/', '', $username);
|
||||
$command_arguments = "var args = '?arg=-l ".$username;
|
||||
$command_arguments .= '&arg='.$address;
|
||||
$command_arguments .= '&arg='.$method_port."';";
|
||||
$command_arguments .= '&arg='.$method_port."&arg=-E';";
|
||||
} else {
|
||||
ui_print_error_message(__('Please use SSH or Telnet.'));
|
||||
return;
|
||||
|
|
|
@ -1 +1,6 @@
|
|||
operation/servers/recon_view.php
|
||||
operation/servers/recon_view.php
|
||||
operation/users/webchat.php
|
||||
include/javascript/webchat.js
|
||||
attachment/pandora_chat.log.json.txt
|
||||
attachment/pandora_chat.user_list.json.txt
|
||||
attachment/pandora_chat.global_counter.txt
|
|
@ -1,5 +1,54 @@
|
|||
START TRANSACTION;
|
||||
|
||||
ALTER TABLE tagente_modulo MODIFY COLUMN `custom_string_1` MEDIUMTEXT;
|
||||
|
||||
ALTER TABLE `trecon_task` MODIFY COLUMN `id_network_profile` TEXT;
|
||||
ALTER TABLE `trecon_task` CHANGE COLUMN `create_incident` `review_mode` TINYINT(1) UNSIGNED DEFAULT 0;
|
||||
ALTER TABLE `trecon_task` ADD COLUMN `subnet_csv` TINYINT(1) UNSIGNED DEFAULT 1;
|
||||
|
||||
UPDATE `trecon_task` SET `review_mode` = 1;
|
||||
ALTER TABLE trecon_task add column `auto_monitor` TINYINT(1) UNSIGNED DEFAULT 1 AFTER `auth_strings`;
|
||||
UPDATE `trecon_task` SET `auto_monitor` = 0;
|
||||
|
||||
CREATE TABLE `tdiscovery_tmp_agents` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id_rt` int(10) unsigned NOT NULL,
|
||||
`label` varchar(600) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
|
||||
`data` MEDIUMTEXT,
|
||||
`review_date` datetime DEFAULT NULL,
|
||||
`created` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `id_rt` (`id_rt`),
|
||||
INDEX `label` (`label`),
|
||||
CONSTRAINT `tdta_trt` FOREIGN KEY (`id_rt`) REFERENCES `trecon_task` (`id_rt`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `tdiscovery_tmp_connections` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id_rt` int(10) unsigned NOT NULL,
|
||||
`dev_1` text,
|
||||
`dev_2` text,
|
||||
`if_1` text,
|
||||
`if_2` text,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `tpen` (
|
||||
`pen` int(10) unsigned NOT NULL,
|
||||
`manufacturer` TEXT,
|
||||
`description` TEXT,
|
||||
PRIMARY KEY (`pen`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tnetwork_profile_pen` (
|
||||
`pen` int(10) unsigned NOT NULL,
|
||||
`id_np` int(10) unsigned NOT NULL,
|
||||
CONSTRAINT `fk_network_profile_pen_pen` FOREIGN KEY (`pen`)
|
||||
REFERENCES `tpen` (`pen`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_network_profile_pen_id_np` FOREIGN KEY (`id_np`)
|
||||
REFERENCES `tnetwork_profile` (`id_np`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
ALTER TABLE `twidget_dashboard` ADD COLUMN `position` TEXT NOT NULL default '';
|
||||
|
||||
ALTER TABLE `tagente_estado` ADD COLUMN `last_status_change` bigint(20) NOT NULL default '0';
|
||||
|
@ -10,4 +59,111 @@ ALTER TABLE `talert_templates` ADD COLUMN `disable_event` tinyint(1) DEFAULT 0;
|
|||
ALTER TABLE `tevent_alert` ADD COLUMN `disable_event` tinyint(1) DEFAULT 0;
|
||||
ALTER TABLE `talert_snmp` ADD COLUMN `disable_event` tinyint(1) DEFAULT 0;
|
||||
|
||||
UPDATE twidget SET description='Show a visual console' WHERE class_name='MapsMadeByUser';
|
||||
UPDATE twidget SET description='Clock' WHERE class_name='ClockWidget';
|
||||
UPDATE twidget SET description='Group status' WHERE class_name='SystemGroupStatusWidget';
|
||||
|
||||
INSERT IGNORE INTO `tpen` VALUES (9,'cisco','Cisco System'),(11,'hp','Hewlett Packard'),(2021,'general_snmp','U.C. Davis, ECE Dept. Tom'),(2636,'juniper','Juniper Networks'),(3375,'f5','F5 Labs'),(8072,'general_snmp','Net SNMP'),(12356,'fortinet','Fortinet');
|
||||
|
||||
SET @template_name = 'Network Management';
|
||||
SET @template_description = 'Basic network monitoring template';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Network Management')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Cisco MIBS';
|
||||
SET @template_description = 'Cisco devices monitoring template (SNMP)';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Cisco MIBS' OR g.name = 'Catalyst 2900')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
INSERT INTO tnetwork_profile_pen (pen, id_np) SELECT * FROM (SELECT p.pen pen, np.id_np id_np FROM tnetwork_profile np, tpen p WHERE np.name = @template_name AND (p.pen = 9)) AS tmp WHERE NOT EXISTS (SELECT pp.id_np FROM tnetwork_profile p, tnetwork_profile_pen pp WHERE p.id_np = pp.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Linux System';
|
||||
SET @template_description = 'Linux system monitoring template (SNMP)';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
|
||||
SET @module_group = 'Linux';
|
||||
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Linux' OR g.name = 'UCD Mibs (Linux, UCD-SNMP)')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
INSERT INTO tnetwork_profile_pen (pen, id_np) SELECT * FROM (SELECT p.pen pen, np.id_np id_np FROM tnetwork_profile np, tpen p WHERE np.name = @template_name AND (p.pen = 2021 OR p.pen = 2636)) AS tmp WHERE NOT EXISTS (SELECT pp.id_np FROM tnetwork_profile p, tnetwork_profile_pen pp WHERE p.id_np = pp.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Windows System';
|
||||
SET @template_description = 'Windows system monitoring template (WMI)';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Microsoft Windows' OR g.name = 'Windows System')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Windows Hardware';
|
||||
SET @template_description = 'Windows hardware monitoring templae (WMI)';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Windows Hardware Layer')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Windows Active Directory';
|
||||
SET @template_description = 'Active directory monitoring template (WMI)';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Windows AD' OR g.name = 'AD Counters')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Windows IIS';
|
||||
SET @template_description = 'IIS monitoring template (WMI)';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Windows IIS' OR g.name = 'IIS services')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Windows Exchange';
|
||||
SET @template_description = 'Exchange monitoring template (WMI)';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Windows Exchange' OR g.name = 'Exchange Services' OR g.name = 'Exchange TCP Ports')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Windows LDAP';
|
||||
SET @template_description = 'LDAP monitoring template (WMI)';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Windows LDAP')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Windows MDSTC';
|
||||
SET @template_description = 'MDSTC monitoring template (WMI)';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Windows MSDTC')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Windows Printers';
|
||||
SET @template_description = 'Windows printers monitoring template (WMI)';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Windows Printers')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Windows DNS';
|
||||
SET @template_description = 'Windows DNS monitoring template (WMI)';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Windows DNS' OR g.name = 'DNS Counters')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Windows MS SQL Server';
|
||||
SET @template_description = 'MS SQL Server monitoring template (WMI)';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'MS SQL Server')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Oracle';
|
||||
SET @template_description = 'Oracle monitoring template';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Oracle')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'MySQL';
|
||||
SET @template_description = 'MySQL monitoring template';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'MySQL')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Windows Antivirus';
|
||||
SET @template_description = 'Windows antivirus monitoring template (WMI)';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Norton' OR g.name = 'Panda' OR g.name = 'McAfee' OR g.name = 'Bitdefender' OR g.name = 'BullGuard' OR g.name = 'AVG' OR g.name = 'Kaspersky')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
COMMIT;
|
||||
|
|
|
@ -1448,6 +1448,7 @@ ALTER TABLE `tagente_modulo` DROP COLUMN `ff_normal`,
|
|||
MODIFY COLUMN `ff_type` tinyint(1) unsigned NULL DEFAULT '0',
|
||||
MODIFY COLUMN `dynamic_next` bigint(20) NOT NULL DEFAULT '0',
|
||||
MODIFY COLUMN `dynamic_two_tailed` tinyint(1) unsigned NULL DEFAULT '0';
|
||||
ALTER TABLE tagente_modulo MODIFY COLUMN `custom_string_1` MEDIUMTEXT;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tagente_datos`
|
||||
|
@ -1476,6 +1477,28 @@ ALTER TABLE tnetwork_component ADD COLUMN `dynamic_two_tailed` tinyint(1) unsign
|
|||
ALTER TABLE `tnetwork_component` ADD COLUMN `ff_type` tinyint(1) unsigned default '0';
|
||||
ALTER TABLE `tnetwork_component` MODIFY COLUMN `ff_type` tinyint(1) unsigned NULL DEFAULT '0';
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Table `tpen`
|
||||
-- ----------------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tpen` (
|
||||
`pen` int(10) unsigned NOT NULL,
|
||||
`manufacturer` TEXT,
|
||||
`description` TEXT,
|
||||
PRIMARY KEY (`pen`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Table `tnetwork_profile_pen`
|
||||
-- ----------------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tnetwork_profile_pen` (
|
||||
`pen` int(10) unsigned NOT NULL,
|
||||
`id_np` int(10) unsigned NOT NULL,
|
||||
CONSTRAINT `fk_network_profile_pen_pen` FOREIGN KEY (`pen`)
|
||||
REFERENCES `tpen` (`pen`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_network_profile_pen_id_np` FOREIGN KEY (`id_np`)
|
||||
REFERENCES `tnetwork_profile` (`id_np`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tagente`
|
||||
-- ---------------------------------------------------------------------
|
||||
|
@ -1661,7 +1684,39 @@ ALTER TABLE `trecon_task` ADD COLUMN `type` int(11) NOT NULL DEFAULT '0',
|
|||
MODIFY COLUMN `wmi_enabled` tinyint(1) unsigned NULL DEFAULT '0',
|
||||
MODIFY COLUMN `auth_strings` text NULL,
|
||||
MODIFY COLUMN `autoconfiguration_enabled` tinyint(1) unsigned NULL DEFAULT '0',
|
||||
MODIFY COLUMN `summary` text NULL;
|
||||
MODIFY COLUMN `summary` text NULL,
|
||||
MODIFY COLUMN `id_network_profile` text,
|
||||
CHANGE COLUMN `create_incident` `review_mode` TINYINT(1) UNSIGNED DEFAULT 1,
|
||||
ADD COLUMN `subnet_csv` TINYINT(1) UNSIGNED DEFAULT 0;
|
||||
|
||||
-- Old recon always report.
|
||||
UPDATE `trecon_task` SET `review_mode` = 1;
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Table `tdiscovery_tmp`
|
||||
-- ----------------------------------------------------------------------
|
||||
CREATE TABLE `tdiscovery_tmp_agents` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id_rt` int(10) unsigned NOT NULL,
|
||||
`label` varchar(600) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
|
||||
`data` MEDIUMTEXT,
|
||||
`review_date` datetime DEFAULT NULL,
|
||||
`created` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `id_rt` (`id_rt`),
|
||||
INDEX `label` (`label`),
|
||||
CONSTRAINT `tdta_trt` FOREIGN KEY (`id_rt`) REFERENCES `trecon_task` (`id_rt`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `tdiscovery_tmp_connections` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id_rt` int(10) unsigned NOT NULL,
|
||||
`dev_1` text,
|
||||
`dev_2` text,
|
||||
`if_1` text,
|
||||
`if_2` text,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `twidget` AND Table `twidget_dashboard`
|
||||
|
@ -2128,6 +2183,8 @@ ALTER TABLE `trecon_task` ADD COLUMN `snmp_auth_method` varchar(25) NOT NULL def
|
|||
ALTER TABLE `trecon_task` ADD COLUMN `snmp_privacy_method` varchar(25) NOT NULL default '';
|
||||
ALTER TABLE `trecon_task` ADD COLUMN `snmp_privacy_pass` varchar(255) NOT NULL default '';
|
||||
ALTER TABLE `trecon_task` ADD COLUMN `snmp_security_level` varchar(25) NOT NULL default '';
|
||||
ALTER TABLE trecon_task add column `auto_monitor` TINYINT(1) UNSIGNED DEFAULT 1 AFTER `auth_strings`;
|
||||
UPDATE `trecon_task` SET `auto_monitor` = 0;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tagent_custom_fields_filter`
|
||||
|
@ -2536,3 +2593,132 @@ INSERT INTO `tnetwork_component` (`name`, `description`, `id_group`, `type`, `ma
|
|||
INSERT INTO `tnetwork_component` (`name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `max_retries`, `history_data`, `min_warning`, `max_warning`, `max_critical`, `str_warning`, `min_ff_event`, `min_critical`, `custom_string_2`, `str_critical`, `custom_integer_1`, `custom_string_1`, `post_process`, `custom_string_3`, `wizard_level`, `custom_integer_2`, `critical_instructions`, `unit`, `unknown_instructions`, `macros`, `warning_inverse`, `warning_instructions`, `tags`, `critical_inverse`, `module_macros`, `id_category`, `min_ff_event_warning`, `disabled_types_event`, `ff_type`, `min_ff_event_normal`, `dynamic_interval`, `min_ff_event_critical`, `dynamic_min`, `each_ff`, `dynamic_two_tailed`, `dynamic_max`, `dynamic_next`) VALUES ('Linux system load','Current load (5 min)',43,34,0,0,300,0,'uptime | awk '{print $(NF-1)}' | tr -d ','','','','',6,2,0,'','','',0,0,1,0.00,0.00,'',0.00,0.00,'',0,'','linux','',0,0,0.000000000000000,'','nowizard','','','','',0,0,0,'','{\"going_unknown\":1}','',0,0,0,0,0,0,0,0,0,0);
|
||||
INSERT INTO `tnetwork_component` (`name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `max_retries`, `history_data`, `min_warning`, `max_warning`, `max_critical`, `str_warning`, `min_ff_event`, `min_critical`, `custom_string_2`, `str_critical`, `custom_integer_1`, `custom_string_1`, `post_process`, `custom_string_3`, `wizard_level`, `custom_integer_2`, `critical_instructions`, `unit`, `unknown_instructions`, `macros`, `warning_inverse`, `warning_instructions`, `tags`, `critical_inverse`, `module_macros`, `id_category`, `min_ff_event_warning`, `disabled_types_event`, `ff_type`, `min_ff_event_normal`, `dynamic_interval`, `min_ff_event_critical`, `dynamic_min`, `each_ff`, `dynamic_two_tailed`, `dynamic_max`, `dynamic_next`) VALUES ('Linux available memory percent','Available memory %',43,34,0,0,300,0,'free | grep Mem | awk '{print $NF/$2 * 100}'','','','',4,2,0,'','','',0,0,1,0.00,0.00,'',0.00,0.00,'',0,'','linux','',0,0,0.000000000000000,'%','nowizard','','','','',0,0,0,'','{\"going_unknown\":1}','',0,0,0,0,0,0,0,0,0,0);
|
||||
INSERT INTO `tnetwork_component` (`name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `max_retries`, `history_data`, `min_warning`, `max_warning`, `max_critical`, `str_warning`, `min_ff_event`, `min_critical`, `custom_string_2`, `str_critical`, `custom_integer_1`, `custom_string_1`, `post_process`, `custom_string_3`, `wizard_level`, `custom_integer_2`, `critical_instructions`, `unit`, `unknown_instructions`, `macros`, `warning_inverse`, `warning_instructions`, `tags`, `critical_inverse`, `module_macros`, `id_category`, `min_ff_event_warning`, `disabled_types_event`, `ff_type`, `min_ff_event_normal`, `dynamic_interval`, `min_ff_event_critical`, `dynamic_min`, `each_ff`, `dynamic_two_tailed`, `dynamic_max`, `dynamic_next`) VALUES ('Linux available disk /','Available free space in mountpoint /',43,34,0,0,300,0,'df / | tail -n +2 | awk '{print $(NF-1)}' | tr -d '%'','','','',4,2,0,'','','',0,0,1,0.00,0.00,'0.00',0.00,0.00,'',0,'','inherited','',0,0,0.000000000000000,'','nowizard','','nowizard','0','',0,0,0,'','{\"going_unknown\":1}','',0,0,0,0,0,0,0,0,0,0);
|
||||
|
||||
--
|
||||
-- Dumping data for table `tpen`
|
||||
--
|
||||
|
||||
INSERT IGNORE INTO `tpen`
|
||||
VALUES
|
||||
(9,'cisco','Cisco System'),
|
||||
(11,'hp','Hewlett Packard'),
|
||||
(2021,'general_snmp','U.C. Davis, ECE Dept. Tom'),
|
||||
(2636,'juniper','Juniper Networks'),
|
||||
(3375,'f5','F5 Labs'),
|
||||
(8072,'general_snmp','Net SNMP'),
|
||||
(12356,'fortinet','Fortinet')
|
||||
;
|
||||
|
||||
--
|
||||
-- Dumping data for table `tnetwork_profile` and `tnetwork_profile_pen`
|
||||
--
|
||||
|
||||
SET @template_name = 'Network Management';
|
||||
SET @template_description = 'Basic network monitoring template';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Network Management')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Cisco MIBS';
|
||||
SET @template_description = 'Cisco devices monitoring template (SNMP)';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Cisco MIBS' OR g.name = 'Catalyst 2900')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
INSERT INTO tnetwork_profile_pen (pen, id_np) SELECT * FROM (SELECT p.pen pen, np.id_np id_np FROM tnetwork_profile np, tpen p WHERE np.name = @template_name AND (p.pen = 9)) AS tmp WHERE NOT EXISTS (SELECT pp.id_np FROM tnetwork_profile p, tnetwork_profile_pen pp WHERE p.id_np = pp.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Linux System';
|
||||
SET @template_description = 'Linux system monitoring template (SNMP)';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
|
||||
SET @module_group = 'Linux';
|
||||
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Linux' OR g.name = 'UCD Mibs (Linux, UCD-SNMP)')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
INSERT INTO tnetwork_profile_pen (pen, id_np) SELECT * FROM (SELECT p.pen pen, np.id_np id_np FROM tnetwork_profile np, tpen p WHERE np.name = @template_name AND (p.pen = 2021 OR p.pen = 2636)) AS tmp WHERE NOT EXISTS (SELECT pp.id_np FROM tnetwork_profile p, tnetwork_profile_pen pp WHERE p.id_np = pp.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Windows System';
|
||||
SET @template_description = 'Windows system monitoring template (WMI)';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Microsoft Windows' OR g.name = 'Windows System')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Windows Hardware';
|
||||
SET @template_description = 'Windows hardware monitoring templae (WMI)';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Windows Hardware Layer')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Windows Active Directory';
|
||||
SET @template_description = 'Active directory monitoring template (WMI)';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Windows AD' OR g.name = 'AD Counters')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Windows IIS';
|
||||
SET @template_description = 'IIS monitoring template (WMI)';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Windows IIS' OR g.name = 'IIS services')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Windows Exchange';
|
||||
SET @template_description = 'Exchange monitoring template (WMI)';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Windows Exchange' OR g.name = 'Exchange Services' OR g.name = 'Exchange TCP Ports')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Windows LDAP';
|
||||
SET @template_description = 'LDAP monitoring template (WMI)';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Windows LDAP')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Windows MDSTC';
|
||||
SET @template_description = 'MDSTC monitoring template (WMI)';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Windows MSDTC')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Windows Printers';
|
||||
SET @template_description = 'Windows printers monitoring template (WMI)';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Windows Printers')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Windows DNS';
|
||||
SET @template_description = 'Windows DNS monitoring template (WMI)';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Windows DNS' OR g.name = 'DNS Counters')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Windows MS SQL Server';
|
||||
SET @template_description = 'MS SQL Server monitoring template (WMI)';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'MS SQL Server')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Oracle';
|
||||
SET @template_description = 'Oracle monitoring template';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Oracle')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'MySQL';
|
||||
SET @template_description = 'MySQL monitoring template';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'MySQL')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
SET @template_name = 'Windows Antivirus';
|
||||
SET @template_description = 'Windows antivirus monitoring template (WMI)';
|
||||
|
||||
INSERT INTO tnetwork_profile (id_np, name, description) SELECT * FROM (SELECT '' id_np, @template_name name, @template_description description) AS tmp WHERE NOT EXISTS (SELECT id_np FROM tnetwork_profile WHERE name = @template_name);
|
||||
INSERT INTO tnetwork_profile_component (id_nc, id_np) SELECT * FROM (SELECT c.id_nc id_nc, p.id_np id_np FROM tnetwork_profile p, tnetwork_component c, tnetwork_component_group g WHERE g.id_sg = c.id_group AND p.name = @template_name AND (g.name = 'Norton' OR g.name = 'Panda' OR g.name = 'McAfee' OR g.name = 'Bitdefender' OR g.name = 'BullGuard' OR g.name = 'AVG' OR g.name = 'Kaspersky')) AS tmp WHERE NOT EXISTS (SELECT pc.id_np FROM tnetwork_profile p, tnetwork_profile_component pc WHERE p.id_np = pc.id_np AND p.name = @template_name);
|
||||
|
||||
|
||||
-- Update widget.
|
||||
|
||||
UPDATE twidget SET description='Show a visual console' WHERE class_name='MapsMadeByUser';
|
||||
UPDATE twidget SET description='Clock' WHERE class_name='ClockWidget';
|
||||
UPDATE twidget SET description='Group status' WHERE class_name='SystemGroupStatusWidget';
|
||||
|
||||
|
||||
|
|
|
@ -81,13 +81,6 @@ if ($config['menu_type'] == 'classic') {
|
|||
}
|
||||
|
||||
|
||||
// Chat messages.
|
||||
$header_chat = "<div id='header_chat'><span id='icon_new_messages_chat' style='display: none;'>";
|
||||
$header_chat .= "<a href='index.php?sec=workspace&sec2=operation/users/webchat'>";
|
||||
$header_chat .= html_print_image('images/header_chat_gray.png', true, ['title' => __('New chat message')]);
|
||||
$header_chat .= '</a></span></div>';
|
||||
|
||||
|
||||
// Search.
|
||||
$acl_head_search = true;
|
||||
if ($config['acl_enterprise'] == 1 && !users_is_admin()) {
|
||||
|
@ -417,7 +410,7 @@ if ($config['menu_type'] == 'classic') {
|
|||
|
||||
echo '<div class="header_left"><span class="header_title">'.$config['custom_title_header'].'</span><span class="header_subtitle">'.$config['custom_subtitle_header'].'</span></div>
|
||||
<div class="header_center">'.$header_searchbar.'</div>
|
||||
<div class="header_right">'.$header_chat, $header_autorefresh, $header_autorefresh_counter, $header_discovery, $servers_list, $header_feedback, $header_support, $header_docu, $header_user, $header_logout.'</div>';
|
||||
<div class="header_right">'.$header_autorefresh, $header_autorefresh_counter, $header_discovery, $servers_list, $header_feedback, $header_support, $header_docu, $header_user, $header_logout.'</div>';
|
||||
?>
|
||||
</div> <!-- Closes #table_header_inner -->
|
||||
</div> <!-- Closes #table_header -->
|
||||
|
@ -640,8 +633,6 @@ if ($config['menu_type'] == 'classic') {
|
|||
|
||||
var fixed_header = <?php echo json_encode((bool) $config_fixed_header); ?>;
|
||||
|
||||
var new_chat = <?php echo (int) $_SESSION['new_chat']; ?>;
|
||||
|
||||
function showinterpreter(){
|
||||
|
||||
document.onclick = function(e) {
|
||||
|
@ -789,9 +780,7 @@ if ($config['menu_type'] == 'classic') {
|
|||
$('div#head').addClass('fixed_header');
|
||||
$('div#main').css('padding-top', $('div#head').innerHeight() + 'px');
|
||||
}
|
||||
|
||||
check_new_chats_icon('icon_new_messages_chat');
|
||||
|
||||
|
||||
/* Temporal fix to hide graphics when ui_dialog are displayed */
|
||||
$("#yougotalert").click(function () {
|
||||
$("#agent_access").css("display", "none");
|
||||
|
|
|
@ -1901,12 +1901,6 @@ if ($enable_module) {
|
|||
'Fail to enable #'.$enable_module.' | '.$module_name.' | '.$agent['alias']
|
||||
);
|
||||
}
|
||||
|
||||
ui_print_result_message(
|
||||
$result,
|
||||
__('Successfully enabled'),
|
||||
__('Could not be enabled')
|
||||
);
|
||||
}
|
||||
|
||||
if ($disable_module) {
|
||||
|
@ -1942,12 +1936,6 @@ if ($disable_module) {
|
|||
'Fail to disable #'.$disable_module.' | '.$module_name.' | '.$agent['alias']
|
||||
);
|
||||
}
|
||||
|
||||
ui_print_result_message(
|
||||
$result,
|
||||
__('Successfully disabled'),
|
||||
__('Could not be disabled')
|
||||
);
|
||||
}
|
||||
|
||||
// Fix to stop the module from being added to the agent's conf
|
||||
|
|
|
@ -283,7 +283,6 @@ if ($id_agent_module) {
|
|||
|
||||
// Security level Could be noAuthNoPriv | authNoPriv | authPriv.
|
||||
$snmp3_security_level = $module['custom_string_3'];
|
||||
|
||||
$ip_target = $module['ip_target'];
|
||||
$disabled = $module['disabled'];
|
||||
$id_export = $module['id_export'];
|
||||
|
@ -297,6 +296,7 @@ if ($id_agent_module) {
|
|||
$custom_integer_2 = $module['custom_integer_2'];
|
||||
$custom_string_1 = $module['custom_string_1'];
|
||||
$custom_string_2 = $module['custom_string_2'];
|
||||
$custom_string_3 = $module['custom_string_3'];
|
||||
$max_timeout = $module['max_timeout'];
|
||||
$max_retries = $module['max_retries'];
|
||||
$custom_id = $module['custom_id'];
|
||||
|
|
|
@ -137,11 +137,31 @@ if (!empty($sub)) {
|
|||
|
||||
$sub = [];
|
||||
if (check_acl($config['id_user'], 0, 'PM')) {
|
||||
$sub['godmode/modules/manage_network_components']['text'] = __('Network components');
|
||||
$sub['godmode/modules/manage_network_components']['id'] = 'Network components';
|
||||
enterprise_hook('components_submenu');
|
||||
$sub['godmode/modules/manage_network_templates']['text'] = __('Module templates');
|
||||
$sub['godmode/modules/manage_network_templates']['id'] = 'Module templates';
|
||||
// enterprise_hook('components_submenu');
|
||||
$sub['templates']['text'] = __('Templates');
|
||||
$sub['templates']['id'] = 'Templates';
|
||||
$sub['templates']['type'] = 'direct';
|
||||
$sub['templates']['subtype'] = 'nolink';
|
||||
$sub2 = [];
|
||||
$sub2['godmode/modules/manage_module_templates']['text'] = __('Module templates');
|
||||
$sub2['godmode/modules/manage_module_templates']['id'] = 'Module templates';
|
||||
$sub2['godmode/modules/private_enterprise_numbers']['text'] = __('Private Enterprise Numbers');
|
||||
$sub2['godmode/modules/private_enterprise_numbers']['id'] = 'Private Enterprise Numbers';
|
||||
$sub2['enterprise/godmode/modules/local_components']['text'] = __('Local components');
|
||||
$sub2['enterprise/godmode/modules/local_components']['id'] = 'Local components';
|
||||
$sub2['godmode/modules/manage_network_components']['text'] = __('Remote components');
|
||||
$sub2['godmode/modules/manage_network_components']['id'] = 'Network components';
|
||||
$sub['templates']['sub2'] = $sub2;
|
||||
/*
|
||||
$sub2['godmode/modules/manage_snmp_modules']['text'] = __('SNMP Modules');
|
||||
$sub2['godmode/modules/manage_snmp_modules']['id'] = 'SNMP Modules';
|
||||
$sub2['godmode/modules/manage_wmi_modules']['text'] = __('WMI Modules');
|
||||
$sub2['godmode/modules/manage_wmi_modules']['id'] = 'WMI Modules';
|
||||
$sub['godmode/modules/manage_block_templates']['text'] = __('Module blocks');
|
||||
$sub['godmode/modules/manage_block_templates']['id'] = 'Module blocks';
|
||||
*/
|
||||
|
||||
|
||||
enterprise_hook('inventory_submenu');
|
||||
enterprise_hook('autoconfiguration_menu');
|
||||
enterprise_hook('agent_repository_menu');
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2020 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// Load global vars
|
||||
// TESTING
|
||||
/*
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
*/
|
||||
// END
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'PM')) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access Network Profile Management'
|
||||
);
|
||||
include 'general/noaccess.php';
|
||||
return;
|
||||
}
|
||||
|
||||
echo 'HOLA PRINCIPAL';
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
/**
|
||||
* Module Templates management.
|
||||
*
|
||||
* @category Module templates management.
|
||||
* @package Pandora FMS
|
||||
* @subpackage Opensource
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2020 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Begin.
|
||||
global $config;
|
||||
|
||||
require_once $config['homedir'].'/include/class/ModuleTemplates.class.php';
|
||||
|
||||
// This page.
|
||||
$ajaxPage = 'godmode/modules/manage_module_templates';
|
||||
|
||||
// Control call flow.
|
||||
try {
|
||||
// User access and validation is being processed on class constructor.
|
||||
$obj = new ModuleTemplates($ajaxPage);
|
||||
} catch (Exception $e) {
|
||||
if (is_ajax()) {
|
||||
echo json_encode(['error' => '[ModuleTemplates]'.$e->getMessage() ]);
|
||||
exit;
|
||||
} else {
|
||||
echo '[ModuleTemplates]'.$e->getMessage();
|
||||
}
|
||||
|
||||
// Stop this execution, but continue 'globally'.
|
||||
return;
|
||||
}
|
||||
|
||||
// AJAX controller.
|
||||
if (is_ajax()) {
|
||||
$method = get_parameter('method');
|
||||
|
||||
if (method_exists($obj, $method) === true) {
|
||||
$obj->{$method}();
|
||||
} else {
|
||||
$obj->error('Method not found. ['.$method.']');
|
||||
}
|
||||
|
||||
// Stop any execution.
|
||||
exit;
|
||||
} else {
|
||||
// Run.
|
||||
$obj->run();
|
||||
}
|
|
@ -66,7 +66,7 @@ if (defined('METACONSOLE')) {
|
|||
}
|
||||
|
||||
ui_print_page_header(
|
||||
__('Module management').' » '.__('Network component management'),
|
||||
__('Module management').' » '.__('Remote component management'),
|
||||
'',
|
||||
false,
|
||||
$help_header,
|
||||
|
|
|
@ -45,8 +45,15 @@ ui_print_page_header(
|
|||
true,
|
||||
'modulemodal'
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
// At this moment, this message is not necessary
|
||||
ui_print_info_message(
|
||||
__(
|
||||
'This section is maintained only for legacy use. Please, keep in mind use %s for manage template blocks.',
|
||||
'<a href="'.ui_get_full_url('index.php?logged=1&sec=gmodules&sec2=godmode/modules/manage_block_templates').'">Module Blocks</a>'
|
||||
)
|
||||
);
|
||||
*/
|
||||
require_once 'include/functions_network_profiles.php';
|
||||
|
||||
$delete_profile = (bool) get_parameter('delete_profile');
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
/**
|
||||
* Private Enterprise Number managemtn.
|
||||
*
|
||||
* @category PEN management.
|
||||
* @package Pandora FMS
|
||||
* @subpackage Opensource
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Begin.
|
||||
global $config;
|
||||
|
||||
require_once $config['homedir'].'/include/class/ConfigPEN.class.php';
|
||||
|
||||
// This page.
|
||||
$ajaxPage = 'godmode/modules/private_enterprise_numbers';
|
||||
|
||||
// Control call flow.
|
||||
try {
|
||||
// User access and validation is being processed on class constructor.
|
||||
$obj = new ConfigPEN($ajaxPage);
|
||||
} catch (Exception $e) {
|
||||
if (is_ajax()) {
|
||||
echo json_encode(['error' => '[ConfigPEN]'.$e->getMessage() ]);
|
||||
exit;
|
||||
} else {
|
||||
echo '[ConfigPEN]'.$e->getMessage();
|
||||
}
|
||||
|
||||
// Stop this execution, but continue 'globally'.
|
||||
return;
|
||||
}
|
||||
|
||||
// AJAX controller.
|
||||
if (is_ajax()) {
|
||||
$method = get_parameter('method');
|
||||
|
||||
if (method_exists($obj, $method) === true) {
|
||||
$obj->{$method}();
|
||||
} else {
|
||||
$obj->error('Method not found. ['.$method.']');
|
||||
}
|
||||
|
||||
// Stop any execution.
|
||||
exit;
|
||||
} else {
|
||||
// Run.
|
||||
$obj->run();
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
enterprise_include_once('include/functions_license.php');
|
||||
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
|
@ -48,6 +50,9 @@ function get_wiz_class($str)
|
|||
case 'ctask':
|
||||
return 'ConsoleTasks';
|
||||
|
||||
case 'deploymentCenter':
|
||||
return 'DeploymentCenter';
|
||||
|
||||
default:
|
||||
// Main, show header.
|
||||
ui_print_page_header(
|
||||
|
@ -124,13 +129,28 @@ $classname_selected = get_wiz_class($wiz_in_use);
|
|||
|
||||
// Else: class not found pseudo exception.
|
||||
if ($classname_selected !== null) {
|
||||
$wiz = new $classname_selected($page);
|
||||
$result = $wiz->run();
|
||||
if (is_array($result) === true) {
|
||||
// Redirect control and messages to DiscoveryTasklist.
|
||||
$classname_selected = 'DiscoveryTaskList';
|
||||
$wiz = new $classname_selected($page);
|
||||
$result = $wiz->run($result['msg'], $result['result']);
|
||||
$wiz = new $classname_selected((int) $page);
|
||||
|
||||
// AJAX controller.
|
||||
if (is_ajax()) {
|
||||
$method = get_parameter('method');
|
||||
|
||||
if (method_exists($wiz, $method) === true) {
|
||||
$wiz->{$method}();
|
||||
} else {
|
||||
$wiz->error('Method not found. ['.$method.']');
|
||||
}
|
||||
|
||||
// Stop any execution.
|
||||
exit;
|
||||
} else {
|
||||
$result = $wiz->run();
|
||||
if (is_array($result) === true) {
|
||||
// Redirect control and messages to DiscoveryTasklist.
|
||||
$classname_selected = 'DiscoveryTaskList';
|
||||
$wiz = new $classname_selected($page);
|
||||
$result = $wiz->run($result['msg'], $result['result']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ global $config;
|
|||
|
||||
check_login();
|
||||
|
||||
require 'vendor/autoload.php';
|
||||
require_once $config['homedir'].'/vendor/autoload.php';
|
||||
|
||||
use PandoraFMS\Dashboard\Manager;
|
||||
|
||||
|
|
|
@ -160,8 +160,6 @@ if (isset($_GET['user_del'])) {
|
|||
$result = delete_user($id_user);
|
||||
|
||||
if ($result) {
|
||||
users_save_logout($user_row, true);
|
||||
|
||||
db_pandora_audit(
|
||||
'User management',
|
||||
__('Deleted user %s', io_safe_input($id_user))
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Extension to schedule tasks on Pandora FMS Console
|
||||
* Defines wizard to configure discovery tasks (Host&devices)
|
||||
*
|
||||
* @category Wizard
|
||||
* @package Pandora FMS
|
||||
|
@ -58,7 +58,6 @@ class HostDevices extends Wizard
|
|||
public $pageLabelsNetScan = [
|
||||
'NetScan definition',
|
||||
'NetScan features',
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -139,6 +138,8 @@ class HostDevices extends Wizard
|
|||
// Load styles.
|
||||
parent::run();
|
||||
|
||||
ui_require_css_file('hostdevices');
|
||||
|
||||
$mode = get_parameter('mode', null);
|
||||
|
||||
if ($mode === null) {
|
||||
|
@ -269,6 +270,8 @@ class HostDevices extends Wizard
|
|||
*/
|
||||
public function parseNetScan()
|
||||
{
|
||||
global $config;
|
||||
|
||||
if ($this->page == 0) {
|
||||
// Check if we're updating a task.
|
||||
$task_id = get_parameter('task', null);
|
||||
|
@ -297,9 +300,63 @@ class HostDevices extends Wizard
|
|||
$comment = get_parameter('comment', '');
|
||||
$server_id = get_parameter('id_recon_server', '');
|
||||
$network = get_parameter('network', '');
|
||||
$network_csv_enabled = (bool) get_parameter_switch(
|
||||
'network_csv_enabled',
|
||||
false
|
||||
);
|
||||
$id_group = get_parameter('id_group', '');
|
||||
$interval = get_parameter('interval', 0);
|
||||
|
||||
if ($network_csv_enabled) {
|
||||
if (empty($_FILES['network_csv']['type']) === false) {
|
||||
if ($_FILES['network_csv']['type'] != 'text/csv'
|
||||
&& $_FILES['network_csv']['type'] != 'text/plain'
|
||||
&& $_FILES['network_csv']['type'] != 'application/octet-stream'
|
||||
&& $_FILES['network_csv']['type'] != 'application/vnd.ms-excel'
|
||||
&& $_FILES['network_csv']['type'] != 'text/x-csv'
|
||||
&& $_FILES['network_csv']['type'] != 'application/csv'
|
||||
&& $_FILES['network_csv']['type'] != 'application/x-csv'
|
||||
&& $_FILES['network_csv']['type'] != 'text/csv'
|
||||
&& $_FILES['network_csv']['type'] != 'text/comma-separated-values'
|
||||
&& $_FILES['network_csv']['type'] != 'text/x-comma-separated-values'
|
||||
&& $_FILES['network_csv']['type'] != 'text/tab-separated-values'
|
||||
) {
|
||||
$this->msg = __(
|
||||
'Invalid mimetype for csv file: %s',
|
||||
$_FILES['network_csv']['type']
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
$network = preg_split(
|
||||
"/\n|,|;/",
|
||||
trim(
|
||||
file_get_contents(
|
||||
$_FILES['network_csv']['tmp_name']
|
||||
)
|
||||
)
|
||||
);
|
||||
unlink($_FILES['network_csv']['tmp_name']);
|
||||
if (empty($network) || is_array($network) === false) {
|
||||
$this->msg = __(
|
||||
'Invalid content readed from csv file: %s',
|
||||
$_FILES['network_csv']['name']
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Sanitize.
|
||||
$network = array_unique($network);
|
||||
$network = array_filter(
|
||||
$network,
|
||||
function ($item) {
|
||||
return (!empty($item));
|
||||
}
|
||||
);
|
||||
$network = join(',', $network);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($task_id) === true) {
|
||||
// We're updating this task.
|
||||
$task = db_get_row(
|
||||
|
@ -333,18 +390,15 @@ class HostDevices extends Wizard
|
|||
if ($task_id !== null
|
||||
&& $taskname == null
|
||||
&& $server_id == null
|
||||
&& $id_group == null
|
||||
&& $server == null
|
||||
&& $datacenter == ''
|
||||
&& $user == ''
|
||||
&& $pass == ''
|
||||
&& $encrypt == null
|
||||
&& $interval == 0
|
||||
&& empty($id_group) === true
|
||||
&& empty($network) === true
|
||||
&& empty($network_csv) === true
|
||||
&& $interval === 0
|
||||
) {
|
||||
// Default values, no data received.
|
||||
// User is accesing directly to this page.
|
||||
if (check_acl(
|
||||
$config['id_usuario'],
|
||||
$config['id_user'],
|
||||
$this->task['id_group'],
|
||||
$this->access
|
||||
) != true
|
||||
|
@ -386,6 +440,7 @@ class HostDevices extends Wizard
|
|||
$this->task['id_recon_server'] = $server_id;
|
||||
$this->task['id_group'] = $id_group;
|
||||
$this->task['interval_sweep'] = $interval;
|
||||
$this->task['subnet_csv'] = $network_csv_enabled;
|
||||
|
||||
if (isset($this->task['id_rt']) === false) {
|
||||
// Create.
|
||||
|
@ -423,7 +478,10 @@ class HostDevices extends Wizard
|
|||
return false;
|
||||
}
|
||||
|
||||
$id_network_profile = get_parameter('id_network_profile', null);
|
||||
$id_network_profile = get_parameter('id_network_profile', []);
|
||||
$review_results = get_parameter_switch('review_results');
|
||||
$review_limited = (bool) get_parameter('review_limited', 0);
|
||||
$auto_monitor = get_parameter_switch('auto_monitor');
|
||||
$autoconf_enabled = get_parameter_switch(
|
||||
'autoconfiguration_enabled'
|
||||
);
|
||||
|
@ -443,7 +501,7 @@ class HostDevices extends Wizard
|
|||
$snmp_privacy_pass = get_parameter('snmp_privacy_pass', null);
|
||||
$snmp_auth_method = get_parameter('snmp_auth_method', null);
|
||||
$snmp_security_level = get_parameter('snmp_security_level', null);
|
||||
$auth_strings = get_parameter('auth_strings', null);
|
||||
$auth_strings = get_parameter('auth_strings', []);
|
||||
|
||||
if ($snmp_version == 3) {
|
||||
$this->task['snmp_community'] = $snmp_context;
|
||||
|
@ -452,7 +510,28 @@ class HostDevices extends Wizard
|
|||
}
|
||||
|
||||
$this->task['autoconfiguration_enabled'] = $autoconf_enabled;
|
||||
$this->task['id_network_profile'] = $id_network_profile;
|
||||
$this->task['id_network_profile'] = '';
|
||||
if (is_array($id_network_profile) === true) {
|
||||
$this->task['id_network_profile'] = join(
|
||||
',',
|
||||
$id_network_profile
|
||||
);
|
||||
}
|
||||
|
||||
if ($review_limited === true) {
|
||||
// License limited, force review.
|
||||
$this->task['review_mode'] = DISCOVERY_REVIEW;
|
||||
} else {
|
||||
if ($review_results) {
|
||||
if ($this->task['review_mode'] != DISCOVERY_RESULTS) {
|
||||
$this->task['review_mode'] = DISCOVERY_REVIEW;
|
||||
}
|
||||
} else {
|
||||
$this->task['review_mode'] = DISCOVERY_STANDARD;
|
||||
}
|
||||
}
|
||||
|
||||
$this->task['auto_monitor'] = $auto_monitor;
|
||||
$this->task['snmp_enabled'] = $snmp_enabled;
|
||||
$this->task['os_detect'] = $os_detect;
|
||||
$this->task['parent_detection'] = $parent_detection;
|
||||
|
@ -467,7 +546,13 @@ class HostDevices extends Wizard
|
|||
$this->task['snmp_privacy_pass'] = $snmp_privacy_pass;
|
||||
$this->task['snmp_auth_method'] = $snmp_auth_method;
|
||||
$this->task['snmp_security_level'] = $snmp_security_level;
|
||||
$this->task['auth_strings'] = $auth_strings;
|
||||
$this->task['auth_strings'] = '';
|
||||
if (is_array($auth_strings) === true) {
|
||||
$this->task['auth_strings'] = join(
|
||||
',',
|
||||
$auth_strings
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->task['disabled'] == 2) {
|
||||
// Wizard finished.
|
||||
|
@ -562,7 +647,7 @@ class HostDevices extends Wizard
|
|||
// Check ACL. If user is not able to manage target task,
|
||||
// redirect him to main page.
|
||||
if (check_acl(
|
||||
$config['id_usuario'],
|
||||
$config['id_user'],
|
||||
$this->task['id_group'],
|
||||
$this->access
|
||||
) != true
|
||||
|
@ -598,10 +683,21 @@ class HostDevices extends Wizard
|
|||
}
|
||||
|
||||
if ($this->page < $this->maxPagesNetScan) {
|
||||
$title = __('NetScan');
|
||||
|
||||
if ($this->page == 1) {
|
||||
$title = __(
|
||||
'"%s" features',
|
||||
io_safe_output(
|
||||
$this->task['name']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Avoid to print header out of wizard.
|
||||
$this->prepareBreadcrum($breadcrum);
|
||||
ui_print_page_header(
|
||||
__('NetScan'),
|
||||
$title,
|
||||
'',
|
||||
false,
|
||||
'',
|
||||
|
@ -678,7 +774,7 @@ class HostDevices extends Wizard
|
|||
|
||||
$form['rows'][0]['columns'][0] = [
|
||||
'width' => '30%',
|
||||
'style' => 'padding: 9px;',
|
||||
'style' => 'padding: 9px;min-width: 250px;',
|
||||
'inputs' => [
|
||||
'0' => [
|
||||
'arguments' => [
|
||||
|
@ -705,7 +801,10 @@ class HostDevices extends Wizard
|
|||
'name' => 'interval_manual_defined',
|
||||
'return' => true,
|
||||
],
|
||||
'extra' => '<span id="interval_manual_container">'.html_print_extended_select_for_time(
|
||||
'extra' => '<div id="interval_manual_container"><div class="time_selection_container">'.ui_print_help_tip(
|
||||
__('The minimum recomended interval for Recon Task is 5 minutes'),
|
||||
true
|
||||
).html_print_extended_select_for_time(
|
||||
'interval',
|
||||
$this->task['interval_sweep'],
|
||||
'',
|
||||
|
@ -715,10 +814,7 @@ class HostDevices extends Wizard
|
|||
true,
|
||||
false,
|
||||
false
|
||||
).ui_print_help_tip(
|
||||
__('The minimum recomended interval for Recon Task is 5 minutes'),
|
||||
true
|
||||
).'</span>',
|
||||
).'</div></div>',
|
||||
|
||||
],
|
||||
],
|
||||
|
@ -728,6 +824,7 @@ class HostDevices extends Wizard
|
|||
'width' => '40%',
|
||||
'padding-right' => '12%',
|
||||
'padding-left' => '5%',
|
||||
'style' => 'min-width: 350px',
|
||||
'inputs' => [
|
||||
'0' => [
|
||||
'label' => '<b>'.__('Task name').':</b>',
|
||||
|
@ -760,6 +857,54 @@ class HostDevices extends Wizard
|
|||
],
|
||||
],
|
||||
'2' => [
|
||||
'label' => '<b>'.__('Use CSV file definition').':</b>'.ui_print_help_tip(
|
||||
__('Define targets using csv o network definition.'),
|
||||
true
|
||||
),
|
||||
'class' => 'no-margin',
|
||||
'arguments' => [
|
||||
'name' => 'network_csv_enabled',
|
||||
'value' => $this->task['subnet_csv'],
|
||||
'type' => 'switch',
|
||||
'inline' => true,
|
||||
'class' => 'discovery_full_width_input',
|
||||
'onclick' => 'toggleNetwork(this);',
|
||||
],
|
||||
],
|
||||
'3' => [
|
||||
'hidden' => (($this->task['subnet_csv'] == '1') ? 0 : 1),
|
||||
'block_id' => 'csv_subnet',
|
||||
'block_content' => [
|
||||
[
|
||||
'label' => '<b>'.__('Networks (csv)').':</b>'.ui_print_help_tip(
|
||||
__('You can upload a CSV file. Each line must contain a network in IP/MASK format. For instance: 192.168.1.1/32'),
|
||||
true
|
||||
),
|
||||
'arguments' => [
|
||||
'name' => 'network_csv',
|
||||
'type' => 'file',
|
||||
'columns' => 25,
|
||||
'rows' => 10,
|
||||
'class' => 'discovery_full_width_input',
|
||||
],
|
||||
],
|
||||
[
|
||||
'label' => '<b>'.__('Networks (current)').':</b>'.ui_print_help_tip(
|
||||
__('Plese upload a new file to overwrite this content.'),
|
||||
true
|
||||
),
|
||||
'arguments' => [
|
||||
'attributes' => 'readonly',
|
||||
'type' => 'textarea',
|
||||
'size' => 25,
|
||||
'value' => $this->task['subnet'],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'4' => [
|
||||
'hidden' => (($this->task['subnet_csv'] == '1') ? 1 : 0),
|
||||
'id' => 'std_subnet',
|
||||
'label' => '<b>'.__('Network').':</b>'.ui_print_help_tip(
|
||||
__('You can specify several networks, separated by commas, for example: 192.168.50.0/24,192.168.60.0/24'),
|
||||
true
|
||||
|
@ -794,6 +939,7 @@ class HostDevices extends Wizard
|
|||
|
||||
$form['rows'][0]['columns'][2] = [
|
||||
'width' => '30%',
|
||||
'style' => 'min-width: 250px',
|
||||
'inputs' => ['0' => $group_select],
|
||||
];
|
||||
|
||||
|
@ -823,8 +969,9 @@ class HostDevices extends Wizard
|
|||
}
|
||||
|
||||
$form['form'] = [
|
||||
'method' => 'POST',
|
||||
'action' => $this->url.'&mode=netscan&page='.($this->page + 1).$task_url,
|
||||
'method' => 'POST',
|
||||
'enctype' => 'multipart/form-data',
|
||||
'action' => $this->url.'&mode=netscan&page='.($this->page + 1).$task_url,
|
||||
];
|
||||
|
||||
// Default.
|
||||
|
@ -848,7 +995,19 @@ class HostDevices extends Wizard
|
|||
$("#hidden-interval").val('.$interval.');
|
||||
$("#interval_units").val('.$unit.');
|
||||
}
|
||||
}).change();';
|
||||
}).change();
|
||||
|
||||
function toggleNetwork(e) {
|
||||
if (e.checked) {
|
||||
$(\'#csv_subnet\').removeClass("hidden");
|
||||
$(\'#std_subnet\').addClass("hidden");
|
||||
} else {
|
||||
$(\'#csv_subnet\').addClass("hidden");
|
||||
$(\'#std_subnet\').removeClass("hidden");
|
||||
}
|
||||
};
|
||||
|
||||
';
|
||||
|
||||
$this->printFormAsGrid($form);
|
||||
$this->printGoBackButton($this->url.'&page='.($this->page - 1));
|
||||
|
@ -878,21 +1037,101 @@ class HostDevices extends Wizard
|
|||
];
|
||||
|
||||
$form['inputs'][] = [
|
||||
'extra' => '<p><h3>Please, configure task <b>'.io_safe_output($this->task['name']).'</b></h3></p>',
|
||||
'label' => __('Auto discover known hardware').ui_print_help_tip(
|
||||
__(
|
||||
'Targets will be monitorized based on its <i>Private Enterprise Number</i>. Requires SNMP.'
|
||||
),
|
||||
true
|
||||
),
|
||||
'arguments' => [
|
||||
'name' => 'auto_monitor',
|
||||
'type' => 'switch',
|
||||
'return' => true,
|
||||
'value' => (isset($this->task['auto_monitor'])) ? $this->task['auto_monitor'] : 1,
|
||||
],
|
||||
];
|
||||
|
||||
$form['inputs'][] = [
|
||||
'label' => __('Module template'),
|
||||
'label' => __('Module templates').ui_print_help_tip(
|
||||
__(
|
||||
'Module <i>Host Alive</i> will be added to discovered agents by default.'
|
||||
),
|
||||
true
|
||||
),
|
||||
'arguments' => [
|
||||
'name' => 'id_network_profile',
|
||||
'name' => 'id_network_profile[]',
|
||||
'type' => 'select_from_sql',
|
||||
'sql' => 'SELECT id_np, name
|
||||
FROM tnetwork_profile
|
||||
ORDER BY name',
|
||||
'sql' => 'SELECT tn.id_np, tn.name
|
||||
FROM tnetwork_profile tn
|
||||
LEFT JOIN `tnetwork_profile_pen` tp
|
||||
ON tp.id_np = tn.id_np
|
||||
WHERE tp.id_np IS NULL
|
||||
ORDER BY tn.name',
|
||||
'return' => true,
|
||||
'selected' => $this->task['id_network_profile'],
|
||||
'selected' => explode(
|
||||
',',
|
||||
$this->task['id_network_profile']
|
||||
),
|
||||
'nothing_value' => 0,
|
||||
'nothing' => __('None'),
|
||||
'multiple' => true,
|
||||
'class' => 'select_multiple',
|
||||
],
|
||||
];
|
||||
|
||||
// License precheck.
|
||||
$license = enterprise_hook('license_get_info');
|
||||
$n_agents = 0;
|
||||
foreach (explode(',', $this->task['subnet']) as $net) {
|
||||
$mask = explode('/', $net, 2)[1];
|
||||
if (empty($mask)) {
|
||||
$n_agents++;
|
||||
} else {
|
||||
$n_agents += pow(2, (32 - $mask));
|
||||
}
|
||||
}
|
||||
|
||||
$limited = false;
|
||||
if (is_array($license) === true
|
||||
&& $n_agents > ($license['limit'] - $license['count'])
|
||||
) {
|
||||
$limit = ($license['limit'] - $license['count']);
|
||||
$limited = true;
|
||||
}
|
||||
|
||||
if ($limited === true) {
|
||||
ui_print_warning_message(
|
||||
__(
|
||||
'Configured networks could generate %d agents, your license only allows %d, \'review results\' is mandatory.',
|
||||
$n_agents,
|
||||
$limit
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$form['inputs'][] = [
|
||||
'label' => __('Review results').ui_print_help_tip(
|
||||
__(
|
||||
'Targets must be validated by user before create agents.'
|
||||
),
|
||||
true
|
||||
),
|
||||
'arguments' => [
|
||||
'name' => 'review_results',
|
||||
'type' => 'switch',
|
||||
'return' => true,
|
||||
'value' => ($this->task['review_mode'] == DISCOVERY_STANDARD) ? (($limited) ? 1 : 0) : 1,
|
||||
'disabled' => $limited,
|
||||
],
|
||||
];
|
||||
|
||||
// Review limited.
|
||||
$form['inputs'][] = [
|
||||
'arguments' => [
|
||||
'name' => 'review_limited',
|
||||
'type' => 'hidden',
|
||||
'return' => true,
|
||||
'value' => (($limited === true) ? 1 : 0),
|
||||
],
|
||||
];
|
||||
|
||||
|
@ -930,7 +1169,7 @@ class HostDevices extends Wizard
|
|||
// Submit button.
|
||||
$form['inputs'][] = [
|
||||
'arguments' => [
|
||||
'name' => 'submit',
|
||||
'name' => 'submit-finish',
|
||||
'label' => __('Finish'),
|
||||
'type' => 'submit',
|
||||
'attributes' => 'class="sub next"',
|
||||
|
|
|
@ -41,7 +41,7 @@ class Wizard
|
|||
/**
|
||||
* Breadcrum
|
||||
*
|
||||
* @var array.
|
||||
* @var array
|
||||
*/
|
||||
public $breadcrum;
|
||||
|
||||
|
@ -233,6 +233,27 @@ class Wizard
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return formatted html for error handler.
|
||||
*
|
||||
* @param string $message Error mesage.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function error($message)
|
||||
{
|
||||
if (is_ajax()) {
|
||||
echo json_encode(
|
||||
[
|
||||
'error' => ui_print_error_message($message, '', true),
|
||||
]
|
||||
);
|
||||
} else {
|
||||
return ui_print_error_message($message, '', true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To be overwritten.
|
||||
*
|
||||
|
@ -566,66 +587,40 @@ class Wizard
|
|||
|
||||
if (is_array($input['block_content']) === true) {
|
||||
// Print independent block of inputs.
|
||||
$output .= '<li id="'.$input['block_id'].'" class="'.$class.'">';
|
||||
$output .= '<div id="'.$input['block_id'].'" class="wizard '.$class.'">';
|
||||
$output .= '<ul class="wizard '.$input['block_class'].'">';
|
||||
foreach ($input['block_content'] as $input) {
|
||||
$output .= $this->printBlockAsGrid($input, $return);
|
||||
}
|
||||
|
||||
$output .= '</ul></li>';
|
||||
$output .= '</ul></div>';
|
||||
} else {
|
||||
if ($input['arguments']['type'] != 'hidden'
|
||||
&& $input['arguments']['type'] != 'hidden_extended'
|
||||
) {
|
||||
if ($input['arguments']['inline'] != 'true') {
|
||||
$output .= '<div class="edit_discovery_input">';
|
||||
} else {
|
||||
$output .= '<div style="display: flex; margin-bottom: 25px; flex-wrap: wrap;">';
|
||||
if (!isset($input['extra'])) {
|
||||
$output .= '<div style="width: 50%;">';
|
||||
}
|
||||
|
||||
if (isset($input['extra'])) {
|
||||
$output .= '<div style="display: flex; margin-right:10px;">';
|
||||
}
|
||||
$id = '';
|
||||
if ($input['id']) {
|
||||
$id = $input['id'];
|
||||
}
|
||||
|
||||
if ($input['arguments']['inline'] == 'true' && isset($input['extra'])) {
|
||||
$output .= '<div style="margin-right:10px;">';
|
||||
if ($input['arguments']['inline'] != 'true') {
|
||||
$output .= '<div id="'.$id.'" class="std_input '.$class.'">';
|
||||
} else {
|
||||
$output .= '<div id="'.$id.'" class="inline_input '.$class.'">';
|
||||
}
|
||||
|
||||
$output .= '<div class="label_select">';
|
||||
$output .= $input['label'];
|
||||
$output .= '</div>';
|
||||
|
||||
if ($input['arguments']['inline'] == 'true' && isset($input['extra'])) {
|
||||
$output .= '</div>';
|
||||
}
|
||||
|
||||
if ($input['arguments']['inline'] == 'true' && !isset($input['extra'])) {
|
||||
$output .= '</div>';
|
||||
}
|
||||
|
||||
if ($input['arguments']['type'] == 'text' || $input['arguments']['type'] == 'text_extended') {
|
||||
$output .= '<div class="discovery_text_input">';
|
||||
$output .= $this->printInput($input['arguments']);
|
||||
$output .= '</div>';
|
||||
} else if ($input['arguments']['inline'] == 'true') {
|
||||
if (isset($input['extra'])) {
|
||||
$output .= '<div style="">';
|
||||
$output .= '<div style="float: left;">';
|
||||
} else {
|
||||
$output .= '<div style="width:50%;">';
|
||||
$output .= '<div style="float: right;">';
|
||||
}
|
||||
|
||||
$output .= '<div class="discovery_inline_input">';
|
||||
$output .= $this->printInput($input['arguments']);
|
||||
$output .= '</div>';
|
||||
$output .= '</div>';
|
||||
|
||||
if (isset($input['extra'])) {
|
||||
$output .= '</div>';
|
||||
}
|
||||
} else {
|
||||
$output .= $this->printInput($input['arguments']);
|
||||
}
|
||||
|
@ -800,7 +795,7 @@ class Wizard
|
|||
$cb_function = $data['cb_function'];
|
||||
$cb_args = $data['cb_args'];
|
||||
|
||||
$output_head = '<form class="discovery" onsubmit="'.$form['onsubmit'].'" enctype="'.$form['enctype'].'" action="'.$form['action'].'" method="'.$form['method'];
|
||||
$output_head = '<form class="discovery wizard" onsubmit="'.$form['onsubmit'].'" enctype="'.$form['enctype'].'" action="'.$form['action'].'" method="'.$form['method'];
|
||||
$output_head .= '" '.$form['extra'].'>';
|
||||
|
||||
if ($return === false) {
|
||||
|
|
|
@ -917,9 +917,11 @@ if ($get_response) {
|
|||
if ($perform_event_response) {
|
||||
global $config;
|
||||
|
||||
$command = get_parameter('target', '');
|
||||
|
||||
$response_id = get_parameter('response_id');
|
||||
$event_id = (int) get_parameter('event_id');
|
||||
$server_id = (int) get_parameter('server_id', 0);
|
||||
|
||||
$command = events_get_response_target($event_id, $response_id, $server_id);
|
||||
|
||||
$event_response = db_get_row('tevent_response', 'id', $response_id);
|
||||
|
||||
|
@ -1017,6 +1019,7 @@ if ($dialogue_event_response) {
|
|||
$show_execute_again_btn = get_parameter('show_execute_again_btn');
|
||||
$out_iterator = get_parameter('out_iterator');
|
||||
$event_response = db_get_row('tevent_response', 'id', $response_id);
|
||||
$server_id = get_parameter('server_id');
|
||||
|
||||
$event = db_get_row('tevento', 'id_evento', $event_id);
|
||||
|
||||
|
@ -1067,7 +1070,8 @@ if ($dialogue_event_response) {
|
|||
echo "<br><div id='response_out' style='text-align:left'></div>";
|
||||
|
||||
echo "<br><div id='re_exec_command' style='display:none;'>";
|
||||
html_print_button(__('Execute again'), 'btn_str', false, 'perform_response(\''.$command.'\', '.$response_id.');', "class='sub next'");
|
||||
html_print_button(__('Execute again'), 'btn_str', false, "perform_response({'target':'".$command."','event_id':".$event_id.",'server_id':".$server_id.'}, '.$response_id.');', "class='sub next'");
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -1034,86 +1034,7 @@ if (check_login()) {
|
|||
}
|
||||
}
|
||||
|
||||
if (is_numeric($module['datos']) && !modules_is_string_type($module['id_tipo_modulo'])) {
|
||||
if ($config['render_proc']) {
|
||||
switch ($module['id_tipo_modulo']) {
|
||||
case 2:
|
||||
case 6:
|
||||
case 9:
|
||||
case 18:
|
||||
case 21:
|
||||
case 31:
|
||||
if ($module['datos'] >= 1) {
|
||||
$salida = $config['render_proc_ok'];
|
||||
} else {
|
||||
$salida = $config['render_proc_fail'];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
switch ($module['id_tipo_modulo']) {
|
||||
case 15:
|
||||
$value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module['id_agente_modulo']);
|
||||
if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') {
|
||||
if ($module['post_process'] > 0) {
|
||||
$salida = human_milliseconds_to_string(($module['datos'] / $module['post_process']));
|
||||
} else {
|
||||
$salida = human_milliseconds_to_string($module['datos']);
|
||||
}
|
||||
} else {
|
||||
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision']));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision']));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch ($module['id_tipo_modulo']) {
|
||||
case 15:
|
||||
$value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module['id_agente_modulo']);
|
||||
if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') {
|
||||
if ($module['post_process'] > 0) {
|
||||
$salida = human_milliseconds_to_string(($module['datos'] / $module['post_process']));
|
||||
} else {
|
||||
$salida = human_milliseconds_to_string($module['datos']);
|
||||
}
|
||||
} else {
|
||||
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision']));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision']));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Show units ONLY in numeric data types
|
||||
if (isset($module['unit'])) {
|
||||
$data_macro = modules_get_unit_macro($module['datos'], $module['unit']);
|
||||
if ($data_macro) {
|
||||
$salida = $data_macro;
|
||||
} else {
|
||||
$salida .= ' <i>'.io_safe_output($module['unit']).'</i>';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$data_macro = modules_get_unit_macro($module['datos'], $module['unit']);
|
||||
if ($data_macro) {
|
||||
$salida = $data_macro;
|
||||
} else {
|
||||
$salida = ui_print_module_string_value(
|
||||
$module['datos'],
|
||||
$module['id_agente_modulo'],
|
||||
$module['current_interval'],
|
||||
$module['module_name']
|
||||
);
|
||||
}
|
||||
}
|
||||
$salida = modules_get_agentmodule_data_for_humans($module);
|
||||
|
||||
if ($module['id_tipo_modulo'] != 25) {
|
||||
$data[6] = ui_print_module_warn_value($module['max_warning'], $module['min_warning'], $module['str_warning'], $module['max_critical'], $module['min_critical'], $module['str_critical'], $module['warning_inverse'], $module['critical_inverse']);
|
||||
|
|
|
@ -24,154 +24,7 @@
|
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*
|
||||
*
|
||||
* MOVED TO DiscoveryTaskList.class.
|
||||
*/
|
||||
|
||||
require_once $config['homedir'].'/include/graphs/functions_d3.php';
|
||||
|
||||
$progress_task_discovery = (bool) get_parameter('progress_task_discovery', 0);
|
||||
$showmap = (bool) get_parameter('showmap', 0);
|
||||
|
||||
if ($progress_task_discovery) {
|
||||
$id_task = get_parameter('id', 0);
|
||||
|
||||
if ($id_task <= 0) {
|
||||
echo json_encode(['error' => true]);
|
||||
return;
|
||||
}
|
||||
|
||||
$task = db_get_row('trecon_task', 'id_rt', $id_task);
|
||||
$global_progress = $task['status'];
|
||||
$summary = json_decode($task['summary'], true);
|
||||
|
||||
$result = '<div id = progress_task_'.$id_task.'>';
|
||||
if ($task['utimestamp']) {
|
||||
$result .= '<div style="display: flex;">';
|
||||
$result .= '<div style="width: 100%; text-align: center; margin-top: 40px;">';
|
||||
$result .= '<span style="font-size: 1.9em; font-family: "lato-bolder", "Open Sans", sans-serif !important;">'._('Overall Progress').'</span>';
|
||||
|
||||
$result .= '<div style="margin-top: 25px;">';
|
||||
$result .= progress_circular_bar(
|
||||
$id_task,
|
||||
($global_progress < 0) ? 100 : $global_progress,
|
||||
200,
|
||||
200,
|
||||
'#7eb641',
|
||||
'%',
|
||||
'',
|
||||
'#3A3A3A',
|
||||
0
|
||||
);
|
||||
|
||||
$result .= '</div>';
|
||||
|
||||
if ($global_progress > 0) {
|
||||
switch ($summary['step']) {
|
||||
case STEP_SCANNING:
|
||||
$str = __('Scanning network');
|
||||
break;
|
||||
|
||||
case STEP_AFT:
|
||||
$str = __('Finding AFT connectivity');
|
||||
break;
|
||||
|
||||
case STEP_TRACEROUTE:
|
||||
$str = __('Finding traceroute connectivity');
|
||||
break;
|
||||
|
||||
case STEP_GATEWAY:
|
||||
$str = __('Finding gateway connectivity');
|
||||
break;
|
||||
|
||||
default:
|
||||
$str = __('Searching for devices...');
|
||||
break;
|
||||
}
|
||||
|
||||
$result .= '</div>';
|
||||
$result .= '<div style="width: 100%; text-align: center; margin-top: 40px;">';
|
||||
$result .= '<span style="font-size: 1.9em; font-family: "lato-bolder", "Open Sans", sans-serif !important;">'.$str.' ';
|
||||
$result .= $summary['c_network_name'];
|
||||
$result .= '</span>';
|
||||
|
||||
$result .= '<div style="margin-top: 25px;">';
|
||||
$result .= progress_circular_bar(
|
||||
$id_task.'_detail',
|
||||
$summary['c_network_percent'],
|
||||
200,
|
||||
200,
|
||||
'#7eb641',
|
||||
'%',
|
||||
'',
|
||||
'#3A3A3A',
|
||||
0
|
||||
);
|
||||
$result .= '</div></div>';
|
||||
}
|
||||
|
||||
$result .= '</div></div>';
|
||||
|
||||
$i = 0;
|
||||
$table = new StdClasS();
|
||||
$table->class = 'databox data';
|
||||
$table->width = '75%';
|
||||
$table->styleTable = 'margin: 2em auto 0;border: 1px solid #ddd;background: white;';
|
||||
$table->rowid = [];
|
||||
$table->data = [];
|
||||
|
||||
// Content.
|
||||
$table->data[$i][0] = '<b>'.__('Hosts discovered').'</b>';
|
||||
$table->data[$i][1] = '<span id="discovered">';
|
||||
$table->data[$i][1] .= $summary['summary']['discovered'];
|
||||
$table->data[$i++][1] .= '</span>';
|
||||
|
||||
$table->data[$i][0] = '<b>'.__('Alive').'</b>';
|
||||
$table->data[$i][1] = '<span id="alive">';
|
||||
$table->data[$i][1] .= $summary['summary']['alive'];
|
||||
$table->data[$i++][1] .= '</span>';
|
||||
|
||||
$table->data[$i][0] = '<b>'.__('Not alive').'</b>';
|
||||
$table->data[$i][1] = '<span id="not_alive">';
|
||||
$table->data[$i][1] .= $summary['summary']['not_alive'];
|
||||
$table->data[$i++][1] .= '</span>';
|
||||
|
||||
$table->data[$i][0] = '<b>'.__('Responding SNMP').'</b>';
|
||||
$table->data[$i][1] = '<span id="SNMP">';
|
||||
$table->data[$i][1] .= $summary['summary']['SNMP'];
|
||||
$table->data[$i++][1] .= '</span>';
|
||||
|
||||
$table->data[$i][0] = '<b>'.__('Responding WMI').'</b>';
|
||||
$table->data[$i][1] = '<span id="WMI">';
|
||||
$table->data[$i][1] .= $summary['summary']['WMI'];
|
||||
$table->data[$i++][1] .= '</span>';
|
||||
|
||||
$result .= '<div style="margin-top: 40px; text-align: center;"><span style="font-size: 1.9em; font-family: "lato-bolder", "Open Sans", sans-serif !important;">'.__('Summary').'</span></div>';
|
||||
$result .= html_print_table($table, true).'</div>';
|
||||
} else {
|
||||
$global_progress = -1;
|
||||
$result .= ui_print_error_message(
|
||||
__('No data to show'),
|
||||
'',
|
||||
true
|
||||
).'</div>';
|
||||
}
|
||||
|
||||
$result_array['status'] = $global_progress;
|
||||
$result_array['html'] = $result;
|
||||
|
||||
echo json_encode($result_array);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($showmap) {
|
||||
include_once $config['homedir'].'/include/class/NetworkMap.class.php';
|
||||
$id_task = get_parameter('id', 0);
|
||||
|
||||
$map = new NetworkMap(
|
||||
[
|
||||
'id_task' => $id_task,
|
||||
'pure' => 1,
|
||||
'widget' => true,
|
||||
]
|
||||
);
|
||||
$map->printMap();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,782 @@
|
|||
<?php
|
||||
/**
|
||||
* Agent Wizard for SNMP and WMI
|
||||
*
|
||||
* @category Class
|
||||
* @package Pandora FMS
|
||||
* @subpackage Agent Configuration
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2020 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Get global data.
|
||||
global $config;
|
||||
|
||||
// Necessary class for extends.
|
||||
require_once $config['homedir'].'/include/class/HTML.class.php';
|
||||
/**
|
||||
* AgentWizard class
|
||||
*/
|
||||
class AgentWizard extends HTML
|
||||
{
|
||||
|
||||
/**
|
||||
* Var that contain very cool stuff
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $ajaxController;
|
||||
|
||||
/**
|
||||
* Contains the URL of this
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $baseUrl;
|
||||
|
||||
/**
|
||||
* Id of this current agent
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $idAgent;
|
||||
|
||||
/**
|
||||
* Wizard Section for Explore
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $wizardSection;
|
||||
|
||||
/**
|
||||
* Label to show what action are performing
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $actionLabel;
|
||||
|
||||
/**
|
||||
* Type of action to do
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
private $actionType;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $ajax_controller Pues hace cosas to wapas.
|
||||
*/
|
||||
public function __construct(string $ajax_controller)
|
||||
{
|
||||
global $config;
|
||||
|
||||
// Check access.
|
||||
check_login();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'AR')) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access event viewer'
|
||||
);
|
||||
|
||||
if (is_ajax()) {
|
||||
echo json_encode(['error' => 'noaccess']);
|
||||
}
|
||||
|
||||
include 'general/noaccess.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
// Set baseUrl for use it in several locations in this class.
|
||||
$this->baseUrl = ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=agent_wizard');
|
||||
// Capture all parameters before start.
|
||||
$this->ajaxController = $ajax_controller;
|
||||
$this->wizardSection = get_parameter('wizard_section', '');
|
||||
$this->idAgent = get_parameter('id_agente', '');
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run main page.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// CSS.
|
||||
ui_require_css_file('wizard');
|
||||
ui_require_css_file('discovery');
|
||||
|
||||
// Javascript.
|
||||
// ui_require_javascript_file('jquery.caret.min');
|
||||
$this->loadMainForm();
|
||||
$this->performWizard();
|
||||
// Load integrated JS
|
||||
$this->loadJS();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Common Main Wizard form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function loadMainForm()
|
||||
{
|
||||
// Define name of explorer button
|
||||
switch ($this->wizardSection) {
|
||||
case 'snmp_explorer':
|
||||
case 'snmp_interfaces_explorer':
|
||||
// Define labels.
|
||||
$this->actionType = 'snmp';
|
||||
$this->actionLabel = __('SNMP Walk');
|
||||
// Fill with servers to perform SNMP walk.
|
||||
$fieldsServers = [];
|
||||
$fieldsServers[0] = __('Local console');
|
||||
if (enterprise_installed()) {
|
||||
enterprise_include_once('include/functions_satellite.php');
|
||||
// Get the servers.
|
||||
$rows = get_proxy_servers();
|
||||
// Check if satellite server has remote configuration enabled.
|
||||
$satellite_remote = config_agents_has_remote_configuration($this->idAgent);
|
||||
// Generate a list with allowed servers.
|
||||
foreach ($rows as $row) {
|
||||
if ($row['server_type'] == 13) {
|
||||
$id_satellite = $row['id_server'];
|
||||
$serverType = ' (Satellite)';
|
||||
} else {
|
||||
$serverType = ' (Standard)';
|
||||
}
|
||||
|
||||
$fieldsServers[$row['id_server']] = $row['name'].$serverType;
|
||||
}
|
||||
}
|
||||
|
||||
// Fill with SNMP versions allowed.
|
||||
$fieldsVersions = [
|
||||
'1' => '1',
|
||||
'2' => '2',
|
||||
'2c' => '2c',
|
||||
'3' => '3',
|
||||
];
|
||||
break;
|
||||
|
||||
case 'wmi_explorer':
|
||||
$this->actionType = 'wmi';
|
||||
$this->actionLabel = __('WMI Explorer');
|
||||
break;
|
||||
|
||||
default:
|
||||
$this->actionType = 'none';
|
||||
$this->actionLabel = __('Nothing');
|
||||
exit;
|
||||
break;
|
||||
}
|
||||
|
||||
// Main form.
|
||||
$form = [
|
||||
'action' => '',
|
||||
// 'action' => $this->baseUrl,
|
||||
'id' => 'main_wizard_form',
|
||||
'method' => 'POST',
|
||||
];
|
||||
|
||||
// Inputs.
|
||||
$inputs = [];
|
||||
|
||||
$inputs[] = [
|
||||
'id' => 'hdn-type-action',
|
||||
'arguments' => [
|
||||
'name' => 'type-action',
|
||||
'type' => 'hidden',
|
||||
'value' => $this->actionType,
|
||||
'return' => true,
|
||||
],
|
||||
];
|
||||
|
||||
$inputs[] = [
|
||||
'label' => __('Target IP'),
|
||||
'id' => 'txt-target-ip',
|
||||
'arguments' => [
|
||||
'name' => 'target-ip',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'text',
|
||||
'class' => '',
|
||||
'return' => true,
|
||||
],
|
||||
];
|
||||
|
||||
$inputs[] = [
|
||||
'label' => __('Port'),
|
||||
'id' => 'txt-target-port',
|
||||
'arguments' => [
|
||||
'name' => 'target-port',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'text',
|
||||
'size' => '20',
|
||||
'class' => '',
|
||||
'return' => true,
|
||||
],
|
||||
];
|
||||
|
||||
if ($this->actionType === 'snmp') {
|
||||
$inputs[] = [
|
||||
'label' => __('Use agent IP'),
|
||||
'id' => 'txt-use-agent-ip',
|
||||
'arguments' => [
|
||||
'name' => 'use-agent-ip',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'checkbox',
|
||||
'class' => '',
|
||||
'return' => true,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
if ($this->actionType === 'wmi') {
|
||||
$inputs[] = [
|
||||
'label' => __('Namespace'),
|
||||
'id' => 'txt-namespace',
|
||||
'arguments' => [
|
||||
'name' => 'namespace',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'text',
|
||||
'class' => '',
|
||||
'return' => true,
|
||||
],
|
||||
];
|
||||
|
||||
$inputs[] = [
|
||||
'label' => __('Username'),
|
||||
'id' => 'txt-username',
|
||||
'arguments' => [
|
||||
'name' => 'username',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'text',
|
||||
'class' => '',
|
||||
'return' => true,
|
||||
],
|
||||
];
|
||||
|
||||
$inputs[] = [
|
||||
'label' => __('Password'),
|
||||
'id' => 'txt-password',
|
||||
'arguments' => [
|
||||
'name' => 'password',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'text',
|
||||
'class' => '',
|
||||
'return' => true,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
$inputs[] = [
|
||||
'label' => __('Server to execute command'),
|
||||
'id' => 'txt-target-port',
|
||||
'arguments' => [
|
||||
'name' => 'target-port',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'select',
|
||||
'fields' => $fieldsServers,
|
||||
'class' => '',
|
||||
'return' => true,
|
||||
],
|
||||
];
|
||||
|
||||
if ($this->actionType === 'snmp') {
|
||||
$inputs[] = [
|
||||
'label' => __('SNMP community'),
|
||||
'id' => 'txt-snmp-community',
|
||||
'arguments' => [
|
||||
'name' => 'snmp-community',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'text',
|
||||
'size' => '20',
|
||||
'class' => '',
|
||||
'return' => true,
|
||||
],
|
||||
];
|
||||
|
||||
$inputs[] = [
|
||||
'label' => __('SNMP version'),
|
||||
'id' => 'txt-snmnp-version',
|
||||
'arguments' => [
|
||||
'name' => 'snmnp-version',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'select',
|
||||
'fields' => $fieldsVersions,
|
||||
'class' => '',
|
||||
'return' => true,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
$inputs[] = [
|
||||
'arguments' => [
|
||||
'label' => $this->actionLabel,
|
||||
'name' => 'action',
|
||||
'type' => 'submit',
|
||||
'attributes' => 'class="sub next" onclick="performAction();return false;"',
|
||||
'return' => true,
|
||||
],
|
||||
];
|
||||
// Prints main form.
|
||||
html_print_div(
|
||||
[
|
||||
'class' => 'white_box',
|
||||
'content' => $this->printForm(
|
||||
[
|
||||
'form' => $form,
|
||||
'inputs' => $inputs,
|
||||
],
|
||||
true
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function performWizard()
|
||||
{
|
||||
// echo json_encode(['error' => obhd($_REQUEST)]);
|
||||
// exit;
|
||||
$sql = sprintf(
|
||||
'SELECT npc.id_nc AS component_id, nc.name, nc.type, nc.description, nc.id_group AS `group`, ncg.name AS `group_name`
|
||||
FROM tnetwork_profile_component AS npc, tnetwork_component AS nc
|
||||
INNER JOIN tnetwork_component_group AS ncg ON ncg.id_sg = nc.id_group
|
||||
WHERE npc.id_nc = nc.id_nc AND npc.id_np = %d',
|
||||
10
|
||||
);
|
||||
$moduleBlocks = db_get_all_rows_sql($sql);
|
||||
|
||||
$blockTables = [];
|
||||
// Build the information of the blocks.
|
||||
foreach ($moduleBlocks as $block) {
|
||||
if (key_exists($block['group'], $blockTables) === false) {
|
||||
$blockTables[$block['group']] = [
|
||||
'name' => $block['group_name'],
|
||||
'data' => [],
|
||||
];
|
||||
}
|
||||
|
||||
$blockTables[$block['group']]['data'][] = [
|
||||
'component_id' => $block['component_id'],
|
||||
'name' => $block['name'],
|
||||
'type' => $block['type'],
|
||||
'description' => $block['description'],
|
||||
];
|
||||
}
|
||||
|
||||
// Lets generate the block tables.
|
||||
$output = '';
|
||||
foreach ($blockTables as $id_group => $blockTable) {
|
||||
// Data with all components.
|
||||
$blockData = $blockTable['data'];
|
||||
// Creation of list of all components.
|
||||
$blockComponentList = '';
|
||||
foreach ($blockData as $component) {
|
||||
$blockComponentList .= $component['component_id'].',';
|
||||
}
|
||||
|
||||
$blockComponentList = chop($blockComponentList, ',');
|
||||
// Title of Block.
|
||||
$blockTitle = $blockTable['name'];
|
||||
$blockTitle .= html_print_div(
|
||||
[
|
||||
'class' => 'white_table_header_checkbox',
|
||||
'content' => html_print_checkbox_switch_extended(
|
||||
'sel_block_'.$id_group,
|
||||
1,
|
||||
0,
|
||||
false,
|
||||
'switchBlockControl(event)',
|
||||
'',
|
||||
true
|
||||
),
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
$table = new StdClasS();
|
||||
$table->class = 'databox data';
|
||||
$table->width = '75%';
|
||||
$table->styleTable = 'margin: 2em auto 0;border: 1px solid #ddd;background: white;';
|
||||
$table->rowid = [];
|
||||
$table->data = [];
|
||||
|
||||
$table->cellpadding = 0;
|
||||
$table->cellspacing = 0;
|
||||
$table->width = '100%';
|
||||
$table->class = 'info_table';
|
||||
|
||||
$table->head = [];
|
||||
$table->head[0] = html_print_div(['style' => 'font-weight:700;', 'content' => __('Module Name')], true);
|
||||
$table->head[1] = html_print_div(['style' => 'font-weight:700;text-align:center;', 'content' => __('Type')], true);
|
||||
$table->head[2] = html_print_div(['style' => 'font-weight:700;', 'content' => __('Module info')], true);
|
||||
$table->head[3] = html_print_div(['style' => 'font-weight:700;text-align:center;', 'content' => __('Warning')], true);
|
||||
$table->head[4] = html_print_div(['style' => 'font-weight:700;text-align:center;', 'content' => __('Critical')], true);
|
||||
$table->head[5] = html_print_div(['style' => 'font-weight:700;margin-right:1.2em;', 'content' => __('Active')], true);
|
||||
|
||||
$table->size = [];
|
||||
$table->size[0] = '15%';
|
||||
$table->size[1] = '3%';
|
||||
$table->size[3] = '210px';
|
||||
$table->size[4] = '210px';
|
||||
$table->size[5] = '3%';
|
||||
|
||||
$table->align = [];
|
||||
$table->align[5] = 'right';
|
||||
|
||||
$table->data = [];
|
||||
|
||||
foreach ($blockData as $module) {
|
||||
// Module Name column.
|
||||
$data[0] = $module['name'];
|
||||
// Module Type column.
|
||||
$data[1] = ui_print_moduletype_icon($module['type'], true);
|
||||
// Module info column.
|
||||
$data[2] = mb_strimwidth(io_safe_output($module['description']), 0, 150, '...');
|
||||
// Warning column.
|
||||
$data[3] = html_print_div(
|
||||
[
|
||||
'class' => 'wizard-column-levels',
|
||||
'content' => 'Min: '.html_print_input_text(
|
||||
'warning_min_'.$module['component_id'],
|
||||
'0',
|
||||
'',
|
||||
3,
|
||||
4,
|
||||
true
|
||||
).' ',
|
||||
],
|
||||
true
|
||||
);
|
||||
$data[3] .= html_print_div(
|
||||
[
|
||||
'class' => 'wizard-column-levels',
|
||||
'content' => 'Max: '.html_print_input_text(
|
||||
'warning_max_'.$module['component_id'],
|
||||
'0',
|
||||
'',
|
||||
3,
|
||||
4,
|
||||
true
|
||||
),
|
||||
],
|
||||
true
|
||||
);
|
||||
$data[3] .= html_print_div(
|
||||
[
|
||||
'class' => 'wizard-column-levels',
|
||||
'style' => 'margin-top: 0.3em;',
|
||||
'content' => 'Inv: '.html_print_checkbox(
|
||||
'warning_inv_'.$module['component_id'],
|
||||
0,
|
||||
false,
|
||||
true,
|
||||
false
|
||||
),
|
||||
],
|
||||
true
|
||||
);
|
||||
// Critical column.
|
||||
$data[4] = html_print_div(
|
||||
[
|
||||
'class' => 'wizard-column-levels',
|
||||
'content' => 'Min: '.html_print_input_text(
|
||||
'critical_min_'.$module['component_id'],
|
||||
'0',
|
||||
'',
|
||||
3,
|
||||
4,
|
||||
true
|
||||
).' ',
|
||||
],
|
||||
true
|
||||
);
|
||||
$data[4] .= html_print_div(
|
||||
[
|
||||
'class' => 'wizard-column-levels',
|
||||
'content' => 'Max: '.html_print_input_text(
|
||||
'critical_max_'.$module['component_id'],
|
||||
'0',
|
||||
'',
|
||||
3,
|
||||
4,
|
||||
true
|
||||
),
|
||||
],
|
||||
true
|
||||
);
|
||||
$data[4] .= html_print_div(
|
||||
[
|
||||
'class' => 'wizard-column-levels',
|
||||
'style' => 'margin-top: 0.3em;',
|
||||
'content' => 'Inv: '.html_print_checkbox(
|
||||
'critical_inv_'.$module['component_id'],
|
||||
0,
|
||||
false,
|
||||
true,
|
||||
false
|
||||
),
|
||||
],
|
||||
true
|
||||
);
|
||||
// Activation column.
|
||||
$data[5] = html_print_checkbox_switch_extended('sel_module_'.$id_group.'_'.$module['component_id'], 1, 0, false, 'switchBlockControl(event)', '', true);
|
||||
|
||||
array_push($table->data, $data);
|
||||
}
|
||||
|
||||
$content = html_print_table($table, true);
|
||||
|
||||
$output .= ui_toggle($content, $blockTitle, '', '', false, true);
|
||||
}
|
||||
|
||||
html_print_div(
|
||||
[
|
||||
'class' => 'white_box',
|
||||
'style' => 'margin-top: 20px;',
|
||||
'content' => $output,
|
||||
]
|
||||
);
|
||||
|
||||
// Form. Not used at this moment.
|
||||
$form = [
|
||||
'action' => $this->baseUrl,
|
||||
'id' => 'modal_form_action_response',
|
||||
'method' => 'POST',
|
||||
'class' => 'modal',
|
||||
'extra' => '',
|
||||
];
|
||||
|
||||
// Inputs.
|
||||
$inputs = [];
|
||||
|
||||
$inputs[] = [
|
||||
'id' => 'inp-id_np',
|
||||
'arguments' => [
|
||||
'name' => 'id_np',
|
||||
'type' => 'hidden',
|
||||
'value' => '69',
|
||||
'return' => true,
|
||||
],
|
||||
];
|
||||
|
||||
$this->printForm(
|
||||
[
|
||||
'form' => $form,
|
||||
'inputs' => $inputs,
|
||||
true
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Perform SNMP
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function performSNMP()
|
||||
{
|
||||
echo 'HOLA';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Perform WMI
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function performWMI()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate the JS needed for use inside
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function loadJS()
|
||||
{
|
||||
$str = '';
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
// The functions goes here!
|
||||
|
||||
/**
|
||||
* WIP: Loads modal from AJAX to perform the required action.
|
||||
*/
|
||||
function performAction() {
|
||||
var btn_ok_text = '<?php echo __('OK'); ?>';
|
||||
var btn_cancel_text = '<?php echo __('Cancel'); ?>';
|
||||
var title = '<?php echo __('Perform %s', $this->actionLabel); ?>';
|
||||
var action = '<?php echo $this->actionType; ?>';
|
||||
console.log(title);
|
||||
console.log(action);
|
||||
load_modal({
|
||||
target: $('#modal'),
|
||||
form: 'modal_form_action_response',
|
||||
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
|
||||
ajax_callback: showMsg,
|
||||
modal: {
|
||||
title: title,
|
||||
ok: btn_ok_text,
|
||||
cancel: btn_cancel_text,
|
||||
},
|
||||
/* extradata: [
|
||||
{
|
||||
name: 'action',
|
||||
value: action,
|
||||
}
|
||||
], */
|
||||
onshow: {
|
||||
page: '<?php echo $this->ajaxController; ?>',
|
||||
method: 'performWizard'
|
||||
}/* ,
|
||||
onsubmit: {
|
||||
page: '<?//php echo $this->ajaxController; ?>',
|
||||
method: 'processData'
|
||||
} */
|
||||
});
|
||||
console.log("he terminado");
|
||||
}
|
||||
|
||||
/**
|
||||
* WIP: Process ajax responses and shows a dialog with results.
|
||||
*/
|
||||
function showMsg(data) {
|
||||
var title = "<?php echo __('Success'); ?>";
|
||||
var text = "";
|
||||
var failed = 0;
|
||||
try {
|
||||
data = JSON.parse(data);
|
||||
text = data["result"];
|
||||
} catch (err) {
|
||||
title = "<?php echo __('Failed'); ?>";
|
||||
text = err.message;
|
||||
failed = 1;
|
||||
}
|
||||
if (!failed && data["error"] != undefined) {
|
||||
title = "<?php echo __('Failed'); ?>";
|
||||
text = data["error"];
|
||||
failed = 1;
|
||||
}
|
||||
if (data["report"] != undefined) {
|
||||
data["report"].forEach(function(item) {
|
||||
text += "<br>" + item;
|
||||
});
|
||||
}
|
||||
|
||||
$("#msg").empty();
|
||||
$("#msg").html(text);
|
||||
$("#msg").dialog({
|
||||
width: 450,
|
||||
position: {
|
||||
my: "center",
|
||||
at: "center",
|
||||
of: window,
|
||||
collision: "fit"
|
||||
},
|
||||
title: title,
|
||||
buttons: [
|
||||
{
|
||||
class:
|
||||
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
|
||||
text: "OK",
|
||||
click: function(e) {
|
||||
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls checkboxes for modules
|
||||
*/
|
||||
function switchBlockControl(e) {
|
||||
var switchId = e.target.id.split("_");
|
||||
var type = switchId[1];
|
||||
var blockNumber = switchId[2];
|
||||
var selectedBlock = $("#checkbox-sel_block_" + blockNumber);
|
||||
var totalCount = 0;
|
||||
var markedCount = 0;
|
||||
|
||||
if (type == 'block') {
|
||||
if (selectedBlock.prop("checked")) {
|
||||
$("[id*=checkbox-sel_module_" + blockNumber + "]").each(function(){
|
||||
$(this).prop("checked", true);
|
||||
});
|
||||
} else {
|
||||
$("[id*=checkbox-sel_module_" + blockNumber + "]").each(function(){
|
||||
$(this).prop("checked", false);
|
||||
});
|
||||
}
|
||||
} else if (type == 'module') {
|
||||
$("[id*=checkbox-sel_module_" + blockNumber + "]").each(function() {
|
||||
if ($(this).prop("checked")) {
|
||||
markedCount++;
|
||||
}
|
||||
totalCount++;
|
||||
});
|
||||
|
||||
if (totalCount == markedCount) {
|
||||
selectedBlock.prop("checked", true);
|
||||
selectedBlock
|
||||
.parent()
|
||||
.removeClass("alpha50");
|
||||
} else if (markedCount == 0) {
|
||||
selectedBlock.prop("checked", false);
|
||||
selectedBlock
|
||||
.parent()
|
||||
.removeClass("alpha50");
|
||||
} else {
|
||||
selectedBlock.prop("checked", true);
|
||||
selectedBlock
|
||||
.parent()
|
||||
.addClass("alpha50");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
$str = ob_get_clean();
|
||||
echo $str;
|
||||
return $str;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,799 @@
|
|||
<?php
|
||||
/**
|
||||
* PEN Configuration feature.
|
||||
*
|
||||
* @category Class
|
||||
* @package Pandora FMS
|
||||
* @subpackage Wizard Setup
|
||||
* @version 0.0.1
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2020 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
global $config;
|
||||
|
||||
require_once $config['homedir'].'/include/class/HTML.class.php';
|
||||
/**
|
||||
* Config PEN Class
|
||||
*/
|
||||
class ConfigPEN extends HTML
|
||||
{
|
||||
|
||||
/**
|
||||
* Url of controller.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $ajaxController;
|
||||
|
||||
/**
|
||||
* URL Base
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $baseUrl;
|
||||
|
||||
|
||||
/**
|
||||
* Contructor.
|
||||
*
|
||||
* @param string $ajax_page Target ajax page.
|
||||
*/
|
||||
public function __construct($ajax_page)
|
||||
{
|
||||
global $config;
|
||||
|
||||
// Check access.
|
||||
check_login();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'PM')) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access PEN Definition feature'
|
||||
);
|
||||
|
||||
include 'general/noaccess.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->ajaxController = $ajax_page;
|
||||
$this->offset = '';
|
||||
$this->baseUrl = ui_get_full_url(
|
||||
'index.php?sec=configuration_wizard_setup&sec2=godmode/modules/private_enterprise_numbers'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array with all the credentials matching filter and ACL.
|
||||
*
|
||||
* @param array $fields Fields array or 'count' keyword to retrieve count.
|
||||
* @param array $filter Filters to be applied.
|
||||
* @param integer $offset Offset (pagination).
|
||||
* @param integer $limit Limit (pagination).
|
||||
* @param string $order Sort order.
|
||||
* @param string $sort_field Sort field.
|
||||
*
|
||||
* @return array With all results or false if error.
|
||||
* @throws Exception On error.
|
||||
*/
|
||||
public static function getAll(
|
||||
$fields,
|
||||
$filter=null,
|
||||
$offset=null,
|
||||
$limit=null,
|
||||
$order=null,
|
||||
$sort_field=null
|
||||
) {
|
||||
$sql_filters = [];
|
||||
$order_by = '';
|
||||
$pagination = '';
|
||||
|
||||
$count = false;
|
||||
if (!is_array($fields) && $fields == 'count') {
|
||||
$fields = ['*'];
|
||||
$count = true;
|
||||
} else if (!is_array($fields)) {
|
||||
error_log('[configPEN.getAll] Fields must be an array or "count".');
|
||||
throw new Exception('[configPEN.getAll] Fields must be an array or "count".');
|
||||
}
|
||||
|
||||
if (is_array($filter)) {
|
||||
if (!empty($filter['free_search'])) {
|
||||
$sql_filters[] = vsprintf(
|
||||
' AND (lower(`manufacturer`) like lower("%%%s%%")
|
||||
OR pen = "%s") ',
|
||||
array_fill(0, 2, $filter['free_search'])
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($filter['pen'])) {
|
||||
$sql_filters[] = sprintf(
|
||||
' AND `pen` = %d',
|
||||
$filter['pen']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($order)) {
|
||||
$dir = 'asc';
|
||||
if ($order == 'desc') {
|
||||
$dir = 'desc';
|
||||
};
|
||||
|
||||
if (in_array(
|
||||
$sort_field,
|
||||
[
|
||||
'pen',
|
||||
'manufacturer',
|
||||
'description',
|
||||
]
|
||||
)
|
||||
) {
|
||||
$order_by = sprintf(
|
||||
'ORDER BY `%s` %s',
|
||||
$sort_field,
|
||||
$dir
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($limit) && $limit > 0
|
||||
&& isset($offset) && $offset >= 0
|
||||
) {
|
||||
$pagination = sprintf(
|
||||
' LIMIT %d OFFSET %d ',
|
||||
$limit,
|
||||
$offset
|
||||
);
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
'SELECT %s
|
||||
FROM `tpen`
|
||||
WHERE 1=1
|
||||
%s
|
||||
%s
|
||||
%s',
|
||||
join(',', $fields),
|
||||
join(' ', $sql_filters),
|
||||
$order_by,
|
||||
$pagination
|
||||
);
|
||||
|
||||
if ($count) {
|
||||
$sql = sprintf('SELECT count(*) as n FROM ( %s ) tt', $sql);
|
||||
|
||||
return db_get_value_sql($sql);
|
||||
}
|
||||
|
||||
return db_get_all_rows_sql($sql);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* AJAX: Return JSON content for datatable.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function draw()
|
||||
{
|
||||
global $config;
|
||||
|
||||
// Datatables offset, limit and order.
|
||||
$filter = get_parameter('filter', []);
|
||||
$start = get_parameter('start', 0);
|
||||
$length = get_parameter('length', $config['block_size']);
|
||||
$order = get_datatable_order(true);
|
||||
try {
|
||||
ob_start();
|
||||
|
||||
$fields = ['*'];
|
||||
|
||||
// Retrieve data.
|
||||
$data = $this->getAll(
|
||||
// Fields.
|
||||
$fields,
|
||||
// Filter.
|
||||
$filter,
|
||||
// Offset.
|
||||
$start,
|
||||
// Limit.
|
||||
$length,
|
||||
// Order.
|
||||
$order['direction'],
|
||||
// Sort field.
|
||||
$order['field']
|
||||
);
|
||||
|
||||
// Retrieve counter.
|
||||
$count = $this->getAll(
|
||||
'count',
|
||||
$filter
|
||||
);
|
||||
|
||||
if ($data) {
|
||||
$data = array_reduce(
|
||||
$data,
|
||||
function ($carry, $item) {
|
||||
// Transforms array of arrays $data into an array
|
||||
// of objects, making a post-process of certain fields.
|
||||
$tmp = (object) $item;
|
||||
|
||||
$tmp->description = io_safe_output($tmp->description);
|
||||
$tmp->manufacturer = io_safe_output($tmp->manufacturer);
|
||||
|
||||
$tmp->options = '';
|
||||
|
||||
$tmp->options = '<a href="javascript:" onclick="showForm(\'';
|
||||
$tmp->options .= $tmp->pen;
|
||||
$tmp->options .= '\')" >';
|
||||
$tmp->options .= html_print_image(
|
||||
'images/eye.png',
|
||||
true,
|
||||
['title' => __('Show')]
|
||||
);
|
||||
$tmp->options .= '</a>';
|
||||
$tmp->options .= '<a href="javascript:" onclick="deletePEN(\'';
|
||||
$tmp->options .= $tmp->pen;
|
||||
$tmp->options .= '\')" >';
|
||||
$tmp->options .= html_print_image(
|
||||
'images/cross.png',
|
||||
true,
|
||||
['title' => __('Delete')]
|
||||
);
|
||||
$tmp->options .= '</a>';
|
||||
|
||||
$carry[] = $tmp;
|
||||
return $carry;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Datatables format: RecordsTotal && recordsfiltered.
|
||||
echo json_encode(
|
||||
[
|
||||
'data' => $data,
|
||||
'recordsTotal' => $count,
|
||||
'recordsFiltered' => $count,
|
||||
]
|
||||
);
|
||||
// Capture output.
|
||||
$response = ob_get_clean();
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['error' => $e->getMessage()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// If not valid, show error with issue.
|
||||
json_decode($response);
|
||||
if (json_last_error() == JSON_ERROR_NONE) {
|
||||
// If valid dump.
|
||||
echo $response;
|
||||
} else {
|
||||
echo json_encode(
|
||||
['error' => $response]
|
||||
);
|
||||
}
|
||||
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run main page.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// Require specific CSS and JS.
|
||||
ui_require_css_file('wizard');
|
||||
ui_require_css_file('discovery');
|
||||
ui_require_css_file('pen');
|
||||
|
||||
// Header section.
|
||||
// Breadcrums.
|
||||
$this->setBreadcrum([]);
|
||||
|
||||
$this->prepareBreadcrum(
|
||||
[
|
||||
[
|
||||
'link' => '',
|
||||
'label' => __('Configuration'),
|
||||
'selected' => false,
|
||||
],
|
||||
[
|
||||
'link' => '',
|
||||
'label' => __('Templates'),
|
||||
'selected' => false,
|
||||
],
|
||||
[
|
||||
'link' => $this->baseUrl,
|
||||
'label' => __('Private Enterprise Numbers'),
|
||||
'selected' => true,
|
||||
],
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
ui_print_page_header(
|
||||
__('Private Enterprise Numbers'),
|
||||
'',
|
||||
false,
|
||||
'',
|
||||
true,
|
||||
'',
|
||||
false,
|
||||
'',
|
||||
GENERIC_SIZE_TEXT,
|
||||
'',
|
||||
$this->printHeader(true)
|
||||
);
|
||||
|
||||
// Definition for AJAX.
|
||||
html_print_input_hidden(
|
||||
'ajax_file',
|
||||
ui_get_full_url('ajax.php', false, false, false)
|
||||
);
|
||||
|
||||
// Ajax page (hidden).
|
||||
html_print_input_hidden(
|
||||
'ajax_page',
|
||||
$this->ajaxController
|
||||
);
|
||||
|
||||
// Allow message area.
|
||||
html_print_div(['id' => 'message_show_area']);
|
||||
// Prints the main table.
|
||||
html_print_div(
|
||||
[
|
||||
'id' => 'main_table_area',
|
||||
'content' => $this->createMainTable(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load modal information for PEN management.
|
||||
*
|
||||
* Ajax. Direct HTML.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function loadModal()
|
||||
{
|
||||
$values = [];
|
||||
$id = (int) get_parameter('pen', 0);
|
||||
if ($id > 0) {
|
||||
$values = $this->getAll(
|
||||
// Fields.
|
||||
['*'],
|
||||
// Filter.
|
||||
['pen' => $id]
|
||||
);
|
||||
if (is_array($values)) {
|
||||
$values = $values[0];
|
||||
}
|
||||
}
|
||||
|
||||
$form = [
|
||||
'action' => '#',
|
||||
'id' => 'modal_form',
|
||||
'onsubmit' => 'return false;',
|
||||
'class' => '',
|
||||
];
|
||||
|
||||
$inputs = [];
|
||||
|
||||
$arguments = [
|
||||
'name' => 'pen',
|
||||
'type' => 'number',
|
||||
'value' => $values['pen'],
|
||||
'required' => true,
|
||||
'return' => true,
|
||||
'size' => 50,
|
||||
];
|
||||
|
||||
if ((bool) $values['pen']) {
|
||||
$arguments['disabled'] = true;
|
||||
}
|
||||
|
||||
$inputs[] = [
|
||||
'label' => __('PEN'),
|
||||
'class' => 'flex-row',
|
||||
'id' => 'div-pen',
|
||||
'arguments' => $arguments,
|
||||
];
|
||||
|
||||
$inputs[] = [
|
||||
'label' => __('Manufacturer'),
|
||||
'class' => 'flex-row',
|
||||
'arguments' => [
|
||||
'name' => 'manufacturer',
|
||||
'id' => 'manufacturer',
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'value' => io_safe_output($values['manufacturer']),
|
||||
'return' => true,
|
||||
],
|
||||
];
|
||||
|
||||
$inputs[] = [
|
||||
'label' => __('Description'),
|
||||
'class' => 'flex-row',
|
||||
'arguments' => [
|
||||
'name' => 'description',
|
||||
'id' => 'description',
|
||||
'type' => 'textarea',
|
||||
'value' => io_safe_output($values['description']),
|
||||
'return' => true,
|
||||
'rows' => 50,
|
||||
'columns' => 30,
|
||||
],
|
||||
];
|
||||
|
||||
echo '<div id="div-form">';
|
||||
echo parent::printForm(
|
||||
[
|
||||
'form' => $form,
|
||||
'inputs' => $inputs,
|
||||
],
|
||||
true
|
||||
);
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a manufacturer register from db.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$pen = get_parameter('pen', 0);
|
||||
|
||||
if (empty($pen)) {
|
||||
echo json_encode(['error' => __('PEN is required')]);
|
||||
} else {
|
||||
if (db_process_sql_delete('tpen', ['pen' => $pen]) !== false) {
|
||||
echo json_encode(['result' => __('Successfully deleted')]);
|
||||
} else {
|
||||
global $config;
|
||||
echo json_encode(['error' => $config['dbconnection']->error]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add or update a manufacturer to private enterprise numbers.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$pen = get_parameter('pen', 0);
|
||||
$manufacturer = get_parameter('manufacturer', '');
|
||||
$description = get_parameter('description', '');
|
||||
$is_new = (bool) get_parameter('is_new', false);
|
||||
|
||||
if (empty($pen)) {
|
||||
$error = __('PEN is required.');
|
||||
}
|
||||
|
||||
if (empty($manufacturer)) {
|
||||
$error = __('Manufacturer is required');
|
||||
}
|
||||
|
||||
if (!empty($error)) {
|
||||
echo json_encode(
|
||||
['error' => $error]
|
||||
);
|
||||
}
|
||||
|
||||
// Add if not exists.
|
||||
$current = $this->getAll(['pen'], ['pen' => $pen]);
|
||||
|
||||
if ($current === false) {
|
||||
// New.
|
||||
if ($is_new === false) {
|
||||
echo json_encode(
|
||||
[
|
||||
'error' => __('This PEN definition does not exist'),
|
||||
]
|
||||
);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rs = db_process_sql_insert(
|
||||
'tpen',
|
||||
[
|
||||
'pen' => $pen,
|
||||
'manufacturer' => $manufacturer,
|
||||
'description' => $description,
|
||||
]
|
||||
);
|
||||
$str = __('created');
|
||||
} else {
|
||||
// Update.
|
||||
if ($is_new === true) {
|
||||
echo json_encode(
|
||||
[
|
||||
'error' => __('This PEN definition already exists'),
|
||||
]
|
||||
);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rs = db_process_sql_update(
|
||||
'tpen',
|
||||
[
|
||||
'manufacturer' => $manufacturer,
|
||||
'description' => $description,
|
||||
],
|
||||
['pen' => $pen]
|
||||
);
|
||||
$str = __('updated');
|
||||
}
|
||||
|
||||
if ($rs === false) {
|
||||
global $config;
|
||||
echo json_encode(['error' => $config['dbconnection']->error]);
|
||||
} else {
|
||||
echo json_encode(['result' => __('Succesfully %s', $str)]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create the main table with the PENs info
|
||||
*
|
||||
* @return string Return entire the table
|
||||
*/
|
||||
public function createMainTable()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$output = '';
|
||||
|
||||
// Datatables list.
|
||||
try {
|
||||
$columns = [
|
||||
'pen',
|
||||
'manufacturer',
|
||||
'description',
|
||||
'options',
|
||||
];
|
||||
|
||||
$column_names = [
|
||||
__('PEN'),
|
||||
__('Manufacturer'),
|
||||
__('Description'),
|
||||
[
|
||||
'text' => __('Options'),
|
||||
'class' => 'action_buttons',
|
||||
],
|
||||
];
|
||||
|
||||
$this->tableId = 'keystore';
|
||||
// Load datatables user interface.
|
||||
$output .= ui_print_datatable(
|
||||
[
|
||||
'id' => $this->tableId,
|
||||
'return' => true,
|
||||
'class' => 'info_table',
|
||||
'style' => 'width: 100%',
|
||||
'columns' => $columns,
|
||||
'column_names' => $column_names,
|
||||
'ajax_url' => $this->ajaxController,
|
||||
'ajax_data' => ['method' => 'draw'],
|
||||
'no_sortable_columns' => [-1],
|
||||
'order' => [
|
||||
'field' => 'pen',
|
||||
'direction' => 'asc',
|
||||
],
|
||||
'search_button_class' => 'sub filter float-right',
|
||||
'form' => [
|
||||
'inputs' => [
|
||||
[
|
||||
'label' => __('Free search'),
|
||||
'type' => 'text',
|
||||
'class' => 'mw250px',
|
||||
'id' => 'free_search',
|
||||
'name' => 'free_search',
|
||||
],
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
// Auxiliar div.
|
||||
$output .= '<div id="modal" style="display: none"></div>';
|
||||
$output .= '<div id="msg" style="display: none"></div>';
|
||||
$output .= '<div id="aux" style="display: none"></div>';
|
||||
|
||||
// Create button.
|
||||
$output .= parent::printInput(
|
||||
[
|
||||
'type' => 'submit',
|
||||
'name' => 'create',
|
||||
'label' => __('Register manufacturer'),
|
||||
'attributes' => 'class="sub next"',
|
||||
'return' => true,
|
||||
]
|
||||
);
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
function cleanupDOM() {
|
||||
$("#div-form").empty();
|
||||
}
|
||||
|
||||
function deletePEN(id) {
|
||||
confirmDialog({
|
||||
title: "<?php echo __('Are you sure?'); ?>",
|
||||
message: "<?php echo __('Are you sure you want to delete this PEN?'); ?>",
|
||||
ok: "<?php echo __('OK'); ?>",
|
||||
cancel: "<?php echo __('Cancel'); ?>",
|
||||
onAccept: function() {
|
||||
$.ajax({
|
||||
method: "post",
|
||||
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
data: {
|
||||
page: "<?php echo $this->ajaxController; ?>",
|
||||
method: "delete",
|
||||
pen: id
|
||||
},
|
||||
datatype: "json",
|
||||
success: function(data) {
|
||||
showMsg(data);
|
||||
},
|
||||
error: function(e) {
|
||||
showMsg(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function showForm(id) {
|
||||
var btn_ok_text = "<?php echo __('OK'); ?>";
|
||||
var btn_cancel_text = "<?php echo __('Cancel'); ?>";
|
||||
var title = "<?php echo __('Register new manufacturer'); ?>";
|
||||
var is_new = 1;
|
||||
if (id) {
|
||||
btn_ok_text = "<?php echo __('Update'); ?>";
|
||||
title = "<?php echo __('Update'); ?> " + id;
|
||||
is_new = 0;
|
||||
}
|
||||
load_modal({
|
||||
target: $("#modal"),
|
||||
form: "modal_form",
|
||||
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
ajax_callback: showMsg,
|
||||
cleanup: cleanupDOM,
|
||||
modal: {
|
||||
title: title,
|
||||
ok: btn_ok_text,
|
||||
cancel: btn_cancel_text
|
||||
},
|
||||
extradata: [
|
||||
{
|
||||
name: "pen",
|
||||
value: id
|
||||
},
|
||||
{
|
||||
name: 'is_new',
|
||||
value: is_new
|
||||
}
|
||||
],
|
||||
onshow: {
|
||||
page: "<?php echo $this->ajaxController; ?>",
|
||||
method: "loadModal"
|
||||
},
|
||||
onsubmit: {
|
||||
page: "<?php echo $this->ajaxController; ?>",
|
||||
method: "add"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Process ajax responses and shows a dialog with results.
|
||||
*/
|
||||
function showMsg(data) {
|
||||
var title = "<?php echo __('Success'); ?>";
|
||||
var text = "";
|
||||
var failed = 0;
|
||||
try {
|
||||
data = JSON.parse(data);
|
||||
text = data["result"];
|
||||
} catch (err) {
|
||||
title = "<?php echo __('Failed'); ?>";
|
||||
text = err.message;
|
||||
failed = 1;
|
||||
}
|
||||
if (!failed && data["error"] != undefined) {
|
||||
title = "<?php echo __('Failed'); ?>";
|
||||
text = data["error"];
|
||||
failed = 1;
|
||||
}
|
||||
if (data["report"] != undefined) {
|
||||
data["report"].forEach(function(item) {
|
||||
text += "<br>" + item;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$("#msg").empty();
|
||||
$("#msg").html(text);
|
||||
$("#msg").dialog({
|
||||
width: 450,
|
||||
position: {
|
||||
my: "center",
|
||||
at: "center",
|
||||
of: window,
|
||||
collision: "fit"
|
||||
},
|
||||
title: title,
|
||||
buttons: [
|
||||
{
|
||||
class:
|
||||
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
|
||||
text: "OK",
|
||||
click: function(e) {
|
||||
if (!failed) {
|
||||
$(".ui-dialog-content").dialog("close");
|
||||
$(".info").hide();
|
||||
cleanupDOM();
|
||||
dt_keystore.draw(false);
|
||||
} else {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$("#submit-create").click(function() {
|
||||
showForm();
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
<?php
|
||||
$output .= ob_get_clean();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -215,6 +215,12 @@ class ConsoleSupervisor
|
|||
*/
|
||||
$this->checkConsoleServerVersions();
|
||||
|
||||
/*
|
||||
* Check if AllowOverride is None or All.
|
||||
* NOTIF.ALLOWOVERIDE.MESSAGE
|
||||
*/
|
||||
$this->checkAllowOverrideEnabled();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -440,6 +446,11 @@ class ConsoleSupervisor
|
|||
*/
|
||||
$this->checkConsoleServerVersions();
|
||||
|
||||
/*
|
||||
* Check if AllowOverride is None or All.
|
||||
*/
|
||||
$this->checkAllowOverrideEnabled();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -606,6 +617,7 @@ class ConsoleSupervisor
|
|||
case 'NOTIF.UPDATEMANAGER.MINOR':
|
||||
case 'NOTIF.UPDATEMANAGER.MESSAGES':
|
||||
case 'NOTIF.CRON.CONFIGURED':
|
||||
case 'NOTIF.ALLOWOVERRIDE.MESSAGE':
|
||||
default:
|
||||
// NOTIF.SERVER.STATUS.
|
||||
// NOTIF.SERVER.STATUS.ID_SERVER.
|
||||
|
@ -2360,4 +2372,50 @@ class ConsoleSupervisor
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if AllowOveride is None or All.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function checkAllowOverrideEnabled()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$message = 'If AllowOverride is disabled, .htaccess will not works.';
|
||||
$message .= '<pre>Please check /etc/httpd/conf/httpd.conf to resolve this problem.';
|
||||
|
||||
// Get content file.
|
||||
$file = file_get_contents('/etc/httpd/conf/httpd.conf');
|
||||
$file_lines = preg_split("#\r?\n#", $file, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$is_none = false;
|
||||
|
||||
$i = 0;
|
||||
foreach ($file_lines as $line) {
|
||||
$i++;
|
||||
|
||||
// Check Line and content.
|
||||
if (preg_match('/ AllowOverride/', $line) && $i === 311) {
|
||||
$result = explode(' ', $line);
|
||||
if ($result[5] == 'None') {
|
||||
$is_none = true;
|
||||
$this->notify(
|
||||
[
|
||||
'type' => 'NOTIF.ALLOWOVERRIDE.MESSAGE',
|
||||
'title' => __('AllowOverride is disabled'),
|
||||
'message' => __($message),
|
||||
'url' => ui_get_full_url('index.php'),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Cleanup notifications if AllowOverride is All.
|
||||
if (!$is_none) {
|
||||
$this->cleanNotifications('NOTIF.ALLOWOVERRIDE.MESSAGE');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -443,6 +443,8 @@ class CredentialStore extends Wizard
|
|||
*/
|
||||
public function draw()
|
||||
{
|
||||
global $config;
|
||||
|
||||
// Datatables offset, limit and order.
|
||||
$filter = get_parameter('filter', []);
|
||||
$start = get_parameter('start', 0);
|
||||
|
|
|
@ -38,7 +38,7 @@ class HTML
|
|||
/**
|
||||
* Breadcrum
|
||||
*
|
||||
* @var array.
|
||||
* @var array
|
||||
*/
|
||||
public $breadcrum;
|
||||
|
||||
|
@ -119,7 +119,7 @@ class HTML
|
|||
/**
|
||||
* Add an element to breadcrum array.
|
||||
*
|
||||
* @param string $breads Elements to add to breadcrum.
|
||||
* @param array $breads Elements to add to breadcrum.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
@ -335,6 +335,27 @@ class HTML
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return formatted html for error handler.
|
||||
*
|
||||
* @param string $message Error mesage.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function error($message)
|
||||
{
|
||||
if (is_ajax()) {
|
||||
echo json_encode(
|
||||
[
|
||||
'error' => ui_print_error_message($message, '', true),
|
||||
]
|
||||
);
|
||||
} else {
|
||||
return ui_print_error_message($message, '', true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print input using functions html lib.
|
||||
*
|
||||
|
@ -725,6 +746,7 @@ class HTML
|
|||
) {
|
||||
$form = $data['form'];
|
||||
$inputs = $data['inputs'];
|
||||
$rawInputs = $data['rawInputs'];
|
||||
$js = $data['js'];
|
||||
$rawjs = $data['js_block'];
|
||||
$cb_function = $data['cb_function'];
|
||||
|
@ -767,6 +789,11 @@ class HTML
|
|||
|
||||
$output .= '</ul>';
|
||||
|
||||
// There is possible add raw inputs for this form.
|
||||
if (empty($rawInputs) === false) {
|
||||
$output .= $rawInputs;
|
||||
}
|
||||
|
||||
if ($print_white_box === true) {
|
||||
$output .= '</div>';
|
||||
}
|
||||
|
@ -800,7 +827,7 @@ class HTML
|
|||
$form = $data['form'];
|
||||
|
||||
$rows = $data['rows'];
|
||||
|
||||
$rawInputs = $data['rawInputs'];
|
||||
$js = $data['js'];
|
||||
$rawjs = $data['js_block'];
|
||||
$cb_function = $data['cb_function'];
|
||||
|
@ -875,6 +902,11 @@ class HTML
|
|||
}
|
||||
}
|
||||
|
||||
// There is possible add raw inputs for this form.
|
||||
if (empty($rawInputs) === false) {
|
||||
$output .= $rawInputs;
|
||||
}
|
||||
|
||||
$output .= '</div>';
|
||||
|
||||
$output .= '<ul class="wizard">'.$output_submit.'</ul>';
|
||||
|
@ -905,6 +937,7 @@ class HTML
|
|||
{
|
||||
$form = $data['form'];
|
||||
$inputs = $data['inputs'];
|
||||
$rawInputs = $data['rawInputs'];
|
||||
$js = $data['js'];
|
||||
$rawjs = $data['js_block'];
|
||||
$cb_function = $data['cb_function'];
|
||||
|
@ -940,7 +973,13 @@ class HTML
|
|||
}
|
||||
|
||||
$output .= '</ul>';
|
||||
// There is possible add raw inputs for this form.
|
||||
if (empty($rawInputs) === false) {
|
||||
$output .= $rawInputs;
|
||||
}
|
||||
|
||||
$output .= '</div>';
|
||||
|
||||
$output .= '<ul class="wizard">'.$output_submit.'</ul>';
|
||||
$output .= '</form>';
|
||||
$output .= '<script>'.$js.'</script>';
|
||||
|
@ -1000,4 +1039,72 @@ class HTML
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a n-dimensional array (data) into a html tree structure.
|
||||
*
|
||||
* Advanced documentation:
|
||||
* https://www.jqueryscript.net/other/Checkable-Hierarchical-Tree.html
|
||||
*
|
||||
* @param string $target Target DOM id.
|
||||
* @param array $data N-dimensional array.
|
||||
* @param string $onclick Onclick function.
|
||||
* @param string $onchange Onchange function.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function printTree(
|
||||
$target,
|
||||
$data,
|
||||
$onclick='',
|
||||
$onchange=''
|
||||
) {
|
||||
ui_require_css_file('simTree');
|
||||
ui_require_javascript_file('simTree');
|
||||
|
||||
/*
|
||||
* SAMPLE SELECT ALL.
|
||||
*
|
||||
* echo '<div class="subtitle">';
|
||||
* echo '<span>';
|
||||
* echo __('Please select devices to be monitored');
|
||||
* echo '</span><div class="manage">';
|
||||
* echo '<button onclick="$(\'.sim-tree li a\').each(function(){simTree_tree.doCheck($(this), false); simTree_tree.clickNode($(this));});">';
|
||||
* echo __('select all');
|
||||
* echo '</button>';
|
||||
* echo '<button onclick="$(\'.sim-tree li a\').each(function(){simTree_tree.doCheck($(this), true); simTree_tree.clickNode($(this));});">';
|
||||
* echo __('deselect all');
|
||||
* echo '</button>';
|
||||
* echo '</div>';
|
||||
* echo '</div>';
|
||||
*
|
||||
* END SAMPLE SELECT ALL.
|
||||
*/
|
||||
|
||||
$output = '
|
||||
<script type="text/javascript">
|
||||
var simTree_'.$target.';
|
||||
$(document).ready(function() {
|
||||
simTree_'.$target.' = simTree({
|
||||
el: $('.$target.'),
|
||||
data: '.json_encode($data).',
|
||||
onClick: function (item) {'.$onclick.';},
|
||||
onChange: function (item) {
|
||||
'.$onchange.';
|
||||
$("#tree-data-'.$target.'").val(JSON.stringify(this.sels));
|
||||
},
|
||||
check: true,
|
||||
linkParent: true
|
||||
});
|
||||
$("#'.$target.'").append(
|
||||
\'<input type="hidden" id="tree-data-'.$target.'" name="tree-data-'.$target.'">\'
|
||||
);
|
||||
|
||||
$("#tree-data-'.$target.'").val(JSON.stringify(simTree_'.$target.'.sels));
|
||||
});
|
||||
</script>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -557,7 +557,7 @@ class Tree
|
|||
$module['id_module_type'] = (int) $module['id_tipo_modulo'];
|
||||
$module['server_type'] = (int) $module['id_modulo'];
|
||||
$module['status'] = $module['estado'];
|
||||
$module['value'] = $module['datos'];
|
||||
$module['value'] = modules_get_agentmodule_data_for_humans($module);
|
||||
|
||||
if (is_metaconsole()) {
|
||||
$module['serverID'] = $this->serverID;
|
||||
|
@ -738,12 +738,10 @@ class Tree
|
|||
$agent['counters']['warning'],
|
||||
$agent['counters']['unknown'],
|
||||
$agent['counters']['total'],
|
||||
$agent['counters']['not_init']
|
||||
$agent['counters']['not_init'],
|
||||
$agent['counters']['alerts']
|
||||
);
|
||||
|
||||
// Alerts fired image
|
||||
$agent['alertImageHTML'] = agents_tree_view_alert_img_ball($agent['counters']['alerts']);
|
||||
|
||||
// search module recalculate counters
|
||||
if (array_key_exists('state_normal', $agent)) {
|
||||
$agent['counters']['unknown'] = $agent['state_unknown'];
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
/**
|
||||
* Pandora build version and version
|
||||
*/
|
||||
$build_version = 'PC200407';
|
||||
$pandora_version = 'v7.0NG.744';
|
||||
$build_version = 'PC200511';
|
||||
$pandora_version = 'v7.0NG.745';
|
||||
|
||||
// Do not overwrite default timezone set if defined.
|
||||
$script_tz = @date_default_timezone_get();
|
||||
|
|
|
@ -524,9 +524,15 @@ define('ARROW_TYPE', 1);
|
|||
|
||||
// Discovery task steps.
|
||||
define('STEP_SCANNING', 1);
|
||||
define('STEP_CAPABILITIES', 7);
|
||||
define('STEP_AFT', 2);
|
||||
define('STEP_TRACEROUTE', 3);
|
||||
define('STEP_GATEWAY', 4);
|
||||
define('STEP_MONITORING', 5);
|
||||
define('STEP_PROCESSING', 6);
|
||||
define('STEP_STATISTICS', 1);
|
||||
define('STEP_APP_SCAN', 2);
|
||||
define('STEP_CUSTOM_QUERIES', 3);
|
||||
|
||||
// Networkmap node types.
|
||||
define('NODE_AGENT', 0);
|
||||
|
@ -594,6 +600,11 @@ define('DISCOVERY_DEPLOY_AGENTS', 9);
|
|||
define('DISCOVERY_APP_SAP', 10);
|
||||
|
||||
|
||||
// Force task build tmp results.
|
||||
define('DISCOVERY_REVIEW', 0);
|
||||
define('DISCOVERY_STANDARD', 1);
|
||||
define('DISCOVERY_RESULTS', 2);
|
||||
|
||||
// Discovery types matching definition.
|
||||
define('DISCOVERY_SCRIPT_HOSTDEVICES_CUSTOM', 0);
|
||||
// Standard applications.
|
||||
|
|
|
@ -310,6 +310,10 @@ function agents_get_alerts_simple($id_agent=false, $filter='', $options=false, $
|
|||
$subQuery = 'SELECT id_agente_modulo
|
||||
FROM tagente_modulo WHERE delete_pending = 0';
|
||||
}
|
||||
|
||||
// Filter by agents id.
|
||||
$id_agents_list = implode(',', $id_agent);
|
||||
$subQuery .= ' AND id_agente in ('.$id_agents_list.')';
|
||||
} else if ($id_agent === false || empty($id_agent)) {
|
||||
if ($allModules) {
|
||||
$disabled = '';
|
||||
|
@ -2638,12 +2642,28 @@ function agents_tree_view_status_img($critical, $warning, $unknown, $total, $not
|
|||
|
||||
|
||||
// Returns the status ball image to display tree view
|
||||
function agents_tree_view_status_img_ball($critical, $warning, $unknown, $total, $notinit)
|
||||
function agents_tree_view_status_img_ball($critical, $warning, $unknown, $total, $notinit, $alerts)
|
||||
{
|
||||
if ($total == 0 || $total == $notinit) {
|
||||
return ui_print_status_image(
|
||||
STATUS_AGENT_NO_MONITORS_BALL,
|
||||
__('No Monitors'),
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
// Use CSS shape instead of image.
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
if ($alerts > 0) {
|
||||
return ui_print_status_image(
|
||||
STATUS_ALERT_FIRED_BALL,
|
||||
__('Alert fired on agent'),
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
// Use CSS shape instead of image.
|
||||
true
|
||||
);
|
||||
}
|
||||
|
@ -2652,24 +2672,40 @@ function agents_tree_view_status_img_ball($critical, $warning, $unknown, $total,
|
|||
return ui_print_status_image(
|
||||
STATUS_AGENT_CRITICAL_BALL,
|
||||
__('At least one module in CRITICAL status'),
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
// Use CSS shape instead of image.
|
||||
true
|
||||
);
|
||||
} else if ($warning > 0) {
|
||||
return ui_print_status_image(
|
||||
STATUS_AGENT_WARNING_BALL,
|
||||
__('At least one module in WARNING status'),
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
// Use CSS shape instead of image.
|
||||
true
|
||||
);
|
||||
} else if ($unknown > 0) {
|
||||
return ui_print_status_image(
|
||||
STATUS_AGENT_DOWN_BALL,
|
||||
__('At least one module is in UKNOWN status'),
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
// Use CSS shape instead of image.
|
||||
true
|
||||
);
|
||||
} else {
|
||||
return ui_print_status_image(
|
||||
STATUS_AGENT_OK_BALL,
|
||||
__('All Monitors OK'),
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
// Use CSS shape instead of image.
|
||||
true
|
||||
);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2439,7 +2439,13 @@ function graphic_agentaccess(
|
|||
if ($return === true) {
|
||||
return vbar_graph($data_array, $options, 1);
|
||||
} else {
|
||||
echo vbar_graph($data_array, $options, 1);
|
||||
$options['generals']['pdf']['width'] = 350;
|
||||
$options['generals']['pdf']['height'] = 125;
|
||||
|
||||
$imgbase64 = '<img src="data:image/jpg;base64,';
|
||||
$imgbase64 .= vbar_graph($data_array, $options, 2);
|
||||
$imgbase64 .= '" />';
|
||||
return $imgbase64;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -722,6 +722,7 @@ function html_print_select(
|
|||
* @param string $style The string of style.
|
||||
* @param mixed $size Max elements showed in select or default (size=10)
|
||||
* @param integer $truncante_size Truncate size of the element, by default is set to GENERIC_SIZE_TEXT constant
|
||||
* @param integer $class Class to apply.
|
||||
*
|
||||
* @return string HTML code if return parameter is true.
|
||||
*/
|
||||
|
@ -738,7 +739,8 @@ function html_print_select_from_sql(
|
|||
$disabled=false,
|
||||
$style=false,
|
||||
$size=false,
|
||||
$trucate_size=GENERIC_SIZE_TEXT
|
||||
$trucate_size=GENERIC_SIZE_TEXT,
|
||||
$class=''
|
||||
) {
|
||||
global $config;
|
||||
|
||||
|
@ -770,7 +772,7 @@ function html_print_select_from_sql(
|
|||
$return,
|
||||
$multiple,
|
||||
$sort,
|
||||
'',
|
||||
$class,
|
||||
$disabled,
|
||||
$style,
|
||||
'',
|
||||
|
@ -1087,7 +1089,7 @@ function html_print_extended_select_for_time(
|
|||
|
||||
ob_start();
|
||||
// Use the no_meta parameter because this image is only in the base console
|
||||
echo '<div id="'.$uniq_name.'_default" style="width:100%;display:inline;">';
|
||||
echo '<div id="'.$uniq_name.'_default" style="width:100%;display:flex;align-items: baseline;">';
|
||||
html_print_select(
|
||||
$fields,
|
||||
$uniq_name.'_select',
|
||||
|
@ -1121,7 +1123,7 @@ function html_print_extended_select_for_time(
|
|||
|
||||
echo '</div>';
|
||||
|
||||
echo '<div id="'.$uniq_name.'_manual" style="width:100%;display:inline;">';
|
||||
echo '<div id="'.$uniq_name.'_manual" style="width:100%;display:flex;">';
|
||||
html_print_input_text($uniq_name.'_text', $selected, '', $size, 255, false, $readonly, false, '', $class);
|
||||
|
||||
html_print_input_hidden($name, $selected, false, $uniq_name);
|
||||
|
@ -1159,8 +1161,8 @@ function html_print_extended_select_for_time(
|
|||
$('#text-".$uniq_name."_text').val(seconds);
|
||||
adjustTextUnits('".$uniq_name."');
|
||||
calculateSeconds('".$uniq_name."');
|
||||
$('#".$uniq_name."_manual').show();
|
||||
$('#".$uniq_name."_default').hide();
|
||||
$('#".$uniq_name."_manual').css('display', 'flex');
|
||||
$('#".$uniq_name."_default').css('display', 'none');
|
||||
}
|
||||
</script>";
|
||||
$returnString = ob_get_clean();
|
||||
|
@ -1334,6 +1336,7 @@ function html_print_input_text_extended(
|
|||
'onkeyup',
|
||||
'required',
|
||||
'autocomplete',
|
||||
'form',
|
||||
];
|
||||
|
||||
$output = '<input '.($password ? 'type="password" autocomplete="'.$autocomplete.'" ' : 'type="text" ');
|
||||
|
@ -1550,7 +1553,9 @@ function html_print_input_text(
|
|||
$class='',
|
||||
$onChange='',
|
||||
$autocomplete='',
|
||||
$autofocus=false
|
||||
$autofocus=false,
|
||||
$onKeyDown='',
|
||||
$formTo=''
|
||||
) {
|
||||
if ($maxlength == 0) {
|
||||
$maxlength = 255;
|
||||
|
@ -1575,6 +1580,10 @@ function html_print_input_text(
|
|||
$attr['onchange'] = $onChange;
|
||||
}
|
||||
|
||||
if ($onKeyDown != '') {
|
||||
$attr['onkeydown'] = $onKeyDown;
|
||||
}
|
||||
|
||||
if ($autocomplete !== '') {
|
||||
$attr['autocomplete'] = $autocomplete;
|
||||
}
|
||||
|
@ -1583,6 +1592,10 @@ function html_print_input_text(
|
|||
$attr['autofocus'] = $autofocus;
|
||||
}
|
||||
|
||||
if ($formTo != '') {
|
||||
$attr['form'] = $formTo;
|
||||
}
|
||||
|
||||
return html_print_input_text_extended(
|
||||
$name,
|
||||
$value,
|
||||
|
@ -2164,6 +2177,10 @@ function html_print_table(&$table, $return=false)
|
|||
$output = '';
|
||||
static $table_count = 0;
|
||||
|
||||
if (!isset($table)) {
|
||||
$table = new StdClass();
|
||||
}
|
||||
|
||||
$table_count++;
|
||||
if (isset($table->align)) {
|
||||
foreach ($table->align as $key => $aa) {
|
||||
|
@ -3453,7 +3470,10 @@ function html_print_input($data, $wrapper='div', $input_only=false)
|
|||
((isset($data['function']) === true) ? $data['function'] : ''),
|
||||
((isset($data['class']) === true) ? $data['class'] : ''),
|
||||
((isset($data['onChange']) === true) ? $data['onChange'] : ''),
|
||||
((isset($data['autocomplete']) === true) ? $data['autocomplete'] : '')
|
||||
((isset($data['autocomplete']) === true) ? $data['autocomplete'] : ''),
|
||||
false,
|
||||
((isset($data['onKeyDown']) === true) ? $data['onKeyDown'] : ''),
|
||||
((isset($data['form']) === true) ? $data['form'] : '')
|
||||
);
|
||||
break;
|
||||
|
||||
|
@ -3500,24 +3520,6 @@ function html_print_input($data, $wrapper='div', $input_only=false)
|
|||
);
|
||||
break;
|
||||
|
||||
case 'text':
|
||||
$output .= html_print_input_text(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['alt']) === true) ? $data['alt'] : ''),
|
||||
((isset($data['size']) === true) ? $data['size'] : 50),
|
||||
((isset($data['maxlength']) === true) ? $data['maxlength'] : 255),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['required']) === true) ? $data['required'] : false),
|
||||
((isset($data['function']) === true) ? $data['function'] : ''),
|
||||
((isset($data['class']) === true) ? $data['class'] : ''),
|
||||
((isset($data['onChange']) === true) ? $data['onChange'] : ''),
|
||||
((isset($data['autocomplete']) === true) ? $data['autocomplete'] : ''),
|
||||
((isset($data['autofocus']) === true) ? $data['autofocus'] : false)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'email':
|
||||
$output .= html_print_input_email($data);
|
||||
break;
|
||||
|
@ -3600,7 +3602,8 @@ function html_print_input($data, $wrapper='div', $input_only=false)
|
|||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['style']) === true) ? $data['style'] : false),
|
||||
((isset($data['size']) === true) ? $data['size'] : false),
|
||||
((isset($data['trucate_size']) === true) ? $data['trucate_size'] : GENERIC_SIZE_TEXT)
|
||||
((isset($data['trucate_size']) === true) ? $data['trucate_size'] : GENERIC_SIZE_TEXT),
|
||||
((isset($data['class']) === true) ? $data['class'] : '')
|
||||
);
|
||||
break;
|
||||
|
||||
|
|
|
@ -2271,6 +2271,102 @@ function modules_get_agentmodule_data(
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return module data in readable format.
|
||||
*
|
||||
* @param array $module Current module.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function modules_get_agentmodule_data_for_humans($module)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (is_numeric($module['datos']) && !modules_is_string_type($module['id_tipo_modulo'])) {
|
||||
if ($config['render_proc']) {
|
||||
switch ($module['id_tipo_modulo']) {
|
||||
case 2:
|
||||
case 6:
|
||||
case 9:
|
||||
case 18:
|
||||
case 21:
|
||||
case 31:
|
||||
if ($module['datos'] >= 1) {
|
||||
$salida = $config['render_proc_ok'];
|
||||
} else {
|
||||
$salida = $config['render_proc_fail'];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
switch ($module['id_tipo_modulo']) {
|
||||
case 15:
|
||||
$value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module['id_agente_modulo']);
|
||||
if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') {
|
||||
if ($module['post_process'] > 0) {
|
||||
$salida = human_milliseconds_to_string(($module['datos'] / $module['post_process']));
|
||||
} else {
|
||||
$salida = human_milliseconds_to_string($module['datos']);
|
||||
}
|
||||
} else {
|
||||
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision']));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision']));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch ($module['id_tipo_modulo']) {
|
||||
case 15:
|
||||
$value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module['id_agente_modulo']);
|
||||
if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') {
|
||||
if ($module['post_process'] > 0) {
|
||||
$salida = human_milliseconds_to_string(($module['datos'] / $module['post_process']));
|
||||
} else {
|
||||
$salida = human_milliseconds_to_string($module['datos']);
|
||||
}
|
||||
} else {
|
||||
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision']));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision']));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Show units ONLY in numeric data types
|
||||
if (isset($module['unit'])) {
|
||||
$data_macro = modules_get_unit_macro($module['datos'], $module['unit']);
|
||||
if ($data_macro) {
|
||||
$salida = $data_macro;
|
||||
} else {
|
||||
$salida .= ' <i>'.io_safe_output($module['unit']).'</i>';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$data_macro = modules_get_unit_macro($module['datos'], $module['unit']);
|
||||
if ($data_macro) {
|
||||
$salida = $data_macro;
|
||||
} else {
|
||||
$salida = ui_print_module_string_value(
|
||||
$module['datos'],
|
||||
$module['id_agente_modulo'],
|
||||
$module['current_interval'],
|
||||
$module['module_name']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $salida;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function gets the modulegroup for a given group
|
||||
*
|
||||
|
|
|
@ -699,45 +699,6 @@ function notifications_print_global_source_configuration($source)
|
|||
$source['id']
|
||||
);
|
||||
$html_selectors .= '</div>';
|
||||
// Generate the checkboxes and time select.
|
||||
$html_checkboxes = "<div class='global-config-notification-checkboxes'>";
|
||||
$html_checkboxes .= ' <span>';
|
||||
$html_checkboxes .= html_print_checkbox_extended('all-'.$source['id'], 1, $is_group_all, false, '', 'class= "elem-clickable"', true, 'id="nt-'.$source['id'].'-all_users"');
|
||||
$html_checkboxes .= __('Notify all users');
|
||||
$html_checkboxes .= ' </span><br><span>';
|
||||
$html_checkboxes .= html_print_checkbox_extended('mail-'.$source['id'], 1, $source['also_mail'], false, '', 'class= "elem-clickable"', true, 'id="nt-'.$source['id'].'-also_mail"');
|
||||
$html_checkboxes .= __('Also email users with notification content');
|
||||
$html_checkboxes .= ' </span><br><span>';
|
||||
$html_checkboxes .= html_print_checkbox_extended('user-'.$source['id'], 1, $source['user_editable'], false, '', 'class= "elem-clickable"', true, 'id="nt-'.$source['id'].'-user_editable"');
|
||||
$html_checkboxes .= __('Users can modify notification preferences');
|
||||
$html_checkboxes .= ' </span>';
|
||||
$html_checkboxes .= '</div>';
|
||||
|
||||
// Generate the select with the time.
|
||||
$html_select_pospone = __('Users can postpone notifications up to');
|
||||
// FIXMEit should not be disabled.
|
||||
$html_select_pospone .= html_print_select(
|
||||
[
|
||||
SECONDS_5MINUTES => __('5 minutes'),
|
||||
SECONDS_15MINUTES => __('15 minutes'),
|
||||
SECONDS_12HOURS => __('12 hours'),
|
||||
SECONDS_1DAY => __('1 day'),
|
||||
SECONDS_1WEEK => __('1 week'),
|
||||
SECONDS_15DAYS => __('15 days'),
|
||||
SECONDS_1MONTH => __('1 month'),
|
||||
NOTIFICATIONS_POSTPONE_FOREVER => __('forever'),
|
||||
],
|
||||
'nt-'.$source['id'].'-max_postpone_time',
|
||||
$source['max_postpone_time'],
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'elem-changeable',
|
||||
true
|
||||
);
|
||||
|
||||
// Return all html.
|
||||
return $html_title.$html_selectors.$html_checkboxes.$html_select_pospone;
|
||||
|
|
|
@ -8993,22 +8993,22 @@ function reporting_get_stats_indicators($data, $width=280, $height=20, $html=tru
|
|||
|
||||
if ($html) {
|
||||
$tdata[0] = '<fieldset class="databox tactical_set">
|
||||
<legend>'.__('Server health').ui_print_help_tip(sprintf(__('%d Downed servers'), $servers['down']), true).'</legend>'.progress_bar($servers['health'], $width, $height, '', 0).'</fieldset>';
|
||||
<legend>'.__('Server health').ui_print_help_tip(sprintf(__('%d Downed servers'), (int) $servers['down']), true).'</legend>'.progress_bar($servers['health'], $width, $height, '', 0).'</fieldset>';
|
||||
$table_ind->rowclass[] = '';
|
||||
$table_ind->data[] = $tdata;
|
||||
|
||||
$tdata[0] = '<fieldset class="databox tactical_set">
|
||||
<legend>'.__('Monitor health').ui_print_help_tip(sprintf(__('%d Not Normal monitors'), $data['monitor_not_normal']), true).'</legend>'.progress_bar($data['monitor_health'], $width, $height, $data['monitor_health'].'% '.__('of monitors up'), 0).'</fieldset>';
|
||||
<legend>'.__('Monitor health').ui_print_help_tip(sprintf(__('%d Not Normal monitors'), (int) $data['monitor_not_normal']), true).'</legend>'.progress_bar($data['monitor_health'], $width, $height, $data['monitor_health'].'% '.__('of monitors up'), 0).'</fieldset>';
|
||||
$table_ind->rowclass[] = '';
|
||||
$table_ind->data[] = $tdata;
|
||||
|
||||
$tdata[0] = '<fieldset class="databox tactical_set">
|
||||
<legend>'.__('Module sanity').ui_print_help_tip(sprintf(__('%d Not inited monitors'), $data['monitor_not_init']), true).'</legend>'.progress_bar($data['module_sanity'], $width, $height, $data['module_sanity'].'% '.__('of total modules inited'), 0).'</fieldset>';
|
||||
<legend>'.__('Module sanity').ui_print_help_tip(sprintf(__('%d Not inited monitors'), (int) $data['monitor_not_init']), true).'</legend>'.progress_bar($data['module_sanity'], $width, $height, $data['module_sanity'].'% '.__('of total modules inited'), 0).'</fieldset>';
|
||||
$table_ind->rowclass[] = '';
|
||||
$table_ind->data[] = $tdata;
|
||||
|
||||
$tdata[0] = '<fieldset class="databox tactical_set">
|
||||
<legend>'.__('Alert level').ui_print_help_tip(sprintf(__('%d Fired alerts'), $data['monitor_alerts_fired']), true).'</legend>'.progress_bar($data['alert_level'], $width, $height, $data['alert_level'].'% '.__('of defined alerts not fired'), 0).'</fieldset>';
|
||||
<legend>'.__('Alert level').ui_print_help_tip(sprintf(__('%d Fired alerts'), (int) $data['monitor_alerts_fired']), true).'</legend>'.progress_bar($data['alert_level'], $width, $height, $data['alert_level'].'% '.__('of defined alerts not fired'), 0).'</fieldset>';
|
||||
$table_ind->rowclass[] = '';
|
||||
$table_ind->data[] = $tdata;
|
||||
|
||||
|
|
|
@ -783,7 +783,7 @@ function snmp_browser_print_container($return=false, $width='100%', $height='60%
|
|||
$table2->cellstyle[0][2] = 'text-align:center;';
|
||||
|
||||
// This extra div that can be handled by jquery's dialog.
|
||||
$output = '<div id="snmp_browser_container" style="display:'.$display.'">';
|
||||
$output = '<div id="snmp_browser_container" style="'.$display.'">';
|
||||
$output .= '<div style="text-align: left; width: '.$width.'; height: '.$height.';">';
|
||||
$output .= '<div style="width: 100%">';
|
||||
$output .= html_print_table($table, true);
|
||||
|
|
|
@ -123,11 +123,11 @@ function treeview_printModuleTable($id_module, $server_data=false, $no_head=fals
|
|||
$row['data'] = $module_group;
|
||||
$table->data['module_group'] = $row;
|
||||
|
||||
// Description
|
||||
// Description.
|
||||
$row = [];
|
||||
$row['title'] = __('Description');
|
||||
$row['data'] = ui_print_truncate_text(
|
||||
$module['descripcion'];,
|
||||
$module['descripcion'],
|
||||
'description',
|
||||
true,
|
||||
true,
|
||||
|
@ -761,21 +761,25 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false)
|
|||
}
|
||||
}
|
||||
|
||||
// End of table advanced
|
||||
// End of table advanced.
|
||||
$table_advanced = html_print_table($table, true);
|
||||
$table_advanced .= '<br>';
|
||||
|
||||
ui_toggle($table_advanced, __('Advanced information'));
|
||||
|
||||
if ($config['agentaccess']) {
|
||||
$access_graph = '<div style="width:100%; height:130px;">';
|
||||
$access_graph = '<div style="width:100%; height:130px; text-align:center;">';
|
||||
$access_graph .= graphic_agentaccess(
|
||||
$id_agente,
|
||||
SECONDS_1DAY,
|
||||
true
|
||||
false
|
||||
);
|
||||
$access_graph .= '</div>';
|
||||
ui_toggle($access_graph, __('Agent access rate (24h)'));
|
||||
|
||||
ui_toggle(
|
||||
$access_graph,
|
||||
__('Agent access rate (24h)')
|
||||
);
|
||||
}
|
||||
|
||||
$events_graph = '<div style="width: 100%; height: 90px; display: flex; flex-direction: row; justify-content: center;">';
|
||||
|
|
|
@ -1908,8 +1908,6 @@ function ui_process_page_head($string, $bitfield)
|
|||
);
|
||||
// Load base64 javascript library.
|
||||
$config['js']['base64'] = 'include/javascript/encode_decode_base64.js';
|
||||
// Load webchat javascript library.
|
||||
$config['js']['webchat'] = 'include/javascript/webchat.js';
|
||||
// Load qrcode library.
|
||||
$config['js']['qrcode'] = 'include/javascript/qrcode.js';
|
||||
// Load intro.js library (for bubbles and clippy).
|
||||
|
@ -2848,6 +2846,7 @@ function ui_print_status_sets(
|
|||
* [
|
||||
* 'page' => 'operation/agentes/ver_agente', Target page.
|
||||
* 'interval' => 100 / $agent["intervalo"], Ask every interval seconds.
|
||||
* 'simple' => 0,
|
||||
* 'data' => [ Data to be sent to target page.
|
||||
* 'id_agente' => $id_agente,
|
||||
* 'refresh_contact' => 1,
|
||||
|
@ -2881,56 +2880,99 @@ function ui_progress(
|
|||
$text = $progress.'%';
|
||||
}
|
||||
|
||||
$id = uniqid();
|
||||
|
||||
ui_require_css_file('progress');
|
||||
$output .= '<span class="progress_main" data-label="'.$text;
|
||||
$output .= '<span id="'.$id.'" class="progress_main" data-label="'.$text;
|
||||
$output .= '" style="width: '.$width.'; height: '.$height.'em; border: 1px solid '.$color.'">';
|
||||
$output .= '<span class="progress" style="width: '.$progress.'%; background: '.$color.'"></span>';
|
||||
$output .= '<span id="'.$id.'_progress" class="progress" style="width: '.$progress.'%; background: '.$color.'"></span>';
|
||||
$output .= '</span>';
|
||||
|
||||
if ($ajax !== false && is_array($ajax)) {
|
||||
$output .= '<script type="text/javascript">
|
||||
if ($ajax['simple']) {
|
||||
$output .= '<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
setInterval(() => {
|
||||
last = $(".progress_main").attr("data-label").split(" ")[0]*1;
|
||||
width = $(".progress").width() / $(".progress").parent().width() * 100;
|
||||
$.post({
|
||||
url: "'.ui_get_full_url('ajax.php', false, false, false).'",
|
||||
data: {';
|
||||
if (is_array($ajax['data'])) {
|
||||
foreach ($ajax['data'] as $token => $value) {
|
||||
$output .= '
|
||||
'.$token.':"'.$value.'",';
|
||||
}
|
||||
}
|
||||
|
||||
$output .= '
|
||||
page: "'.$ajax['page'].'"
|
||||
},
|
||||
success: function(data) {
|
||||
try {
|
||||
val = JSON.parse(data);
|
||||
$("#'.$id.'").attr("data-label", val + " %");
|
||||
$("#'.$id.'_progress").width(val+"%");';
|
||||
if (isset($ajax['oncomplete'])) {
|
||||
$output .= '
|
||||
if (val == 100) {
|
||||
'.$ajax['oncomplete'].'($("#'.$id.'"));
|
||||
}
|
||||
';
|
||||
}
|
||||
|
||||
$output .= '
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}, '.($ajax['interval'] > 0 ? $ajax['interval'] * 1000 : 30000 ).');
|
||||
});
|
||||
</script>';
|
||||
} else {
|
||||
$output .= '<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
setInterval(() => {
|
||||
last = $("#'.$id.'").attr("data-label").split(" ")[0]*1;
|
||||
width = $("#'.$id.'_progress").width() / $("#'.$id.'_progress").parent().width() * 100;
|
||||
width_interval = '.$ajax['interval'].';
|
||||
if (last % 10 == 0) {
|
||||
$.post({
|
||||
url: "'.ui_get_full_url('ajax.php', false, false, false).'",
|
||||
data: {';
|
||||
if (is_array($ajax['data'])) {
|
||||
foreach ($ajax['data'] as $token => $value) {
|
||||
$output .= '
|
||||
'.$token.':"'.$value.'",';
|
||||
if (is_array($ajax['data'])) {
|
||||
foreach ($ajax['data'] as $token => $value) {
|
||||
$output .= '
|
||||
'.$token.':"'.$value.'",';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$output .= '
|
||||
$output .= '
|
||||
page: "'.$ajax['page'].'"
|
||||
},
|
||||
success: function(data) {
|
||||
try {
|
||||
val = JSON.parse(data);
|
||||
$(".progress_main").attr("data-label", val["last_contact"]+" s");
|
||||
$(".progress").width(val["progress"]+"%");
|
||||
$("#'.$id.'").attr("data-label", val["last_contact"]+" s");
|
||||
$("#'.$id.'_progress").width(val["progress"]+"%");
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
$(".progress_text").attr("data-label", (last -1) + " s");
|
||||
if (width < 100) {
|
||||
$(".progress").width((width+width_interval) + "%");
|
||||
$("#'.$id.'_progress").width((width+width_interval) + "%");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$(".progress_main").attr("data-label", (last -1) + " s");
|
||||
$("#'.$id.'").attr("data-label", (last -1) + " s");
|
||||
if (width < 100) {
|
||||
$(".progress").width((width+width_interval) + "%");
|
||||
$("#'.$id.'_progress").width((width+width_interval) + "%");
|
||||
}
|
||||
}
|
||||
}, 1000);
|
||||
});
|
||||
</script>';
|
||||
}
|
||||
}
|
||||
|
||||
if (!$return) {
|
||||
|
@ -3469,10 +3511,13 @@ function ui_print_datatable(array $parameters)
|
|||
ui_require_javascript_file('buttons.html5.min');
|
||||
ui_require_javascript_file('buttons.print.min');
|
||||
|
||||
$output = $include.$output;
|
||||
if (isset($parameters['return']) && $parameters['return'] == true) {
|
||||
// Compat.
|
||||
$parameters['print'] = false;
|
||||
}
|
||||
|
||||
// Print datatable if needed.
|
||||
if (isset($parameters['print']) === false || $parameters['print'] === false) {
|
||||
if (isset($parameters['print']) === false || $parameters['print'] === true) {
|
||||
echo $output;
|
||||
}
|
||||
|
||||
|
@ -3673,8 +3718,8 @@ function ui_toggle(
|
|||
// Generate unique Id.
|
||||
$uniqid = uniqid('');
|
||||
|
||||
$image_a = html_print_image($img_a, true, false, true);
|
||||
$image_b = html_print_image($img_b, true, false, true);
|
||||
$image_a = html_print_image($img_a, true, [ 'style' => 'object-fit: contain;' ], true);
|
||||
$image_b = html_print_image($img_b, true, [ 'style' => 'object-fit: contain;' ], true);
|
||||
// Options.
|
||||
if ($hidden_default) {
|
||||
$style = 'display:none';
|
||||
|
@ -3698,6 +3743,7 @@ function ui_toggle(
|
|||
$original,
|
||||
true,
|
||||
[
|
||||
'style' => 'object-fit: contain;',
|
||||
'title' => $title,
|
||||
'id' => 'image_'.$uniqid,
|
||||
]
|
||||
|
|
|
@ -497,508 +497,6 @@ function users_get_user_by_id($id_user)
|
|||
}
|
||||
|
||||
|
||||
define('MAX_TIMES', 10);
|
||||
|
||||
//
|
||||
// WEBCHAT FUNCTIONS/////////////////////////////////
|
||||
//
|
||||
function users_get_last_messages($last_time=false)
|
||||
{
|
||||
$file_global_counter_chat = $config['attachment_store'].'/pandora_chat.global_counter.txt';
|
||||
|
||||
// First lock the file
|
||||
$fp_global_counter = @fopen($file_global_counter_chat, 'a+');
|
||||
if ($fp_global_counter === false) {
|
||||
echo json_encode($return);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Try to look MAX_TIMES times
|
||||
$tries = 0;
|
||||
while (!flock($fp_global_counter, LOCK_EX)) {
|
||||
$tries++;
|
||||
if ($tries > MAX_TIMES) {
|
||||
echo json_encode($return);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
fscanf($fp_global_counter, '%d', $global_counter_file);
|
||||
if (empty($global_counter_file)) {
|
||||
$global_counter_file = 0;
|
||||
}
|
||||
|
||||
$timestamp = time();
|
||||
if ($last_time === false) {
|
||||
$last_time = (24 * 60 * 60);
|
||||
}
|
||||
|
||||
$from = ($timestamp - $last_time);
|
||||
|
||||
$log_chat_file = $config['attachment_store'].'/pandora_chat.log.json.txt';
|
||||
|
||||
$return = [
|
||||
'correct' => false,
|
||||
'log' => [],
|
||||
];
|
||||
|
||||
if (!file_exists($log_chat_file)) {
|
||||
touch($log_chat_file);
|
||||
}
|
||||
|
||||
$text_encode = @file_get_contents($log_chat_file);
|
||||
$log = json_decode($text_encode, true);
|
||||
|
||||
if ($log !== false) {
|
||||
if ($log === null) {
|
||||
$log = [];
|
||||
}
|
||||
|
||||
$log_last_time = [];
|
||||
foreach ($log as $message) {
|
||||
if ($message['timestamp'] >= $from) {
|
||||
$log_last_time[] = $message;
|
||||
}
|
||||
}
|
||||
|
||||
$return['correct'] = true;
|
||||
$return['log'] = $log_last_time;
|
||||
$return['global_counter'] = $global_counter_file;
|
||||
}
|
||||
|
||||
echo json_encode($return);
|
||||
|
||||
fclose($fp_global_counter);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
function users_save_login()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$file_global_user_list = $config['attachment_store'].'/pandora_chat.user_list.json.txt';
|
||||
|
||||
$user = db_get_row_filter(
|
||||
'tusuario',
|
||||
['id_user' => $config['id_user']]
|
||||
);
|
||||
|
||||
$message = sprintf(
|
||||
__('User %s login at %s'),
|
||||
$user['fullname'],
|
||||
date($config['date_format'])
|
||||
);
|
||||
users_save_text_message($message, 'notification');
|
||||
|
||||
// First lock the file
|
||||
$fp_user_list = @fopen($file_global_user_list, 'a+');
|
||||
if ($fp_user_list === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Try to look MAX_TIMES times
|
||||
$tries = 0;
|
||||
while (!flock($fp_user_list, LOCK_EX)) {
|
||||
$tries++;
|
||||
if ($tries > MAX_TIMES) {
|
||||
return;
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
@fscanf($fp_user_list, "%[^\n]", $user_list_json);
|
||||
|
||||
$user_list = json_decode($user_list_json, true);
|
||||
if (empty($user_list)) {
|
||||
$user_list[$config['id_user']] = [
|
||||
'name' => $user['fullname'],
|
||||
'count' => 1,
|
||||
];
|
||||
} else if (isset($user_list[$config['id_user']])) {
|
||||
$user_list[$config['id_user']] = [
|
||||
'name' => $user['fullname'],
|
||||
'count' => $user_list[$config['id_user']]['count'],
|
||||
];
|
||||
} else {
|
||||
$users_count = count($user_list);
|
||||
$user_list[$config['id_user']] = [
|
||||
'name' => $user['fullname'],
|
||||
'count' => ++$users_count,
|
||||
];
|
||||
}
|
||||
|
||||
// Clean the file
|
||||
ftruncate($fp_user_list, 0);
|
||||
|
||||
$status = fwrite($fp_user_list, json_encode($user_list));
|
||||
|
||||
if ($status === false) {
|
||||
fclose($fp_user_list);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
fclose($fp_user_list);
|
||||
}
|
||||
|
||||
|
||||
function users_save_logout($user=false, $delete=false)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$return = [
|
||||
'correct' => false,
|
||||
'users' => [],
|
||||
];
|
||||
|
||||
$file_global_user_list = $config['attachment_store'].'/pandora_chat.user_list.json.txt';
|
||||
|
||||
if (empty($user)) {
|
||||
$user = db_get_row_filter(
|
||||
'tusuario',
|
||||
['id_user' => $config['id_user']]
|
||||
);
|
||||
}
|
||||
|
||||
if ($delete) {
|
||||
$no_json_output = true;
|
||||
$message = sprintf(
|
||||
__('User %s was deleted in the DB at %s'),
|
||||
$user['fullname'],
|
||||
date($config['date_format'])
|
||||
);
|
||||
} else {
|
||||
$no_json_output = false;
|
||||
$message = sprintf(
|
||||
__('User %s logout at %s'),
|
||||
$user['fullname'],
|
||||
date($config['date_format'])
|
||||
);
|
||||
}
|
||||
|
||||
users_save_text_message($message, 'notification', $no_json_output);
|
||||
|
||||
// First lock the file
|
||||
$fp_user_list = @fopen($file_global_user_list, 'a+');
|
||||
if ($fp_user_list === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Try to look MAX_TIMES times
|
||||
$tries = 0;
|
||||
while (!flock($fp_user_list, LOCK_EX)) {
|
||||
$tries++;
|
||||
if ($tries > MAX_TIMES) {
|
||||
return;
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
@fscanf($fp_user_list, "%[^\n]", $user_list_json);
|
||||
|
||||
$user_list = json_decode($user_list_json, true);
|
||||
if (empty($user_list)) {
|
||||
$user_list = [];
|
||||
}
|
||||
|
||||
unset($user_list[$user['id_user']]);
|
||||
|
||||
// Clean the file
|
||||
ftruncate($fp_user_list, 0);
|
||||
|
||||
$status = fwrite($fp_user_list, json_encode($user_list));
|
||||
|
||||
if ($status === false) {
|
||||
fclose($fp_user_list);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
fclose($fp_user_list);
|
||||
}
|
||||
|
||||
|
||||
function users_save_text_message($message=false, $type='message', $no_json_output=false)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$file_global_counter_chat = $config['attachment_store'].'/pandora_chat.global_counter.txt';
|
||||
$log_chat_file = $config['attachment_store'].'/pandora_chat.log.json.txt';
|
||||
|
||||
$return = ['correct' => false];
|
||||
|
||||
$id_user = $config['id_user'];
|
||||
$user = db_get_row_filter(
|
||||
'tusuario',
|
||||
['id_user' => $id_user]
|
||||
);
|
||||
|
||||
$message_data = [];
|
||||
$message_data['type'] = $type;
|
||||
$message_data['id_user'] = $id_user;
|
||||
$message_data['user_name'] = $user['fullname'];
|
||||
$message_data['text'] = io_safe_input_html($message);
|
||||
// The $message_data['timestamp'] set when adquire the files to save.
|
||||
// First lock the file
|
||||
$fp_global_counter = @fopen($file_global_counter_chat, 'a+');
|
||||
if ($fp_global_counter === false) {
|
||||
if (!$no_json_output) {
|
||||
echo json_encode($return);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Try to look MAX_TIMES times
|
||||
$tries = 0;
|
||||
while (!flock($fp_global_counter, LOCK_EX)) {
|
||||
$tries++;
|
||||
if ($tries > MAX_TIMES) {
|
||||
if (!$no_json_output) {
|
||||
echo json_encode($return);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
@fscanf($fp_global_counter, '%d', $global_counter_file);
|
||||
if (empty($global_counter_file)) {
|
||||
$global_counter_file = 0;
|
||||
}
|
||||
|
||||
// Clean the file
|
||||
ftruncate($fp_global_counter, 0);
|
||||
|
||||
$message_data['timestamp'] = time();
|
||||
$message_data['human_time'] = date($config['date_format'], $message_data['timestamp']);
|
||||
|
||||
$global_counter = ($global_counter_file + 1);
|
||||
|
||||
$status = fwrite($fp_global_counter, $global_counter);
|
||||
|
||||
if ($status === false) {
|
||||
fclose($fp_global_counter);
|
||||
|
||||
if (!$no_json_output) {
|
||||
echo json_encode($return);
|
||||
}
|
||||
|
||||
return;
|
||||
} else {
|
||||
$text_encode = @file_get_contents($log_chat_file);
|
||||
$log = json_decode($text_encode, true);
|
||||
$log[$global_counter] = $message_data;
|
||||
$status = file_put_contents($log_chat_file, json_encode($log));
|
||||
|
||||
fclose($fp_global_counter);
|
||||
|
||||
$return['correct'] = true;
|
||||
if (!$no_json_output) {
|
||||
echo json_encode($return);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
function users_long_polling_check_messages($global_counter)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$file_global_counter_chat = $config['attachment_store'].'/pandora_chat.global_counter.txt';
|
||||
$log_chat_file = $config['attachment_store'].'/pandora_chat.log.json.txt';
|
||||
|
||||
$changes = false;
|
||||
|
||||
$tries_general = 0;
|
||||
|
||||
$error = false;
|
||||
|
||||
while (!$changes) {
|
||||
// First lock the file
|
||||
$fp_global_counter = @fopen($file_global_counter_chat, 'a+');
|
||||
if ($fp_global_counter) {
|
||||
// Try to look MAX_TIMES times
|
||||
$tries = 0;
|
||||
$lock = true;
|
||||
while (!flock($fp_global_counter, LOCK_EX)) {
|
||||
$tries++;
|
||||
if ($tries > MAX_TIMES) {
|
||||
$lock = false;
|
||||
$error = true;
|
||||
break;
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
if ($lock) {
|
||||
@fscanf($fp_global_counter, '%d', $global_counter_file);
|
||||
if (empty($global_counter_file)) {
|
||||
$global_counter_file = 0;
|
||||
}
|
||||
|
||||
if ($global_counter_file > $global_counter) {
|
||||
// TODO Optimize slice the array.
|
||||
$text_encode = @file_get_contents($log_chat_file);
|
||||
$log = json_decode($text_encode, true);
|
||||
|
||||
$return_log = [];
|
||||
foreach ($log as $key => $message) {
|
||||
if ($key <= $global_counter) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$return_log[] = $message;
|
||||
}
|
||||
|
||||
$return = [
|
||||
'correct' => true,
|
||||
'global_counter' => $global_counter_file,
|
||||
'log' => $return_log,
|
||||
];
|
||||
|
||||
echo json_encode($return);
|
||||
|
||||
fclose($fp_global_counter);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fclose($fp_global_counter);
|
||||
}
|
||||
|
||||
sleep(3);
|
||||
$tries_general = ($tries_general + 3);
|
||||
|
||||
if ($tries_general > MAX_TIMES) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Because maybe the exit of loop for exaust.
|
||||
echo json_encode(['correct' => false, 'error' => $error]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the last global counter for chat.
|
||||
*
|
||||
* @param string $mode There are two modes 'json', 'return' and 'session'. And json is by default.
|
||||
*/
|
||||
function users_get_last_global_counter($mode='json')
|
||||
{
|
||||
global $config;
|
||||
|
||||
$file_global_counter_chat = $config['attachment_store'].'/pandora_chat.global_counter.txt';
|
||||
|
||||
$global_counter_file = 0;
|
||||
|
||||
$fp_global_counter = @fopen($file_global_counter_chat, 'a+');
|
||||
if ($fp_global_counter) {
|
||||
$tries = 0;
|
||||
$lock = true;
|
||||
while (!flock($fp_global_counter, LOCK_EX)) {
|
||||
$tries++;
|
||||
if ($tries > MAX_TIMES) {
|
||||
$lock = false;
|
||||
break;
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
if ($lock) {
|
||||
@fscanf($fp_global_counter, '%d', $global_counter_file);
|
||||
if (empty($global_counter_file)) {
|
||||
$global_counter_file = 0;
|
||||
}
|
||||
|
||||
fclose($fp_global_counter);
|
||||
}
|
||||
}
|
||||
|
||||
switch ($mode) {
|
||||
case 'json':
|
||||
echo json_encode(['correct' => true, 'global_counter' => $global_counter_file]);
|
||||
break;
|
||||
|
||||
case 'return':
|
||||
return $global_counter_file;
|
||||
|
||||
break;
|
||||
case 'session':
|
||||
$_SESSION['global_counter_chat'] = $global_counter_file;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the last global counter for chat.
|
||||
*
|
||||
* @param string $mode There are two modes 'json', 'return' and 'session'. And json is by default.
|
||||
*/
|
||||
function users_get_last_type_message()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$return = 'false';
|
||||
|
||||
$file_global_counter_chat = $config['attachment_store'].'/pandora_chat.global_counter.txt';
|
||||
$log_chat_file = $config['attachment_store'].'/pandora_chat.log.json.txt';
|
||||
|
||||
$global_counter_file = 0;
|
||||
|
||||
$fp_global_counter = @fopen($file_global_counter_chat, 'a+');
|
||||
if ($fp_global_counter) {
|
||||
$tries = 0;
|
||||
$lock = true;
|
||||
while (!flock($fp_global_counter, LOCK_EX)) {
|
||||
$tries++;
|
||||
if ($tries > MAX_TIMES) {
|
||||
$lock = false;
|
||||
break;
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
if ($lock) {
|
||||
$text_encode = @file_get_contents($log_chat_file);
|
||||
$log = json_decode($text_encode, true);
|
||||
|
||||
// Prevent from error when chat file log doesn't exists
|
||||
if (empty($log)) {
|
||||
$return = false;
|
||||
} else {
|
||||
$last = end($log);
|
||||
$return = $last['type'];
|
||||
}
|
||||
|
||||
fclose($fp_global_counter);
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
function users_is_admin($id_user=false)
|
||||
{
|
||||
global $config;
|
||||
|
@ -1026,98 +524,6 @@ function users_is_admin($id_user=false)
|
|||
}
|
||||
|
||||
|
||||
function users_is_last_system_message()
|
||||
{
|
||||
$type = users_get_last_type_message();
|
||||
|
||||
if ($type != 'message') {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function users_check_users()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$return = [
|
||||
'correct' => false,
|
||||
'users' => '',
|
||||
];
|
||||
|
||||
$users_with_session = db_get_all_rows_sql('SELECT tsessions_php.data FROM pandora.tsessions_php;');
|
||||
$users_logged_now = [];
|
||||
foreach ($users_with_session as $user_with_session) {
|
||||
$tmp_id_user = explode('"', $user_with_session['data']);
|
||||
array_push($users_logged_now, $tmp_id_user[1]);
|
||||
}
|
||||
|
||||
$file_global_user_list = $config['attachment_store'].'/pandora_chat.user_list.json.txt';
|
||||
|
||||
// First lock the file
|
||||
$fp_user_list = @fopen($file_global_user_list, 'a+');
|
||||
if ($fp_user_list === false) {
|
||||
echo json_encode($return);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Try to look MAX_TIMES times
|
||||
$tries = 0;
|
||||
while (!flock($fp_user_list, LOCK_EX)) {
|
||||
$tries++;
|
||||
if ($tries > MAX_TIMES) {
|
||||
echo json_encode($return);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
@fscanf($fp_user_list, "%[^\n]", $user_list_json);
|
||||
|
||||
$user_list = json_decode($user_list_json, true);
|
||||
if (empty($user_list)) {
|
||||
$user_list = [];
|
||||
}
|
||||
|
||||
// Compare both user list. Meanwhile the user from chat file have an active
|
||||
// session, his continue in the list of active chat users
|
||||
$user_name_list = [];
|
||||
foreach ($user_list as $key => $user) {
|
||||
if (in_array($key, $users_logged_now)) {
|
||||
array_push($user_name_list, $user['name']);
|
||||
} else {
|
||||
unset($user_list[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
// Clean the file
|
||||
ftruncate($fp_user_list, 0);
|
||||
|
||||
// Update the file with the correct list of users
|
||||
$status = fwrite($fp_user_list, json_encode($user_list));
|
||||
|
||||
/*
|
||||
if ($status === false) {
|
||||
fclose($fp_user_list);
|
||||
|
||||
return;
|
||||
} */
|
||||
// Closing the resource
|
||||
fclose($fp_user_list);
|
||||
|
||||
$return['correct'] = true;
|
||||
$return['users'] = implode('<br />', $user_name_list);
|
||||
echo json_encode($return);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Check if a user can manage a group when group is all
|
||||
// This function dont check acls of the group, only if the
|
||||
// user is admin or pandora manager and the group is all
|
||||
|
|
|
@ -564,13 +564,13 @@ function visual_map_print_item(
|
|||
}
|
||||
|
||||
if ($is_a_link_to_other_visualconsole) {
|
||||
if (METACONSOLE == 1) {
|
||||
if (is_metaconsole() === true) {
|
||||
$url = $config['homeurl'].'index.php?sec=screen&sec2=screens/screens&action=visualmap&pure=0&id_visualmap='.$layoutData['id_layout_linked'].'&refr=300';
|
||||
} else {
|
||||
$url = $config['homeurl'].'index.php?sec=network&sec2=operation/visual_console/render_view&pure='.$config['pure'].'&id='.$layoutData['id_layout_linked'];
|
||||
}
|
||||
} else {
|
||||
if (METACONSOLE == 1) {
|
||||
if (is_metaconsole() === true) {
|
||||
$url = $config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=0&ag_group='.$layoutData['id_group'].'&ag_freestring=&module_option=1&ag_modulename=&moduletype=&datatype=&status=-1&sort_field=&sort=none&pure=';
|
||||
} else {
|
||||
$url = $config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/estado_agente&group_id='.$layoutData['id_group'];
|
||||
|
|
|
@ -1604,15 +1604,14 @@
|
|||
}),
|
||||
d.GridStackUI
|
||||
);
|
||||
})
|
||||
/**
|
||||
* gridstack.js 0.3.0
|
||||
* http://troolee.github.io/gridstack.js/
|
||||
* (c) 2014-2016 Pavel Reznikov, Dylan Weiss
|
||||
* gridstack.js may be freely distributed under the MIT license.
|
||||
* @preserve
|
||||
*/,
|
||||
(function(a) {
|
||||
}),
|
||||
/**
|
||||
* gridstack.js 0.3.0
|
||||
* http://troolee.github.io/gridstack.js/
|
||||
* (c) 2014-2016 Pavel Reznikov, Dylan Weiss
|
||||
* gridstack.js may be freely distributed under the MIT license.
|
||||
* @preserve
|
||||
*/ (function(a) {
|
||||
if ("function" == typeof define && define.amd)
|
||||
define([
|
||||
"jquery",
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
// http://code.accursoft.com/caret - 1.3.3
|
||||
!function(e){e.fn.caret=function(e){var t=this[0],n="true"===t.contentEditable;if(0==arguments.length){if(window.getSelection){if(n){t.focus();var o=window.getSelection().getRangeAt(0),r=o.cloneRange();return r.selectNodeContents(t),r.setEnd(o.endContainer,o.endOffset),r.toString().length}return t.selectionStart}if(document.selection){if(t.focus(),n){var o=document.selection.createRange(),r=document.body.createTextRange();return r.moveToElementText(t),r.setEndPoint("EndToEnd",o),r.text.length}var e=0,c=t.createTextRange(),r=document.selection.createRange().duplicate(),a=r.getBookmark();for(c.moveToBookmark(a);0!==c.moveStart("character",-1);)e++;return e}return t.selectionStart?t.selectionStart:0}if(-1==e&&(e=this[n?"text":"val"]().length),window.getSelection)n?(t.focus(),window.getSelection().collapse(t.firstChild,e)):t.setSelectionRange(e,e);else if(document.body.createTextRange)if(n){var c=document.body.createTextRange();c.moveToElementText(t),c.moveStart("character",e),c.collapse(!0),c.select()}else{var c=t.createTextRange();c.move("character",e),c.select()}return n||t.focus(),e}}(jQuery);
|
|
@ -0,0 +1,370 @@
|
|||
/*
|
||||
jQuery tagEditor v1.0.21
|
||||
Copyright (c) 2014 Simon Steinberger / Pixabay
|
||||
GitHub: https://github.com/Pixabay/jQuery-tagEditor
|
||||
License: http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
(function($){
|
||||
// auto grow input (stackoverflow.com/questions/931207)
|
||||
$.fn.tagEditorInput=function(){var t=" ",e=$(this),n=parseInt(e.css("fontSize")),i=$("<span/>").css({position:"absolute",top:-9999,left:-9999,width:"auto",fontSize:e.css("fontSize"),fontFamily:e.css("fontFamily"),fontWeight:e.css("fontWeight"),letterSpacing:e.css("letterSpacing"),whiteSpace:"nowrap"}),s=function(){if(t!==(t=e.val())){i.text(t);var s=i.width()+n;20>s&&(s=20),s!=e.width()&&e.width(s)}};return i.insertAfter(e),e.bind("keyup keydown focus",s)};
|
||||
|
||||
// plugin with val as parameter for public methods
|
||||
$.fn.tagEditor = function(options, val, blur){
|
||||
|
||||
// helper
|
||||
function escape(tag) {
|
||||
return tag.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
||||
}
|
||||
|
||||
// build options dictionary with default values
|
||||
var blur_result, o = $.extend({}, $.fn.tagEditor.defaults, options), selector = this;
|
||||
|
||||
// store regex and default delimiter in options for later use
|
||||
o.dregex = new RegExp('['+o.delimiter.replace('-', '\-')+']', 'g');
|
||||
|
||||
// public methods
|
||||
if (typeof options == 'string') {
|
||||
// depending on selector, response may contain tag lists of multiple editor instances
|
||||
var response = [];
|
||||
selector.each(function(){
|
||||
// the editor is the next sibling to the hidden, original field
|
||||
var el = $(this), o = el.data('options'), ed = el.next('.tag-editor');
|
||||
if (options == 'getTags')
|
||||
response.push({field: el[0], editor: ed, tags: ed.data('tags')});
|
||||
else if (options == 'addTag') {
|
||||
if (o.maxTags && ed.data('tags').length >= o.maxTags) return false;
|
||||
// insert new tag
|
||||
$('<li><div class="tag-editor-spacer"> '+o.delimiter[0]+'</div><div class="tag-editor-tag"></div><div class="tag-editor-delete"><i></i></div></li>').appendTo(ed).find('.tag-editor-tag')
|
||||
.html('<input type="text" maxlength="'+o.maxLength+'">').addClass('active').find('input').val(val).blur();
|
||||
if (!blur) ed.click();
|
||||
else $('.placeholder', ed).remove();
|
||||
} else if (options == 'removeTag') {
|
||||
// trigger delete on matching tag, then click editor to create a new tag
|
||||
$('.tag-editor-tag', ed).filter(function(){return $(this).text()==val;}).closest('li').find('.tag-editor-delete').click();
|
||||
if (!blur) ed.click();
|
||||
} else if (options == 'destroy') {
|
||||
el.removeClass('tag-editor-hidden-src').removeData('options').off('focus.tag-editor').next('.tag-editor').remove();
|
||||
}
|
||||
});
|
||||
return options == 'getTags' ? response : this;
|
||||
}
|
||||
|
||||
// delete selected tags on backspace, delete, ctrl+x
|
||||
if (window.getSelection) $(document).off('keydown.tag-editor').on('keydown.tag-editor', function(e){
|
||||
if (e.which == 8 || e.which == 46 || e.ctrlKey && e.which == 88) {
|
||||
try {
|
||||
var sel = getSelection(), el = document.activeElement.tagName != 'INPUT' ? $(sel.getRangeAt(0).startContainer.parentNode).closest('.tag-editor') : 0;
|
||||
} catch(e){ el = 0; }
|
||||
if (sel.rangeCount > 0 && el && el.length) {
|
||||
var tags = [], splits = sel.toString().split(el.prev().data('options').dregex);
|
||||
for (i=0; i<splits.length; i++){ var tag = $.trim(splits[i]); if (tag) tags.push(tag); }
|
||||
$('.tag-editor-tag', el).each(function(){
|
||||
if (~$.inArray($(this).text(), tags)) $(this).closest('li').find('.tag-editor-delete').click();
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return selector.each(function(){
|
||||
var el = $(this), tag_list = []; // cache current tags
|
||||
|
||||
// create editor (ed) instance
|
||||
var ed = $('<ul '+(o.clickDelete ? 'oncontextmenu="return false;" ' : '')+'class="tag-editor"></ul>').insertAfter(el);
|
||||
el.addClass('tag-editor-hidden-src') // hide original field
|
||||
.data('options', o) // set data on hidden field
|
||||
.on('focus.tag-editor', function(){ ed.click(); }); // simulate tabindex
|
||||
|
||||
// add dummy item for min-height on empty editor
|
||||
ed.append('<li style="width:1px"> </li>');
|
||||
|
||||
// markup for new tag
|
||||
var new_tag = '<li><div class="tag-editor-spacer"> '+o.delimiter[0]+'</div><div class="tag-editor-tag"></div><div class="tag-editor-delete"><i></i></div></li>';
|
||||
|
||||
// helper: update global data
|
||||
function set_placeholder(){
|
||||
if (o.placeholder && !tag_list.length && !$('.deleted, .placeholder, input', ed).length)
|
||||
ed.append('<li class="placeholder"><div>'+o.placeholder+'</div></li>');
|
||||
}
|
||||
|
||||
// helper: update global data
|
||||
function update_globals(init){
|
||||
var old_tags = tag_list.toString();
|
||||
tag_list = $('.tag-editor-tag:not(.deleted)', ed).map(function(i, e) {
|
||||
var val = $.trim($(this).hasClass('active') ? $(this).find('input').val() : $(e).text());
|
||||
if (val) return val;
|
||||
}).get();
|
||||
ed.data('tags', tag_list);
|
||||
el.val(tag_list.join(o.delimiter[0]));
|
||||
// change callback except for plugin init
|
||||
if (!init) if (old_tags != tag_list.toString()) o.onChange(el, ed, tag_list);
|
||||
set_placeholder();
|
||||
}
|
||||
|
||||
ed.click(function(e, closest_tag){
|
||||
var d, dist = 99999, loc;
|
||||
|
||||
// do not create tag when user selects tags by text selection
|
||||
if (window.getSelection && getSelection() != '') return;
|
||||
|
||||
if (o.maxTags && ed.data('tags').length >= o.maxTags) { ed.find('input').blur(); return false; }
|
||||
|
||||
blur_result = true
|
||||
$('input:focus', ed).blur();
|
||||
if (!blur_result) return false;
|
||||
blur_result = true
|
||||
|
||||
// always remove placeholder on click
|
||||
$('.placeholder', ed).remove();
|
||||
if (closest_tag && closest_tag.length)
|
||||
loc = 'before';
|
||||
else {
|
||||
// calculate tag closest to click position
|
||||
$('.tag-editor-tag', ed).each(function(){
|
||||
var tag = $(this), to = tag.offset(), tag_x = to.left, tag_y = to.top;
|
||||
if (e.pageY >= tag_y && e.pageY <= tag_y+tag.height()) {
|
||||
if (e.pageX < tag_x) loc = 'before', d = tag_x - e.pageX;
|
||||
else loc = 'after', d = e.pageX - tag_x - tag.width();
|
||||
if (d < dist) dist = d, closest_tag = tag;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (loc == 'before') {
|
||||
$(new_tag).insertBefore(closest_tag.closest('li')).find('.tag-editor-tag').click();
|
||||
} else if (loc == 'after')
|
||||
$(new_tag).insertAfter(closest_tag.closest('li')).find('.tag-editor-tag').click();
|
||||
else // empty editor
|
||||
$(new_tag).appendTo(ed).find('.tag-editor-tag').click();
|
||||
return false;
|
||||
});
|
||||
|
||||
ed.on('click', '.tag-editor-delete', function(e){
|
||||
// delete icon is hidden when input is visible; place cursor near invisible delete icon on click
|
||||
if ($(this).prev().hasClass('active')) { $(this).closest('li').find('input').caret(-1); return false; }
|
||||
|
||||
var li = $(this).closest('li'), tag = li.find('.tag-editor-tag');
|
||||
if (o.beforeTagDelete(el, ed, tag_list, tag.text()) === false) return false;
|
||||
tag.addClass('deleted').animate({width: 0}, o.animateDelete, function(){ li.remove(); set_placeholder(); });
|
||||
update_globals();
|
||||
return false;
|
||||
});
|
||||
|
||||
// delete on right mouse click or ctrl+click
|
||||
if (o.clickDelete)
|
||||
ed.on('mousedown', '.tag-editor-tag', function(e){
|
||||
if (e.ctrlKey || e.which > 1) {
|
||||
var li = $(this).closest('li'), tag = li.find('.tag-editor-tag');
|
||||
if (o.beforeTagDelete(el, ed, tag_list, tag.text()) === false) return false;
|
||||
tag.addClass('deleted').animate({width: 0}, o.animateDelete, function(){ li.remove(); set_placeholder(); });
|
||||
update_globals();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
ed.on('click', '.tag-editor-tag', function(e){
|
||||
// delete on right click or ctrl+click -> exit
|
||||
if (o.clickDelete && (e.ctrlKey || e.which > 1)) return false;
|
||||
|
||||
if (!$(this).hasClass('active')) {
|
||||
var tag = $(this).text();
|
||||
// guess cursor position in text input
|
||||
var left_percent = Math.abs(($(this).offset().left - e.pageX)/$(this).width()), caret_pos = parseInt(tag.length*left_percent),
|
||||
input = $(this).html('<input type="text" maxlength="'+o.maxLength+'" value="'+escape(tag)+'">').addClass('active').find('input');
|
||||
input.data('old_tag', tag).tagEditorInput().focus().caret(caret_pos);
|
||||
if (o.autocomplete) {
|
||||
var aco = $.extend({}, o.autocomplete);
|
||||
// extend user provided autocomplete select method
|
||||
var ac_select = 'select' in aco ? o.autocomplete.select : '';
|
||||
aco.select = function(e, ui){ if (ac_select) ac_select(e, ui); setTimeout(function(){
|
||||
ed.trigger('click', [$('.active', ed).find('input').closest('li').next('li').find('.tag-editor-tag')]);
|
||||
}, 20); };
|
||||
input.autocomplete(aco);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
// helper: split into multiple tags, e.g. after paste
|
||||
function split_cleanup(input){
|
||||
var li = input.closest('li'), sub_tags = input.val().replace(/ +/, ' ').split(o.dregex),
|
||||
old_tag = input.data('old_tag'), old_tags = tag_list.slice(0), exceeded = false, cb_val; // copy tag_list
|
||||
for (var i=0; i<sub_tags.length; i++) {
|
||||
tag = $.trim(sub_tags[i]).slice(0, o.maxLength);
|
||||
if (o.forceLowercase) tag = tag.toLowerCase();
|
||||
cb_val = o.beforeTagSave(el, ed, old_tags, old_tag, tag);
|
||||
tag = cb_val || tag;
|
||||
if (cb_val === false || !tag) continue;
|
||||
// remove duplicates
|
||||
if (o.removeDuplicates && ~$.inArray(tag, old_tags))
|
||||
$('.tag-editor-tag', ed).each(function(){ if ($(this).text() == tag) $(this).closest('li').remove(); });
|
||||
old_tags.push(tag);
|
||||
li.before('<li><div class="tag-editor-spacer"> '+o.delimiter[0]+'</div><div class="tag-editor-tag">'+escape(tag)+'</div><div class="tag-editor-delete"><i></i></div></li>');
|
||||
if (o.maxTags && old_tags.length >= o.maxTags) { exceeded = true; break; }
|
||||
}
|
||||
input.attr('maxlength', o.maxLength).removeData('old_tag').val('')
|
||||
if (exceeded) input.blur(); else input.focus();
|
||||
update_globals();
|
||||
}
|
||||
|
||||
ed.on('blur', 'input', function(e){
|
||||
e.stopPropagation();
|
||||
var input = $(this), old_tag = input.data('old_tag'), tag = $.trim(input.val().replace(/ +/, ' ').replace(o.dregex, o.delimiter[0]));
|
||||
if (!tag) {
|
||||
if (old_tag && o.beforeTagDelete(el, ed, tag_list, old_tag) === false) {
|
||||
input.val(old_tag).focus();
|
||||
blur_result = false;
|
||||
update_globals();
|
||||
return;
|
||||
}
|
||||
try { input.closest('li').remove(); } catch(e){}
|
||||
if (old_tag) update_globals();
|
||||
}
|
||||
else if (tag.indexOf(o.delimiter[0])>=0) { split_cleanup(input); return; }
|
||||
else if (tag != old_tag) {
|
||||
if (o.forceLowercase) tag = tag.toLowerCase();
|
||||
cb_val = o.beforeTagSave(el, ed, tag_list, old_tag, tag);
|
||||
tag = cb_val || tag;
|
||||
if (cb_val === false) {
|
||||
if (old_tag) {
|
||||
input.val(old_tag).focus();
|
||||
blur_result = false;
|
||||
update_globals();
|
||||
return;
|
||||
}
|
||||
try { input.closest('li').remove(); } catch(e){}
|
||||
if (old_tag) update_globals();
|
||||
}
|
||||
// remove duplicates
|
||||
else if (o.removeDuplicates)
|
||||
$('.tag-editor-tag:not(.active)', ed).each(function(){ if ($(this).text() == tag) $(this).closest('li').remove(); });
|
||||
}
|
||||
input.parent().html(escape(tag)).removeClass('active');
|
||||
if (tag != old_tag) update_globals();
|
||||
set_placeholder();
|
||||
});
|
||||
|
||||
var pasted_content;
|
||||
ed.on('paste', 'input', function(e){
|
||||
$(this).removeAttr('maxlength');
|
||||
pasted_content = $(this);
|
||||
setTimeout(function(){ split_cleanup(pasted_content); }, 30);
|
||||
});
|
||||
|
||||
// keypress delimiter
|
||||
var inp;
|
||||
ed.on('keypress', 'input', function(e){
|
||||
if (o.delimiter.indexOf(String.fromCharCode(e.which))>=0) {
|
||||
inp = $(this);
|
||||
setTimeout(function(){ split_cleanup(inp); }, 20);
|
||||
}
|
||||
});
|
||||
|
||||
ed.on('keydown', 'input', function(e){
|
||||
var $t = $(this);
|
||||
|
||||
// left/up key + backspace key on empty field
|
||||
if ((e.which == 37 || !o.autocomplete && e.which == 38) && !$t.caret() || e.which == 8 && !$t.val()) {
|
||||
var prev_tag = $t.closest('li').prev('li').find('.tag-editor-tag');
|
||||
if (prev_tag.length) prev_tag.click().find('input').caret(-1);
|
||||
else if ($t.val() && !(o.maxTags && ed.data('tags').length >= o.maxTags)) $(new_tag).insertBefore($t.closest('li')).find('.tag-editor-tag').click();
|
||||
return false;
|
||||
}
|
||||
// right/down key
|
||||
else if ((e.which == 39 || !o.autocomplete && e.which == 40) && ($t.caret() == $t.val().length)) {
|
||||
var next_tag = $t.closest('li').next('li').find('.tag-editor-tag');
|
||||
if (next_tag.length) next_tag.click().find('input').caret(0);
|
||||
else if ($t.val()) ed.click();
|
||||
return false;
|
||||
}
|
||||
// tab key
|
||||
else if (e.which == 9) {
|
||||
// shift+tab
|
||||
if (e.shiftKey) {
|
||||
var prev_tag = $t.closest('li').prev('li').find('.tag-editor-tag');
|
||||
if (prev_tag.length) prev_tag.click().find('input').caret(0);
|
||||
else if ($t.val() && !(o.maxTags && ed.data('tags').length >= o.maxTags)) $(new_tag).insertBefore($t.closest('li')).find('.tag-editor-tag').click();
|
||||
// allow tabbing to previous element
|
||||
else {
|
||||
el.attr('disabled', 'disabled');
|
||||
setTimeout(function(){ el.removeAttr('disabled'); }, 30);
|
||||
return;
|
||||
}
|
||||
return false;
|
||||
// tab
|
||||
} else {
|
||||
var next_tag = $t.closest('li').next('li').find('.tag-editor-tag');
|
||||
if (next_tag.length) next_tag.click().find('input').caret(0);
|
||||
else if ($t.val()) ed.click();
|
||||
else return; // allow tabbing to next element
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// del key
|
||||
else if (e.which == 46 && (!$.trim($t.val()) || ($t.caret() == $t.val().length))) {
|
||||
var next_tag = $t.closest('li').next('li').find('.tag-editor-tag');
|
||||
if (next_tag.length) next_tag.click().find('input').caret(0);
|
||||
else if ($t.val()) ed.click();
|
||||
return false;
|
||||
}
|
||||
// enter key
|
||||
else if (e.which == 13) {
|
||||
ed.trigger('click', [$t.closest('li').next('li').find('.tag-editor-tag')]);
|
||||
|
||||
// trigger blur if maxTags limit is reached
|
||||
if (o.maxTags && ed.data('tags').length >= o.maxTags) ed.find('input').blur();
|
||||
|
||||
return false;
|
||||
}
|
||||
// pos1
|
||||
else if (e.which == 36 && !$t.caret()) ed.find('.tag-editor-tag').first().click();
|
||||
// end
|
||||
else if (e.which == 35 && $t.caret() == $t.val().length) ed.find('.tag-editor-tag').last().click();
|
||||
// esc
|
||||
else if (e.which == 27) {
|
||||
$t.val($t.data('old_tag') ? $t.data('old_tag') : '').blur();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// create initial tags
|
||||
var tags = o.initialTags.length ? o.initialTags : el.val().split(o.dregex);
|
||||
for (var i=0; i<tags.length; i++) {
|
||||
if (o.maxTags && i >= o.maxTags) break;
|
||||
var tag = $.trim(tags[i].replace(/ +/, ' '));
|
||||
if (tag) {
|
||||
if (o.forceLowercase) tag = tag.toLowerCase();
|
||||
tag_list.push(tag);
|
||||
ed.append('<li><div class="tag-editor-spacer"> '+o.delimiter[0]+'</div><div class="tag-editor-tag">'+escape(tag)+'</div><div class="tag-editor-delete"><i></i></div></li>');
|
||||
}
|
||||
}
|
||||
update_globals(true); // true -> no onChange callback
|
||||
|
||||
// init sortable
|
||||
if (o.sortable && $.fn.sortable) ed.sortable({
|
||||
distance: 5, cancel: '.tag-editor-spacer, input', helper: 'clone',
|
||||
update: function(){ update_globals(); }
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.tagEditor.defaults = {
|
||||
initialTags: [],
|
||||
maxTags: 0,
|
||||
maxLength: 50,
|
||||
delimiter: ',;',
|
||||
placeholder: '',
|
||||
forceLowercase: true,
|
||||
removeDuplicates: true,
|
||||
clickDelete: false,
|
||||
animateDelete: 175,
|
||||
sortable: true, // jQuery UI sortable
|
||||
autocomplete: null, // options dict for jQuery UI autocomplete
|
||||
|
||||
// callbacks
|
||||
onChange: function(){},
|
||||
beforeTagSave: function(){},
|
||||
beforeTagDelete: function(){}
|
||||
};
|
||||
}(jQuery));
|
File diff suppressed because one or more lines are too long
|
@ -103,6 +103,7 @@ $(document).ready(function() {
|
|||
url:
|
||||
"https://pandorafms.com/library/wp-json/wp/v2/categories?per_page=100",
|
||||
type: "GET",
|
||||
cache: false,
|
||||
crossDomain: true,
|
||||
contentType: "application/json",
|
||||
success: function(data) {
|
||||
|
@ -136,6 +137,7 @@ $(document).ready(function() {
|
|||
url:
|
||||
api_url + search_modules + "&orderby=modified&per_page=9&page=" + page,
|
||||
type: "GET",
|
||||
cache: false,
|
||||
crossDomain: true,
|
||||
contentType: "application/json",
|
||||
beforeSend: function(xhr) {
|
||||
|
@ -238,6 +240,7 @@ function library_main() {
|
|||
$.ajax({
|
||||
url: "https://pandorafms.com/library/wp-json/wp/v2/pages/121",
|
||||
type: "GET",
|
||||
cache: false,
|
||||
crossDomain: true,
|
||||
contentType: "application/json",
|
||||
beforeSend: function(xhr) {
|
||||
|
@ -313,6 +316,7 @@ function get_category(id) {
|
|||
$.ajax({
|
||||
url: "https://pandorafms.com/library/wp-json/wp/v2/categories/" + id,
|
||||
type: "GET",
|
||||
cache: false,
|
||||
contentType: "application/json",
|
||||
success: function(response) {
|
||||
$("#category_title_result h2").append(
|
||||
|
|
|
@ -837,8 +837,8 @@ function post_process_select_events(name) {
|
|||
*/
|
||||
function period_select_init(name, allow_zero) {
|
||||
// Manual mode is hidden by default
|
||||
$("#" + name + "_manual").hide();
|
||||
$("#" + name + "_default").show();
|
||||
$("#" + name + "_manual").css("display", "none");
|
||||
$("#" + name + "_default").css("display", "flex");
|
||||
|
||||
// If the text input is empty, we put on it 5 minutes by default
|
||||
if ($("#text-" + name + "_text").val() == "") {
|
||||
|
@ -852,8 +852,8 @@ function period_select_init(name, allow_zero) {
|
|||
}
|
||||
} else if ($("#text-" + name + "_text").val() == 0 && allow_zero != true) {
|
||||
$("#" + name + "_units option:last").prop("selected", false);
|
||||
$("#" + name + "_manual").show();
|
||||
$("#" + name + "_default").hide();
|
||||
$("#" + name + "_manual").css("display", "flex");
|
||||
$("#" + name + "_default").css("display", "none");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -941,13 +941,13 @@ function selectFirst(name) {
|
|||
*/
|
||||
function toggleBoth(name) {
|
||||
if ($("#" + name + "_default").css("display") == "none") {
|
||||
$("#" + name + "_default").css("display", "inline");
|
||||
$("#" + name + "_default").css("display", "flex");
|
||||
} else {
|
||||
$("#" + name + "_default").css("display", "none");
|
||||
}
|
||||
|
||||
if ($("#" + name + "_manual").css("display") == "none") {
|
||||
$("#" + name + "_manual").css("display", "inline");
|
||||
$("#" + name + "_manual").css("display", "flex");
|
||||
} else {
|
||||
$("#" + name + "_manual").css("display", "none");
|
||||
}
|
||||
|
|
|
@ -244,8 +244,19 @@ function initialiceLayout(data) {
|
|||
}
|
||||
|
||||
$("#delete-widget-" + id).click(function(event) {
|
||||
var nodo = event.target.offsetParent;
|
||||
deleteCell(id, nodo.parentNode);
|
||||
// eslint-disable-next-line no-undef
|
||||
confirmDialog({
|
||||
title: "Are you sure?",
|
||||
message:
|
||||
"<h4 style='text-align: center;padding-top: 20px;'>All changes made to this widget will be lost</h4>",
|
||||
cancel: "Cancel",
|
||||
ok: "Ok",
|
||||
onAccept: function() {
|
||||
// Continue execution.
|
||||
var nodo = event.target.offsetParent;
|
||||
deleteCell(id, nodo.parentNode);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#configure-widget-" + id).click(function() {
|
||||
|
|
|
@ -118,30 +118,26 @@ function execute_response(event_id, server_id) {
|
|||
}
|
||||
|
||||
response["target"] = get_response_target(event_id, response_id, server_id);
|
||||
response["event_id"] = event_id;
|
||||
response["server_id"] = server_id;
|
||||
|
||||
switch (response["type"]) {
|
||||
case "command":
|
||||
show_response_dialog(event_id, response_id, response);
|
||||
break;
|
||||
case "url":
|
||||
if (response["new_window"] == 1) {
|
||||
window.open(response["target"], "_blank");
|
||||
} else {
|
||||
show_response_dialog(event_id, response_id, response);
|
||||
}
|
||||
break;
|
||||
if (response["type"] == "url" && response["new_window"] == 1) {
|
||||
window.open(response["target"], "_blank");
|
||||
} else {
|
||||
show_response_dialog(response_id, response);
|
||||
}
|
||||
}
|
||||
|
||||
//Show the modal window of an event response
|
||||
function show_response_dialog(event_id, response_id, response) {
|
||||
function show_response_dialog(response_id, response) {
|
||||
var params = [];
|
||||
params.push("page=include/ajax/events");
|
||||
params.push("dialogue_event_response=1");
|
||||
params.push("massive=0");
|
||||
params.push("event_id=" + event_id);
|
||||
params.push("event_id=" + response["event_id"]);
|
||||
params.push("target=" + response["target"]);
|
||||
params.push("response_id=" + response_id);
|
||||
params.push("server_id=" + response["server_id"]);
|
||||
|
||||
jQuery.ajax({
|
||||
data: params.join("&"),
|
||||
|
@ -159,7 +155,7 @@ function show_response_dialog(event_id, response_id, response) {
|
|||
draggable: true,
|
||||
modal: false,
|
||||
open: function() {
|
||||
perform_response(response["target"], response_id);
|
||||
perform_response(response, response_id);
|
||||
},
|
||||
width: response["modal_width"],
|
||||
height: response["modal_height"]
|
||||
|
@ -171,7 +167,6 @@ function show_response_dialog(event_id, response_id, response) {
|
|||
|
||||
//Show the modal window of event responses when multiple events are selected
|
||||
function show_massive_response_dialog(
|
||||
event_id,
|
||||
response_id,
|
||||
response,
|
||||
out_iterator,
|
||||
|
@ -183,13 +178,14 @@ function show_massive_response_dialog(
|
|||
params.push("massive=1");
|
||||
params.push("end=" + end);
|
||||
params.push("out_iterator=" + out_iterator);
|
||||
params.push("event_id=" + event_id);
|
||||
params.push("event_id=" + response["event_id"]);
|
||||
params.push("target=" + response["target"]);
|
||||
params.push("response_id=" + response_id);
|
||||
params.push("server_id=" + response["server_id"]);
|
||||
|
||||
jQuery.ajax({
|
||||
data: params.join("&"),
|
||||
response_tg: response["target"],
|
||||
response_tg: response,
|
||||
response_id: response_id,
|
||||
out_iterator: out_iterator,
|
||||
type: "POST",
|
||||
|
@ -384,7 +380,7 @@ function get_response_target(
|
|||
}
|
||||
|
||||
// Perform a response and put the output into a div
|
||||
function perform_response(target, response_id) {
|
||||
function perform_response(response, response_id) {
|
||||
$("#re_exec_command").hide();
|
||||
$("#response_loading_command").show();
|
||||
$("#response_out").html("");
|
||||
|
@ -392,8 +388,10 @@ function perform_response(target, response_id) {
|
|||
var params = [];
|
||||
params.push("page=include/ajax/events");
|
||||
params.push("perform_event_response=1");
|
||||
params.push("target=" + target);
|
||||
params.push("target=" + response["target"]);
|
||||
params.push("response_id=" + response_id);
|
||||
params.push("event_id=" + response["event_id"]);
|
||||
params.push("server_id=" + response["server_id"]);
|
||||
|
||||
jQuery.ajax({
|
||||
data: params.join("&"),
|
||||
|
@ -413,7 +411,7 @@ function perform_response(target, response_id) {
|
|||
}
|
||||
|
||||
// Perform a response and put the output into a div
|
||||
function perform_response_massive(target, response_id, out_iterator) {
|
||||
function perform_response_massive(response, response_id, out_iterator) {
|
||||
$("#re_exec_command").hide();
|
||||
$("#response_loading_command_" + out_iterator).show();
|
||||
$("#response_out_" + out_iterator).html("");
|
||||
|
@ -421,8 +419,10 @@ function perform_response_massive(target, response_id, out_iterator) {
|
|||
var params = [];
|
||||
params.push("page=include/ajax/events");
|
||||
params.push("perform_event_response=1");
|
||||
params.push("target=" + target);
|
||||
params.push("target=" + response["target"]);
|
||||
params.push("response_id=" + response_id);
|
||||
params.push("event_id=" + response["event_id"]);
|
||||
params.push("server_id=" + response["server_id"]);
|
||||
|
||||
jQuery.ajax({
|
||||
data: params.join("&"),
|
||||
|
@ -916,17 +916,24 @@ function check_massive_response_event(
|
|||
|
||||
$(".chk_val:checked").each(function() {
|
||||
var event_id = $(this).val();
|
||||
var server_id = $("#hidden-server_id_" + event_id).val();
|
||||
var meta = $("#hidden-meta").val();
|
||||
var server_id = 0;
|
||||
if (meta) {
|
||||
server_id = $("#hidden-server_id_" + event_id).val();
|
||||
}
|
||||
|
||||
response["target"] = get_response_target(
|
||||
event_id,
|
||||
response_id,
|
||||
server_id,
|
||||
response_command
|
||||
);
|
||||
response["server_id"] = server_id;
|
||||
response["event_id"] = event_id;
|
||||
|
||||
if (total_checked - 1 === counter) end = 1;
|
||||
|
||||
show_massive_response_dialog(event_id, response_id, response, counter, end);
|
||||
show_massive_response_dialog(response_id, response, counter, end);
|
||||
|
||||
counter++;
|
||||
});
|
||||
|
|
|
@ -22,7 +22,7 @@ function progress_task_list(id, title) {
|
|||
autoOpen: false,
|
||||
modal: false,
|
||||
resizable: false,
|
||||
draggable: false,
|
||||
draggable: true,
|
||||
closeOnEscape: true,
|
||||
width: 800,
|
||||
height: 600,
|
||||
|
@ -35,19 +35,23 @@ function progress_task_list(id, title) {
|
|||
// Function var.
|
||||
var handleFetchTaskList = function(err, data) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
}
|
||||
if (data.error) {
|
||||
// TODO: Show info about the problem.
|
||||
$elem.html(data.error);
|
||||
} else {
|
||||
$elem.html(data.html);
|
||||
}
|
||||
|
||||
$elem.html(data.html);
|
||||
if (!$elem.dialog("isOpen")) $elem.dialog("open");
|
||||
|
||||
if (data.status != -1) {
|
||||
timeoutRef = setTimeout(function() {
|
||||
xhr = fetchTaskList(id, handleFetchTaskList);
|
||||
}, 3000);
|
||||
}
|
||||
};
|
||||
|
||||
if (!$elem.dialog("isOpen"))
|
||||
timeoutRef = setInterval(function() {
|
||||
xhr = fetchTaskList(id, handleFetchTaskList);
|
||||
}, 3000);
|
||||
|
||||
xhr = fetchTaskList(id, handleFetchTaskList);
|
||||
}
|
||||
|
||||
|
@ -60,12 +64,13 @@ function progress_task_list(id, title) {
|
|||
function fetchTaskList(id, callback) {
|
||||
return jQuery.ajax({
|
||||
data: {
|
||||
page: "include/ajax/task_list.ajax",
|
||||
progress_task_discovery: 1,
|
||||
page: "godmode/servers/discovery",
|
||||
wiz: "tasklist",
|
||||
method: "progressTaskDiscovery",
|
||||
id: id
|
||||
},
|
||||
type: "POST",
|
||||
url: "ajax.php",
|
||||
url: $("#ajax-url").val(),
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
callback(null, data);
|
||||
|
@ -95,12 +100,13 @@ function show_map(id, name) {
|
|||
|
||||
jQuery.ajax({
|
||||
data: {
|
||||
page: "include/ajax/task_list.ajax",
|
||||
showmap: 1,
|
||||
page: "godmode/servers/discovery",
|
||||
wiz: "tasklist",
|
||||
method: "taskShowmap",
|
||||
id: id
|
||||
},
|
||||
type: "POST",
|
||||
url: "ajax.php",
|
||||
url: $("#ajax-url").val(),
|
||||
dataType: "html",
|
||||
success: function(data) {
|
||||
$("#map_task")
|
||||
|
@ -109,3 +115,106 @@ function show_map(id, name) {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
function show_review(id, name) {
|
||||
load_modal({
|
||||
target: $("#task_review"),
|
||||
form: "review",
|
||||
url: $("#ajax-url").val(),
|
||||
modal: {
|
||||
title: "Review " + name,
|
||||
ok: "OK",
|
||||
cancel: "Cancel"
|
||||
},
|
||||
ajax_callback: function(data) {
|
||||
var title = $("#success-str").val();
|
||||
var text = "";
|
||||
var failed = 0;
|
||||
try {
|
||||
data = JSON.parse(data);
|
||||
text = data["result"];
|
||||
} catch (err) {
|
||||
title = $("#failed-str").val();
|
||||
text = err.message;
|
||||
failed = 1;
|
||||
}
|
||||
if (!failed && data["error"] != undefined) {
|
||||
title = $("#failed-str").val();
|
||||
text = data["error"];
|
||||
failed = 1;
|
||||
}
|
||||
if (data["report"] != undefined) {
|
||||
data["report"].forEach(function(item) {
|
||||
text += "<br>" + item;
|
||||
});
|
||||
}
|
||||
|
||||
$("#msg").empty();
|
||||
$("#msg").html(text);
|
||||
$("#msg").dialog({
|
||||
width: 450,
|
||||
position: {
|
||||
my: "center",
|
||||
at: "center",
|
||||
of: window,
|
||||
collision: "fit"
|
||||
},
|
||||
maxHeight: 400,
|
||||
title: title,
|
||||
buttons: [
|
||||
{
|
||||
class:
|
||||
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
|
||||
text: "OK",
|
||||
click: function(e) {
|
||||
if (!failed) {
|
||||
$(".ui-dialog-content").dialog("close");
|
||||
$("#task_review").empty();
|
||||
location.reload();
|
||||
} else {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
},
|
||||
extradata: [
|
||||
{
|
||||
name: "id",
|
||||
value: id
|
||||
},
|
||||
{
|
||||
name: "wiz",
|
||||
value: "tasklist"
|
||||
}
|
||||
],
|
||||
onshow: {
|
||||
page: "godmode/servers/discovery",
|
||||
method: "showTaskReview",
|
||||
maxHeight: 800
|
||||
},
|
||||
onsubmit: {
|
||||
page: "godmode/servers/discovery",
|
||||
method: "parseTaskReview"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function force_task_run(url) {
|
||||
window.location = url;
|
||||
}
|
||||
|
||||
function force_task(url, ask) {
|
||||
if (ask != undefined) {
|
||||
confirmDialog({
|
||||
title: ask.title,
|
||||
message: ask.message,
|
||||
onAccept: function() {
|
||||
force_task_run(url);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
force_task_run(url);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -319,6 +319,21 @@ function load_modal(settings) {
|
|||
contentType: false,
|
||||
data: data,
|
||||
success: function(data) {
|
||||
if (settings.onshow.parser) {
|
||||
data = settings.onshow.parser(data);
|
||||
} else {
|
||||
data = (function(d) {
|
||||
try {
|
||||
d = JSON.parse(d);
|
||||
} catch (e) {
|
||||
// Not JSON
|
||||
return d;
|
||||
}
|
||||
if (d.error) return d.error;
|
||||
|
||||
if (d.result) return d.result;
|
||||
})(data);
|
||||
}
|
||||
settings.target.html(data);
|
||||
if (settings.onload != undefined) {
|
||||
settings.onload(data);
|
||||
|
@ -338,6 +353,12 @@ function load_modal(settings) {
|
|||
? settings.onshow.maxHeight
|
||||
: "auto",
|
||||
overlay: settings.modal.overlay,
|
||||
position: {
|
||||
my: "top+20%",
|
||||
at: "top",
|
||||
of: window,
|
||||
collision: "fit"
|
||||
},
|
||||
buttons: required_buttons,
|
||||
closeOnEscape: true,
|
||||
open: function() {
|
||||
|
@ -386,6 +407,7 @@ function confirmDialog(settings) {
|
|||
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel",
|
||||
click: function() {
|
||||
$(this).dialog("close");
|
||||
$(this).remove();
|
||||
if (typeof settings.onDeny == "function") settings.onDeny();
|
||||
}
|
||||
},
|
||||
|
@ -395,6 +417,7 @@ function confirmDialog(settings) {
|
|||
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
|
||||
click: function() {
|
||||
$(this).dialog("close");
|
||||
$(this).remove();
|
||||
if (typeof settings.onAccept == "function") settings.onAccept();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,441 @@
|
|||
/**
|
||||
* IMPORTANT. Official plugin does not allow string ids
|
||||
* This modificated one yes.
|
||||
*/
|
||||
!(function(e) {
|
||||
var t = {};
|
||||
function i(s) {
|
||||
if (t[s]) return t[s].exports;
|
||||
var n = (t[s] = { i: s, l: !1, exports: {} });
|
||||
return e[s].call(n.exports, n, n.exports, i), (n.l = !0), n.exports;
|
||||
}
|
||||
(i.m = e),
|
||||
(i.c = t),
|
||||
(i.d = function(e, t, s) {
|
||||
i.o(e, t) || Object.defineProperty(e, t, { enumerable: !0, get: s });
|
||||
}),
|
||||
(i.r = function(e) {
|
||||
"undefined" != typeof Symbol &&
|
||||
Symbol.toStringTag &&
|
||||
Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }),
|
||||
Object.defineProperty(e, "__esModule", { value: !0 });
|
||||
}),
|
||||
(i.t = function(e, t) {
|
||||
if ((1 & t && (e = i(e)), 8 & t)) return e;
|
||||
if (4 & t && "object" == typeof e && e && e.__esModule) return e;
|
||||
var s = Object.create(null);
|
||||
if (
|
||||
(i.r(s),
|
||||
Object.defineProperty(s, "default", { enumerable: !0, value: e }),
|
||||
2 & t && "string" != typeof e)
|
||||
)
|
||||
for (var n in e)
|
||||
i.d(
|
||||
s,
|
||||
n,
|
||||
function(t) {
|
||||
return e[t];
|
||||
}.bind(null, n)
|
||||
);
|
||||
return s;
|
||||
}),
|
||||
(i.n = function(e) {
|
||||
var t =
|
||||
e && e.__esModule
|
||||
? function() {
|
||||
return e.default;
|
||||
}
|
||||
: function() {
|
||||
return e;
|
||||
};
|
||||
return i.d(t, "a", t), t;
|
||||
}),
|
||||
(i.o = function(e, t) {
|
||||
return Object.prototype.hasOwnProperty.call(e, t);
|
||||
}),
|
||||
(i.p = ""),
|
||||
i((i.s = 0));
|
||||
})([
|
||||
function(e, t, i) {
|
||||
"use strict";
|
||||
i.r(t);
|
||||
i(1);
|
||||
!(function(e, t) {
|
||||
if (!e || !e.document) throw new Error("simTree need window");
|
||||
!(function(e) {
|
||||
var t,
|
||||
i = e.document,
|
||||
s = {
|
||||
linkParent: !1,
|
||||
response: {
|
||||
name: "name",
|
||||
id: "id",
|
||||
pid: "pid",
|
||||
checked: "checked",
|
||||
open: "open",
|
||||
disabled: "disabled"
|
||||
}
|
||||
},
|
||||
n = function(e) {
|
||||
throw new Error(e);
|
||||
},
|
||||
a = function(e, t) {
|
||||
return e.replace(/\{\{(.+?)\}\}/g, function(e, i) {
|
||||
return t[i] ? t[i] : "";
|
||||
});
|
||||
},
|
||||
r = function e(t) {
|
||||
if (
|
||||
("undefined" == typeof $ && n("simTreeneed jquery"),
|
||||
$.isPlainObject(t))
|
||||
) {
|
||||
if ((t.el || n("你没有传el"), !(this instanceof e)))
|
||||
return new e(t);
|
||||
(this.options = $.extend(!0, {}, s, t)), this.init();
|
||||
}
|
||||
},
|
||||
d = [],
|
||||
o = [];
|
||||
(r.prototype = {
|
||||
version: "0.0.2",
|
||||
constructor: r,
|
||||
on: function(e, t, i) {
|
||||
var s, n;
|
||||
return (
|
||||
(this.handles[e] = this.handles[e] || []),
|
||||
(s = this.handles[e].isTriggered),
|
||||
(n = this.handles[e].args),
|
||||
$.isFunction(t) &&
|
||||
(!0 === i ? (this.handles[e] = [t]) : this.handles[e].push(t),
|
||||
s && t.call(this, n)),
|
||||
this
|
||||
);
|
||||
},
|
||||
off: function(e) {
|
||||
return (this.handles[e] = []), this;
|
||||
},
|
||||
trigger: function(e, t) {
|
||||
var i, s;
|
||||
for (
|
||||
this.handles[e] = this.handles[e] || [],
|
||||
i = 0,
|
||||
s = this.handles[e].length,
|
||||
this.handles[e].isTriggered = !0,
|
||||
this.handles[e].args = t;
|
||||
i < s;
|
||||
i++
|
||||
)
|
||||
this.handles[e][i].call(this, t);
|
||||
},
|
||||
init: function() {
|
||||
var e = this.options,
|
||||
t = e.data;
|
||||
(this.handles = {}),
|
||||
(this.$el = $(e.el)),
|
||||
(this.data = t),
|
||||
this.event(),
|
||||
this.render();
|
||||
},
|
||||
dataCallback: function() {
|
||||
var e = arguments;
|
||||
1 === e.length ? this.render(e[0]) : this.doRender(e[0], e[1]);
|
||||
},
|
||||
parse: function(e) {
|
||||
var t = this.options,
|
||||
i = t.response,
|
||||
s = [],
|
||||
n = {},
|
||||
a = 0,
|
||||
r = e.length,
|
||||
d = i.id,
|
||||
o = i.pid;
|
||||
if (t.childNodeAsy) return e;
|
||||
for (; a < r; a++) {
|
||||
var h = e[a],
|
||||
c = h[d];
|
||||
if (h.children) return e;
|
||||
c && (n[c] = h);
|
||||
}
|
||||
for (a = 0; a < r; a++) {
|
||||
var h = e[a],
|
||||
l = h[o],
|
||||
u = n[l];
|
||||
l && u ? (u.children || (u.children = [])).push(h) : s.push(h);
|
||||
}
|
||||
return s;
|
||||
},
|
||||
render: function(e) {
|
||||
var e = e || this.data;
|
||||
$.isFunction(e) && e({}, this.dataCallback.bind(this)),
|
||||
$.isArray(e) && ((e = this.parse(e)), this.doRender(this.$el, e));
|
||||
},
|
||||
doRender: function(e, t, s) {
|
||||
var n,
|
||||
r,
|
||||
h,
|
||||
c,
|
||||
l,
|
||||
u = this,
|
||||
f = this.options,
|
||||
p = f.response,
|
||||
m = t.length,
|
||||
g = 0,
|
||||
v = p.id,
|
||||
k = p.name,
|
||||
s = s || 1,
|
||||
C =
|
||||
'<i data-type="{{asy}}" class="sim-tree-spread {{spreadIcon}}"></i><a href="javascript:;"><i class="sim-tree-checkbox"></i>{{text}}</a>',
|
||||
b = e === this.$el,
|
||||
y = $(i.createElement("ul")),
|
||||
w = f.childNodeAsy ? "asy" : "";
|
||||
for (
|
||||
f.check ||
|
||||
(C = C.replace('<i class="sim-tree-checkbox"></i>', ""));
|
||||
g < m;
|
||||
g++
|
||||
)
|
||||
(n = t[g]),
|
||||
(r = i.createElement("li")),
|
||||
(c = !!n.children),
|
||||
(l = n[p.disabled]),
|
||||
(r.innerHTML = a(C, {
|
||||
asy: w,
|
||||
text: n[k],
|
||||
spreadIcon: c ? "sim-icon-r" : "hidden"
|
||||
})),
|
||||
r.setAttribute("data-level", s),
|
||||
r.setAttribute("data-id", n[v]),
|
||||
l && r.setAttribute("class", "disabled"),
|
||||
(h = $(r)).data("data", n),
|
||||
y.append(h),
|
||||
c && this.doRender(h, n.children, s + 1),
|
||||
n[p.checked] && d.push(n[v]),
|
||||
n[p.open] && o.push(n[v]);
|
||||
m && e.append(y),
|
||||
b
|
||||
? (y.addClass("sim-tree"),
|
||||
this.trigger("done", t),
|
||||
$.each(o, function(e, t) {
|
||||
u.expandNode(t);
|
||||
}),
|
||||
this.setSelected(d))
|
||||
: f.childNodeAsy &&
|
||||
(this.hideLoading(e.find(".sim-tree-spread")),
|
||||
y.addClass("show"));
|
||||
},
|
||||
event: function() {
|
||||
var e = this;
|
||||
this.$el.off("click").on("click", function(t) {
|
||||
var i = $(t.target);
|
||||
return (
|
||||
i.hasClass("sim-tree-spread") && e.spread.call(e, i),
|
||||
i.hasClass("sim-tree-checkbox") && (i = i.parent()),
|
||||
"a" === i[0].tagName.toLowerCase() && e.clickNode.call(e, i),
|
||||
!1
|
||||
);
|
||||
}),
|
||||
this.$el.on("selectstart", function() {
|
||||
return !1;
|
||||
}),
|
||||
this.options.done && this.on("done", this.options.done),
|
||||
this.options.onClick && this.on("click", this.options.onClick),
|
||||
this.options.onChange && this.on("change", this.options.onChange),
|
||||
this.options.onSearch && this.on("search", this.options.onSearch);
|
||||
},
|
||||
spread: function(e) {
|
||||
e.hasClass("sim-icon-r")
|
||||
? this.doSpread(e, !0)
|
||||
: this.doSpread(e, !1);
|
||||
},
|
||||
showLoading: function(e) {
|
||||
e.addClass("sim-loading");
|
||||
},
|
||||
hideLoading: function(e) {
|
||||
e.removeClass("sim-loading");
|
||||
},
|
||||
doSpread: function(e, t) {
|
||||
var i = e.parent(),
|
||||
s = i.children("ul"),
|
||||
n = i.data("data");
|
||||
n.children &&
|
||||
(t
|
||||
? (e.removeClass("sim-icon-r").addClass("sim-icon-d"),
|
||||
"asy" === e.data("type") &&
|
||||
$.isFunction(this.data) &&
|
||||
(this.showLoading(e),
|
||||
this.data(i.data("data"), this.dataCallback.bind(this, i)),
|
||||
e.data("type", "")),
|
||||
s.addClass("show"))
|
||||
: (e.removeClass("sim-icon-d").addClass("sim-icon-r"),
|
||||
s.removeClass("show")));
|
||||
},
|
||||
clickNode: function(e) {
|
||||
var i,
|
||||
s,
|
||||
n,
|
||||
a = this,
|
||||
r = e.parent(),
|
||||
d = this.$el.find("li"),
|
||||
o = d.length,
|
||||
h = 0,
|
||||
c = [],
|
||||
l = !1;
|
||||
if (!r.hasClass("disabled")) {
|
||||
if (this.options.check)
|
||||
for (
|
||||
l = !0,
|
||||
this.doCheck(e.find(".sim-tree-checkbox")),
|
||||
this.options.linkParent &&
|
||||
((s = r.children("ul")),
|
||||
(n = s.find(".sim-tree-checkbox")),
|
||||
$.each(n, function() {
|
||||
a.doCheck($(this), r.data("checked"), !0);
|
||||
}));
|
||||
h < o;
|
||||
h++
|
||||
)
|
||||
!0 === (i = d.eq(h).data()).checked && c.push(i.data);
|
||||
else
|
||||
t && t.css("font-weight", "normal"),
|
||||
e.css("font-weight", "bold"),
|
||||
(t = e),
|
||||
(i = r.data("data")),
|
||||
(c = [i]),
|
||||
(l = !this.sels || !(this.sels[0] === i));
|
||||
(this.sels = c),
|
||||
this.trigger("click", c),
|
||||
l && this.trigger("change", c);
|
||||
}
|
||||
},
|
||||
doCheck: function(e, t, i) {
|
||||
var s = e.closest("li"),
|
||||
n = s.data();
|
||||
void 0 === t && (t = !n.checked),
|
||||
!0 === t
|
||||
? e.removeClass("sim-tree-semi").addClass("checked")
|
||||
: !1 === t
|
||||
? e.removeClass("checked sim-tree-semi")
|
||||
: "semi" === t &&
|
||||
e.removeClass("checked").addClass("sim-tree-semi"),
|
||||
s.data("checked", t),
|
||||
!0 === this.options.linkParent && !i && this.setParentCheck(s);
|
||||
},
|
||||
setParentCheck: function(e) {
|
||||
var t,
|
||||
i = e.parent("ul"),
|
||||
s = i.parent("li"),
|
||||
n = i.children("li"),
|
||||
a = s.find(">a .sim-tree-checkbox"),
|
||||
r = [],
|
||||
d = n.length;
|
||||
s.length &&
|
||||
(e.find(">a .sim-tree-checkbox").hasClass("sim-tree-semi")
|
||||
? this.doCheck(a, "semi")
|
||||
: ($.each(n, function() {
|
||||
!0 === $(this).data("checked") && r.push($(this));
|
||||
}),
|
||||
(t = r.length),
|
||||
d === t && this.doCheck(a, !0),
|
||||
t || this.doCheck(a, !1),
|
||||
t >= 1 && t < d && this.doCheck(a, "semi")));
|
||||
},
|
||||
search: function(e) {
|
||||
if (this.$el) {
|
||||
var t,
|
||||
i,
|
||||
s,
|
||||
e = $.trim(e),
|
||||
n = this.$el.find("li"),
|
||||
a = 0,
|
||||
r = n.length,
|
||||
d = [],
|
||||
o = new RegExp(e, "i");
|
||||
for (
|
||||
n
|
||||
.hide()
|
||||
.children(".sim-tree-spread")
|
||||
.addClass("hidden");
|
||||
a < r;
|
||||
a++
|
||||
)
|
||||
(i = n.eq(a)),
|
||||
(t = i.children("a").text()),
|
||||
(s = i.data("data")),
|
||||
e
|
||||
? -1 !== t.search(o) &&
|
||||
(1 !== parseInt(i.data("level")) &&
|
||||
this.expandNode(s[this.options.response.pid]),
|
||||
i
|
||||
.parents("li")
|
||||
.add(i)
|
||||
.show(),
|
||||
d.push(i))
|
||||
: (i.show(),
|
||||
s.children &&
|
||||
i.children(".sim-tree-spread").removeClass("hidden"));
|
||||
this.trigger("search", e);
|
||||
}
|
||||
},
|
||||
expandNode: function(e) {
|
||||
var t = e.addClass ? e : this.$el.find("[data-id='" + e + "']"),
|
||||
i = t.data("data"),
|
||||
s = i[this.options.response.pid],
|
||||
n = t.children(".sim-tree-spread"),
|
||||
a = parseInt(t.data("level"));
|
||||
i.children &&
|
||||
n.length &&
|
||||
(n.removeClass("hidden"), this.doSpread(n, !0)),
|
||||
1 !== a && this.expandNode(s);
|
||||
},
|
||||
setSelected: function(e) {
|
||||
var t = this,
|
||||
i = e,
|
||||
s = [],
|
||||
n = [];
|
||||
("string" != typeof i && "number" != typeof i) || (i = [i]),
|
||||
$.isArray(i) &&
|
||||
(this.options.check || (i = [i[0]]),
|
||||
$.each(i, function(e, i) {
|
||||
var a = t.$el.find("[data-id='" + i + "']"),
|
||||
r = a.children("a"),
|
||||
d = r.children(".sim-tree-checkbox"),
|
||||
o = a.data("data");
|
||||
if (!a.length) return !0;
|
||||
d.length ? t.doCheck(d, !0) : r.css("font-weight", "bold"),
|
||||
1 !== parseInt(a.data("level")) &&
|
||||
t.expandNode(o[t.options.response.pid]),
|
||||
s.push(o),
|
||||
n.push(a[0]);
|
||||
}),
|
||||
(t.sels = s),
|
||||
t.trigger("click", s));
|
||||
},
|
||||
getSelected: function() {
|
||||
return this.sels;
|
||||
},
|
||||
disableNode: function(e) {
|
||||
var t = this,
|
||||
i = e;
|
||||
("string" != typeof i && "number" != typeof i) || (i = [i]),
|
||||
$.isArray(i) &&
|
||||
$.each(i, function(e, i) {
|
||||
var s = t.$el.find("[data-id='" + i + "']");
|
||||
s.addClass("disabled");
|
||||
});
|
||||
},
|
||||
destroy: function() {
|
||||
for (var e in (this.$el.html(""), this)) delete this[e];
|
||||
},
|
||||
refresh: function(e) {
|
||||
this.$el.html(""), this.render(e);
|
||||
}
|
||||
}),
|
||||
(e.simTree = r),
|
||||
($.fn.simTree = function(e) {
|
||||
return (e = $.extend(!0, { el: this }, e)), r(e);
|
||||
});
|
||||
})(e);
|
||||
})("undefined" != typeof window ? window : void 0);
|
||||
},
|
||||
function(e, t, i) {}
|
||||
]);
|
|
@ -20,7 +20,7 @@ var TreeController = {
|
|||
recipient: "",
|
||||
tree: [],
|
||||
emptyMessage: "No data found.",
|
||||
foundMessage: "Found groups",
|
||||
foundMessage: "Groups found",
|
||||
errorMessage: "Error",
|
||||
baseURL: "",
|
||||
ajaxURL: "ajax.php",
|
||||
|
@ -48,9 +48,15 @@ var TreeController = {
|
|||
.addClass("tree-root")
|
||||
.hide()
|
||||
.prepend(
|
||||
'<img src="' +
|
||||
'<div class="tree-node flex-row-vcenter">' +
|
||||
'<img src="' +
|
||||
(controller.baseURL.length > 0 ? controller.baseURL : "") +
|
||||
'images/pandora.png" />'
|
||||
'images/pandora.png" />' +
|
||||
"<span class='margin-left-1'>" +
|
||||
(controller.tree.length > 0
|
||||
? controller.foundMessage + ": " + controller.tree.length
|
||||
: "") +
|
||||
"</div>"
|
||||
);
|
||||
}
|
||||
// Normal group
|
||||
|
@ -315,7 +321,7 @@ var TreeController = {
|
|||
_processNodeCounterTitle($totalCounter, type, "total");
|
||||
|
||||
// Open the parentheses
|
||||
$counters.append(" (");
|
||||
$counters.append(" [ ");
|
||||
|
||||
$counters.append($totalCounter);
|
||||
|
||||
|
@ -409,7 +415,7 @@ var TreeController = {
|
|||
}
|
||||
|
||||
// Close the parentheses
|
||||
$counters.append(")");
|
||||
$counters.append(" ]");
|
||||
|
||||
hasCounters = true;
|
||||
}
|
||||
|
@ -541,6 +547,7 @@ var TreeController = {
|
|||
break;
|
||||
case "agent":
|
||||
// Is quiet
|
||||
|
||||
if (
|
||||
typeof element.quietImageHTML != "undefined" &&
|
||||
element.quietImageHTML.length > 0
|
||||
|
@ -560,16 +567,6 @@ var TreeController = {
|
|||
|
||||
$content.append($statusImage);
|
||||
}
|
||||
// Alerts fired image
|
||||
if (
|
||||
typeof element.alertImageHTML != "undefined" &&
|
||||
element.alertImageHTML.length > 0
|
||||
) {
|
||||
var $alertImage = $(element.alertImageHTML);
|
||||
$alertImage.addClass("agent-alerts-fired");
|
||||
|
||||
$content.append($alertImage);
|
||||
}
|
||||
|
||||
// Events by agent
|
||||
if (element.showEventsBtn == 1) {
|
||||
|
@ -690,6 +687,8 @@ var TreeController = {
|
|||
$content.append(" " + element.name);
|
||||
break;
|
||||
case "module":
|
||||
$content.addClass("module");
|
||||
|
||||
// Status image
|
||||
if (
|
||||
typeof element.statusImageHTML != "undefined" &&
|
||||
|
@ -700,17 +699,19 @@ var TreeController = {
|
|||
|
||||
$content.append($statusImage);
|
||||
}
|
||||
// Server type
|
||||
if (
|
||||
typeof element.serverTypeHTML != "undefined" &&
|
||||
element.serverTypeHTML.length > 0 &&
|
||||
element.serverTypeHTML != "--"
|
||||
) {
|
||||
var $serverTypeImage = $(element.serverTypeHTML);
|
||||
$serverTypeImage.addClass("module-server-type");
|
||||
|
||||
$content.append($serverTypeImage);
|
||||
}
|
||||
// Name max 42 chars.
|
||||
$content.append(
|
||||
'<span class="module-name">' +
|
||||
element.name.substring(0, 42) +
|
||||
(element.name.length > 42 ? "..." : "") +
|
||||
"</span>"
|
||||
);
|
||||
|
||||
// Value.
|
||||
$content.append(
|
||||
'<span class="module-value">' + element.value + "</span>"
|
||||
);
|
||||
|
||||
if (
|
||||
typeof element.showGraphs != "undefined" &&
|
||||
|
@ -832,7 +833,6 @@ var TreeController = {
|
|||
$content.append($alertsImage);
|
||||
}
|
||||
|
||||
$content.append(element.name);
|
||||
break;
|
||||
case "os":
|
||||
if (
|
||||
|
@ -1086,20 +1086,6 @@ var TreeController = {
|
|||
}
|
||||
|
||||
controller.recipient.empty();
|
||||
if (
|
||||
controller.tree.length !== undefined &&
|
||||
controller.foundMessage !== "not"
|
||||
) {
|
||||
controller.recipient.html(
|
||||
"<div> " +
|
||||
controller.foundMessage +
|
||||
": " +
|
||||
controller.tree.length +
|
||||
"</div>" +
|
||||
"<br/>"
|
||||
);
|
||||
}
|
||||
|
||||
var $children = _processGroup(this.recipient, this.tree, true);
|
||||
$children.show();
|
||||
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
function check_new_chats_icon(id_icon) {
|
||||
if (new_chat) {
|
||||
$("#" + id_icon).pulsate();
|
||||
}
|
||||
}
|
||||
|
||||
function check_new_chats_icon_ajax(id_icon) {
|
||||
var exit = false;
|
||||
|
||||
url_chunks = location.href.split("&");
|
||||
$.each(url_chunks, function(key, chunk) {
|
||||
if (chunk == "sec2=operation/users/webchat") exit = true;
|
||||
return;
|
||||
});
|
||||
|
||||
if (exit) {
|
||||
return;
|
||||
}
|
||||
|
||||
old = global_counter_chat;
|
||||
get_last_global_counter();
|
||||
|
||||
if (old < global_counter_chat) {
|
||||
$("#" + id_icon).pulsate();
|
||||
}
|
||||
|
||||
setTimeout('check_new_chats_icon("' + id_icon + '")', 5000);
|
||||
}
|
||||
|
||||
function get_last_global_counter() {
|
||||
var parameters = {};
|
||||
parameters["page"] = "operation/users/webchat";
|
||||
parameters["get_last_global_counter"] = 1;
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "ajax.php",
|
||||
data: parameters,
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(data) {
|
||||
if (data["correct"] == 1) {
|
||||
global_counter_chat = data["global_counter"];
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -1042,6 +1042,17 @@ class Manager
|
|||
$cellData['id_widget'] = $this->widgetId;
|
||||
}
|
||||
}
|
||||
|
||||
$instance = $this->instanceWidget();
|
||||
$cellData['options'] = $instance->decoders(
|
||||
$instance->getOptionsWidget()
|
||||
);
|
||||
|
||||
if (isset($cellData['options']['title']) === false) {
|
||||
$cellData['options']['title'] = $instance->getDescription();
|
||||
}
|
||||
|
||||
$cellData['options'] = json_encode($cellData['options']);
|
||||
}
|
||||
|
||||
View::render(
|
||||
|
|
|
@ -59,7 +59,7 @@ class Widget
|
|||
|
||||
$cellClass = new Cell($this->cellId, $this->dashboardId);
|
||||
$this->dataCell = $cellClass->get();
|
||||
$this->values = $this->getOptionsWidget();
|
||||
$this->values = $this->decoders($this->getOptionsWidget());
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
@ -535,6 +535,34 @@ class Widget
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Decoders hack for retrocompability.
|
||||
*
|
||||
* @param array $decoder Values.
|
||||
*
|
||||
* @return array Returns the values with the correct key.
|
||||
*/
|
||||
public function decoders(array $decoder):array
|
||||
{
|
||||
$values = [];
|
||||
|
||||
if (isset($decoder['title']) === true) {
|
||||
$values['title'] = $decoder['title'];
|
||||
}
|
||||
|
||||
if (isset($decoder['background-color']) === true) {
|
||||
$values['background'] = $decoder['background-color'];
|
||||
}
|
||||
|
||||
if (isset($decoder['background']) === true) {
|
||||
$values['background'] = $decoder['background'];
|
||||
}
|
||||
|
||||
return $values;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Size Cell.
|
||||
*
|
||||
|
|
|
@ -169,489 +169,11 @@ class AgentModuleWidget extends Widget
|
|||
|
||||
// This forces at least a first configuration.
|
||||
$this->configurationRequired = false;
|
||||
if (empty($this->values['moduleId']) === true) {
|
||||
$this->configurationRequired = true;
|
||||
}
|
||||
|
||||
$this->overflow_scrollbars = false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// DO NOT CHANGE THIS VALUE.
|
||||
$id_group = isset($this->options['search_group_'.$id]) ? $this->options['search_group_'.$id] : 0;
|
||||
|
||||
$agent_conf_key = 'id_agent_'.$id;
|
||||
$id_agent = $this->options[$agent_conf_key];
|
||||
$module_conf_key = 'id_module_'.$id;
|
||||
$id_module = $this->options[$module_conf_key];
|
||||
$recursion_checked = $this->options['recursion'];
|
||||
|
||||
$this->add_configuration(
|
||||
'search_group_'.$id,
|
||||
__('Group'),
|
||||
OPTION_TREE_GROUP_SELECT
|
||||
);
|
||||
|
||||
$list_agents = agents_get_group_agents(
|
||||
$id_group,
|
||||
false,
|
||||
'lower',
|
||||
false,
|
||||
$recursion_checked
|
||||
);
|
||||
|
||||
if (!isset($this->options['selection_agent_module_'.$id])
|
||||
|| $this->options['selection_agent_module_'.$id] == ''
|
||||
|| $this->options['selection_agent_module_'.$id] == null
|
||||
) {
|
||||
$selection_agent_module = 'common';
|
||||
} else {
|
||||
$selection_agent_module = $this->options['selection_agent_module_'.$id];
|
||||
}
|
||||
|
||||
$limit_common = '';
|
||||
$sql = false;
|
||||
if (!empty($id_agent)) {
|
||||
if ($selection_agent_module == 'common') {
|
||||
$limit_common = sprintf(
|
||||
' AND (SELECT count(nombre)
|
||||
FROM tagente_modulo t2
|
||||
WHERE t2.delete_pending = 0
|
||||
AND t1.nombre = t2.nombre
|
||||
AND t2.id_agente IN (%s)) = (%d)',
|
||||
implode(',', (array) $id_agent),
|
||||
count($id_agent)
|
||||
);
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
'SELECT DISTINCT nombre
|
||||
FROM tagente_modulo t1
|
||||
WHERE id_agente IN (%s)
|
||||
AND delete_pending = 0 %s ORDER BY nombre',
|
||||
implode(', ', (array) $id_agent),
|
||||
$limit_common
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($id_module)) {
|
||||
$this->options[$module_conf_key] = index_array(
|
||||
db_get_all_rows_sql($sql),
|
||||
'nombre',
|
||||
'nombre'
|
||||
);
|
||||
}
|
||||
|
||||
$this->add_configuration(
|
||||
'recursion',
|
||||
__('Recursion'),
|
||||
OPTION_BOOLEAN
|
||||
);
|
||||
|
||||
$this->add_configuration(
|
||||
$agent_conf_key,
|
||||
__('Agent'),
|
||||
OPTION_SELECT_MULTISELECTION,
|
||||
['values' => $list_agents]
|
||||
);
|
||||
|
||||
$this->add_configuration(
|
||||
'selection_agent_module_'.$id,
|
||||
__('Show common modules'),
|
||||
OPTION_SINGLE_SELECT,
|
||||
[
|
||||
'values' => [
|
||||
'common' => __('Show common modules'),
|
||||
'all' => __('Show all modules'),
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_configuration(
|
||||
$module_conf_key,
|
||||
__('Module'),
|
||||
OPTION_SELECT_MULTISELECTION,
|
||||
[
|
||||
'values' => index_array(
|
||||
db_get_all_rows_sql($sql),
|
||||
'nombre',
|
||||
'nombre'
|
||||
),
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_configuration(
|
||||
'',
|
||||
'',
|
||||
OPTION_CUSTOM_INPUT,
|
||||
[
|
||||
'widget' => $this,
|
||||
'entire_row' => true,
|
||||
'update' => false,
|
||||
]
|
||||
);
|
||||
*/
|
||||
|
||||
|
||||
function print_configuration_custom($return=true)
|
||||
{
|
||||
$id = $this->getId();
|
||||
ob_start();
|
||||
|
||||
?>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
recalculate_modules_select_agent_module(
|
||||
$("#selection_agent_module_<?php echo $id; ?>").val()
|
||||
);
|
||||
|
||||
function recalculate_modules_select_agent_module (selection_mode) {
|
||||
var idAgents = Array();
|
||||
jQuery.each ($('#id_agent_<?php echo $id; ?> option:selected'), function (i, val) {
|
||||
idAgents.push($(val).val());
|
||||
});
|
||||
jQuery.post ('ajax.php',
|
||||
{"page": "operation/agentes/ver_agente",
|
||||
"get_modules_group_value_name_json": 1,
|
||||
"selection": selection_mode == 'all' ? 1 : 0,
|
||||
"id_agents[]": idAgents
|
||||
},
|
||||
function (data, status) {
|
||||
$('#id_module_<?php echo $id; ?>').empty ();
|
||||
if (data) {
|
||||
jQuery.each (data, function (id, value) {
|
||||
$('#id_module_<?php echo $id; ?>')
|
||||
.append ($('<option></option>')
|
||||
.html(value)
|
||||
.prop("value", value)
|
||||
.prop("selected", 'selected'));
|
||||
});
|
||||
}
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
$('#search_group_<?php echo $id; ?>').on('change',function() {
|
||||
jQuery.post ("ajax.php",
|
||||
{
|
||||
"page" : "operation/agentes/ver_agente",
|
||||
"get_agents_group_json" : 1,
|
||||
"id_group" : this.value,
|
||||
"recursion" : ($('#checkbox-recursion-<?php echo $id; ?>').is(':checked')) ? 1 : 0
|
||||
},
|
||||
function (data, status) {
|
||||
$('#id_agent_<?php echo $id; ?>').html('');
|
||||
jQuery.each (data, function(id, value) {
|
||||
// Remove keys_prefix from the index.
|
||||
option = $("<option></option>")
|
||||
.prop("value", id)
|
||||
.prop("selected", 'selected')
|
||||
.html(value);
|
||||
$('#id_agent_<?php echo $id; ?>').append (option);
|
||||
});
|
||||
|
||||
recalculate_modules_select_agent_module(
|
||||
$("#selection_agent_module_<?php echo $id; ?>").val()
|
||||
);
|
||||
},
|
||||
"json"
|
||||
);
|
||||
});
|
||||
|
||||
$('#checkbox-recursion-<?php echo $id; ?>').on('change', function() {
|
||||
($('#hidden-recursion_sent').val() === '1') ? $('#hidden-recursion_sent').val('0') : $('#hidden-recursion_sent').val('1');
|
||||
jQuery.post ("ajax.php",
|
||||
{
|
||||
"page" : "operation/agentes/ver_agente",
|
||||
"get_agents_group_json" : 1,
|
||||
"id_group" : $('#search_group_<?php echo $id; ?>').val(),
|
||||
"recursion" : ($('#checkbox-recursion-<?php echo $id; ?>').is(':checked')) ? 1 : 0
|
||||
},
|
||||
function (data, status) {
|
||||
$('#id_agent_<?php echo $id; ?>').html('');
|
||||
jQuery.each (data, function(id, value) {
|
||||
// Remove keys_prefix from the index.
|
||||
option = $("<option></option>")
|
||||
.prop("value", id)
|
||||
.prop("selected", 'selected')
|
||||
.html(value);
|
||||
$('#id_agent_<?php echo $id; ?>').append (option);
|
||||
});
|
||||
|
||||
recalculate_modules_select_agent_module(
|
||||
$("#selection_agent_module_<?php echo $id; ?>").val()
|
||||
);
|
||||
},
|
||||
"json"
|
||||
);
|
||||
});
|
||||
|
||||
$("#id_agent_<?php echo $id; ?>").on('change',function () {
|
||||
recalculate_modules_select_agent_module(
|
||||
$("#selection_agent_module_<?php echo $id; ?>").val()
|
||||
);
|
||||
});
|
||||
|
||||
$("#selection_agent_module_<?php echo $id; ?>").on('change',function(evt) {
|
||||
recalculate_modules_select_agent_module(
|
||||
$("#selection_agent_module_<?php echo $id; ?>").val()
|
||||
);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
|
||||
public function generate_data_agent_module($agents, $all_modules)
|
||||
{
|
||||
$return = [];
|
||||
$cont = 0;
|
||||
$name = '';
|
||||
|
||||
foreach ($all_modules as $key => $module) {
|
||||
if ($module == $name) {
|
||||
$modules_by_name[($cont - 1)]['id'][] = $key;
|
||||
} else {
|
||||
$name = $module;
|
||||
$modules_by_name[$cont]['name'] = $name;
|
||||
$modules_by_name[$cont]['id'][] = $key;
|
||||
$cont ++;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($agents as $agent) {
|
||||
if (!users_access_to_agent($agent['id_agente'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$row = [];
|
||||
$row['agent_status'] = agents_get_status($agent['id_agente'], true);
|
||||
$row['agent_name'] = $agent['nombre'];
|
||||
$row['agent_alias'] = $agent['alias'];
|
||||
$agent_modules = agents_get_modules($agent['id_agente']);
|
||||
|
||||
$row['modules'] = [];
|
||||
foreach ($modules_by_name as $module) {
|
||||
$row['modules'][$module['name']] = null;
|
||||
foreach ($module['id'] as $module_id) {
|
||||
if (array_key_exists($module_id, $agent_modules)) {
|
||||
$row['modules'][$module['name']] = modules_get_agentmodule_status($module_id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$return[] = $row;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
public function generate_view_agent_module($visual_data)
|
||||
{
|
||||
$table_data = '<div>';
|
||||
$table_data .= '<table class="widget_agent_module" cellpadding="1" cellspacing="0" border="0" style="background-color: #EEE;">';
|
||||
|
||||
if (!empty($visual_data)) {
|
||||
$table_data .= '<th>'.__('Agents').' / '.__('Modules').'</th>';
|
||||
|
||||
$array_names = [];
|
||||
|
||||
foreach ($visual_data as $data) {
|
||||
foreach ($data['modules'] as $module_name => $module) {
|
||||
if ($module === null || in_array($module_name, $array_names)) {
|
||||
continue;
|
||||
} else {
|
||||
$array_names[] = $module_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
natcasesort($array_names);
|
||||
foreach ($array_names as $module_name) {
|
||||
$file_name = ui_print_truncate_text(
|
||||
$module_name,
|
||||
'module_small',
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
'...'
|
||||
);
|
||||
$table_data .= '<th style="padding: 10px;">'.$file_name.'</th>';
|
||||
}
|
||||
|
||||
foreach ($visual_data as $row) {
|
||||
$table_data .= "<tr style='height: 35px;'>";
|
||||
switch ($row['agent_status']) {
|
||||
case AGENT_STATUS_ALERT_FIRED:
|
||||
$rowcolor = COL_ALERTFIRED;
|
||||
$textcolor = '#000';
|
||||
break;
|
||||
|
||||
case AGENT_STATUS_CRITICAL:
|
||||
$rowcolor = COL_CRITICAL;
|
||||
$textcolor = '#FFF';
|
||||
break;
|
||||
|
||||
case AGENT_STATUS_WARNING:
|
||||
$rowcolor = COL_WARNING;
|
||||
$textcolor = '#000';
|
||||
break;
|
||||
|
||||
case AGENT_STATUS_NORMAL:
|
||||
$rowcolor = COL_NORMAL;
|
||||
$textcolor = '#FFF';
|
||||
break;
|
||||
|
||||
case AGENT_STATUS_UNKNOWN:
|
||||
case AGENT_STATUS_ALL:
|
||||
default:
|
||||
$rowcolor = COL_UNKNOWN;
|
||||
$textcolor = '#FFF';
|
||||
break;
|
||||
}
|
||||
|
||||
$file_name = ui_print_truncate_text(
|
||||
$row['agent_alias'],
|
||||
'agent_small',
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
'...'
|
||||
);
|
||||
$table_data .= "<td style='background-color: ".$rowcolor.";'>".$file_name.'</td>';
|
||||
|
||||
foreach ($row['modules'] as $module_name => $module) {
|
||||
if ($module === null) {
|
||||
if (in_array($module_name, $array_names)) {
|
||||
$table_data .= "<td style='background-color: #DDD;'></td>";
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
$table_data .= "<td style='text-align: center; background-color: #DDD;'>";
|
||||
switch ($module) {
|
||||
case AGENT_STATUS_NORMAL:
|
||||
$table_data .= ui_print_status_image(
|
||||
'module_ok.png',
|
||||
__(
|
||||
'%s in %s : NORMAL',
|
||||
$module_name,
|
||||
$row['agent_alias']
|
||||
),
|
||||
true,
|
||||
[
|
||||
'width' => '20px',
|
||||
'height' => '20px',
|
||||
]
|
||||
);
|
||||
break;
|
||||
|
||||
case AGENT_STATUS_CRITICAL:
|
||||
$table_data .= ui_print_status_image(
|
||||
'module_critical.png',
|
||||
__(
|
||||
'%s in %s : CRITICAL',
|
||||
$module_name,
|
||||
$row['agent_alias']
|
||||
),
|
||||
true,
|
||||
[
|
||||
'width' => '20px',
|
||||
'height' => '20px',
|
||||
]
|
||||
);
|
||||
break;
|
||||
|
||||
case AGENT_STATUS_WARNING:
|
||||
$table_data .= ui_print_status_image(
|
||||
'module_warning.png',
|
||||
__(
|
||||
'%s in %s : WARNING',
|
||||
$module_name,
|
||||
$row['agent_alias']
|
||||
),
|
||||
true,
|
||||
[
|
||||
'width' => '20px',
|
||||
'height' => '20px',
|
||||
]
|
||||
);
|
||||
break;
|
||||
|
||||
case AGENT_STATUS_UNKNOWN:
|
||||
$table_data .= ui_print_status_image(
|
||||
'module_unknown.png',
|
||||
__(
|
||||
'%s in %s : UNKNOWN',
|
||||
$module_name,
|
||||
$row['agent_alias']
|
||||
),
|
||||
true,
|
||||
[
|
||||
'width' => '20px',
|
||||
'height' => '20px',
|
||||
]
|
||||
);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
$table_data .= ui_print_status_image(
|
||||
'module_no_data.png',
|
||||
__(
|
||||
'%s in %s : Not initialize',
|
||||
$module_name,
|
||||
$row['agent_alias']
|
||||
),
|
||||
true,
|
||||
[
|
||||
'width' => '20px',
|
||||
'height' => '20px',
|
||||
]
|
||||
);
|
||||
break;
|
||||
|
||||
case AGENT_STATUS_ALERT_FIRED:
|
||||
default:
|
||||
$table_data .= ui_print_status_image(
|
||||
'module_alertsfired.png',
|
||||
__(
|
||||
'%s in %s : ALERTS FIRED',
|
||||
$module_name,
|
||||
$row['agent_alias']
|
||||
),
|
||||
true,
|
||||
[
|
||||
'width' => '20px',
|
||||
'height' => '20px',
|
||||
]
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
$table_data .= '</td>';
|
||||
}
|
||||
}
|
||||
|
||||
$table_data .= '</tr>';
|
||||
}
|
||||
} else {
|
||||
$table_data .= '<tr><td>'.__('Please configure this widget before usage').'</td></tr>';
|
||||
}
|
||||
|
||||
$table_data .= '</table>';
|
||||
$table_data .= '</div>';
|
||||
|
||||
return $table_data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates inputs for form (specific).
|
||||
*
|
||||
|
@ -666,38 +188,12 @@ class AgentModuleWidget extends Widget
|
|||
// Retrieve global - common inputs.
|
||||
$inputs = parent::getFormInputs();
|
||||
|
||||
// Autocomplete agents.
|
||||
$inputs[] = [
|
||||
'label' => __('Agent'),
|
||||
'arguments' => [
|
||||
'type' => 'autocomplete_agent',
|
||||
'name' => 'agentAlias',
|
||||
'id_agent_hidden' => $values['agentId'],
|
||||
'name_agent_hidden' => 'agentId',
|
||||
'server_id_hidden' => $values['metaconsoleId'],
|
||||
'name_server_hidden' => 'metaconsoleId',
|
||||
'return' => true,
|
||||
'module_input' => true,
|
||||
'module_name' => 'moduleId',
|
||||
'module_none' => false,
|
||||
'size' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
// Autocomplete module.
|
||||
$inputs[] = [
|
||||
'label' => __('Module'),
|
||||
'arguments' => [
|
||||
'type' => 'autocomplete_module',
|
||||
'fields' => $fields,
|
||||
'name' => 'moduleId',
|
||||
'selected' => $values['moduleId'],
|
||||
'return' => true,
|
||||
'sort' => false,
|
||||
'agent_id' => $values['agentId'],
|
||||
'metaconsole_id' => $values['metaconsoleId'],
|
||||
'style' => 'width: inherit;',
|
||||
],
|
||||
'label' => \ui_print_error_message(
|
||||
__('This widget has been removed'),
|
||||
'',
|
||||
true
|
||||
),
|
||||
];
|
||||
|
||||
return $inputs;
|
||||
|
@ -714,12 +210,6 @@ class AgentModuleWidget extends Widget
|
|||
// Retrieve global - common inputs.
|
||||
$values = parent::getPost();
|
||||
|
||||
$values['agentId'] = \get_parameter('agentId', 0);
|
||||
$values['metaconsoleId'] = \get_parameter('metaconsoleId', 0);
|
||||
$values['moduleId'] = \get_parameter('moduleId', 0);
|
||||
$values['period'] = \get_parameter('period', 0);
|
||||
$values['showLegend'] = \get_parameter_switch('showLegend');
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
|
@ -733,45 +223,14 @@ class AgentModuleWidget extends Widget
|
|||
{
|
||||
global $config;
|
||||
|
||||
// TODO:XXX WIP.
|
||||
return 'WIP in this widget';
|
||||
/*
|
||||
$this->body = '';
|
||||
$id_agent = $this->options['id_agent_'.$this->getId()];
|
||||
if (! check_acl($config['id_user'], 0, 'AR')) {
|
||||
$this->body = __('You don\'t have access');
|
||||
return;
|
||||
}
|
||||
|
||||
$id_module = $this->options['id_module_'.$this->getId()];
|
||||
if ($id_agent) {
|
||||
$sql = 'SELECT id_agente,nombre,alias
|
||||
FROM tagente
|
||||
WHERE id_agente IN ('.implode(',', $id_agent).')
|
||||
ORDER BY id_agente';
|
||||
$agents = db_get_all_rows_sql($sql);
|
||||
if ($agents === false) {
|
||||
$agents = [];
|
||||
}
|
||||
|
||||
$sql = 'SELECT id_agente_modulo,nombre
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente IN ('.implode(',', $id_agent).")
|
||||
AND nombre IN ('".implode("','", $id_module)."')
|
||||
AND delete_pending = 0 ORDER BY nombre";
|
||||
$modules = index_array(db_get_all_rows_sql($sql), 'id_agente_modulo', 'nombre');
|
||||
if ($modules === false) {
|
||||
$modules = [];
|
||||
}
|
||||
} else {
|
||||
$agents = [];
|
||||
$modules = [];
|
||||
}
|
||||
|
||||
$visual_data = $this->generate_data_agent_module($agents, $modules);
|
||||
|
||||
$this->body .= $this->generate_view_agent_module($visual_data);
|
||||
*/
|
||||
$output .= '<div class="container-center">';
|
||||
$output .= \ui_print_error_message(
|
||||
__('This widget has been removed'),
|
||||
'',
|
||||
true
|
||||
);
|
||||
$output .= '</div>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ class AlertsFiredWidget extends Widget
|
|||
$this->gridWidth = $gridWidth;
|
||||
|
||||
// Options.
|
||||
$this->values = $this->getOptionsWidget();
|
||||
$this->values = $this->decoders($this->getOptionsWidget());
|
||||
|
||||
// Positions.
|
||||
$this->position = $this->getPositionWidget();
|
||||
|
@ -176,6 +176,31 @@ class AlertsFiredWidget extends Widget
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Decoders hack for retrocompability.
|
||||
*
|
||||
* @param array $decoder Values.
|
||||
*
|
||||
* @return array Returns the values with the correct key.
|
||||
*/
|
||||
public function decoders(array $decoder): array
|
||||
{
|
||||
$values = [];
|
||||
// Retrieve global - common inputs.
|
||||
$values = parent::decoders($decoder);
|
||||
|
||||
if (isset($decoder['group']) === true) {
|
||||
$values['groupId'] = $decoder['group'];
|
||||
}
|
||||
|
||||
if (isset($decoder['groupId']) === true) {
|
||||
$values['groupId'] = $decoder['groupId'];
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates inputs for form (specific).
|
||||
*
|
||||
|
@ -234,7 +259,7 @@ class AlertsFiredWidget extends Widget
|
|||
|
||||
$output = '';
|
||||
|
||||
if ($this->values['groupId'] === 0) {
|
||||
if ((int) $this->values['groupId'] === 0) {
|
||||
$groups = users_get_groups(false, 'AR', false);
|
||||
} else {
|
||||
$groups = [$this->values['groupId'] => ''];
|
||||
|
@ -254,7 +279,7 @@ class AlertsFiredWidget extends Widget
|
|||
|
||||
$flag = false;
|
||||
foreach ($groups as $id_group => $name) {
|
||||
$alerts_group = get_group_alerts($id_group);
|
||||
$alerts_group = get_group_alerts([$id_group]);
|
||||
if (isset($alerts_group['simple']) === true) {
|
||||
$alerts_group = $alerts_group['simple'];
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue