Merge remote-tracking branch 'origin/develop' into ent-8303-formularios-en-modulos-para-nueva-funcionalidad-incremento-de-valor

This commit is contained in:
Calvo 2021-11-24 13:28:36 +01:00
commit 5464a73a12
91 changed files with 3566 additions and 1111 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.758-211118 Version: 7.0NG.758.1-211124
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent #Pandora FMS Linux Agent
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.758 %define version 7.0NG.758.1
%define release 211118 %define release 211124
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent #Pandora FMS Linux Agent
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.758 %define version 7.0NG.758.1
%define release 211118 %define release 211124
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

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

View File

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

View File

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

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils; using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1 #define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.758 Build 211118") #define PANDORA_VERSION ("7.0NG.758.1 Build 211124")
string pandora_path; string pandora_path;
string pandora_dir; string pandora_dir;

View File

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

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 7.0NG.758-211118 Version: 7.0NG.758.1-211124
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

@ -114,3 +114,4 @@ enterprise/include/javascript/tooltipster.bundle.min.js
enterprise/include/styles/tooltipster.bundle.min.css enterprise/include/styles/tooltipster.bundle.min.css
mobile/include/javascript/jquery.mobile-1.3.1.js mobile/include/javascript/jquery.mobile-1.3.1.js
mobile/include/style/jquery.mobile-1.3.1.css mobile/include/style/jquery.mobile-1.3.1.css
godmode/alerts/configure_alert_special_days.php

View File

@ -9,8 +9,33 @@ ALTER TABLE `tlocal_component` ADD COLUMN `percentage_warning` tinyint(1) UNSIGN
ALTER TABLE `tpolicy_modules` ADD COLUMN `percentage_warning` tinyint(1) UNSIGNED DEFAULT 0; ALTER TABLE `tpolicy_modules` ADD COLUMN `percentage_warning` tinyint(1) UNSIGNED DEFAULT 0;
ALTER TABLE `tpolicy_modules` ADD COLUMN `percentage_critical` tinyint(1) UNSIGNED DEFAULT 0; ALTER TABLE `tpolicy_modules` ADD COLUMN `percentage_critical` tinyint(1) UNSIGNED DEFAULT 0;
ALTER TABLE tagente_modulo MODIFY debug_content TEXT;
CREATE TABLE IF NOT EXISTS `talert_calendar` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL default '',
`id_group` INT(10) NOT NULL DEFAULT 0,
`description` text,
PRIMARY KEY (`id`),
UNIQUE (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT IGNORE INTO `talert_calendar` VALUES (1, 'Default', 0, 'Default calendar');
ALTER TABLE `talert_special_days` ADD COLUMN `id_calendar` int(10) unsigned NOT NULL DEFAULT 1;
ALTER TABLE `talert_special_days` ADD COLUMN `day_code` tinyint(2) unsigned NOT NULL DEFAULT 0;
UPDATE `talert_special_days` set `day_code` = 1 WHERE `same_day` = 'monday';
UPDATE `talert_special_days` set `day_code` = 2 WHERE `same_day` = 'tuesday';
UPDATE `talert_special_days` set `day_code` = 3 WHERE `same_day` = 'wednesday';
UPDATE `talert_special_days` set `day_code` = 4 WHERE `same_day` = 'thursday';
UPDATE `talert_special_days` set `day_code` = 5 WHERE `same_day` = 'friday';
UPDATE `talert_special_days` set `day_code` = 6 WHERE `same_day` = 'saturday';
UPDATE `talert_special_days` set `day_code` = 7 WHERE `same_day` = 'sunday';
ALTER TABLE `talert_special_days` DROP COLUMN `same_day`;
ALTER TABLE `talert_special_days` ADD FOREIGN KEY (`id_calendar`) REFERENCES `talert_calendar`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `tagent_repository` ADD COLUMN `deployment_timeout` INT UNSIGNED DEFAULT 600 AFTER `path`;
COMMIT; COMMIT;

View File

@ -1565,7 +1565,7 @@ ALTER TABLE `tagente_modulo` DROP COLUMN `ff_normal`,
MODIFY COLUMN `dynamic_next` bigint(20) NOT NULL DEFAULT '0', MODIFY COLUMN `dynamic_next` bigint(20) NOT NULL DEFAULT '0',
MODIFY COLUMN `dynamic_two_tailed` tinyint(1) unsigned NULL DEFAULT '0'; MODIFY COLUMN `dynamic_two_tailed` tinyint(1) unsigned NULL DEFAULT '0';
ALTER TABLE tagente_modulo MODIFY COLUMN `custom_string_1` MEDIUMTEXT; ALTER TABLE tagente_modulo MODIFY COLUMN `custom_string_1` MEDIUMTEXT;
ALTER TABLE `tagente_modulo` ADD COLUMN `debug_content` varchar(200); ALTER TABLE `tagente_modulo` ADD COLUMN `debug_content` TEXT;
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- Table `tagente_datos` -- Table `tagente_datos`
@ -2683,6 +2683,7 @@ CREATE TABLE `tagent_repository` (
`arch` ENUM('x64', 'x86') DEFAULT 'x64', `arch` ENUM('x64', 'x86') DEFAULT 'x64',
`version` VARCHAR(10) DEFAULT '', `version` VARCHAR(10) DEFAULT '',
`path` text, `path` text,
`deployment_timeout` INT UNSIGNED DEFAULT 600,
`uploaded_by` VARCHAR(100) DEFAULT '', `uploaded_by` VARCHAR(100) DEFAULT '',
`uploaded` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was uploaded", `uploaded` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was uploaded",
`last_err` text, `last_err` text,
@ -4223,3 +4224,31 @@ INSERT INTO `tncm_script` VALUES
(5,5,'enable&#x0d;&#x0a;expect:Password:&#92;s*&#x0d;&#x0a;_enablepass_&#x0d;&#x0a;term&#x20;length&#x20;0&#x0d;&#x0a;config&#x20;term&#x0d;&#x0a;end&#x0d;&#x0a;end&#x0d;&#x0a;exit&#x0d;&#x0a;'); (5,5,'enable&#x0d;&#x0a;expect:Password:&#92;s*&#x0d;&#x0a;_enablepass_&#x0d;&#x0a;term&#x20;length&#x20;0&#x0d;&#x0a;config&#x20;term&#x0d;&#x0a;end&#x0d;&#x0a;end&#x0d;&#x0a;exit&#x0d;&#x0a;');
INSERT INTO `tncm_template_scripts`(`id_template`, `id_script`) VALUES (1,1),(1,2),(1,3),(1,4),(1,5); INSERT INTO `tncm_template_scripts`(`id_template`, `id_script`) VALUES (1,1),(1,2),(1,3),(1,4),(1,5);
-- ----------------------------------------------------------------------
-- Table `talert_calendar`
-- ----------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `talert_calendar` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL default '',
`id_group` INT(10) NOT NULL DEFAULT 0,
`description` text,
PRIMARY KEY (`id`),
UNIQUE (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT IGNORE INTO `talert_calendar` VALUES (1, 'Default', 0, 'Default calendar');
ALTER TABLE `talert_special_days` ADD COLUMN `id_calendar` int(10) unsigned NOT NULL DEFAULT 1;
ALTER TABLE `talert_special_days` ADD COLUMN `day_code` tinyint(2) unsigned NOT NULL DEFAULT 0;
UPDATE `talert_special_days` set `day_code` = 1 WHERE `same_day` = 'monday';
UPDATE `talert_special_days` set `day_code` = 2 WHERE `same_day` = 'tuesday';
UPDATE `talert_special_days` set `day_code` = 3 WHERE `same_day` = 'wednesday';
UPDATE `talert_special_days` set `day_code` = 4 WHERE `same_day` = 'thursday';
UPDATE `talert_special_days` set `day_code` = 5 WHERE `same_day` = 'friday';
UPDATE `talert_special_days` set `day_code` = 6 WHERE `same_day` = 'saturday';
UPDATE `talert_special_days` set `day_code` = 7 WHERE `same_day` = 'sunday';
ALTER TABLE `talert_special_days` DROP COLUMN `same_day`;
ALTER TABLE `talert_special_days` ADD FOREIGN KEY (`id_calendar`) REFERENCES `talert_calendar`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -688,7 +688,7 @@ foreach ($simple_alerts as $alert) {
$data[3] .= '</tr>'; $data[3] .= '</tr>';
} }
$data[3] .= '<div id="update_action-div" class="invisible left">'; $data[3] .= '<div id="update_action-div" class="invisible">';
$data[3] .= '</div>'; $data[3] .= '</div>';
$data[3] .= '</table>'; $data[3] .= '</table>';
// Is possible manage actions if have LW permissions in the agent group of the alert module // Is possible manage actions if have LW permissions in the agent group of the alert module
@ -1163,18 +1163,18 @@ function show_display_update_action(id_module_action, alert_id, alert_id_agent_m
background: "black" background: "black"
}, },
open: function() { open: function() {
$("#action_select_ajax, #action_select_ajax").select2({ $('#update_action-div').css('overflow', 'hidden');
$("#action_select, #action_select_ajax").select2({
tags: true, tags: true,
dropdownParent: $("#update_action-div") dropdownParent: $('#update_action-')
}); });
}, },
width: 500, width: 455,
height: 300 height: 370
}) })
.show (); .show ();
} }
}); });
} }
/* ]]> */ /* ]]> */

View File

@ -1,577 +1,75 @@
<?php <?php
/**
* Calendar controller.
*
* @category Alerts
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation 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.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com // Begin.
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Copyright (c) 2012-2016 Junichi Satoh
// 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
global $config; global $config;
require_once 'include/functions_alerts.php'; require_once $config['homedir'].'/vendor/autoload.php';
require_once 'include/ics-parser/class.iCalReader.php'; require_once $config['homedir'].'/include/class/CalendarManager.class.php';
check_login(); use PandoraFMS\CalendarManager;
if (! check_acl($config['id_user'], 0, 'LM')) { $ajaxPage = 'godmode/alerts/alert_special_days';
db_pandora_audit( $url = 'index.php?sec=galertas&sec2=godmode/alerts/alert_special_days';
'ACL Violation',
'Trying to access Alert Management' // Control call flow.
); try {
include 'general/noaccess.php'; // User access and validation is being processed on class constructor.
$cs = new CalendarManager($url, $ajaxPage);
} catch (Exception $e) {
if ((bool) is_ajax() === true) {
echo json_encode(['error' => '[CalendarManager]'.$e->getMessage() ]);
exit; exit;
} } else {
echo '[CalendarManager]'.$e->getMessage();
if (is_ajax()) {
$get_alert_command = (bool) get_parameter('get_alert_command');
if ($get_alert_command) {
$id = (int) get_parameter('id');
$command = alerts_get_alert_command($id);
echo json_encode($command);
} }
// Stop this execution, but continue 'globally'.
return; return;
} }
// Header // AJAX controller.
ui_print_page_header( if ((bool) is_ajax() === true) {
__('Alerts').' &raquo; '.__('Special days list'), $method = get_parameter('method');
'images/gm_alerts.png',
false,
'alert_special_days',
true
);
$update_special_day = (bool) get_parameter('update_special_day'); if (method_exists($cs, $method) === true) {
$create_special_day = (bool) get_parameter('create_special_day'); if (CalendarManager::ajaxMethod($method) === true) {
$delete_special_day = (bool) get_parameter('delete_special_day'); $cs->{$method}();
$upload_ical = (bool) get_parameter('upload_ical', 0);
$display_range = (int) get_parameter('display_range');
if ($upload_ical) {
$same_day = (string) get_parameter('same_day');
$overwrite = (bool) get_parameter('overwrite', 0);
$values = [];
$values['id_group'] = (string) get_parameter('id_group');
$values['same_day'] = $same_day;
$error = $_FILES['ical_file']['error'];
$extension = substr($_FILES['ical_file']['name'], -3);
if ($error == 0 && strcasecmp($extension, 'ics') == 0) {
$skipped_dates = '';
// $today = date ('Ymd');
$this_month = date('Ym');
$ical = new ICal($_FILES['ical_file']['tmp_name']);
$events = $ical->events();
foreach ($events as $event) {
$event_date = substr($event['DTSTART'], 0, 8);
$event_month = substr($event['DTSTART'], 0, 6);
if ($event_month >= $this_month) {
$values['description'] = @$event['SUMMARY'];
$values['date'] = $event_date;
$date = date('Y-m-d', strtotime($event_date));
$date_check = '';
$filter['id_group'] = $values['id_group'];
$filter['date'] = $date;
$date_check = db_get_value_filter('date', 'talert_special_days', $filter);
if ($date_check == $date) {
if ($overwrite) {
$id_special_day = db_get_value_filter('id', 'talert_special_days', $filter);
alerts_update_alert_special_day($id_special_day, $values);
} else { } else {
if ($skipped_dates == '') { $cs->error('Unavailable method.');
$skipped_dates = __('Skipped dates: ');
}
$skipped_dates .= $date.' ';
} }
} else { } else {
alerts_create_alert_special_day($date, $same_day, $values); $cs->error('Method not found. ['.$method.']');
}
}
} }
$result = true; // Stop any execution.
} else { exit;
$result = false;
}
if ($result) {
db_pandora_audit('Special days list', 'Upload iCalendar '.$_FILES['ical_file']['name']);
}
ui_print_result_message($result, __('Success to upload iCalendar').'<br />'.$skipped_dates, __('Fail to upload iCalendar'));
}
if ($create_special_day) {
$date = (string) get_parameter('date');
$same_day = (string) get_parameter('same_day');
$values = [];
$values['id_group'] = (string) get_parameter('id_group');
$values['description'] = io_safe_input(strip_tags(io_safe_output((string) get_parameter('description'))));
$aviable_description = true;
if (preg_match('/script/i', $values['description'])) {
$aviable_description = false;
}
$array_date = explode('-', $date);
$year = $array_date[0];
$month = $array_date[1];
$day = $array_date[2];
if ($year == '*') {
// '0001' means every year.
$year = '0001';
$date = $year.'-'.$month.'-'.$day;
}
if (!checkdate($month, $day, $year)) {
$result = '';
} else {
$date_check = '';
$filter['id_group'] = $values['id_group'];
$filter['date'] = $date;
$date_check = db_get_value_filter('date', 'talert_special_days', $filter);
if ($date_check == $date) {
$result = '';
$messageAction = __('Could not be created, it already exists');
} else {
if ($aviable_description) {
$result = alerts_create_alert_special_day($date, $same_day, $values);
$info = '{"Date":"'.$date.'","Same day of the week":"'.$same_day.'","Description":"'.$values['description'].'"}';
} else {
$result = false;
}
}
}
if ($result) {
db_pandora_audit('Command management', 'Create special day '.$result, false, false, $info);
} else {
db_pandora_audit('Command management', 'Fail try to create special day', false, false);
}
// Show errors
if (!isset($messageAction)) {
$messageAction = __('Could not be created');
}
$messageAction = ui_print_result_message(
$result,
__('Successfully created'),
$messageAction
);
}
if ($update_special_day) {
$id = (int) get_parameter('id');
$alert = alerts_get_alert_special_day($id);
$date = (string) get_parameter('date');
$date_orig = (string) get_parameter('date_orig');
$same_day = (string) get_parameter('same_day');
$description = io_safe_input(strip_tags(io_safe_output((string) get_parameter('description'))));
$id_group = (string) get_parameter('id_group');
$id_group_orig = (string) get_parameter('id_group_orig');
$aviable_description = true;
if (preg_match('/script/i', $description)) {
$aviable_description = false;
}
$array_date = explode('-', $date);
$year = $array_date[0];
$month = $array_date[1];
$day = $array_date[2];
if ($year == '*') {
// '0001' means every year.
$year = '0001';
$date = $year.'-'.$month.'-'.$day;
}
$values = [];
$values['date'] = $date;
$values['id_group'] = $id_group;
$values['same_day'] = $same_day;
$values['description'] = $description;
if (!checkdate($month, $day, $year)) {
$result = '';
} else {
if ($id_group != $id_group_orig || $date != $date_orig) {
$date_check = '';
$filter['id_group'] = $id_group;
$filter['date'] = $date;
$date_check = db_get_value_filter('date', 'talert_special_days', $filter);
if ($date_check == $date) {
$result = '';
$messageAction = __('Could not be updated, it already exists');
} else {
if ($aviable_description !== false) {
$result = alerts_update_alert_special_day($id, $values);
$info = '{"Date":"'.$date.'","Same day of the week":"'.$same_day.'","Description":"'.$description.'"}';
}
}
} else {
if ($aviable_description !== false) {
$result = alerts_update_alert_special_day($id, $values);
$info = '{"Date":"'.$date.'","Same day of the week":"'.$same_day.'","Description":"'.$description.'"}';
}
}
}
if ($result) {
db_pandora_audit('Command management', 'Update special day '.$id, false, false, $info);
} else {
db_pandora_audit('Command management', 'Fail to update special day '.$id, false, false);
}
// Show errors
if (!isset($messageAction)) {
$messageAction = __('Could not be updated');
}
$messageAction = ui_print_result_message(
$result,
__('Successfully updated'),
$messageAction
);
}
if ($delete_special_day) {
$id = (int) get_parameter('id');
$result = alerts_delete_alert_special_day($id);
if ($result) {
db_pandora_audit('Command management', 'Delete special day '.$id);
} else {
db_pandora_audit('Command management', 'Fail to delete special day '.$id);
}
ui_print_result_message(
$result,
__('Successfully deleted'),
__('Could not be deleted')
);
}
echo "<table cellpadding='4' cellspacing='4' class='databox upload bolder margin-bottom-10' width='100%
'><tr>";
echo "<form method='post' enctype='multipart/form-data' action='index.php?sec=gagente&sec2=godmode/alerts/alert_special_days'>";
echo '<td>';
echo __('iCalendar(.ics) file').'&nbsp;';
html_print_input_file('ical_file', false, false);
echo '</td><td>';
echo __('Same day of the week');
$days = [];
$days['monday'] = __('Monday');
$days['tuesday'] = __('Tuesday');
$days['wednesday'] = __('Wednesday');
$days['thursday'] = __('Thursday');
$days['friday'] = __('Friday');
$days['saturday'] = __('Saturday');
$days['sunday'] = __('Sunday');
html_print_select($days, 'same_day', $same_day, '', '', 0, false, false, false);
echo '</td><td>';
echo __('Group').'&nbsp;';
$own_info = get_user_info($config['id_user']);
if (!users_can_manage_group_all('LM')) {
$can_manage_group_all = false;
} else { } else {
$can_manage_group_all = true; // Run.
$cs->run();
} }
echo '<div class="inline w250px">';
html_print_select_groups(false, 'LM', $can_manage_group_all, 'id_group', $id_group, false, '', 0, false, false, true, '', false, 'width:100px;');
echo '</div>';
echo '</td><td>';
echo __('Overwrite');
ui_print_help_tip(__('Check this box, if you want to overwrite existing same days.'), false);
echo '&nbsp;';
html_print_checkbox('overwrite', 1, $overwrite, false, false, false, true);
echo '</td><td>';
html_print_input_hidden('upload_ical', 1);
echo "<input name='srcbutton' type='submit' class='sub next' value='".__('Upload')."'>";
echo '</td></form>';
echo '</tr></table>';
$this_year = date('Y');
$this_month = date('m');
$filter = [];
if (!is_user_admin($config['id_user'])) {
$filter['id_group'] = array_keys(users_get_groups(false, 'LM'));
}
// Show display range.
$html = "<table cellpadding='4' cellspacing='4' width='100%' margin-bottom: 10px;'><tr><td>".__('Display range: ');
if ($display_range) {
$html .= '<a href="index.php?sec=galertas&sec2=godmode/alerts/alert_special_days">['.__('Default').']</a>&nbsp;&nbsp;';
if ($display_range > 1970) {
$html .= '<a href="index.php?sec=galertas&sec2=godmode/alerts/alert_special_days&display_range=';
$html .= ($display_range - 1);
$html .= '">&lt;&lt;&nbsp;</a>';
}
$html .= '<a href="index.php?sec=galertas&sec2=godmode/alerts/alert_special_days&display_range='.$display_range.'" class="bolder">['.$display_range.']</a>';
$html .= '<a href="index.php?sec=galertas&sec2=godmode/alerts/alert_special_days&display_range=';
$html .= ($display_range + 1);
$html .= '">&nbsp;&gt;&gt;</a>';
} else {
$html .= '<a href="index.php?sec=galertas&sec2=godmode/alerts/alert_special_days" class="bolder">['.__('Default').']</a>&nbsp;&nbsp;';
$html .= '<a href="index.php?sec=galertas&sec2=godmode/alerts/alert_special_days&display_range=';
$html .= ($this_year - 1);
$html .= '">&lt;&lt;&nbsp;</a>';
$html .= '<a href="index.php?sec=galertas&sec2=godmode/alerts/alert_special_days&display_range=';
$html .= $this_year;
$html .= '">[';
$html .= $this_year;
$html .= ']</a>';
$html .= '<a href="index.php?sec=galertas&sec2=godmode/alerts/alert_special_days&display_range=';
$html .= ($this_year + 1);
$html .= '">&nbsp;&gt;&gt;</a>';
}
$html .= '</td></tr>';
echo $html;
// Show calendar
for ($month = 1; $month <= 12; $month++) {
if ($display_range) {
$display_month = $month;
$display_year = $display_range;
} else {
$display_month = ($this_month + $month - 1);
$display_year = $this_year;
}
if ($display_month > 12) {
$display_month -= 12;
$display_year += 1;
}
$cal_table = new stdClass();
$cal_table->width = '100%';
$cal_table->class = 'databox data';
$cal_table->data = [];
$cal_table->head = [];
$cal_table->head[0] = __('Sun');
$cal_table->head[1] = __('Mon');
$cal_table->head[2] = __('Tue');
$cal_table->head[3] = __('Wed');
$cal_table->head[4] = __('Thu');
$cal_table->head[5] = __('Fri');
$cal_table->head[6] = __('Sat');
$cal_table->cellstyle = [];
$cal_table->size = [];
$cal_table->size[0] = '14%';
$cal_table->size[1] = '14%';
$cal_table->size[2] = '14%';
$cal_table->size[3] = '14%';
$cal_table->size[4] = '14%';
$cal_table->size[5] = '14%';
$cal_table->size[6] = '14%';
$cal_table->align = [];
$cal_table->border = '1';
$cal_table->titlestyle = 'text-align:center; font-weight: bold;';
switch ($display_month) {
case 1:
$cal_table->title = __('January');
break;
case 2:
$cal_table->title = __('February');
break;
case 3:
$cal_table->title = __('March');
break;
case 4:
$cal_table->title = __('April');
break;
case 5:
$cal_table->title = __('May');
break;
case 6:
$cal_table->title = __('June');
break;
case 7:
$cal_table->title = __('July');
break;
case 8:
$cal_table->title = __('August');
break;
case 9:
$cal_table->title = __('September');
break;
case 10:
$cal_table->title = __('October');
break;
case 11:
$cal_table->title = __('November');
break;
case 12:
$cal_table->title = __('December');
break;
}
$cal_table->title .= ' / '.$display_year;
$last_day = date('j', mktime(0, 0, 0, ($display_month + 1), 0, $display_year));
$cal_line = 0;
for ($day = 1; $day < ($last_day + 1); $day++) {
$week = date('w', mktime(0, 0, 0, $display_month, $day, $display_year));
if ($cal_line == 0 && $week != 0 && $day == 1) {
for ($i = 0; $i < $week; $i++) {
$cal_table->cellstyle[$cal_line][$i] = 'font-size: 18px;';
$cal_table->data[$cal_line][$i] = '-';
}
}
if ($week == 0 || $week == 6) {
$cal_table->cellstyle[$cal_line][$week] = 'color: red;';
}
$date = sprintf('%04d-%02d-%02d', $display_year, $display_month, $day);
$date_wildcard = sprintf('0001-%02d-%02d', $display_month, $day);
$special_days = '';
$filter['date'] = [
$date,
$date_wildcard,
];
$filter['order']['field'] = 'date';
$filter['order']['order'] = 'DESC';
$special_days = db_get_all_rows_filter('talert_special_days', $filter);
if ($special_days != '') {
foreach ($special_days as $special_day) {
$cal_table->data[$cal_line][$week] .= '<div class="font_18px" style="';
if ($special_day['same_day'] == 'sunday' || $special_day['same_day'] == 'saturday') {
$cal_table->data[$cal_line][$week] .= 'color: red;';
}
$cal_table->data[$cal_line][$week] .= '">';
$cal_table->data[$cal_line][$week] .= $day;
$cal_table->data[$cal_line][$week] .= '</div>';
$cal_table->data[$cal_line][$week] .= ui_print_group_icon($special_day['id_group'], true);
if ($special_day['date'] == $date_wildcard) {
$cal_table->data[$cal_line][$week] .= '('.ui_print_help_tip('This is valid every year. However, this will be ignored if indivisual setting for the same group is available.', true).') ';
}
$cal_table->data[$cal_line][$week] .= __('Same as ');
switch ($special_day['same_day']) {
case 'monday':
$cal_table->data[$cal_line][$week] .= __('Monday');
break;
case 'tuesday':
$cal_table->data[$cal_line][$week] .= __('Tuesday');
break;
case 'wednesday':
$cal_table->data[$cal_line][$week] .= __('Wednesday');
break;
case 'thursday':
$cal_table->data[$cal_line][$week] .= __('Thursday');
break;
case 'friday':
$cal_table->data[$cal_line][$week] .= __('Friday');
break;
case 'saturday':
$cal_table->data[$cal_line][$week] .= __('Saturday');
break;
case 'sunday':
$cal_table->data[$cal_line][$week] .= __('Sunday');
break;
}
// Only show description if is filled.
if (empty($special_day['description']) === false) {
$cal_table->data[$cal_line][$week] .= ui_print_help_tip($special_day['description'], true);
}
if ($special_day['id_group'] || ($can_manage_group_all && $special_day['id_group'] == 0)) {
$cal_table->data[$cal_line][$week] .= '<a href="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_special_days&id='.$special_day['id'].'" title=';
$cal_table->data[$cal_line][$week] .= __('Edit');
$cal_table->data[$cal_line][$week] .= '>'.html_print_image(
'images/config.png',
true,
['class' => 'invert_filter']
).'</a> &nbsp;';
$cal_table->data[$cal_line][$week] .= '<a href="index.php?sec=galertas&sec2=godmode/alerts/alert_special_days&delete_special_day=1&id='.$special_day['id'].'"onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;" title=';
$cal_table->data[$cal_line][$week] .= __('Remove');
$cal_table->data[$cal_line][$week] .= '>'.html_print_image(
'images/cross.png',
true,
['class' => 'invert_filter']
).'</a>';
;
}
$cal_table->data[$cal_line][$week] .= '<br>';
$cal_table->cellstyle[$cal_line][$week] = 'font-weight: bold;';
}
} else {
$cal_table->cellstyle[$cal_line][$week] .= 'font-size: 18px;';
$cal_table->data[$cal_line][$week] = $day.'&nbsp;';
}
$cal_table->data[$cal_line][$week] .= '<a href="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_special_days&create_special_day=1&date='.$date.'" title=';
$cal_table->data[$cal_line][$week] .= __('Create');
$cal_table->data[$cal_line][$week] .= '>'.html_print_image(
'images/add_mc.png',
true,
['class' => 'invert_filter']
).'</a>';
if ($week == 6) {
$cal_line++;
}
}
for ($padding = ($week + 1); $padding <= 6; $padding++) {
$cal_table->cellstyle[$cal_line][$padding] = 'font-size: 18px;';
$cal_table->data[$cal_line][$padding] = '-';
}
html_print_table($cal_table);
}
echo '<div class="action-buttons" style="width: '.$table->width.'">';
echo '<form method="post" action="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_special_days">';
html_print_submit_button(__('Create'), 'create', false, 'class="sub next"');
html_print_input_hidden('create_special_day', 1);
echo '</form>';
echo '</div>';

View File

@ -1,159 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Copyright (c) 2012-2013 Junichi Satoh
// 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.
global $config;
require_once 'include/functions_alerts.php';
check_login();
if (! check_acl($config['id_user'], 0, 'LM')) {
db_pandora_audit(
'ACL Violation',
'Trying to access Alert Management'
);
include 'general/noaccess.php';
exit;
}
ui_require_javascript_file('calendar');
$id = (int) get_parameter('id');
$date = (string) get_parameter('date');
$name = '';
$command = '';
$description = '';
$same_day = '';
$id_group = 0;
if ($id) {
$special_day = alerts_get_alert_special_day($id);
$date = str_replace('0001', '*', $special_day['date']);
$date_orig = $date;
$same_day = $special_day['same_day'];
$description = $special_day['description'];
$id_group = $special_day['id_group'];
$id_group_orig = $id_group;
}
if ($date == '') {
$date = date('Y-m-d', get_system_time());
}
// Header.
ui_print_page_header(
__('Alerts').' &raquo; '.__('Configure special day'),
'images/gm_alerts.png',
false,
'',
true
);
$table = new stdClass();
$table->width = '100%';
$table->class = 'databox filters';
$table->style = [];
$table->style[0] = 'font-weight: bold';
$table->size = [];
$table->size[0] = '20%';
$table->data = [];
$table->data[0][0] = __('Date');
$table->data[0][1] = html_print_input_text(
'date',
$date,
'',
10,
10,
true
);
$table->data[0][1] .= html_print_image(
'images/calendar_view_day.png',
true,
[
'alt' => 'calendar',
'onclick' => "scwShow(scwID('text-date'),this);",
'class' => 'invert_filter',
]
);
$table->data[1][0] = __('Group');
$groups = users_get_groups();
$own_info = get_user_info($config['id_user']);
// Only display group "All" if user is administrator or has "LM" privileges.
if (users_can_manage_group_all('LM')) {
$display_all_group = true;
} else {
$display_all_group = false;
}
$table->data[1][1] = html_print_select_groups(
false,
'LW',
$display_all_group,
'id_group',
$id_group,
'',
'',
0,
true
);
$table->data[2][0] = __('Same day of the week');
$days = [];
$days['monday'] = __('Monday');
$days['tuesday'] = __('Tuesday');
$days['wednesday'] = __('Wednesday');
$days['thursday'] = __('Thursday');
$days['friday'] = __('Friday');
$days['saturday'] = __('Saturday');
$days['sunday'] = __('Sunday');
$table->data[2][1] = html_print_select(
$days,
'same_day',
$same_day,
'',
'',
0,
true,
false,
false
);
$table->data[3][0] = __('Description');
$table->data[3][1] = html_print_textarea(
'description',
10,
30,
$description,
'',
true
);
echo '<form method="post" action="index.php?sec=galertas&sec2=godmode/alerts/alert_special_days">';
html_print_table($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
if ($id) {
html_print_input_hidden('id', $id);
html_print_input_hidden('update_special_day', 1);
html_print_input_hidden('id_group_orig', $id_group_orig);
html_print_input_hidden('date_orig', $date_orig);
html_print_submit_button(__('Update'), 'create', false, 'class="sub upd"');
} else {
html_print_input_hidden('create_special_day', 1);
html_print_submit_button(__('Create'), 'create', false, 'class="sub wand"');
}
echo '</div>';
echo '</form>';

View File

@ -11,8 +11,11 @@
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// Load global vars // Load global vars.
global $config; global $config;
use PandoraFMS\Calendar;
require_once $config['homedir'].'/include/functions_alerts.php'; require_once $config['homedir'].'/include/functions_alerts.php';
require_once $config['homedir'].'/include/functions_users.php'; require_once $config['homedir'].'/include/functions_users.php';
enterprise_include_once('meta/include/functions_alerts_meta.php'); enterprise_include_once('meta/include/functions_alerts_meta.php');
@ -288,7 +291,7 @@ function update_template($step)
$friday = (bool) get_parameter('friday'); $friday = (bool) get_parameter('friday');
$saturday = (bool) get_parameter('saturday'); $saturday = (bool) get_parameter('saturday');
$sunday = (bool) get_parameter('sunday'); $sunday = (bool) get_parameter('sunday');
$special_day = (bool) get_parameter('special_day'); $special_day = (int) get_parameter('special_day');
$time_from = (string) get_parameter('time_from'); $time_from = (string) get_parameter('time_from');
$time_from = date('H:i:00', strtotime($time_from)); $time_from = date('H:i:00', strtotime($time_from));
$time_to = (string) get_parameter('time_to'); $time_to = (string) get_parameter('time_to');
@ -418,7 +421,7 @@ $thursday = true;
$friday = true; $friday = true;
$saturday = true; $saturday = true;
$sunday = true; $sunday = true;
$special_day = false; $special_day = 0;
$default_action = 0; $default_action = 0;
$fields = []; $fields = [];
for ($i = 1; $i <= $config['max_macro_fields']; $i++) { for ($i = 1; $i <= $config['max_macro_fields']; $i++) {
@ -561,7 +564,7 @@ if ($id && ! $create_template) {
$friday = (bool) $template['friday']; $friday = (bool) $template['friday'];
$saturday = (bool) $template['saturday']; $saturday = (bool) $template['saturday'];
$sunday = (bool) $template['sunday']; $sunday = (bool) $template['sunday'];
$special_day = (bool) $template['special_day']; $special_day = (int) $template['special_day'];
$max_alerts = $template['max_alerts']; $max_alerts = $template['max_alerts'];
$min_alerts = $template['min_alerts']; $min_alerts = $template['min_alerts'];
$min_alerts_reset_counter = $template['min_alerts_reset_counter']; $min_alerts_reset_counter = $template['min_alerts_reset_counter'];
@ -671,11 +674,36 @@ if ($step == 2) {
); );
$table->data[0][2] = __('Use special days list'); $table->data[0][2] = __('Use special days list');
$table->data[0][3] = html_print_checkbox( $data_special_days = Calendar::calendars(
// Fields.
[ '`talert_calendar`.*' ],
// Filter.
[],
// Count.
false,
// Offset.
null,
// Limit.
null,
// Order.
null,
// Sort field.
null,
// Reduce to a select.
true
);
$table->data[0][3] = html_print_select(
$data_special_days,
'special_day', 'special_day',
1,
$special_day, $special_day,
'',
__('None'),
0,
true, true,
false,
false,
'',
(!$is_management_allowed | $disabled) (!$is_management_allowed | $disabled)
); );

View File

@ -422,8 +422,8 @@ if ($show_update_action_menu) {
$id_action $id_action
); );
$data .= '<form id="update_action-'.$alert['id'].'" method="post">'; $data .= '<form id="update_action-'.$alert['id'].'" method="post" style="height:85%;">';
$data .= '<table class="databox_color w100p bg_color222">'; $data .= '<table class="databox_color w100p bg_color222" style="height:100%;">';
$data .= html_print_input_hidden( $data .= html_print_input_hidden(
'update_action', 'update_action',
1, 1,

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -173,6 +173,7 @@ define('COL_GRAPH13', '#E83128');
// Styles. // Styles.
// Size of text in characters for truncate. // Size of text in characters for truncate.
define('GENERIC_SIZE_TEXT', 50); define('GENERIC_SIZE_TEXT', 50);
define('MENU_SIZE_TEXT', 20);

View File

@ -679,7 +679,7 @@ function agents_get_agents(
// Add the group filter to // Add the group filter to
$where = db_format_array_where_clause_sql($filter, 'AND', '('.$where_secondary.') AND '); $where = db_format_array_where_clause_sql($filter, 'AND', '('.$where_secondary.') AND ');
if ($where == '' && $where_secondary != '') { if ($where == '' && $where_secondary != '') {
$where = $where_secondary; $where = '('.$where_secondary.')';
} }
$where_nogroup = db_format_array_where_clause_sql( $where_nogroup = db_format_array_where_clause_sql(

View File

@ -2380,118 +2380,6 @@ function get_alert_last_fire_timestamp_in_period($id_alert_module, $period, $dat
} }
/**
* Insert in talert_special_days a new special day.
*
* @param date of special day.
* @param same day of the week.
* @param mixed A single value or array of values to insert (can be a multiple a mount of rows).
*
* @return mixed False in case of error or invalid values passed. Affected rows otherwise.
*/
function alerts_create_alert_special_day($date, $same_day, $values=false)
{
if (empty($date)) {
return false;
}
if (empty($same_day)) {
return false;
}
if (! is_array($values)) {
$values = [];
}
global $config;
$date_db = '';
switch ($config['dbtype']) {
case 'mysql':
$date_db = 'date';
break;
case 'oracle':
$date_db = '"date"';
break;
}
$values[$date_db] = $date;
$values['same_day'] = $same_day;
return @db_process_sql_insert('talert_special_days', $values);
}
/**
* Update a special day in talert_special_days.
*
* @param int special day Id.
* @param mixed Array of values to update.
*
* @return mixed False in case of error or invalid values passed. Affected rows otherwise
*/
function alerts_update_alert_special_day($id_special_day, $values)
{
$id_special_day = safe_int($id_special_day, 1);
if (empty($id_special_day)) {
return false;
}
if (! is_array($values)) {
return false;
}
return (@db_process_sql_update(
'talert_special_days',
$values,
['id' => $id_special_day]
)) !== false;
}
/**
* Delete a special day in talert_special_days.
*
* @param int special day Id.
*
* @return mixed False in case of error or invalid values passed. Affected rows otherwise
*/
function alerts_delete_alert_special_day($id_special_day)
{
$id_special_day = safe_int($id_special_day, 1);
if (empty($id_special_day)) {
return false;
}
return (@db_process_sql_delete(
'talert_special_days',
['id' => $id_special_day]
)) !== false;
}
/**
* Get a special day in talert_special_days.
*
* @param int special day Id.
*
* @return mixed False in case of error or invalid values passed. All row of the selected command otherwise
*/
function alerts_get_alert_special_day($id_special_day)
{
$id_special_day = safe_int($id_special_day, 1);
if (empty($id_special_day)) {
return false;
}
return db_get_row('talert_special_days', 'id', $id_special_day);
}
/** /**
* Get number of alert fired that an action is executed. Only fot non default alerts * Get number of alert fired that an action is executed. Only fot non default alerts
* *

View File

@ -55,6 +55,7 @@ enterprise_include_once('include/functions_alerts.php');
// Clases. // Clases.
use PandoraFMS\Module; use PandoraFMS\Module;
use PandoraFMS\Enterprise\Cluster; use PandoraFMS\Enterprise\Cluster;
use PandoraFMS\SpecialDay;
/** /**
@ -14131,7 +14132,7 @@ function api_get_special_days($thrash1, $thrash2, $other, $thrash3)
* *
* @param $thrash1 Don't use. * @param $thrash1 Don't use.
* @param $thrash2 Don't use. * @param $thrash2 Don't use.
* @param array $other it's array, $other as param is <special_day>;<same_day>;<description>;<id_group>; in this order * @param array $other it's array, $other as param is <special_day>;<day_code>;<description>;<id_group>; in this order
* and separator char (after text ; ) and separator (pass in param othermode as othermode=url_encode_separator_<separator>) * and separator char (after text ; ) and separator (pass in param othermode as othermode=url_encode_separator_<separator>)
* @param $thrash3 Don't use * @param $thrash3 Don't use
* *
@ -14150,6 +14151,7 @@ function api_set_create_special_day($thrash1, $thrash2, $other, $thrash3)
$same_day = $other['data'][1]; $same_day = $other['data'][1];
$description = $other['data'][2]; $description = $other['data'][2];
$idGroup = $other['data'][3]; $idGroup = $other['data'][3];
$calendar_name = (isset($other['data'][4]) === true) ? $other['data'][4] : 'Default';
if (!check_acl($config['id_user'], $idGroup, 'LM', true)) { if (!check_acl($config['id_user'], $idGroup, 'LM', true)) {
returnError('forbidden', 'string'); returnError('forbidden', 'string');
@ -14186,17 +14188,51 @@ function api_set_create_special_day($thrash1, $thrash2, $other, $thrash3)
} }
} }
$values = [ $weekdays = [
'description' => $other['data'][2], 'monday' => 1,
'id_group' => $other['data'][3], 'tuesday' => 2,
'wednesday' => 3,
'thursday' => 4,
'friday' => 5,
'saturday' => 6,
'sunday' => 7,
'holiday' => 8,
]; ];
$idSpecialDay = alerts_create_alert_special_day($special_day, $same_day, $values); $day_code = (isset($weekdays[$same_day]) === true) ? $weekdays[$same_day] : 0;
if (is_error($idSpecialDay)) { if ($day_code === 0) {
returnError('Special Day could not be created'); returnError('Special Day could not be created. Same day doesn\'t exists.');
return;
}
$id_calendar = db_get_value_sql(
sprintf(
'SELECT id FROM talert_calendar WHERE name="%s"',
$calendar_name
)
);
if ($id_calendar === false) {
returnError('Special Day could not be created. Calendar doesn\'t exists.');
return;
}
try {
$sd = new SpecialDay();
$sd->date($special_day);
$sd->id_group($idGroup);
$sd->day_code($day_code);
$sd->description($description);
$sd->id_calendar($id_calendar);
$sd->save();
if ($sd->save() === true) {
returnData('string', ['type' => 'string', 'data' => $sd->id()]);
} else { } else {
returnData('string', ['type' => 'string', 'data' => $idSpecialDay]); returnError('Special Day could not be created');
}
} catch (Exception $e) {
returnData('string', ['type' => 'string', 'data' => $e]);
} }
} }
@ -14693,7 +14729,7 @@ function api_set_recreate_service_modules($id, $id_agent)
* *
* @param string $id Id of the special day to update. * @param string $id Id of the special day to update.
* @param $thrash2 Don't use. * @param $thrash2 Don't use.
* @param array $other it's array, $other as param is <special_day>;<same_day>;<description>;<id_group>; in this order * @param array $other it's array, $other as param is <special_day>;<day_code>;<description>;<id_group>; in this order
* and separator char (after text ; ) and separator (pass in param othermode as othermode=url_encode_separator_<separator>) * and separator char (after text ; ) and separator (pass in param othermode as othermode=url_encode_separator_<separator>)
* @param $thrash3 Don't use * @param $thrash3 Don't use
* *
@ -14709,9 +14745,10 @@ function api_set_update_special_day($id_special_day, $thrash2, $other, $thrash3)
} }
$special_day = $other['data'][0]; $special_day = $other['data'][0];
$same_day = $other['data'][1]; $day_code = $other['data'][1];
$description = $other['data'][2]; $description = $other['data'][2];
$idGroup = $other['data'][3]; $idGroup = $other['data'][3];
$id_calendar = $other['data'][4];
if (!check_acl($config['id_user'], $idGroup, 'LM', true)) { if (!check_acl($config['id_user'], $idGroup, 'LM', true)) {
returnError('forbidden', 'string'); returnError('forbidden', 'string');
@ -14742,24 +14779,22 @@ function api_set_update_special_day($id_special_day, $thrash2, $other, $thrash3)
return; return;
} }
$return = db_process_sql_update( try {
'talert_special_days', $sd = new SpecialDay();
[ $sd->date($special_day);
'date' => $special_day, $sd->id_group($idGroup);
'same_day' => $same_day, $sd->day_code($day_code);
'description' => $description, $sd->description($description);
'id_group' => $idGroup, $sd->id_calendar($id_calendar);
], $sd->save();
['id' => $id_special_day] if ($sd->save() === true) {
); returnError('Special Day could not be updated');
} else {
returnData( returnData('string', ['type' => 'string', 'data' => $sd->id()]);
'string', }
[ } catch (Exception $e) {
'type' => 'string', returnData('string', ['type' => 'string', 'data' => $e]);
'data' => (int) ((bool) $return), }
]
);
} }
@ -14805,13 +14840,20 @@ function api_set_delete_special_day($id_special_day, $thrash2, $thrash3, $thrash
return; return;
} }
$return = alerts_delete_alert_special_day($id_special_day); try {
$specialDay = new SpecialDay($id_special_day);
if (is_error($return)) { } catch (\Exception $e) {
if ($id > 0) {
returnError('The Special Day could not be deleted.'); returnError('The Special Day could not be deleted.');
} else {
returnData('string', ['type' => 'string', 'data' => $return]);
} }
return;
}
// Remove.
$specialDay->delete();
$return = 'success';
returnData('string', ['type' => 'string', 'data' => $return]);
} }

View File

@ -4032,15 +4032,19 @@ function html_print_input_file($name, $return=false, $options=false)
if ($options) { if ($options) {
if (isset($options['size'])) { if (isset($options['size'])) {
$output .= 'size="'.$options['size'].'"'; $output .= ' size="'.$options['size'].'"';
} }
if (isset($options['disabled'])) { if (isset($options['disabled'])) {
$output .= 'disabled="disabled"'; $output .= ' disabled="disabled"';
} }
if (isset($options['class'])) { if (isset($options['class'])) {
$output .= 'class="'.$options['class'].'"'; $output .= ' class="'.$options['class'].'"';
}
if (isset($options['required'])) {
$output .= ' required';
} }
} }

View File

@ -376,11 +376,11 @@ function menu_print_menu(&$menu)
if (isset($sub2['title'])) { if (isset($sub2['title'])) {
$sub_title = $sub2['title']; $sub_title = $sub2['title'];
} else { } else {
$sub_title = ''; $sub_title = $sub2['text'];
} }
$submenu2_list .= '<li class="'.$class.'" >'; $submenu2_list .= '<li class="'.$class.'" >';
$submenu2_list .= '<a href="'.$link.'"><div class="'.$sub_tree_class.'" title="'.$sub2['text'].'" >'.$sub2['text'].'</div></a></li>'; $submenu2_list .= '<a href="'.$link.'"><div class="'.$sub_tree_class.'" title="'.$sub_title.'" >'.$sub2['text'].'</div></a></li>';
$sub_title = ''; $sub_title = '';
} }

View File

@ -177,13 +177,8 @@ function servers_get_performance()
WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
AND tagente.id_agente = tagente_estado.id_agente AND tagente.id_agente = tagente_estado.id_agente
AND tagente_modulo.disabled = 0 AND tagente_modulo.disabled = 0
AND tagente_modulo.id_modulo <> 0
AND delete_pending = 0 AND delete_pending = 0
AND (utimestamp > 0
OR (id_tipo_modulo = 100
OR (id_tipo_modulo > 21
AND id_tipo_modulo < 23)
)
)
AND tagente.disabled = 0 AND tagente.disabled = 0
GROUP BY tagente_modulo.id_modulo' GROUP BY tagente_modulo.id_modulo'
); );

View File

@ -105,64 +105,119 @@ function tactical_get_data($id_user=false, $user_strict=false, $acltags, $return
if (is_metaconsole() && !empty($list_groups)) { if (is_metaconsole() && !empty($list_groups)) {
$cache_table = 'tmetaconsole_agent'; $cache_table = 'tmetaconsole_agent';
$sql_stats = "SELECT id_grupo, COUNT(id_agente) AS agents_total, if (users_is_admin() === false) {
SUM(total_count) AS monitors_total, $user_groups_ids_array = explode(',', $user_groups_ids);
SUM(normal_count) AS monitors_ok,
SUM(warning_count) AS monitors_warning, $user_group_children_ids = [];
SUM(critical_count) AS monitors_critical,
SUM(unknown_count) AS monitors_unknown, foreach ($user_groups_ids_array as $user_group_id) {
SUM(notinit_count) AS monitors_not_init, $group_children_ids = groups_get_children_ids($user_group_id);
SUM(fired_count) AS alerts_fired $user_group_children_ids = array_merge($user_group_children_ids, $group_children_ids);
FROM $cache_table }
WHERE disabled = 0
AND id_grupo IN ($user_groups_ids) $user_groups_ids = implode(',', array_unique($user_group_children_ids));
GROUP BY id_grupo"; }
$sql_stats = sprintf(
'SELECT tma.id_grupo, COUNT(tma.id_agente) AS agents_total,
SUM(tma.total_count) AS monitors_total,
SUM(tma.normal_count) AS monitors_ok,
SUM(tma.warning_count) AS monitors_warning,
SUM(tma.critical_count) AS monitors_critical,
SUM(tma.unknown_count) AS monitors_unknown,
SUM(tma.notinit_count) AS monitors_not_init,
SUM(tma.fired_count) AS alerts_fired
FROM tmetaconsole_agent tma
LEFT JOIN tmetaconsole_agent_secondary_group tmasg
ON tma.id_agente = tmasg.id_agent
WHERE tma.disabled = 0
AND tma.id_grupo IN (%s) OR tmasg.id_group IN (%s)
GROUP BY tma.id_grupo',
$user_groups_ids,
$user_groups_ids
);
$data_stats = db_get_all_rows_sql($sql_stats); $data_stats = db_get_all_rows_sql($sql_stats);
$sql_stats_unknown = "SELECT id_grupo, COUNT(id_agente) AS agents_unknown $sql_stats_unknown = sprintf(
FROM $cache_table 'SELECT tma.id_grupo, COUNT(tma.id_agente) AS agents_unknown
WHERE disabled = 0 FROM tmetaconsole_agent tma
AND id_grupo IN ($user_groups_ids) LEFT JOIN tmetaconsole_agent_secondary_group tmasg
AND critical_count = 0 ON tma.id_agente = tmasg.id_agent
AND warning_count = 0 WHERE tma.disabled = 0
AND unknown_count > 0 AND (tma.id_grupo IN (%s) OR tmasg.id_group IN (%s))
GROUP BY id_grupo"; AND tma.critical_count = 0
AND tma.warning_count = 0
AND tma.unknown_count > 0
GROUP BY tma.id_grupo',
$user_groups_ids,
$user_groups_ids
);
$data_stats_unknown = db_get_all_rows_sql($sql_stats_unknown); $data_stats_unknown = db_get_all_rows_sql($sql_stats_unknown);
$sql_stats_not_init = "SELECT id_grupo, COUNT(id_agente) AS agents_not_init $sql_stats_not_init = sprintf(
FROM $cache_table 'SELECT tma.id_grupo, COUNT(tma.id_agente) AS agents_not_init
WHERE disabled = 0 FROM tmetaconsole_agent tma
AND id_grupo IN ($user_groups_ids) LEFT JOIN tmetaconsole_agent_secondary_group tmasg
AND (total_count = 0 OR total_count = notinit_count) ON tma.id_agente = tmasg.id_agent
GROUP BY id_grupo"; WHERE tma.disabled = 0
AND (tma.id_grupo IN (%s) OR tmasg.id_group IN (%s))
AND (tma.total_count = 0 OR tma.total_count = tma.notinit_count)
GROUP BY tma.id_grupo',
$user_groups_ids,
$user_groups_ids
);
$data_stats_not_init = db_get_all_rows_sql($sql_stats_not_init); $data_stats_not_init = db_get_all_rows_sql($sql_stats_not_init);
$sql_stats_ok = "SELECT id_grupo, COUNT(id_agente) AS agents_ok $sql_stats_ok = sprintf(
FROM $cache_table 'SELECT tma.id_grupo, COUNT(tma.id_agente) AS agents_ok
WHERE disabled = 0 FROM tmetaconsole_agent tma
AND id_grupo IN ($user_groups_ids) LEFT JOIN tmetaconsole_agent_secondary_group tmasg
AND critical_count = 0 ON tma.id_agente = tmasg.id_agent
AND warning_count = 0 WHERE tma.disabled = 0
AND unknown_count = 0 AND (tma.id_grupo IN (%s) OR tmasg.id_group IN (%s))
AND normal_count > 0 AND tma.critical_count = 0
GROUP BY id_grupo"; AND tma.warning_count = 0
AND tma.unknown_count = 0
AND tma.normal_count > 0
GROUP BY tma.id_grupo',
$user_groups_ids,
$user_groups_ids
);
$data_stats_ok = db_get_all_rows_sql($sql_stats_ok); $data_stats_ok = db_get_all_rows_sql($sql_stats_ok);
$sql_stats_warning = "SELECT id_grupo, COUNT(id_agente) AS agents_warning $sql_stats_warning = sprintf(
FROM $cache_table 'SELECT tma.id_grupo, COUNT(tma.id_agente) AS agents_warning
WHERE disabled = 0 FROM tmetaconsole_agent tma
AND id_grupo IN ($user_groups_ids) LEFT JOIN tmetaconsole_agent_secondary_group tmasg
AND critical_count = 0 ON tma.id_agente = tmasg.id_agent
AND warning_count > 0 WHERE tma.disabled = 0
GROUP BY id_grupo"; AND (tma.id_grupo IN (%s) OR tmasg.id_group IN (%s))
AND tma.critical_count = 0
AND tma.warning_count > 0
GROUP BY tma.id_grupo',
$user_groups_ids,
$user_groups_ids
);
$data_stats_warning = db_get_all_rows_sql($sql_stats_warning); $data_stats_warning = db_get_all_rows_sql($sql_stats_warning);
$sql_stats_critical = "SELECT id_grupo, COUNT(id_agente) AS agents_critical $sql_stats_critical = sprintf(
FROM $cache_table 'SELECT tma.id_grupo, COUNT(tma.id_agente) AS agents_critical
WHERE disabled = 0 FROM tmetaconsole_agent tma
AND id_grupo IN ($user_groups_ids) LEFT JOIN tmetaconsole_agent_secondary_group tmasg
AND critical_count > 0 ON tma.id_agente = tmasg.id_agent
GROUP BY id_grupo"; WHERE tma.disabled = 0
AND (tma.id_grupo IN (%s) OR tmasg.id_group IN (%s))
AND tma.critical_count > 0
GROUP BY tma.id_grupo',
$user_groups_ids,
$user_groups_ids
);
$data_stats_critical = db_get_all_rows_sql($sql_stats_critical); $data_stats_critical = db_get_all_rows_sql($sql_stats_critical);
if (!empty($data_stats)) { if (!empty($data_stats)) {
@ -292,7 +347,7 @@ function tactical_get_data($id_user=false, $user_strict=false, $acltags, $return
$list['_total_agents_'] = $total_agentes[0]['total_agents']; $list['_total_agents_'] = $total_agentes[0]['total_agents'];
$list['_monitor_alerts_fire_count_'] = $group_stat[0]['alerts_fired']; $list['_monitor_alerts_fire_count_'] = $group_stat[0]['alerts_fired'];
$list['_monitors_alerts_'] = tactical_monitor_alerts(explode(',', $user_groups_ids), $user_strict, explode(',', $user_groups_ids)); $list['_monitors_alerts_'] = tactical_monitor_alerts($user_strict);
// Get total count of monitors for this group, except disabled. // Get total count of monitors for this group, except disabled.
$list['_monitor_checks_'] = ($list['_monitors_not_init_'] + $list['_monitors_unknown_'] + $list['_monitors_warning_'] + $list['_monitors_critical_'] + $list['_monitors_ok_']); $list['_monitor_checks_'] = ($list['_monitors_not_init_'] + $list['_monitors_unknown_'] + $list['_monitors_warning_'] + $list['_monitors_critical_'] + $list['_monitors_ok_']);
@ -411,12 +466,14 @@ function tactical_get_data($id_user=false, $user_strict=false, $acltags, $return
} }
$list['_monitors_alerts_fired_'] = tactical_monitor_fired_alerts(explode(',', $user_groups_ids), $user_strict, explode(',', $user_groups_ids)); $list['_monitors_alerts_fired_'] = tactical_monitor_fired_alerts(explode(',', $user_groups_ids), $user_strict, explode(',', $user_groups_ids));
$list['_monitors_alerts_'] = tactical_monitor_alerts(explode(',', $user_groups_ids), $user_strict, explode(',', $user_groups_ids)); $list['_monitors_alerts_'] = tactical_monitor_alerts($user_strict);
$total_agentes = agents_get_agents(false, ['count(DISTINCT id_agente) as total_agents'], 'AR', false, false, 1); $total_agentes = agents_get_agents(false, ['count(DISTINCT id_agente) as total_agents'], 'AR', false, false, 1);
$list['_total_agents_'] = $total_agentes[0]['total_agents']; $list['_total_agents_'] = $total_agentes[0]['total_agents'];
$list['_monitor_checks_'] = ($list['_monitors_not_init_'] + $list['_monitors_unknown_'] + $list['_monitors_warning_'] + $list['_monitors_critical_'] + $list['_monitors_ok_']);
$list['_monitor_total_'] = ($list['_monitors_not_init_'] + $list['_monitors_unknown_'] + $list['_monitors_warning_'] + $list['_monitors_critical_'] + $list['_monitors_ok_']); $list['_monitor_total_'] = ($list['_monitors_not_init_'] + $list['_monitors_unknown_'] + $list['_monitors_warning_'] + $list['_monitors_critical_'] + $list['_monitors_ok_']);
$list['_monitor_checks_'] = ($list['_monitors_unknown_'] + $list['_monitors_warning_'] + $list['_monitors_critical_'] + $list['_monitors_ok_']);
// Calculate not_normal monitors // Calculate not_normal monitors
$list['_monitor_not_normal_'] = ($list['_monitor_checks_'] - $list['_monitors_ok_']); $list['_monitor_not_normal_'] = ($list['_monitor_checks_'] - $list['_monitors_ok_']);
@ -442,42 +499,33 @@ function tactical_status_modules_agents($id_user=false, $user_strict=false, $acc
} }
function tactical_monitor_alerts($group_array, $strict_user=false, $id_group_strict=false) function tactical_monitor_alerts($strict_user=false)
{ {
// If there are not groups to query, we jump to nextone $groups = users_get_groups($config['id_user'], 'AR', false);
if (empty($group_array)) { $id_groups = array_keys($groups);
return 0;
} else if (!is_array($group_array)) {
$group_array = [$group_array];
}
$group_clause = implode(',', $group_array); if (empty($id_groups)) {
$group_clause = '('.$group_clause.')'; $where_clause .= ' AND (1 = 0) ';
if ($strict_user) {
$group_clause_strict = implode(',', $id_group_strict);
$group_clause_strict = '('.$group_clause_strict.')';
$sql = "SELECT COUNT(talert_template_modules.id)
FROM talert_template_modules, tagente_modulo, tagente_estado, tagente
WHERE tagente.id_grupo IN $group_clause_strict AND tagente_modulo.id_agente = tagente.id_agente
AND tagente.disabled = 0 AND tagente_modulo.disabled = 0
AND talert_template_modules.disabled = 0
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo";
$count = db_get_sql($sql);
return $count;
} else { } else {
// TODO REVIEW ORACLE AND POSTGRES $where_clause .= sprintf(
return db_get_sql( ' AND id_agent_module IN (
"SELECT COUNT(talert_template_modules.id) SELECT tam.id_agente_modulo
FROM talert_template_modules, tagente_modulo, tagente_estado, tagente FROM tagente_modulo tam
WHERE tagente.id_grupo IN $group_clause AND tagente_modulo.id_agente = tagente.id_agente WHERE tam.id_agente IN (SELECT ta.id_agente
AND tagente.disabled = 0 AND tagente_modulo.disabled = 0 FROM tagente ta LEFT JOIN tagent_secondary_group tasg ON
AND talert_template_modules.disabled = 0 ta.id_agente = tasg.id_agent
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo WHERE (ta.id_grupo IN (%s) OR tasg.id_group IN (%s)))) ',
AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo" implode(',', $id_groups),
implode(',', $id_groups)
); );
} }
$filter_alert = [];
$filter_alert['disabled'] = 'all_enabled';
$alert_count = get_group_alerts($id_groups, $filter_alert, false, $where_clause, false, false, false, true, $strict_user);
return $alert_count;
} }

View File

@ -3591,7 +3591,7 @@ function ui_print_datatable(array $parameters)
// Order. // Order.
$err_msg = '<div id="error-'.$table_id.'"></div>'; $err_msg = '<div id="error-'.$table_id.'"></div>';
$output = $err_msg.$filter.$extra.$table.$js; $output = $err_msg.$filter.$extra.$table.$js;
if (is_ajax() === false) {
ui_require_css_file('datatables.min', 'include/styles/js/'); ui_require_css_file('datatables.min', 'include/styles/js/');
ui_require_css_file('tables'); ui_require_css_file('tables');
if (is_metaconsole()) { if (is_metaconsole()) {
@ -3603,6 +3603,74 @@ function ui_print_datatable(array $parameters)
ui_require_javascript_file('dataTables.buttons.min'); ui_require_javascript_file('dataTables.buttons.min');
ui_require_javascript_file('buttons.html5.min'); ui_require_javascript_file('buttons.html5.min');
ui_require_javascript_file('buttons.print.min'); ui_require_javascript_file('buttons.print.min');
} else {
// Load tables.css.
$output .= '<link rel="stylesheet" href="';
$output .= ui_get_full_url(
'include/styles/tables.css',
false,
false,
false
);
$output .= '"/>';
if (is_metaconsole() === true) {
// Load tables_meta.css.
$output .= '<link rel="stylesheet" href="';
$output .= ui_get_full_url(
ENTERPRISE_DIR.'/include/styles/tables_meta.css',
false,
false,
false
);
$output .= '"/>';
}
// Load datatables.js.
$output .= '<script src="';
$output .= ui_get_full_url(
'include/javascript/datatables.min.js',
false,
false,
false
);
$output .= '" type="text/javascript"></script>';
// Load buttons.dataTables.min.js.
$output .= '<script src="';
$output .= ui_get_full_url(
'include/javascript/buttons.dataTables.min.js',
false,
false,
false
);
$output .= '" type="text/javascript"></script>';
// Load dataTables.buttons.min.js.
$output .= '<script src="';
$output .= ui_get_full_url(
'include/javascript/dataTables.buttons.min.js',
false,
false,
false
);
$output .= '" type="text/javascript"></script>';
// Load buttons.html5.min.js.
$output .= '<script src="';
$output .= ui_get_full_url(
'include/javascript/buttons.html5.min.js',
false,
false,
false
);
$output .= '" type="text/javascript"></script>';
// Load buttons.print.min.js.
$output .= '<script src="';
$output .= ui_get_full_url(
'include/javascript/buttons.print.min.js',
false,
false,
false
);
$output .= '" type="text/javascript"></script>';
}
if (isset($parameters['return']) && $parameters['return'] == true) { if (isset($parameters['return']) && $parameters['return'] == true) {
// Compat. // Compat.

View File

@ -301,6 +301,7 @@ function users_get_groups(
$search='' $search=''
) { ) {
static $group_cache = []; static $group_cache = [];
$filter = ''; $filter = '';
// Added users_group_cache to avoid unnecessary proccess on massive calls... // Added users_group_cache to avoid unnecessary proccess on massive calls...
@ -342,13 +343,6 @@ function users_get_groups(
$query = 'SELECT * FROM tgrupo ORDER BY nombre'; $query = 'SELECT * FROM tgrupo ORDER BY nombre';
$raw_groups = db_get_all_rows_sql($query); $raw_groups = db_get_all_rows_sql($query);
if (empty($search) === false) {
$filter = sprintf(
' AND lower(tgrupo.nombre) like lower("%%%s%%")',
$search
);
}
$query = sprintf( $query = sprintf(
"SELECT tgrupo.*, tperfil.*, tusuario_perfil.tags, tusuario_perfil.no_hierarchy FROM tgrupo, tusuario_perfil, tperfil "SELECT tgrupo.*, tperfil.*, tusuario_perfil.tags, tusuario_perfil.no_hierarchy FROM tgrupo, tusuario_perfil, tperfil
WHERE (tgrupo.id_grupo = tusuario_perfil.id_grupo OR tusuario_perfil.id_grupo = 0) WHERE (tgrupo.id_grupo = tusuario_perfil.id_grupo OR tusuario_perfil.id_grupo = 0)
@ -451,6 +445,16 @@ function users_get_groups(
} }
} }
// Search filter.
if (empty($search) === false) {
$user_groups = array_filter(
$user_groups,
function ($group) use ($search) {
return (bool) preg_match('/'.$search.'/i', $group['nombre']);
}
);
}
$users_group_cache[$users_group_cache_key] = $user_groups; $users_group_cache[$users_group_cache_key] = $user_groups;
return $user_groups; return $user_groups;

View File

@ -1,5 +1,4 @@
/* globals $ */ /* globals $ confirmDialog uniqId showMsg*/
function parse_alert_command(command, classs) { function parse_alert_command(command, classs) {
if (classs == "recovery") { if (classs == "recovery") {
classs = "fields_recovery"; classs = "fields_recovery";
@ -36,21 +35,64 @@ function parse_alert_command(command, classs) {
return command; return command;
} }
// eslint-disable-next-line no-unused-vars
function render_command_preview(original_command) { function render_command_preview(original_command) {
$("#textarea_command_preview").html( $("#textarea_command_preview").html(
parse_alert_command(original_command, "") parse_alert_command(original_command, "")
); );
} }
// eslint-disable-next-line no-unused-vars
function render_command_recovery_preview(original_command) { function render_command_recovery_preview(original_command) {
$("#textarea_command_recovery_preview").html( $("#textarea_command_recovery_preview").html(
parse_alert_command(original_command, "recovery") parse_alert_command(original_command, "recovery")
); );
} }
// eslint-disable-next-line no-unused-vars
function render_command_description(command_description) { function render_command_description(command_description) {
if (command_description != "") { if (command_description != "") {
command_description = "<br>" + command_description; command_description = "<br>" + command_description;
} }
$("#command_description").html(command_description); $("#command_description").html(command_description);
} }
// eslint-disable-next-line no-unused-vars
function load_templates_alerts_special_days(settings) {
confirmDialog({
title: settings.title,
message: function() {
var id = "div-" + uniqId();
$.ajax({
method: "post",
url: settings.url,
data: {
page: settings.page,
method: "drawAlertTemplates",
date: settings.date,
id_group: settings.id_group,
day_code: settings.day_code,
id_calendar: settings.id_calendar
},
datatype: "html",
success: function(data) {
$("#" + id)
.empty()
.html(data);
},
error: function(e) {
showMsg(e);
}
});
return "<div id ='" + id + "'>" + settings.loading + "</div>";
},
ok: settings.btn_ok_text,
cancel: settings.btn_cancel_text,
onAccept: function() {
$("#" + settings.name_form).submit();
},
size: 750,
maxHeight: 500
});
}

View File

@ -0,0 +1,274 @@
<?php
// phpcs:disable Squiz.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Calendar entity class.
*
* @category Class
* @package Pandora FMS
* @subpackage OpenSource
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation 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.
namespace PandoraFMS;
/**
* PandoraFMS agent entity.
*/
class Calendar extends Entity
{
/**
* Search Calendar.
*
* @param array $filter Filters.
*
* @return array Rows.
*/
public static function search(array $filter)
{
$table = '`talert_calendar`';
$rows = \db_get_all_rows_filter(
$table,
$filter,
['`talert_calendar`.*']
);
return $rows;
}
/**
* Builds a PandoraFMS\Calendar object from given id.
*
* @param integer $id Id special day.
*/
public function __construct(?int $id=null)
{
$table = 'talert_calendar';
$filter = ['id' => $id];
$this->existsInDB = false;
if (is_numeric($id) === true
&& $id > 0
) {
parent::__construct(
$table,
$filter,
null,
false
);
$this->existsInDB = true;
} else {
// Create empty skel.
parent::__construct($table, null);
}
}
/**
* Saves current definition to database.
*
* @return mixed Affected rows of false in case of error.
* @throws \Exception On error.
*/
public function save()
{
if ($this->fields['id'] > 0) {
// Update.
$updates = $this->fields;
$rs = \db_process_sql_update(
$this->table,
$updates,
['id' => $this->fields['id']]
);
if ($rs === false) {
global $config;
throw new \Exception(
__METHOD__.' error: '.$config['dbconnection']->error
);
}
} else {
// Creation.
$inserts = $this->fields;
// Clean null fields.
foreach ($inserts as $k => $v) {
if ($v === null) {
unset($inserts[$k]);
}
}
$rs = \db_process_sql_insert(
$this->table,
$inserts
);
if ($rs === false) {
global $config;
throw new \Exception(
__METHOD__.' error: '.$config['dbconnection']->error
);
}
$this->fields['id'] = $rs;
}
return true;
}
/**
* Remove this calendar.
*
* @return void
*/
public function delete()
{
if ($this->existsInDB === true) {
\db_process_delete_temp(
$this->table,
'id',
$this->fields['id']
);
}
}
/**
* Returns an array with all calendar filtered.
*
* @param array $fields Fields array or 'count' keyword to retrieve count.
* @param array $filter Filters to be applied.
* @param boolean $count Retrieve count of items instead results.
* @param integer $offset Offset (pagination).
* @param integer $limit Limit (pagination).
* @param string $order Sort order.
* @param string $sort_field Sort field.
* @param boolean $select_options Array options for select.
*
* @return array With all results.
* @throws \Exception On error.
*/
public static function calendars(
array $fields=[ '`talert_calendar`.*' ],
array $filter=[],
bool $count=false,
?int $offset=null,
?int $limit=null,
?string $order=null,
?string $sort_field=null,
?bool $select_options=false
) {
$sql_filters = [];
$order_by = '';
$pagination = '';
if (isset($filter['free_search']) === true
&& empty($filter['free_search']) === false
) {
$sql_filters[] = vsprintf(
' AND (`talert_calendar`.`name` like "%%%s%%"
OR `talert_calendar`.`description` like "%%%s%%")',
array_fill(0, 2, $filter['free_search'])
);
}
if (isset($order) === true) {
$dir = 'asc';
if ($order === 'desc') {
$dir = 'desc';
};
if (in_array(
$sort_field,
[ 'name' ]
) === true
) {
$order_by = sprintf(
'ORDER BY `talert_calendar`.`%s` %s',
$sort_field,
$dir
);
} else {
// Custom field order.
$order_by = sprintf(
'ORDER BY `%s` %s',
$sort_field,
$dir
);
}
}
if (isset($limit) === true && $limit > 0
&& isset($offset) === true && $offset >= 0
) {
$pagination = sprintf(
' LIMIT %d OFFSET %d ',
$limit,
$offset
);
}
$sql = sprintf(
'SELECT %s
FROM `talert_calendar`
WHERE 1=1
%s
%s
%s',
join(',', $fields),
join(' ', $sql_filters),
$order_by,
$pagination
);
if ($count === true) {
$sql = sprintf('SELECT count(*) as n FROM ( %s ) tt', $sql);
return ['count' => \db_get_value_sql($sql)];
}
$return = \db_get_all_rows_sql($sql);
if (is_array($return) === false) {
return [];
}
if ($select_options === true) {
$return = array_reduce(
$return,
function ($carry, $item) {
$carry[$item['id']] = $item['name'];
return $carry;
}
);
}
return $return;
}
}

View File

@ -519,8 +519,6 @@ class EventsListWidget extends Widget
} }
} }
$hours = ($this->values['maxHours'] * SECONDS_1HOUR);
// Put hours in seconds. // Put hours in seconds.
$filter = []; $filter = [];
$order = []; $order = [];
@ -546,7 +544,7 @@ class EventsListWidget extends Widget
} }
} else { } else {
// Filtering. // Filtering.
$filter['event_view_hr'] = $hours; $filter['event_view_hr'] = $this->values['maxHours'];
// Group. // Group.
$filter['id_group_filter'] = $this->values['groupId']; $filter['id_group_filter'] = $this->values['groupId'];

View File

@ -0,0 +1,310 @@
<?php
// phpcs:disable Squiz.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Special day entity class.
*
* @category Class
* @package Pandora FMS
* @subpackage OpenSource
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation 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.
namespace PandoraFMS;
/**
* PandoraFMS agent entity.
*/
class SpecialDay extends Entity
{
/**
* Builds a PandoraFMS\SpecialDay object from given id.
*
* @param integer $id Id special day.
*/
public function __construct(?int $id=null)
{
$table = 'talert_special_days';
$filter = ['id' => $id];
$this->existsInDB = false;
if (is_numeric($id) === true
&& $id > 0
) {
parent::__construct(
$table,
$filter,
null,
false
);
$this->existsInDB = true;
} else {
// Create empty skel.
parent::__construct($table, null);
}
}
/**
* Saves current definition to database.
*
* @return mixed Affected rows of false in case of error.
* @throws \Exception On error.
*/
public function save()
{
if ($this->fields['id'] > 0) {
// Update.
$updates = $this->fields;
$rs = \db_process_sql_update(
$this->table,
$updates,
['id' => $this->fields['id']]
);
if ($rs === false) {
global $config;
throw new \Exception(
__METHOD__.' error: '.$config['dbconnection']->error
);
}
} else {
// Creation.
$inserts = $this->fields;
// Clean null fields.
foreach ($inserts as $k => $v) {
if ($v === null) {
unset($inserts[$k]);
}
}
$rs = \db_process_sql_insert(
$this->table,
$inserts
);
if ($rs === false) {
global $config;
throw new \Exception(
__METHOD__.' error: '.$config['dbconnection']->error
);
}
$this->fields['id'] = $rs;
}
return true;
}
/**
* Remove this Special day.
*
* @return void
*/
public function delete()
{
if ($this->existsInDB === true) {
\db_process_delete_temp(
$this->table,
'id',
$this->fields['id']
);
}
}
/**
* Returns an array with all special days filtered.
*
* @param array $fields Fields array or 'count' keyword to retrieve count.
* @param array $filter Filters to be applied.
* @param boolean $count Retrieve count of items instead results.
* @param integer $offset Offset (pagination).
* @param integer $limit Limit (pagination).
* @param string $order Sort order.
* @param string $sort_field Sort field.
* @param boolean $reduce Reduce result [Year][month][day].
*
* @return array With all results.
* @throws \Exception On error.
*/
public static function specialDays(
array $fields=[ '`talert_special_days`.*' ],
array $filter=[],
bool $count=false,
?int $offset=null,
?int $limit=null,
?string $order=null,
?string $sort_field=null,
?bool $reduce=false
) {
$sql_filters = [];
$order_by = '';
$pagination = '';
if (isset($filter['free_search']) === true
&& empty($filter['free_search']) === false
) {
$sql_filters[] = vsprintf(
' AND `talert_special_days`.`name` like "%%%s%%"',
array_fill(0, 1, $filter['free_search'])
);
}
if (isset($filter['id_calendar']) === true
&& empty($filter['id_calendar']) === false
) {
$sql_filters[] = sprintf(
' AND `talert_special_days`.`id_calendar` = %d',
$filter['id_calendar']
);
}
if (isset($filter['date']) === true
&& empty($filter['date']) === false
) {
$sql_filters[] = sprintf(
' AND `talert_special_days`.`date` >= "%s"',
$filter['date']
);
}
if (isset($filter['futureDate']) === true
&& empty($filter['futureDate']) === false
) {
$sql_filters[] = sprintf(
' AND `talert_special_days`.`date` <= "%s"',
$filter['futureDate']
);
}
if (isset($filter['id_group']) === true
&& empty($filter['id_group']) === false
) {
$sql_filters[] = sprintf(
' AND `talert_special_days`.`id_group` IN ("%s")',
implode(',', $filter['id_group'])
);
}
if (isset($filter['date_match']) === true
&& empty($filter['date_match']) === false
) {
$sql_filters[] = sprintf(
' AND `talert_special_days`.`date` = "%s"',
$filter['date_match']
);
}
if (isset($filter['day_code']) === true
&& empty($filter['day_code']) === false
) {
$sql_filters[] = sprintf(
' AND `talert_special_days`.`day_code` = %d',
$filter['day_code']
);
}
if (isset($order) === true) {
$dir = 'asc';
if ($order === 'desc') {
$dir = 'desc';
};
if (in_array(
$sort_field,
[ 'name' ]
) === true
) {
$order_by = sprintf(
'ORDER BY `talert_special_days`.`%s` %s',
$sort_field,
$dir
);
} else {
// Custom field order.
$order_by = sprintf(
'ORDER BY `%s` %s',
$sort_field,
$dir
);
}
}
if (isset($limit) === true && $limit > 0
&& isset($offset) === true && $offset >= 0
) {
$pagination = sprintf(
' LIMIT %d OFFSET %d ',
$limit,
$offset
);
}
$sql = sprintf(
'SELECT %s
FROM `talert_special_days`
WHERE 1=1
%s
%s
%s',
join(',', $fields),
join(' ', $sql_filters),
$order_by,
$pagination
);
if ($count === true) {
$sql = sprintf('SELECT count(*) as n FROM ( %s ) tt', $sql);
return ['count' => \db_get_value_sql($sql)];
}
$return = \db_get_all_rows_sql($sql);
if (is_array($return) === false) {
return [];
}
if ($reduce === true) {
$return = array_reduce(
$return,
function ($carry, $item) {
$year = date('Y', strtotime($item['date']));
$month = date('n', strtotime($item['date']));
$day = date('j', strtotime($item['date']));
$carry[$year][$month][$day][] = $item;
return $carry;
}
);
}
return $return;
}
}

View File

@ -292,3 +292,54 @@ div#rules.show {
#rules select.click-list-elements:focus { #rules select.click-list-elements:focus {
outline-color: transparent; outline-color: transparent;
} }
#icalendar-special-days {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: space-between;
align-items: center;
background-color: #fff;
border: 1px solid #e1e1e1;
border-radius: 5px;
padding: 20px 50px;
}
#icalendar-special-days ul.wizard {
flex: 0;
}
#icalendar-special-days ul.wizard:first-child {
flex: 1 1 100%;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: space-between;
align-items: center;
margin-right: 80px;
}
.note-special-day {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
align-content: center;
}
.note-special-day div {
display: flex;
flex-direction: row;
align-items: center;
align-content: center;
}
.note-special-day div a.tip {
margin: 0px;
margin-right: 2px;
}
.note-special-day div a.tip > img {
margin: 0px;
}

View File

@ -3279,6 +3279,13 @@ td.empty_field {
width: 96%; width: 96%;
} }
#update_action-
> .select2-container--default
.select2-results
> .select2-results__options {
max-height: 125px !important;
}
/* Policies styles */ /* Policies styles */
table#policy_modules td * { table#policy_modules td * {

View File

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

View File

@ -479,7 +479,7 @@ if ($load_filter_id === 0) {
// Do not load the user filter if we come from the 24h event graph. // Do not load the user filter if we come from the 24h event graph.
$from_event_graph = get_parameter('filter[from_event_graph]', $filter['from_event_graph']); $from_event_graph = get_parameter('filter[from_event_graph]', $filter['from_event_graph']);
if ($loaded_filter !== false && $from_event_graph != 1) { if ($loaded_filter !== false && $from_event_graph != 1 && !isset($fb64)) {
$filter = events_get_event_filter($loaded_filter['id_filter']); $filter = events_get_event_filter($loaded_filter['id_filter']);
if ($filter !== false) { if ($filter !== false) {
$id_group = $filter['id_group']; $id_group = $filter['id_group'];

View File

@ -78,6 +78,10 @@ $integria_types_csv = integria_api_call(null, null, null, null, 'get_types');
get_array_from_csv_data_pair($integria_types_csv, $integria_types_values); get_array_from_csv_data_pair($integria_types_csv, $integria_types_values);
$integria_resolution_csv = integria_api_call(null, null, null, null, 'get_incidents_resolutions');
get_array_from_csv_data_pair($integria_resolution_csv, $integria_resolution_values);
$event_id = (int) get_parameter('from_event'); $event_id = (int) get_parameter('from_event');
$incident_id_edit = (int) get_parameter('incident_id'); $incident_id_edit = (int) get_parameter('incident_id');
$create_incident = (bool) get_parameter('create_incident', 0); $create_incident = (bool) get_parameter('create_incident', 0);
@ -88,6 +92,7 @@ $incident_owner = get_parameter('owner');
$incident_type = (int) get_parameter('type'); $incident_type = (int) get_parameter('type');
$incident_creator = get_parameter('creator'); $incident_creator = get_parameter('creator');
$incident_status = (int) get_parameter('status'); $incident_status = (int) get_parameter('status');
$incident_resolution = (int) get_parameter('resolution');
$incident_title = events_get_field_value_by_event_id($event_id, get_parameter('incident_title')); $incident_title = events_get_field_value_by_event_id($event_id, get_parameter('incident_title'));
$incident_content = events_get_field_value_by_event_id($event_id, get_parameter('incident_content')); $incident_content = events_get_field_value_by_event_id($event_id, get_parameter('incident_content'));
$file_description = get_parameter('file_description'); $file_description = get_parameter('file_description');
@ -98,8 +103,13 @@ $incident_content = str_replace(',', ':::', $incident_content);
// Perform action. // Perform action.
if ($create_incident === true) { if ($create_incident === true) {
// Disregard incident resolution unless status is 'closed'.
if ($incident_status !== 7) {
$incident_resolution = 0;
}
// Call Integria IMS API method to create an incident. // Call Integria IMS API method to create an incident.
$result_api_call = integria_api_call(null, null, null, null, 'create_incident', [$incident_title, $incident_group_id, $incident_criticity_id, $incident_content, '', $incident_type, '', $incident_owner, '0', $incident_status], false, '', ','); $result_api_call = integria_api_call(null, null, null, null, 'create_incident', [$incident_title, $incident_group_id, $incident_criticity_id, $incident_content, '', $incident_type, '', $incident_owner, '0', $incident_status, '', $incident_resolution], false, '', ',');
if ($userfile !== '' && $result_api_call !== false) { if ($userfile !== '' && $result_api_call !== false) {
integriaims_upload_file('userfile', $result_api_call, $file_description); integriaims_upload_file('userfile', $result_api_call, $file_description);
@ -114,8 +124,13 @@ if ($create_incident === true) {
__('Could not be created in Integria IMS') __('Could not be created in Integria IMS')
); );
} else if ($update_incident === true) { } else if ($update_incident === true) {
// Disregard incident resolution unless status is 'closed'.
if ($incident_status !== 7) {
$incident_resolution = 0;
}
// Call Integria IMS API method to update an incident. // Call Integria IMS API method to update an incident.
$result_api_call = integria_api_call(null, null, null, null, 'update_incident', [$incident_id_edit, $incident_title, $incident_content, '', $incident_group_id, $incident_criticity_id, 0, $incident_status, $incident_owner, 0, $incident_type], false, '', ','); $result_api_call = integria_api_call(null, null, null, null, 'update_incident', [$incident_id_edit, $incident_title, $incident_content, '', $incident_group_id, $incident_criticity_id, $incident_resolution, $incident_status, $incident_owner, 0, $incident_type], false, '', ',');
if ($userfile !== '') { if ($userfile !== '') {
integriaims_upload_file('userfile', $incident_id_edit, $file_description); integriaims_upload_file('userfile', $incident_id_edit, $file_description);
@ -161,8 +176,8 @@ $table->style[0] = 'width: 33%; padding-right: 50px; padding-left: 100px;';
$table->style[1] = 'width: 33%; padding-right: 50px; padding-left: 50px;'; $table->style[1] = 'width: 33%; padding-right: 50px; padding-left: 50px;';
$table->style[2] = 'width: 33%; padding-right: 100px; padding-left: 50px;'; $table->style[2] = 'width: 33%; padding-right: 100px; padding-left: 50px;';
$table->colspan[0][0] = 2; $table->colspan[0][0] = 2;
$table->colspan[3][0] = 3; $table->colspan[4][0] = 3;
$table->colspan[5][0] = 3; $table->colspan[6][0] = 3;
$help_macros = isset($_GET['from_event']) ? ui_print_help_icon('response_macros', true) : ''; $help_macros = isset($_GET['from_event']) ? ui_print_help_icon('response_macros', true) : '';
@ -174,6 +189,7 @@ if ($update) {
$input_value_criticity = $incident_details[7]; $input_value_criticity = $incident_details[7];
$input_value_owner = $incident_details[5]; $input_value_owner = $incident_details[5];
$input_value_content = $incident_details[4]; $input_value_content = $incident_details[4];
$input_value_resolution = $incident_details[12];
} else if (isset($_GET['from_event'])) { } else if (isset($_GET['from_event'])) {
$input_value_title = $config['cr_incident_title']; $input_value_title = $config['cr_incident_title'];
$input_value_type = $config['cr_incident_type']; $input_value_type = $config['cr_incident_type'];
@ -182,6 +198,7 @@ if ($update) {
$input_value_criticity = $config['cr_default_criticity']; $input_value_criticity = $config['cr_default_criticity'];
$input_value_owner = $config['cr_default_owner']; $input_value_owner = $config['cr_default_owner'];
$input_value_content = $config['cr_incident_content']; $input_value_content = $config['cr_incident_content'];
$input_value_resolution = 0;
} else { } else {
$input_value_title = ''; $input_value_title = '';
$input_value_type = ''; $input_value_type = '';
@ -190,6 +207,7 @@ if ($update) {
$input_value_criticity = ''; $input_value_criticity = '';
$input_value_owner = ''; $input_value_owner = '';
$input_value_content = ''; $input_value_content = '';
$input_value_resolution = 0;
} }
$table->data[0][0] = '<div class="label_select"><p class="input_label">'.__('Title').':&nbsp'.$help_macros.'</p>'; $table->data[0][0] = '<div class="label_select"><p class="input_label">'.__('Title').':&nbsp'.$help_macros.'</p>';
@ -303,8 +321,26 @@ $table->data[2][2] .= '<div class="label_select_parent">'.html_print_autocomplet
'w100p' 'w100p'
).'</div>'; ).'</div>';
$table->data[3][0] = '<div class="label_select"><p class="input_label">'.__('Description').':&nbsp'.$help_macros.'</p>';
$table->data[3][0] .= '<div class="label_select_parent">'.html_print_textarea( $table->data[3][0] = '<div class="label_select"><p class="input_label">'.__('Resolution').': </p>';
$table->data[3][0] .= '<div class="label_select_parent">'.html_print_select(
$integria_resolution_values,
'resolution',
$input_value_resolution,
'',
'',
1,
true,
false,
true,
'',
false,
'width: 100%;'
).'</div>';
$table->data[4][0] = '<div class="label_select"><p class="input_label">'.__('Description').':&nbsp'.$help_macros.'</p>';
$table->data[4][0] .= '<div class="label_select_parent">'.html_print_textarea(
'incident_content', 'incident_content',
3, 3,
20, 20,
@ -313,10 +349,10 @@ $table->data[3][0] .= '<div class="label_select_parent">'.html_print_textarea(
true true
).'</div>'; ).'</div>';
$table->data[4][0] = '<div class="label_select"><p class="input_label">'.__('File name').':</p>'; $table->data[5][0] = '<div class="label_select"><p class="input_label">'.__('File name').':</p>';
$table->data[4][0] .= html_print_input_file('userfile', true); $table->data[5][0] .= html_print_input_file('userfile', true);
$table->data[5][0] = '<div class="label_select"><p class="input_label">'.__('Attachment description').':</p>'; $table->data[6][0] = '<div class="label_select"><p class="input_label">'.__('Attachment description').':</p>';
$table->data[5][0] .= html_print_textarea( $table->data[6][0] .= html_print_textarea(
'file_description', 'file_description',
3, 3,
20, 20,
@ -345,3 +381,32 @@ if ($update) {
} }
echo '</div>'; echo '</div>';
?>
<script type="text/javascript">
$(document).ready(function () {
$('#add_alert_table-3').hide();
var input_value_status =
<?php
$status_value = ($input_value_status === '') ? 0 : $input_value_status;
echo $status_value;
?>
;
if (input_value_status === 7) {
$('#add_alert_table-3').show();
} else {
$('#add_alert_table-3').hide();
}
$('#status').on('change', function() {
if ($(this).val() === '7') {
$('#add_alert_table-3').show();
} else {
$('#add_alert_table-3').hide();
}
});
});
</script>

View File

@ -220,7 +220,7 @@ if (check_acl($config['id_user'], 0, 'VR') || check_acl($config['id_user'], 0, '
$name = io_safe_output($layout['name']); $name = io_safe_output($layout['name']);
$sub2['operation/visual_console/render_view&amp;id='.$layout['id']]['text'] = mb_substr($name, 0, 19); $sub2['operation/visual_console/render_view&amp;id='.$layout['id']]['text'] = ui_print_truncate_text($name, MENU_SIZE_TEXT, false, true, false);
$sub2['operation/visual_console/render_view&amp;id='.$layout['id']]['id'] = mb_substr($name, 0, 19); $sub2['operation/visual_console/render_view&amp;id='.$layout['id']]['id'] = mb_substr($name, 0, 19);
$sub2['operation/visual_console/render_view&amp;id='.$layout['id']]['title'] = $name; $sub2['operation/visual_console/render_view&amp;id='.$layout['id']]['title'] = $name;
if (!empty($config['vc_refr'])) { if (!empty($config['vc_refr'])) {
@ -235,7 +235,7 @@ if (check_acl($config['id_user'], 0, 'VR') || check_acl($config['id_user'], 0, '
if ($break_max_console) { if ($break_max_console) {
$sub2['godmode/reporting/visual_console_favorite']['text'] = __('Show more').' >'; $sub2['godmode/reporting/visual_console_favorite']['text'] = __('Show more').' >';
$sub2['godmode/reporting/visual_console_favorite']['id'] = 'visual_favourite_console'; $sub2['godmode/reporting/visual_console_favorite']['id'] = 'visual_favourite_console';
$sub2['godmode/reporting/visual_console_favorite']['title'] = 'show_more'; $sub2['godmode/reporting/visual_console_favorite']['title'] = __('Show more');
$sub2['godmode/reporting/visual_console_favorite']['refr'] = 0; $sub2['godmode/reporting/visual_console_favorite']['refr'] = 0;
} }
@ -281,7 +281,7 @@ if (check_acl($config['id_user'], 0, 'MR') || check_acl($config['id_user'], 0, '
continue; continue;
} }
$sub2['operation/gis_maps/render_view&amp;map_id='.$gisMap['id_tgis_map']]['text'] = mb_substr(io_safe_output($gisMap['map_name']), 0, 15); $sub2['operation/gis_maps/render_view&amp;map_id='.$gisMap['id_tgis_map']]['text'] = ui_print_truncate_text(io_safe_output($gisMap['map_name']), MENU_SIZE_TEXT, false, true, false);
$sub2['operation/gis_maps/render_view&amp;map_id='.$gisMap['id_tgis_map']]['id'] = mb_substr(io_safe_output($gisMap['map_name']), 0, 15); $sub2['operation/gis_maps/render_view&amp;map_id='.$gisMap['id_tgis_map']]['id'] = mb_substr(io_safe_output($gisMap['map_name']), 0, 15);
$sub2['operation/gis_maps/render_view&amp;map_id='.$gisMap['id_tgis_map']]['title'] = io_safe_output($gisMap['map_name']); $sub2['operation/gis_maps/render_view&amp;map_id='.$gisMap['id_tgis_map']]['title'] = io_safe_output($gisMap['map_name']);
$sub2['operation/gis_maps/render_view&amp;map_id='.$gisMap['id_tgis_map']]['refr'] = 0; $sub2['operation/gis_maps/render_view&amp;map_id='.$gisMap['id_tgis_map']]['refr'] = 0;
@ -345,7 +345,7 @@ if (check_acl($config['id_user'], 0, 'RR') || check_acl($config['id_user'], 0, '
$name = io_safe_output($dashboard['name']); $name = io_safe_output($dashboard['name']);
$sub2['operation/dashboard/dashboard&dashboardId='.$dashboard['id']] = [ $sub2['operation/dashboard/dashboard&dashboardId='.$dashboard['id']] = [
'text' => mb_substr($name, 0, 19), 'text' => ui_print_truncate_text($name, MENU_SIZE_TEXT, false, true, false),
'title' => $name, 'title' => $name,
]; ];
} }

View File

@ -208,14 +208,7 @@ if ($searchpolicies === true) {
$sql = "SELECT id, name, description, id_group, status $sql = "SELECT id, name, description, id_group, status
FROM tpolicies FROM tpolicies
WHERE name LIKE '$stringSearchSQL' WHERE name LIKE '$stringSearchSQL'
AND AND id_group IN ($id_user_groups_str)
(id_group IN ($id_user_groups_str)
OR 1 = (
SELECT is_admin
FROM tusuario
WHERE id_user = 'admin'
)
)
"; ";
} }

View File

@ -225,7 +225,7 @@ if ($searchUsers) {
$user_groups = users_get_groups( $user_groups = users_get_groups(
$user['id_user'], $user['id_user'],
'AR', false,
$user_can_manage_all $user_can_manage_all
); );
@ -236,7 +236,6 @@ if ($searchUsers) {
&& $config['id_user'] != $user['id_user'] && $config['id_user'] != $user['id_user']
|| (users_is_admin($config['id_user']) === false || (users_is_admin($config['id_user']) === false
&& users_is_admin($user['id_user']) === true) && users_is_admin($user['id_user']) === true)
|| $config['id_user'] === $user['id_user']
) { ) {
unset($users[$key]); unset($users[$key]);
} else { } else {

View File

@ -2,8 +2,8 @@
# Pandora FMS Console # Pandora FMS Console
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.758 %define version 7.0NG.758.1
%define release 211118 %define release 211124
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -2,8 +2,8 @@
# Pandora FMS Console # Pandora FMS Console
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.758 %define version 7.0NG.758.1
%define release 211118 %define release 211124
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -2,8 +2,8 @@
# Pandora FMS Console # Pandora FMS Console
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.758 %define version 7.0NG.758.1
%define release 211118 %define release 211124
%define httpd_name httpd %define httpd_name httpd
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name apache2 %define httpd_name apache2

View File

@ -9,7 +9,7 @@
# This code is licensed under GPL 2.0 license. # This code is licensed under GPL 2.0 license.
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.758" PI_VERSION="7.0NG.758.1"
FORCE=0 FORCE=0
DESTDIR="" DESTDIR=""
LOG_TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"` LOG_TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"`

View File

@ -266,7 +266,7 @@ CREATE TABLE IF NOT EXISTS `tagente_modulo` (
`prediction_threshold` int(4) default 0, `prediction_threshold` int(4) default 0,
`parent_module_id` int(10) unsigned NOT NULL default 0, `parent_module_id` int(10) unsigned NOT NULL default 0,
`cps` int NOT NULL default 0, `cps` int NOT NULL default 0,
`debug_content` varchar(200), `debug_content` TEXT,
`percentage_critical` tinyint(1) unsigned default '0', `percentage_critical` tinyint(1) unsigned default '0',
`percentage_warning` tinyint(1) unsigned default '0', `percentage_warning` tinyint(1) unsigned default '0',
PRIMARY KEY (`id_agente_modulo`), PRIMARY KEY (`id_agente_modulo`),
@ -572,16 +572,31 @@ CREATE TABLE IF NOT EXISTS `talert_template_module_actions` (
ON DELETE CASCADE ON UPDATE CASCADE ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `talert_calendar`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `talert_calendar` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL default '',
`id_group` INT(10) NOT NULL DEFAULT 0,
`description` text,
PRIMARY KEY (`id`),
UNIQUE (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------------------------------- -- -----------------------------------------------------
-- Table `talert_special_days` -- Table `talert_special_days`
-- ----------------------------------------------------- -- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `talert_special_days` ( CREATE TABLE IF NOT EXISTS `talert_special_days` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_calendar` int(10) unsigned NOT NULL DEFAULT 1,
`id_group` INT(10) NOT NULL DEFAULT 0, `id_group` INT(10) NOT NULL DEFAULT 0,
`date` date NOT NULL DEFAULT '1970-01-01', `date` date NOT NULL DEFAULT '1970-01-01',
`same_day` enum('monday','tuesday','wednesday','thursday','friday','saturday','sunday') NOT NULL DEFAULT 'sunday', `day_code` tinyint(2) NOT NULL,
`description` text, `description` text,
PRIMARY KEY (`id`) PRIMARY KEY (`id`),
FOREIGN KEY (`id_calendar`) REFERENCES talert_calendar(`id`)
ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------------------------------- -- -----------------------------------------------------
@ -3858,6 +3873,7 @@ CREATE TABLE `tagent_repository` (
`arch` ENUM('x64', 'x86') DEFAULT 'x64', `arch` ENUM('x64', 'x86') DEFAULT 'x64',
`version` VARCHAR(10) DEFAULT '', `version` VARCHAR(10) DEFAULT '',
`path` text, `path` text,
`deployment_timeout` INT UNSIGNED DEFAULT 600,
`uploaded_by` VARCHAR(100) DEFAULT '', `uploaded_by` VARCHAR(100) DEFAULT '',
`uploaded` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was uploaded", `uploaded` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was uploaded",
`last_err` text, `last_err` text,

View File

@ -2777,3 +2777,5 @@ INSERT INTO `tncm_script` VALUES
(5,5,'enable&#x0d;&#x0a;expect:Password:&#92;s*&#x0d;&#x0a;_enablepass_&#x0d;&#x0a;term&#x20;length&#x20;0&#x0d;&#x0a;config&#x20;term&#x0d;&#x0a;end&#x0d;&#x0a;end&#x0d;&#x0a;exit&#x0d;&#x0a;'); (5,5,'enable&#x0d;&#x0a;expect:Password:&#92;s*&#x0d;&#x0a;_enablepass_&#x0d;&#x0a;term&#x20;length&#x20;0&#x0d;&#x0a;config&#x20;term&#x0d;&#x0a;end&#x0d;&#x0a;end&#x0d;&#x0a;exit&#x0d;&#x0a;');
INSERT INTO `tncm_template_scripts`(`id_template`, `id_script`) VALUES (1,1),(1,2),(1,3),(1,4),(1,5); INSERT INTO `tncm_template_scripts`(`id_template`, `id_script`) VALUES (1,1),(1,2),(1,3),(1,4),(1,5);
INSERT INTO `talert_calendar` VALUES (1, 'Default', 0, 'Default calendar');

View File

@ -0,0 +1,140 @@
<?php
/**
* Calendar: edit page
*
* @category View
* @package Pandora FMS
* @subpackage Alert
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation 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.
* ============================================================================
*/
// Extras required.
\ui_require_css_file('wizard');
\enterprise_include_once('meta/include/functions_alerts_meta.php');
\enterprise_hook('open_meta_frame');
if (\is_metaconsole() === true) {
\alerts_meta_print_header($tabs);
} else {
// Header.
\ui_print_page_header(
// Title.
__('Calendars Edit'),
// Icon.
'images/gm_alerts.png',
// Return.
false,
// Help.
'alert_special_days',
// Godmode.
true,
// Options.
$tabs
);
}
$is_management_allowed = \is_management_allowed();
if ($is_management_allowed === false) {
if (\is_metaconsole() === false) {
$url_link = '<a target="_blank" href="'.ui_get_meta_url($url).'">';
$url_link .= __('metaconsole');
$url_link .= '</a>';
} else {
$url_link = __('any node');
}
\ui_print_warning_message(
__(
'This node is configured with centralized mode. All alert calendar information is read only. Go to %s to manage it.',
$url_link
)
);
}
if (empty($message) === false) {
echo $message;
}
$inputs = [];
// Name.
$inputs[] = [
'label' => __('Name'),
'arguments' => [
'type' => 'text',
'name' => 'name',
'required' => true,
'value' => $calendar->name(),
],
];
// Group.
$inputs[] = [
'label' => __('Group'),
'arguments' => [
'type' => 'select_groups',
'returnAllGroup' => true,
'name' => 'id_group',
'selected' => $calendar->id_group(),
'required' => true,
],
];
// Description.
$inputs[] = [
'label' => __('Description'),
'arguments' => [
'type' => 'textarea',
'name' => 'description',
'required' => false,
'value' => $calendar->description(),
'rows' => 50,
'columns' => 30,
],
];
if ($is_management_allowed === true) {
// Submit.
$inputs[] = [
'arguments' => [
'name' => 'button',
'label' => (($create === true) ? __('Create') : __('Update')),
'type' => 'submit',
'attributes' => 'class="sub next"',
],
];
}
// Print form.
HTML::printForm(
[
'form' => [
'action' => $url.'&op=edit&action=save&id='.$calendar->id(),
'method' => 'POST',
],
'inputs' => $inputs,
],
false,
true
);
\enterprise_hook('close_meta_frame');

View File

@ -0,0 +1,154 @@
<?php
/**
* Calendar: Calendar list page.
*
* @category View
* @package Pandora FMS
* @subpackage Alert
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation 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.
* ============================================================================
*/
\ui_require_css_file('wizard');
\enterprise_include_once('meta/include/functions_alerts_meta.php');
\enterprise_hook('open_meta_frame');
if (\is_metaconsole() === true) {
\alerts_meta_print_header($tabs);
} else {
// Header.
\ui_print_page_header(
// Title.
__('Calendars'),
// Icon.
'images/gm_alerts.png',
// Return.
false,
// Help.
'alert_special_days',
// Godmode.
true,
// Options.
$tabs
);
}
$is_management_allowed = \is_management_allowed();
if ($is_management_allowed === false) {
if (\is_metaconsole() === false) {
$url_link = '<a target="_blank" href="'.ui_get_meta_url($url).'">';
$url_link .= __('metaconsole');
$url_link .= '</a>';
} else {
$url_link = __('any node');
}
\ui_print_warning_message(
__(
'This node is configured with centralized mode. All alert calendar information is read only. Go to %s to manage it.',
$url_link
)
);
}
if (empty($message) === false) {
echo $message;
}
// Datatables list.
try {
$columns = [
[
'text' => 'id',
'class' => 'invisible',
],
'name',
'id_group',
'description',
[
'text' => 'options',
'class' => 'w150px action_buttons',
],
];
$column_names = [
__('ID'),
__('Name'),
__('Group'),
__('Description'),
__('Options'),
];
$tableId = 'calendar_list';
// Load datatables user interface.
ui_print_datatable(
[
'id' => $tableId,
'class' => 'info_table',
'style' => 'width: 100%',
'columns' => $columns,
'column_names' => $column_names,
'ajax_url' => $ajax_url,
'ajax_data' => ['method' => 'drawListCalendar'],
'no_sortable_columns' => [-1],
'order' => [
'field' => 'id',
'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();
}
if ((bool) check_acl($config['id_user'], 0, 'LM') === true) {
HTML::printForm(
[
'form' => [
'action' => $url.'&op=edit',
'method' => 'POST',
],
'inputs' => [
[
'arguments' => [
'name' => 'button',
'label' => __('Create'),
'type' => 'submit',
'attributes' => 'class="sub next"',
],
],
],
]
);
}
\enterprise_hook('close_meta_frame');

View File

@ -0,0 +1,515 @@
<?php
/**
* Calendar: Calendar list page.
*
* @category View
* @package Pandora FMS
* @subpackage Alert
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation 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;
\ui_require_css_file('wizard');
\enterprise_include_once('meta/include/functions_alerts_meta.php');
\enterprise_hook('open_meta_frame');
if (\is_metaconsole() === true) {
\alerts_meta_print_header($tabs);
} else {
// Header.
\ui_print_page_header(
// Title.
__('Special days'),
// Icon.
'images/gm_alerts.png',
// Return.
false,
// Help.
'alert_special_days',
// Godmode.
true,
// Options.
$tabs
);
}
$is_management_allowed = \is_management_allowed();
if ($is_management_allowed === false) {
if (\is_metaconsole() === false) {
$url_link = '<a target="_blank" href="'.ui_get_meta_url($url).'">';
$url_link .= __('metaconsole');
$url_link .= '</a>';
} else {
$url_link = __('any node');
}
\ui_print_warning_message(
__(
'This node is configured with centralized mode. All alert calendar information is read only. Go to %s to manage it.',
$url_link
)
);
}
if (empty($message) === false) {
echo $message;
}
$inputs = [];
// Name.
$inputs[] = [
'label' => __('iCalendar(.ics) file'),
'arguments' => [
'name' => 'ical_file',
'type' => 'file',
'columns' => 25,
'rows' => 10,
'options' => ['required' => 1],
],
];
$days = [];
$days['monday'] = __('Monday');
$days['tuesday'] = __('Tuesday');
$days['wednesday'] = __('Wednesday');
$days['thursday'] = __('Thursday');
$days['friday'] = __('Friday');
$days['saturday'] = __('Saturday');
$days['sunday'] = __('Sunday');
// Same day of the week.
$inputs[] = [
'label' => __('Same day of the week'),
'arguments' => [
'name' => 'day_code',
'type' => 'select',
'fields' => $days,
],
];
// Group.
$inputs[] = [
'label' => __('Group'),
'arguments' => [
'type' => 'select_groups',
'returnAllGroup' => true,
'name' => 'id_group',
],
];
// Group.
$inputs[] = [
'label' => __('Overwrite').ui_print_help_tip(
__('Check this box, if you want to overwrite existing same days.'),
true
),
'arguments' => [
'type' => 'checkbox',
'name' => 'overwrite',
'id' => 'overwrite',
'disabled_hidden' => true,
],
];
// Submit.
$inputs[] = [
'arguments' => [
'name' => 'button',
'label' => __('Upload'),
'type' => 'submit',
'attributes' => 'class="sub next"',
],
];
if ($is_management_allowed === true) {
// Print form.
HTML::printForm(
[
'form' => [
'action' => $url.'&op=upload_ical&id='.$id_calendar,
'method' => 'POST',
'id' => 'icalendar-special-days',
'enctype' => 'multipart/form-data',
],
'inputs' => $inputs,
],
false
);
}
$this_year = date('Y');
$this_month = date('m');
$filter = [];
if (!is_user_admin($config['id_user'])) {
$filter['id_group'] = array_keys(users_get_groups(false, 'LM'));
}
$url = $url.'&id_calendar='.$id_calendar;
// Show display range.
$html = "<table cellpadding='4' cellspacing='4' width='100%' margin-bottom: 10px;'><tr><td>".__('Display range: ');
if ($display_range) {
$html .= '<a href="'.$url.'">['.__('Default').']</a>&nbsp;&nbsp;';
if ($display_range > 1970) {
$html .= '<a href="'.$url.'&display_range=';
$html .= ($display_range - 1);
$html .= '">&lt;&lt;&nbsp;</a>';
}
$html .= '<a href="'.$url.'&display_range='.$display_range.'" class="bolder">['.$display_range.']</a>';
$html .= '<a href="'.$url.'&display_range=';
$html .= ($display_range + 1);
$html .= '">&nbsp;&gt;&gt;</a>';
} else {
$html .= '<a href="'.$url.'" class="bolder">['.__('Default').']</a>&nbsp;&nbsp;';
$html .= '<a href="'.$url.'&display_range=';
$html .= ($this_year - 1);
$html .= '">&lt;&lt;&nbsp;</a>';
$html .= '<a href="'.$url.'&display_range=';
$html .= $this_year;
$html .= '">[';
$html .= $this_year;
$html .= ']</a>';
$html .= '<a href="'.$url.'&display_range=';
$html .= ($this_year + 1);
$html .= '">&nbsp;&gt;&gt;</a>';
}
$html .= '</td></tr>';
echo $html;
// Show calendar.
for ($month = 1; $month <= 12; $month++) {
if ($display_range) {
$display_month = $month;
$display_year = $display_range;
} else {
$display_month = ($this_month + $month - 1);
$display_year = $this_year;
}
if ($display_month > 12) {
$display_month -= 12;
$display_year++;
}
$cal_table = new stdClass();
$cal_table->width = '100%';
$cal_table->class = 'databox data';
$cal_table->data = [];
$cal_table->head = [];
$cal_table->head[0] = __('Sun');
$cal_table->head[1] = __('Mon');
$cal_table->head[2] = __('Tue');
$cal_table->head[3] = __('Wed');
$cal_table->head[4] = __('Thu');
$cal_table->head[5] = __('Fri');
$cal_table->head[6] = __('Sat');
$cal_table->cellstyle = [];
$cal_table->size = [];
$cal_table->size[0] = '14%';
$cal_table->size[1] = '14%';
$cal_table->size[2] = '14%';
$cal_table->size[3] = '14%';
$cal_table->size[4] = '14%';
$cal_table->size[5] = '14%';
$cal_table->size[6] = '14%';
$cal_table->align = [];
$cal_table->border = '1';
$cal_table->titlestyle = 'text-align:center; font-weight: bold;';
switch ($display_month) {
case 1:
$cal_table->title = __('January');
break;
case 2:
$cal_table->title = __('February');
break;
case 3:
$cal_table->title = __('March');
break;
case 4:
$cal_table->title = __('April');
break;
case 5:
$cal_table->title = __('May');
break;
case 6:
$cal_table->title = __('June');
break;
case 7:
$cal_table->title = __('July');
break;
case 8:
$cal_table->title = __('August');
break;
case 9:
$cal_table->title = __('September');
break;
case 10:
$cal_table->title = __('October');
break;
case 11:
$cal_table->title = __('November');
break;
case 12:
$cal_table->title = __('December');
break;
default:
// Not possible.
break;
}
$cal_table->title .= ' / '.$display_year;
$last_day = date('j', mktime(0, 0, 0, ($display_month + 1), 0, $display_year));
$cal_line = 0;
for ($day = 1; $day < ($last_day + 1); $day++) {
$week = date('w', mktime(0, 0, 0, $display_month, $day, $display_year));
if ($cal_line == 0 && $week != 0 && $day == 1) {
for ($i = 0; $i < $week; $i++) {
$cal_table->cellstyle[$cal_line][$i] = 'font-size: 18px;';
$cal_table->data[$cal_line][$i] = '-';
}
}
if ($week == 0 || $week == 6) {
$cal_table->cellstyle[$cal_line][$week] = 'color: red;';
}
$date = sprintf('%04d-%02d-%02d', $display_year, $display_month, $day);
$date_wildcard = sprintf('0001-%02d-%02d', $display_month, $day);
$cal_table->cellstyle[$cal_line][$week] .= 'font-size: 18px;';
$cal_table->data[$cal_line][$week] = $day.'&nbsp;';
if ($is_management_allowed === true) {
$cal_table->data[$cal_line][$week] .= '<a href="'.$url.'&op=edit&date='.$date.'" title=';
$cal_table->data[$cal_line][$week] .= __('Create');
$cal_table->data[$cal_line][$week] .= '>'.html_print_image(
'images/add_mc.png',
true,
['class' => 'invert_filter']
).'</a>';
}
if (empty($specialDays) === false && isset($specialDays[$display_year][$display_month][$day]) === true) {
$cal_table->data[$cal_line][$week] .= '<br>';
foreach ($specialDays[$display_year][$display_month][$day] as $special_day) {
// Only show description if is filled.
$cal_table->data[$cal_line][$week] .= '<div class="note-special-day">';
$cal_table->data[$cal_line][$week] .= '<div>';
$cal_table->data[$cal_line][$week] .= ui_print_group_icon(
$special_day['id_group'],
true
);
if (empty($special_day['description']) === false) {
$cal_table->data[$cal_line][$week] .= ui_print_help_tip($special_day['description'], true);
}
if ($special_day['date'] == $date_wildcard) {
$cal_table->data[$cal_line][$week] .= '(';
$cal_table->data[$cal_line][$week] .= ui_print_help_tip(
'This is valid every year. However, this will be ignored if indivisual setting for the same group is available.',
true
);
$cal_table->data[$cal_line][$week] .= ') ';
}
$cal_table->data[$cal_line][$week] .= __('As ');
switch ($special_day['day_code']) {
case '1':
$cal_table->data[$cal_line][$week] .= __('Monday');
break;
case '2':
$cal_table->data[$cal_line][$week] .= __('Tuesday');
break;
case '3':
$cal_table->data[$cal_line][$week] .= __('Wednesday');
break;
case '4':
$cal_table->data[$cal_line][$week] .= __('Thursday');
break;
case '5':
$cal_table->data[$cal_line][$week] .= __('Friday');
break;
case '6':
$cal_table->data[$cal_line][$week] .= __('Saturday');
break;
case '7':
$cal_table->data[$cal_line][$week] .= __('Sunday');
break;
case '8':
$cal_table->data[$cal_line][$week] .= __('Holidays');
break;
default:
// Not possible.
break;
}
$cal_table->data[$cal_line][$week] .= '</div>';
$cal_table->data[$cal_line][$week] .= '<div>';
if ($special_day['id_group'] || (users_can_manage_group_all('LM') === true && $special_day['id_group'] == 0)) {
$script_delete = '';
$dateformat = date_create($special_day['date']);
$options_zoom = htmlspecialchars(
json_encode(
[
'date' => $special_day['date'],
'id_group' => $special_day['id_group'],
'day_code' => $special_day['day_code'],
'id_calendar' => $special_day['id_calendar'],
'btn_ok_text' => __('Create'),
'btn_cancel_text' => __('Cancel'),
'title' => date_format($dateformat, 'd M Y'),
'url' => ui_get_full_url('ajax.php', false, false, false),
'page' => $ajax_url,
'loading' => __('Loading, this operation might take several minutes...'),
]
),
ENT_QUOTES,
'UTF-8'
);
$onclick_zoom = 'load_templates_alerts_special_days('.$options_zoom.')';
$cal_table->data[$cal_line][$week] .= '<a href="#" onclick="'.$onclick_zoom.'"';
$cal_table->data[$cal_line][$week] .= 'title="';
$cal_table->data[$cal_line][$week] .= __('Show templates');
$cal_table->data[$cal_line][$week] .= '">';
$cal_table->data[$cal_line][$week] .= html_print_image(
'images/zoom.png',
true,
['class' => 'invert_filter']
).'</a>';
if ($is_management_allowed === true) {
$cal_table->data[$cal_line][$week] .= '<a href="'.$url.'&op=edit&id='.$special_day['id'].'" title=';
$cal_table->data[$cal_line][$week] .= __('Edit');
$cal_table->data[$cal_line][$week] .= '>'.html_print_image(
'images/config.png',
true,
['class' => 'invert_filter']
).'</a> &nbsp;';
$url_delete = $url.'&op=delete&id='.$special_day['id'];
$script_delete = 'if (!confirm(\''.__('Are you sure?').'\')) return false;';
$cal_table->data[$cal_line][$week] .= '<a href="'.$url_delete.'"';
$cal_table->data[$cal_line][$week] .= ' onClick="'.$script_delete.'"';
$cal_table->data[$cal_line][$week] .= 'title="';
$cal_table->data[$cal_line][$week] .= __('Remove');
$cal_table->data[$cal_line][$week] .= '">';
$cal_table->data[$cal_line][$week] .= html_print_image(
'images/cross.png',
true,
['class' => 'invert_filter']
).'</a>';
}
}
$cal_table->data[$cal_line][$week] .= '</div>';
$cal_table->data[$cal_line][$week] .= '</div>';
}
}
if ($week == 6) {
$cal_line++;
}
}
for ($padding = ($week + 1); $padding <= 6; $padding++) {
$cal_table->cellstyle[$cal_line][$padding] = 'font-size: 18px;';
$cal_table->data[$cal_line][$padding] = '-';
}
html_print_table($cal_table);
}
if ((bool) check_acl($config['id_user'], 0, 'LM') === true) {
HTML::printForm(
[
'form' => [
'action' => $url.'&op=edit',
'method' => 'POST',
],
'inputs' => [
[
'arguments' => [
'name' => 'button',
'label' => __('Create'),
'type' => 'submit',
'attributes' => 'class="sub next"',
],
],
],
]
);
}
echo '<div id="modal-alert-templates" class="invisible"></div>';
ui_require_javascript_file('pandora_alerts');
\enterprise_hook('close_meta_frame');
?>
<script type="text/javascript">
$(document).ready (function () {
$("#submit-button").click (function (e) {
e.preventDefault();
load_templates_alerts_special_days({
date: '',
id_group: $("#id_group").val(),
day_code: $("#day_code").val(),
id_calendar: '<?php echo $id_calendar; ?>',
btn_ok_text: '<?php echo __('Create'); ?>',
btn_cancel_text: '<?php echo __('Cancel'); ?>',
title: '<?php echo __('Load calendar'); ?>',
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
page: "godmode/alerts/alert_special_days",
loading: '<?php echo __('Loading, this operation might take several minutes...'); ?>',
name_form: 'icalendar-special-days'
});
});
});
</script>

View File

@ -0,0 +1,216 @@
<?php
/**
* Special days.
*
* @category Alerts
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation 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.
* ============================================================================
*/
// Extras required.
\ui_require_css_file('wizard');
\enterprise_include_once('meta/include/functions_alerts_meta.php');
\enterprise_hook('open_meta_frame');
if (\is_metaconsole() === true) {
\alerts_meta_print_header($tabs);
} else {
// Header.
\ui_print_page_header(
// Title.
__('Alerts').' &raquo; '.__('Configure special day'),
// Icon.
'images/gm_alerts.png',
// Return.
false,
// Help.
'alert_special_days',
// Godmode.
true,
// Options.
$tabs
);
}
$is_management_allowed = \is_management_allowed();
if ($is_management_allowed === false) {
if (\is_metaconsole() === false) {
$url_link = '<a target="_blank" href="'.ui_get_meta_url($url).'">';
$url_link .= __('metaconsole');
$url_link .= '</a>';
} else {
$url_link = __('any node');
}
\ui_print_warning_message(
__(
'This node is configured with centralized mode. All alert calendar information is read only. Go to %s to manage it.',
$url_link
)
);
}
if (empty($message) === false) {
echo $message;
}
$inputs = [];
// Date.
$inputs[] = [
'label' => __('Date'),
'arguments' => [
'type' => 'text',
'name' => 'date',
'required' => true,
'value' => $specialDay->date(),
],
'extra' => html_print_image(
'images/calendar_view_day.png',
true,
[
'alt' => 'calendar',
'onclick' => "scwShow(scwID('text-date'),this);",
'class' => 'invert_filter',
]
),
];
if (users_can_manage_group_all('LM') === true) {
$display_all_group = true;
} else {
$display_all_group = false;
}
// Group.
$inputs[] = [
'label' => __('Group'),
'arguments' => [
'type' => 'select_groups',
'returnAllGroup' => $display_all_group,
'name' => 'id_group',
'selected' => $specialDay->id_group(),
],
];
$days = [];
$days[1] = __('Monday');
$days[2] = __('Tuesday');
$days[3] = __('Wednesday');
$days[4] = __('Thursday');
$days[5] = __('Friday');
$days[6] = __('Saturday');
$days[7] = __('Sunday');
$days[8] = __('Holidays');
// Same day of the week.
$inputs[] = [
'label' => __('Same day of the week'),
'arguments' => [
'name' => 'day_code',
'type' => 'select',
'fields' => $days,
'selected' => ($specialDay->day_code() === null) ? 1 : $specialDay->day_code(),
],
];
// Description.
$inputs[] = [
'label' => __('Description'),
'arguments' => [
'type' => 'textarea',
'name' => 'description',
'required' => false,
'value' => $specialDay->description(),
'rows' => 50,
'columns' => 30,
],
];
// Calendar.
$inputs[] = [
'arguments' => [
'type' => 'hidden',
'name' => 'id_calendar',
'value' => $specialDay->id_calendar(),
],
];
if ($is_management_allowed === true) {
// Submit.
$inputs[] = [
'arguments' => [
'name' => 'button',
'label' => (($create === true) ? __('Create') : __('Update')),
'type' => 'submit',
'attributes' => 'class="sub next"',
],
];
}
// Print form.
HTML::printForm(
[
'form' => [
'id' => 'form-special-days',
'action' => $url.'&action=save&id='.$specialDay->id(),
'method' => 'POST',
],
'inputs' => $inputs,
],
false,
true
);
echo '<div id="modal-alert-templates" class="invisible"></div>';
ui_require_javascript_file('calendar');
ui_require_javascript_file('pandora_alerts');
\enterprise_hook('close_meta_frame');
?>
<script type="text/javascript">
$(document).ready (function () {
$("#submit-button").click (function (e) {
e.preventDefault();
var date = new Date($("#text-date").val());
var dateformat = date.toLocaleString(
'default',
{day: 'numeric', month: 'short', year: 'numeric'}
);
load_templates_alerts_special_days({
date: $("#text-date").val(),
id_group: $("#id_group").val(),
day_code: $("#day_code").val(),
id_calendar: '<?php echo $id_calendar; ?>',
btn_ok_text: '<?php echo __('Create'); ?>',
btn_cancel_text: '<?php echo __('Cancel'); ?>',
title: dateformat,
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
page: '<?php echo $ajax_url; ?>',
loading: '<?php echo __('Loading, this operation might take several minutes...'); ?>',
name_form: 'form-special-days'
});
});
});
</script>

View File

@ -80,6 +80,7 @@ $inputs = [
'name' => 'name', 'name' => 'name',
'value' => $arrayDashboard['name'], 'value' => $arrayDashboard['name'],
'size' => '', 'size' => '',
'maxlength' => 35,
], ],
], ],
[ [

View File

@ -1,5 +1,5 @@
package: pandorafms-server package: pandorafms-server
Version: 7.0NG.758-211118 Version: 7.0NG.758.1-211124
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.758-211118" pandora_version="7.0NG.758.1-211124"
package_cpan=0 package_cpan=0
package_pandora=1 package_pandora=1

View File

@ -1,7 +1,7 @@
############################################################################# #############################################################################
# Pandora FMS Server Parameters # Pandora FMS Server Parameters
# Pandora FMS, the Flexible Monitoring System. # Pandora FMS, the Flexible Monitoring System.
# Version 7.0NG.758 # Version 7.0NG.758.1
# Licensed under GPL license v2, # Licensed under GPL license v2,
# (c) 2003-2021 Artica Soluciones Tecnologicas # (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -45,8 +45,8 @@ our @EXPORT = qw(
); );
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.758"; my $pandora_version = "7.0NG.758.1";
my $pandora_build = "211118"; my $pandora_build = "211124";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash # Setup hash

View File

@ -531,15 +531,16 @@ sub pandora_evaluate_alert ($$$$$$$;$$$$) {
my $date = sprintf("%4d%02d%02d", $year + 1900, $mon + 1, $mday); my $date = sprintf("%4d%02d%02d", $year + 1900, $mon + 1, $mday);
# '0001' means every year. # '0001' means every year.
my $date_every_year = sprintf("0001%02d%02d", $mon + 1, $mday); my $date_every_year = sprintf("0001%02d%02d", $mon + 1, $mday);
my $special_day = get_db_value ($dbh, 'SELECT same_day FROM talert_special_days WHERE (date = ? OR date = ?) AND (id_group = 0 OR id_group = ?) ORDER BY date DESC', $date, $date_every_year, $alert->{'id_group'}); my $special_day = get_db_value ($dbh, 'SELECT day_code FROM talert_special_days WHERE (date = ? OR date = ?) AND (id_group = 0 OR id_group = ?) AND (id_calendar = ?) ORDER BY date DESC', $date, $date_every_year, $alert->{'id_group'}, $alert->{'special_day'});
if (!defined($special_day)) { if (!defined($special_day)) {
$special_day = ''; $special_day = 0;
} }
if ($special_day ne '') { my @weeks = ( 'none', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday', 'holiday');
logger ($pa_config, $date . " is a special day for " . $alert->{'name'} . ". (as a " . $special_day . ")", 10); if ($special_day != 0) {
return $status if ($alert->{$special_day} != 1); logger ($pa_config, $date . " is a special day for " . $alert->{'name'} . ". (as a " . $weeks[$special_day] . ")", 10);
return $status if (!defined($alert->{$weeks[$special_day]}) || $alert->{$weeks[$special_day]} == 0);
} }
else { else {
logger ($pa_config, $date . " is *NOT* a special day for " . $alert->{'name'}, 10); logger ($pa_config, $date . " is *NOT* a special day for " . $alert->{'name'}, 10);
@ -1092,6 +1093,15 @@ sub pandora_execute_action ($$$$$$$$$;$) {
my ($field1, $field2, $field3, $field4, $field5, $field6, $field7, $field8, $field9, $field10); my ($field1, $field2, $field3, $field4, $field5, $field6, $field7, $field8, $field9, $field10);
my ($field11, $field12, $field13, $field14, $field15, $field16, $field17, $field18, $field19, $field20); my ($field11, $field12, $field13, $field14, $field15, $field16, $field17, $field18, $field19, $field20);
# Check for empty alert fields and assign command field.
my $index = 1;
my @command_fields = split(/,|\[|\]/, $action->{'fields_values'});
foreach my $field (@command_fields) {
unless (defined($action->{'field'.$index}) && $action->{'field'.$index} ne "") {
$action->{'field'.$index} = defined($field) ? $field : "" ;
}
}
if (!defined($alert->{'snmp_alert'})) { if (!defined($alert->{'snmp_alert'})) {
# Regular alerts # Regular alerts
$field1 = defined($action->{'field1'}) && $action->{'field1'} ne "" ? $action->{'field1'} : $alert->{'field1'}; $field1 = defined($action->{'field1'}) && $action->{'field1'} ne "" ? $action->{'field1'} : $alert->{'field1'};
@ -1138,6 +1148,7 @@ sub pandora_execute_action ($$$$$$$$$;$) {
$field20 = defined($alert->{'field20'}) && $alert->{'field20'} ne "" ? $alert->{'field20'} : $action->{'field20'}; $field20 = defined($alert->{'field20'}) && $alert->{'field20'} ne "" ? $alert->{'field20'} : $action->{'field20'};
} }
# Recovery fields, thanks to Kato Atsushi # Recovery fields, thanks to Kato Atsushi
if ($alert_mode == RECOVERED_ALERT) { if ($alert_mode == RECOVERED_ALERT) {
# Field 1 is a special case where [RECOVER] prefix is not added even when it is defined # Field 1 is a special case where [RECOVER] prefix is not added even when it is defined

View File

@ -33,8 +33,8 @@ use base 'Exporter';
our @ISA = qw(Exporter); our @ISA = qw(Exporter);
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.758"; my $pandora_version = "7.0NG.758.1";
my $pandora_build = "211118"; my $pandora_build = "211124";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] ); our %EXPORT_TAGS = ( 'all' => [ qw() ] );

View File

@ -2,8 +2,8 @@
# Pandora FMS Server # Pandora FMS Server
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.758 %define version 7.0NG.758.1
%define release 211118 %define release 211124
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -2,8 +2,8 @@
# Pandora FMS Server # Pandora FMS Server
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.758 %define version 7.0NG.758.1
%define release 211118 %define release 211124
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -8,8 +8,8 @@
# This code is licensed under GPL 2.0 license. # This code is licensed under GPL 2.0 license.
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.758" PI_VERSION="7.0NG.758.1"
PI_BUILD="211118" PI_BUILD="211124"
MODE=$1 MODE=$1
if [ $# -gt 1 ]; then if [ $# -gt 1 ]; then

View File

@ -35,7 +35,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB; use PandoraFMS::DB;
# version: define current version # version: define current version
my $version = "7.0NG.758 Build 211118"; my $version = "7.0NG.758.1 Build 211124";
# Pandora server configuration # Pandora server configuration
my %conf; my %conf;

View File

@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv; Encode::Locale::decode_argv;
# version: define current version # version: define current version
my $version = "7.0NG.758 Build 211118"; my $version = "7.0NG.758.1 Build 211124";
# save program name for logging # save program name for logging
my $progname = basename($0); my $progname = basename($0);
@ -179,7 +179,7 @@ sub help_screen{
help_screen_line('--update_alert_template', "<template_name> <field_to_change> \n\t <new_value>", 'Update a field of an alert template'); help_screen_line('--update_alert_template', "<template_name> <field_to_change> \n\t <new_value>", 'Update a field of an alert template');
help_screen_line('--validate_all_alerts', '', 'Validate all the alerts'); help_screen_line('--validate_all_alerts', '', 'Validate all the alerts');
help_screen_line('--validate_alert', '<template_name> <agent_id> <module_id> [<use_alias>]', 'Validate alert given angent, module and alert'); help_screen_line('--validate_alert', '<template_name> <agent_id> <module_id> [<use_alias>]', 'Validate alert given angent, module and alert');
help_screen_line('--create_special_day', "<special_day> <same_day> <description> <group>", 'Create special day'); help_screen_line('--create_special_day', "<special_day> <calendar_name> <same_day> <description> <group>", 'Create special day');
help_screen_line('--delete_special_day', '<special_day>', 'Delete special day'); help_screen_line('--delete_special_day', '<special_day>', 'Delete special day');
help_screen_line('--update_special_day', "<special_day> <field_to_change> <new_value>", 'Update a field of a special day'); help_screen_line('--update_special_day', "<special_day> <field_to_change> <new_value>", 'Update a field of a special day');
help_screen_line('--create_data_module_from_local_component', '<agent_name> <component_name> [<use_alias>]', "Create a new data \n\t module from a local component"); help_screen_line('--create_data_module_from_local_component', '<agent_name> <component_name> [<use_alias>]', "Create a new data \n\t module from a local component");
@ -956,6 +956,31 @@ sub pandora_get_special_day_id ($$) {
return defined ($special_day_id) ? $special_day_id : -1; return defined ($special_day_id) ? $special_day_id : -1;
} }
##########################################################################
## SUB pandora_get_calendar_id(id)
## Return calendar id, given "calendar_name"
##########################################################################
sub pandora_get_calendar_id ($$) {
my ($dbh, $calendar_name) = @_;
my $calendar_id = get_db_value ($dbh, "SELECT id FROM talert_calendar WHERE ${RDBMS_QUOTE}name${RDBMS_QUOTE} = ?", $calendar_name);
return defined ($calendar_id) ? $calendar_id : -1;
}
##########################################################################
## SUB pandora_get_same_day_id(id)
## Return same day id, given "same_day"
##########################################################################
sub pandora_get_same_day_id ($$) {
my ($dbh, $same_day) = @_;
my $weeks = { 'monday' => 1, 'tuesday' => 2, 'wednesday' => 3, 'thursday' => 4, 'friday' => 5, 'saturday' => 6, 'sunday' => 7, 'holiday' => 8};
return defined ($weeks->{$same_day}) ? $weeks->{$same_day} : -1;
}
########################################################################## ##########################################################################
## Delete a special day. ## Delete a special day.
########################################################################## ##########################################################################
@ -6413,9 +6438,13 @@ sub pandora_get_network_component_id($$) {
############################################################################## ##############################################################################
sub cli_create_special_day() { sub cli_create_special_day() {
my ($special_day, $same_day, $description, $group_name) = @ARGV[2..5]; my ($special_day, $calendar_name, $same_day, $description, $group_name) = @ARGV[2..5];
my $calendar_name_exists = pandora_get_calendar_id ($dbh, $calendar_name);
my $same_day_exists = pandora_get_same_day_id ($dbh, $same_day);
my $special_day_exists = pandora_get_special_day_id ($dbh, $special_day); my $special_day_exists = pandora_get_special_day_id ($dbh, $special_day);
non_exist_check($special_day_exists,'special day',$special_day); non_exist_check($special_day_exists,'special day',$special_day);
non_exist_check($calendar_name_exists,'calendar name',$calendar_name);
non_exist_check($same_day_exists,'same day',$same_day);
my $group_id = 0; my $group_id = 0;
@ -6434,7 +6463,8 @@ sub cli_create_special_day() {
help_screen (); help_screen ();
exit 1; exit 1;
} }
if ($same_day !~ /monday|tuesday|wednesday|thursday|friday|saturday|sunday/) {
if ($same_day !~ /monday|tuesday|wednesday|thursday|friday|saturday|sunday|holiday/) {
print_log "[ERROR] '$same_day' is invalid day.\n\n"; print_log "[ERROR] '$same_day' is invalid day.\n\n";
$param = '--create_special_day'; $param = '--create_special_day';
help_screen (); help_screen ();
@ -6447,6 +6477,7 @@ sub cli_create_special_day() {
$parameters{'same_day'} = $same_day; $parameters{'same_day'} = $same_day;
$parameters{'description'} = decode('UTF-8', $description); $parameters{'description'} = decode('UTF-8', $description);
$parameters{'id_group'} = $group_id; $parameters{'id_group'} = $group_id;
$parameters{'calendar_name'} = $calendar_name;
pandora_create_special_day_from_hash ($conf, \%parameters, $dbh); pandora_create_special_day_from_hash ($conf, \%parameters, $dbh);
} }