Merge branch 'develop' into ent-3594-Unificacion-de-tamaños-de-checkbox-switch
Conflicts: pandora_console/include/functions_html.php pandora_console/include/styles/pandora.css pandora_console/install.php Former-commit-id: 5cd5899c222ba13ec9bfa0212e5d2ec580353787
|
@ -54,7 +54,8 @@ AGENT_WIN_FILE="$CODEHOME/pandora_agents/win32/pandora.cc"
|
|||
AGENT_WIN_MPI_FILE="$CODEHOME/pandora_agents/win32/installer/pandora.mpi"
|
||||
AGENT_WIN_RC_FILE="$CODEHOME/pandora_agents/win32/versioninfo.rc"
|
||||
SATELLITE_FILE="$PANDHOME_ENT/satellite_server/satellite_server.pl"
|
||||
PERL_PLUGIN_FILES="$PANDHOME_ENT/pandora_server/util/plugin/vmware-plugin.pl \
|
||||
PERL_PLUGIN_FILES="$PANDHOME_ENT/pandora_server/util/recon_script/vmware-plugin.pl \
|
||||
$PANDHOME_ENT/pandora_server/util/recon_script/pcm_client.pl \
|
||||
$PANDHOME_ENT/pandora_plugins/NGINX/nginx_requests_queued.pl \
|
||||
$PANDHOME_ENT/pandora_plugins/Sybase/sybase_plugin.pl \
|
||||
$PANDHOME_ENT/pandora_plugins/SNMP/dynamic_snmp.pl \
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-agent-unix
|
||||
Version: 7.0NG.731-190225
|
||||
Version: 7.0NG.731-190226
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.731-190225"
|
||||
pandora_version="7.0NG.731-190226"
|
||||
|
||||
echo "Test if you has the tools for to make the packages."
|
||||
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
||||
|
|
|
@ -42,7 +42,7 @@ my $Sem = undef;
|
|||
my $ThreadSem = undef;
|
||||
|
||||
use constant AGENT_VERSION => '7.0NG.731';
|
||||
use constant AGENT_BUILD => '190225';
|
||||
use constant AGENT_BUILD => '190226';
|
||||
|
||||
# Agent log default file size maximum and instances
|
||||
use constant DEFAULT_MAX_LOG_SIZE => 600000;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.731
|
||||
%define release 190225
|
||||
%define release 190226
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.731
|
||||
%define release 190225
|
||||
%define release 190226
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.731"
|
||||
PI_BUILD="190225"
|
||||
PI_BUILD="190226"
|
||||
OS_NAME=`uname -s`
|
||||
|
||||
FORCE=0
|
||||
|
|
|
@ -186,7 +186,7 @@ UpgradeApplicationID
|
|||
{}
|
||||
|
||||
Version
|
||||
{190225}
|
||||
{190226}
|
||||
|
||||
ViewReadme
|
||||
{Yes}
|
||||
|
|
|
@ -30,7 +30,7 @@ using namespace Pandora;
|
|||
using namespace Pandora_Strutils;
|
||||
|
||||
#define PATH_SIZE _MAX_PATH+1
|
||||
#define PANDORA_VERSION ("7.0NG.731(Build 190225)")
|
||||
#define PANDORA_VERSION ("7.0NG.731(Build 190226)")
|
||||
|
||||
string pandora_path;
|
||||
string pandora_dir;
|
||||
|
|
|
@ -11,7 +11,7 @@ BEGIN
|
|||
VALUE "LegalCopyright", "Artica ST"
|
||||
VALUE "OriginalFilename", "PandoraAgent.exe"
|
||||
VALUE "ProductName", "Pandora FMS Windows Agent"
|
||||
VALUE "ProductVersion", "(7.0NG.731(Build 190225))"
|
||||
VALUE "ProductVersion", "(7.0NG.731(Build 190226))"
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
END
|
||||
END
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-console
|
||||
Version: 7.0NG.731-190225
|
||||
Version: 7.0NG.731-190226
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.731-190225"
|
||||
pandora_version="7.0NG.731-190226"
|
||||
|
||||
package_pear=0
|
||||
package_pandora=1
|
||||
|
|
|
@ -1,5 +1,147 @@
|
|||
START TRANSACTION;
|
||||
|
||||
UPDATE `twidget` SET `unique_name`='example' WHERE `class_name` LIKE 'WelcomeWidget';
|
||||
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp');
|
||||
|
||||
COMMIT;
|
||||
ALTER TABLE `trecon_task` ADD COLUMN `wmi_enabled` tinyint(1) unsigned DEFAULT '0';
|
||||
ALTER TABLE `trecon_task` ADD COLUMN `auth_strings` text;
|
||||
ALTER TABLE `trecon_task` ADD COLUMN `autoconfiguration_enabled` tinyint(1) unsigned default '0';
|
||||
|
||||
|
||||
INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Application.VMware', 'Discovery Application script to monitor VMware technologies (ESXi, VCenter, VSphere)', '/usr/share/pandora_server/util/recon_scripts/vmware-plugin.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}');
|
||||
INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Cloud', 'Discovery Cloud script to monitor Cloud technologies (AWS.EC2, AWS.S3, AWS.RDS, RDS,ȊWS.EKS)', '/usr/share/pandora_server/util/recon_scripts/pcm_client.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}');
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tevent_extended` (
|
||||
`id` serial PRIMARY KEY,
|
||||
`id_evento` bigint(20) unsigned NOT NULL,
|
||||
`external_id` bigint(20) unsigned,
|
||||
`utimestamp` bigint(20) NOT NULL default '0',
|
||||
`description` text,
|
||||
FOREIGN KEY `tevent_ext_fk`(`id_evento`) REFERENCES `tevento`(`id_evento`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `tnotification_source` (
|
||||
`id` serial,
|
||||
`description` VARCHAR(255) DEFAULT NULL,
|
||||
`icon` text,
|
||||
`max_postpone_time` int(11) DEFAULT NULL,
|
||||
`enabled` int(1) DEFAULT NULL,
|
||||
`user_editable` int(1) DEFAULT NULL,
|
||||
`also_mail` int(1) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Dumping data for table `tnotification_source`
|
||||
--
|
||||
INSERT INTO `tnotification_source`(`description`, `icon`, `max_postpone_time`, `enabled`, `user_editable`, `also_mail`) VALUES
|
||||
("System status", "icono_info_mr.png", 86400, 1, 1, 0),
|
||||
("Message", "icono_info_mr.png", 86400, 1, 1, 0),
|
||||
("Pending task", "icono_info_mr.png", 86400, 1, 1, 0),
|
||||
("Advertisement", "icono_info_mr.png", 86400, 1, 1, 0),
|
||||
("Official communication", "icono_info_mr.png", 86400, 1, 1, 0),
|
||||
("Sugerence", "icono_info_mr.png", 86400, 1, 1, 0);
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `tmensajes`
|
||||
-- -----------------------------------------------------
|
||||
ALTER TABLE `tmensajes` ADD COLUMN `url` TEXT;
|
||||
ALTER TABLE `tmensajes` ADD COLUMN `response_mode` VARCHAR(200) DEFAULT NULL;
|
||||
ALTER TABLE `tmensajes` ADD COLUMN `citicity` INT(10) UNSIGNED DEFAULT '0';
|
||||
ALTER TABLE `tmensajes` ADD COLUMN `id_source` BIGINT(20) UNSIGNED NOT NULL;
|
||||
ALTER TABLE `tmensajes` ADD COLUMN `subtype` VARCHAR(255) DEFAULT '';
|
||||
ALTER TABLE `tmensajes` ADD INDEX (`id_source`);
|
||||
UPDATE `tmensajes` SET `id_source`=(SELECT `id` FROM `tnotification_source` WHERE `description` = "Message");
|
||||
ALTER TABLE `tmensajes` ADD CONSTRAINT `tsource_fk` FOREIGN KEY (`id_source`) REFERENCES `tnotification_source` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tnotification_user` (
|
||||
`id_mensaje` INT(10) UNSIGNED NOT NULL,
|
||||
`id_user` VARCHAR(60) NOT NULL,
|
||||
`utimestamp_read` BIGINT(20),
|
||||
`utimestamp_erased` BIGINT(20),
|
||||
`postpone` INT,
|
||||
PRIMARY KEY (`id_mensaje`,`id_user`),
|
||||
FOREIGN KEY (`id_mensaje`) REFERENCES `tmensajes`(`id_mensaje`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tnotification_group` (
|
||||
`id_mensaje` INT(10) UNSIGNED NOT NULL,
|
||||
`id_group` mediumint(4) UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (`id_mensaje`,`id_group`),
|
||||
FOREIGN KEY (`id_mensaje`) REFERENCES `tmensajes`(`id_mensaje`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tnotification_source_user` (
|
||||
`id_source` BIGINT(20) UNSIGNED NOT NULL,
|
||||
`id_user` VARCHAR(60),
|
||||
`enabled` INT(1) DEFAULT NULL,
|
||||
`also_mail` INT(1) DEFAULT NULL,
|
||||
PRIMARY KEY (`id_source`,`id_user`),
|
||||
FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tnotification_source_group` (
|
||||
`id_source` BIGINT(20) UNSIGNED NOT NULL,
|
||||
`id_group` mediumint(4) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id_source`,`id_group`),
|
||||
INDEX (`id_group`),
|
||||
FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tnotification_source_group_user`(
|
||||
`id_source` BIGINT(20) UNSIGNED NOT NULL,
|
||||
`id_group` mediumint(4) unsigned NOT NULL,
|
||||
`id_user` VARCHAR(60),
|
||||
`enabled` INT(1) DEFAULT NULL,
|
||||
`also_mail` INT(1) DEFAULT NULL,
|
||||
PRIMARY KEY (`id_source`,`id_user`),
|
||||
FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
FOREIGN KEY (`id_group`) REFERENCES `tnotification_source_group`(`id_group`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
INSERT INTO `talert_commands` (`name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES ('Generate Notification','Internal type','This command allows you to send an internal notification to any user or group.',1,'[\"Destination user\",\"Destination group\",\"Title\",\"Message\",\"Link\",\"Criticity\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]');
|
||||
|
||||
INSERT INTO `tnotification_source_user` (`id_source`, `id_user`, `enabled`, `also_mail`) VALUES ((SELECT `id` FROM `tnotification_source` WHERE `description`="System status"), "admin", 1, 0);
|
||||
INSERT INTO `tnotification_source_group` SELECT `id`,0 FROM `tnotification_source` WHERE `description`="Message";
|
||||
INSERT INTO `tnotification_user` (`id_mensaje`, `id_user`) SELECT `id_mensaje`, `id_usuario_destino` FROM `tmensajes` WHERE `id_usuario_destino` != '';
|
||||
|
||||
INSERT INTO tlog_graph_models (`title`,`regexp`,`fields`,`average`) VALUES ('Apache accesses per client and status',
|
||||
'(.*?)\ -.*1.1"\ (\d+)\ \d+',
|
||||
'host,status', 1);
|
||||
|
||||
INSERT INTO tlog_graph_models (`title`,`regexp`,`fields`,`average`) VALUES ('Apache time per requester and html code',
|
||||
'(.*?)\ -.*1.1"\ (\d+)\ (\d+)',
|
||||
'origin,respose,_time_', 1);
|
||||
|
||||
INSERT INTO tlog_graph_models (`title`,`regexp`,`fields`,`average`) VALUES ('Count output',
|
||||
'.*',
|
||||
'Coincidences', 0);
|
||||
|
||||
INSERT INTO tlog_graph_models (`title`,`regexp`,`fields`,`average`) VALUES ('Events replicated to metaconsole',
|
||||
'.* (.*?) .* (\d+) events replicated to metaconsole',
|
||||
'server,_events_', 0);
|
||||
|
||||
INSERT INTO tlog_graph_models (`title`,`regexp`,`fields`,`average`) VALUES ('Pages with warnings',
|
||||
'PHP Warning:.*in (.*?) on',
|
||||
'page', 0);
|
||||
|
||||
INSERT INTO tlog_graph_models (`title`,`regexp`,`fields`,`average`) VALUES ('Users login',
|
||||
'Starting Session \d+\ of user (.*)',
|
||||
'user', 0);
|
||||
|
||||
COMMIT;
|
||||
|
|
|
@ -1407,12 +1407,16 @@ ALTER TABLE twidget_dashboard MODIFY options LONGTEXT NOT NULL default "";
|
|||
ALTER TABLE trecon_task ADD `alias_as_name` int(2) unsigned default '0';
|
||||
ALTER TABLE trecon_task ADD `snmp_enabled` int(2) unsigned default '0';
|
||||
ALTER TABLE trecon_task ADD `vlan_enabled` int(2) unsigned default '0';
|
||||
ALTER TABLE trecon_task ADD `wmi_enabled` tinyint(1) unsigned DEFAULT '0';
|
||||
ALTER TABLE trecon_task ADD `auth_strings` text;
|
||||
ALTER TABLE trecon_task ADD `autoconfiguration_enabled` tinyint(1) unsigned default '0';
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `twidget` AND Table `twidget_dashboard`
|
||||
-- ---------------------------------------------------------------------
|
||||
UPDATE twidget_dashboard SET id_widget = (SELECT id FROM twidget WHERE unique_name = 'graph_module_histogram') WHERE id_widget = (SELECT id FROM twidget WHERE unique_name = 'graph_availability');
|
||||
DELETE FROM twidget WHERE unique_name = 'graph_availability';
|
||||
UPDATE `twidget` SET `unique_name`='example' WHERE `class_name` LIKE 'WelcomeWidget';
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tbackup` (Extension table. Modify only if exists)
|
||||
|
@ -1817,7 +1821,30 @@ CREATE TABLE IF NOT EXISTS `tlog_graph_models` (
|
|||
INSERT INTO tlog_graph_models VALUES (1, 'Apache log model',
|
||||
'^.*?\s+.*".*?\s(\/.*?)\?.*1.1"\s+(.*?)\s+(.*?)\s+',
|
||||
'pagina, html_err_code, _tiempo_', 1);
|
||||
|
||||
|
||||
INSERT INTO tlog_graph_models VALUES (2, 'Apache accesses per client and status',
|
||||
'(.*?)\ -.*1.1"\ (\d+)\ \d+',
|
||||
'host,status', 1);
|
||||
|
||||
INSERT INTO tlog_graph_models VALUES (3, 'Apache time per requester and html code',
|
||||
'(.*?)\ -.*1.1"\ (\d+)\ (\d+)',
|
||||
'origin,respose,_time_', 1);
|
||||
|
||||
INSERT INTO tlog_graph_models VALUES (4, 'Count output',
|
||||
'.*',
|
||||
'Coincidences', 0);
|
||||
|
||||
INSERT INTO tlog_graph_models VALUES (5, 'Events replicated to metaconsole',
|
||||
'.* (.*?) .* (\d+) events replicated to metaconsole',
|
||||
'server,_events_', 0);
|
||||
|
||||
INSERT INTO tlog_graph_models VALUES (6, 'Pages with warnings',
|
||||
'PHP Warning:.*in (.*?) on',
|
||||
'page', 0);
|
||||
|
||||
INSERT INTO tlog_graph_models VALUES (7, 'Users login',
|
||||
'Starting Session \d+\ of user (.*)',
|
||||
'user', 0);
|
||||
-- -----------------------------------------------------
|
||||
-- Add column in table `treport`
|
||||
-- -----------------------------------------------------
|
||||
|
@ -1857,6 +1884,19 @@ ALTER TABLE `tevento` ADD COLUMN `data` double(22,5) default NULL;
|
|||
|
||||
ALTER TABLE `tevento` ADD COLUMN `module_status` int(4) NOT NULL default '0';
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tevent_extended`
|
||||
-- ---------------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tevent_extended` (
|
||||
`id` serial PRIMARY KEY,
|
||||
`id_evento` bigint(20) unsigned NOT NULL,
|
||||
`external_id` bigint(20) unsigned,
|
||||
`utimestamp` bigint(20) NOT NULL default '0',
|
||||
`description` text,
|
||||
FOREIGN KEY `tevent_ext_fk`(`id_evento`) REFERENCES `tevento`(`id_evento`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `tgis_map_layer_groups`
|
||||
-- -----------------------------------------------------
|
||||
|
@ -1869,3 +1909,128 @@ CREATE TABLE IF NOT EXISTS `tgis_map_layer_groups` (
|
|||
FOREIGN KEY (`group_id`) REFERENCES `tgrupo` (`id_grupo`) ON DELETE CASCADE,
|
||||
FOREIGN KEY (`agent_id`) REFERENCES `tagente` (`id_agente`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `tnotification_source`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE `tnotification_source` (
|
||||
`id` serial,
|
||||
`description` VARCHAR(255) DEFAULT NULL,
|
||||
`icon` text,
|
||||
`max_postpone_time` int(11) DEFAULT NULL,
|
||||
`enabled` int(1) DEFAULT NULL,
|
||||
`user_editable` int(1) DEFAULT NULL,
|
||||
`also_mail` int(1) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Dumping data for table `tnotification_source`
|
||||
--
|
||||
INSERT INTO `tnotification_source`(`description`, `icon`, `max_postpone_time`, `enabled`, `user_editable`, `also_mail`) VALUES
|
||||
("System status", "icono_info_mr.png", 86400, 1, 1, 0),
|
||||
("Message", "icono_info_mr.png", 86400, 1, 1, 0),
|
||||
("Pending task", "icono_info_mr.png", 86400, 1, 1, 0),
|
||||
("Advertisement", "icono_info_mr.png", 86400, 1, 1, 0),
|
||||
("Official communication", "icono_info_mr.png", 86400, 1, 1, 0),
|
||||
("Sugerence", "icono_info_mr.png", 86400, 1, 1, 0);
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `tmensajes`
|
||||
-- -----------------------------------------------------
|
||||
ALTER TABLE `tmensajes` ADD COLUMN `url` TEXT;
|
||||
ALTER TABLE `tmensajes` ADD COLUMN `response_mode` VARCHAR(200) DEFAULT NULL;
|
||||
ALTER TABLE `tmensajes` ADD COLUMN `citicity` INT(10) UNSIGNED DEFAULT '0';
|
||||
ALTER TABLE `tmensajes` ADD COLUMN `id_source` BIGINT(20) UNSIGNED NOT NULL;
|
||||
ALTER TABLE `tmensajes` ADD COLUMN `subtype` VARCHAR(255) DEFAULT '';
|
||||
ALTER TABLE `tmensajes` ADD CONSTRAINT `tsource_fk` FOREIGN KEY (`id_source`) REFERENCES `tnotification_source` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Table `tnotification_user`
|
||||
-- ----------------------------------------------------------------------
|
||||
CREATE TABLE `tnotification_user` (
|
||||
`id_mensaje` INT(10) UNSIGNED NOT NULL,
|
||||
`id_user` VARCHAR(60) NOT NULL,
|
||||
`utimestamp_read` BIGINT(20),
|
||||
`utimestamp_erased` BIGINT(20),
|
||||
`postpone` INT,
|
||||
PRIMARY KEY (`id_mensaje`,`id_user`),
|
||||
FOREIGN KEY (`id_mensaje`) REFERENCES `tmensajes`(`id_mensaje`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Table `tnotification_group`
|
||||
-- ----------------------------------------------------------------------
|
||||
CREATE TABLE `tnotification_group` (
|
||||
`id_mensaje` INT(10) UNSIGNED NOT NULL,
|
||||
`id_group` mediumint(4) UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (`id_mensaje`,`id_group`),
|
||||
FOREIGN KEY (`id_mensaje`) REFERENCES `tmensajes`(`id_mensaje`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Table `tnotification_source_user`
|
||||
-- ----------------------------------------------------------------------
|
||||
CREATE TABLE `tnotification_source_user` (
|
||||
`id_source` BIGINT(20) UNSIGNED NOT NULL,
|
||||
`id_user` VARCHAR(60),
|
||||
`enabled` INT(1) DEFAULT NULL,
|
||||
`also_mail` INT(1) DEFAULT NULL,
|
||||
PRIMARY KEY (`id_source`,`id_user`),
|
||||
FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Table `tnotification_source_group`
|
||||
-- ----------------------------------------------------------------------
|
||||
CREATE TABLE `tnotification_source_group` (
|
||||
`id_source` BIGINT(20) UNSIGNED NOT NULL,
|
||||
`id_group` mediumint(4) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id_source`,`id_group`),
|
||||
INDEX (`id_group`),
|
||||
FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Table `tnotification_source_user`
|
||||
-- ----------------------------------------------------------------------
|
||||
CREATE TABLE `tnotification_source_group_user` (
|
||||
`id_source` BIGINT(20) UNSIGNED NOT NULL,
|
||||
`id_group` mediumint(4) unsigned NOT NULL,
|
||||
`id_user` VARCHAR(60),
|
||||
`enabled` INT(1) DEFAULT NULL,
|
||||
`also_mail` INT(1) DEFAULT NULL,
|
||||
PRIMARY KEY (`id_source`,`id_user`),
|
||||
FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
FOREIGN KEY (`id_group`) REFERENCES `tnotification_source_group`(`id_group`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Add alert command 'Generate notification'
|
||||
-- ----------------------------------------------------------------------
|
||||
INSERT INTO `talert_commands` (`name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES ('Generate Notification','Internal type','This command allows you to send an internal notification to any user or group.',1,'[\"Destination user\",\"Destination group\",\"Title\",\"Message\",\"Link\",\"Criticity\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]');
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Update message references and pre-configure notifications
|
||||
-- ----------------------------------------------------------------------
|
||||
INSERT INTO `tnotification_source_user` (`id_source`, `id_user`, `enabled`, `also_mail`) VALUES ((SELECT `id` FROM `tnotification_source` WHERE `description`="System status"), "admin", 1, 0);
|
||||
INSERT INTO `tnotification_source_group` SELECT `id`,0 FROM `tnotification_source` WHERE `description`="Message";
|
||||
INSERT INTO `tnotification_user` (`id_mensaje`, `id_user`) SELECT `id_mensaje`, `id_usuario_destino` FROM `tmensajes` WHERE `id_usuario_destino` != '';
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Add custom internal recon scripts
|
||||
-- ----------------------------------------------------------------------
|
||||
INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Application.VMware', 'Discovery Application script to monitor VMware technologies (ESXi, VCenter, VSphere)', '/usr/share/pandora_server/util/recon_scripts/vmware-plugin.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}');
|
||||
INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Cloud', 'Discovery Cloud script to monitor Cloud technologies (AWS.EC2, AWS.S3, AWS.RDS, RDS,ȊWS.EKS)', '/usr/share/pandora_server/util/recon_scripts/pcm_client.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}');
|
||||
|
|
|
@ -15,17 +15,17 @@ global $config;
|
|||
check_login();
|
||||
ui_require_css_file('firts_task');
|
||||
?>
|
||||
<?php ui_print_info_message(['no_close' => true, 'message' => __('There are no recon task defined yet.') ]); ?>
|
||||
<?php ui_print_info_message(['no_close' => true, 'message' => __('There are no discovery tasks defined yet.') ]); ?>
|
||||
|
||||
<div class="new_task">
|
||||
<div class="image_task">
|
||||
<?php echo html_print_image('images/firts_task/icono_grande_reconserver.png', true, ['title' => __('Recon server')]); ?>
|
||||
<?php echo html_print_image('images/firts_task/icono_grande_reconserver.png', true, ['title' => __('Discovery server')]); ?>
|
||||
</div>
|
||||
<div class="text_task">
|
||||
<h3> <?php echo __('Create Recon Task'); ?> <p id="description_task">
|
||||
<h3> <?php echo __('Create Discovery Task'); ?><p id="description_task">
|
||||
<?php
|
||||
echo __(
|
||||
'The Recon Task definition of Pandora FMS is used to find new elements in the network.
|
||||
'Discovery Task are used to find new elements in the network.
|
||||
If it detects any item, it will add that item to the monitoring, and if that item it is already being monitored, then it will
|
||||
ignore it or will update its information.There are three types of detection: Based on <strong id="fuerte"> ICMP </strong>(pings),
|
||||
<strong id="fuerte">SNMP</strong> (detecting the topology of networks and their interfaces), and other <strong id="fuerte"> customized </strong>
|
||||
|
@ -33,8 +33,8 @@ ui_require_css_file('firts_task');
|
|||
);
|
||||
?>
|
||||
</p>
|
||||
<form action="index.php?sec=gservers&sec2=godmode/servers/manage_recontask_form&create" method="post">
|
||||
<input type="submit" class="button_task" value="<?php echo __('Create Recon Task'); ?>" />
|
||||
<form action="index.php?sec=gservers&sec2=godmode/servers/discovery" method="post">
|
||||
<input type="submit" class="button_task" value="<?php echo __('Discover'); ?>" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
|
@ -13,6 +12,7 @@
|
|||
// GNU General Public License for more details.
|
||||
require_once 'include/functions_messages.php';
|
||||
require_once 'include/functions_servers.php';
|
||||
require_once 'include/functions_notifications.php';
|
||||
|
||||
// Check permissions
|
||||
// Global errors/warnings checking.
|
||||
|
@ -57,7 +57,7 @@ config_check();
|
|||
$table->cellspacing = 0;
|
||||
$table->head = [];
|
||||
$table->data = [];
|
||||
$table->style[0] = $table->style['clippy'] = $table->style[1] = $table->style[3] = $table->style[4] = $table->style[5] = $table->style[6] = $table->style[8] = $table->style[9] = $table->style['qr'] = 'width: 22px; text-align:center; height: 22px; padding-right: 9px;padding-left: 9px;';
|
||||
$table->style['clippy'] = $table->style[1] = $table->style[4] = $table->style[5] = $table->style[6] = $table->style[8] = $table->style[9] = $table->style['qr'] = $table->style['notifications'] = 'width: 22px; text-align:center; height: 22px; padding-right: 9px;padding-left: 9px;';
|
||||
$table->style[7] = 'width: 20px; padding-right: 9px;';
|
||||
$table->style['searchbar'] = 'width: 180px; min-width: 180px;';
|
||||
$table->style[11] = 'padding-left: 10px; padding-right: 5px;width: 16px;';
|
||||
|
@ -110,27 +110,6 @@ config_check();
|
|||
$table->data[0]['searchbar'] = $search_bar;
|
||||
}
|
||||
|
||||
// Servers check
|
||||
$servers = [];
|
||||
$servers['all'] = (int) db_get_value('COUNT(id_server)', 'tserver');
|
||||
$servers['up'] = (int) servers_check_status();
|
||||
$servers['down'] = ($servers['all'] - $servers['up']);
|
||||
if ($servers['up'] == 0) {
|
||||
// All Servers down or no servers at all
|
||||
$servers_check_img = html_print_image('images/header_down.png', true, ['alt' => 'cross', 'class' => 'bot', 'title' => __('All systems').': '.__('Down')]);
|
||||
} else if ($servers['down'] != 0) {
|
||||
// Some servers down
|
||||
$servers_check_img = html_print_image('images/header_warning.png', true, ['alt' => 'error', 'class' => 'bot', 'title' => $servers['down'].' '.__('servers down')]);
|
||||
} else {
|
||||
// All servers up
|
||||
$servers_check_img = html_print_image('images/header_ready.png', true, ['alt' => 'ok', 'class' => 'bot', 'title' => __('All systems').': '.__('Ready')]);
|
||||
}
|
||||
|
||||
unset($servers);
|
||||
// Since this is the header, we don't like to trickle down variables.
|
||||
$servers_link_open = '<a class="white" href="index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60">';
|
||||
$servers_link_close = '</a>';
|
||||
|
||||
if ($config['show_qr_code_header'] == 0) {
|
||||
$show_qr_code_header = 'display: none;';
|
||||
} else {
|
||||
|
@ -175,12 +154,6 @@ config_check();
|
|||
).'</a>';
|
||||
}
|
||||
|
||||
|
||||
$table->data[0][0] = $servers_link_open.$servers_check_img.$servers_link_close;
|
||||
|
||||
|
||||
|
||||
|
||||
// ======= Autorefresh code =============================
|
||||
$autorefresh_txt = '';
|
||||
$autorefresh_additional = '';
|
||||
|
@ -254,57 +227,8 @@ config_check();
|
|||
$table->data[0][1] = $autorefresh_link_open_img.$autorefresh_img.$autorefresh_link_close;
|
||||
$table->data[0][2] = $autorefresh_link_open_txt.$autorefresh_txt.$autorefresh_link_close.$autorefresh_additional;
|
||||
// ======================================================
|
||||
$check_minor_release_available = false;
|
||||
$pandora_management = check_acl($config['id_user'], 0, 'PM');
|
||||
|
||||
$check_minor_release_available = db_check_minor_relase_available();
|
||||
|
||||
if ($check_minor_release_available) {
|
||||
if (users_is_admin($config['id_user'])) {
|
||||
if ($config['language'] == 'es') {
|
||||
set_pandora_error_for_header('Hay una o mas revisiones menores en espera para ser actualizadas. <a style="font-size:8pt;font-style:italic;" target="blank" href="http://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Actualizacion#Versi.C3.B3n_7.0NG_.28_Rolling_Release_.29">'.__('Sobre actualización de revisión menor').'</a>', 'Revisión/es menor/es disponible/s');
|
||||
} else {
|
||||
set_pandora_error_for_header('There are one or more minor releases waiting for update. <a style="font-size:8pt;font-style:italic;" target="blank" href="http://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Anexo_Upgrade#Version_7.0NG_.28_Rolling_Release_.29">'.__('About minor release update').'</a>', 'minor release/s available');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo '<div id="alert_messages" style="display: none"></div>';
|
||||
|
||||
if ($config['alert_cnt'] > 0) {
|
||||
$maintenance_link = 'javascript:';
|
||||
$maintenance_title = __('System alerts detected - Please fix as soon as possible');
|
||||
$maintenance_class = $maintenance_id = 'show_systemalert_dialog white';
|
||||
|
||||
$maintenance_link_open_txt = '<a href="'.$maintenance_link.'" title="'.$maintenance_title.'" class="'.$maintenance_class.'" id="show_systemalert_dialog">';
|
||||
$maintenance_link_open_img = '<a href="'.$maintenance_link.'" title="'.$maintenance_title.'" class="'.$maintenance_class.'">';
|
||||
$maintenance_link_close = '</a>';
|
||||
if (!$pandora_management) {
|
||||
$maintenance_img = '';
|
||||
} else {
|
||||
$maintenance_img = $maintenance_link_open_img.html_print_image(
|
||||
'images/header_yellow.png',
|
||||
true,
|
||||
[
|
||||
'title' => __(
|
||||
'You have %d warning(s)',
|
||||
$config['alert_cnt']
|
||||
),
|
||||
'id' => 'yougotalert',
|
||||
'class' => 'bot',
|
||||
]
|
||||
).$maintenance_link_close;
|
||||
}
|
||||
} else {
|
||||
if (!$pandora_management) {
|
||||
$maintenance_img = '';
|
||||
} else {
|
||||
$maintenance_img = html_print_image('images/header_ready.png', true, ['title' => __('There are not warnings'), 'id' => 'yougotalert', 'class' => 'bot']);
|
||||
}
|
||||
}
|
||||
|
||||
$table->data[0][3] = $maintenance_img;
|
||||
|
||||
// Main help icon
|
||||
if (!$config['disable_help']) {
|
||||
$table->data[0][4] = '<a href="#" class="modalpopup" id="helpmodal">'.html_print_image(
|
||||
|
@ -318,6 +242,12 @@ config_check();
|
|||
).'</a>';
|
||||
}
|
||||
|
||||
$notifications_numbers = notifications_get_counters();
|
||||
$table->data[0]['notifications'] = notifications_print_ball(
|
||||
$notifications_numbers['notifications'],
|
||||
$notifications_numbers['last_id']
|
||||
);
|
||||
|
||||
// Logout
|
||||
$table->data[0][5] = '<a class="white" href="'.ui_get_full_url('index.php?bye=bye').'">';
|
||||
$table->data[0][5] .= html_print_image('images/header_logout.png', true, ['alt' => __('Logout'), 'class' => 'bot', 'title' => __('Logout')]);
|
||||
|
@ -341,18 +271,6 @@ config_check();
|
|||
$table->data[0][8] .= '</a>';
|
||||
$table->data[0][8] .= '</span>';
|
||||
|
||||
// Messages
|
||||
$msg_cnt = messages_get_count($config['id_user']);
|
||||
if ($msg_cnt > 0) {
|
||||
echo '<div id="dialog_messages" style="display: none"></div>';
|
||||
|
||||
$table->data[0][9] = '<a href="ajax.php?page=operation/messages/message_list" title="'.__('Message overview').'" id="show_messages_dialog">';
|
||||
$table->data[0][9] .= html_print_image('images/header_email.png', true, ['title' => __('You have %d unread message(s)', $msg_cnt), 'id' => 'yougotmail', 'class' => 'bot', 'style' => 'width:24px;']);
|
||||
$table->data[0][9] .= '</a>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
html_print_table($table);
|
||||
|
||||
unset($table);
|
||||
|
@ -373,6 +291,9 @@ config_check();
|
|||
</tr>
|
||||
</table>
|
||||
|
||||
<!-- Notifications content wrapper-->
|
||||
<div id='notification-content' style='display:none;' /></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
/* <![CDATA[ */
|
||||
|
||||
|
@ -381,12 +302,223 @@ config_check();
|
|||
if (isset($config['fixed_header'])) {
|
||||
$config_fixed_header = $config['fixed_header'];
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
function addNotifications(event) {
|
||||
var element = document.getElementById("notification-content");
|
||||
if (!element) {
|
||||
console.error('Cannot locate the notification content element.');
|
||||
return;
|
||||
}
|
||||
// If notification-content is empty, retrieve the notifications.
|
||||
if (!element.firstChild) {
|
||||
jQuery.post ("ajax.php",
|
||||
{
|
||||
"page" : "godmode/setup/setup_notifications",
|
||||
"get_notifications_dropdown" : 1,
|
||||
},
|
||||
function (data, status) {
|
||||
// Apppend data
|
||||
element.innerHTML = data;
|
||||
// Show the content
|
||||
element.style.display = "block";
|
||||
attatch_to_image();
|
||||
},
|
||||
"html"
|
||||
);
|
||||
} else {
|
||||
// If there is some notifications retrieved, only show it.
|
||||
element.style.display = "block";
|
||||
attatch_to_image();
|
||||
}
|
||||
}
|
||||
|
||||
function attatch_to_image() {
|
||||
var notification_elem = document.getElementById("notification-wrapper");
|
||||
if (!notification_elem) return;
|
||||
var image_attached =
|
||||
document.getElementById("notification-ball-header")
|
||||
.getBoundingClientRect()
|
||||
.left
|
||||
;
|
||||
notification_elem.style.left = image_attached - 300 + "px";
|
||||
}
|
||||
|
||||
function notifications_clean_ui(action, self_id) {
|
||||
switch(action) {
|
||||
case 'item':
|
||||
// Recalculate the notification ball.
|
||||
check_new_notifications();
|
||||
break;
|
||||
case 'toast':
|
||||
// Only remove the toast element.
|
||||
document.getElementById(self_id).remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function notifications_hide() {
|
||||
var element = document.getElementById("notification-content");
|
||||
element.style.display = "none"
|
||||
}
|
||||
|
||||
function click_on_notification_toast(event) {
|
||||
var match = /notification-(.*)-id-([0-9]+)/.exec(event.target.id);
|
||||
if (!match) {
|
||||
console.error(
|
||||
"Cannot handle toast click event. Id not valid: ",
|
||||
event.target.id
|
||||
);
|
||||
return;
|
||||
}
|
||||
jQuery.post ("ajax.php",
|
||||
{
|
||||
"page" : "godmode/setup/setup_notifications",
|
||||
"mark_notification_as_read" : 1,
|
||||
"message": match[2]
|
||||
},
|
||||
function (data, status) {
|
||||
if (!data.result) {
|
||||
console.error("Cannot redirect to URL.");
|
||||
return;
|
||||
}
|
||||
notifications_clean_ui(match[1], event.target.id);
|
||||
},
|
||||
"json"
|
||||
)
|
||||
.fail(function(xhr, textStatus, errorThrown){
|
||||
console.error(
|
||||
"Failed onclik event on toast. Error: ",
|
||||
xhr.responseText
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function print_toast(title, subtitle, severity, url, id, onclick) {
|
||||
// TODO severity.
|
||||
severity = '';
|
||||
|
||||
// Start the toast.
|
||||
var toast = document.createElement('a');
|
||||
toast.setAttribute('onclick', onclick);
|
||||
toast.setAttribute('href', url);
|
||||
toast.setAttribute('target', '_blank');
|
||||
|
||||
// Fill toast.
|
||||
var toast_div = document.createElement('div');
|
||||
toast_div.className = 'snackbar ' + severity;
|
||||
toast_div.id = id;
|
||||
var toast_title = document.createElement('h3');
|
||||
var toast_text = document.createElement('p');
|
||||
toast_title.innerHTML = title;
|
||||
toast_text.innerHTML = subtitle;
|
||||
toast_div.appendChild(toast_title);
|
||||
toast_div.appendChild(toast_text);
|
||||
toast.appendChild(toast_div);
|
||||
|
||||
// Show and program the hide event.
|
||||
toast_div.className = toast_div.className + ' show';
|
||||
setTimeout(function(){
|
||||
toast_div.className = toast_div.className.replace("show", "");
|
||||
}, 8000);
|
||||
|
||||
return toast;
|
||||
}
|
||||
|
||||
function check_new_notifications() {
|
||||
var last_id = document.getElementById('notification-ball-header')
|
||||
.getAttribute('last_id');
|
||||
if (last_id === null) {
|
||||
console.error('Cannot retrieve notifications ball last_id.');
|
||||
return;
|
||||
}
|
||||
|
||||
jQuery.post ("ajax.php",
|
||||
{
|
||||
"page" : "godmode/setup/setup_notifications",
|
||||
"check_new_notifications" : 1,
|
||||
"last_id": last_id
|
||||
},
|
||||
function (data, status) {
|
||||
// Clean the toasts wrapper at first.
|
||||
var toast_wrapper = document.getElementById(
|
||||
'notifications-toasts-wrapper'
|
||||
);
|
||||
if (toast_wrapper === null) {
|
||||
console.error('Cannot place toast notifications.');
|
||||
return;
|
||||
}
|
||||
while (toast_wrapper.firstChild) {
|
||||
toast_wrapper.removeChild(toast_wrapper.firstChild);
|
||||
}
|
||||
|
||||
// Return if no new notification.
|
||||
if(!data.has_new_notifications) return;
|
||||
|
||||
// Substitute the ball
|
||||
var new_ball = atob(data.new_ball);
|
||||
var ball_wrapper = document
|
||||
.getElementById('notification-ball-header')
|
||||
.parentElement;
|
||||
if (ball_wrapper === null) {
|
||||
console.error('Cannot update notification ball');
|
||||
return;
|
||||
}
|
||||
// Print the new ball and clean old notifications
|
||||
ball_wrapper.innerHTML = new_ball;
|
||||
var not_drop = document.getElementById('notification-content');
|
||||
while (not_drop.firstChild && not_drop) {
|
||||
not_drop.removeChild(not_drop.firstChild);
|
||||
}
|
||||
|
||||
// Add the new toasts.
|
||||
if (Array.isArray(data.new_notifications)) {
|
||||
data.new_notifications.forEach(function(ele) {
|
||||
toast_wrapper.appendChild(
|
||||
print_toast(
|
||||
ele.subject,
|
||||
ele.mensaje,
|
||||
ele.criticity,
|
||||
ele.full_url,
|
||||
'notification-toast-id-' + ele.id_mensaje,
|
||||
'click_on_notification_toast(event)'
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
},
|
||||
"json"
|
||||
)
|
||||
.fail(function(xhr, textStatus, errorThrown){
|
||||
console.error(
|
||||
"Cannot get new notifications. Error: ",
|
||||
xhr.responseText
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// Resize event
|
||||
window.addEventListener("resize", function() {
|
||||
attatch_to_image();
|
||||
});
|
||||
|
||||
var fixed_header = <?php echo json_encode((bool) $config_fixed_header); ?>;
|
||||
|
||||
var new_chat = <?php echo (int) $_SESSION['new_chat']; ?>;
|
||||
$(document).ready (function () {
|
||||
|
||||
// Check new notifications on a periodic way
|
||||
setInterval(check_new_notifications, 10000);
|
||||
|
||||
// Print the wrapper for notifications
|
||||
var notifications_toasts_wrapper = document.createElement('div');
|
||||
notifications_toasts_wrapper.id = 'notifications-toasts-wrapper';
|
||||
document.body.insertBefore(
|
||||
notifications_toasts_wrapper,
|
||||
document.body.firstChild
|
||||
);
|
||||
|
||||
<?php
|
||||
if (($autorefresh_list !== null) && (array_search($_GET['sec2'], $autorefresh_list) !== false) && (!isset($_GET['refr']))) {
|
||||
$do_refresh = true;
|
||||
|
@ -438,33 +570,12 @@ config_check();
|
|||
$("#ui_close_dialog_titlebar").click(function () {
|
||||
$("#agent_access").css("display","");
|
||||
});
|
||||
|
||||
function blinkmail(){
|
||||
$("#yougotmail").delay(100).fadeTo(300,0.2).delay(100).fadeTo(300,1, blinkmail);
|
||||
}
|
||||
function blinkalert(){
|
||||
$("#yougotalert").delay(100).fadeTo(300,0.2).delay(100).fadeTo(300,1, blinkalert);
|
||||
}
|
||||
|
||||
function blinkpubli(){
|
||||
$(".publienterprise").delay(100).fadeTo(300,0.2).delay(100).fadeTo(300,1, blinkpubli);
|
||||
}
|
||||
<?php
|
||||
if ($msg_cnt > 0) {
|
||||
?>
|
||||
blinkmail();
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<?php
|
||||
if ($config['alert_cnt'] > 0) {
|
||||
?>
|
||||
blinkalert();
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
blinkpubli();
|
||||
|
||||
blinkpubli();
|
||||
|
||||
<?php
|
||||
if ($_GET['refr']) {
|
||||
|
@ -499,4 +610,4 @@ config_check();
|
|||
});
|
||||
});
|
||||
/* ]]> */
|
||||
</script>
|
||||
</script>
|
|
@ -159,8 +159,8 @@ $module_macros = [];
|
|||
// Create agent
|
||||
if ($create_agent) {
|
||||
$mssg_warning = 0;
|
||||
$alias_safe_output = io_safe_output(get_parameter("alias",""));
|
||||
$alias = io_safe_input(trim (preg_replace('/[\/\\\|%#&$-]/', '', $alias_safe_output)));
|
||||
$alias_safe_output = io_safe_output(get_parameter('alias', ''));
|
||||
$alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$-]/', '', $alias_safe_output)));
|
||||
$alias_as_name = (int) get_parameter_post('alias_as_name', 0);
|
||||
$direccion_agente = (string) get_parameter_post('direccion', '');
|
||||
$unique_ip = (int) get_parameter_post('unique_ip', 0);
|
||||
|
@ -765,8 +765,8 @@ if ($update_agent) {
|
|||
$mssg_warning = 0;
|
||||
$id_agente = (int) get_parameter_post('id_agente');
|
||||
$nombre_agente = str_replace('`', '‘', (string) get_parameter_post('agente', ''));
|
||||
$alias_safe_output = io_safe_output(get_parameter("alias",""));
|
||||
$alias = io_safe_input(trim (preg_replace('/[\/\\\|%#&$-]/', '', $alias_safe_output)));
|
||||
$alias_safe_output = io_safe_output(get_parameter('alias', ''));
|
||||
$alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$-]/', '', $alias_safe_output)));
|
||||
$alias_as_name = (int) get_parameter_post('alias_as_name', 0);
|
||||
$direccion_agente = (string) get_parameter_post('direccion', '');
|
||||
$unique_ip = (int) get_parameter_post('unique_ip', 0);
|
||||
|
|
|
@ -4,27 +4,27 @@
|
|||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
global $config;
|
||||
|
||||
check_login ();
|
||||
check_login();
|
||||
|
||||
if (! check_acl ($config['id_user'], 0, 'AR')
|
||||
&& ! check_acl ($config['id_user'], 0, 'AW') &&
|
||||
! check_acl ($config['id_user'], 0, 'AM')) {
|
||||
db_pandora_audit('ACL Violation',
|
||||
'Trying to access Agent Management');
|
||||
require ('general/noaccess.php');
|
||||
return;
|
||||
if (! check_acl($config['id_user'], 0, 'AR')
|
||||
&& ! check_acl($config['id_user'], 0, 'AW')
|
||||
&& ! check_acl($config['id_user'], 0, 'AM')
|
||||
) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access Agent Management'
|
||||
);
|
||||
include 'general/noaccess.php';
|
||||
return;
|
||||
}
|
||||
|
||||
$update = get_parameter('upd_button', '');
|
||||
|
@ -32,81 +32,94 @@ $default = (int) get_parameter('default', 0);
|
|||
|
||||
|
||||
if ($default != 0) {
|
||||
$fields_selected = explode (',', $config['status_monitor_fields']);
|
||||
}
|
||||
else if ($update != '') {
|
||||
$fields_selected = (array)get_parameter('fields_selected');
|
||||
|
||||
if ($fields_selected[0] == '') {
|
||||
$fields_selected = explode (',', $config['status_monitor_fields']);
|
||||
}
|
||||
else {
|
||||
$status_monitor_fields = implode (',', $fields_selected);
|
||||
}
|
||||
|
||||
$values = array(
|
||||
'token' => 'status_monitor_fields',
|
||||
'value' => $status_monitor_fields
|
||||
);
|
||||
$fields_selected = explode(',', $config['status_monitor_fields']);
|
||||
} else if ($update != '') {
|
||||
$fields_selected = (array) get_parameter('fields_selected');
|
||||
|
||||
//update 'status_monitor_fields' in tconfig table to keep the value at update.
|
||||
$result = db_process_sql_update('tconfig', $values,
|
||||
array ('token' => 'status_monitor_fields'));
|
||||
if ($fields_selected[0] == '') {
|
||||
$fields_selected = explode(',', $config['status_monitor_fields']);
|
||||
} else {
|
||||
$status_monitor_fields = implode(',', $fields_selected);
|
||||
}
|
||||
|
||||
ui_print_result_message ($result, __('Successfully updated'), __('Could not be updated'));
|
||||
$values = [
|
||||
'token' => 'status_monitor_fields',
|
||||
'value' => $status_monitor_fields,
|
||||
];
|
||||
|
||||
$config['status_monitor_fields'] = $status_monitor_fields;
|
||||
// update 'status_monitor_fields' in tconfig table to keep the value at update.
|
||||
$result = db_process_sql_update(
|
||||
'tconfig',
|
||||
$values,
|
||||
['token' => 'status_monitor_fields']
|
||||
);
|
||||
|
||||
ui_print_result_message($result, __('Successfully updated'), __('Could not be updated'));
|
||||
|
||||
$config['status_monitor_fields'] = $status_monitor_fields;
|
||||
}
|
||||
|
||||
$fields_selected = array();
|
||||
$fields_selected = [];
|
||||
$status_monitor_fields = '';
|
||||
$fields_selected = explode (',', $config['status_monitor_fields']);
|
||||
$fields_selected = explode(',', $config['status_monitor_fields']);
|
||||
|
||||
$result_selected = array();
|
||||
$result_selected = [];
|
||||
|
||||
//show list of fields selected.
|
||||
if ($fields_selected[0]!='') {
|
||||
foreach ($fields_selected as $field_selected) {
|
||||
switch ($field_selected) {
|
||||
case 'policy':
|
||||
$result = __('Policy');
|
||||
break;
|
||||
case 'agent':
|
||||
$result = __('Agent');
|
||||
break;
|
||||
case 'data_type':
|
||||
$result = __('Data type');
|
||||
break;
|
||||
case 'module_name':
|
||||
$result = __('Module name');
|
||||
break;
|
||||
case 'server_type':
|
||||
$result = __('Server type');
|
||||
break;
|
||||
case 'interval':
|
||||
$result = __('Interval');
|
||||
break;
|
||||
case 'status':
|
||||
$result = __('Status');
|
||||
break;
|
||||
case 'graph':
|
||||
$result = __('Graph');
|
||||
break;
|
||||
case 'warn':
|
||||
$result = __('Warn');
|
||||
break;
|
||||
case 'data':
|
||||
$result = __('Data');
|
||||
break;
|
||||
case 'timestamp':
|
||||
$result = __('Timestamp');
|
||||
break;
|
||||
case 'to_critical':
|
||||
$result = __('Last status change');
|
||||
break;
|
||||
}
|
||||
$result_selected[$field_selected] = $result;
|
||||
}
|
||||
// show list of fields selected.
|
||||
if ($fields_selected[0] != '') {
|
||||
foreach ($fields_selected as $field_selected) {
|
||||
switch ($field_selected) {
|
||||
case 'policy':
|
||||
$result = __('Policy');
|
||||
break;
|
||||
|
||||
case 'agent':
|
||||
$result = __('Agent');
|
||||
break;
|
||||
|
||||
case 'data_type':
|
||||
$result = __('Data type');
|
||||
break;
|
||||
|
||||
case 'module_name':
|
||||
$result = __('Module name');
|
||||
break;
|
||||
|
||||
case 'server_type':
|
||||
$result = __('Server type');
|
||||
break;
|
||||
|
||||
case 'interval':
|
||||
$result = __('Interval');
|
||||
break;
|
||||
|
||||
case 'status':
|
||||
$result = __('Status');
|
||||
break;
|
||||
|
||||
case 'graph':
|
||||
$result = __('Graph');
|
||||
break;
|
||||
|
||||
case 'warn':
|
||||
$result = __('Warn');
|
||||
break;
|
||||
|
||||
case 'data':
|
||||
$result = __('Data');
|
||||
break;
|
||||
|
||||
case 'timestamp':
|
||||
$result = __('Timestamp');
|
||||
break;
|
||||
|
||||
case 'to_critical':
|
||||
$result = __('Last status change');
|
||||
break;
|
||||
}
|
||||
|
||||
$result_selected[$field_selected] = $result;
|
||||
}
|
||||
}
|
||||
|
||||
echo '<h3>'.__('Show monitor detail fields').'</h3>';
|
||||
|
@ -115,17 +128,16 @@ $table = new stdClass();
|
|||
$table->width = '100%';
|
||||
$table->class = 'databox filters';
|
||||
|
||||
$table->size = array();
|
||||
//~ $table->size[0] = '20%';
|
||||
$table->size = [];
|
||||
// ~ $table->size[0] = '20%';
|
||||
$table->size[1] = '10px';
|
||||
//~ $table->size[2] = '20%';
|
||||
|
||||
// ~ $table->size[2] = '20%';
|
||||
$table->style[0] = 'text-align:center;';
|
||||
$table->style[2] = 'text-align:center;';
|
||||
|
||||
$table->data = array();
|
||||
$table->data = [];
|
||||
|
||||
$fields_available = array();
|
||||
$fields_available = [];
|
||||
|
||||
$fields_available['policy'] = __('Policy');
|
||||
$fields_available['agent'] = __('Agent');
|
||||
|
@ -140,36 +152,56 @@ $fields_available['data'] = __('Data');
|
|||
$fields_available['timestamp'] = __('Timestamp');
|
||||
$fields_available['to_critical'] = __('Last status change');
|
||||
|
||||
//remove fields already selected
|
||||
foreach ($fields_available as $key=>$available) {
|
||||
foreach ($result_selected as $selected) {
|
||||
if ($selected == $available) {
|
||||
unset($fields_available[$key]);
|
||||
}
|
||||
}
|
||||
// remove fields already selected
|
||||
foreach ($fields_available as $key => $available) {
|
||||
foreach ($result_selected as $selected) {
|
||||
if ($selected == $available) {
|
||||
unset($fields_available[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$table->data[0][0] = '<b>' . __('Fields available').'</b>';
|
||||
$table->data[1][0] = html_print_select ($fields_available, 'fields_available[]', true, '', '', 0, true, true, false, '', false, 'width: 300px');
|
||||
$table->data[1][1] = '<a href="javascript:">' .
|
||||
html_print_image('images/darrowright.png', true,
|
||||
array('id' => 'right', 'title' => __('Add fields to select'))) .
|
||||
'</a>';
|
||||
$table->data[1][1] .= '<br><br><br><br><a href="javascript:">' .
|
||||
html_print_image('images/darrowleft.png', true,
|
||||
array('id' => 'left', 'title' => __('Delete fields to select'))) .
|
||||
'</a>';
|
||||
$table->data[0][0] = '<b>'.__('Fields available').'</b>';
|
||||
$table->data[1][0] = html_print_select($fields_available, 'fields_available[]', true, '', '', 0, true, true, false, '', false, 'width: 300px');
|
||||
$table->data[1][1] = '<a href="javascript:">'.html_print_image(
|
||||
'images/darrowright.png',
|
||||
true,
|
||||
[
|
||||
'id' => 'right',
|
||||
'title' => __('Add fields to select'),
|
||||
]
|
||||
).'</a>';
|
||||
$table->data[1][1] .= '<br><br><br><br><a href="javascript:">'.html_print_image(
|
||||
'images/darrowleft.png',
|
||||
true,
|
||||
[
|
||||
'id' => 'left',
|
||||
'title' => __('Delete fields to select'),
|
||||
]
|
||||
).'</a>';
|
||||
|
||||
$table->data[0][1] = '';
|
||||
$table->data[0][2] = '<b>' . __('Fields selected') . '</b>';
|
||||
$table->data[1][2] = html_print_select($result_selected,
|
||||
'fields_selected[]', true, '', '', 0, true, true, false, '', false, 'width: 300px');
|
||||
$table->data[0][2] = '<b>'.__('Fields selected').'</b>';
|
||||
$table->data[1][2] = html_print_select(
|
||||
$result_selected,
|
||||
'fields_selected[]',
|
||||
true,
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
'width: 300px'
|
||||
);
|
||||
|
||||
echo '<form id="custom_status_monitor" method="post" action="index.php?sec=view&sec2=operation/agentes/status_monitor§ion=fields&pure='.$config['pure'].'">';
|
||||
html_print_table($table);
|
||||
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||
html_print_submit_button (__('Update'), 'upd_button', false, 'class="sub upd"');
|
||||
html_print_submit_button(__('Update'), 'upd_button', false, 'class="sub upd"');
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
?>
|
||||
|
@ -177,64 +209,64 @@ echo '</div>';
|
|||
<script type="text/javascript">
|
||||
/* <![CDATA[ */
|
||||
$(document).ready (function () {
|
||||
|
||||
$("#right").click (function () {
|
||||
jQuery.each($("select[name='fields_available[]'] option:selected"), function (key, value) {
|
||||
field_name = $(value).html();
|
||||
if (field_name != <?php echo "'".__('None')."'"; ?>) {
|
||||
id_field = $(value).attr('value');
|
||||
$("select[name='fields_selected[]']").append($("<option></option>").html(field_name).attr("value", id_field));
|
||||
$("#fields_available").find("option[value='" + id_field + "']").remove();
|
||||
$("#fields_selected").find("option[value='0']").remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#left").click (function () {
|
||||
var current_fields_size = ($('#fields_selected option').length);
|
||||
var selected_fields = [];
|
||||
var selected_fields_total = '';
|
||||
|
||||
$("#right").click (function () {
|
||||
jQuery.each($("select[name='fields_available[]'] option:selected"), function (key, value) {
|
||||
field_name = $(value).html();
|
||||
if (field_name != <?php echo "'".__('None')."'"; ?>) {
|
||||
id_field = $(value).attr('value');
|
||||
$("select[name='fields_selected[]']").append($("<option></option>").html(field_name).attr("value", id_field));
|
||||
$("#fields_available").find("option[value='" + id_field + "']").remove();
|
||||
$("#fields_selected").find("option[value='0']").remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#left").click (function () {
|
||||
var current_fields_size = ($('#fields_selected option').length);
|
||||
var selected_fields = [];
|
||||
var selected_fields_total = '';
|
||||
|
||||
jQuery.each($("select[name='fields_selected[]'] option:selected"), function (key, value) {
|
||||
field_name = $(value).html();
|
||||
selected_fields.push(field_name);
|
||||
selected_fields_total = selected_fields.length;
|
||||
});
|
||||
jQuery.each($("select[name='fields_selected[]'] option:selected"), function (key, value) {
|
||||
field_name = $(value).html();
|
||||
selected_fields.push(field_name);
|
||||
selected_fields_total = selected_fields.length;
|
||||
});
|
||||
|
||||
if(selected_fields_total === current_fields_size){
|
||||
display_confirm_dialog(
|
||||
"<?php echo '<span style=text-transform:none;font-size:9.5pt;>'.__('There must be at least one custom field. Timestamp will be set by default').'</span>'; ?>",
|
||||
"<?php echo __('Confirm'); ?>",
|
||||
"<?php echo __('Cancel'); ?>",
|
||||
function () {
|
||||
move_left();
|
||||
$("#fields_available").find("option[value='timestamp']").remove();
|
||||
$("select[name='fields_selected[]']").append($("<option></option>").val('timestamp').html('<i>' + 'Timestamp' + '</i>'));
|
||||
}
|
||||
);
|
||||
}
|
||||
else{
|
||||
move_left();
|
||||
}
|
||||
});
|
||||
|
||||
$("#submit-upd_button").click(function () {
|
||||
$("#fields_selected").find("option[value='0']").remove();
|
||||
$('#fields_selected option').map(function() {
|
||||
$(this).prop('selected', true);
|
||||
});
|
||||
});
|
||||
if(selected_fields_total === current_fields_size){
|
||||
display_confirm_dialog(
|
||||
"<?php echo '<span style=text-transform:none;font-size:9.5pt;>'.__('There must be at least one custom field. Timestamp will be set by default').'</span>'; ?>",
|
||||
"<?php echo __('Confirm'); ?>",
|
||||
"<?php echo __('Cancel'); ?>",
|
||||
function () {
|
||||
move_left();
|
||||
$("#fields_available").find("option[value='timestamp']").remove();
|
||||
$("select[name='fields_selected[]']").append($("<option></option>").val('timestamp').html('<i>' + 'Timestamp' + '</i>'));
|
||||
}
|
||||
);
|
||||
}
|
||||
else{
|
||||
move_left();
|
||||
}
|
||||
});
|
||||
|
||||
$("#submit-upd_button").click(function () {
|
||||
$("#fields_selected").find("option[value='0']").remove();
|
||||
$('#fields_selected option').map(function() {
|
||||
$(this).prop('selected', true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function move_left(){
|
||||
jQuery.each($("select[name='fields_selected[]'] option:selected"), function (key, value) {
|
||||
field_name = $(value).html();
|
||||
if (field_name != <?php echo "'".__('None')."'"; ?>) {
|
||||
id_field = $(value).attr('value');
|
||||
$("select[name='fields_available[]']").append($("<option></option>").val(id_field).html('<i>' + field_name + '</i>'));
|
||||
$("#fields_selected").find("option[value='" + id_field + "']").remove();
|
||||
$("#fields_available").find("option[value='0']").remove();
|
||||
}
|
||||
});
|
||||
jQuery.each($("select[name='fields_selected[]'] option:selected"), function (key, value) {
|
||||
field_name = $(value).html();
|
||||
if (field_name != <?php echo "'".__('None')."'"; ?>) {
|
||||
id_field = $(value).attr('value');
|
||||
$("select[name='fields_available[]']").append($("<option></option>").val(id_field).html('<i>' + field_name + '</i>'));
|
||||
$("#fields_selected").find("option[value='" + id_field + "']").remove();
|
||||
$("#fields_available").find("option[value='0']").remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -21,6 +21,21 @@ require_once 'include/functions_menu.php';
|
|||
$menu_godmode = [];
|
||||
$menu_godmode['class'] = 'godmode';
|
||||
|
||||
|
||||
if (check_acl($config['id_user'], 0, 'PM')) {
|
||||
$sub = [];
|
||||
$sub['godmode/servers/discovery']['text'] = __('Discover');
|
||||
$sub['godmode/servers/discovery']['id'] = 'Discover';
|
||||
$sub['godmode/servers/discovery']['subsecs'] = ['godmode/servers/discovery'];
|
||||
|
||||
// Add to menu.
|
||||
$menu_godmode['discover']['text'] = __('Discovery');
|
||||
$menu_godmode['discover']['sec2'] = 'godmode/servers/discovery';
|
||||
$menu_godmode['discover']['id'] = 'god-discovery';
|
||||
$menu_godmode['discover']['sub'] = $sub;
|
||||
}
|
||||
|
||||
|
||||
$sub = [];
|
||||
if (check_acl($config['id_user'], 0, 'AW') || check_acl($config['id_user'], 0, 'AD')) {
|
||||
$sub['godmode/agentes/modificar_agente']['text'] = __('Manage agents');
|
||||
|
@ -200,6 +215,7 @@ if (check_acl($config['id_user'], 0, 'AW') || check_acl($config['id_user'], 0, '
|
|||
$menu_godmode['gservers']['id'] = 'god-servers';
|
||||
|
||||
$sub = [];
|
||||
|
||||
if (check_acl($config['id_user'], 0, 'AW')) {
|
||||
$sub['godmode/servers/modificar_server']['text'] = __('Manage servers');
|
||||
$sub['godmode/servers/modificar_server']['id'] = 'Manage servers';
|
||||
|
@ -269,6 +285,9 @@ if (check_acl($config['id_user'], 0, 'PM')) {
|
|||
$sub2['godmode/setup/setup&section=ehorus']['text'] = __('eHorus');
|
||||
$sub2['godmode/setup/setup&section=ehorus']['refr'] = 0;
|
||||
|
||||
$sub2['godmode/setup/setup&section=notifications']['text'] = __('Notifications');
|
||||
$sub2['godmode/setup/setup&section=notifications']['refr'] = 0;
|
||||
|
||||
if ($config['activate_gis']) {
|
||||
$sub2['godmode/setup/gis']['text'] = __('Map conections GIS');
|
||||
}
|
||||
|
|
|
@ -0,0 +1,136 @@
|
|||
<?php
|
||||
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'AW')) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access Server Management'
|
||||
);
|
||||
include 'general/noaccess.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
ui_require_css_file('discovery');
|
||||
|
||||
ui_print_page_header(__('Discover'), '', false, '', true);
|
||||
|
||||
|
||||
/**
|
||||
* Mask class names.
|
||||
*
|
||||
* @param string $str Wiz parameter.
|
||||
*
|
||||
* @return string Classname.
|
||||
*/
|
||||
function get_wiz_class($str)
|
||||
{
|
||||
switch ($str) {
|
||||
case 'hd':
|
||||
return 'HostDevices';
|
||||
|
||||
case 'cloud':
|
||||
return 'Cloud';
|
||||
|
||||
case 'tasklist':
|
||||
return 'DiscoveryTaskList';
|
||||
|
||||
case 'app':
|
||||
return 'Applications';
|
||||
|
||||
case 'ctask':
|
||||
return 'ConsoleTasks';
|
||||
|
||||
default:
|
||||
// Ignore.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Aux. function to compare classpath names.
|
||||
*
|
||||
* @param string $a Classpath A.
|
||||
* @param string $b Classpath B.
|
||||
*
|
||||
* @return string Matching one.
|
||||
*/
|
||||
function cl_load_cmp($a, $b)
|
||||
{
|
||||
$str_a = basename($a, '.class.php');
|
||||
$str_b = basename($b, '.class.php');
|
||||
if ($str_a == $str_b) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($str_a < $str_b) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* CLASS LOADER.
|
||||
*/
|
||||
|
||||
// Dynamic class loader.
|
||||
$classes = glob($config['homedir'].'/godmode/wizards/*.class.php');
|
||||
if (enterprise_installed()) {
|
||||
$ent_classes = glob(
|
||||
$config['homedir'].'/enterprise/godmode/wizards/*.class.php'
|
||||
);
|
||||
if ($ent_classes === false) {
|
||||
$ent_classes = [];
|
||||
}
|
||||
|
||||
$classes = array_merge($classes, $ent_classes);
|
||||
}
|
||||
|
||||
foreach ($classes as $classpath) {
|
||||
include_once $classpath;
|
||||
}
|
||||
|
||||
// Sort output.
|
||||
uasort($classes, 'cl_load_cmp');
|
||||
|
||||
// Check user action.
|
||||
$wiz_in_use = get_parameter('wiz', null);
|
||||
$page = get_parameter('page', 0);
|
||||
|
||||
$classname_selected = get_wiz_class($wiz_in_use);
|
||||
|
||||
// Else: class not found pseudo exception.
|
||||
if ($classname_selected !== null) {
|
||||
$wiz = new $classname_selected($page);
|
||||
$result = $wiz->run();
|
||||
if (is_array($result) === true) {
|
||||
// Redirect control and messages to DiscoveryTasklist.
|
||||
$classname_selected = 'DiscoveryTaskList';
|
||||
$wiz = new $classname_selected($page);
|
||||
$result = $wiz->run($result['msg'], $result['result']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($classname_selected === null) {
|
||||
// Load classes and print selector.
|
||||
$wiz_data = [];
|
||||
foreach ($classes as $classpath) {
|
||||
$classname = basename($classpath, '.class.php');
|
||||
$obj = new $classname();
|
||||
|
||||
// DiscoveryTaskList must be first button.
|
||||
if ($classname == 'DiscoveryTaskList') {
|
||||
array_unshift($wiz_data, $obj->load());
|
||||
} else {
|
||||
$wiz_data[] = $obj->load();
|
||||
}
|
||||
}
|
||||
|
||||
Wizard::printBigButtonsList($wiz_data);
|
||||
}
|
|
@ -248,9 +248,9 @@ $table->rowclass[17] = 'recon_script';
|
|||
$table->data[0][0] = '<b>'.__('Task name').'</b>';
|
||||
$table->data[0][1] = html_print_input_text('name', $name, '', 25, 0, true);
|
||||
|
||||
// Recon server
|
||||
$table->data[1][0] = '<b>'.__('Recon server').ui_print_help_tip(
|
||||
__('You must select a Recon Server for the Task, otherwise the Recon Task will never run'),
|
||||
// Discovery server
|
||||
$table->data[1][0] = '<b>'.__('Discovery server').ui_print_help_tip(
|
||||
__('You must select a Discovery Server to run the Task, otherwise the Recon Task will never run'),
|
||||
true
|
||||
);
|
||||
|
||||
|
|
|
@ -524,6 +524,18 @@ if ($config['history_db_enabled'] == 1) {
|
|||
);
|
||||
}
|
||||
|
||||
$table->data[] = [
|
||||
__('Max. days before delete old messages'),
|
||||
html_print_input_text(
|
||||
'delete_old_messages',
|
||||
$config['delete_old_messages'],
|
||||
'',
|
||||
5,
|
||||
5,
|
||||
true
|
||||
),
|
||||
];
|
||||
|
||||
$table_other = new stdClass();
|
||||
$table_other->width = '100%';
|
||||
$table_other->class = 'databox filters';
|
||||
|
|
|
@ -122,6 +122,12 @@ $buttons['ehorus'] = [
|
|||
'text' => '<a href="index.php?sec=gsetup&sec2=godmode/setup/setup§ion=ehorus">'.html_print_image('images/ehorus/ehorus.png', true, ['title' => __('eHorus')]).'</a>',
|
||||
];
|
||||
|
||||
// FIXME: Not definitive icon
|
||||
$buttons['notifications'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="index.php?sec=gsetup&sec2=godmode/setup/setup§ion=notifications">'.html_print_image('images/alerts_template.png', true, ['title' => __('Notifications')]).'</a>',
|
||||
];
|
||||
|
||||
$help_header = '';
|
||||
if (enterprise_installed()) {
|
||||
$subpage = setup_enterprise_add_subsection_main($section, $buttons, $help_header);
|
||||
|
@ -159,6 +165,11 @@ switch ($section) {
|
|||
$buttons['ehorus']['active'] = true;
|
||||
$subpage = ' » '.__('eHorus');
|
||||
break;
|
||||
|
||||
case 'notifications':
|
||||
$buttons['notifications']['active'] = true;
|
||||
$subpage = ' » '.__('Notifications');
|
||||
break;
|
||||
}
|
||||
|
||||
// Header.
|
||||
|
@ -199,6 +210,10 @@ switch ($section) {
|
|||
include_once $config['homedir'].'/godmode/setup/setup_ehorus.php';
|
||||
break;
|
||||
|
||||
case 'notifications':
|
||||
include_once $config['homedir'].'/godmode/setup/setup_notifications.php';
|
||||
break;
|
||||
|
||||
default:
|
||||
enterprise_hook('setup_enterprise_select_tab', [$section]);
|
||||
break;
|
||||
|
|
|
@ -0,0 +1,413 @@
|
|||
<?php
|
||||
/**
|
||||
* Library. Notification system auxiliary functions.
|
||||
*
|
||||
* @category UI file
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
global $config;
|
||||
|
||||
require_once $config['homedir'].'/include/functions_notifications.php';
|
||||
|
||||
check_login();
|
||||
|
||||
// AJAX actions.
|
||||
$source = get_parameter('source', '');
|
||||
$users = get_parameter('users', '');
|
||||
$elements = get_parameter('elements', []);
|
||||
$is_users = $users === 'users';
|
||||
if (get_parameter('get_selection_two_ways_form', 0)) {
|
||||
$info_selec = ($is_users === true) ? notifications_get_user_source_not_configured($source) : notifications_get_group_source_not_configured($source);
|
||||
|
||||
echo notifications_print_two_ways_select(
|
||||
$info_selec,
|
||||
$users,
|
||||
$source
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (get_parameter('add_source_to_database', 0)) {
|
||||
$res = ($is_users) ? notifications_add_users_to_source($source, $elements) : notifications_add_group_to_source($source, $elements);
|
||||
$result = ['result' => $res];
|
||||
echo json_encode($result);
|
||||
return;
|
||||
}
|
||||
|
||||
if (get_parameter('remove_source_on_database', 0)) {
|
||||
$res = ($is_users) ? notifications_remove_users_from_source($source, $elements) : notifications_remove_group_from_source($source, $elements);
|
||||
$result = ['result' => $res];
|
||||
echo json_encode($result);
|
||||
return;
|
||||
}
|
||||
|
||||
if (get_parameter('update_config', 0)) {
|
||||
$element = (string) get_parameter('element', '');
|
||||
$value = (int) get_parameter('value', 0);
|
||||
|
||||
// Update the label value.
|
||||
ob_clean();
|
||||
$res = false;
|
||||
switch ($element) {
|
||||
// All users has other action.
|
||||
case 'all_users':
|
||||
$res = ($value) ? notifications_add_group_to_source($source, [0]) : notifications_remove_group_from_source($source, [0]);
|
||||
break;
|
||||
|
||||
default:
|
||||
$res = (bool) db_process_sql_update(
|
||||
'tnotification_source',
|
||||
[$element => $value],
|
||||
['id' => $source]
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
echo json_encode(['result' => $res]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (get_parameter('check_new_notifications', 0)) {
|
||||
$last_id_ui = (int) get_parameter('last_id', 0);
|
||||
$counters = notifications_get_counters();
|
||||
if ((int) $last_id_ui === (int) $counters['last_id']) {
|
||||
echo json_encode(['has_new_notifications' => false]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (messages_get_count() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$messages = messages_get_overview(
|
||||
'timestamp',
|
||||
'ASC',
|
||||
false,
|
||||
true,
|
||||
0,
|
||||
['id_mensaje' => '>'.$last_id_ui]
|
||||
);
|
||||
if ($messages === false) {
|
||||
$messages = [];
|
||||
}
|
||||
|
||||
// If there is new messages, get the info.
|
||||
echo json_encode(
|
||||
[
|
||||
'has_new_notifications' => true,
|
||||
'new_ball' => base64_encode(
|
||||
notifications_print_ball(
|
||||
$counters['notifications'],
|
||||
$counters['last_id']
|
||||
)
|
||||
),
|
||||
'new_notifications' => array_map(
|
||||
function ($elem) {
|
||||
$elem['full_url'] = messages_get_url($elem['id_mensaje']);
|
||||
return $elem;
|
||||
},
|
||||
$messages
|
||||
),
|
||||
]
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (get_parameter('mark_notification_as_read', 0)) {
|
||||
$message = (int) get_parameter('message', 0);
|
||||
messages_process_read($message);
|
||||
// TODO check read.
|
||||
$url = messages_get_url($message);
|
||||
// Return false if cannot get the URL.
|
||||
if ($url === false) {
|
||||
echo json_encode(['result' => false]);
|
||||
return;
|
||||
}
|
||||
|
||||
// If there is new messages, get the info.
|
||||
echo json_encode(
|
||||
[
|
||||
'result' => true,
|
||||
'url' => $url,
|
||||
]
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (get_parameter('get_notifications_dropdown', 0)) {
|
||||
echo notifications_print_dropdown();
|
||||
return;
|
||||
}
|
||||
|
||||
// Notification table. It is just a wrapper.
|
||||
$table_content = new StdClass();
|
||||
$table_content->data = [];
|
||||
$table_content->width = '100%';
|
||||
$table_content->id = 'notifications-wrapper';
|
||||
$table_content->class = 'databox filters';
|
||||
$table_content->size['name'] = '30%';
|
||||
|
||||
// Print each source configuration.
|
||||
$table_content->data = array_map(
|
||||
function ($source) {
|
||||
return notifications_print_global_source_configuration($source);
|
||||
},
|
||||
notifications_get_all_sources()
|
||||
);
|
||||
|
||||
html_print_table($table_content);
|
||||
|
||||
?>
|
||||
<script>
|
||||
// Get index of two ways element dialog.
|
||||
function notifications_two_ways_element_get_dialog (id, source_id) {
|
||||
return 'global_config_notifications_dialog_add-' + id + '-' + source_id;
|
||||
}
|
||||
|
||||
// Get index of two ways element form.
|
||||
function notifications_two_ways_element_get_sufix (id, source_id) {
|
||||
return 'multi-' + id + '-' + source_id;
|
||||
}
|
||||
|
||||
// Open a dialog with selector of source elements.
|
||||
function add_source_dialog(users, source_id) {
|
||||
// Display the dialog
|
||||
var dialog_id = notifications_two_ways_element_get_dialog(users, source_id);
|
||||
// Clean id element.
|
||||
var previous_dialog = document.getElementById(dialog_id);
|
||||
if (previous_dialog !== null) previous_dialog.remove();
|
||||
// Create or recreate the content.
|
||||
var not_dialog = document.createElement('div');
|
||||
not_dialog.setAttribute(
|
||||
'class',
|
||||
'global_config_notifications_dialog_add_wrapper'
|
||||
);
|
||||
not_dialog.setAttribute('id', dialog_id);
|
||||
document.body.appendChild(not_dialog);
|
||||
$("#" + dialog_id).dialog({
|
||||
resizable: false,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
dialogClass: "global_config_notifications_dialog_add_full",
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
},
|
||||
closeOnEscape: true,
|
||||
modal: true
|
||||
});
|
||||
|
||||
jQuery.post ("ajax.php",
|
||||
{"page" : "godmode/setup/setup_notifications",
|
||||
"get_selection_two_ways_form" : 1,
|
||||
"users" : users,
|
||||
"source" : source_id
|
||||
},
|
||||
function (data, status) {
|
||||
not_dialog.innerHTML = data
|
||||
},
|
||||
"html"
|
||||
);
|
||||
}
|
||||
|
||||
// Move from selected and not selected source elements.
|
||||
function notifications_modify_two_ways_element (id, source_id, operation) {
|
||||
var index_sufix = notifications_two_ways_element_get_sufix (id, source_id);
|
||||
var start_id = operation === 'add' ? 'all-' : 'selected-';
|
||||
var end_id = operation !== 'add' ? 'all-' : 'selected-';
|
||||
var select = document.getElementById(
|
||||
start_id + index_sufix
|
||||
);
|
||||
var select_end = document.getElementById(
|
||||
end_id + index_sufix
|
||||
);
|
||||
for (var i = select.options.length - 1; i >= 0; i--) {
|
||||
if(select.options[i].selected){
|
||||
select_end.appendChild(select.options[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add elements to database and close dialog
|
||||
function notifications_add_source_element_to_database(id, source_id) {
|
||||
var index = 'selected-' +
|
||||
notifications_two_ways_element_get_sufix (id, source_id);
|
||||
var select = document.getElementById(index);
|
||||
var selected = [];
|
||||
for (var i = select.options.length - 1; i >= 0; i--) {
|
||||
selected.push(select.options[i].value);
|
||||
}
|
||||
jQuery.post ("ajax.php",
|
||||
{"page" : "godmode/setup/setup_notifications",
|
||||
"add_source_to_database" : 1,
|
||||
"users" : id,
|
||||
"source" : source_id,
|
||||
"elements": selected
|
||||
},
|
||||
function (data, status) {
|
||||
if (data.result) {
|
||||
// Append to other element
|
||||
var out_select = document.getElementById(
|
||||
notifications_two_ways_element_get_sufix(id, source_id)
|
||||
);
|
||||
for (var i = select.options.length - 1; i >= 0; i--) {
|
||||
out_select.appendChild(select.options[i]);
|
||||
}
|
||||
// Close the dialog
|
||||
$("#" + notifications_two_ways_element_get_dialog(
|
||||
id,
|
||||
source_id
|
||||
))
|
||||
.dialog("close");
|
||||
} else {
|
||||
console.log("Cannot update element.");
|
||||
}
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
// Add elements to database and remove it form main select
|
||||
function remove_source_elements(id, source_id) {
|
||||
var index = notifications_two_ways_element_get_sufix(id, source_id);
|
||||
var select = document.getElementById(index);
|
||||
var selected = [];
|
||||
var selected_index = [];
|
||||
for (var i = select.options.length - 1; i >= 0; i--) {
|
||||
if(select.options[i].selected){
|
||||
selected.push(select.options[i].value);
|
||||
selected_index.push(i);
|
||||
}
|
||||
}
|
||||
jQuery.post ("ajax.php",
|
||||
{"page" : "godmode/setup/setup_notifications",
|
||||
"remove_source_on_database" : 1,
|
||||
"users" : id,
|
||||
"source" : source_id,
|
||||
"elements": selected
|
||||
},
|
||||
function (data, status) {
|
||||
if (data.result) {
|
||||
// Append to other element
|
||||
for (var i = 0; i < selected_index.length; i++) {
|
||||
select.remove(selected_index[i]);
|
||||
}
|
||||
} else {
|
||||
console.log("Cannot delete elements.");
|
||||
}
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function notifications_handle_change_element(event) {
|
||||
event.preventDefault();
|
||||
var match = /nt-([0-9]+)-(.*)/.exec(event.target.id);
|
||||
if (!match) {
|
||||
console.error(
|
||||
"Cannot handle change element. Id not valid: ", event.target.id
|
||||
);
|
||||
return;
|
||||
}
|
||||
var action = {source: match[1], bit: match[2]};
|
||||
var element = document.getElementById(event.target.id);
|
||||
if (element === null) {
|
||||
console.error(
|
||||
"Cannot get element. Id: ", event.target.id
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
var value;
|
||||
switch (action.bit) {
|
||||
case 'enabled':
|
||||
case 'also_mail':
|
||||
case 'user_editable':
|
||||
case 'all_users':
|
||||
value = element.checked ? 1 : 0;
|
||||
break;
|
||||
case 'max_postpone_time':
|
||||
value = element.value;
|
||||
break;
|
||||
default:
|
||||
console.error("Unregonized action", action.bit, '.');
|
||||
return;
|
||||
|
||||
}
|
||||
jQuery.post ("ajax.php",
|
||||
{
|
||||
"page" : "godmode/setup/setup_notifications",
|
||||
"update_config" : 1,
|
||||
"source" : match[1],
|
||||
"element" : match[2],
|
||||
"value": value
|
||||
},
|
||||
function (data, status) {
|
||||
if (!data.result) {
|
||||
console.error("Error changing configuration in database.");
|
||||
} else {
|
||||
switch (action.bit) {
|
||||
case 'enabled':
|
||||
case 'also_mail':
|
||||
case 'user_editable':
|
||||
case 'all_users':
|
||||
element.checked = !element.checked;
|
||||
break;
|
||||
case 'max_postpone_time':
|
||||
value = element.value;
|
||||
break;
|
||||
default:
|
||||
console.error(
|
||||
"Unregonized action (insert on db)", action.bit, '.'
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
"json"
|
||||
)
|
||||
.done(function(m){})
|
||||
.fail(function(xhr, textStatus, errorThrown){
|
||||
console.error(
|
||||
"Cannot change configuration in database. Server error.",
|
||||
xhr.responseText
|
||||
);
|
||||
});
|
||||
}
|
||||
(function(){
|
||||
// Add listener to all componentes marked
|
||||
var all_clickables = document.getElementsByClassName('elem-clickable');
|
||||
for (var i = 0; i < all_clickables.length; i++) {
|
||||
all_clickables[i].addEventListener(
|
||||
'click', notifications_handle_change_element, false
|
||||
);
|
||||
}
|
||||
var all_changes = document.getElementsByClassName('elem-changeable');
|
||||
for (var i = 0; i < all_changes.length; i++) {
|
||||
all_changes[i].addEventListener(
|
||||
'change', notifications_handle_change_element, false
|
||||
);
|
||||
}
|
||||
})();
|
||||
</script>
|
|
@ -751,7 +751,7 @@ if ($create_alert || $update_alert) {
|
|||
|
||||
// echo '<tr><td class="datos"><b>' . __('Alert filters') . ui_print_help_icon("snmp_alert_filters", true) . '</b></td></tr>';
|
||||
// OID
|
||||
echo '<tr id="tr-oid">'.'<td class="datos2">'.__('Enterprise String').ui_print_help_tip (__('Matches substrings. End the string with $ for exact matches.'), true).'</td>'.'<td class="datos2">';
|
||||
echo '<tr id="tr-oid">'.'<td class="datos2">'.__('Enterprise String').ui_print_help_tip(__('Matches substrings. End the string with $ for exact matches.'), true).'</td>'.'<td class="datos2">';
|
||||
html_print_input_text('oid', $oid, '', 50, 255);
|
||||
echo '</td></tr>';
|
||||
|
||||
|
|
|
@ -0,0 +1,984 @@
|
|||
<?php
|
||||
/**
|
||||
* Extension to schedule tasks on Pandora FMS Console
|
||||
*
|
||||
* @category Wizard
|
||||
* @package Pandora FMS
|
||||
* @subpackage Host&Devices
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
require_once __DIR__.'/Wizard.main.php';
|
||||
require_once $config['homedir'].'/include/functions_users.php';
|
||||
require_once $config['homedir'].'/include/functions_reports.php';
|
||||
require_once $config['homedir'].'/include/functions_cron.php';
|
||||
|
||||
/**
|
||||
* Defined as wizard to guide user to explore running tasks.
|
||||
*/
|
||||
class DiscoveryTaskList extends Wizard
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param integer $page Start page, by default 0.
|
||||
* @param string $msg Custom default mesage.
|
||||
* @param string $icon Custom icon.
|
||||
* @param string $label Custom label.
|
||||
*
|
||||
* @return class HostDevices
|
||||
*/
|
||||
public function __construct(
|
||||
int $page=0,
|
||||
string $msg='Default message. Not set.',
|
||||
string $icon='images/wizard/tasklist.png',
|
||||
string $label='Task list'
|
||||
) {
|
||||
$this->setBreadcrum([]);
|
||||
|
||||
$this->task = [];
|
||||
$this->msg = $msg;
|
||||
$this->icon = $icon;
|
||||
$this->label = __($label);
|
||||
$this->page = $page;
|
||||
$this->url = ui_get_full_url(
|
||||
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist'
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements run method.
|
||||
*
|
||||
* @return mixed Returns null if wizard is ongoing. Result if done.
|
||||
*/
|
||||
public function run($message='', $status=null)
|
||||
{
|
||||
global $config;
|
||||
// Load styles.
|
||||
parent::run();
|
||||
|
||||
$this->prepareBreadcrum(
|
||||
[
|
||||
[
|
||||
'link' => 'index.php?sec=gservers&sec2=godmode/servers/discovery',
|
||||
'label' => 'Discovery',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->printHeader();
|
||||
|
||||
// Show redirected messages from discovery.php.
|
||||
if ($status === 0) {
|
||||
ui_print_success_message($message);
|
||||
} else if ($status !== null) {
|
||||
ui_print_error_message($message);
|
||||
}
|
||||
|
||||
$force_run = (bool) get_parameter('force_run');
|
||||
if ($force_run === true) {
|
||||
return $this->forceConsoleTask();
|
||||
}
|
||||
|
||||
$delete_console_task = (bool) get_parameter('delete_console_task');
|
||||
if ($delete_console_task === true) {
|
||||
return $this->deleteConsoleTask();
|
||||
}
|
||||
|
||||
$delete = (bool) get_parameter('delete', false);
|
||||
if ($delete === true) {
|
||||
return $this->deleteTask();
|
||||
}
|
||||
|
||||
if (enterprise_installed()) {
|
||||
// This check only applies to enterprise users.
|
||||
// Check if DiscoveryCronTasks is running. Warn user if not.
|
||||
if ($config['cron_last_run'] == 0
|
||||
|| (get_system_time() - $config['cron_last_run']) > 3600
|
||||
) {
|
||||
$message_conf_cron = __('DiscoveryConsoleTasks is not running properly').'. ';
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
|
||||
$message_conf_cron .= __('Discovery relies on a proper setup of cron, the time-based scheduling service');
|
||||
$message_conf_cron .= '. '.__('Please, add the following line to your crontab file:');
|
||||
$message_conf_cron .= '<b><pre style="color: #333;">* * * * * <user> wget -q -O - --no-check-certificate ';
|
||||
$message_conf_cron .= str_replace(
|
||||
ENTERPRISE_DIR.'/meta/',
|
||||
'',
|
||||
ui_get_full_url(false)
|
||||
);
|
||||
$message_conf_cron .= ENTERPRISE_DIR.'/'.EXTENSIONS_DIR;
|
||||
$message_conf_cron .= '/cron/cron.php >> ';
|
||||
$message_conf_cron .= $config['homedir'].'/pandora_console.log</pre></b>';
|
||||
}
|
||||
|
||||
if (isset($config['cron_last_run']) === true
|
||||
&& $config['cron_last_run'] > 0
|
||||
) {
|
||||
$message_conf_cron .= '<p style="color: #333;">'.__('Last execution').': ';
|
||||
$message_conf_cron .= date('Y/m/d H:i:s', $config['cron_last_run']).'</p>';
|
||||
$message_conf_cron .= '<p style="color: #333;">';
|
||||
$message_conf_cron .= __('Please check process is no locked.').'</p>';
|
||||
}
|
||||
|
||||
ui_print_warning_message($message_conf_cron, '', false);
|
||||
}
|
||||
}
|
||||
|
||||
$ret = $this->showListConsoleTask();
|
||||
$ret2 = $this->showList();
|
||||
|
||||
if ($ret === false && $ret2 === false) {
|
||||
include_once $config['homedir'].'/general/firts_task/recon_view.php';
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements load method.
|
||||
*
|
||||
* @return mixed Skeleton for button.
|
||||
*/
|
||||
public function load()
|
||||
{
|
||||
return [
|
||||
'icon' => $this->icon,
|
||||
'label' => $this->label,
|
||||
'url' => $this->url,
|
||||
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a recon task.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteTask()
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'PM')) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access recon task viewer'
|
||||
);
|
||||
include 'general/noaccess.php';
|
||||
return;
|
||||
}
|
||||
|
||||
$task = get_parameter('task', null);
|
||||
|
||||
if ($task !== null) {
|
||||
$result = db_process_sql_delete(
|
||||
'trecon_task',
|
||||
['id_rt' => $task]
|
||||
);
|
||||
|
||||
if ($result == 1) {
|
||||
return [
|
||||
'result' => 0,
|
||||
'msg' => __('Task successfully deleted'),
|
||||
'id' => false,
|
||||
];
|
||||
}
|
||||
|
||||
// Trick to avoid double execution.
|
||||
header('Location: '.$this->url);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Force console task.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function forceConsoleTask()
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'PM')) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access recon task viewer'
|
||||
);
|
||||
include 'general/noaccess.php';
|
||||
return;
|
||||
}
|
||||
|
||||
$id_console_task = (int) get_parameter('id_console_task');
|
||||
|
||||
if ($id_console_task !== null) {
|
||||
cron_task_run($id_console_task, true);
|
||||
// Trick to avoid double execution.
|
||||
header('Location: '.$this->url);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a Console task.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteConsoleTask()
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'PM')) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access recon task viewer'
|
||||
);
|
||||
include 'general/noaccess.php';
|
||||
return;
|
||||
}
|
||||
|
||||
$id_console_task = (int) get_parameter('id_console_task');
|
||||
|
||||
if ($id_console_task !== null) {
|
||||
$result = db_process_sql_delete(
|
||||
'tuser_task_scheduled',
|
||||
['id' => $id_console_task]
|
||||
);
|
||||
|
||||
if ($result == 1) {
|
||||
return [
|
||||
'result' => 0,
|
||||
'msg' => __('Console Task successfully deleted'),
|
||||
'id' => false,
|
||||
];
|
||||
}
|
||||
|
||||
// Trick to avoid double execution.
|
||||
header('Location: '.$this->url);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show complete list of running tasks.
|
||||
*
|
||||
* @return boolean Success or not.
|
||||
*/
|
||||
public function showList()
|
||||
{
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'PM')) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access recon task viewer'
|
||||
);
|
||||
include 'general/noaccess.php';
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get all recon servers.
|
||||
$servers = db_get_all_rows_sql('SELECT * FROM tserver WHERE server_type = 3');
|
||||
if ($servers === false) {
|
||||
$servers = [];
|
||||
ui_print_error_message(__('Discovery Server is disabled'));
|
||||
return false;
|
||||
} else {
|
||||
$recon_task = db_get_all_rows_sql('SELECT * FROM trecon_task');
|
||||
if ($recon_task === false) {
|
||||
return false;
|
||||
} else {
|
||||
include_once $config['homedir'].'/include/functions_graph.php';
|
||||
include_once $config['homedir'].'/include/functions_servers.php';
|
||||
include_once $config['homedir'].'/include/functions_network_profiles.php';
|
||||
|
||||
$modules_server = 0;
|
||||
$total_modules = 0;
|
||||
$total_modules_data = 0;
|
||||
|
||||
// --------------------------------
|
||||
// FORCE A RECON TASK
|
||||
// --------------------------------
|
||||
if (check_acl($config['id_user'], 0, 'PM')) {
|
||||
if (isset($_GET['force'])) {
|
||||
$id = (int) get_parameter_get('force', 0);
|
||||
servers_force_recon_task($id);
|
||||
header(
|
||||
'Location: '.ui_get_full_url(
|
||||
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($servers as $serverItem) {
|
||||
$id_server = $serverItem['id_server'];
|
||||
$server_name = servers_get_name($id_server);
|
||||
$recon_tasks = db_get_all_rows_field_filter(
|
||||
'trecon_task',
|
||||
'id_recon_server',
|
||||
$id_server
|
||||
);
|
||||
|
||||
$user_groups = implode(',', array_keys(users_get_groups()));
|
||||
$defined_tasks = db_get_all_rows_filter(
|
||||
'tuser_task_scheduled',
|
||||
'id_grupo IN ('.$user_groups.')'
|
||||
);
|
||||
|
||||
if (isset($tasks_console) === true
|
||||
&& is_array($tasks_console) === true
|
||||
) {
|
||||
foreach ($tasks_console as $key => $value) {
|
||||
$value['parameters'] = unserialize(
|
||||
$value['parameters']
|
||||
);
|
||||
|
||||
$value['type'] = 'Cron';
|
||||
array_push($recon_tasks, $value);
|
||||
}
|
||||
}
|
||||
|
||||
// Show network tasks for Recon Server.
|
||||
if ($recon_tasks === false) {
|
||||
$recon_tasks = [];
|
||||
}
|
||||
|
||||
$table = new StdClass();
|
||||
$table->cellpadding = 4;
|
||||
$table->cellspacing = 4;
|
||||
$table->width = '100%';
|
||||
$table->class = 'databox data';
|
||||
$table->head = [];
|
||||
$table->data = [];
|
||||
$table->align = [];
|
||||
$table->headstyle = [];
|
||||
for ($i = 0; $i < 9; $i++) {
|
||||
$table->headstyle[$i] = 'text-align: left;';
|
||||
}
|
||||
|
||||
$table->head[0] = __('Force');
|
||||
$table->align[0] = 'left';
|
||||
|
||||
$table->head[1] = __('Task name');
|
||||
$table->align[1] = 'left';
|
||||
|
||||
$table->head[2] = __('Interval');
|
||||
$table->align[2] = 'left';
|
||||
|
||||
$table->head[3] = __('Network');
|
||||
$table->align[3] = 'left';
|
||||
|
||||
$table->head[4] = __('Status');
|
||||
$table->align[4] = 'left';
|
||||
|
||||
$table->head[5] = __('Task type');
|
||||
$table->align[5] = 'left';
|
||||
|
||||
$table->head[6] = __('Progress');
|
||||
$table->align[6] = 'left';
|
||||
|
||||
$table->head[7] = __('Updated at');
|
||||
$table->align[7] = 'left';
|
||||
|
||||
$table->head[8] = __('Operations');
|
||||
$table->align[8] = 'left';
|
||||
|
||||
foreach ($recon_tasks as $task) {
|
||||
$data = [];
|
||||
|
||||
if ($task['disabled'] == 0) {
|
||||
$data[0] = '<a href="'.ui_get_full_url(
|
||||
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist&server_id='.$id_server.'&force='.$task['id_rt']
|
||||
).'">';
|
||||
$data[0] .= html_print_image('images/target.png', true, ['title' => __('Force')]);
|
||||
$data[0] .= '</a>';
|
||||
} else if ($task['disabled'] == 2) {
|
||||
$data[0] = ui_print_help_tip(
|
||||
__('This task has not been completely defined, please edit it'),
|
||||
true
|
||||
);
|
||||
} else {
|
||||
$data[0] = '';
|
||||
}
|
||||
|
||||
$data[1] = '<b>'.$task['name'].'</b>';
|
||||
|
||||
if ($task['interval_sweep'] > 0) {
|
||||
$data[2] = human_time_description_raw(
|
||||
$task['interval_sweep']
|
||||
);
|
||||
} else {
|
||||
$data[2] = __('Manual');
|
||||
}
|
||||
|
||||
if ($task['id_recon_script'] == 0) {
|
||||
$data[3] = $task['subnet'];
|
||||
} else {
|
||||
$data[3] = '-';
|
||||
}
|
||||
|
||||
if ($task['status'] <= 0) {
|
||||
$data[4] = __('Done');
|
||||
} else {
|
||||
$data[4] = __('Pending');
|
||||
}
|
||||
|
||||
if ($task['id_recon_script'] == 0) {
|
||||
// Discovery NetScan.
|
||||
$data[5] = html_print_image(
|
||||
'images/network.png',
|
||||
true,
|
||||
['title' => __('Discovery NetScan')]
|
||||
).' ';
|
||||
$data[5] .= network_profiles_get_name(
|
||||
$task['id_network_profile']
|
||||
);
|
||||
} else {
|
||||
// APP recon task.
|
||||
$data[5] = html_print_image(
|
||||
'images/plugin.png',
|
||||
true
|
||||
).' ';
|
||||
$data[5] .= db_get_sql(
|
||||
sprintf(
|
||||
'SELECT name FROM trecon_script WHERE id_recon_script = %d',
|
||||
$task['id_recon_script']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($task['status'] <= 0 || $task['status'] > 100) {
|
||||
$data[6] = '-';
|
||||
} else {
|
||||
$data[6] = progress_bar(
|
||||
$task['status'],
|
||||
100,
|
||||
20,
|
||||
__('Progress').':'.$task['status'].'%',
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
if ($task['utimestamp'] > 0) {
|
||||
$data[7] = ui_print_timestamp(
|
||||
$task['utimestamp'],
|
||||
true
|
||||
);
|
||||
} else {
|
||||
$data[7] = __('Not executed yet');
|
||||
}
|
||||
|
||||
if (check_acl(
|
||||
$config['id_user'],
|
||||
$task['id_group'],
|
||||
'PM'
|
||||
)
|
||||
) {
|
||||
// Check if is a H&D, Cloud or Application.
|
||||
$data[8] = '<a href="'.ui_get_full_url(
|
||||
sprintf(
|
||||
'index.php?sec=gservers&sec2=godmode/servers/discovery&%s&task=%d',
|
||||
$this->getTargetWiz($task),
|
||||
$task['id_rt']
|
||||
)
|
||||
).'">'.html_print_image(
|
||||
'images/config.png',
|
||||
true
|
||||
).'</a>';
|
||||
$data[8] .= '<a href="'.ui_get_full_url(
|
||||
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist&delete=1&task='.$task['id_rt']
|
||||
).'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image(
|
||||
'images/cross.png',
|
||||
true
|
||||
).'</a>';
|
||||
} else {
|
||||
$data[8] = '';
|
||||
}
|
||||
|
||||
array_push($table->data, $data);
|
||||
}
|
||||
|
||||
if (empty($table->data)) {
|
||||
echo '<div class="nf">'.__('Server').' '.$server_name.' '.__('has no recon tasks assigned').'</div>';
|
||||
} else {
|
||||
echo '<h2>'.__('Server task').'</h2>';
|
||||
html_print_table($table);
|
||||
}
|
||||
|
||||
unset($table);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$form = [
|
||||
'form' => [
|
||||
'method' => 'POST',
|
||||
'action' => ui_get_full_url(
|
||||
'index.php?sec=gservers&sec2=godmode/servers/discovery'
|
||||
),
|
||||
],
|
||||
'inputs' => [
|
||||
[
|
||||
'arguments' => [
|
||||
'name' => 'submit',
|
||||
'label' => __('Go back'),
|
||||
'type' => 'submit',
|
||||
'attributes' => 'class="sub cancel"',
|
||||
'return' => true,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$this->printForm($form);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show complete list of running tasks.
|
||||
*
|
||||
* @return boolean Success or not.
|
||||
*/
|
||||
public function showListConsoleTask()
|
||||
{
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'PM')) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access recon task viewer'
|
||||
);
|
||||
include 'general/noaccess.php';
|
||||
return false;
|
||||
}
|
||||
|
||||
$read_perms = check_acl(
|
||||
$config['id_user'],
|
||||
0,
|
||||
'RR'
|
||||
);
|
||||
$write_perms = check_acl(
|
||||
$config['id_user'],
|
||||
0,
|
||||
'RW'
|
||||
);
|
||||
$manage_perms = check_acl(
|
||||
$config['id_user'],
|
||||
0,
|
||||
'RM'
|
||||
);
|
||||
$manage_pandora = check_acl(
|
||||
$config['id_user'],
|
||||
0,
|
||||
'PM'
|
||||
);
|
||||
|
||||
$url = 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist&';
|
||||
|
||||
$user_groups = implode(
|
||||
',',
|
||||
array_keys(users_get_groups())
|
||||
);
|
||||
|
||||
$defined_tasks = db_get_all_rows_filter(
|
||||
'tuser_task_scheduled',
|
||||
'id_grupo IN ('.$user_groups.')'
|
||||
);
|
||||
|
||||
if (!check_acl($config['id_user'], 0, 'PM')) {
|
||||
$read_tasks = [];
|
||||
foreach ($defined_tasks as $task) {
|
||||
$function_name = db_get_value(
|
||||
'function_name',
|
||||
'tuser_task',
|
||||
'id',
|
||||
$task['id_user_task']
|
||||
);
|
||||
|
||||
if (($function_name != 'cron_task_execute_custom_script')
|
||||
&& ($function_name != 'cron_task_do_backup')
|
||||
) {
|
||||
$read_tasks[] = $task;
|
||||
}
|
||||
}
|
||||
|
||||
$defined_tasks = $read_tasks;
|
||||
|
||||
if (empty($defined_tasks)) {
|
||||
$defined_tasks = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($defined_tasks !== false) {
|
||||
echo '<h2>'.__('Console task').'</h2>';
|
||||
|
||||
$table = new stdClass();
|
||||
$table->class = 'databox data';
|
||||
$table->width = '100%';
|
||||
$table->data = [];
|
||||
$table->head = [];
|
||||
$table->head[0] = '';
|
||||
$table->head[1] = __('User');
|
||||
$table->head[2] = __('Task');
|
||||
$table->head[3] = __('Scheduled');
|
||||
$table->head[4] = __('Next execution');
|
||||
$table->head[5] = __('Last run');
|
||||
$table->head[6] = __('Group');
|
||||
$table->head[7] = __('Operations');
|
||||
$table->align[7] = 'left';
|
||||
|
||||
foreach ($defined_tasks as $task) {
|
||||
$data = [];
|
||||
|
||||
$function_name = db_get_value(
|
||||
'function_name',
|
||||
'tuser_task',
|
||||
'id',
|
||||
$task['id_user_task']
|
||||
);
|
||||
|
||||
switch ($function_name) {
|
||||
case 'cron_task_generate_report':
|
||||
if ($write_perms || $manage_pandora) {
|
||||
$data[0] = '<a href="'.$url;
|
||||
$data[0] .= 'force_run=1&id_console_task='.$task['id'].'">';
|
||||
$data[0] .= html_print_image(
|
||||
'images/target.png',
|
||||
true,
|
||||
['title' => __('Force run')]
|
||||
);
|
||||
$data[0] .= '</a>';
|
||||
} else {
|
||||
$data[0] = '';
|
||||
}
|
||||
|
||||
$data[1] = $task['id_usuario'];
|
||||
$data[2] = db_get_value(
|
||||
'name',
|
||||
'tuser_task',
|
||||
'id',
|
||||
$task['id_user_task']
|
||||
);
|
||||
$args = unserialize($task['args']);
|
||||
$report = reports_get_report($args[0]);
|
||||
|
||||
// Check ACL in reports_get_report return false.
|
||||
if ($report === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$email = $args[1];
|
||||
$data[2] .= '<br>- '.__('Report').": <a href='index.php?sec=reporting&sec2=operation/reporting/reporting_viewer&id=".$args[0]."'>";
|
||||
$data[2] .= $report['name'].'</a>';
|
||||
$data[2] .= '<br>- '.__('Email').": <a href='mailto:".$email."'>";
|
||||
$data[2] .= ui_print_truncate_text(
|
||||
$email,
|
||||
60,
|
||||
false
|
||||
).'</a>';
|
||||
break;
|
||||
|
||||
case 'cron_task_generate_report_by_template':
|
||||
if ($write_perms || $manage_pandora) {
|
||||
$data[0] = '<a href="'.$url;
|
||||
$data[0] .= 'force_run=1&id_console_task='.$task['id'].'">';
|
||||
$data[0] .= html_print_image(
|
||||
'images/target.png',
|
||||
true,
|
||||
['title' => __('Force run')]
|
||||
);
|
||||
$data[0] .= '</a>';
|
||||
} else {
|
||||
$data[0] = '';
|
||||
}
|
||||
|
||||
$data[1] = $task['id_usuario'];
|
||||
$data[2] = db_get_value(
|
||||
'name',
|
||||
'tuser_task',
|
||||
'id',
|
||||
$task['id_user_task']
|
||||
);
|
||||
|
||||
$args = unserialize($task['args']);
|
||||
|
||||
$filter = [];
|
||||
$filter['id_report'] = $args[0];
|
||||
$template = db_get_row_filter(
|
||||
'treport_template',
|
||||
$filter,
|
||||
false
|
||||
);
|
||||
|
||||
// Check ACL in reports_get_report return false.
|
||||
if ($template === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$agents_id = $args[1];
|
||||
$id_group = $args[2];
|
||||
$report_per_agent = $args[0];
|
||||
$report_name = $args[3];
|
||||
$email = $args[4];
|
||||
$data[2] .= '<br>- '.__('Template').": <a href='index.php?sec=reporting&sec2=operation/reporting/reporting_viewer";
|
||||
$data[2] .= '&id='.$args[0]."'>".$template['name'].'</a>';
|
||||
$data[2] .= '<br>- '.__('Agents').': '.$agents_id.'</a>';
|
||||
$data[2] .= '<br>- '.__('Report per agent').': '.$report_per_agent.'</a>';
|
||||
$data[2] .= '<br>- '.__('Report name').': '.$report_name.'</a>';
|
||||
$data[2] .= '<br>- '.__('Email').": <a href='mailto:".$email."'>".$email.'</a>';
|
||||
break;
|
||||
|
||||
case 'cron_task_execute_custom_script':
|
||||
if ($manage_pandora) {
|
||||
$data[0] = '<a href="'.$url;
|
||||
$data[0] .= 'force_run=1&id_console_task='.$task['id'].'">';
|
||||
$data[0] .= html_print_image(
|
||||
'images/target.png',
|
||||
true,
|
||||
['title' => __('Force run')]
|
||||
);
|
||||
$data[0] .= '</a>';
|
||||
} else {
|
||||
$data[0] = '';
|
||||
}
|
||||
|
||||
$data[1] = $task['id_usuario'];
|
||||
$data[2] = db_get_value(
|
||||
'name',
|
||||
'tuser_task',
|
||||
'id',
|
||||
$task['id_user_task']
|
||||
);
|
||||
|
||||
$args = unserialize($task['args']);
|
||||
$data[2] .= '<br>- '.__('Custom script').': '.$args[0];
|
||||
break;
|
||||
|
||||
case 'cron_task_save_report_to_disk':
|
||||
if ($write_perms || $manage_pandora) {
|
||||
$data[0] = '<a href="'.$url;
|
||||
$data[0] .= 'force_run=1&id_console_task='.$task['id'].'">';
|
||||
$data[0] .= html_print_image(
|
||||
'images/target.png',
|
||||
true,
|
||||
['title' => __('Force run')]
|
||||
);
|
||||
$data[0] .= '</a>';
|
||||
} else {
|
||||
$data[0] = '';
|
||||
}
|
||||
|
||||
$data[1] = $task['id_usuario'];
|
||||
$data[2] = db_get_value(
|
||||
'name',
|
||||
'tuser_task',
|
||||
'id',
|
||||
$task['id_user_task']
|
||||
);
|
||||
|
||||
$args = unserialize($task['args']);
|
||||
$report = reports_get_report($args[0]);
|
||||
|
||||
// Check ACL in reports_get_report return false.
|
||||
if ($report === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$path = $args[1];
|
||||
$data[2] .= '<br>- '.__('Report').": <a href='index.php?sec=reporting&sec2=operation/reporting/reporting_viewer";
|
||||
$data[2] .= '&id='.$args[0]."'>".$report['name'].'</a>';
|
||||
$data[2] .= '<br>- '.__('Path').': '.$path.'</a>';
|
||||
break;
|
||||
|
||||
case 'cron_task_save_xml_report_to_disk':
|
||||
if ($write_perms || $manage_pandora) {
|
||||
$data[0] = '<a href="'.$url;
|
||||
$data[0] .= 'force_run=1&id_console_task='.$task['id'].'">';
|
||||
$data[0] .= html_print_image(
|
||||
'images/target.png',
|
||||
true,
|
||||
['title' => __('Force run')]
|
||||
);
|
||||
$data[0] .= '</a>';
|
||||
} else {
|
||||
$data[0] = '';
|
||||
}
|
||||
|
||||
$data[1] = $task['id_usuario'];
|
||||
$data[2] = db_get_value('name', 'tuser_task', 'id', $task['id_user_task']);
|
||||
$args = unserialize($task['args']);
|
||||
$report = reports_get_report($args[0]);
|
||||
|
||||
// Check ACL in reports_get_report return false.
|
||||
if ($report === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$path = $args[1];
|
||||
$data[2] .= '<br>- '.__('Report').": <a href='index.php?sec=reporting&sec2=operation/reporting/reporting_viewer";
|
||||
$data[2] .= '&id='.$args[0]."'>".$report['name'].'</a>';
|
||||
$data[2] .= '<br>- '.__('Path').': '.$path.'</a>';
|
||||
break;
|
||||
|
||||
case 'cron_task_do_backup':
|
||||
if ($manage_pandora) {
|
||||
$data[0] = '<a href="'.$url;
|
||||
$data[0] .= 'force_run=1&id_console_task='.$task['id'].'">';
|
||||
$data[0] .= html_print_image(
|
||||
'images/target.png',
|
||||
true,
|
||||
['title' => __('Force run')]
|
||||
);
|
||||
$data[0] .= '</a>';
|
||||
} else {
|
||||
$data[0] = '';
|
||||
}
|
||||
|
||||
$data[1] = $task['id_usuario'];
|
||||
$data[2] = db_get_value(
|
||||
'name',
|
||||
'tuser_task',
|
||||
'id',
|
||||
$task['id_user_task']
|
||||
);
|
||||
$args = unserialize($task['args']);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Ignore.
|
||||
break;
|
||||
}
|
||||
|
||||
$data[3] = cron_get_scheduled_string($task['scheduled']);
|
||||
$data[4] = date('Y/m/d H:i:s', $args['first_execution']);
|
||||
$data[5] = empty($task['last_run']) ? __('Never') : date('Y/m/d H:i:s', $task['last_run']);
|
||||
|
||||
$data[6] = ui_print_group_icon($task['id_grupo'], true);
|
||||
|
||||
if ($function_name == 'cron_task_do_backup' || $function_name == 'cron_task_execute_custom_script') {
|
||||
if ($manage_pandora) {
|
||||
$data[7] = '<a href="'.ui_get_full_url(
|
||||
sprintf(
|
||||
'index.php?sec=gservers&sec2=godmode/servers/discovery&%s&task=%d',
|
||||
$this->getTargetWiz(['description' => 'console_task']),
|
||||
$task['id']
|
||||
)
|
||||
).'">';
|
||||
$data[7] .= html_print_image(
|
||||
'images/config.png',
|
||||
true,
|
||||
['title' => __('Edit')]
|
||||
).'</a>';
|
||||
}
|
||||
|
||||
if ($manage_pandora) {
|
||||
$data[7] .= '<a href="'.$url;
|
||||
$data[7] .= 'delete_console_task=1&id_console_task='.$task['id'].'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
|
||||
$data[7] .= html_print_image(
|
||||
'images/cross.png',
|
||||
true,
|
||||
['title' => __('Delete')]
|
||||
);
|
||||
$data[7] .= '</a>';
|
||||
}
|
||||
} else {
|
||||
if ($write_perms || $manage_pandora) {
|
||||
$data[7] = '<a href="'.ui_get_full_url(
|
||||
sprintf(
|
||||
'index.php?sec=gservers&sec2=godmode/servers/discovery&%s&task=%d',
|
||||
$this->getTargetWiz(['description' => 'console_task']),
|
||||
$task['id']
|
||||
)
|
||||
).'">';
|
||||
$data[7] .= html_print_image(
|
||||
'images/config.png',
|
||||
true,
|
||||
['title' => __('Edit')]
|
||||
).'</a>';
|
||||
}
|
||||
|
||||
if ($manage_perms || $manage_pandora) {
|
||||
$data[7] .= '<a href="'.$url;
|
||||
$data[7] .= 'delete_console_task=1&id_console_task='.$task['id'].'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
|
||||
$data[7] .= html_print_image(
|
||||
'images/cross.png',
|
||||
true,
|
||||
['title' => __('Delete')]
|
||||
);
|
||||
$data[7] .= '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
array_push($table->data, $data);
|
||||
}
|
||||
|
||||
html_print_table($table);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return target url sub-string to edit target task.
|
||||
*
|
||||
* @param array $task With all data.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTargetWiz($task)
|
||||
{
|
||||
// TODO: Do not use description. Use recon_script ID instead.
|
||||
switch ($task['description']) {
|
||||
case 'Discovery.Application.VMware':
|
||||
return 'wiz=app&mode=vmware&page=0';
|
||||
|
||||
case CLOUDWIZARD_AWS_DESCRIPTION:
|
||||
return 'wiz=cloud&mode=amazonws&page=1';
|
||||
|
||||
case 'console_task':
|
||||
return 'wiz=ctask';
|
||||
|
||||
default:
|
||||
return 'wiz=hd&mode=netscan';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,678 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Interfaz tope gama que obliga a implementar metodos.
|
||||
*/
|
||||
|
||||
define('CLOUDWIZARD_AWS_DESCRIPTION', 'Discovery.Cloud.AWS.EC2');
|
||||
|
||||
class Wizard
|
||||
{
|
||||
|
||||
/**
|
||||
* Breadcrum
|
||||
*
|
||||
* @var array.
|
||||
*/
|
||||
public $breadcrum;
|
||||
|
||||
/**
|
||||
* Undocumented variable
|
||||
*
|
||||
* @var [type]
|
||||
*/
|
||||
public $page;
|
||||
|
||||
/**
|
||||
* Target icon to be shown in discovery wizard list.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $icon;
|
||||
|
||||
/**
|
||||
* Target label to be shown in discovery wizard list.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $label;
|
||||
|
||||
/**
|
||||
* This wizard's url.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $url;
|
||||
|
||||
/**
|
||||
* Result of wizard execution (0 - ok, 1 - not ok).
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $result;
|
||||
|
||||
/**
|
||||
* Message to be delivered to user.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $msg;
|
||||
|
||||
|
||||
/**
|
||||
* Setter for breadcrum
|
||||
*
|
||||
* @param array $str Breadcrum.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setBreadcrum(array $str)
|
||||
{
|
||||
$this->breadcrum = $str;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Getter for breadcrum
|
||||
*
|
||||
* @return array Breadcrum.
|
||||
*/
|
||||
public function getBreadcrum()
|
||||
{
|
||||
return $this->breadcrum;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add an element to breadcrum array.
|
||||
*
|
||||
* @param string $breads Elements to add to breadcrum.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function addBreadcrum($breads)
|
||||
{
|
||||
if (empty($breads)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->breadcrum = array_merge($this->breadcrum, $breads);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setter for label
|
||||
*
|
||||
* @param string $str Label.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setLabel(string $str)
|
||||
{
|
||||
$this->label = $str;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Getter for label
|
||||
*
|
||||
* @return array Breadcrum.
|
||||
*/
|
||||
public function getLabel()
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return units associated to target interval (in seconds).
|
||||
*
|
||||
* @param integer $interval Target interval.
|
||||
*
|
||||
* @return integer Unit.
|
||||
*/
|
||||
public function getTimeUnit($interval)
|
||||
{
|
||||
$units = [
|
||||
1,
|
||||
60,
|
||||
3600,
|
||||
86400,
|
||||
604800,
|
||||
2592000,
|
||||
31104000,
|
||||
];
|
||||
|
||||
$size = count($units);
|
||||
for ($i = 0; $i < $size; $i++) {
|
||||
if ($interval < $units[$i]) {
|
||||
if (($i - 1) < 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return $units[($i - 1)];
|
||||
}
|
||||
}
|
||||
|
||||
return $units[-1];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Builder for breadcrum
|
||||
*
|
||||
* @param array $urls Array of urls to be stored in breadcrum.
|
||||
* @param boolean $add True if breadcrum should be added instead of
|
||||
* overwrite it.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function prepareBreadcrum(array $urls, bool $add=false)
|
||||
{
|
||||
$bc = [];
|
||||
$i = 0;
|
||||
foreach ($urls as $url) {
|
||||
if ($url['selected'] == 1) {
|
||||
$class = 'selected';
|
||||
} else {
|
||||
$class = '';
|
||||
}
|
||||
|
||||
$bc[$i] = '<a href="'.$url['link'].'" class="text_color">';
|
||||
$bc[$i] .= '<div class="arrow_box '.$class.'">'.$url['label'];
|
||||
$bc[$i++] .= '</div></a>';
|
||||
}
|
||||
|
||||
if ($add === true) {
|
||||
$this->addBreadcrum($bc);
|
||||
} else {
|
||||
$this->setBreadcrum($bc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To be overwritten.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
ui_require_css_file('wizard');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if environment is ready,
|
||||
* returns array
|
||||
* icon: icon to be displayed
|
||||
* label: label to be displayed
|
||||
*
|
||||
* @return array With data.
|
||||
**/
|
||||
public function load()
|
||||
{
|
||||
return [
|
||||
'icon' => $this->icon,
|
||||
'label' => $this->label,
|
||||
'url' => $this->url,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print breadcrum to follow flow.
|
||||
*
|
||||
* @return string Breadcrum HTML code.
|
||||
*/
|
||||
public function printBreadcrum()
|
||||
{
|
||||
return '<h1 class="wizard">'.implode('', $this->breadcrum).'</h1>';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prints a header for current wizard.
|
||||
*
|
||||
* @param boolean $return Return HTML or print it.
|
||||
*
|
||||
* @return string HTML code for header.
|
||||
*/
|
||||
public function printHeader(bool $return=false)
|
||||
{
|
||||
$output = $this->printBreadcrum();
|
||||
if ($return === false) {
|
||||
echo $output;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print input using functions html lib.
|
||||
*
|
||||
* @param array $data Input definition.
|
||||
*
|
||||
* @return string HTML code for desired input.
|
||||
*/
|
||||
public function printInput($data)
|
||||
{
|
||||
if (is_array($data) === false) {
|
||||
return '';
|
||||
}
|
||||
|
||||
switch ($data['type']) {
|
||||
case 'text':
|
||||
return html_print_input_text(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['alt']) === true) ? $data['alt'] : ''),
|
||||
((isset($data['size']) === true) ? $data['size'] : 50),
|
||||
((isset($data['maxlength']) === true) ? $data['maxlength'] : 255),
|
||||
((isset($data['return']) === true) ? $data['return'] : true),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['required']) === true) ? $data['required'] : false),
|
||||
((isset($data['function']) === true) ? $data['function'] : ''),
|
||||
((isset($data['class']) === true) ? $data['class'] : ''),
|
||||
((isset($data['onChange']) === true) ? $data['onChange'] : ''),
|
||||
((isset($data['autocomplete']) === true) ? $data['autocomplete'] : '')
|
||||
);
|
||||
|
||||
case 'image':
|
||||
return html_print_input_image(
|
||||
$data['name'],
|
||||
$data['src'],
|
||||
$data['value'],
|
||||
((isset($data['style']) === true) ? $data['style'] : ''),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['options']) === true) ? $data['options'] : false)
|
||||
);
|
||||
|
||||
case 'text_extended':
|
||||
return html_print_input_text_extended(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
$data['id'],
|
||||
$data['alt'],
|
||||
$data['size'],
|
||||
$data['maxlength'],
|
||||
$data['disabled'],
|
||||
$data['script'],
|
||||
$data['attributes'],
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['password']) === true) ? $data['password'] : false),
|
||||
((isset($data['function']) === true) ? $data['function'] : '')
|
||||
);
|
||||
|
||||
case 'password':
|
||||
return html_print_input_password(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['alt']) === true) ? $data['alt'] : ''),
|
||||
((isset($data['size']) === true) ? $data['size'] : 50),
|
||||
((isset($data['maxlength']) === true) ? $data['maxlength'] : 255),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['required']) === true) ? $data['required'] : false),
|
||||
((isset($data['class']) === true) ? $data['class'] : '')
|
||||
);
|
||||
|
||||
case 'text':
|
||||
return html_print_input_text(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['alt']) === true) ? $data['alt'] : ''),
|
||||
((isset($data['size']) === true) ? $data['size'] : 50),
|
||||
((isset($data['maxlength']) === true) ? $data['maxlength'] : 255),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['required']) === true) ? $data['required'] : false),
|
||||
((isset($data['function']) === true) ? $data['function'] : ''),
|
||||
((isset($data['class']) === true) ? $data['class'] : ''),
|
||||
((isset($data['onChange']) === true) ? $data['onChange'] : ''),
|
||||
((isset($data['autocomplete']) === true) ? $data['autocomplete'] : '')
|
||||
);
|
||||
|
||||
case 'image':
|
||||
return html_print_input_image(
|
||||
$data['name'],
|
||||
$data['src'],
|
||||
$data['value'],
|
||||
((isset($data['style']) === true) ? $data['style'] : ''),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['options']) === true) ? $data['options'] : false)
|
||||
);
|
||||
|
||||
case 'hidden':
|
||||
return html_print_input_hidden(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['class']) === true) ? $data['class'] : false)
|
||||
);
|
||||
|
||||
case 'hidden_extended':
|
||||
return html_print_input_hidden_extended(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
$data['id'],
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['class']) === true) ? $data['class'] : false)
|
||||
);
|
||||
|
||||
case 'color':
|
||||
return html_print_input_color(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['class']) === true) ? $data['class'] : false),
|
||||
((isset($data['return']) === true) ? $data['return'] : false)
|
||||
);
|
||||
|
||||
case 'file':
|
||||
return html_print_input_file(
|
||||
$data['name'],
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['options']) === true) ? $data['options'] : false)
|
||||
);
|
||||
|
||||
case 'select':
|
||||
return html_print_select(
|
||||
$data['fields'],
|
||||
$data['name'],
|
||||
((isset($data['selected']) === true) ? $data['selected'] : ''),
|
||||
((isset($data['script']) === true) ? $data['script'] : ''),
|
||||
((isset($data['nothing']) === true) ? $data['nothing'] : ''),
|
||||
((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['multiple']) === true) ? $data['multiple'] : false),
|
||||
((isset($data['sort']) === true) ? $data['sort'] : true),
|
||||
((isset($data['class']) === true) ? $data['class'] : ''),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['style']) === true) ? $data['style'] : false),
|
||||
((isset($data['option_style']) === true) ? $data['option_style'] : false),
|
||||
((isset($data['size']) === true) ? $data['size'] : false),
|
||||
((isset($data['modal']) === true) ? $data['modal'] : false),
|
||||
((isset($data['message']) === true) ? $data['message'] : ''),
|
||||
((isset($data['select_all']) === true) ? $data['select_all'] : false)
|
||||
);
|
||||
|
||||
case 'select_from_sql':
|
||||
return html_print_select_from_sql(
|
||||
$data['sql'],
|
||||
$data['name'],
|
||||
((isset($data['selected']) === true) ? $data['selected'] : ''),
|
||||
((isset($data['script']) === true) ? $data['script'] : ''),
|
||||
((isset($data['nothing']) === true) ? $data['nothing'] : ''),
|
||||
((isset($data['nothing_value']) === true) ? $data['nothing_value'] : '0'),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['multiple']) === true) ? $data['multiple'] : false),
|
||||
((isset($data['sort']) === true) ? $data['sort'] : true),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['style']) === true) ? $data['style'] : false),
|
||||
((isset($data['size']) === true) ? $data['size'] : false),
|
||||
((isset($data['trucate_size']) === true) ? $data['trucate_size'] : GENERIC_SIZE_TEXT)
|
||||
);
|
||||
|
||||
case 'select_groups':
|
||||
return html_print_select_groups(
|
||||
((isset($data['id_user']) === true) ? $data['id_user'] : false),
|
||||
((isset($data['privilege']) === true) ? $data['privilege'] : 'AR'),
|
||||
((isset($data['returnAllGroup']) === true) ? $data['returnAllGroup'] : true),
|
||||
$data['name'],
|
||||
((isset($data['selected']) === true) ? $data['selected'] : ''),
|
||||
((isset($data['script']) === true) ? $data['script'] : ''),
|
||||
((isset($data['nothing']) === true) ? $data['nothing'] : ''),
|
||||
((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['multiple']) === true) ? $data['multiple'] : false),
|
||||
((isset($data['sort']) === true) ? $data['sort'] : true),
|
||||
((isset($data['class']) === true) ? $data['class'] : ''),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['style']) === true) ? $data['style'] : false),
|
||||
((isset($data['option_style']) === true) ? $data['option_style'] : false),
|
||||
((isset($data['id_group']) === true) ? $data['id_group'] : false),
|
||||
((isset($data['keys_field']) === true) ? $data['keys_field'] : 'id_grupo'),
|
||||
((isset($data['strict_user']) === true) ? $data['strict_user'] : false),
|
||||
((isset($data['delete_groups']) === true) ? $data['delete_groups'] : false),
|
||||
((isset($data['include_groups']) === true) ? $data['include_groups'] : false)
|
||||
);
|
||||
|
||||
case 'submit':
|
||||
return '<div class="action-buttons" style="width: 100%">'.html_print_submit_button(
|
||||
((isset($data['label']) === true) ? $data['label'] : 'OK'),
|
||||
((isset($data['name']) === true) ? $data['name'] : ''),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['attributes']) === true) ? $data['attributes'] : ''),
|
||||
((isset($data['return']) === true) ? $data['return'] : false)
|
||||
).'</div>';
|
||||
|
||||
case 'checkbox':
|
||||
return html_print_checkbox(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['checked']) === true) ? $data['checked'] : false),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['script']) === true) ? $data['script'] : ''),
|
||||
((isset($data['disabled_hidden']) === true) ? $data['disabled_hidden'] : false)
|
||||
);
|
||||
|
||||
case 'switch':
|
||||
return html_print_switch($data);
|
||||
|
||||
case 'interval':
|
||||
return html_print_extended_select_for_time(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['script']) === true) ? $data['script'] : ''),
|
||||
((isset($data['nothing']) === true) ? $data['nothing'] : ''),
|
||||
((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0),
|
||||
((isset($data['size']) === true) ? $data['size'] : false),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['style']) === true) ? $data['selected'] : false),
|
||||
((isset($data['unique']) === true) ? $data['unique'] : false)
|
||||
);
|
||||
|
||||
case 'textarea':
|
||||
return html_print_textarea(
|
||||
$data['name'],
|
||||
$data['rows'],
|
||||
$data['columns'],
|
||||
((isset($data['value']) === true) ? $data['value'] : ''),
|
||||
((isset($data['attributes']) === true) ? $data['attributes'] : ''),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['class']) === true) ? $data['class'] : '')
|
||||
);
|
||||
|
||||
default:
|
||||
// Ignore.
|
||||
break;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prints a go back button redirecting to main page.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function printGoBackButton($url=null)
|
||||
{
|
||||
if (isset($url) === false) {
|
||||
$url = ui_get_full_url(
|
||||
'index.php?sec=gservers&sec2=godmode/servers/discovery'
|
||||
);
|
||||
}
|
||||
|
||||
$form = [
|
||||
'form' => [
|
||||
'method' => 'POST',
|
||||
'action' => $url,
|
||||
],
|
||||
'inputs' => [
|
||||
[
|
||||
'arguments' => [
|
||||
'name' => 'submit',
|
||||
'label' => __('Go back'),
|
||||
'type' => 'submit',
|
||||
'attributes' => 'class="sub cancel"',
|
||||
'return' => true,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$this->printForm($form);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print a block of inputs.
|
||||
*
|
||||
* @param array $input Definition of target block to be printed.
|
||||
* @param boolean $return Return as string or direct output.
|
||||
*
|
||||
* @return string HTML content.
|
||||
*/
|
||||
public function printBlock(array $input, bool $return=false)
|
||||
{
|
||||
$output = '';
|
||||
if ($input['hidden'] == 1) {
|
||||
$class = ' class="hidden"';
|
||||
} else {
|
||||
$class = '';
|
||||
}
|
||||
|
||||
if (is_array($input['block_content']) === true) {
|
||||
// Print independent block of inputs.
|
||||
$output .= '<li id="'.$input['block_id'].'" '.$class.'>';
|
||||
$output .= '<ul class="wizard">';
|
||||
foreach ($input['block_content'] as $input) {
|
||||
$output .= $this->printBlock($input, $return);
|
||||
}
|
||||
|
||||
$output .= '</ul></li>';
|
||||
} else {
|
||||
if ($input['arguments']['type'] != 'hidden') {
|
||||
$output .= '<li id="'.$input['id'].'" '.$class.'>';
|
||||
$output .= '<label>'.$input['label'].'</label>';
|
||||
$output .= $this->printInput($input['arguments']);
|
||||
// Allow dynamic content.
|
||||
$output .= $input['extra'];
|
||||
$output .= '</li>';
|
||||
} else {
|
||||
$output .= $this->printInput($input['arguments']);
|
||||
// Allow dynamic content.
|
||||
$output .= $input['extra'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($return === false) {
|
||||
echo $output;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print a form.
|
||||
*
|
||||
* @param array $data Definition of target form to be printed.
|
||||
* @param boolean $return Return as string or direct output.
|
||||
*
|
||||
* @return string HTML code.
|
||||
*/
|
||||
public function printForm(array $data, bool $return=false)
|
||||
{
|
||||
$form = $data['form'];
|
||||
$inputs = $data['inputs'];
|
||||
$js = $data['js'];
|
||||
$cb_function = $data['cb_function'];
|
||||
$cb_args = $data['cb_args'];
|
||||
|
||||
$output_head = '<form enctype="'.$form['enctype'].'" action="'.$form['action'].'" method="'.$form['method'];
|
||||
$output_head .= '" '.$form['extra'].'>';
|
||||
|
||||
if ($return === false) {
|
||||
echo $output_head;
|
||||
}
|
||||
|
||||
try {
|
||||
if (isset($cb_function) === true) {
|
||||
call_user_func_array(
|
||||
$cb_function,
|
||||
(isset($cb_args) === true) ? $cb_args : []
|
||||
);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
error_log('Error executing wizard callback: ', $e->getMessage());
|
||||
}
|
||||
|
||||
$output = '<ul class="wizard">';
|
||||
|
||||
foreach ($inputs as $input) {
|
||||
$output .= $this->printBlock($input, true);
|
||||
}
|
||||
|
||||
$output .= '</ul>';
|
||||
$output .= '</form>';
|
||||
$output .= '<script>'.$js.'</script>';
|
||||
|
||||
if ($return === false) {
|
||||
echo $output;
|
||||
}
|
||||
|
||||
return $output_head.$output;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print a big button element (huge image, big text and link).
|
||||
*
|
||||
* @param array $data Element data (link, image...).
|
||||
*
|
||||
* @return void Only prints the element.
|
||||
*/
|
||||
public static function printBigButtonElement($data)
|
||||
{
|
||||
if (isset($data['url']) === false) {
|
||||
$data['url'] = '#';
|
||||
}
|
||||
|
||||
?>
|
||||
<li class="discovery">
|
||||
<a href="<?php echo $data['url']; ?>">
|
||||
<div class="data_container">
|
||||
<?php html_print_image($data['icon']); ?>
|
||||
<br><label id="text_wizard">
|
||||
<?php echo io_safe_output($data['label']); ?>
|
||||
</label>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print a list of big buttons elements.
|
||||
*
|
||||
* @param array $list_data Array of data for printBigButtonElement.
|
||||
*
|
||||
* @return void Print the full list.
|
||||
*/
|
||||
public static function printBigButtonsList($list_data)
|
||||
{
|
||||
echo '<ul>';
|
||||
array_map('self::printBigButtonElement', $list_data);
|
||||
echo '</ul>';
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
global $config;
|
||||
require $config['homedir'].'/godmode/wizards/Wizard.interface.php';
|
||||
|
||||
$obj = new HostDevices();
|
||||
|
||||
$obj->load();
|
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 311 B |
After Width: | Height: | Size: 381 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 855 B |
After Width: | Height: | Size: 8.1 KiB |
After Width: | Height: | Size: 1.0 KiB |
|
@ -1,16 +1,31 @@
|
|||
<?php
|
||||
/**
|
||||
* Manage AJAX response for event pages.
|
||||
*
|
||||
* @category Ajax
|
||||
* @package Pandora FMS
|
||||
* @subpackage Events
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2010 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.
|
||||
require_once 'include/functions_events.php';
|
||||
require_once 'include/functions_agents.php';
|
||||
require_once 'include/functions_ui.php';
|
||||
|
@ -209,11 +224,14 @@ if ($dialogue_event_response) {
|
|||
$prompt = '<br>> ';
|
||||
switch ($event_response['type']) {
|
||||
case 'command':
|
||||
|
||||
|
||||
if ($massive) {
|
||||
echo "<div style='text-align:left'>";
|
||||
echo $prompt.sprintf("(Event #$event_id) ".__('Executing command: %s', $command));
|
||||
echo $prompt.sprintf(
|
||||
'(Event #'.$event_id.') '.__(
|
||||
'Executing command: %s',
|
||||
$command
|
||||
)
|
||||
);
|
||||
echo '</div><br>';
|
||||
|
||||
echo "<div id='response_loading_command_".$out_iterator."' style='display:none'>".html_print_image('images/spinner.gif', true).'</div>';
|
||||
|
@ -241,7 +259,11 @@ if ($dialogue_event_response) {
|
|||
|
||||
case 'url':
|
||||
$command = str_replace('localhost', $_SERVER['SERVER_NAME'], $command);
|
||||
echo "<iframe src='$command' id='divframe' style='width:100%;height:90%;'></iframe>";
|
||||
echo "<iframe src='".$command."' id='divframe' style='width:100%;height:90%;'></iframe>";
|
||||
break;
|
||||
|
||||
default:
|
||||
// Ignore.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -318,10 +340,10 @@ if ($get_extended_event) {
|
|||
$readonly = true;
|
||||
}
|
||||
|
||||
// Clean url from events and store in array
|
||||
// Clean url from events and store in array.
|
||||
$event['clean_tags'] = events_clean_tags($event['tags']);
|
||||
|
||||
// If the event is not found, we abort
|
||||
// If the event is not found, we abort.
|
||||
if (empty($event)) {
|
||||
ui_print_error_message('Event not found');
|
||||
return false;
|
||||
|
@ -340,42 +362,62 @@ if ($get_extended_event) {
|
|||
$event['timestamp_last'] = $timestamp_last;
|
||||
$event['event_rep'] = $event_rep;
|
||||
|
||||
// Check ACLs
|
||||
// Check ACLs.
|
||||
if (is_user_admin($config['id_user'])) {
|
||||
// Do nothing if you're admin, you get full access
|
||||
// Do nothing if you're admin, you get full access.
|
||||
$__ignored_line = 0;
|
||||
} else if ($config['id_user'] == $event['owner_user']) {
|
||||
// Do nothing if you're the owner user, you get access
|
||||
// Do nothing if you're the owner user, you get access.
|
||||
$__ignored_line = 0;
|
||||
} else if ($event['id_grupo'] == 0) {
|
||||
// If the event has access to all groups, you get access
|
||||
// If the event has access to all groups, you get access.
|
||||
$__ignored_line = 0;
|
||||
} else {
|
||||
// Get your groups
|
||||
// Get your groups.
|
||||
$groups = users_get_groups($config['id_user'], 'ER');
|
||||
|
||||
if (in_array($event['id_grupo'], array_keys($groups))) {
|
||||
// If the event group is among the groups of the user, you get access
|
||||
// If event group is among the groups of the user, you get access.
|
||||
$__ignored_line = 0;
|
||||
} else {
|
||||
// If all the access types fail, abort
|
||||
// If all the access types fail, abort.
|
||||
echo 'Access denied';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Print group_rep in a hidden field to recover it from javascript
|
||||
// Print group_rep in a hidden field to recover it from javascript.
|
||||
html_print_input_hidden('group_rep', (int) $group_rep);
|
||||
|
||||
if ($event === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Tabs
|
||||
// Tabs.
|
||||
$tabs = "<ul style='background:#ffffff !important; border-top: 0px; border-left: 0px; border-right: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; border-color: #D3D3D3;'>";
|
||||
$tabs .= "<li><a href='#extended_event_general_page' id='link_general'>".html_print_image('images/lightning_go.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('General').'</span></a></li>';
|
||||
if (events_has_extended_info($event['id_evento']) === true) {
|
||||
$tabs .= "<li><a href='#extended_event_related_page' id='link_related'>".html_print_image('images/zoom.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('Related').'</span></a></li>';
|
||||
}
|
||||
|
||||
$tabs .= "<li><a href='#extended_event_details_page' id='link_details'>".html_print_image('images/zoom.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('Details').'</span></a></li>';
|
||||
$tabs .= "<li><a href='#extended_event_custom_fields_page' id='link_custom_fields'>".html_print_image('images/custom_field_col.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('Agent fields').'</span></a></li>';
|
||||
$tabs .= "<li><a href='#extended_event_comments_page' id='link_comments'>".html_print_image('images/pencil.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('Comments').'</span></a></li>';
|
||||
|
||||
if (!$readonly
|
||||
&& ((tags_checks_event_acl($config['id_user'], $event['id_grupo'], 'EM', $event['clean_tags'], $childrens_ids)) || (tags_checks_event_acl($config['id_user'], $event['id_grupo'], 'EW', $event['clean_tags'], $childrens_ids)))
|
||||
&& ((tags_checks_event_acl(
|
||||
$config['id_user'],
|
||||
$event['id_grupo'],
|
||||
'EM',
|
||||
$event['clean_tags'],
|
||||
$childrens_ids
|
||||
)) || (tags_checks_event_acl(
|
||||
$config['id_user'],
|
||||
$event['id_grupo'],
|
||||
'EW',
|
||||
$event['clean_tags'],
|
||||
$childrens_ids
|
||||
)))
|
||||
) {
|
||||
$tabs .= "<li><a href='#extended_event_responses_page' id='link_responses'>".html_print_image('images/event_responses_col.png', true)."<span style='position:relative;top:-6px;left:3px;margin-right:10px;'>".__('Responses').'</span></a></li>';
|
||||
}
|
||||
|
@ -386,7 +428,7 @@ if ($get_extended_event) {
|
|||
|
||||
$tabs .= '</ul>';
|
||||
|
||||
// Get criticity image
|
||||
// Get criticity image.
|
||||
switch ($event['criticity']) {
|
||||
default:
|
||||
case 0:
|
||||
|
@ -418,7 +460,19 @@ if ($get_extended_event) {
|
|||
}
|
||||
|
||||
if (!$readonly
|
||||
&& ((tags_checks_event_acl($config['id_user'], $event['id_grupo'], 'EM', $event['clean_tags'], $childrens_ids)) || (tags_checks_event_acl($config['id_user'], $event['id_grupo'], 'EW', $event['clean_tags'], $childrens_ids)))
|
||||
&& ((tags_checks_event_acl(
|
||||
$config['id_user'],
|
||||
$event['id_grupo'],
|
||||
'EM',
|
||||
$event['clean_tags'],
|
||||
$childrens_ids
|
||||
)) || (tags_checks_event_acl(
|
||||
$config['id_user'],
|
||||
$event['id_grupo'],
|
||||
'EW',
|
||||
$event['clean_tags'],
|
||||
$childrens_ids
|
||||
)))
|
||||
) {
|
||||
$responses = events_page_responses($event, $childrens_ids);
|
||||
} else {
|
||||
|
@ -426,7 +480,7 @@ if ($get_extended_event) {
|
|||
}
|
||||
|
||||
$console_url = '';
|
||||
// If metaconsole switch to node to get details and custom fields
|
||||
// If metaconsole switch to node to get details and custom fields.
|
||||
if ($meta) {
|
||||
$server = metaconsole_get_connection_by_id($server_id);
|
||||
metaconsole_connect($server);
|
||||
|
@ -436,7 +490,12 @@ if ($get_extended_event) {
|
|||
|
||||
$details = events_page_details($event, $server);
|
||||
|
||||
// Juanma (09/05/2014) Fix: Needs to reconnect to node, in previous funct node connection was lost
|
||||
if (events_has_extended_info($event['id_evento']) === true) {
|
||||
$related = events_page_related($event, $server);
|
||||
}
|
||||
|
||||
// Juanma (09/05/2014) Fix: Needs to reconnect to node, in previous funct
|
||||
// node connection was lost.
|
||||
if ($meta) {
|
||||
$server = metaconsole_get_connection_by_id($server_id);
|
||||
metaconsole_connect($server);
|
||||
|
@ -463,7 +522,7 @@ if ($get_extended_event) {
|
|||
|
||||
$loading = '<div id="response_loading" style="display:none">'.html_print_image('images/spinner.gif', true).'</div>';
|
||||
|
||||
$out = '<div id="tabs" style="height:95%; overflow: auto">'.$tabs.$notifications.$loading.$general.$details.$custom_fields.$comments.$responses.$custom_data.html_print_input_hidden('id_event', $event['id_evento']).'</div>';
|
||||
$out = '<div id="tabs" style="height:95%; overflow: auto">'.$tabs.$notifications.$loading.$general.$details.$related.$custom_fields.$comments.$responses.$custom_data.html_print_input_hidden('id_event', $event['id_evento']).'</div>';
|
||||
|
||||
$js = '<script>
|
||||
$(function() {
|
||||
|
@ -471,7 +530,7 @@ if ($get_extended_event) {
|
|||
});
|
||||
';
|
||||
|
||||
// Load the required tab
|
||||
// Load the required tab.
|
||||
switch ($dialog_page) {
|
||||
case 'general':
|
||||
$js .= '$tabs.tabs( "option", "active", 0);';
|
||||
|
@ -481,26 +540,53 @@ if ($get_extended_event) {
|
|||
$js .= '$tabs.tabs( "option", "active", 1);';
|
||||
break;
|
||||
|
||||
case 'custom_fields':
|
||||
case 'related':
|
||||
$js .= '$tabs.tabs( "option", "active", 2);';
|
||||
break;
|
||||
|
||||
case 'comments':
|
||||
case 'custom_fields':
|
||||
$js .= '$tabs.tabs( "option", "active", 3);';
|
||||
break;
|
||||
|
||||
case 'responses':
|
||||
case 'comments':
|
||||
$js .= '$tabs.tabs( "option", "active", 4);';
|
||||
break;
|
||||
|
||||
case 'custom_data':
|
||||
case 'responses':
|
||||
$js .= '$tabs.tabs( "option", "active", 5);';
|
||||
break;
|
||||
|
||||
case 'custom_data':
|
||||
$js .= '$tabs.tabs( "option", "active", 6);';
|
||||
break;
|
||||
|
||||
default:
|
||||
// Ignore.
|
||||
break;
|
||||
}
|
||||
|
||||
$js .= '
|
||||
});
|
||||
</script>';
|
||||
$js .= '});';
|
||||
|
||||
if (events_has_extended_info($event['id_evento']) === true) {
|
||||
$js .= '
|
||||
$("#link_related").click(function (){
|
||||
$.post ({
|
||||
url : "ajax.php",
|
||||
data : {
|
||||
page: "include/ajax/events_extended",
|
||||
get_extended_info: 1,
|
||||
id_event: '.$event['id_evento'].'
|
||||
},
|
||||
dataType : "html",
|
||||
success: function (data) {
|
||||
$("#related_data").html(data);
|
||||
console.log("vamos puta");
|
||||
}
|
||||
});
|
||||
});';
|
||||
}
|
||||
|
||||
$js .= '</script>';
|
||||
|
||||
echo $out.$js;
|
||||
}
|
||||
|
@ -542,6 +628,10 @@ if ($get_events_details) {
|
|||
$img = ui_get_full_url('images/hourglass.png', false, false, false);
|
||||
$title = __('Event in process');
|
||||
break;
|
||||
|
||||
default:
|
||||
// Ignore.
|
||||
break;
|
||||
}
|
||||
|
||||
$out .= '<tr class="'.get_priority_class($event['criticity']).'" style="height: 25px;">';
|
||||
|
@ -593,7 +683,8 @@ if ($table_events) {
|
|||
$id_agente = (int) get_parameter('id_agente', 0);
|
||||
$all_events_24h = (int) get_parameter('all_events_24h', 0);
|
||||
|
||||
// Fix: for tag functionality groups have to be all user_groups (propagate ACL funct!)
|
||||
// Fix: for tag functionality groups have to be all user_groups
|
||||
// (propagate ACL funct!).
|
||||
$groups = users_get_groups($config['id_user']);
|
||||
|
||||
$tags_condition = tags_get_acl_tags(
|
||||
|
@ -611,7 +702,7 @@ if ($table_events) {
|
|||
|
||||
if ($all_events_24h) {
|
||||
events_print_event_table(
|
||||
"utimestamp > $date_subtract_day",
|
||||
'utimestamp > '.$date_subtract_day,
|
||||
200,
|
||||
'100%',
|
||||
false,
|
||||
|
@ -620,7 +711,7 @@ if ($table_events) {
|
|||
);
|
||||
} else {
|
||||
events_print_event_table(
|
||||
"estado <> 1 $tags_condition",
|
||||
'estado <> 1 '.$tags_condition,
|
||||
200,
|
||||
'100%',
|
||||
false,
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
/**
|
||||
* Manage AJAX response for event pages.
|
||||
*
|
||||
* @category Ajax
|
||||
* @package Pandora FMS
|
||||
* @subpackage Events extended
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
require_once 'include/functions_events.php';
|
||||
|
||||
|
||||
enterprise_include_once('meta/include/functions_events_meta.php');
|
||||
enterprise_include_once('include/functions_metaconsole.php');
|
||||
|
||||
|
||||
global $config;
|
||||
|
||||
// Check ACLs.
|
||||
if (is_user_admin($config['id_user']) === true) {
|
||||
// Do nothing if you're admin, you get full access.
|
||||
$allowed = true;
|
||||
} else if ($config['id_user'] == $event['owner_user']) {
|
||||
// Do nothing if you're the owner user, you get access.
|
||||
$allowed = true;
|
||||
} else if ($event['id_grupo'] == 0) {
|
||||
// If the event has access to all groups, you get access.
|
||||
$allowed = true;
|
||||
} else {
|
||||
// Get your groups.
|
||||
$groups = users_get_groups($config['id_user'], 'ER');
|
||||
|
||||
if (in_array($event['id_grupo'], array_keys($groups))) {
|
||||
// If event group is among the groups of the user, you get access.
|
||||
$__ignored_line = true;
|
||||
} else {
|
||||
// If all the access types fail, abort.
|
||||
$allowed = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($allowed === false) {
|
||||
echo 'Access denied';
|
||||
exit;
|
||||
}
|
||||
|
||||
$id_event = get_parameter('id_event', null);
|
||||
$get_extended_info = get_parameter('get_extended_info', 0);
|
||||
|
||||
|
||||
if ($get_extended_info == 1) {
|
||||
if (isset($id_event) === false) {
|
||||
echo 'Internal error. Invalid event.';
|
||||
exit;
|
||||
}
|
||||
|
||||
$extended_info = events_get_extended_events($id_event);
|
||||
|
||||
$table = new StdClass();
|
||||
//
|
||||
// Details.
|
||||
//
|
||||
$table->width = '100%';
|
||||
$table->data = [];
|
||||
$table->head = [];
|
||||
$table->style[0] = 'min-width:120px; text-align: left;';
|
||||
$table->style[1] = 'text-align: left;';
|
||||
$table->cellspacing = 2;
|
||||
$table->cellpadding = 2;
|
||||
$table->class = 'alternate rounded_cells';
|
||||
|
||||
$output = [];
|
||||
$output[] = '<b>'.__('Timestamp').'</b>';
|
||||
$output[] = '<b>'.__('Description').'</b>';
|
||||
$table->data[] = $output;
|
||||
|
||||
foreach ($extended_info as $data) {
|
||||
$output = [];
|
||||
$output[] = date('Y/m/d H:i:s', $data['utimestamp']);
|
||||
$output[] = io_safe_output($data['description']);
|
||||
$table->data[] = $output;
|
||||
}
|
||||
|
||||
html_print_table($table);
|
||||
}
|
|
@ -20,7 +20,7 @@
|
|||
/**
|
||||
* Pandora build version and version
|
||||
*/
|
||||
$build_version = 'PC190225';
|
||||
$build_version = 'PC190226';
|
||||
$pandora_version = 'v7.0NG.731';
|
||||
|
||||
// Do not overwrite default timezone set if defined.
|
||||
|
|
|
@ -1,47 +1,57 @@
|
|||
<?php
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2012 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 Lesser General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
/**
|
||||
* @package Include
|
||||
* @subpackage Constants
|
||||
* Constants definitions.
|
||||
*
|
||||
* @category Library
|
||||
* @package Pandora FMS
|
||||
* @subpackage Opensource
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Enterprise hook constant
|
||||
// Enterprise hook constant.
|
||||
define('ENTERPRISE_NOT_HOOK', -1);
|
||||
|
||||
// Others
|
||||
// Others.
|
||||
define('GROUP_ALL', 0);
|
||||
|
||||
// Date and time formats
|
||||
// Date and time formats.
|
||||
define('DATE_FORMAT', 'Y/m/d');
|
||||
define('DATE_FORMAT_JS', 'yy/mm/dd');
|
||||
define('TIME_FORMAT', 'H:i:s');
|
||||
define('TIME_FORMAT_JS', 'HH:mm:ss');
|
||||
|
||||
// Events state constants
|
||||
// Events state constants.
|
||||
define('EVENT_NEW', 0);
|
||||
define('EVENT_VALIDATE', 1);
|
||||
define('EVENT_PROCESS', 2);
|
||||
|
||||
|
||||
|
||||
// Agents disabled status
|
||||
// Agents disabled status.
|
||||
define('AGENT_ENABLED', 0);
|
||||
define('AGENT_DISABLED', 1);
|
||||
|
||||
|
||||
|
||||
// Error report codes
|
||||
// Error report codes.
|
||||
define('NOERR', 11111);
|
||||
define('ERR_GENERIC', -10000);
|
||||
define('ERR_EXIST', -20000);
|
||||
|
@ -61,12 +71,12 @@ define('ERR_ACL', -110000);
|
|||
define('ERR_AUTH', -120000);
|
||||
define('ERR_COULDNT_RESOLVE_HOST', -130000);
|
||||
|
||||
// Event status code
|
||||
// Event status code.
|
||||
define('EVENT_STATUS_NEW', 0);
|
||||
define('EVENT_STATUS_INPROCESS', 2);
|
||||
define('EVENT_STATUS_VALIDATED', 1);
|
||||
|
||||
// Seconds in a time unit constants
|
||||
// Seconds in a time unit constants.
|
||||
define('SECONDS_1MINUTE', 60);
|
||||
define('SECONDS_2MINUTES', 120);
|
||||
define('SECONDS_5MINUTES', 300);
|
||||
|
@ -97,16 +107,16 @@ define('SECONDS_3YEARS', 93312000);
|
|||
|
||||
|
||||
|
||||
// Separator constats
|
||||
// Separator constats.
|
||||
define('SEPARATOR_COLUMN', ';');
|
||||
define('SEPARATOR_ROW', chr(10));
|
||||
// chr(10) = '\n'
|
||||
// Chr(10) is \n.
|
||||
define('SEPARATOR_COLUMN_CSV', '#');
|
||||
define('SEPARATOR_ROW_CSV', "@\n");
|
||||
|
||||
|
||||
|
||||
// Backup paths
|
||||
// Backup paths.
|
||||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
case 'postgresql':
|
||||
|
@ -118,11 +128,15 @@ switch ($config['dbtype']) {
|
|||
define('BACKUP_DIR', 'DATA_PUMP_DIR');
|
||||
define('BACKUP_FULLPATH', 'DATA_PUMP_DIR');
|
||||
break;
|
||||
|
||||
default:
|
||||
// Ignore.
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Color constants
|
||||
// Color constants.
|
||||
define('COL_CRITICAL', '#FC4444');
|
||||
define('COL_WARNING', '#FAD403');
|
||||
define('COL_WARNING_DARK', '#FFB900');
|
||||
|
@ -152,14 +166,13 @@ define('COL_GRAPH12', '#F45B95');
|
|||
define('COL_GRAPH13', '#E83128');
|
||||
|
||||
|
||||
/*
|
||||
The styles */
|
||||
// Size of text in characters for truncate
|
||||
// Styles.
|
||||
// Size of text in characters for truncate.
|
||||
define('GENERIC_SIZE_TEXT', 50);
|
||||
|
||||
|
||||
|
||||
// Agent module status
|
||||
// Agent module status.
|
||||
define('AGENT_MODULE_STATUS_ALL', -1);
|
||||
define('AGENT_MODULE_STATUS_CRITICAL_BAD', 1);
|
||||
define('AGENT_MODULE_STATUS_CRITICAL_ALERT', 100);
|
||||
|
@ -172,7 +185,7 @@ define('AGENT_MODULE_STATUS_WARNING_ALERT', 200);
|
|||
define('AGENT_MODULE_STATUS_UNKNOWN', 3);
|
||||
define('AGENT_MODULE_STATUS_NOT_INIT', 5);
|
||||
|
||||
// Agent status
|
||||
// Agent status.
|
||||
define('AGENT_STATUS_ALL', -1);
|
||||
define('AGENT_STATUS_CRITICAL', 1);
|
||||
define('AGENT_STATUS_NORMAL', 0);
|
||||
|
@ -183,9 +196,8 @@ define('AGENT_STATUS_ALERT_FIRED', 4);
|
|||
define('AGENT_STATUS_WARNING', 2);
|
||||
|
||||
|
||||
/*
|
||||
Visual maps contants */
|
||||
// The items kind
|
||||
// Visual maps contants.
|
||||
// The items kind.
|
||||
define('STATIC_GRAPH', 0);
|
||||
define('PERCENTILE_BAR', 3);
|
||||
define('MODULE_GRAPH', 1);
|
||||
|
@ -208,59 +220,58 @@ define('DONUT_GRAPH', 17);
|
|||
define('BARS_GRAPH', 18);
|
||||
define('CLOCK', 19);
|
||||
define('COLOR_CLOUD', 20);
|
||||
// Some styles
|
||||
// Some styles.
|
||||
define('MIN_WIDTH', 300);
|
||||
define('MIN_HEIGHT', 120);
|
||||
define('MIN_WIDTH_CAPTION', 420);
|
||||
// The process for simple value
|
||||
// The process for simple value.
|
||||
define('PROCESS_VALUE_NONE', 0);
|
||||
define('PROCESS_VALUE_MIN', 1);
|
||||
define('PROCESS_VALUE_MAX', 2);
|
||||
define('PROCESS_VALUE_AVG', 3);
|
||||
// Status
|
||||
// Status.
|
||||
define('VISUAL_MAP_STATUS_CRITICAL_BAD', 1);
|
||||
define('VISUAL_MAP_STATUS_CRITICAL_ALERT', 4);
|
||||
define('VISUAL_MAP_STATUS_NORMAL', 0);
|
||||
define('VISUAL_MAP_STATUS_WARNING', 2);
|
||||
define('VISUAL_MAP_STATUS_UNKNOWN', 3);
|
||||
define('VISUAL_MAP_STATUS_WARNING_ALERT', 10);
|
||||
// Wizard
|
||||
// Wizard.
|
||||
define('VISUAL_MAP_WIZARD_PARENTS_NONE', 0);
|
||||
define('VISUAL_MAP_WIZARD_PARENTS_ITEM_MAP', 1);
|
||||
define('VISUAL_MAP_WIZARD_PARENTS_AGENT_RELANTIONSHIP', 2);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Service constants */
|
||||
// Status
|
||||
// Service constants.
|
||||
// Status.
|
||||
define('SERVICE_STATUS_UNKNOWN', -1);
|
||||
define('SERVICE_STATUS_NORMAL', 0);
|
||||
define('SERVICE_STATUS_CRITICAL', 1);
|
||||
define('SERVICE_STATUS_WARNING', 2);
|
||||
define('SERVICE_STATUS_ALERT', 4);
|
||||
// Default weights
|
||||
// Default weights.
|
||||
define('SERVICE_WEIGHT_CRITICAL', 1);
|
||||
define('SERVICE_WEIGHT_WARNING', 0.5);
|
||||
define('SERVICE_ELEMENT_WEIGHT_CRITICAL', 1);
|
||||
define('SERVICE_ELEMENT_WEIGHT_WARNING', 0.5);
|
||||
define('SERVICE_ELEMENT_WEIGHT_OK', 0);
|
||||
define('SERVICE_ELEMENT_WEIGHT_UNKNOWN', 0);
|
||||
// Modes
|
||||
// Modes.
|
||||
define('SERVICE_MODE_MANUAL', 0);
|
||||
define('SERVICE_MODE_AUTO', 1);
|
||||
define('SERVICE_MODE_SIMPLE', 2);
|
||||
|
||||
|
||||
/*
|
||||
Status images */
|
||||
// For modules
|
||||
|
||||
// Status images.
|
||||
// For modules.
|
||||
define('STATUS_MODULE_OK', 'module_ok.png');
|
||||
define('STATUS_MODULE_CRITICAL', 'module_critical.png');
|
||||
define('STATUS_MODULE_WARNING', 'module_warning.png');
|
||||
define('STATUS_MODULE_NO_DATA', 'module_no_data.png');
|
||||
define('STATUS_MODULE_UNKNOWN', 'module_unknown.png');
|
||||
// For agents
|
||||
// For agents.
|
||||
define('STATUS_AGENT_CRITICAL', 'agent_critical.png');
|
||||
define('STATUS_AGENT_WARNING', 'agent_warning.png');
|
||||
define('STATUS_AGENT_DOWN', 'agent_down.png');
|
||||
|
@ -269,24 +280,24 @@ define('STATUS_AGENT_OK', 'agent_ok.png');
|
|||
define('STATUS_AGENT_NO_DATA', 'agent_no_data.png');
|
||||
define('STATUS_AGENT_NO_MONITORS', 'agent_no_monitors.png');
|
||||
define('STATUS_AGENT_NOT_INIT', 'agent_notinit.png');
|
||||
// For alerts
|
||||
// For alerts.
|
||||
define('STATUS_ALERT_FIRED', 'alert_fired.png');
|
||||
define('STATUS_ALERT_NOT_FIRED', 'alert_not_fired.png');
|
||||
define('STATUS_ALERT_DISABLED', 'alert_disabled.png');
|
||||
// For servers
|
||||
// For servers.
|
||||
define('STATUS_SERVER_OK', 'server_ok.png');
|
||||
define('STATUS_SERVER_DOWN', 'server_down.png');
|
||||
|
||||
|
||||
/*
|
||||
Status images (ball) */
|
||||
// For modules
|
||||
|
||||
// Status images (ball).
|
||||
// For modules.
|
||||
define('STATUS_MODULE_OK_BALL', 'module_ok_ball.png');
|
||||
define('STATUS_MODULE_CRITICAL_BALL', 'module_critical_ball.png');
|
||||
define('STATUS_MODULE_WARNING_BALL', 'module_warning_ball.png');
|
||||
define('STATUS_MODULE_NO_DATA_BALL', 'module_no_data_ball.png');
|
||||
define('STATUS_MODULE_UNKNOWN_BALL', 'module_unknown_ball.png');
|
||||
// For agents
|
||||
// For agents.
|
||||
define('STATUS_AGENT_CRITICAL_BALL', 'agent_critical_ball.png');
|
||||
define('STATUS_AGENT_WARNING_BALL', 'agent_warning_ball.png');
|
||||
define('STATUS_AGENT_DOWN_BALL', 'agent_down_ball.png');
|
||||
|
@ -295,17 +306,17 @@ define('STATUS_AGENT_OK_BALL', 'agent_ok_ball.png');
|
|||
define('STATUS_AGENT_NO_DATA_BALL', 'agent_no_data_ball.png');
|
||||
define('STATUS_AGENT_NO_MONITORS_BALL', 'agent_no_monitors_ball.png');
|
||||
define('STATUS_AGENT_NOT_INIT_BALL', 'agent_notinit_ball.png');
|
||||
// For alerts
|
||||
// For alerts.
|
||||
define('STATUS_ALERT_FIRED_BALL', 'alert_fired_ball.png');
|
||||
define('STATUS_ALERT_NOT_FIRED_BALL', 'alert_not_fired_ball.png');
|
||||
define('STATUS_ALERT_DISABLED_BALL', 'alert_disabled_ball.png');
|
||||
// For servers
|
||||
// For servers.
|
||||
define('STATUS_SERVER_OK_BALL', 'server_ok_ball.png');
|
||||
define('STATUS_SERVER_DOWN_BALL', 'server_down_ball.png');
|
||||
|
||||
|
||||
|
||||
// Events criticity
|
||||
// Events criticity.
|
||||
define('EVENT_CRIT_MAINTENANCE', 0);
|
||||
define('EVENT_CRIT_INFORMATIONAL', 1);
|
||||
define('EVENT_CRIT_NORMAL', 2);
|
||||
|
@ -317,7 +328,7 @@ define('EVENT_CRIT_WARNING_OR_CRITICAL', 34);
|
|||
define('EVENT_CRIT_NOT_NORMAL', 20);
|
||||
define('EVENT_CRIT_OR_NORMAL', 21);
|
||||
|
||||
// Id Module (more use in component)
|
||||
// Id Module (more use in component).
|
||||
define('MODULE_DATA', 1);
|
||||
define('MODULE_NETWORK', 2);
|
||||
define('MODULE_SNMP', 2);
|
||||
|
@ -327,7 +338,7 @@ define('MODULE_WMI', 6);
|
|||
define('MODULE_WEB', 7);
|
||||
define('MODULE_WUX', 8);
|
||||
|
||||
// Type of Modules of Prediction
|
||||
// Type of Modules of Prediction.
|
||||
define('MODULE_PREDICTION_SERVICE', 2);
|
||||
define('MODULE_PREDICTION_SYNTHETIC', 3);
|
||||
define('MODULE_PREDICTION_NETFLOW', 4);
|
||||
|
@ -335,7 +346,7 @@ define('MODULE_PREDICTION_CLUSTER', 5);
|
|||
define('MODULE_PREDICTION_CLUSTER_AA', 6);
|
||||
define('MODULE_PREDICTION_CLUSTER_AP', 7);
|
||||
|
||||
// SNMP CONSTANTS
|
||||
// SNMP CONSTANTS.
|
||||
define('SNMP_DIR_MIBS', 'attachment/mibs');
|
||||
|
||||
define('SNMP_TRAP_TYPE_NONE', -1);
|
||||
|
@ -346,16 +357,16 @@ define('SNMP_TRAP_TYPE_LINK_UP', 3);
|
|||
define('SNMP_TRAP_TYPE_AUTHENTICATION_FAILURE', 4);
|
||||
define('SNMP_TRAP_TYPE_OTHER', 5);
|
||||
|
||||
// PASSWORD POLICIES
|
||||
// PASSWORD POLICIES.
|
||||
define('PASSSWORD_POLICIES_OK', 0);
|
||||
define('PASSSWORD_POLICIES_FIRST_CHANGE', 1);
|
||||
define('PASSSWORD_POLICIES_EXPIRED', 2);
|
||||
|
||||
// SERVER TYPES
|
||||
// SERVER TYPES.
|
||||
define('SERVER_TYPE_DATA', 0);
|
||||
define('SERVER_TYPE_NETWORK', 1);
|
||||
define('SERVER_TYPE_SNMP', 2);
|
||||
define('SERVER_TYPE_RECON', 3);
|
||||
define('SERVER_TYPE_DISCOVERY', 3);
|
||||
define('SERVER_TYPE_PLUGIN', 4);
|
||||
define('SERVER_TYPE_PREDICTION', 5);
|
||||
define('SERVER_TYPE_WMI', 6);
|
||||
|
@ -374,7 +385,7 @@ define('SERVER_TYPE_SYSLOG', 18);
|
|||
define('SERVER_TYPE_AUTOPROVISION', 19);
|
||||
define('SERVER_TYPE_MIGRATION', 20);
|
||||
|
||||
// REPORTS
|
||||
// REPORTS.
|
||||
define('REPORT_TOP_N_MAX', 1);
|
||||
define('REPORT_TOP_N_MIN', 2);
|
||||
define('REPORT_TOP_N_AVG', 0);
|
||||
|
@ -412,7 +423,7 @@ define('REPORT_GENERAL_GROUP_BY_AGENT', 1);
|
|||
|
||||
define('REPORTING_CUSTOM_GRAPH_LEGEND_EACH_MODULE_VERTICAL_SIZE', 15);
|
||||
|
||||
// POLICIES
|
||||
// POLICIES.
|
||||
define('POLICY_UPDATED', 0);
|
||||
define('POLICY_PENDING_DATABASE', 1);
|
||||
define('POLICY_PENDING_ALL', 2);
|
||||
|
@ -426,7 +437,7 @@ define('MODULE_LINKED', 1);
|
|||
define('MODULE_PENDING_UNLINK', 10);
|
||||
define('MODULE_PENDING_LINK', 11);
|
||||
|
||||
// EVENTS
|
||||
// EVENTS.
|
||||
define('EVENTS_GOING_UNKNOWN', 'going_unknown');
|
||||
define('EVENTS_UNKNOWN', 'unknown');
|
||||
define('EVENTS_ALERT_FIRED', 'alert_fired');
|
||||
|
@ -445,7 +456,7 @@ define('EVENTS_GOING_DOWN_CRITICAL', 'going_down_critical');
|
|||
define('EVENTS_GOING_UP_NORMAL', 'going_up_normal');
|
||||
define('EVENTS_CONFIGURATION_CHANGE', 'configuration_change');
|
||||
|
||||
// CUSTOM GRAPHS
|
||||
// CUSTOM GRAPHS.
|
||||
define('CUSTOM_GRAPH_AREA', 0);
|
||||
define('CUSTOM_GRAPH_STACKED_AREA', 1);
|
||||
define('CUSTOM_GRAPH_LINE', 2);
|
||||
|
@ -457,26 +468,26 @@ define('CUSTOM_GRAPH_VBARS', 7);
|
|||
define('CUSTOM_GRAPH_PIE', 8);
|
||||
define('CUSTOM_GRAPH_BULLET_CHART_THRESHOLD', 9);
|
||||
|
||||
// COLLECTIONS
|
||||
// COLLECTIONS.
|
||||
define('COLLECTION_PENDING_APPLY', 0);
|
||||
define('COLLECTION_CORRECT', 1);
|
||||
define('COLLECTION_ERROR_LOST_DIRECTORY', 2);
|
||||
define('COLLECTION_UNSAVED', 3);
|
||||
|
||||
// PAGINATION
|
||||
// PAGINATION.
|
||||
define('PAGINATION_BLOCKS_LIMIT', 15);
|
||||
|
||||
// CHARTS
|
||||
// CHARTS.
|
||||
define('CHART_DEFAULT_WIDTH', 150);
|
||||
define('CHART_DEFAULT_HEIGHT', 110);
|
||||
|
||||
define('CHART_DEFAULT_ALPHA', 50);
|
||||
|
||||
// Statwin
|
||||
// Statwin.
|
||||
define('STATWIN_DEFAULT_CHART_WIDTH', 555);
|
||||
define('STATWIN_DEFAULT_CHART_HEIGHT', 245);
|
||||
|
||||
// Dashboard
|
||||
// Dashboard.
|
||||
define('DASHBOARD_DEFAULT_COUNT_CELLS', 1);
|
||||
|
||||
define('OPTION_TEXT', 1);
|
||||
|
@ -491,11 +502,11 @@ define('OPTION_AGENT_AUTOCOMPLETE', 9);
|
|||
define('OPTION_SELECT_MULTISELECTION', 10);
|
||||
define('OPTION_COLOR_PICKER', 11);
|
||||
|
||||
// Transactional map constants
|
||||
// Transactional map constants.
|
||||
define('NODE_TYPE', 0);
|
||||
define('ARROW_TYPE', 1);
|
||||
|
||||
// SAML attributes constants
|
||||
// SAML attributes constants.
|
||||
define('SAML_ROLE_AND_TAG', 'eduPersonEntitlement');
|
||||
define('SAML_USER_DESC', 'commonName');
|
||||
define('SAML_ID_USER_IN_PANDORA', 'eduPersonTargetedId');
|
||||
|
@ -503,11 +514,11 @@ define('SAML_GROUP_IN_PANDORA', 'schacHomeOrganization');
|
|||
define('SAML_MAIL_IN_PANDORA', 'mail');
|
||||
define('SAML_DEFAULT_PROFILES_AND_TAGS_FORM', 'urn:mace:rediris.es:entitlement:monitoring:');
|
||||
|
||||
// Other constants
|
||||
// Other constants.
|
||||
define('STATUS_OK', 0);
|
||||
define('STATUS_ERROR', 1);
|
||||
|
||||
// Maps (new networkmaps and new visualmaps)
|
||||
// Maps (new networkmaps and new visualmaps).
|
||||
define('MAP_TYPE_NETWORKMAP', 0);
|
||||
define('MAP_TYPE_VISUALMAP', 1);
|
||||
|
||||
|
@ -530,14 +541,14 @@ define('MAP_SOURCE_IP_MASK', 1);
|
|||
define('NETWORKMAP_DEFAULT_WIDTH', 800);
|
||||
define('NETWORKMAP_DEFAULT_HEIGHT', 800);
|
||||
|
||||
// Background options
|
||||
// Background options.
|
||||
define('CENTER', 0);
|
||||
define('MOSAIC', 1);
|
||||
define('STRECH', 2);
|
||||
define('FIT_WIDTH', 3);
|
||||
define('FIT_HEIGH', 4);
|
||||
|
||||
// Items of maps
|
||||
// Items of maps.
|
||||
define('ITEM_TYPE_AGENT_NETWORKMAP', 0);
|
||||
define('ITEM_TYPE_MODULE_NETWORKMAP', 1);
|
||||
define('ITEM_TYPE_EDGE_NETWORKMAP', 2);
|
||||
|
@ -546,7 +557,7 @@ define('ITEM_TYPE_MODULEGROUP_NETWORKMAP', 4);
|
|||
define('ITEM_TYPE_GROUP_NETWORKMAP', 5);
|
||||
define('ITEM_TYPE_POLICY_NETWORKMAP', 6);
|
||||
|
||||
// Another constants new networkmap
|
||||
// Another constants new networkmap.
|
||||
define('DEFAULT_NODE_WIDTH', 30);
|
||||
define('DEFAULT_NODE_HEIGHT', 30);
|
||||
define('DEFAULT_NODE_SHAPE', 'circle');
|
||||
|
|
|
@ -706,6 +706,7 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa
|
|||
$i = 1;
|
||||
$max = count($values);
|
||||
foreach ($values as $field => $value) {
|
||||
$negative = false;
|
||||
if (is_numeric($field)) {
|
||||
// User provide the exact operation to do
|
||||
$query .= $value;
|
||||
|
@ -718,6 +719,11 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($field[0] == '!') {
|
||||
$negative = true;
|
||||
$field = substr($field, 1);
|
||||
}
|
||||
|
||||
if ($field[0] != '`') {
|
||||
// If the field is as <table>.<field>, don't scape.
|
||||
if (strstr($field, '.') === false) {
|
||||
|
@ -732,7 +738,8 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa
|
|||
} else if (is_float($value) || is_double($value)) {
|
||||
$query .= sprintf('%s = %f', $field, $value);
|
||||
} else if (is_array($value)) {
|
||||
$query .= sprintf('%s IN ("%s")', $field, implode('", "', $value));
|
||||
$not = $negative ? ' NOT ' : '';
|
||||
$query .= sprintf('%s %sIN ("%s")', $field, $not, implode('", "', $value));
|
||||
} else {
|
||||
if ($value === '') {
|
||||
// Search empty string
|
||||
|
|
|
@ -852,6 +852,28 @@ function get_parameter_checkbox($name, $default='')
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Transforms a swicth data (on - non present) to a int value.
|
||||
*
|
||||
* @param string $name Variable, switch name.
|
||||
* @param string $default Default value.
|
||||
*
|
||||
* @return integer Value, 1 on, 0 off.
|
||||
*/
|
||||
function get_parameter_switch($name, $default='')
|
||||
{
|
||||
$data = get_parameter($name, null);
|
||||
|
||||
if ($data === null) {
|
||||
return 0;
|
||||
} else if ($data == 'on') {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
function get_cookie($name, $default='')
|
||||
{
|
||||
if (isset($_COOKIE[$name])) {
|
||||
|
|
|
@ -1,26 +1,39 @@
|
|||
<?php
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
/**
|
||||
* @package Include
|
||||
* Extension to self monitor Pandora FMS Console
|
||||
*
|
||||
* @category Config
|
||||
* @package Pandora FMS
|
||||
* @subpackage Config
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Config functions.
|
||||
|
||||
|
||||
/**
|
||||
* Creates a single config value in the database.
|
||||
*
|
||||
* @param string Config token to create.
|
||||
* @param string Value to set.
|
||||
* @param string $token Config token to create.
|
||||
* @param string $value Value to set.
|
||||
*
|
||||
* @return boolean Config id if success. False on failure.
|
||||
*/
|
||||
|
@ -41,15 +54,15 @@ function config_create_value($token, $value)
|
|||
*
|
||||
* If the config token doesn't exists, it's created.
|
||||
*
|
||||
* @param string Config token to update.
|
||||
* @param string New value to set.
|
||||
* @param string $token Config token to update.
|
||||
* @param string $value New value to set.
|
||||
*
|
||||
* @return boolean True if success. False on failure.
|
||||
*/
|
||||
function config_update_value($token, $value)
|
||||
{
|
||||
global $config;
|
||||
// Include functions_io to can call __() function
|
||||
// Include functions_io to can call __() function.
|
||||
include_once $config['homedir'].'/include/functions_io.php';
|
||||
|
||||
if ($token == 'list_ACL_IPs_for_API') {
|
||||
|
@ -73,7 +86,7 @@ function config_update_value($token, $value)
|
|||
return (bool) config_create_value($token, io_safe_input($value));
|
||||
}
|
||||
|
||||
// If it has not changed
|
||||
// If it has not changed.
|
||||
if ($config[$token] == $value) {
|
||||
return true;
|
||||
}
|
||||
|
@ -97,15 +110,17 @@ function config_update_value($token, $value)
|
|||
|
||||
/**
|
||||
* Updates all config values in case setup page was invoked
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function config_update_config()
|
||||
{
|
||||
global $config;
|
||||
|
||||
// Include functions_io to can call __() function
|
||||
// Include functions_io to can call __() function.
|
||||
include_once $config['homedir'].'/include/functions_io.php';
|
||||
|
||||
// If user is not even log it, don't try this
|
||||
// If user is not even log it, don't try this.
|
||||
if (! isset($config['id_user'])) {
|
||||
$config['error_config_update_config'] = [];
|
||||
$config['error_config_update_config']['correct'] = false;
|
||||
|
@ -127,7 +142,7 @@ function config_update_config()
|
|||
if ($update_config) {
|
||||
db_pandora_audit('Setup', 'Setup has changed');
|
||||
} else {
|
||||
// Do none
|
||||
// Do nothing.
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -137,8 +152,8 @@ function config_update_config()
|
|||
switch ($sec2) {
|
||||
case 'godmode/setup/setup':
|
||||
$section_setup = get_parameter('section');
|
||||
// MAIN SETUP
|
||||
// Setup now is divided in different tabs
|
||||
// MAIN SETUP.
|
||||
// Setup now is divided in different tabs.
|
||||
switch ($section_setup) {
|
||||
case 'general':
|
||||
if (!config_update_value('language', (string) get_parameter('language'))) {
|
||||
|
@ -165,7 +180,7 @@ function config_update_config()
|
|||
$error_update[] = __('Automatic check for updates');
|
||||
}
|
||||
|
||||
if (!config_update_value('cert_path', get_parameter('cert_path'))) {
|
||||
if (!config_update_value('cert_path', (bool) get_parameter('cert_path'))) {
|
||||
$error_update[] = __('SSL cert path');
|
||||
}
|
||||
|
||||
|
@ -228,7 +243,7 @@ function config_update_config()
|
|||
$error_update[] = __('Sound for Monitor warning');
|
||||
}
|
||||
|
||||
// Update of Pandora FMS license
|
||||
// Update of Pandora FMS license.
|
||||
$update_manager_installed = db_get_value('value', 'tconfig', 'token', 'update_manager_installed');
|
||||
|
||||
if ($update_manager_installed == 1) {
|
||||
|
@ -294,10 +309,6 @@ function config_update_config()
|
|||
if (!config_update_value('auditdir', get_parameter('auditdir'))) {
|
||||
$error_update[] = __('Audit log directory');
|
||||
}
|
||||
|
||||
if (!config_update_value('unique_ip', get_parameter('unique_ip'))) {
|
||||
$error_update[] = __('unique_ip');
|
||||
}
|
||||
break;
|
||||
|
||||
case 'enterprise':
|
||||
|
@ -472,7 +483,7 @@ function config_update_config()
|
|||
break;
|
||||
|
||||
case 'auth':
|
||||
// AUTHENTICATION SETUP
|
||||
// AUTHENTICATION SETUP.
|
||||
if (!config_update_value('auth', get_parameter('auth'))) {
|
||||
$error_update[] = __('Authentication method');
|
||||
}
|
||||
|
@ -639,9 +650,10 @@ function config_update_config()
|
|||
break;
|
||||
|
||||
case 'perf':
|
||||
// PERFORMANCE SETUP
|
||||
// PERFORMANCE SETUP.
|
||||
if (!config_update_value('event_purge', get_parameter('event_purge'))) {
|
||||
$error_update[] = $check_metaconsole_events_history = get_parameter('metaconsole_events_history', -1);
|
||||
$check_metaconsole_events_history = get_parameter('metaconsole_events_history', -1);
|
||||
$error_update[] = $check_metaconsole_events_history;
|
||||
}
|
||||
|
||||
if ($check_metaconsole_events_history != -1) {
|
||||
|
@ -736,17 +748,17 @@ function config_update_config()
|
|||
}
|
||||
}
|
||||
|
||||
if (!config_update_value('max_graph_container', get_parameter('max_graph_container'))) {
|
||||
$error_update[] = __('Graph container - Max. Items');
|
||||
if (!config_update_value('delete_old_messages', get_parameter('delete_old_messages'))) {
|
||||
$error_update[] = __('Max. days before delete old messages');
|
||||
}
|
||||
|
||||
if (!config_update_value('max_execution_event_response', get_parameter('max_execution_event_response'))) {
|
||||
$error_update[] = __('Max. execution event response');
|
||||
if (!config_update_value('max_graph_container', get_parameter('max_graph_container'))) {
|
||||
$error_update[] = __('Graph container - Max. Items');
|
||||
}
|
||||
break;
|
||||
|
||||
case 'vis':
|
||||
// VISUAL STYLES SETUP
|
||||
// VISUAL STYLES SETUP.
|
||||
if (!config_update_value('date_format', (string) get_parameter('date_format'))) {
|
||||
$error_update[] = __('Date format string');
|
||||
}
|
||||
|
@ -1060,12 +1072,12 @@ function config_update_config()
|
|||
$error_update[] = __('Display text when proc modules have state critical');
|
||||
}
|
||||
|
||||
// Daniel maya 02/06/2016 Display menu with click --INI
|
||||
// Daniel maya 02/06/2016 Display menu with click --INI.
|
||||
if (!config_update_value('click_display', (bool) get_parameter('click_display', false))) {
|
||||
$error_update[] = __('Display lateral menus with left click');
|
||||
}
|
||||
|
||||
// Daniel maya 02/06/2016 Display menu with click --END
|
||||
// Daniel maya 02/06/2016 Display menu with click --END.
|
||||
if (isset($config['enterprise_installed']) && $config['enterprise_installed'] == 1) {
|
||||
if (!config_update_value('service_label_font_size', get_parameter('service_label_font_size', false))) {
|
||||
$error_update[] = __('Service label font size');
|
||||
|
@ -1136,7 +1148,7 @@ function config_update_config()
|
|||
// --------------------------------------------------
|
||||
$interval_values = get_parameter('interval_values');
|
||||
|
||||
// Add new interval value if is provided
|
||||
// Add new interval value if is provided.
|
||||
$interval_value = (float) get_parameter('interval_value', 0);
|
||||
|
||||
if ($interval_value > 0) {
|
||||
|
@ -1154,7 +1166,7 @@ function config_update_config()
|
|||
}
|
||||
}
|
||||
|
||||
// Delete interval value if is required
|
||||
// Delete interval value if is required.
|
||||
$interval_to_delete = (float) get_parameter('interval_to_delete');
|
||||
if ($interval_to_delete > 0) {
|
||||
$interval_values_array = explode(',', $interval_values);
|
||||
|
@ -1176,7 +1188,7 @@ function config_update_config()
|
|||
$error_update[] = __('Custom report info');
|
||||
}
|
||||
|
||||
// Juanma (06/05/2014) New feature: Custom front page for reports
|
||||
// Juanma (06/05/2014) New feature: Custom front page for reports.
|
||||
if (!config_update_value('custom_report_front', get_parameter('custom_report_front'))) {
|
||||
$error_update[] = __('Custom report front');
|
||||
}
|
||||
|
@ -1337,7 +1349,15 @@ function config_update_config()
|
|||
$error_update[] = __('eHorus id custom field');
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Ignore.
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
// Ignore.
|
||||
break;
|
||||
}
|
||||
|
||||
if (count($error_update) > 0) {
|
||||
|
@ -1359,7 +1379,9 @@ function config_update_config()
|
|||
|
||||
|
||||
/**
|
||||
* Process config variables
|
||||
* Process config variables.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function config_process_config()
|
||||
{
|
||||
|
@ -1377,7 +1399,7 @@ function config_process_config()
|
|||
$is_windows = true;
|
||||
}
|
||||
|
||||
// Compatibility fix
|
||||
// Compatibility fix.
|
||||
foreach ($configs as $c) {
|
||||
$config[$c['token']] = $c['value'];
|
||||
}
|
||||
|
@ -1434,18 +1456,18 @@ function config_process_config()
|
|||
|
||||
if (!isset($config['prominent_time'])) {
|
||||
// Prominent time tells us what to show prominently when a timestamp is
|
||||
// displayed. The comparation (... days ago) or the timestamp (full date)
|
||||
// displayed. The comparation (... days ago) or the timestamp (full date).
|
||||
config_update_value('prominent_time', 'comparation');
|
||||
}
|
||||
|
||||
if (!isset($config['timesource'])) {
|
||||
// Timesource says where time comes from (system or mysql)
|
||||
// Timesource says where time comes from (system or mysql).
|
||||
config_update_value('timesource', 'system');
|
||||
}
|
||||
|
||||
if (!isset($config['https'])) {
|
||||
// Sets whether or not we want to enforce https. We don't want to go to a
|
||||
// potentially unexisting config by default
|
||||
// potentially unexisting config by default.
|
||||
config_update_value('https', false);
|
||||
}
|
||||
|
||||
|
@ -1454,7 +1476,7 @@ function config_process_config()
|
|||
}
|
||||
|
||||
if (!isset($config['cert_path'])) {
|
||||
// Sets name and path of ssl path for use in application
|
||||
// Sets name and path of ssl path for use in application.
|
||||
config_update_value('cert_path', '/etc/ssl/certs/pandorafms.pem');
|
||||
}
|
||||
|
||||
|
@ -1466,7 +1488,7 @@ function config_process_config()
|
|||
config_update_value('status_images_set', 'default');
|
||||
}
|
||||
|
||||
// Load user session
|
||||
// Load user session.
|
||||
if (isset($_SESSION['id_usuario'])) {
|
||||
$config['id_user'] = $_SESSION['id_usuario'];
|
||||
}
|
||||
|
@ -1517,12 +1539,12 @@ function config_process_config()
|
|||
}
|
||||
}
|
||||
|
||||
if (!isset($config['max_graph_container'])) {
|
||||
config_update_value('max_graph_container', 10);
|
||||
if (!isset($config['delete_old_messages'])) {
|
||||
config_update_value('delete_old_messages', 21);
|
||||
}
|
||||
|
||||
if (!isset($config['max_execution_event_response'])) {
|
||||
config_update_value('max_execution_event_response', 10);
|
||||
if (!isset($config['max_graph_container'])) {
|
||||
config_update_value('max_graph_container', 10);
|
||||
}
|
||||
|
||||
if (!isset($config['max_macro_fields'])) {
|
||||
|
@ -1669,13 +1691,10 @@ function config_process_config()
|
|||
config_update_value('limit_parameters_massive', (ini_get('max_input_vars') / 2));
|
||||
}
|
||||
|
||||
if (!isset($config['unique_ip'])) {
|
||||
config_update_value('unique_ip', 0);
|
||||
}
|
||||
|
||||
/*
|
||||
*Parse the ACL IP list for access API
|
||||
* Parse the ACL IP list for access API
|
||||
*/
|
||||
|
||||
$temp_list_ACL_IPs_for_API = [];
|
||||
if (isset($config['list_ACL_IPs_for_API'])) {
|
||||
if (!empty($config['list_ACL_IPs_for_API'])) {
|
||||
|
@ -1691,8 +1710,7 @@ function config_process_config()
|
|||
// the first time make a conenction and disable itself
|
||||
// Not Managed here !
|
||||
// if (!isset ($config["autoupdate"])) {
|
||||
// config_update_value ('autoupdate', true);
|
||||
// }
|
||||
// config_update_value ('autoupdate', true);.
|
||||
include_once $config['homedir'].'/include/auth/mysql.php';
|
||||
include_once $config['homedir'].'/include/functions_io.php';
|
||||
|
||||
|
@ -2287,7 +2305,7 @@ function config_process_config()
|
|||
}
|
||||
|
||||
if (defined('METACONSOLE')) {
|
||||
// Customizable sections (Metaconsole)
|
||||
// Customizable sections (Metaconsole).
|
||||
enterprise_include_once('include/functions_enterprise.php');
|
||||
$customizable_sections = enterprise_hook('enterprise_get_customizable_sections');
|
||||
|
||||
|
@ -2309,15 +2327,15 @@ function config_process_config()
|
|||
) {
|
||||
$isFunctionSkins = enterprise_include_once('include/functions_skins.php');
|
||||
if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) {
|
||||
// Try to update user table in order to refresh skin inmediatly
|
||||
// Try to update user table in order to refresh skin inmediatly.
|
||||
$is_user_updating = get_parameter('sec2', '');
|
||||
|
||||
if ($is_user_updating == 'operation/users/user_edit') {
|
||||
$id = get_parameter_get('id', $config['id_user']);
|
||||
// ID given as parameter
|
||||
// ID given as parameter.
|
||||
$user_info = get_user_info($id);
|
||||
|
||||
// If current user is editing himself or if the user has UM (User Management) rights on any groups the user is part of AND the authorization scheme allows for users/admins to update info
|
||||
// If current user is editing himself or if the user has UM (User Management) rights on any groups the user is part of AND the authorization scheme allows for users/admins to update info.
|
||||
if (($config['id_user'] == $id || check_acl($config['id_user'], users_get_groups($id), 'UM')) && $config['user_can_update_info']) {
|
||||
$view_mode = false;
|
||||
} else {
|
||||
|
@ -2331,7 +2349,7 @@ function config_process_config()
|
|||
}
|
||||
|
||||
if (!is_metaconsole()) {
|
||||
// Skins are available only in console mode
|
||||
// Skins are available only in console mode.
|
||||
if (isset($config['id_user'])) {
|
||||
$relative_path = enterprise_hook('skins_set_image_skin_path', [$config['id_user']]);
|
||||
} else {
|
||||
|
@ -2461,12 +2479,12 @@ function config_process_config()
|
|||
config_update_value('render_proc_fail', __('Fail'));
|
||||
}
|
||||
|
||||
// Daniel maya 02/06/2016 Display menu with click --INI
|
||||
// Daniel maya 02/06/2016 Display menu with click --INI.
|
||||
if (!isset($config['click_display'])) {
|
||||
config_update_value('click_display', 1);
|
||||
}
|
||||
|
||||
// Daniel maya 02/06/2016 Display menu with click --END
|
||||
// Daniel maya 02/06/2016 Display menu with click --END.
|
||||
if (isset($config['enterprise_installed']) && $config['enterprise_installed'] == 1) {
|
||||
if (!isset($config['service_label_font_size'])) {
|
||||
config_update_value('service_label_font_size', 20);
|
||||
|
@ -2493,7 +2511,7 @@ function config_process_config()
|
|||
config_update_value('custom_report_info', 1);
|
||||
}
|
||||
|
||||
// Juanma (06/05/2014) New feature: Custom front page for reports
|
||||
// Juanma (06/05/2014) New feature: Custom front page for reports.
|
||||
if (!isset($config['custom_report_front'])) {
|
||||
config_update_value('custom_report_front', 0);
|
||||
}
|
||||
|
@ -2603,7 +2621,7 @@ function config_process_config()
|
|||
config_update_value('instance_registered', 0);
|
||||
}
|
||||
|
||||
// eHorus
|
||||
// Ehorus.
|
||||
if (!isset($config['ehorus_enabled'])) {
|
||||
config_update_value('ehorus_enabled', 0);
|
||||
}
|
||||
|
@ -2638,285 +2656,77 @@ function config_process_config()
|
|||
}
|
||||
}
|
||||
|
||||
// Finally, check if any value was overwritten in a form
|
||||
// Finally, check if any value was overwritten in a form.
|
||||
config_update_config();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Start supervisor.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function config_check()
|
||||
{
|
||||
global $config;
|
||||
|
||||
// At this first version I'm passing errors using session variables, because the error management
|
||||
// is done by an AJAX request. Better solutions could be implemented in the future :-)
|
||||
if (license_free() && users_is_admin($config['id_user'])) {
|
||||
$login = get_parameter('login', false);
|
||||
// Registration advice
|
||||
if ((!isset($config['instance_registered']) || ($config['instance_registered'] != 1)) && ($login === false)) {
|
||||
set_pandora_error_for_header(
|
||||
__('Click <a style="font-weight:bold; text-decoration:underline" href="javascript: force_run_register();"> here</a> to start the registration process'),
|
||||
__('This instance is not registered in the Update manager')
|
||||
);
|
||||
}
|
||||
include_once __DIR__.'/class/ConsoleSupervisor.php';
|
||||
|
||||
// Newsletter advice
|
||||
$newsletter = db_get_value('middlename', 'tusuario', 'id_user', $config['id_user']);
|
||||
if ($newsletter != 1 && $login === false) {
|
||||
set_pandora_error_for_header(
|
||||
__('Click <a style="font-weight:bold; text-decoration:underline" href="javascript: force_run_newsletter();"> here</a> to start the newsletter subscription process'),
|
||||
__('Not subscribed to the newsletter')
|
||||
);
|
||||
}
|
||||
// Enterprise customers launch supervisor using discovery task.
|
||||
if (enterprise_installed() === false) {
|
||||
$supervisor = new ConsoleSupervisor(false);
|
||||
$supervisor->run();
|
||||
} else if ($config['cron_last_run'] == 0
|
||||
|| (get_system_time() - $config['cron_last_run']) > 3600
|
||||
) {
|
||||
$supervisor = new ConsoleSupervisor(false);
|
||||
$supervisor->runBasic();
|
||||
}
|
||||
|
||||
// Check default password for "admin"
|
||||
$is_admin = db_get_value('is_admin', 'tusuario', 'id_user', $config['id_user']);
|
||||
if ($is_admin) {
|
||||
$hashpass = db_get_sql(
|
||||
"SELECT password
|
||||
FROM tusuario WHERE id_user = 'admin'"
|
||||
);
|
||||
if ($hashpass == '1da7ee7d45b96d0e1f45ee4ee23da560') {
|
||||
set_pandora_error_for_header(
|
||||
__('Default password for "Admin" user has not been changed.'),
|
||||
__('Please change the default password because is a common vulnerability reported.')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($config['license_expired'])) {
|
||||
set_pandora_error_for_header(
|
||||
__('You can not get updates until you renew the license.'),
|
||||
__('This license has expired.')
|
||||
);
|
||||
}
|
||||
|
||||
if (!is_writable('attachment')) {
|
||||
set_pandora_error_for_header(
|
||||
__('Please check that the web server has write rights on the {HOMEDIR}/attachment directory'),
|
||||
__('Attachment directory is not writable by HTTP Server')
|
||||
);
|
||||
}
|
||||
|
||||
// Get remote file dir.
|
||||
$remote_config = io_safe_output(
|
||||
db_get_value_filter(
|
||||
'value',
|
||||
'tconfig',
|
||||
['token' => 'remote_config']
|
||||
)
|
||||
);
|
||||
|
||||
if (enterprise_installed()) {
|
||||
if (!is_readable($remote_config)) {
|
||||
set_pandora_error_for_header(
|
||||
__('Remote configuration directory is not readble for the console').' - '.$remote_config
|
||||
);
|
||||
}
|
||||
|
||||
$remote_config_conf = $remote_config.'/conf';
|
||||
if (!is_writable($remote_config_conf)) {
|
||||
set_pandora_error_for_header(
|
||||
__('Remote configuration directory is not writtable for the console').' - '.$remote_config.'/conf'
|
||||
);
|
||||
}
|
||||
|
||||
$remote_config_col = $remote_config.'/collections';
|
||||
if (!is_writable($remote_config_col)) {
|
||||
set_pandora_error_for_header(
|
||||
__('Remote configuration directory is not writtable for the console').' - '.$remote_config.'/collections'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Check attachment directory (too much files?)
|
||||
$filecount = count(glob($config['homedir'].'/attachment/*'));
|
||||
// N temporal files of trash should be enough for most people.
|
||||
if ($filecount > $config['num_files_attachment']) {
|
||||
set_pandora_error_for_header(
|
||||
__('There are too much files in attachment directory. This is not fatal, but you should consider cleaning up your attachment directory manually')." ( $filecount ".__('files').' )',
|
||||
__('Too much files in your tempora/attachment directory')
|
||||
);
|
||||
}
|
||||
|
||||
// Check database maintance
|
||||
$db_maintance = db_get_value_filter(
|
||||
'value',
|
||||
'tconfig',
|
||||
['token' => 'db_maintance']
|
||||
);
|
||||
|
||||
// If never was executed, it means we are in the first Pandora FMS execution. Set current timestamp
|
||||
if (empty($db_maintance)) {
|
||||
config_update_value('db_maintance', date('U'));
|
||||
}
|
||||
|
||||
$last_maintance = (date('U') - $db_maintance);
|
||||
|
||||
// ~ about 50 hr
|
||||
if ($last_maintance > 190000) {
|
||||
set_pandora_error_for_header(
|
||||
__('Your database is not maintained correctly. It seems that more than 48hrs have passed without proper maintenance. Please review documents of %s on how to perform this maintenance process (DB Tool) and enable it as soon as possible.', get_product_name()),
|
||||
__('Database maintance problem')
|
||||
);
|
||||
}
|
||||
|
||||
$fontpath = io_safe_output(db_get_value_filter('value', 'tconfig', ['token' => 'fontpath']));
|
||||
if (($fontpath == '') or (!file_exists($fontpath))) {
|
||||
set_pandora_error_for_header(
|
||||
__('Your defined font doesnt exist or is not defined. Please check font parameters in your config'),
|
||||
__('Default font doesnt exist')
|
||||
);
|
||||
}
|
||||
|
||||
if ($config['event_storm_protection']) {
|
||||
set_pandora_error_for_header(
|
||||
__('You need to restart server after altering this configuration setting.'),
|
||||
__('Event storm protection is activated. No events will be generated during this mode.')
|
||||
);
|
||||
}
|
||||
|
||||
global $develop_bypass;
|
||||
|
||||
if ($develop_bypass == 1) {
|
||||
set_pandora_error_for_header(
|
||||
__('Your %s has the "develop_bypass" mode enabled. This is a developer mode and should be disabled in a production system. This value is written in the main index.php file', get_product_name()),
|
||||
__('Developer mode is enabled')
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($_SESSION['new_update'])) {
|
||||
if (!empty($_SESSION['return_installation_open'])) {
|
||||
if (!$_SESSION['return_installation_open']['return']) {
|
||||
foreach ($_SESSION['return_installation_open']['text'] as $message) {
|
||||
set_pandora_error_for_header(
|
||||
$message,
|
||||
__('Error first setup Open update')
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($_SESSION['new_update'] == 'new') {
|
||||
set_pandora_error_for_header(
|
||||
__('There is a new update available. Please<a style="font-weight:bold;" href="index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=online"> go to Administration:Setup:Update Manager</a> for more details.'),
|
||||
__('New %s Console update', get_product_name())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// PHP configuration values
|
||||
$PHPupload_max_filesize = config_return_in_bytes(ini_get('upload_max_filesize'));
|
||||
$PHPmax_input_time = ini_get('max_input_time');
|
||||
$PHPmemory_limit = config_return_in_bytes(ini_get('memory_limit'));
|
||||
$PHPmax_execution_time = ini_get('max_execution_time');
|
||||
$PHPsafe_mode = ini_get('safe_mode');
|
||||
$PHPdisable_functions = ini_get('disable_functions');
|
||||
|
||||
if ($PHPsafe_mode === '1') {
|
||||
set_pandora_error_for_header(
|
||||
__('To disable, change it on your PHP configuration file (php.ini) and put safe_mode = Off (Dont forget restart apache process after changes)'),
|
||||
sprintf(__('PHP safe mode is enabled. Some features may not properly work.'))
|
||||
);
|
||||
}
|
||||
|
||||
if ($PHPmax_input_time !== '-1') {
|
||||
set_pandora_error_for_header(
|
||||
sprintf(__('Recommended value is %s'), '-1 ('.__('Unlimited').')').'<br><br>'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'),
|
||||
sprintf(__("Not recommended '%s' value in PHP configuration"), 'max_input_time')
|
||||
);
|
||||
}
|
||||
|
||||
if ($PHPmax_execution_time !== '0') {
|
||||
set_pandora_error_for_header(
|
||||
sprintf(__('Recommended value is: %s'), '0 ('.__('Unlimited').')').'<br><br>'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'),
|
||||
sprintf(__("Not recommended '%s' value in PHP configuration"), 'max_execution_time')
|
||||
);
|
||||
}
|
||||
|
||||
$PHPupload_max_filesize_min = config_return_in_bytes('800M');
|
||||
|
||||
if ($PHPupload_max_filesize < $PHPupload_max_filesize_min) {
|
||||
set_pandora_error_for_header(
|
||||
sprintf(__('Recommended value is: %s'), sprintf(__('%s or greater'), '800M')).'<br><br>'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'),
|
||||
sprintf(__("Not recommended '%s' value in PHP configuration"), 'upload_max_filesize')
|
||||
);
|
||||
}
|
||||
|
||||
$PHPmemory_limit_min = config_return_in_bytes('500M');
|
||||
|
||||
if ($PHPmemory_limit < $PHPmemory_limit_min && $PHPmemory_limit !== '-1') {
|
||||
set_pandora_error_for_header(
|
||||
sprintf(__('Recommended value is: %s'), sprintf(__('%s or greater'), '500M')).'<br><br>'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator'),
|
||||
sprintf(__("Not recommended '%s' value in PHP configuration"), 'memory_limit')
|
||||
);
|
||||
}
|
||||
|
||||
if (preg_match('/system/', $PHPdisable_functions) or preg_match('/exec/', $PHPdisable_functions)) {
|
||||
set_pandora_error_for_header(
|
||||
__('Variable disable_functions containts functions system() or exec(), in PHP configuration file (php.ini)').'<br /><br />'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'),
|
||||
__('Problems with disable functions in PHP.INI')
|
||||
);
|
||||
}
|
||||
|
||||
$result_ejecution = exec('"'.io_safe_output($config['phantomjs_bin']).'/phantomjs" --version');
|
||||
if (!isset($result_ejecution) || $result_ejecution == '') {
|
||||
if ($config['language'] == 'es') {
|
||||
set_pandora_error_for_header(
|
||||
__('To be able to create images of the graphs for PDFs, please install the phantom.js extension. For that, it is necessary to follow these steps:').'<a target="blank" href="https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Configuracion#Phantomjs">Click here</a>',
|
||||
__('phantomjs is not installed')
|
||||
);
|
||||
} else {
|
||||
set_pandora_error_for_header(
|
||||
__('To be able to create images of the graphs for PDFs, please install the phantom.js extension. For that, it is necessary to follow these steps:').'<a target="blank" href="https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Configuration#Phantomjs">Click here</a>',
|
||||
__('phantomjs is not installed')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$php_version = phpversion();
|
||||
$php_version_array = explode('.', $php_version);
|
||||
if ($php_version_array[0] < 7) {
|
||||
if ($config['language'] == 'es') {
|
||||
$url_help = 'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Instalaci%C3%B3n_y_actualizaci%C3%B3n_PHP_7';
|
||||
} else {
|
||||
$url_help = 'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:_PHP_7';
|
||||
}
|
||||
|
||||
set_pandora_error_for_header(
|
||||
__('For a correct operation of PandoraFMS, PHP must be updated to version 7.0 or higher.').'<br>'.__('Otherwise, functionalities will be lost.').'<br>'."<ol><li style='color: #676767'>".__('Report download in PDF format').'</li>'."<li style='color: #676767'>".__('Emails Sending').'</li>'."<li style='color: #676767'>".__('Metaconsole Collections').'</li>'."<li style='color: #676767'>".'...'.'</li>'.'</ol>'.'<a target="blank" href="'.$url_help.'">'.__('Access Help').'</a>',
|
||||
__('PHP UPDATE REQUIRED')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return in bytes
|
||||
*
|
||||
* @param string $val Value to convert.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
function config_return_in_bytes($val)
|
||||
{
|
||||
$val = trim($val);
|
||||
$last = strtolower($val[(strlen($val) - 1)]);
|
||||
switch ($last) {
|
||||
// The 'G' modifier is available since PHP 5.1.0
|
||||
// The 'G' modifier is available since PHP 5.1.0.
|
||||
case 'g':
|
||||
$val *= 1024;
|
||||
case 'm':
|
||||
$val *= 1024;
|
||||
case 'k':
|
||||
$val *= 1024;
|
||||
default:
|
||||
// Ignore.
|
||||
break;
|
||||
}
|
||||
|
||||
return $val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function config_user_set_custom_config()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$userinfo = get_user_info($config['id_user']);
|
||||
|
||||
// Refresh the last_connect info in the user table
|
||||
// if last update was more than 5 minutes ago
|
||||
// Refresh the last_connect info in the user table.
|
||||
// if last update was more than 5 minutes ago.
|
||||
if ($userinfo['last_connect'] < (time() - SECONDS_1MINUTE)) {
|
||||
update_user($config['id_user'], ['last_connect' => time()]);
|
||||
}
|
||||
|
@ -2925,7 +2735,7 @@ function config_user_set_custom_config()
|
|||
$config['block_size'] = $userinfo['block_size'];
|
||||
}
|
||||
|
||||
// Each user could have it's own timezone)
|
||||
// Each user could have it's own timezone).
|
||||
if (isset($userinfo['timezone'])) {
|
||||
if ($userinfo['timezone'] != '') {
|
||||
date_default_timezone_set($userinfo['timezone']);
|
||||
|
@ -2938,6 +2748,11 @@ function config_user_set_custom_config()
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function config_prepare_session()
|
||||
{
|
||||
global $config;
|
||||
|
@ -2950,10 +2765,10 @@ function config_prepare_session()
|
|||
}
|
||||
|
||||
if ($user_sesion_time == 0) {
|
||||
// Change the session timeout value to session_timeout minutes // 8*60*60 = 8 hours
|
||||
// Change the session timeout value to session_timeout minutes // 8*60*60 = 8 hours.
|
||||
$sessionCookieExpireTime = $config['session_timeout'];
|
||||
} else {
|
||||
// Change the session timeout value to session_timeout minutes // 8*60*60 = 8 hours
|
||||
// Change the session timeout value to session_timeout minutes // 8*60*60 = 8 hours.
|
||||
$sessionCookieExpireTime = $user_sesion_time;
|
||||
}
|
||||
|
||||
|
@ -2963,7 +2778,7 @@ function config_prepare_session()
|
|||
$sessionCookieExpireTime *= 60;
|
||||
}
|
||||
|
||||
// Reset the expiration time upon page load //session_name() is default name of session PHPSESSID
|
||||
// Reset the expiration time upon page load //session_name() is default name of session PHPSESSID.
|
||||
if (isset($_COOKIE[session_name()])) {
|
||||
setcookie(session_name(), $_COOKIE[session_name()], (time() + $sessionCookieExpireTime), '/');
|
||||
}
|
||||
|
|
|
@ -15,17 +15,23 @@ global $config;
|
|||
|
||||
require_once $config['homedir'].'/include/functions_db.php';
|
||||
|
||||
// Update the execution interval of the given module
|
||||
// Update the execution interval of the given module.
|
||||
function cron_update_module_interval($module_id, $cron)
|
||||
{
|
||||
// Check for a valid cron
|
||||
// Check for a valid cron.
|
||||
if (!cron_check_syntax($cron)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($cron == '* * * * *') {
|
||||
$module_interval = db_get_value_filter('module_interval', 'tagente_modulo', ['id_agente_modulo' => $module_id]);
|
||||
return db_process_sql('UPDATE tagente_estado SET current_interval = '.$module_interval.' WHERE id_agente_modulo = '.(int) $module_id);
|
||||
$module_interval = db_get_value_filter(
|
||||
'module_interval',
|
||||
'tagente_modulo',
|
||||
['id_agente_modulo' => $module_id]
|
||||
);
|
||||
return db_process_sql(
|
||||
'UPDATE tagente_estado SET current_interval = '.$module_interval.' WHERE id_agente_modulo = '.(int) $module_id
|
||||
);
|
||||
} else {
|
||||
return db_process_sql(
|
||||
'UPDATE tagente_estado SET current_interval = '.cron_next_execution($cron, $module_interval, $module_id).' WHERE id_agente_modulo = '.(int) $module_id
|
||||
|
@ -38,7 +44,7 @@ function cron_update_module_interval($module_id, $cron)
|
|||
// Get the number of seconds left to the next execution of the given cron entry.
|
||||
function cron_next_execution($cron, $module_interval, $module_id)
|
||||
{
|
||||
// Get day of the week and month from cron config
|
||||
// Get day of the week and month from cron config.
|
||||
$cron_array = explode(' ', $cron);
|
||||
$minute = $cron_array[0];
|
||||
$hour = $cron_array[1];
|
||||
|
@ -46,21 +52,34 @@ function cron_next_execution($cron, $module_interval, $module_id)
|
|||
$month = $cron_array[3];
|
||||
$wday = $cron_array[4];
|
||||
|
||||
// Get last execution time
|
||||
$last_execution = db_get_value('utimestamp', 'tagente_estado', 'id_agente_modulo', $module_id);
|
||||
// Get last execution time.
|
||||
$last_execution = db_get_value(
|
||||
'utimestamp',
|
||||
'tagente_estado',
|
||||
'id_agente_modulo',
|
||||
$module_id
|
||||
);
|
||||
$cur_time = ($last_execution !== false) ? $last_execution : time();
|
||||
|
||||
// Any day of the way
|
||||
// Any day of the way.
|
||||
if ($wday == '*') {
|
||||
$nex_time = cron_next_execution_date($cron, $cur_time, $module_interval);
|
||||
$nex_time = cron_next_execution_date(
|
||||
$cron,
|
||||
$cur_time,
|
||||
$module_interval
|
||||
);
|
||||
return ($nex_time - $cur_time);
|
||||
}
|
||||
|
||||
// A specific day of the week
|
||||
// A specific day of the week.
|
||||
$count = 0;
|
||||
$nex_time = $cur_time;
|
||||
do {
|
||||
$nex_time = cron_next_execution_date($cron, $nex_time, $module_interval);
|
||||
$nex_time = cron_next_execution_date(
|
||||
$cron,
|
||||
$nex_time,
|
||||
$module_interval
|
||||
);
|
||||
$nex_time_wd = $nex_time;
|
||||
|
||||
$array_nex = explode(' ', date('m w', $nex_time_wd));
|
||||
|
@ -68,12 +87,12 @@ function cron_next_execution($cron, $module_interval, $module_id)
|
|||
$nex_wday = $array_nex[1];
|
||||
|
||||
do {
|
||||
// Check the day of the week
|
||||
// Check the day of the week.
|
||||
if ($nex_wday == $wday) {
|
||||
return ($nex_time_wd - $cur_time);
|
||||
}
|
||||
|
||||
// Move to the next day of the month
|
||||
// Move to the next day of the month.
|
||||
$nex_time_wd += SECONDS_1DAY;
|
||||
|
||||
$array_nex_w = explode(' ', date('m w', $nex_time_wd));
|
||||
|
@ -84,7 +103,7 @@ function cron_next_execution($cron, $module_interval, $module_id)
|
|||
$count++;
|
||||
} while ($count < SECONDS_1MINUTE);
|
||||
|
||||
// Something went wrong, default to 5 minutes
|
||||
// Something went wrong, default to 5 minutes.
|
||||
return SECONDS_5MINUTES;
|
||||
}
|
||||
|
||||
|
@ -92,11 +111,11 @@ function cron_next_execution($cron, $module_interval, $module_id)
|
|||
// Get the next execution date for the given cron entry in seconds since epoch.
|
||||
function cron_next_execution_date($cron, $cur_time=false, $module_interval=300)
|
||||
{
|
||||
// Get cron configuration
|
||||
// Get cron configuration.
|
||||
$cron_array = explode(' ', $cron);
|
||||
|
||||
// REMARKS: Months start from 1 in php (different to server)
|
||||
// Get current time
|
||||
// Get current time.
|
||||
if ($cur_time === false) {
|
||||
$cur_time = time();
|
||||
}
|
||||
|
@ -107,7 +126,7 @@ function cron_next_execution_date($cron, $cur_time=false, $module_interval=300)
|
|||
return $nex_time;
|
||||
}
|
||||
|
||||
// Update minutes
|
||||
// Update minutes.
|
||||
$min_s = cron_get_interval($cron_array[0]);
|
||||
$nex_time_array[0] = ($min_s['down'] == '*') ? 0 : $min_s['down'];
|
||||
|
||||
|
@ -118,22 +137,22 @@ function cron_next_execution_date($cron, $cur_time=false, $module_interval=300)
|
|||
}
|
||||
}
|
||||
|
||||
// Check if next hour is in cron
|
||||
// Check if next hour is in cron.
|
||||
$nex_time_array[1]++;
|
||||
$nex_time = cron_valid_date($nex_time_array);
|
||||
|
||||
if ($nex_time === false) {
|
||||
// Update the month day if overflow
|
||||
// Update the month day if overflow.
|
||||
$nex_time_array[1] = 0;
|
||||
$nex_time_array[2]++;
|
||||
$nex_time = cron_valid_date($nex_time_array);
|
||||
if ($nex_time === false) {
|
||||
// Update the month if overflow
|
||||
// Update the month if overflow.
|
||||
$nex_time_array[2] = 1;
|
||||
$nex_time_array[3]++;
|
||||
$nex_time = cron_valid_date($nex_time_array);
|
||||
if ($nex_time === false) {
|
||||
// Update the year if overflow
|
||||
// Update the year if overflow.
|
||||
$nex_time_array[3] = 1;
|
||||
$nex_time_array[4]++;
|
||||
$nex_time = cron_valid_date($nex_time_array);
|
||||
|
@ -141,16 +160,16 @@ function cron_next_execution_date($cron, $cur_time=false, $module_interval=300)
|
|||
}
|
||||
}
|
||||
|
||||
// Check the hour
|
||||
// Check the hour.
|
||||
if (cron_is_in_cron($cron_array, $nex_time_array) && $nex_time) {
|
||||
return $nex_time;
|
||||
}
|
||||
|
||||
// Update the hour if fails
|
||||
// Update the hour if fails.
|
||||
$hour_s = cron_get_interval($cron_array[1]);
|
||||
$nex_time_array[1] = ($hour_s['down'] == '*') ? 0 : $hour_s['down'];
|
||||
|
||||
// When an overflow is passed check the hour update again
|
||||
// When an overflow is passed check the hour update again.
|
||||
$nex_time = cron_valid_date($nex_time_array);
|
||||
if ($nex_time >= $cur_time) {
|
||||
if (cron_is_in_cron($cron_array, $nex_time_array) && $nex_time) {
|
||||
|
@ -158,32 +177,32 @@ function cron_next_execution_date($cron, $cur_time=false, $module_interval=300)
|
|||
}
|
||||
}
|
||||
|
||||
// Check if next day is in cron
|
||||
// Check if next day is in cron.
|
||||
$nex_time_array[2]++;
|
||||
$nex_time = cron_valid_date($nex_time_array);
|
||||
if ($nex_time === false) {
|
||||
// Update the month if overflow
|
||||
// Update the month if overflow.
|
||||
$nex_time_array[2] = 1;
|
||||
$nex_time_array[3]++;
|
||||
$nex_time = cron_valid_date($nex_time_array);
|
||||
if ($nex_time === false) {
|
||||
// Update the year if overflow
|
||||
// Update the year if overflow.
|
||||
$nex_time_array[3] = 1;
|
||||
$nex_time_array[4]++;
|
||||
$nex_time = cron_valid_date($nex_time_array);
|
||||
}
|
||||
}
|
||||
|
||||
// Check the day
|
||||
// Check the day.
|
||||
if (cron_is_in_cron($cron_array, $nex_time_array) && $nex_time) {
|
||||
return $nex_time;
|
||||
}
|
||||
|
||||
// Update the day if fails
|
||||
// Update the day if fails.
|
||||
$mday_s = cron_get_interval($cron_array[2]);
|
||||
$nex_time_array[2] = ($mday_s['down'] == '*') ? 1 : $mday_s['down'];
|
||||
|
||||
// When an overflow is passed check the hour update in the next execution
|
||||
// When an overflow is passed check the hour update in the next execution.
|
||||
$nex_time = cron_valid_date($nex_time_array);
|
||||
if ($nex_time >= $cur_time) {
|
||||
if (cron_is_in_cron($cron_array, $nex_time_array) && $nex_time) {
|
||||
|
@ -191,26 +210,26 @@ function cron_next_execution_date($cron, $cur_time=false, $module_interval=300)
|
|||
}
|
||||
}
|
||||
|
||||
// Check if next month is in cron
|
||||
// Check if next month is in cron.
|
||||
$nex_time_array[3]++;
|
||||
$nex_time = cron_valid_date($nex_time_array);
|
||||
if ($nex_time === false) {
|
||||
// Update the year if overflow
|
||||
// Update the year if overflow.
|
||||
$nex_time_array[3] = 1;
|
||||
$nex_time_array[4]++;
|
||||
$nex_time = cron_valid_date($nex_time_array);
|
||||
}
|
||||
|
||||
// Check the month
|
||||
// Check the month.
|
||||
if (cron_is_in_cron($cron_array, $nex_time_array) && $nex_time) {
|
||||
return $nex_time;
|
||||
}
|
||||
|
||||
// Update the month if fails
|
||||
// Update the month if fails.
|
||||
$mon_s = cron_get_interval($cron_array[3]);
|
||||
$nex_time_array[3] = ($mon_s['down'] == '*') ? 1 : $mon_s['down'];
|
||||
|
||||
// When an overflow is passed check the hour update in the next execution
|
||||
// When an overflow is passed check the hour update in the next execution.
|
||||
$nex_time = cron_valid_date($nex_time_array);
|
||||
if ($nex_time >= $cur_time) {
|
||||
if (cron_is_in_cron($cron_array, $nex_time_array) && $nex_time) {
|
||||
|
@ -218,7 +237,7 @@ function cron_next_execution_date($cron, $cur_time=false, $module_interval=300)
|
|||
}
|
||||
}
|
||||
|
||||
// Update the year
|
||||
// Update the year.
|
||||
$nex_time_array[4]++;
|
||||
$nex_time = cron_valid_date($nex_time_array);
|
||||
|
||||
|
@ -226,10 +245,10 @@ function cron_next_execution_date($cron, $cur_time=false, $module_interval=300)
|
|||
}
|
||||
|
||||
|
||||
// Get an array with the cron interval
|
||||
// Get an array with the cron interval.
|
||||
function cron_get_interval($element)
|
||||
{
|
||||
// Not a range
|
||||
// Not a range.
|
||||
if (!preg_match('/(\d+)\-(\d+)/', $element, $capture)) {
|
||||
return [
|
||||
'down' => $element,
|
||||
|
@ -250,12 +269,12 @@ function cron_is_in_cron($elems_cron, $elems_curr_time)
|
|||
$elem_cron = array_shift($elems_cron);
|
||||
$elem_curr_time = array_shift($elems_curr_time);
|
||||
|
||||
// If there is no elements means that is in cron
|
||||
// If there is no elements means that is in cron.
|
||||
if ($elem_cron === null || $elem_curr_time === null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Go to last element if current is a wild card
|
||||
// Go to last element if current is a wild card.
|
||||
if ($elem_cron != '*') {
|
||||
$elem_s = cron_get_interval($elem_cron);
|
||||
// Check if there is no a range
|
||||
|
@ -263,7 +282,7 @@ function cron_is_in_cron($elems_cron, $elems_curr_time)
|
|||
return false;
|
||||
}
|
||||
|
||||
// Check if there is on the range
|
||||
// Check if there is on the range.
|
||||
if ($elem_s['up'] !== false) {
|
||||
if ($elem_s['down'] < $elem_s['up']) {
|
||||
if ($elem_curr_time < $elem_s['down'] || $elem_curr_time > $elem_s['up']) {
|
||||
|
@ -283,14 +302,365 @@ function cron_is_in_cron($elems_cron, $elems_curr_time)
|
|||
|
||||
function cron_valid_date($da)
|
||||
{
|
||||
$st = sprintf('%04d:%02d:%02d %02d:%02d:00', $da[4], $da[3], $da[2], $da[1], $da[0]);
|
||||
$st = sprintf(
|
||||
'%04d:%02d:%02d %02d:%02d:00',
|
||||
$da[4],
|
||||
$da[3],
|
||||
$da[2],
|
||||
$da[1],
|
||||
$da[0]
|
||||
);
|
||||
$time = strtotime($st);
|
||||
return $time;
|
||||
}
|
||||
|
||||
|
||||
// Check if cron is properly constructed
|
||||
// Check if cron is properly constructed.
|
||||
function cron_check_syntax($cron)
|
||||
{
|
||||
return preg_match('/^[\d|\*].* .*[\d|\*].* .*[\d|\*].* .*[\d|\*].* .*[\d|\*]$/', $cron);
|
||||
return preg_match(
|
||||
'/^[\d|\*].* .*[\d|\*].* .*[\d|\*].* .*[\d|\*].* .*[\d|\*]$/',
|
||||
$cron
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function cron_list_table()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$read_perms = check_acl($config['id_user'], 0, 'RR');
|
||||
$write_perms = check_acl($config['id_user'], 0, 'RW');
|
||||
$manage_perms = check_acl($config['id_user'], 0, 'RM');
|
||||
$manage_pandora = check_acl($config['id_user'], 0, 'PM');
|
||||
|
||||
$url = 'index.php?extension_in_menu=gservers&sec=extensions&sec2=enterprise/extensions/cron&';
|
||||
|
||||
$user_groups = implode(
|
||||
',',
|
||||
array_keys(users_get_groups())
|
||||
);
|
||||
|
||||
$defined_tasks = db_get_all_rows_filter(
|
||||
'tuser_task_scheduled',
|
||||
'id_grupo IN ('.$user_groups.')'
|
||||
);
|
||||
|
||||
if (!check_acl($config['id_user'], 0, 'PM')) {
|
||||
$read_tasks = [];
|
||||
foreach ($defined_tasks as $task) {
|
||||
$function_name = db_get_value(
|
||||
'function_name',
|
||||
'tuser_task',
|
||||
'id',
|
||||
$task['id_user_task']
|
||||
);
|
||||
|
||||
if (($function_name != 'cron_task_execute_custom_script')
|
||||
&& ($function_name != 'cron_task_do_backup')
|
||||
) {
|
||||
$read_tasks[] = $task;
|
||||
}
|
||||
}
|
||||
|
||||
$defined_tasks = $read_tasks;
|
||||
|
||||
if (empty($defined_tasks)) {
|
||||
$defined_tasks = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($defined_tasks !== false) {
|
||||
echo '<h2>'.__('Scheduled jobs').'</h2>';
|
||||
|
||||
$table = new stdClass();
|
||||
$table->class = 'databox data';
|
||||
$table->width = '100%';
|
||||
$table->data = [];
|
||||
$table->head = [];
|
||||
$table->head[0] = '';
|
||||
$table->head[1] = __('User');
|
||||
$table->head[2] = __('Task');
|
||||
$table->head[3] = __('Scheduled');
|
||||
$table->head[4] = __('Next execution');
|
||||
$table->head[5] = __('Last run');
|
||||
$table->head[6] = __('Group');
|
||||
$table->head[7] = __('Actions');
|
||||
$table->align[7] = 'left';
|
||||
|
||||
foreach ($defined_tasks as $task) {
|
||||
$data = [];
|
||||
|
||||
$function_name = db_get_value(
|
||||
'function_name',
|
||||
'tuser_task',
|
||||
'id',
|
||||
$task['id_user_task']
|
||||
);
|
||||
|
||||
switch ($function_name) {
|
||||
case 'cron_task_generate_report':
|
||||
if ($write_perms || $manage_pandora) {
|
||||
$data[0] = '<a href="'.$url;
|
||||
$data[0] .= 'force_run=1&id_user_task='.$task['id'].'">';
|
||||
$data[0] .= html_print_image(
|
||||
'images/target.png',
|
||||
true,
|
||||
['title' => __('Force run')]
|
||||
);
|
||||
$data[0] .= '</a>';
|
||||
} else {
|
||||
$data[0] = '';
|
||||
}
|
||||
|
||||
$data[1] = $task['id_usuario'];
|
||||
$data[2] = db_get_value(
|
||||
'name',
|
||||
'tuser_task',
|
||||
'id',
|
||||
$task['id_user_task']
|
||||
);
|
||||
$args = unserialize($task['args']);
|
||||
$report = reports_get_report($args[0]);
|
||||
|
||||
// Check ACL in reports_get_report return false.
|
||||
if ($report === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$email = $args[1];
|
||||
$data[2] .= '<br>- '.__('Report').": <a href='index.php?sec=reporting&sec2=operation/reporting/reporting_viewer&id=".$args[0]."'>";
|
||||
$data[2] .= $report['name'].'</a>';
|
||||
$data[2] .= '<br>- '.__('Email').": <a href='mailto:".$email."'>";
|
||||
$data[2] .= ui_print_truncate_text($email, 60, false).'</a>';
|
||||
break;
|
||||
|
||||
case 'cron_task_generate_report_by_template':
|
||||
if ($write_perms || $manage_pandora) {
|
||||
$data[0] = '<a href="'.$url;
|
||||
$data[0] .= 'force_run=1&id_user_task='.$task['id'].'">';
|
||||
$data[0] .= html_print_image(
|
||||
'images/target.png',
|
||||
true,
|
||||
['title' => __('Force run')]
|
||||
);
|
||||
$data[0] .= '</a>';
|
||||
} else {
|
||||
$data[0] = '';
|
||||
}
|
||||
|
||||
$data[1] = $task['id_usuario'];
|
||||
$data[2] = db_get_value(
|
||||
'name',
|
||||
'tuser_task',
|
||||
'id',
|
||||
$task['id_user_task']
|
||||
);
|
||||
|
||||
$args = unserialize($task['args']);
|
||||
|
||||
$filter = [];
|
||||
$filter['id_report'] = $args[0];
|
||||
$template = db_get_row_filter(
|
||||
'treport_template',
|
||||
$filter,
|
||||
false
|
||||
);
|
||||
|
||||
// Check ACL in reports_get_report return false.
|
||||
if ($template === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$agents_id = $args[1];
|
||||
$id_group = $args[2];
|
||||
$report_per_agent = $args[0];
|
||||
$report_name = $args[3];
|
||||
$email = $args[4];
|
||||
$data[2] .= '<br>- '.__('Template').": <a href='index.php?sec=reporting&sec2=operation/reporting/reporting_viewer";
|
||||
$data[2] .= '&id='.$args[0]."'>".$template['name'].'</a>';
|
||||
$data[2] .= '<br>- '.__('Agents').': '.$agents_id.'</a>';
|
||||
$data[2] .= '<br>- '.__('Report per agent').': '.$report_per_agent.'</a>';
|
||||
$data[2] .= '<br>- '.__('Report name').': '.$report_name.'</a>';
|
||||
$data[2] .= '<br>- '.__('Email').": <a href='mailto:".$email."'>".$email.'</a>';
|
||||
break;
|
||||
|
||||
case 'cron_task_execute_custom_script':
|
||||
if ($manage_pandora) {
|
||||
$data[0] = '<a href="'.$url;
|
||||
$data[0] .= 'force_run=1&id_user_task='.$task['id'].'">';
|
||||
$data[0] .= html_print_image(
|
||||
'images/target.png',
|
||||
true,
|
||||
['title' => __('Force run')]
|
||||
);
|
||||
$data[0] .= '</a>';
|
||||
} else {
|
||||
$data[0] = '';
|
||||
}
|
||||
|
||||
$data[1] = $task['id_usuario'];
|
||||
$data[2] = db_get_value(
|
||||
'name',
|
||||
'tuser_task',
|
||||
'id',
|
||||
$task['id_user_task']
|
||||
);
|
||||
|
||||
$args = unserialize($task['args']);
|
||||
$data[2] .= '<br>- '.__('Custom script').': '.$args[0];
|
||||
break;
|
||||
|
||||
case 'cron_task_save_report_to_disk':
|
||||
if ($write_perms || $manage_pandora) {
|
||||
$data[0] = '<a href="'.$url;
|
||||
$data[0] .= 'force_run=1&id_user_task='.$task['id'].'">';
|
||||
$data[0] .= html_print_image(
|
||||
'images/target.png',
|
||||
true,
|
||||
['title' => __('Force run')]
|
||||
);
|
||||
$data[0] .= '</a>';
|
||||
} else {
|
||||
$data[0] = '';
|
||||
}
|
||||
|
||||
$data[1] = $task['id_usuario'];
|
||||
$data[2] = db_get_value(
|
||||
'name',
|
||||
'tuser_task',
|
||||
'id',
|
||||
$task['id_user_task']
|
||||
);
|
||||
|
||||
$args = unserialize($task['args']);
|
||||
$report = reports_get_report($args[0]);
|
||||
|
||||
// Check ACL in reports_get_report return false.
|
||||
if ($report === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$path = $args[1];
|
||||
$data[2] .= '<br>- '.__('Report').": <a href='index.php?sec=reporting&sec2=operation/reporting/reporting_viewer";
|
||||
$data[2] .= '&id='.$args[0]."'>".$report['name'].'</a>';
|
||||
$data[2] .= '<br>- '.__('Path').': '.$path.'</a>';
|
||||
break;
|
||||
|
||||
case 'cron_task_save_xml_report_to_disk':
|
||||
if ($write_perms || $manage_pandora) {
|
||||
$data[0] = '<a href="'.$url;
|
||||
$data[0] .= 'force_run=1&id_user_task='.$task['id'].'">';
|
||||
$data[0] .= html_print_image(
|
||||
'images/target.png',
|
||||
true,
|
||||
['title' => __('Force run')]
|
||||
);
|
||||
$data[0] .= '</a>';
|
||||
} else {
|
||||
$data[0] = '';
|
||||
}
|
||||
|
||||
$data[1] = $task['id_usuario'];
|
||||
$data[2] = db_get_value('name', 'tuser_task', 'id', $task['id_user_task']);
|
||||
$args = unserialize($task['args']);
|
||||
$report = reports_get_report($args[0]);
|
||||
|
||||
// Check ACL in reports_get_report return false.
|
||||
if ($report === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$path = $args[1];
|
||||
$data[2] .= '<br>- '.__('Report').": <a href='index.php?sec=reporting&sec2=operation/reporting/reporting_viewer";
|
||||
$data[2] .= '&id='.$args[0]."'>".$report['name'].'</a>';
|
||||
$data[2] .= '<br>- '.__('Path').': '.$path.'</a>';
|
||||
break;
|
||||
|
||||
case 'cron_task_do_backup':
|
||||
if ($manage_pandora) {
|
||||
$data[0] = '<a href="'.$url;
|
||||
$data[0] .= 'force_run=1&id_user_task='.$task['id'].'">';
|
||||
$data[0] .= html_print_image(
|
||||
'images/target.png',
|
||||
true,
|
||||
['title' => __('Force run')]
|
||||
);
|
||||
$data[0] .= '</a>';
|
||||
} else {
|
||||
$data[0] = '';
|
||||
}
|
||||
|
||||
$data[1] = $task['id_usuario'];
|
||||
$data[2] = db_get_value(
|
||||
'name',
|
||||
'tuser_task',
|
||||
'id',
|
||||
$task['id_user_task']
|
||||
);
|
||||
$args = unserialize($task['args']);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Ignore.
|
||||
break;
|
||||
}
|
||||
|
||||
$data[3] = cron_get_scheduled_string($task['scheduled']);
|
||||
$data[4] = date('Y/m/d H:i:s', $args['first_execution']);
|
||||
$data[5] = empty($task['last_run']) ? __('Never') : date('Y/m/d H:i:s', $task['last_run']);
|
||||
|
||||
$data[6] = ui_print_group_icon($task['id_grupo'], true);
|
||||
|
||||
if ($function_name == 'cron_task_do_backup' || $function_name == 'cron_task_execute_custom_script') {
|
||||
if ($manage_pandora) {
|
||||
$data[7] = '<a href="'.$url;
|
||||
$data[7] .= 'edit_task=1&id='.$task['id'].'">';
|
||||
$data[7] .= html_print_image(
|
||||
'images/config.png',
|
||||
true,
|
||||
['title' => __('Edit')]
|
||||
);
|
||||
$data[7] .= '</a>';
|
||||
}
|
||||
|
||||
if ($manage_pandora) {
|
||||
$data[7] .= '<a href="'.$url;
|
||||
$data[7] .= 'delete_task=1&id_user_task='.$task['id'].'">';
|
||||
$data[7] .= html_print_image(
|
||||
'images/cross.png',
|
||||
true,
|
||||
['title' => __('Delete')]
|
||||
);
|
||||
$data[7] .= '</a>';
|
||||
}
|
||||
} else {
|
||||
if ($write_perms || $manage_pandora) {
|
||||
$data[7] = '<a href="'.$url;
|
||||
$data[7] .= 'edit_task=1&id='.$task['id'].'">';
|
||||
$data[7] .= html_print_image(
|
||||
'images/config.png',
|
||||
true,
|
||||
['title' => __('Edit')]
|
||||
);
|
||||
$data[7] .= '</a>';
|
||||
}
|
||||
|
||||
if ($manage_perms || $manage_pandora) {
|
||||
$data[7] .= '<a href="'.$url;
|
||||
$data[7] .= 'delete_task=1&id_user_task='.$task['id'].'">';
|
||||
$data[7] .= html_print_image(
|
||||
'images/cross.png',
|
||||
true,
|
||||
['title' => __('Delete')]
|
||||
);
|
||||
$data[7] .= '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
array_push($table->data, $data);
|
||||
}
|
||||
|
||||
html_print_table($table);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -178,7 +178,8 @@ function extensions_get_extensions($enterprise=false, $rel_path='')
|
|||
function extensions_is_enabled_extension($name)
|
||||
{
|
||||
global $config;
|
||||
return isset($config['extensions'][$name]);
|
||||
return isset($config['extensions'][$name])
|
||||
|| isset($config['extensions'][$name.'.php']);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -549,12 +549,6 @@ function grafico_modulo_sparse($params)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!isset($params['agent_module_id'])) {
|
||||
return false;
|
||||
} else {
|
||||
$agent_module_id = $params['agent_module_id'];
|
||||
}
|
||||
|
||||
if (!isset($params['period'])) {
|
||||
return false;
|
||||
}
|
||||
|
@ -710,6 +704,12 @@ function grafico_modulo_sparse($params)
|
|||
$params['projection'] = false;
|
||||
}
|
||||
|
||||
if (!isset($params['agent_module_id'])) {
|
||||
return graph_nodata_image($params['width'], $params['height']);
|
||||
} else {
|
||||
$agent_module_id = $params['agent_module_id'];
|
||||
}
|
||||
|
||||
// XXXX Configurable
|
||||
$params['grid_color'] = '#C1C1C1';
|
||||
$params['legend_color'] = '#636363';
|
||||
|
@ -1318,6 +1318,10 @@ function graphic_combined_module(
|
|||
$array_data = [];
|
||||
|
||||
foreach ($module_list as $key => $agent_module_id) {
|
||||
if ((bool) $agent_module_id === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_metaconsole() && $params_combined['type_report'] == 'automatic_graph') {
|
||||
$server = metaconsole_get_connection_by_id($agent_module_id['server']);
|
||||
if (metaconsole_connect($server) != NOERR) {
|
||||
|
@ -1394,6 +1398,15 @@ function graphic_combined_module(
|
|||
}
|
||||
}
|
||||
|
||||
if (empty($array_data)) {
|
||||
if ($params_combined['return']) {
|
||||
return graph_nodata_image($width, $height);
|
||||
}
|
||||
|
||||
echo graph_nodata_image($width, $height);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($params_combined['projection']) {
|
||||
// If projection doesn't have data then don't draw graph
|
||||
if ($output_projection != null) {
|
||||
|
|
|
@ -1822,35 +1822,35 @@ function html_get_predefined_table($model='transparent', $columns=4)
|
|||
* Print a nicely formatted table. Code taken from moodle.
|
||||
*
|
||||
* @param object Object with several properties:
|
||||
* $table->head - An array of heading names.
|
||||
* $table->head_colspan - An array of colspans of each head column.
|
||||
* $table->headstyle - An array of styles of each head column.
|
||||
* $table->align - An array of column alignments
|
||||
* $table->valign - An array of column alignments
|
||||
* $table->size - An array of column sizes
|
||||
* $table->wrap - An array of "nowrap"s or nothing
|
||||
* $table->style - An array of personalized style for each column.
|
||||
* $table->rowid - An array of personalized ids of each row.
|
||||
* $table->rowstyle - An array of personalized style of each row.
|
||||
* $table->rowclass - An array of personalized classes of each row (odd-evens classes will be ignored).
|
||||
* $table->colspan - An array of colspans of each column.
|
||||
* $table->rowspan - An array of rowspans of each column.
|
||||
* $table->data[] - An array of arrays containing the data.
|
||||
* $table->width - A percentage of the page
|
||||
* $table->border - Border of the table.
|
||||
* $table->tablealign - Align the whole table (float left or right)
|
||||
* $table->cellpadding - Padding on each cell
|
||||
* $table->cellspacing - Spacing between cells
|
||||
* $table->cellstyle - Style of a cell
|
||||
* $table->cellclass - Class of a cell
|
||||
* $table->class - CSS table class
|
||||
* $table->id - Table ID (useful in JavaScript)
|
||||
* $table->headclass[] - An array of classes for each heading
|
||||
* $table->title - Title of the table is a single string that will be on top of the table in the head spanning the whole table
|
||||
* $table->titlestyle - Title style
|
||||
* $table->titleclass - Title class
|
||||
* $table->styleTable - Table style
|
||||
* $table->caption - Table title
|
||||
* $table->head - An array of heading names.
|
||||
* $table->head_colspan - An array of colspans of each head column.
|
||||
* $table->headstyle - An array of styles of each head column.
|
||||
* $table->align - An array of column alignments
|
||||
* $table->valign - An array of column alignments
|
||||
* $table->size - An array of column sizes
|
||||
* $table->wrap - An array of "nowrap"s or nothing
|
||||
* $table->style - An array of personalized style for each column.
|
||||
* $table->rowid - An array of personalized ids of each row.
|
||||
* $table->rowstyle - An array of personalized style of each row.
|
||||
* $table->rowclass - An array of personalized classes of each row (odd-evens classes will be ignored).
|
||||
* $table->colspan - An array of colspans of each column.
|
||||
* $table->rowspan - An array of rowspans of each column.
|
||||
* $table->data[] - An array of arrays containing the data.
|
||||
* $table->width - A percentage of the page
|
||||
* $table->border - Border of the table.
|
||||
* $table->tablealign - Align the whole table (float left or right)
|
||||
* $table->cellpadding - Padding on each cell
|
||||
* $table->cellspacing - Spacing between cells
|
||||
* $table->cellstyle - Style of a cell
|
||||
* $table->cellclass - Class of a cell
|
||||
* $table->class - CSS table class
|
||||
* $table->id - Table ID (useful in JavaScript)
|
||||
* $table->headclass[] - An array of classes for each heading
|
||||
* $table->title - Title of the table is a single string that will be on top of the table in the head spanning the whole table
|
||||
* $table->titlestyle - Title style
|
||||
* $table->titleclass - Title class
|
||||
* $table->styleTable - Table style
|
||||
* $table->caption - Table title
|
||||
* @param bool Whether to return an output string or echo now
|
||||
*
|
||||
* @return string HTML code if return parameter is true.
|
||||
|
@ -2257,7 +2257,7 @@ function html_print_checkbox_extended($name, $value, $checked, $disabled, $scrip
|
|||
if ($id == '') {
|
||||
$output .= ' id="checkbox-'.$id_aux.'"';
|
||||
} else {
|
||||
$output .= ' id='.$id;
|
||||
$output .= ' '.$id.'"';
|
||||
}
|
||||
|
||||
if ($script != '') {
|
||||
|
|
|
@ -1,55 +1,150 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2009 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 Lesser General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
/**
|
||||
* @package Include
|
||||
* @subpackage Messages
|
||||
* Extension to manage a list of gateways and the node address where they should
|
||||
* point to.
|
||||
*
|
||||
* @category Extensions
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
require_once $config['homedir'].'/include/functions_users.php';
|
||||
require_once $config['homedir'].'/include/functions_groups.php';
|
||||
require_once $config['homedir'].'/include/functions_notifications.php';
|
||||
|
||||
|
||||
/**
|
||||
* Set targets for given messaje
|
||||
*
|
||||
* @param integer $message_id Message id.
|
||||
* @param array $users An array with all target users.
|
||||
* @param array $groups An array with all target groups.
|
||||
*
|
||||
* @return boolean Task status.
|
||||
*/
|
||||
function message_set_targets(
|
||||
int $message_id,
|
||||
array $users=null,
|
||||
array $groups=null
|
||||
) {
|
||||
if (empty($message_id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_array($users)) {
|
||||
$values = [];
|
||||
foreach ($users as $user) {
|
||||
if (empty($user)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$values['id_mensaje'] = $message_id;
|
||||
$values['id_user'] = $user;
|
||||
}
|
||||
|
||||
if (!empty($values)) {
|
||||
$ret = db_process_sql_insert('tnotification_user', $values);
|
||||
if ($ret === false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($groups)) {
|
||||
$values = [];
|
||||
foreach ($groups as $group) {
|
||||
if ($group != 0 && empty($group)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$values['id_mensaje'] = $message_id;
|
||||
$values['id_group'] = $group;
|
||||
}
|
||||
|
||||
if (!empty($values)) {
|
||||
$ret = db_process_sql_insert('tnotification_group', $values);
|
||||
if ($ret === false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a private message to be forwarded to other people
|
||||
*
|
||||
* @param string $usuario_origen The sender of the message
|
||||
* @param string $usuario_destino The receiver of the message
|
||||
* @param string $subject Subject of the message (much like E-Mail)
|
||||
* @param string $mensaje The actual message. This message will be cleaned by io_safe_input
|
||||
* (html is allowed but loose html chars will be translated)
|
||||
* @param string $usuario_origen The sender of the message.
|
||||
* @param array $target_users The receiver of the message.
|
||||
* @param array $target_groups Target groups to be delivered.
|
||||
* @param string $subject Subject of the message (much like E-Mail).
|
||||
* @param string $mensaje The actual message. This message will be
|
||||
* cleaned by io_safe_input (html is allowed but
|
||||
* loose html chars will be translated).
|
||||
*
|
||||
* @return boolean true when delivered, false in case of error
|
||||
*/
|
||||
function messages_create_message($usuario_origen, $usuario_destino, $subject, $mensaje)
|
||||
{
|
||||
function messages_create_message(
|
||||
string $usuario_origen,
|
||||
array $target_users,
|
||||
array $target_groups,
|
||||
string $subject,
|
||||
string $mensaje
|
||||
) {
|
||||
$users = users_get_info();
|
||||
|
||||
if (!array_key_exists($usuario_origen, $users) || !array_key_exists($usuario_destino, $users)) {
|
||||
return false;
|
||||
// Users don't exist so don't send to them
|
||||
// Create message.
|
||||
$message_id = db_process_sql_insert(
|
||||
'tmensajes',
|
||||
[
|
||||
'id_usuario_origen' => $usuario_origen,
|
||||
'subject' => $subject,
|
||||
'mensaje' => $mensaje,
|
||||
'id_source' => get_notification_source_id('message'),
|
||||
'timestamp' => get_system_time(),
|
||||
]
|
||||
);
|
||||
|
||||
// Update URL
|
||||
// Update targets.
|
||||
if ($message_id !== false) {
|
||||
$ret = message_set_targets(
|
||||
$message_id,
|
||||
$target_users,
|
||||
$target_groups
|
||||
);
|
||||
if ($ret === false) {
|
||||
// Failed to deliver messages. Erase message and show error.
|
||||
db_process_sql_delete(
|
||||
'tmensajes',
|
||||
['id_mensaje' => $message_id]
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$values = [];
|
||||
$values['id_usuario_origen'] = $usuario_origen;
|
||||
$values['id_usuario_destino'] = $usuario_destino;
|
||||
$values['subject'] = $subject;
|
||||
$values['mensaje'] = $mensaje;
|
||||
$values['timestamp'] = get_system_time();
|
||||
|
||||
$return = db_process_sql_insert('tmensajes', $values);
|
||||
|
||||
if ($return === false) {
|
||||
return false;
|
||||
} else {
|
||||
|
@ -58,108 +153,133 @@ function messages_create_message($usuario_origen, $usuario_destino, $subject, $m
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates private messages to be forwarded to groups
|
||||
*
|
||||
* @param string The sender of the message
|
||||
* @param string The receivers (group) of the message
|
||||
* @param string Subject of the message (much like E-Mail)
|
||||
* @param string The actual message. This message will be cleaned by io_safe_input
|
||||
* (html is allowed but loose html chars will be translated)
|
||||
*
|
||||
* @return boolean true when delivered, false in case of error
|
||||
*/
|
||||
function messages_create_group($usuario_origen, $dest_group, $subject, $mensaje)
|
||||
{
|
||||
$users = users_get_info();
|
||||
$group_users = groups_get_users($dest_group);
|
||||
|
||||
if (! array_key_exists($usuario_origen, $users)) {
|
||||
// Users don't exist in the system
|
||||
return false;
|
||||
} else if (empty($group_users)) {
|
||||
// There are no users in the group, so it hasn't failed although it hasn't done anything.
|
||||
return true;
|
||||
}
|
||||
|
||||
// array unique
|
||||
foreach ($group_users as $user) {
|
||||
foreach ($user as $key => $us) {
|
||||
if ($key == 'id_user') {
|
||||
$group_user[$us] = $us;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($group_user as $user) {
|
||||
$return = messages_create_message($usuario_origen, get_user_id($user), $subject, $mensaje);
|
||||
if ($return === false) {
|
||||
// Error sending message
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deletes a private message
|
||||
*
|
||||
* @param integer $id_message
|
||||
* @param integer $id_message Message to be deleted.
|
||||
*
|
||||
* @return boolean true when deleted, false in case of error
|
||||
*/
|
||||
function messages_delete_message($id_message)
|
||||
function messages_delete_message(int $id_message)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$where = [
|
||||
// 'id_usuario_destino' => $config["id_user"],
|
||||
'id_mensaje' => $id_message,
|
||||
];
|
||||
return (bool) db_process_sql_delete('tmensajes', $where);
|
||||
// Check if user has grants to access the message.
|
||||
if (check_notification_readable($id_message) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$utimestamp = time();
|
||||
|
||||
$ret = db_process_sql_update(
|
||||
'tnotification_user',
|
||||
['utimestamp_erased' => $utimestamp],
|
||||
[
|
||||
'id_mensaje' => $id_message,
|
||||
'id_user' => $config['id_user'],
|
||||
]
|
||||
);
|
||||
|
||||
if ($ret === 0) {
|
||||
// No previous updates.
|
||||
// Message available to user due group assignment.
|
||||
$ret = db_process_sql_insert(
|
||||
'tnotification_user',
|
||||
[
|
||||
'id_mensaje' => $id_message,
|
||||
'id_user' => $config['id_user'],
|
||||
'utimestamp_erased' => $utimestamp,
|
||||
]
|
||||
);
|
||||
|
||||
// Quick fix. Insertions returns 0.
|
||||
if ($ret !== false) {
|
||||
$ret = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return (bool) $ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Marks a private message as read/unread
|
||||
*
|
||||
* @param integer $message_id The message to modify
|
||||
* @param boolean $read To set unread pass 0, false or empty value
|
||||
* @param integer $message_id The message to modify.
|
||||
* @param boolean $read To set unread pass 0, false or empty value.
|
||||
*
|
||||
* @return boolean true when marked, false in case of error
|
||||
*/
|
||||
function messages_process_read($message_id, $read=true)
|
||||
{
|
||||
if (empty($read)) {
|
||||
$read = 0;
|
||||
} else {
|
||||
$read = 1;
|
||||
function messages_process_read(
|
||||
int $message_id,
|
||||
bool $read=true
|
||||
) {
|
||||
global $config;
|
||||
// Check if user has grants to read the message.
|
||||
if (check_notification_readable($message_id) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (bool) db_process_sql_update('tmensajes', ['estado' => $read], ['id_mensaje' => $message_id]);
|
||||
if (empty($read)) {
|
||||
// Mark as unread.
|
||||
$utimestamp = null;
|
||||
} else {
|
||||
// Mark as read.
|
||||
$utimestamp = time();
|
||||
}
|
||||
|
||||
$ret = db_process_sql_update(
|
||||
'tnotification_user',
|
||||
['utimestamp_read' => $utimestamp],
|
||||
[
|
||||
'id_mensaje' => $message_id,
|
||||
'id_user' => $config['id_user'],
|
||||
'utimestamp_read' => null,
|
||||
]
|
||||
);
|
||||
|
||||
if ($ret === 0) {
|
||||
// No previous updates.
|
||||
// Message available to user due group assignment.
|
||||
$ret = db_process_sql_insert(
|
||||
'tnotification_user',
|
||||
[
|
||||
'id_mensaje' => $message_id,
|
||||
'id_user' => $config['id_user'],
|
||||
'utimestamp_read' => $utimestamp,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
return (bool) $ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets a private message
|
||||
*
|
||||
* This function abstracts the database backend so it can simply be replaced with another system
|
||||
* This function abstracts the database backend so it can simply be
|
||||
* replaced with another system
|
||||
*
|
||||
* @param integer $message_id
|
||||
* @param integer $message_id Message to be retrieved.
|
||||
*
|
||||
* @return mixed False if it doesn't exist or a filled array otherwise
|
||||
*/
|
||||
function messages_get_message($message_id)
|
||||
function messages_get_message(int $message_id)
|
||||
{
|
||||
global $config;
|
||||
|
||||
// Check if user has grants to read the message.
|
||||
if (check_notification_readable($message_id) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
"SELECT id_usuario_origen, id_usuario_destino, subject, mensaje, timestamp
|
||||
FROM tmensajes
|
||||
WHERE id_usuario_destino='%s' AND id_mensaje=%d",
|
||||
$config['id_user'],
|
||||
'SELECT *, nu.utimestamp_read > 0 as "read"
|
||||
FROM tmensajes tm
|
||||
LEFT JOIN tnotification_user nu
|
||||
ON nu.id_mensaje = tm.id_mensaje
|
||||
WHERE tm.id_mensaje=%d',
|
||||
$message_id
|
||||
);
|
||||
$row = db_get_row_sql($sql);
|
||||
|
@ -168,6 +288,8 @@ function messages_get_message($message_id)
|
|||
return false;
|
||||
}
|
||||
|
||||
$row['id_usuario_destino'] = $config['id_user'];
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
|
@ -175,20 +297,21 @@ function messages_get_message($message_id)
|
|||
/**
|
||||
* Gets a sent message
|
||||
*
|
||||
* This function abstracts the database backend so it can simply be replaced with another system
|
||||
* This function abstracts the database backend so it can simply be
|
||||
* replaced with another system
|
||||
*
|
||||
* @param integer $message_id
|
||||
* @param integer $message_id Message to be retrieved.
|
||||
*
|
||||
* @return mixed False if it doesn't exist or a filled array otherwise
|
||||
*/
|
||||
function messages_get_message_sent($message_id)
|
||||
function messages_get_message_sent(int $message_id)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$sql = sprintf(
|
||||
"SELECT id_usuario_origen, id_usuario_destino, subject, mensaje, timestamp
|
||||
FROM tmensajes
|
||||
WHERE id_usuario_origen='%s' AND id_mensaje=%d",
|
||||
"SELECT id_usuario_origen, subject, mensaje, timestamp
|
||||
FROM tmensajes
|
||||
WHERE id_usuario_origen='%s' AND id_mensaje=%d",
|
||||
$config['id_user'],
|
||||
$message_id
|
||||
);
|
||||
|
@ -198,6 +321,16 @@ function messages_get_message_sent($message_id)
|
|||
return false;
|
||||
}
|
||||
|
||||
$targets = get_notification_targets($message_id);
|
||||
|
||||
$row['id_usuario_destino'] = implode(
|
||||
',',
|
||||
$targets['users']
|
||||
).','.implode(
|
||||
',',
|
||||
$targets['groups']
|
||||
);
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
|
@ -205,29 +338,77 @@ function messages_get_message_sent($message_id)
|
|||
/**
|
||||
* Counts private messages
|
||||
*
|
||||
* @param string $user
|
||||
* @param boolean $incl_read Whether or not to include read messages
|
||||
* @param string $user Target user.
|
||||
* @param boolean $incl_read Whether or not to include read messages.
|
||||
* @param boolean $ignore_source Ignore source.
|
||||
*
|
||||
* @return integer The number of messages this user has
|
||||
*/
|
||||
function messages_get_count($user=false, $incl_read=false)
|
||||
{
|
||||
function messages_get_count(
|
||||
string $user='',
|
||||
bool $incl_read=false,
|
||||
bool $ignore_source=false
|
||||
) {
|
||||
if (empty($user)) {
|
||||
global $config;
|
||||
$user = $config['id_user'];
|
||||
}
|
||||
|
||||
if (empty($incl_read)) {
|
||||
$filter = 'AND estado = 0';
|
||||
if (!empty($incl_read)) {
|
||||
// Do not filter.
|
||||
$read = ' 1=1 ';
|
||||
} else {
|
||||
$filter = '';
|
||||
// Retrieve only unread messages.
|
||||
$read = ' t.read is null';
|
||||
}
|
||||
|
||||
if ($ignore_source === true) {
|
||||
$source_select = '';
|
||||
$source_sql = '';
|
||||
$source_extra = '';
|
||||
} else {
|
||||
$source_select = ',IF(ns.user_editable,nsu.enabled,ns.enabled) as enabled';
|
||||
|
||||
// Row in tnotification_source_user could exist or not.
|
||||
$source_sql = sprintf(
|
||||
'INNER JOIN (
|
||||
tnotification_source ns
|
||||
LEFT JOIN tnotification_source_user nsu
|
||||
ON ns.id=nsu.id_source
|
||||
AND nsu.id_user="%s")
|
||||
ON tm.id_source=ns.id',
|
||||
$user
|
||||
);
|
||||
$source_extra = 'AND (t.enabled=1 OR t.enabled is null)';
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
"SELECT COUNT(*)
|
||||
FROM tmensajes WHERE id_usuario_destino='%s' %s",
|
||||
'SELECT count(*) as "n" FROM (
|
||||
SELECT
|
||||
tm.*,
|
||||
utimestamp_read > 0 as "read"
|
||||
%s
|
||||
FROM tmensajes tm
|
||||
%s
|
||||
LEFT JOIN tnotification_user nu
|
||||
ON tm.id_mensaje=nu.id_mensaje
|
||||
AND nu.id_user="%s"
|
||||
LEFT JOIN (tnotification_group ng
|
||||
INNER JOIN tusuario_perfil up
|
||||
ON ng.id_group=up.id_grupo
|
||||
AND up.id_grupo=ng.id_group)
|
||||
ON tm.id_mensaje=ng.id_mensaje
|
||||
WHERE utimestamp_erased is null
|
||||
AND (nu.id_user="%s" OR up.id_usuario="%s" OR ng.id_group=0)
|
||||
) t
|
||||
WHERE %s %s',
|
||||
$source_select,
|
||||
$source_sql,
|
||||
$user,
|
||||
$filter
|
||||
$user,
|
||||
$user,
|
||||
$read,
|
||||
$source_extra
|
||||
);
|
||||
|
||||
return (int) db_get_sql($sql);
|
||||
|
@ -235,13 +416,13 @@ function messages_get_count($user=false, $incl_read=false)
|
|||
|
||||
|
||||
/**
|
||||
* Counts sended messages
|
||||
* Counts messages sent.
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $user Target user.
|
||||
*
|
||||
* @return integer The number of messages this user has sent
|
||||
*/
|
||||
function messages_get_count_sent($user=false)
|
||||
function messages_get_count_sent(string $user='')
|
||||
{
|
||||
if (empty($user)) {
|
||||
global $config;
|
||||
|
@ -250,7 +431,7 @@ function messages_get_count_sent($user=false)
|
|||
|
||||
$sql = sprintf(
|
||||
"SELECT COUNT(*)
|
||||
FROM tmensajes WHERE id_usuario_origen='%s'",
|
||||
FROM tmensajes WHERE id_usuario_origen='%s'",
|
||||
$user
|
||||
);
|
||||
|
||||
|
@ -261,20 +442,34 @@ function messages_get_count_sent($user=false)
|
|||
/**
|
||||
* Get message overview in array
|
||||
*
|
||||
* @param string $order How to order them valid:
|
||||
* (status (default), subject, timestamp, sender)
|
||||
* @param string $order_dir Direction of order (ASC = Ascending, DESC = Descending)
|
||||
* @param string $order How to order them valid:
|
||||
* (status (default), subject, timestamp, sender).
|
||||
* @param string $order_dir Direction of order
|
||||
* (ASC = Ascending, DESC = Descending).
|
||||
* @param boolean $incl_read Include read messages in return.
|
||||
* @param boolean $incl_source_info Include source info.
|
||||
* @param integer $limit Maximum number of result in the query.
|
||||
* @param array $other_filter Add a filter on main query.
|
||||
*
|
||||
* @return integer The number of messages this user has
|
||||
*/
|
||||
function messages_get_overview($order='status', $order_dir='ASC')
|
||||
{
|
||||
function messages_get_overview(
|
||||
string $order='status',
|
||||
string $order_dir='ASC',
|
||||
bool $incl_read=true,
|
||||
bool $incl_source_info=false,
|
||||
int $limit=0,
|
||||
array $other_filter=[]
|
||||
) {
|
||||
global $config;
|
||||
|
||||
switch ($order) {
|
||||
case 'timestamp':
|
||||
case 'sender':
|
||||
case 'subject':
|
||||
case 'timestamp':{
|
||||
}
|
||||
case 'sender':{
|
||||
}
|
||||
case 'subject':{
|
||||
}
|
||||
break;
|
||||
|
||||
case 'status':
|
||||
|
@ -287,21 +482,59 @@ function messages_get_overview($order='status', $order_dir='ASC')
|
|||
$order .= ' DESC';
|
||||
}
|
||||
|
||||
$result = [];
|
||||
$return = db_get_all_rows_field_filter('tmensajes', 'id_usuario_destino', $config['id_user'], $order);
|
||||
|
||||
if ($return === false) {
|
||||
return $result;
|
||||
if (!empty($incl_read)) {
|
||||
// Do not filter.
|
||||
$read = '';
|
||||
} else {
|
||||
// Retrieve only unread messages.
|
||||
$read = 'where t.read is null';
|
||||
}
|
||||
|
||||
foreach ($return as $message) {
|
||||
$result[$message['id_mensaje']]['sender'] = $message['id_usuario_origen'];
|
||||
$result[$message['id_mensaje']]['subject'] = $message['subject'];
|
||||
$result[$message['id_mensaje']]['timestamp'] = $message['timestamp'];
|
||||
$result[$message['id_mensaje']]['status'] = $message['estado'];
|
||||
$source_fields = '';
|
||||
$source_join = '';
|
||||
if ($incl_source_info) {
|
||||
$source_fields = ', tns.*';
|
||||
$source_join = 'INNER JOIN tnotification_source tns
|
||||
ON tns.id=tm.id_source
|
||||
INNER JOIN tnotification_source_user nsu
|
||||
ON nsu.id_source=tns.id
|
||||
AND nsu.enabled = 1
|
||||
OR tns.enabled = 1';
|
||||
}
|
||||
|
||||
return $result;
|
||||
// Using distinct because could be double assignment due group/user.
|
||||
$sql = sprintf(
|
||||
'SELECT * FROM (
|
||||
SELECT DISTINCT tm.*, utimestamp_read > 0 as "read" %s
|
||||
FROM tmensajes tm
|
||||
LEFT JOIN tnotification_user nu
|
||||
ON tm.id_mensaje=nu.id_mensaje
|
||||
AND nu.id_user="%s"
|
||||
LEFT JOIN (tnotification_group ng
|
||||
INNER JOIN tusuario_perfil up
|
||||
ON ng.id_group=up.id_grupo
|
||||
AND up.id_grupo=ng.id_group
|
||||
) ON tm.id_mensaje=ng.id_mensaje
|
||||
%s
|
||||
WHERE utimestamp_erased is null
|
||||
AND (nu.id_user="%s" OR up.id_usuario="%s" OR ng.id_group=0)
|
||||
) t
|
||||
%s
|
||||
%s
|
||||
ORDER BY %s
|
||||
%s',
|
||||
$source_fields,
|
||||
$config['id_user'],
|
||||
$source_join,
|
||||
$config['id_user'],
|
||||
$config['id_user'],
|
||||
$read,
|
||||
db_format_array_where_clause_sql($other_filter, 'AND', ' AND '),
|
||||
$order,
|
||||
($limit !== 0) ? ' LIMIT '.$limit : ''
|
||||
);
|
||||
|
||||
return db_get_all_rows_sql($sql);
|
||||
}
|
||||
|
||||
|
||||
|
@ -309,19 +542,25 @@ function messages_get_overview($order='status', $order_dir='ASC')
|
|||
* Get sent message overview in array
|
||||
*
|
||||
* @param string $order How to order them valid:
|
||||
* (status (default), subject, timestamp, sender)
|
||||
* @param string $order_dir Direction of order (ASC = Ascending, DESC = Descending)
|
||||
* (status (default), subject, timestamp, sender).
|
||||
* @param string $order_dir Direction of order
|
||||
* (ASC = Ascending, DESC = Descending).
|
||||
*
|
||||
* @return integer The number of messages this user has
|
||||
*/
|
||||
function messages_get_overview_sent($order='timestamp', $order_dir='ASC')
|
||||
{
|
||||
function messages_get_overview_sent(
|
||||
string $order='timestamp',
|
||||
string $order_dir='ASC'
|
||||
) {
|
||||
global $config;
|
||||
|
||||
switch ($order) {
|
||||
case 'timestamp':
|
||||
case 'sender':
|
||||
case 'subject':
|
||||
case 'timestamp':{
|
||||
}
|
||||
case 'sender':{
|
||||
}
|
||||
case 'subject':{
|
||||
}
|
||||
break;
|
||||
|
||||
case 'status':
|
||||
|
@ -334,19 +573,35 @@ function messages_get_overview_sent($order='timestamp', $order_dir='ASC')
|
|||
$order .= ' DESC';
|
||||
}
|
||||
|
||||
$result = [];
|
||||
$return = db_get_all_rows_field_filter('tmensajes', 'id_usuario_origen', $config['id_user'], $order);
|
||||
|
||||
if ($return === false) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
foreach ($return as $message) {
|
||||
$result[$message['id_mensaje']]['dest'] = $message['id_usuario_destino'];
|
||||
$result[$message['id_mensaje']]['subject'] = $message['subject'];
|
||||
$result[$message['id_mensaje']]['timestamp'] = $message['timestamp'];
|
||||
$result[$message['id_mensaje']]['status'] = $message['estado'];
|
||||
}
|
||||
|
||||
return $result;
|
||||
return db_get_all_rows_field_filter(
|
||||
'tmensajes',
|
||||
'id_usuario_origen',
|
||||
$config['id_user'],
|
||||
$order
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the URL of a message. If field in db is null, it returs a link to
|
||||
* messages view.
|
||||
*
|
||||
* @param integer $message_id Message id to get URL.
|
||||
*
|
||||
* @return mixed False if fails. A string with URL otherwise.
|
||||
*/
|
||||
function messages_get_url($message_id)
|
||||
{
|
||||
$messages = messages_get_message($message_id);
|
||||
if ($messages === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Return URL stored if is set in database.
|
||||
if (isset($messages['url'])) {
|
||||
return $messages['url'];
|
||||
}
|
||||
|
||||
// Return the message direction.
|
||||
return ui_get_full_url('index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&id_message='.$message_id);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,999 @@
|
|||
<?php
|
||||
/**
|
||||
* Library. Notification system auxiliary functions.
|
||||
*
|
||||
* @category Library
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
require_once $config['homedir'].'/include/functions_messages.php';
|
||||
|
||||
define('NOTIFICATIONS_POSTPONE_FOREVER', -1);
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves source ID for given source.
|
||||
*
|
||||
* @param string $source Source.
|
||||
*
|
||||
* @return integer source's id.
|
||||
*/
|
||||
function get_notification_source_id(string $source)
|
||||
{
|
||||
if (empty($source) === true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return db_get_value_sql(
|
||||
sprintf(
|
||||
'SELECT id
|
||||
FROM `tnotification_source`
|
||||
WHERE lower(`description`) = lower("%s")',
|
||||
$source
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve all targets for given message.
|
||||
*
|
||||
* @param integer $id_message Message id.
|
||||
*
|
||||
* @return array of users and groups target of this message.
|
||||
*/
|
||||
function get_notification_targets(int $id_message)
|
||||
{
|
||||
$targets = [
|
||||
'users' => [],
|
||||
'groups' => [],
|
||||
];
|
||||
|
||||
if (empty($id_message)) {
|
||||
return $targets;
|
||||
}
|
||||
|
||||
$ret = db_get_all_rows_sql(
|
||||
sprintf(
|
||||
'SELECT id_user
|
||||
FROM tnotification_user nu
|
||||
WHERE nu.id_mensaje = %d',
|
||||
$id_message
|
||||
)
|
||||
);
|
||||
|
||||
if (is_array($ret)) {
|
||||
foreach ($ret as $row) {
|
||||
array_push(
|
||||
$targets['users'],
|
||||
get_user_fullname($row['id_user'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$ret = db_get_all_rows_sql(
|
||||
sprintf(
|
||||
'SELECT COALESCE(tg.nombre,ng.id_group) as "id_group"
|
||||
FROM tnotification_group ng
|
||||
LEFT JOIN tgrupo tg
|
||||
ON tg.id_grupo=ng.id_group
|
||||
WHERE ng.id_mensaje = %d',
|
||||
$id_message
|
||||
)
|
||||
);
|
||||
|
||||
if (is_array($ret)) {
|
||||
foreach ($ret as $row) {
|
||||
if ($row['id_group'] == '0') {
|
||||
$row['id_group'] = '<b>'.__('All').'</b>';
|
||||
}
|
||||
|
||||
array_push($targets['groups'], $row['id_group']);
|
||||
}
|
||||
}
|
||||
|
||||
return $targets;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if current user has grants to read this notification
|
||||
*
|
||||
* @param integer $id_message Target message.
|
||||
*
|
||||
* @return boolean true, read available. False if not.
|
||||
*/
|
||||
function check_notification_readable(int $id_message)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (empty($id_message)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Using distinct to avoid double response on group messages read by user.
|
||||
$sql = sprintf(
|
||||
'SELECT DISTINCT tm.*, utimestamp_read > 0 as "read"
|
||||
FROM tmensajes tm
|
||||
LEFT JOIN tnotification_user nu
|
||||
ON tm.id_mensaje=nu.id_mensaje
|
||||
AND nu.id_user="%s"
|
||||
AND tm.id_mensaje=%d
|
||||
LEFT JOIN (tnotification_group ng
|
||||
INNER JOIN tusuario_perfil up
|
||||
ON ng.id_group=up.id_grupo
|
||||
AND up.id_grupo=ng.id_group
|
||||
) ON tm.id_mensaje=ng.id_mensaje
|
||||
WHERE utimestamp_erased is null
|
||||
AND (nu.id_user="%s" OR up.id_usuario="%s" OR ng.id_group=0)',
|
||||
$config['id_user'],
|
||||
$id_message,
|
||||
$config['id_user'],
|
||||
$config['id_user']
|
||||
);
|
||||
|
||||
return (bool) db_get_value_sql($sql);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the target users and groups assigned to be notified on
|
||||
* desired source.
|
||||
*
|
||||
* @param integer $id_source Source identificator.
|
||||
*
|
||||
* @return array [users] and [groups] with the targets.
|
||||
*/
|
||||
function get_notification_source_targets(int $id_source)
|
||||
{
|
||||
$ret = [];
|
||||
|
||||
$users = db_get_all_rows_sql(
|
||||
sprintf(
|
||||
'SELECT
|
||||
id_user,
|
||||
IF(ns.user_editable = 1,nsu.also_mail,ns.also_mail) AS also_mail
|
||||
FROM tnotification_source_user nsu
|
||||
INNER JOIN tnotification_source ns
|
||||
ON ns.id=nsu.id_source
|
||||
WHERE ns.id = %d
|
||||
AND ((ns.enabled is NULL OR ns.enabled != 0)
|
||||
OR (nsu.enabled is NULL OR nsu.enabled != 0))',
|
||||
$id_source
|
||||
)
|
||||
);
|
||||
|
||||
if ($users !== false) {
|
||||
$i = 0;
|
||||
foreach ($users as $user) {
|
||||
$ret['users'][$i]['id_user'] = $user['id_user'];
|
||||
$ret['users'][$i++]['also_mail'] = $user['also_mail'];
|
||||
}
|
||||
}
|
||||
|
||||
$groups = db_get_all_rows_sql(
|
||||
sprintf(
|
||||
'SELECT id_group,ns.also_mail
|
||||
FROM tnotification_source_group nsg
|
||||
INNER JOIN tnotification_source ns
|
||||
ON ns.id=nsg.id_source
|
||||
WHERE ns.id = %d
|
||||
AND (ns.enabled is NULL OR ns.enabled != 0)',
|
||||
$id_source
|
||||
)
|
||||
);
|
||||
|
||||
if ($groups !== false) {
|
||||
$i = 0;
|
||||
foreach ($groups as $group) {
|
||||
$ret['groups'][$i]['id_group'] = $group['id_group'];
|
||||
$ret['groups'][$i++]['also_mail'] = $group['also_mail'];
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return all info from tnotification_source
|
||||
*
|
||||
* @param array $filter Filter to table tnotification_source.
|
||||
*
|
||||
* @return array with sources info
|
||||
*/
|
||||
function notifications_get_all_sources($filter=[])
|
||||
{
|
||||
return db_get_all_rows_filter('tnotification_source', $filter);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the user sources to be inserted into a select
|
||||
*
|
||||
* @param integer $source_id Source database identificator.
|
||||
*
|
||||
* @return array with the user id in keys and user id in value too
|
||||
*/
|
||||
function notifications_get_user_sources_for_select($source_id)
|
||||
{
|
||||
$users = notifications_get_user_sources(
|
||||
['id_source' => $source_id],
|
||||
['id_user']
|
||||
);
|
||||
|
||||
return index_array($users, 'id_user', 'id_user');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the user sources
|
||||
*
|
||||
* @param array $filter Filter of sql query.
|
||||
* @param array $fields Fields to get of query.
|
||||
*
|
||||
* @return array Array with user sources data.
|
||||
*/
|
||||
function notifications_get_user_sources($filter=[], $fields=[])
|
||||
{
|
||||
$users = db_get_all_rows_filter(
|
||||
'tnotification_source_user',
|
||||
$filter,
|
||||
$fields
|
||||
);
|
||||
// If fails or no one is selected, return empty array.
|
||||
if ($users === false) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $users;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the groups sources to be inserted into a select
|
||||
*
|
||||
* @param integer $source_id Source database identificator.
|
||||
*
|
||||
* @return array with the group id in keys and group name in value
|
||||
*/
|
||||
function notifications_get_group_sources_for_select($source_id)
|
||||
{
|
||||
$groups = notifications_get_group_sources(
|
||||
['id_source' => $source_id],
|
||||
['id_group']
|
||||
);
|
||||
return index_array($groups, 'id_group', 'name');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the group sources
|
||||
*
|
||||
* @param array $filter Filter of sql query.
|
||||
* @param array $fields Fields retrieved.
|
||||
*
|
||||
* @return array With the group info
|
||||
*/
|
||||
function notifications_get_group_sources($filter=[], $fields=[])
|
||||
{
|
||||
// Get only the tnotifications_source_group fields in addition to group name.
|
||||
if (empty($fields)) {
|
||||
$fields[] = 'tnsg.*';
|
||||
}
|
||||
|
||||
$fields = array_map(
|
||||
function ($field) {
|
||||
if (!preg_match('/^tnsg./', $field)) {
|
||||
$field = 'tnsg.'.$field;
|
||||
}
|
||||
|
||||
return $field;
|
||||
},
|
||||
$fields
|
||||
);
|
||||
|
||||
// Get groups.
|
||||
$groups = db_get_all_rows_filter(
|
||||
'tnotification_source_group tnsg
|
||||
LEFT JOIN tgrupo tg ON tnsg.id_group = tg.id_grupo',
|
||||
$filter,
|
||||
array_merge($fields, ['IFNULL(tg.nombre, "All") AS name'])
|
||||
);
|
||||
|
||||
// If fails or no one is selected, return empty array.
|
||||
if ($groups === false) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a set of groups from notification source
|
||||
*
|
||||
* @param integer $source_id Source id.
|
||||
* @param array $groups Id of groups to be deleted.
|
||||
*
|
||||
* @return boolean True if success. False otherwise.
|
||||
*/
|
||||
function notifications_remove_group_from_source($source_id, $groups)
|
||||
{
|
||||
// Source id is mandatory.
|
||||
if (!isset($source_id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Delete from database.
|
||||
return db_process_sql_delete(
|
||||
'tnotification_source_group',
|
||||
[
|
||||
'id_group' => $groups,
|
||||
'id_source' => $source_id,
|
||||
]
|
||||
) !== false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a set of users from notification source
|
||||
*
|
||||
* @param integer $source_id Source id.
|
||||
* @param array $users Id of users to be deleted.
|
||||
*
|
||||
* @return boolean True if success. False otherwise.
|
||||
*/
|
||||
function notifications_remove_users_from_source($source_id, $users)
|
||||
{
|
||||
// Source id is mandatory.
|
||||
if (!isset($source_id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Delete from database.
|
||||
return db_process_sql_delete(
|
||||
'tnotification_source_user',
|
||||
[
|
||||
'id_user' => $users,
|
||||
'id_source' => $source_id,
|
||||
]
|
||||
) !== false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert a set of groups to notification source
|
||||
*
|
||||
* @param integer $source_id Source id.
|
||||
* @param array $groups Id of groups to be deleted.
|
||||
*
|
||||
* @return boolean True if success. False otherwise.
|
||||
*/
|
||||
function notifications_add_group_to_source($source_id, $groups)
|
||||
{
|
||||
// Source id is mandatory.
|
||||
if (!isset($source_id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Insert into database all groups passed.
|
||||
$res = true;
|
||||
foreach ($groups as $group) {
|
||||
if (!isset($group)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$res = $res && db_process_sql_insert(
|
||||
'tnotification_source_group',
|
||||
[
|
||||
'id_group' => $group,
|
||||
'id_source' => $source_id,
|
||||
]
|
||||
) !== false;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert a set of users to notification source
|
||||
*
|
||||
* @param integer $source_id Source id.
|
||||
* @param array $users Id of users to be deleted.
|
||||
*
|
||||
* @return boolean True if success. False otherwise.
|
||||
*/
|
||||
function notifications_add_users_to_source($source_id, $users)
|
||||
{
|
||||
// Source id is mandatory.
|
||||
if (!isset($source_id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Insert into database all groups passed.
|
||||
$res = true;
|
||||
$also_mail = db_get_value(
|
||||
'also_mail',
|
||||
'tnotification_source',
|
||||
'id',
|
||||
$source_id
|
||||
);
|
||||
foreach ($users as $user) {
|
||||
if (empty($user)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$res = $res && db_process_sql_insert(
|
||||
'tnotification_source_user',
|
||||
[
|
||||
'id_user' => $user,
|
||||
'id_source' => $source_id,
|
||||
'enabled' => 1,
|
||||
'also_mail' => (int) $also_mail,
|
||||
]
|
||||
) !== false;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the groups that not own to a source and, for that reason, they can be
|
||||
* added to the source.
|
||||
*
|
||||
* @param integer $source_id Source id.
|
||||
*
|
||||
* @return array Indexed by id group all selectable groups.
|
||||
*/
|
||||
function notifications_get_group_source_not_configured($source_id)
|
||||
{
|
||||
$groups_selected = notifications_get_group_sources_for_select($source_id);
|
||||
$all_groups = users_get_groups_for_select(false, 'AR', false, true, $groups_selected);
|
||||
return array_diff($all_groups, $groups_selected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the users that not own to a source and, for that reason, they can be
|
||||
* added to the source.
|
||||
*
|
||||
* @param integer $source_id Source id.
|
||||
*
|
||||
* @return array Indexed by id user, all selectable users.
|
||||
*/
|
||||
function notifications_get_user_source_not_configured($source_id)
|
||||
{
|
||||
$users_selected = array_keys(notifications_get_user_sources_for_select($source_id));
|
||||
$users = get_users(
|
||||
'id_user',
|
||||
['!id_user' => $users_selected],
|
||||
['id_user']
|
||||
);
|
||||
return index_array($users, 'id_user', 'id_user');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Build a data struct to handle the value of a label
|
||||
*
|
||||
* @param mixed $status Status value.
|
||||
* @param mixed $enabled Enabled value.
|
||||
*
|
||||
* @return array with status (1|0) and enabled (1|0)
|
||||
*/
|
||||
function notifications_build_user_enable_return($status, $enabled)
|
||||
{
|
||||
return [
|
||||
'status' => ((bool) $status === true) ? 1 : 0,
|
||||
'enabled' => ((bool) $enabled === true) ? 1 : 0,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get user label (enabled, also_mail...) status.
|
||||
*
|
||||
* @param integer $source Id of notification source.
|
||||
* @param string $user User id.
|
||||
* @param string $label Label id (enabled, also_email...).
|
||||
*
|
||||
* @return array Return of notifications_build_user_enable_return.
|
||||
*/
|
||||
function notifications_get_user_label_status($source, $user, $label)
|
||||
{
|
||||
// If not enabled, it cannot be modificable.
|
||||
if (!$source['enabled']) {
|
||||
return notifications_build_user_enable_return(false, false);
|
||||
}
|
||||
|
||||
// See at first for direct reference.
|
||||
$user_source = notifications_get_user_sources(
|
||||
[
|
||||
'id_source' => $source['id'],
|
||||
'id_user' => $user,
|
||||
]
|
||||
);
|
||||
if (!empty($user_source)) {
|
||||
return notifications_build_user_enable_return(
|
||||
isset($user_source[0][$label]) ? $user_source[0][$label] : false,
|
||||
$source['user_editable']
|
||||
);
|
||||
}
|
||||
|
||||
$common_groups = array_intersect(
|
||||
array_keys(users_get_groups($user)),
|
||||
array_keys(
|
||||
notifications_get_group_sources_for_select($source['id'])
|
||||
)
|
||||
);
|
||||
// No group found, return no permissions.
|
||||
$value = empty($common_groups) ? false : $source[$label];
|
||||
return notifications_build_user_enable_return(
|
||||
$value,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the status to a single label on config of users notifications.
|
||||
*
|
||||
* @param integer $source Id of notification source.
|
||||
* @param string $user User id.
|
||||
* @param string $label Label id (enabled, also_email...).
|
||||
* @param mixed $value Numeric value: 1 or 0.
|
||||
*
|
||||
* @return boolean True if success.
|
||||
*/
|
||||
function notifications_set_user_label_status($source, $user, $label, $value)
|
||||
{
|
||||
$source_info = notifications_get_all_sources(['id' => $source]);
|
||||
if (!isset($source_info[0])
|
||||
|| !$source_info[0]['enabled']
|
||||
|| !$source_info[0]['user_editable']
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (bool) db_process_sql_update(
|
||||
'tnotification_source_user',
|
||||
[$label => $value],
|
||||
[
|
||||
'id_user' => $user,
|
||||
'id_source' => $source,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the counters of notification. Usefull to print the header notification
|
||||
* ball.
|
||||
*
|
||||
* @return array With the fields:
|
||||
* 'notifications' => Total new notifications,
|
||||
* 'last_id' => Id of last read value. Usefull to make comparisons.
|
||||
*/
|
||||
function notifications_get_counters()
|
||||
{
|
||||
$num_notifications = 0;
|
||||
$last_id = 0;
|
||||
$last_message = messages_get_overview(
|
||||
'timestamp',
|
||||
'DESC',
|
||||
false,
|
||||
false,
|
||||
1
|
||||
);
|
||||
if (!empty($last_message)) {
|
||||
$num_notifications = messages_get_count();
|
||||
$last_id = $last_message[0]['id_mensaje'];
|
||||
}
|
||||
|
||||
return [
|
||||
'notifications' => $num_notifications,
|
||||
'last_id' => $last_id,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
// /////////////////////////////////////////////////////////////////////////////
|
||||
// UI FUNCTIONS
|
||||
// /////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* Print the notification ball to see unread messages.
|
||||
*
|
||||
* @param integer $num_notifications Number of messages shown
|
||||
* in notification ball.
|
||||
* @param integer $last_id Id of last message shown
|
||||
* in the notification ball.
|
||||
*
|
||||
* @return string with HTML code of notification ball.
|
||||
*/
|
||||
function notifications_print_ball($num_notifications, $last_id)
|
||||
{
|
||||
$no_notifications = (int) $num_notifications === 0;
|
||||
$class_status = ($no_notifications) ? 'notification-ball-no-messages' : 'notification-ball-new-messages';
|
||||
return sprintf(
|
||||
'<div
|
||||
%s
|
||||
class="notification-ball %s"
|
||||
id="notification-ball-header"
|
||||
last_id="%s"
|
||||
>
|
||||
%s
|
||||
</div>',
|
||||
($no_notifications) ? '' : 'onclick="addNotifications(event)"',
|
||||
$class_status,
|
||||
$last_id,
|
||||
$num_notifications
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print notification configuration global
|
||||
*
|
||||
* @param array $source Notification source data.
|
||||
*
|
||||
* @return string with HTML of source configuration
|
||||
*/
|
||||
function notifications_print_global_source_configuration($source)
|
||||
{
|
||||
// Get some values to generate the title.
|
||||
$switch_values = [
|
||||
'name' => 'enable-'.$source['id'],
|
||||
'value' => $source['enabled'],
|
||||
'id' => 'nt-'.$source['id'].'-enabled',
|
||||
'class' => 'elem-clickable',
|
||||
];
|
||||
|
||||
// Search if group all is set and handle that situation.
|
||||
$source_groups = notifications_get_group_sources_for_select($source['id']);
|
||||
$is_group_all = isset($source_groups['0']);
|
||||
if ($is_group_all) {
|
||||
unset($source_groups['0']);
|
||||
}
|
||||
|
||||
// Generate the title.
|
||||
$html_title = "<div class='global-config-notification-title'>";
|
||||
$html_title .= html_print_switch($switch_values);
|
||||
$html_title .= '<h2>'.$source['description'].'</h2>';
|
||||
$html_title .= '</div>';
|
||||
|
||||
// Generate the html for title.
|
||||
$html_selectors = "<div class='global-config-notification-selectors'>";
|
||||
$html_selectors .= notifications_print_source_select_box(
|
||||
notifications_get_user_sources_for_select($source['id']),
|
||||
'users',
|
||||
$source['id']
|
||||
);
|
||||
$html_selectors .= notifications_print_source_select_box(
|
||||
$source_groups,
|
||||
'groups',
|
||||
$source['id']
|
||||
);
|
||||
$html_selectors .= '</div>';
|
||||
// Generate the checkboxes and time select.
|
||||
$html_checkboxes = "<div class='global-config-notification-checkboxes'>";
|
||||
$html_checkboxes .= ' <span>';
|
||||
$html_checkboxes .= html_print_checkbox_extended('all-'.$source['id'], 1, $is_group_all, false, '', 'class= "elem-clickable"', true, 'id="nt-'.$source['id'].'-all_users"');
|
||||
$html_checkboxes .= __('Notify all users');
|
||||
$html_checkboxes .= ' </span><br><span>';
|
||||
$html_checkboxes .= html_print_checkbox_extended('mail-'.$source['id'], 1, $source['also_mail'], false, '', 'class= "elem-clickable"', true, 'id="nt-'.$source['id'].'-also_mail"');
|
||||
$html_checkboxes .= __('Also email users with notification content');
|
||||
$html_checkboxes .= ' </span><br><span>';
|
||||
$html_checkboxes .= html_print_checkbox_extended('user-'.$source['id'], 1, $source['user_editable'], false, '', 'class= "elem-clickable"', true, 'id="nt-'.$source['id'].'-user_editable"');
|
||||
$html_checkboxes .= __('Users can modify notification preferences');
|
||||
$html_checkboxes .= ' </span>';
|
||||
$html_checkboxes .= '</div>';
|
||||
|
||||
// Generate the select with the time.
|
||||
$html_select_pospone = __('Users can postpone notifications up to');
|
||||
// FIXMEit should not be disabled.
|
||||
$html_select_pospone .= html_print_select(
|
||||
[
|
||||
SECONDS_5MINUTES => __('5 minutes'),
|
||||
SECONDS_15MINUTES => __('15 minutes'),
|
||||
SECONDS_12HOURS => __('12 hours'),
|
||||
SECONDS_1DAY => __('1 day'),
|
||||
SECONDS_1WEEK => __('1 week'),
|
||||
SECONDS_15DAYS => __('15 days'),
|
||||
SECONDS_1MONTH => __('1 month'),
|
||||
NOTIFICATIONS_POSTPONE_FOREVER => __('forever'),
|
||||
],
|
||||
'nt-'.$source['id'].'-max_postpone_time',
|
||||
$source['max_postpone_time'],
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'elem-changeable',
|
||||
true
|
||||
);
|
||||
|
||||
// Return all html.
|
||||
return $html_title.$html_selectors.$html_checkboxes.$html_select_pospone;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print select boxes of notified users or groups
|
||||
*
|
||||
* @param array $info_selec All info required for build the selector.
|
||||
* @param string $id One of users|groups.
|
||||
* @param string $source_id Id of source.
|
||||
*
|
||||
* @return string HTML with the generated selector
|
||||
*/
|
||||
function notifications_print_source_select_box(
|
||||
$info_selec,
|
||||
$id,
|
||||
$source_id
|
||||
) {
|
||||
$title = ($id === 'users') ? __('Notified users') : __('Notified groups');
|
||||
$add_title = ($id === 'users') ? __('Add users') : __('Add groups');
|
||||
$delete_title = ($id === 'users') ? __('Delete users') : __('Delete groups');
|
||||
|
||||
// Generate the HTML.
|
||||
return sprintf(
|
||||
"
|
||||
<div class='global-config-notification-single-selector'>
|
||||
<div>
|
||||
<h4>%s</h4>
|
||||
%s
|
||||
</div>
|
||||
<div class='global-notifications-icons'>
|
||||
%s
|
||||
%s
|
||||
</div>
|
||||
</div>
|
||||
",
|
||||
$title,
|
||||
// Put a true if empty sources to avoid to sow the 'None' value.
|
||||
html_print_select(
|
||||
empty($info_selec) ? true : $info_selec,
|
||||
'multi-'.$id.'-'.$source_id.'[]',
|
||||
0,
|
||||
false,
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
true
|
||||
),
|
||||
html_print_image(
|
||||
'images/input_add.png',
|
||||
true,
|
||||
[
|
||||
'title' => $add_title,
|
||||
'onclick' => sprintf(
|
||||
"add_source_dialog('%s', '%s')",
|
||||
$id,
|
||||
$source_id
|
||||
),
|
||||
]
|
||||
),
|
||||
html_print_image(
|
||||
'images/input_delete.png',
|
||||
true,
|
||||
[
|
||||
'title' => $delete_title,
|
||||
'onclick' => sprintf(
|
||||
"remove_source_elements('%s', '%s')",
|
||||
$id,
|
||||
$source_id
|
||||
),
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print the select with right and left arrows to select new sources
|
||||
* (groups or users).
|
||||
*
|
||||
* @param array $info_selec Array with source info.
|
||||
* @param string $users One of users|groups.
|
||||
* @param source $source_id Source id.
|
||||
*
|
||||
* @return string HTML with the select code.
|
||||
*/
|
||||
function notifications_print_two_ways_select($info_selec, $users, $source_id)
|
||||
{
|
||||
return sprintf(
|
||||
"
|
||||
<div class='global_config_notifications_dialog_add'>
|
||||
%s
|
||||
<div class='global_config_notifications_two_ways_form_arrows'>
|
||||
%s
|
||||
%s
|
||||
</div>
|
||||
%s
|
||||
</div>
|
||||
%s
|
||||
",
|
||||
html_print_select(
|
||||
empty($info_selec) ? true : $info_selec,
|
||||
'all-multi-'.$users.'-'.$source_id.'[]',
|
||||
0,
|
||||
false,
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
''
|
||||
),
|
||||
html_print_image(
|
||||
'images/darrowright.png',
|
||||
true,
|
||||
[
|
||||
'title' => __('Add elements'),
|
||||
'onclick' => sprintf(
|
||||
"notifications_modify_two_ways_element('%s', '%s', 'add')",
|
||||
$users,
|
||||
$source_id
|
||||
),
|
||||
]
|
||||
),
|
||||
html_print_image(
|
||||
'images/darrowleft.png',
|
||||
true,
|
||||
[
|
||||
'title' => __('Remove elements'),
|
||||
'onclick' => sprintf(
|
||||
"notifications_modify_two_ways_element('%s', '%s', 'remove')",
|
||||
$users,
|
||||
$source_id
|
||||
),
|
||||
]
|
||||
),
|
||||
html_print_select(
|
||||
true,
|
||||
'selected-multi-'.$users.'-'.$source_id.'[]',
|
||||
0,
|
||||
false,
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
''
|
||||
),
|
||||
html_print_button(
|
||||
__('Add'),
|
||||
'Add',
|
||||
false,
|
||||
sprintf(
|
||||
"notifications_add_source_element_to_database('%s', '%s')",
|
||||
$users,
|
||||
$source_id
|
||||
),
|
||||
"class='sub add'",
|
||||
true
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print a label status represented by a switch
|
||||
*
|
||||
* @param integer $source Source id.
|
||||
* @param string $user User id.
|
||||
* @param string $label Label (enabled, also_mail...).
|
||||
*
|
||||
* @return string With HTML code
|
||||
*/
|
||||
function notifications_print_user_switch($source, $user, $label)
|
||||
{
|
||||
$status = notifications_get_user_label_status($source, $user, $label);
|
||||
return html_print_switch(
|
||||
[
|
||||
'name' => $label,
|
||||
'value' => $status['status'],
|
||||
'disabled' => !$status['enabled'],
|
||||
'class' => 'notifications-user-label_individual',
|
||||
'id' => 'notifications-user-'.$source['id'].'-label-'.$label,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates the dropdown notifications menu.
|
||||
*
|
||||
* @return string HTML with dropdown menu.
|
||||
*/
|
||||
function notifications_print_dropdown()
|
||||
{
|
||||
$mess = messages_get_overview('status', 'DESC', false, true);
|
||||
if ($mess === false) {
|
||||
$mess = [];
|
||||
}
|
||||
|
||||
return sprintf(
|
||||
"<div id='notification-wrapper'>
|
||||
<div id='notification-wrapper-inner'>
|
||||
%s
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
id='notification-wrapper-shadow'
|
||||
onclick='notifications_hide()'
|
||||
>
|
||||
</div>
|
||||
",
|
||||
array_reduce(
|
||||
$mess,
|
||||
function ($carry, $message) {
|
||||
return $carry.notifications_print_dropdown_element($message);
|
||||
},
|
||||
''
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print a single notification box
|
||||
*
|
||||
* @param array $message_info Info of printed message.
|
||||
*
|
||||
* @return string HTML code of single message
|
||||
*/
|
||||
function notifications_print_dropdown_element($message_info)
|
||||
{
|
||||
return sprintf(
|
||||
"<a
|
||||
class='notification-item'
|
||||
onclick='click_on_notification_toast(event)'
|
||||
id='notification-item-id-%s'
|
||||
href='%s'
|
||||
target='_blank'
|
||||
>
|
||||
%s
|
||||
<div class='notification-info'>
|
||||
<h4 class='notification-title'>
|
||||
%s
|
||||
</h4>
|
||||
<p class='notification-subtitle'>
|
||||
%s
|
||||
</p>
|
||||
</div>
|
||||
</a>",
|
||||
$message_info['id_mensaje'],
|
||||
messages_get_url($message_info['id_mensaje']),
|
||||
html_print_image('images/'.$message_info['icon'], true),
|
||||
$message_info['subject'],
|
||||
str_replace([io_safe_input('<br>')], ' ', $message_info['mensaje'])
|
||||
);
|
||||
}
|
|
@ -1,22 +1,33 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2009 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 Lesser General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
/**
|
||||
* @package Include
|
||||
* @subpackage Servers
|
||||
* Auxiliary functions to manage servers.
|
||||
*
|
||||
* @category Library
|
||||
* @package Pandora FMS
|
||||
* @subpackage Opensource
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
require_once __DIR__.'/constants.php';
|
||||
|
||||
|
||||
/**
|
||||
* Get a server.
|
||||
|
@ -194,7 +205,7 @@ function servers_get_performance()
|
|||
case SERVER_TYPE_EXPORT:
|
||||
case SERVER_TYPE_INVENTORY:
|
||||
case SERVER_TYPE_EVENT:
|
||||
case SERVER_TYPE_RECON:
|
||||
case SERVER_TYPE_DISCOVERY:
|
||||
case SERVER_TYPE_SYSLOG:
|
||||
break;
|
||||
}
|
||||
|
@ -415,8 +426,8 @@ function servers_get_info($id_server=-1)
|
|||
$id_modulo = 0;
|
||||
break;
|
||||
|
||||
case SERVER_TYPE_RECON:
|
||||
$server['img'] = html_print_image('images/recon.png', true, ['title' => __('Recon server')]);
|
||||
case SERVER_TYPE_DISCOVERY:
|
||||
$server['img'] = html_print_image('images/recon.png', true, ['title' => __('Discovery server')]);
|
||||
$server['type'] = 'recon';
|
||||
$id_modulo = 0;
|
||||
break;
|
||||
|
@ -589,11 +600,11 @@ function servers_get_info($id_server=-1)
|
|||
$server['lag'] = 0;
|
||||
$server['module_lag'] = 0;
|
||||
}
|
||||
// Recon server
|
||||
else if ($server['server_type'] == SERVER_TYPE_RECON) {
|
||||
// Discovery server
|
||||
else if ($server['server_type'] == SERVER_TYPE_DISCOVERY) {
|
||||
$server['name'] = '<a href="index.php?sec=estado&sec2=operation/servers/recon_view&server_id='.$server['id_server'].'">'.$server['name'].'</a>';
|
||||
|
||||
// Total jobs running on this recon server
|
||||
// Total jobs running on this Discovery server
|
||||
$server['modules'] = db_get_sql(
|
||||
'SELECT COUNT(id_rt)
|
||||
FROM trecon_task
|
||||
|
@ -921,3 +932,64 @@ function servers_get_status($id_server)
|
|||
$serverinfo = servers_get_info($id_server);
|
||||
return $serverinfo[$id_server];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return server name based on identifier.
|
||||
*
|
||||
* @param integer $server Server identifier.
|
||||
*
|
||||
* @return string Server name
|
||||
*/
|
||||
function servers_get_server_string_name(int $server)
|
||||
{
|
||||
switch ($server) {
|
||||
case SERVER_TYPE_DATA:
|
||||
return __('Data server');
|
||||
|
||||
case SERVER_TYPE_NETWORK:
|
||||
return __('Network server');
|
||||
|
||||
case SERVER_TYPE_SNMP:
|
||||
return __('SNMP server');
|
||||
|
||||
case SERVER_TYPE_ENTERPRISE_ICMP:
|
||||
return __('Enterprise ICMP server');
|
||||
|
||||
case SERVER_TYPE_ENTERPRISE_SNMP:
|
||||
return __('Enterprise SNMP server');
|
||||
|
||||
case SERVER_TYPE_PLUGIN:
|
||||
return __('Plugin server');
|
||||
|
||||
case SERVER_TYPE_PREDICTION:
|
||||
return __('Prediction Server');
|
||||
|
||||
case SERVER_TYPE_WMI:
|
||||
return __('WMI server');
|
||||
|
||||
case SERVER_TYPE_WEB:
|
||||
return __('Web server');
|
||||
|
||||
case SERVER_TYPE_EXPORT:
|
||||
return __('Export server');
|
||||
|
||||
case SERVER_TYPE_INVENTORY:
|
||||
return __('Inventory server');
|
||||
|
||||
case SERVER_TYPE_EVENT:
|
||||
return __('Event server');
|
||||
|
||||
case SERVER_TYPE_DISCOVERY:
|
||||
return __('Discovery server');
|
||||
|
||||
case SERVER_TYPE_SYSLOG:
|
||||
return __('Syslog server');
|
||||
|
||||
case SERVER_TYPE_WUX:
|
||||
return __('WUX server');
|
||||
|
||||
default:
|
||||
return __('N/A');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ $nfdump_date_format = 'Y/m/d.H:i:s';
|
|||
* @param id string Level ID. Do not set, used for recursion.
|
||||
* @param depth string Branch depth. Do not set, used for recursion.
|
||||
*/
|
||||
function snmp_browser_print_tree($tree, $id=0, $depth=0, $last=0, $last_array=[])
|
||||
function snmp_browser_print_tree($tree, $id=0, $depth=0, $last=0, $last_array=[], $sufix=false, $checked=[])
|
||||
{
|
||||
static $url = false;
|
||||
|
||||
|
@ -52,13 +52,13 @@ function snmp_browser_print_tree($tree, $id=0, $depth=0, $last=0, $last_array=[]
|
|||
}
|
||||
|
||||
foreach ($tree['__LEAVES__'] as $level => $sub_level) {
|
||||
// Id used to expand leafs
|
||||
// Id used to expand leafs.
|
||||
$sub_id = time().rand(0, getrandmax());
|
||||
|
||||
// Display the branch
|
||||
// Display the branch.
|
||||
echo "<li id='li_$sub_id' style='margin: 0; padding: 0;'>";
|
||||
|
||||
// Indent sub branches
|
||||
// Indent sub branches.
|
||||
for ($i = 1; $i <= $depth; $i++) {
|
||||
if ($last_array[$i] == 1) {
|
||||
echo '<img src="'.$url.'/no_branch.png" style="vertical-align: middle;">';
|
||||
|
@ -67,7 +67,7 @@ function snmp_browser_print_tree($tree, $id=0, $depth=0, $last=0, $last_array=[]
|
|||
}
|
||||
}
|
||||
|
||||
// Branch
|
||||
// Branch.
|
||||
if (! empty($sub_level['__LEAVES__'])) {
|
||||
echo "<a id='anchor_$sub_id' onfocus='javascript: this.blur();' href='javascript: toggleTreeNode(\"$sub_id\", \"$id\");'>";
|
||||
if ($depth == 0 && $count == 0) {
|
||||
|
@ -84,7 +84,7 @@ function snmp_browser_print_tree($tree, $id=0, $depth=0, $last=0, $last_array=[]
|
|||
|
||||
echo '</a>';
|
||||
}
|
||||
// Leave
|
||||
// Leave.
|
||||
else {
|
||||
if ($depth == 0 && $count == 0) {
|
||||
if ($count == $total) {
|
||||
|
@ -106,15 +106,18 @@ function snmp_browser_print_tree($tree, $id=0, $depth=0, $last=0, $last_array=[]
|
|||
echo '</a>';
|
||||
}
|
||||
|
||||
echo html_print_checkbox("create_$sub_id", 0, false, true, false, '').' <span>'.$level.'</span>';
|
||||
$checkbox_name_sufix = ($sufix === true) ? '_'.$level : '';
|
||||
$checkbox_name = 'create_'.$sub_id.$checkbox_name_sufix;
|
||||
$status = (!empty($checked) && isset($checked[$level]));
|
||||
echo html_print_checkbox($checkbox_name, 0, $status, true, false, '').' <span>'.$level.'</span>';
|
||||
if (isset($sub_level['__VALUE__'])) {
|
||||
echo '<span class="value" style="display: none;"> = '.$sub_level['__VALUE__'].'</span>';
|
||||
}
|
||||
|
||||
echo '</li>';
|
||||
|
||||
// Recursively print sub levels
|
||||
snmp_browser_print_tree($sub_level, $sub_id, ($depth + 1), ($count == $total ? 1 : 0), $last_array);
|
||||
// Recursively print sub levels.
|
||||
snmp_browser_print_tree($sub_level, $sub_id, ($depth + 1), ($count == $total ? 1 : 0), $last_array, $sufix, $checked);
|
||||
|
||||
$count++;
|
||||
}
|
||||
|
@ -838,7 +841,7 @@ function snmp_browser_print_container($return=false, $width='100%', $height='500
|
|||
if ($(this).is(':checked') ) {
|
||||
$('input[name*=create_network_component]').show();
|
||||
var id_input = $(this).attr("id");
|
||||
id_input = id_input.split("checkbox-create_");
|
||||
id_input = id_input.match("checkbox-create_([0-9]+)");
|
||||
var checks = $('#ul_'+id_input[1]).find('input').map(function(){
|
||||
if(this.id.indexOf('checkbox-create_')!=-1){
|
||||
return this.id;
|
||||
|
@ -851,7 +854,7 @@ function snmp_browser_print_container($return=false, $width='100%', $height='500
|
|||
} else {
|
||||
var id_input = $(this).attr("id");
|
||||
|
||||
id_input = id_input.split("checkbox-create_");
|
||||
id_input = id_input.match("checkbox-create_([0-9]+)");
|
||||
var checks = $('#ul_'+id_input[1]).find('input').map(function(){
|
||||
if(this.id.indexOf('checkbox-create_')!=-1){
|
||||
return this.id;
|
||||
|
|
|
@ -857,11 +857,11 @@ function pandoraFlotSlicebar(
|
|||
|
||||
var font_size = parseInt(font_size);
|
||||
if (font != undefined)
|
||||
var font = font
|
||||
.split("/")
|
||||
.pop()
|
||||
.split(".")
|
||||
.shift();
|
||||
var font = font
|
||||
.split("/")
|
||||
.pop()
|
||||
.split(".")
|
||||
.shift();
|
||||
// Check possible adapt_keys on classes
|
||||
check_adaptions(graph_id);
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
<p>The "ReconScripts" allows to work with more flexible capabilities. The recon scripts are developped in an individual way with completely specific targets, such as the network plugins or the agent plugins. Each ReconScript is different and has one purpose.</p>
|
||||
|
||||
<p>Its basic idea consist on "detect" things in the system it recognizes and automatically log in one monitoring (network, plugin or wmi) so in a completely customized way we could automatically log in requests in an Oracle database, new virtual host in a VmWare that is managed with VirtualCenter or we also can detect new requests in an WebLogic application Server. It is possible to do an script or application that does the task that are wanted and schedule its execution through the Recon Server.</p>
|
||||
<p>Its basic idea consist on "detect" things in the system it recognizes and automatically log in one monitoring (network, plugin or wmi) so in a completely customized way we could automatically log in requests in an Oracle database, new virtual host in a VmWare that is managed with VirtualCenter or we also can detect new requests in an WebLogic application Server. It is possible to do an script or application that does the task that are wanted and schedule its execution through the Discovery Server.</p>
|
||||
|
||||
<p>A field with importance is:</p>
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@ If you choose to edit or create a new task of network recon, then you should fil
|
|||
|
||||
Name of the discovery task. It's only a descriptive value to could distinguish the task in case it would have several of them with different values of filter or template. <br><br>
|
||||
|
||||
<b>Recon server</b><br>
|
||||
<b>Discovery server</b><br>
|
||||
|
||||
Recon Server assigned to the task. If you have several Recon Servers, then you have to select here which of them you want to do the recon task. <br><br>
|
||||
Discovery Server assigned to the task. If you have several Discovery Servers, then you have to select here which of them you want to do the recon task. <br><br>
|
||||
|
||||
<b>Mode</b><br>
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
検出タスクの名前です。フィルターやテンプレートとは異なり、タスクを区別しやすい説明を入れるだけです。<br><br>
|
||||
|
||||
<b>自動検出サーバ(Recon server)</b><br>
|
||||
<b>自動検出サーバ(Discovery server)</b><br>
|
||||
|
||||
タスクを割り当てる自動検出サーバです。複数の自動検出サーバがある場合は、自動検出タスクをどのサーバで実行するかを選択します。<br><br>
|
||||
|
||||
|
|
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
* Discovery css global
|
||||
*/
|
||||
|
||||
li.discovery {
|
||||
display: inline-block;
|
||||
float: left;
|
||||
width: 250px;
|
||||
height: 120px;
|
||||
margin: 15px;
|
||||
padding-bottom: 50px;
|
||||
}
|
||||
|
||||
li.discovery > a {
|
||||
text-decoration: none;
|
||||
color: #333;
|
||||
}
|
||||
li.discovery > a:hover {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
li.discovery img {
|
||||
height: 90px;
|
||||
}
|
||||
|
||||
li.discovery > a label {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
div.data_container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
text-align: center;
|
||||
padding-top: 30px;
|
||||
padding-bottom: 30px;
|
||||
}
|
||||
|
||||
div.data_container:hover {
|
||||
box-shadow: 2px 2px 10px #ddd;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: This may be at hostdevices.css
|
||||
*/
|
||||
.texto {
|
||||
height: auto;
|
||||
text-align: center;
|
||||
}
|
||||
h1.wizard {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
margin-top: -1.25em;
|
||||
}
|
||||
h1.wizard a {
|
||||
margin-left: -20px;
|
||||
}
|
||||
h1.wizard a:hover {
|
||||
color: #fff;
|
||||
}
|
||||
#text_wizard {
|
||||
font-weight: bolder;
|
||||
text-decoration: none;
|
||||
font-size: 24px;
|
||||
}
|
||||
div.arrow_box {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
background: #ccc;
|
||||
color: #888;
|
||||
padding: 1.3em;
|
||||
margin-left: 20px;
|
||||
margin-bottom: 10px;
|
||||
padding-left: 3em;
|
||||
}
|
||||
|
||||
.arrow_box:before {
|
||||
top: 50%;
|
||||
border: solid transparent;
|
||||
content: " ";
|
||||
height: 0;
|
||||
width: 0;
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
z-index: 1;
|
||||
}
|
||||
.arrow_box.selected {
|
||||
background: #424242;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.arrow_box:after {
|
||||
left: 0%;
|
||||
border-left-color: white;
|
||||
border-width: 20px;
|
||||
margin-top: -20px;
|
||||
}
|
||||
|
||||
div.arrow_box:before {
|
||||
left: 100%;
|
||||
border-left-color: #ccc;
|
||||
border-width: 20px;
|
||||
margin-top: -20px;
|
||||
}
|
||||
.arrow_box.selected:before {
|
||||
border-left-color: #424242;
|
||||
}
|
||||
|
||||
.arrow_box.selected:hover {
|
||||
color: #fff;
|
||||
}
|
||||
.arrow_box:hover {
|
||||
color: #000;
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
/*
|
||||
* TODO: This may be at hostdevices.css
|
||||
*/
|
|
@ -167,6 +167,9 @@ li:hover ul {
|
|||
}
|
||||
|
||||
/* Godmode images */
|
||||
#icon_god-discovery {
|
||||
background: url(../../images/gm_discovery.menu.png) no-repeat 50% 50%;
|
||||
}
|
||||
#icon_god-resources {
|
||||
background: url(../../images/gm_resources.menu.png) no-repeat 50% 50%;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/* Chat containers */
|
||||
.container {
|
||||
border: 2px solid #dedede;
|
||||
background-color: #f1f1f1;
|
||||
border-radius: 5px;
|
||||
padding: 10px;
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
/* Darker chat container */
|
||||
.darker {
|
||||
border-color: #ccc;
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
/* Clear floats */
|
||||
.container::after {
|
||||
content: "";
|
||||
clear: both;
|
||||
display: table;
|
||||
}
|
||||
|
||||
/* Style images */
|
||||
.container img {
|
||||
float: left;
|
||||
max-width: 60px;
|
||||
width: 100%;
|
||||
margin-right: 20px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
/* Style the right image */
|
||||
.container img.right {
|
||||
float: right;
|
||||
margin-left: 20px;
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
/* Style time text */
|
||||
.time-right {
|
||||
float: right;
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
/* Style time text */
|
||||
.time-left {
|
||||
float: left;
|
||||
color: #999;
|
||||
}
|
|
@ -917,6 +917,13 @@ input.group_item_min[disabled] {
|
|||
background: #fefefe url(../../images/group_green.disabled.png) no-repeat
|
||||
center !important;
|
||||
}
|
||||
input.color_cloud_min {
|
||||
background: #fefefe url(../../images/color_cloud_item.png) no-repeat center !important;
|
||||
}
|
||||
input.color_cloud_min[disabled] {
|
||||
background: #fefefe url(../../images/color_cloud_item.disabled.png) no-repeat
|
||||
center !important;
|
||||
}
|
||||
|
||||
div#cont {
|
||||
position: fixed;
|
||||
|
@ -1496,14 +1503,12 @@ table.databox {
|
|||
}
|
||||
|
||||
.databox > thead > tr > th,
|
||||
.databox > tbody > tr > th {
|
||||
.databox > tbody > tr > th,
|
||||
.databox > thead > tr > th a {
|
||||
padding: 9px 7px;
|
||||
font-weight: normal;
|
||||
color: #fff;
|
||||
}
|
||||
.databox > td {
|
||||
#border-bottom: 1px solid #e2e2e2;
|
||||
}
|
||||
|
||||
.databox > th * {
|
||||
color: #fff;
|
||||
|
@ -4250,255 +4255,191 @@ div#dialog_messages table th:last-child {
|
|||
text-align: right;
|
||||
}
|
||||
|
||||
/* --- JQUERY-UI --- */
|
||||
.ui-button-text-only .ui-button-text {
|
||||
font-family: "nunito", sans-serif;
|
||||
font-size: 9pt;
|
||||
color: #82b92e;
|
||||
/*
|
||||
* ---------------------------------------------------------------------
|
||||
* - Notifications
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
.notification-ball {
|
||||
border: white solid 2px;
|
||||
border-radius: 50px;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
.ui-datepicker .ui-datepicker-title *,
|
||||
.ui-datepicker th * {
|
||||
color: white;
|
||||
}
|
||||
.ui-datepicker .ui-datepicker-title select,
|
||||
.ui-datepicker .ui-datepicker-title option {
|
||||
color: #111 !important;
|
||||
}
|
||||
.ui-dialog .ui-dialog-titlebar {
|
||||
display: inherit;
|
||||
text-align: center;
|
||||
padding: 0.4em 1em;
|
||||
height: 30px;
|
||||
position: relative;
|
||||
background-color: #82b92e !important;
|
||||
}
|
||||
.ui-dialog .ui-dialog-title {
|
||||
font-family: "Nunito", sans-serif;
|
||||
margin: 0.1em 0 !important;
|
||||
white-space: nowrap !important;
|
||||
width: 100% !important;
|
||||
overflow: hidden !important;
|
||||
text-overflow: ellipsis !important;
|
||||
font-size: 11pt;
|
||||
position: relative;
|
||||
top: 5px;
|
||||
float: none !important;
|
||||
}
|
||||
.ui-dialog .ui-dialog-titlebar-close {
|
||||
position: absolute !important;
|
||||
right: 1em !important;
|
||||
width: 21px !important;
|
||||
margin: 0px 0 0 0 !important;
|
||||
padding: 1px !important;
|
||||
height: 20px !important;
|
||||
bottom: 30% !important;
|
||||
top: 20% !important;
|
||||
}
|
||||
.ui-dialog .ui-dialog-content {
|
||||
position: relative !important;
|
||||
border: 0;
|
||||
padding: 0.5em 1em !important;
|
||||
background: none !important;
|
||||
overflow: auto !important;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
.ui-dialog .ui-dialog-buttonpane {
|
||||
text-align: left;
|
||||
border-width: 1px 0 0 0;
|
||||
background-image: none;
|
||||
margin-top: 0.5em;
|
||||
padding: 0.3em 1em 0.5em 0.4em;
|
||||
}
|
||||
.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset {
|
||||
float: right;
|
||||
}
|
||||
.ui-dialog .ui-dialog-buttonpane button {
|
||||
margin: 0.5em 1em 0.5em 0 !important;
|
||||
cursor: pointer !important;
|
||||
background: white !important;
|
||||
background-color: white !important;
|
||||
border: 1px solid #82b92e !important;
|
||||
min-height: 35px !important;
|
||||
width: 90px !important;
|
||||
}
|
||||
.ui-widget-content {
|
||||
background: #ffffff url(include/styles/images/ui-bg_flat_75_ffffff_40x100.png)
|
||||
50% 50% repeat-x;
|
||||
}
|
||||
.ui-state-default,
|
||||
.ui-widget-content .ui-state-default,
|
||||
.ui-widget-header .ui-state-default {
|
||||
margin-top: 3px;
|
||||
border: 1px solid #d3d3d3 !important;
|
||||
border-bottom: 0 !important;
|
||||
background: #e6e6e6 url(images/ui-bg_glass_75_e6e6e6_1x400.png) 50% 50%
|
||||
repeat-x !important;
|
||||
font-weight: normal !important;
|
||||
color: #555555 !important;
|
||||
}
|
||||
.ui-corner-all,
|
||||
.ui-corner-top,
|
||||
.ui-corner-left,
|
||||
.ui-corner-tl {
|
||||
border-top-left-radius: 0 !important;
|
||||
}
|
||||
.ui-corner-all,
|
||||
.ui-corner-top,
|
||||
.ui-corner-right,
|
||||
.ui-corner-tr {
|
||||
border-top-right-radius: 0 !important;
|
||||
}
|
||||
.ui-corner-all,
|
||||
.ui-corner-bottom,
|
||||
.ui-corner-left,
|
||||
.ui-corner-bl {
|
||||
border-bottom-left-radius: 0 !important;
|
||||
}
|
||||
.ui-corner-all,
|
||||
.ui-corner-bottom,
|
||||
.ui-corner-right,
|
||||
.ui-corner-br {
|
||||
border-bottom-right-radius: 0 !important;
|
||||
}
|
||||
#ui-datepicker-div {
|
||||
border-color: #b1b1b1;
|
||||
background: #ffffff;
|
||||
}
|
||||
.ui-widget-header {
|
||||
background: #b1b1b1 !important;
|
||||
color: #ffffff !important;
|
||||
}
|
||||
.ui-datepicker-calendar th {
|
||||
background-color: #3f3f3f;
|
||||
}
|
||||
.ui-dialog .ui-widget-header {
|
||||
|
||||
.notification-ball-no-messages {
|
||||
background-color: #82b92e;
|
||||
cursor: pointer;
|
||||
}
|
||||
.ui_tpicker_hour,
|
||||
.ui_tpicker_minute,
|
||||
.ui_tpicker_second,
|
||||
.ui-slider-handle {
|
||||
border: 1px solid #aaaaaa !important;
|
||||
}
|
||||
.ui-timepicker-div dd {
|
||||
margin: 0px 15px 0px 15px;
|
||||
}
|
||||
.ui-timepicker-div .ui-datepicker-title {
|
||||
color: white;
|
||||
}
|
||||
.ui-datepicker-buttonpane button {
|
||||
border-color: #b1b1b1 !important;
|
||||
}
|
||||
.ui-datepicker-buttonpane .ui-datepicker-current {
|
||||
margin-left: 0.2em !important;
|
||||
}
|
||||
.ui-dialog .ui-widget-content {
|
||||
border: 0px !important;
|
||||
}
|
||||
.ui-dialog {
|
||||
box-shadow: 5px 5px 19px #4e4e4e;
|
||||
border: 0px !important;
|
||||
padding: 0 !important;
|
||||
}
|
||||
.ui-dialog-titlebar {
|
||||
border: 0px !important;
|
||||
}
|
||||
.ui-dialog-titlebar .ui-icon-closethick,
|
||||
.ui-dialog-titlebar .ui-state-default,
|
||||
.ui-dialog-titlebar .ui-state-hover,
|
||||
.ui-dialog-titlebar button {
|
||||
background: transparent;
|
||||
border: 0px;
|
||||
.notification-ball-new-messages {
|
||||
background-color: #fc4444;
|
||||
}
|
||||
|
||||
.ui-dialog-title {
|
||||
color: #ffffff;
|
||||
font-size: 9pt;
|
||||
#notification-wrapper {
|
||||
background: white;
|
||||
border: #a5a5a5 solid 1px;
|
||||
z-index: 900000;
|
||||
position: absolute;
|
||||
width: 400px;
|
||||
margin-top: -5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.ui-widget input,
|
||||
.ui-widget select,
|
||||
.ui-widget textarea,
|
||||
.ui-widget button {
|
||||
font-family: Verdana, Arial, sans-serif !important;
|
||||
#notification-wrapper::before {
|
||||
content: "";
|
||||
display: block;
|
||||
position: absolute;
|
||||
width: 0px;
|
||||
height: 0;
|
||||
border-color: transparent;
|
||||
border-width: 12px;
|
||||
border-style: solid;
|
||||
bottom: 100%;
|
||||
left: 78%;
|
||||
left: calc(78% - 2px);
|
||||
margin-left: -12px;
|
||||
border-bottom-color: white;
|
||||
}
|
||||
#notification-wrapper-inner {
|
||||
max-height: 400px;
|
||||
overflow: auto;
|
||||
}
|
||||
#notification-wrapper-shadow {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
background: #111;
|
||||
position: fixed;
|
||||
z-index: 9009;
|
||||
top: 0;
|
||||
opacity: 0.3;
|
||||
}
|
||||
.notification-item {
|
||||
background: whitesmoke;
|
||||
height: 100px;
|
||||
margin: 7px;
|
||||
border: #e4e4e4 solid 1px;
|
||||
display: flex;
|
||||
flex-flow: row nowrap;
|
||||
align-items: center;
|
||||
padding: 5px;
|
||||
}
|
||||
.notification-item:hover {
|
||||
border: #ccc solid 1px;
|
||||
}
|
||||
.notification-item > * {
|
||||
padding-left: 15px;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
a.ui-button:active,
|
||||
.ui-button:active,
|
||||
.ui-button.ui-state-active:hover,
|
||||
.ui-state-focus .ui-widget-content,
|
||||
.ui-state-focus .ui-widget-header,
|
||||
.ui-state-focus .ui-button:hover,
|
||||
.ui-button:focus {
|
||||
background: transparent !important;
|
||||
border: none !important;
|
||||
.notification-item:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.ui-state-hover,
|
||||
.ui-widget-content .ui-state-hover,
|
||||
.ui-widget-header .ui-state-hover {
|
||||
border: 1px solid #999999 !important;
|
||||
border-bottom: 0 !important;
|
||||
background: #dadada url(images/ui-bg_glass_75_dadada_1x400.png) 50% 50%
|
||||
repeat-x !important;
|
||||
.notification-info {
|
||||
width: 87%;
|
||||
display: flex;
|
||||
flex-flow: column nowrap;
|
||||
overflow: hidden;
|
||||
max-height: 83px;
|
||||
line-height: 1.4em;
|
||||
}
|
||||
.notification-item img {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
}
|
||||
.notification-title {
|
||||
margin: 0;
|
||||
}
|
||||
.notification-subtitle {
|
||||
margin: 0;
|
||||
color: #373737;
|
||||
}
|
||||
|
||||
.ui-state-active,
|
||||
.ui-widget-content .ui-state-active,
|
||||
.ui-widget-header .ui-state-active {
|
||||
border: 1px solid #aaaaaa !important;
|
||||
border-bottom: 0 !important;
|
||||
background: #ffffff url(images/ui-bg_glass_65_ffffff_1x400.png) 50% 50%
|
||||
repeat-x !important;
|
||||
font-weight: normal !important;
|
||||
color: #212121 !important;
|
||||
}
|
||||
.ui-state-active a,
|
||||
.ui-state-active a:link,
|
||||
.ui-state-active a:visited {
|
||||
color: #212121 !important;
|
||||
.global-config-notification-title {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
ul.ui-front {
|
||||
z-index: 1000000 !important;
|
||||
padding-right: 0px !important;
|
||||
.global-config-notification-title h2 {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
ul.ui-front li {
|
||||
padding: 3px !important;
|
||||
.global-config-notification-checkboxes :first-child {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
ul.ui-front li:hover {
|
||||
background-color: #e1e3e1 !important;
|
||||
.global-config-notification-selectors {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
ul.ui-front li a.ui-menu-item-wrapper {
|
||||
background: transparent !important;
|
||||
border: none !important;
|
||||
.global-config-notification-selectors h4 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
ul.ui-front li a.ui-menu-item-wrapper span {
|
||||
padding-left: 5px !important;
|
||||
.global-config-notification-single-selector,
|
||||
.global_config_notifications_dialog_add select {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
ul.ui-front li a.ui-menu-item-wrapper:hover {
|
||||
text-decoration: none !important;
|
||||
.global-config-notification-single-selector :first-child,
|
||||
.global-config-notification-single-selector :first-child select {
|
||||
width: 99%;
|
||||
}
|
||||
/* --- END - JQUERY-UI --- */
|
||||
|
||||
.toogle_switch {
|
||||
.global-config-notification-single-selector :last-child,
|
||||
.global_config_notifications_dialog_add_wrapper {
|
||||
flex-direction: column;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.global_config_notifications_dialog_add {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
margin: 8px;
|
||||
}
|
||||
|
||||
.global_config_notifications_two_ways_form_arrows {
|
||||
display: flex;
|
||||
flex-flow: column;
|
||||
justify-content: center;
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
.global_config_notifications_two_ways_form_arrows img {
|
||||
margin: 15px 0;
|
||||
}
|
||||
|
||||
/* jQuery dialog */
|
||||
.no-close .ui-dialog-titlebar-close {
|
||||
display: none;
|
||||
}
|
||||
/* jQuery dialog */
|
||||
|
||||
/* --- SWITCH --- */
|
||||
.p-switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 30px;
|
||||
height: 17px;
|
||||
}
|
||||
|
||||
.toogle_switch input {
|
||||
.p-switch input {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.slider {
|
||||
.p-slider {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 0;
|
||||
|
@ -4511,7 +4452,7 @@ ul.ui-front li a.ui-menu-item-wrapper:hover {
|
|||
border-radius: 34px;
|
||||
}
|
||||
|
||||
.slider:before {
|
||||
.p-slider:before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: 13px;
|
||||
|
@ -4524,22 +4465,105 @@ ul.ui-front li a.ui-menu-item-wrapper:hover {
|
|||
border-radius: 50%;
|
||||
}
|
||||
|
||||
input:checked + .slider {
|
||||
input:checked + .p-slider {
|
||||
background-color: #82b92e;
|
||||
}
|
||||
|
||||
input:focus + .slider {
|
||||
input:focus + .p-slider {
|
||||
box-shadow: 0 0 1px #82b92e;
|
||||
}
|
||||
|
||||
input:checked + .slider:before {
|
||||
input:checked + .p-slider:before {
|
||||
-webkit-transform: translateX(13px);
|
||||
-ms-transform: translateX(13px);
|
||||
transform: translateX(13px);
|
||||
}
|
||||
|
||||
/* jQuery dialog */
|
||||
.no-close .ui-dialog-titlebar-close {
|
||||
display: none;
|
||||
/* --- END SWITCH --- */
|
||||
|
||||
/* --- TOAST --- */
|
||||
#notifications-toasts-wrapper {
|
||||
position: fixed;
|
||||
right: 20px;
|
||||
top: 70px;
|
||||
width: 270px;
|
||||
height: 100%;
|
||||
z-index: 6;
|
||||
pointer-events: none;
|
||||
}
|
||||
/* --- END - JQUERY-UI --- */
|
||||
|
||||
.snackbar {
|
||||
max-width: 270px;
|
||||
background-color: #333;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
/* border-radius: 2px; */
|
||||
padding: 16px;
|
||||
margin: 10px;
|
||||
border-radius: 4px;
|
||||
visibility: hidden;
|
||||
pointer-events: all;
|
||||
}
|
||||
|
||||
.snackbar.show {
|
||||
visibility: visible;
|
||||
-webkit-animation: fadein 0.5s, fadeout 0.5s 7.5s;
|
||||
animation: fadein 0.5s, fadeout 0.5s 7.5s;
|
||||
}
|
||||
|
||||
.snackbar p,
|
||||
.snackbar h3 {
|
||||
text-align: left;
|
||||
margin: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
.snackbar h3 {
|
||||
color: white;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
@-webkit-keyframes fadein {
|
||||
from {
|
||||
bottom: 0;
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
bottom: 30px;
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fadein {
|
||||
from {
|
||||
bottom: 0;
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
bottom: 30px;
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes fadeout {
|
||||
from {
|
||||
bottom: 30px;
|
||||
opacity: 1;
|
||||
}
|
||||
to {
|
||||
bottom: 0;
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fadeout {
|
||||
from {
|
||||
bottom: 30px;
|
||||
opacity: 1;
|
||||
}
|
||||
to {
|
||||
bottom: 0;
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* --- END TOAST --- */
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Discovery > Wizard css global style
|
||||
*/
|
||||
|
||||
ul.wizard {
|
||||
}
|
||||
|
||||
ul.wizard li {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
ul.wizard li > label:not(.p-switch) {
|
||||
width: 250px;
|
||||
vertical-align: top;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
ul.wizard li > textarea {
|
||||
width: 250px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
|
@ -105,6 +105,7 @@ if (!empty($sub2)) {
|
|||
}
|
||||
|
||||
enterprise_hook('cluster_menu');
|
||||
enterprise_hook('aws_menu');
|
||||
|
||||
if (!empty($sub)) {
|
||||
$menu_operation['estado']['text'] = __('Monitoring');
|
||||
|
@ -375,6 +376,11 @@ $sub['operation/users/user_edit']['text'] = __('Edit my user');
|
|||
$sub['operation/users/user_edit']['id'] = 'Edit my user';
|
||||
$sub['operation/users/user_edit']['refr'] = 0;
|
||||
|
||||
// Users
|
||||
$sub['operation/users/user_edit_notifications']['text'] = __('Configure user notifications');
|
||||
$sub['operation/users/user_edit_notifications']['id'] = 'Configure user notifications';
|
||||
$sub['operation/users/user_edit_notifications']['refr'] = 0;
|
||||
|
||||
// ANY user can chat with other user and dogs.
|
||||
// Users
|
||||
$sub['operation/users/webchat']['text'] = __('WebChat');
|
||||
|
|
|
@ -1,24 +1,39 @@
|
|||
<?php
|
||||
/**
|
||||
* Extension to manage a list of gateways and the node address where they should
|
||||
* point to.
|
||||
*
|
||||
* @category Extensions
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// Load global vars
|
||||
global $config;
|
||||
|
||||
require_once 'include/functions_users.php';
|
||||
require_once 'include/functions_groups.php';
|
||||
require_once 'include/functions_io.php';
|
||||
|
||||
// params
|
||||
// Parse parameters.
|
||||
$new_msg = get_parameter('new_msg', 0);
|
||||
$dst_user = get_parameter('dst_user');
|
||||
$dst_group = get_parameter('dst_group');
|
||||
|
@ -30,23 +45,42 @@ $show_sent = get_parameter('show_sent', 0);
|
|||
|
||||
$buttons['message_list'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="index.php?sec=message_list&sec2=operation/messages/message_list">'.html_print_image('images/email_inbox.png', true, ['title' => __('Received messages')]).'</a>',
|
||||
'text' => '<a href="index.php?sec=message_list&sec2=operation/messages/message_list">'.html_print_image(
|
||||
'images/email_inbox.png',
|
||||
true,
|
||||
['title' => __('Received messages')]
|
||||
).'</a>',
|
||||
];
|
||||
|
||||
$buttons['sent_messages'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="index.php?sec=message_list&sec2=operation/messages/message_list&show_sent=1">'.html_print_image('images/email_outbox.png', true, ['title' => __('Sent messages')]).'</a>',
|
||||
'text' => '<a href="index.php?sec=message_list&sec2=operation/messages/message_list&show_sent=1">'.html_print_image(
|
||||
'images/email_outbox.png',
|
||||
true,
|
||||
['title' => __('Sent messages')]
|
||||
).'</a>',
|
||||
];
|
||||
|
||||
$buttons['create_message'] = [
|
||||
'active' => true,
|
||||
'text' => '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit">'.html_print_image('images/new_message.png', true, ['title' => __('Create message')]).'</a>',
|
||||
'text' => '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit">'.html_print_image(
|
||||
'images/new_message.png',
|
||||
true,
|
||||
['title' => __('Create message')]
|
||||
).'</a>',
|
||||
];
|
||||
|
||||
// Header
|
||||
ui_print_page_header(__('Messages'), 'images/email_mc.png', false, '', false, $buttons);
|
||||
// Header.
|
||||
ui_print_page_header(
|
||||
__('Messages'),
|
||||
'images/email_mc.png',
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
$buttons
|
||||
);
|
||||
|
||||
// read a message
|
||||
// Read a message.
|
||||
if ($read_message) {
|
||||
$message_id = (int) get_parameter('id_message');
|
||||
if ($show_sent) {
|
||||
|
@ -56,10 +90,10 @@ if ($read_message) {
|
|||
messages_process_read($message_id);
|
||||
}
|
||||
|
||||
if ($message == false) {
|
||||
if ($message === false) {
|
||||
echo '<div>'.__('This message does not exist in the system').'</div>';
|
||||
return;
|
||||
// Move out of this page and go processing other pages
|
||||
// Move out of this page and go processing other pages.
|
||||
}
|
||||
|
||||
$user_name = get_user_fullname($message['id_usuario_origen']);
|
||||
|
@ -72,19 +106,70 @@ if ($read_message) {
|
|||
$dst_name = $message['id_usuario_destino'];
|
||||
}
|
||||
|
||||
$table = new stdClass();
|
||||
$table->width = '100%';
|
||||
$table->class = 'databox filters';
|
||||
$table->data = [];
|
||||
if (isset($user_name) !== true || empty($user_name) === true) {
|
||||
echo '<h1>Notification</h1>';
|
||||
} else {
|
||||
echo '<h1>Conversation with '.$user_name.'</h1>';
|
||||
}
|
||||
|
||||
$table->data[0][0] = __('Sender');
|
||||
$table->data[0][1] = $user_name.' '.__('at').' '.ui_print_timestamp($message['timestamp'], true, ['prominent' => 'timestamp']);
|
||||
echo '<h2>Subject: '.$message['subject'].'</h2>';
|
||||
|
||||
$table->data[1][0] = __('Destination');
|
||||
$table->data[1][1] = $dst_name;
|
||||
$conversation = [];
|
||||
$target_str = $message['mensaje'];
|
||||
|
||||
while (preg_match_all(
|
||||
'/(.*)On(.*)wrote:(.*)/',
|
||||
$target_str,
|
||||
$decoded,
|
||||
PREG_PATTERN_ORDER
|
||||
) !== false && empty($target_str) !== true) {
|
||||
if (empty($decoded[2]) !== true) {
|
||||
array_push(
|
||||
$conversation,
|
||||
[
|
||||
'message' => array_pop($decoded)[0],
|
||||
'date' => array_pop($decoded)[0],
|
||||
]
|
||||
);
|
||||
} else {
|
||||
array_push(
|
||||
$conversation,
|
||||
['message' => $target_str]
|
||||
);
|
||||
}
|
||||
|
||||
$target_str = $decoded[1][0];
|
||||
}
|
||||
|
||||
ui_require_css_file('message_edit');
|
||||
foreach ($conversation as $row) {
|
||||
$date = $row['date'];
|
||||
|
||||
if ($date === null) {
|
||||
$date = date(
|
||||
$config['date_format'],
|
||||
$message['timestamp']
|
||||
).' '.$user_name;
|
||||
}
|
||||
|
||||
$order = [
|
||||
"\r\n",
|
||||
"\n",
|
||||
"\r",
|
||||
];
|
||||
$replace = '<br />';
|
||||
$parsed_message = str_replace(
|
||||
$order,
|
||||
$replace,
|
||||
trim(io_safe_output($row['message']))
|
||||
);
|
||||
|
||||
echo '<div class="container">';
|
||||
echo ' <p>'.$parsed_message.'</p>';
|
||||
echo '<span class="time-left">'.$date.'</span>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
$table->data[2][0] = __('Subject');
|
||||
$table->data[2][1] = html_print_input_text_extended('subject', $message['subject'], 'text-subject', '', 50, 70, true, false, '', 'readonly');
|
||||
|
||||
$order = [
|
||||
"\r\n",
|
||||
|
@ -94,21 +179,21 @@ if ($read_message) {
|
|||
$replace = '<br />';
|
||||
$parsed_message = str_replace($order, $replace, $message['mensaje']);
|
||||
|
||||
$table->data[3][0] = __('Message');
|
||||
$table->data[3][1] = html_print_textarea('message', 15, 255, $message['mensaje'], 'readonly', true);
|
||||
|
||||
// Prevent RE: RE: RE:
|
||||
// Prevent RE: RE: RE:.
|
||||
if (strstr($message['subject'], 'RE:')) {
|
||||
$new_subj = $message['subject'];
|
||||
} else {
|
||||
$new_subj = 'RE: '.$message['subject'];
|
||||
}
|
||||
|
||||
// Start the message much like an e-mail reply
|
||||
$new_msg = "\n\n\nOn ".date($config['date_format'], $message['timestamp']).' '.$user_name.' '.__('wrote').":\n\n".$message['mensaje'];
|
||||
// Start the message much like an e-mail reply.
|
||||
$new_msg = "\n\n\nOn ".date(
|
||||
$config['date_format'],
|
||||
$message['timestamp']
|
||||
).' '.$user_name.' '.__('wrote').":\n\n".$message['mensaje'];
|
||||
|
||||
|
||||
echo '<form id="delete_message" method="post" action="index.php?sec=message_list&sec2=operation/messages/message_list&show_sent=1&delete_message=1&id='.$message_id.'">';
|
||||
html_print_table($table);
|
||||
echo '</form>';
|
||||
|
||||
echo '<form id="reply_message" method="post" action="index.php?sec=message_list&sec2=operation/messages/message_edit&new_msg=1&reply=1">';
|
||||
|
@ -119,17 +204,33 @@ if ($read_message) {
|
|||
echo '</form>';
|
||||
|
||||
echo "<div class= 'action-buttons' style=' width:".$table->width."'>";
|
||||
html_print_submit_button(__('Delete'), 'delete_btn', false, 'form="delete_message" class="sub delete"');
|
||||
html_print_submit_button(
|
||||
__('Delete conversation'),
|
||||
'delete_btn',
|
||||
false,
|
||||
'form="delete_message" class="sub delete"'
|
||||
);
|
||||
echo ' ';
|
||||
html_print_submit_button(__('Reply'), 'reply', false, 'form="reply_message" class="sub next"');
|
||||
html_print_submit_button(
|
||||
__('Reply'),
|
||||
'reply',
|
||||
false,
|
||||
'form="reply_message" class="sub next"'
|
||||
);
|
||||
echo '</div>';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Create message (destination user)
|
||||
// Create message (destination user).
|
||||
if (($new_msg) && (!empty($dst_user)) && (!$reply)) {
|
||||
$return = messages_create_message($config['id_user'], $dst_user, $subject, $message);
|
||||
$return = messages_create_message(
|
||||
$config['id_user'],
|
||||
[$dst_user],
|
||||
[],
|
||||
$subject,
|
||||
$message
|
||||
);
|
||||
|
||||
$user_name = get_user_fullname($dst_user);
|
||||
if (!$user_name) {
|
||||
|
@ -143,9 +244,15 @@ if (($new_msg) && (!empty($dst_user)) && (!$reply)) {
|
|||
);
|
||||
}
|
||||
|
||||
// Create message (destination group)
|
||||
// Create message (destination group).
|
||||
if (($new_msg) && ($dst_group != '') && (!$reply)) {
|
||||
$return = messages_create_group($config['id_user'], $dst_group, $subject, $message);
|
||||
$return = messages_create_message(
|
||||
$config['id_user'],
|
||||
[],
|
||||
[$dst_group],
|
||||
$subject,
|
||||
$message
|
||||
);
|
||||
|
||||
ui_print_result_message(
|
||||
$return,
|
||||
|
@ -154,8 +261,8 @@ if (($new_msg) && ($dst_group != '') && (!$reply)) {
|
|||
);
|
||||
}
|
||||
|
||||
// message creation form
|
||||
// user info
|
||||
// Message creation form.
|
||||
// User info.
|
||||
$own_info = get_user_info($config['id_user']);
|
||||
|
||||
$table = new stdClass();
|
||||
|
@ -174,12 +281,28 @@ if (!empty($own_info['fullname'])) {
|
|||
|
||||
$table->data[1][0] = __('Destination');
|
||||
|
||||
$is_admin = (bool) db_get_value('is_admin', 'tusuario', 'id_user', $config['id_user']);
|
||||
$is_admin = (bool) db_get_value(
|
||||
'is_admin',
|
||||
'tusuario',
|
||||
'id_user',
|
||||
$config['id_user']
|
||||
);
|
||||
|
||||
if ($is_admin) {
|
||||
$users_full = db_get_all_rows_filter('tusuario', [], ['id_user', 'fullname']);
|
||||
$users_full = db_get_all_rows_filter(
|
||||
'tusuario',
|
||||
[],
|
||||
[
|
||||
'id_user',
|
||||
'fullname',
|
||||
]
|
||||
);
|
||||
} else {
|
||||
$users_full = groups_get_users(array_keys(users_get_groups()), false, false);
|
||||
$users_full = groups_get_users(
|
||||
array_keys(users_get_groups()),
|
||||
false,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
$users = [];
|
||||
|
@ -187,17 +310,16 @@ foreach ($users_full as $user_id => $user_info) {
|
|||
$users[$user_info['id_user']] = $user_info['fullname'];
|
||||
}
|
||||
|
||||
// Check if the user to reply is in the list, if not add reply user
|
||||
// Check if the user to reply is in the list, if not add reply user.
|
||||
if ($reply) {
|
||||
if (!array_key_exists($dst_user, $users)) {
|
||||
// Add the user to reply
|
||||
// Add the user to reply.
|
||||
$user_reply = db_get_row('tusuario', 'id_user', $dst_user);
|
||||
$users[$user_reply['id_user']] = $user_reply['fullname'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) {
|
||||
$return_all_groups = true;
|
||||
} else {
|
||||
|
@ -205,21 +327,61 @@ if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) {
|
|||
}
|
||||
|
||||
$groups = users_get_groups($config['id_user'], 'AR');
|
||||
// Get a list of all groups
|
||||
$table->data[1][1] = html_print_select($users, 'dst_user', $dst_user, '', __('Select user'), false, true, false, '', false);
|
||||
// Get a list of all groups.
|
||||
$table->data[1][1] = html_print_select(
|
||||
$users,
|
||||
'dst_user',
|
||||
$dst_user,
|
||||
'',
|
||||
__('Select user'),
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
'',
|
||||
false
|
||||
);
|
||||
$table->data[1][1] .= ' '.__('OR').' ';
|
||||
$table->data[1][1] .= html_print_select_groups($config['id_user'], 'AR', $return_all_groups, 'dst_group', $dst_group, '', __('Select group'), '', true);
|
||||
$table->data[1][1] .= html_print_select_groups(
|
||||
$config['id_user'],
|
||||
'AR',
|
||||
$return_all_groups,
|
||||
'dst_group',
|
||||
$dst_group,
|
||||
'',
|
||||
__('Select group'),
|
||||
'',
|
||||
true
|
||||
);
|
||||
|
||||
$table->data[2][0] = __('Subject');
|
||||
$table->data[2][1] = html_print_input_text('subject', $subject, '', 50, 70, true);
|
||||
$table->data[2][1] = html_print_input_text(
|
||||
'subject',
|
||||
$subject,
|
||||
'',
|
||||
50,
|
||||
70,
|
||||
true
|
||||
);
|
||||
|
||||
$table->data[3][0] = __('Message');
|
||||
$table->data[3][1] = html_print_textarea('message', 15, 255, $message, '', true);
|
||||
$table->data[3][1] = html_print_textarea(
|
||||
'message',
|
||||
15,
|
||||
255,
|
||||
$message,
|
||||
'',
|
||||
true
|
||||
);
|
||||
|
||||
echo '<form method="post" action="index.php?sec=message_list&sec2=operation/messages/message_edit&new_msg=1">';
|
||||
html_print_table($table);
|
||||
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||
html_print_submit_button(__('Send message'), 'send_mes', false, 'class="sub wand"');
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
html_print_submit_button(
|
||||
__('Send message'),
|
||||
'send_mes',
|
||||
false,
|
||||
'class="sub wand"'
|
||||
);
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
|
|
|
@ -1,16 +1,32 @@
|
|||
<?php
|
||||
/**
|
||||
* Extension to manage a list of gateways and the node address where they should
|
||||
* point to.
|
||||
*
|
||||
* @category Extensions
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2009 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.
|
||||
require_once 'include/functions_messages.php';
|
||||
|
||||
$delete_msg = get_parameter('delete_message', 0);
|
||||
|
@ -20,7 +36,7 @@ $mark_unread = get_parameter('mark_unread', 0);
|
|||
|
||||
$active_list = true;
|
||||
$active_sent = false;
|
||||
if ($show_sent) {
|
||||
if ($show_sent !== 0) {
|
||||
$active_list = false;
|
||||
$active_sent = true;
|
||||
}
|
||||
|
@ -37,11 +53,22 @@ $buttons['sent_messages'] = [
|
|||
|
||||
$buttons['create_message'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit">'.html_print_image('images/new_message.png', true, ['title' => __('Create message')]).'</a>',
|
||||
'text' => '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit">'.html_print_image(
|
||||
'images/new_message.png',
|
||||
true,
|
||||
['title' => __('Create message')]
|
||||
).'</a>',
|
||||
];
|
||||
|
||||
if (!is_ajax()) {
|
||||
ui_print_page_header(__('Messages'), 'images/email_mc.png', false, '', false, $buttons);
|
||||
ui_print_page_header(
|
||||
__('Messages'),
|
||||
'images/email_mc.png',
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
$buttons
|
||||
);
|
||||
}
|
||||
|
||||
if ($mark_unread) {
|
||||
|
@ -52,7 +79,7 @@ if ($mark_unread) {
|
|||
if ($delete_msg) {
|
||||
$id = (int) get_parameter('id');
|
||||
$result = messages_delete_message($id);
|
||||
// Delete message function will actually check the credentials
|
||||
// Delete message function will actually check the credentials.
|
||||
ui_print_result_message(
|
||||
$result,
|
||||
__('Successfully deleted'),
|
||||
|
@ -61,13 +88,10 @@ if ($delete_msg) {
|
|||
}
|
||||
|
||||
if ($multiple_delete) {
|
||||
$ids = (array) get_parameter('delete_multiple', []);
|
||||
$ids = (array) get_parameter('delete_multiple_messages', []);
|
||||
|
||||
foreach ($ids as $id) {
|
||||
$result = db_process_sql_delete(
|
||||
'tmensajes',
|
||||
['id_mensaje' => $id]
|
||||
);
|
||||
$result = messages_delete_message($id);
|
||||
|
||||
if ($result === false) {
|
||||
break;
|
||||
|
@ -82,21 +106,23 @@ if ($multiple_delete) {
|
|||
}
|
||||
|
||||
if ($show_sent) {
|
||||
// sent view
|
||||
// Sent view.
|
||||
$num_messages = messages_get_count_sent($config['id_user']);
|
||||
if ($num_messages > 0 && !is_ajax()) {
|
||||
echo '<p>'.__('You have').' <b>'.$num_messages.'</b> '.' '.__('sent message(s)').'.</p>';
|
||||
echo '<p>'.__('You have').' <b>'.$num_messages.'</b> '.__('sent message(s)').'.</p>';
|
||||
}
|
||||
|
||||
$messages = messages_get_overview_sent('', 'DESC');
|
||||
} else {
|
||||
// messages received
|
||||
$num_messages = messages_get_count($config['id_user']);
|
||||
// Messages received.
|
||||
$num_messages = messages_get_count($config['id_user'], true, true);
|
||||
if ($num_messages > 0 && !is_ajax()) {
|
||||
echo '<p>'.__('You have').' <b>'.$num_messages.'</b> '.' '.__('unread message(s)').'.</p>';
|
||||
$unread_messages = messages_get_count($config['id_user'], false, true);
|
||||
echo '<p>'.__('You have').' <b>'.$unread_messages.'</b> '.__('unread message(s)').'.</p>';
|
||||
$messages = messages_get_overview();
|
||||
} else {
|
||||
$messages = messages_get_overview('status', 'ASC');
|
||||
}
|
||||
|
||||
$messages = messages_get_overview();
|
||||
}
|
||||
|
||||
if (empty($messages)) {
|
||||
|
@ -139,10 +165,12 @@ if (empty($messages)) {
|
|||
$table->head[3] = __('Timestamp');
|
||||
$table->head[4] = __('Delete').html_print_checkbox('all_delete_messages', 0, false, true, false);
|
||||
|
||||
foreach ($messages as $message_id => $message) {
|
||||
|
||||
foreach ($messages as $message) {
|
||||
$message_id = $message['id_mensaje'];
|
||||
$data = [];
|
||||
$data[0] = '';
|
||||
if ($message['status'] == 1) {
|
||||
if ($message['read'] == 1) {
|
||||
if ($show_sent) {
|
||||
$data[0] .= '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&show_sent=1&id_message='.$message_id.'">';
|
||||
$data[0] .= html_print_image('images/email_open.png', true, ['border' => 0, 'title' => __('Click to read')]);
|
||||
|
@ -202,10 +230,10 @@ if (empty($messages)) {
|
|||
|
||||
if ($show_sent) {
|
||||
$data[4] = '<a href="index.php?sec=message_list&sec2=operation/messages/message_list&show_sent=1&delete_message=1&id='.$message_id.'"
|
||||
onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['title' => __('Delete')]).'</a>'.html_print_checkbox_extended('delete_multiple_messages[]', $message_id, false, false, '', 'class="check_delete_messages"', true);
|
||||
onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['title' => __('Delete')]).'</a>'.html_print_checkbox_extended('delete_multiple_messages[]', $message_id, false, false, '', 'class="check_delete_messages"', true);
|
||||
} else {
|
||||
$data[4] = '<a href="index.php?sec=message_list&sec2=operation/messages/message_list&delete_message=1&id='.$message_id.'"
|
||||
onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['title' => __('Delete')]).'</a>'.html_print_checkbox_extended('delete_multiple_messages[]', $message_id, false, false, '', 'class="check_delete_messages"', true);
|
||||
onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['title' => __('Delete')]).'</a>'.html_print_checkbox_extended('delete_multiple_messages[]', $message_id, false, false, '', 'class="check_delete_messages"', true);
|
||||
}
|
||||
|
||||
array_push($table->data, $data);
|
||||
|
|
|
@ -30,7 +30,7 @@ $servers = db_get_all_rows_sql('SELECT * FROM tserver WHERE server_type = 3');
|
|||
if ($servers === false) {
|
||||
$servers = [];
|
||||
ui_print_page_header(__('Recon View'), 'images/op_recon.png', false, '', false);
|
||||
ui_print_error_message(__('Recon Server is disabled'));
|
||||
ui_print_error_message(__('Discovery Server is disabled'));
|
||||
return;
|
||||
} else {
|
||||
$recon_task = db_get_all_rows_sql('SELECT * FROM trecon_task');
|
||||
|
|
|
@ -29,69 +29,10 @@
|
|||
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
// Load the header
|
||||
require $config['homedir'].'/operation/users/user_edit_header.php';
|
||||
|
||||
enterprise_hook('open_meta_frame');
|
||||
|
||||
require_once $config['homedir'].'/include/functions_profile.php';
|
||||
require_once $config['homedir'].'/include/functions_users.php';
|
||||
require_once $config['homedir'].'/include/functions_groups.php';
|
||||
require_once $config['homedir'].'/include/functions_visual_map.php';
|
||||
|
||||
$meta = false;
|
||||
if (enterprise_installed() && defined('METACONSOLE')) {
|
||||
$meta = true;
|
||||
}
|
||||
|
||||
$id = get_parameter_get('id', $config['id_user']);
|
||||
// ID given as parameter.
|
||||
$status = get_parameter('status', -1);
|
||||
// Flag to print action status message.
|
||||
$user_info = get_user_info($id);
|
||||
|
||||
$id = $user_info['id_user'];
|
||||
// This is done in case there are problems with uppercase/lowercase
|
||||
// (MySQL auth has that problem).
|
||||
if ((!check_acl($config['id_user'], users_get_groups($id), 'UM'))
|
||||
&& ($id != $config['id_user'])
|
||||
) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to view a user without privileges'
|
||||
);
|
||||
include 'general/noaccess.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
// If current user is editing himself or if the user has UM (User Management)
|
||||
// rights on any groups the user is part of AND the authorization scheme allows
|
||||
// for users/admins to update info.
|
||||
if (($config['id_user'] == $id || check_acl($config['id_user'], users_get_groups($id), 'UM'))
|
||||
&& $config['user_can_update_info']
|
||||
) {
|
||||
$view_mode = false;
|
||||
} else {
|
||||
$view_mode = true;
|
||||
}
|
||||
|
||||
// Header.
|
||||
if ($meta) {
|
||||
user_meta_print_header();
|
||||
$url = 'index.php?sec=advanced&sec2=advanced/users_setup&tab=user_edit';
|
||||
} else {
|
||||
ui_print_page_header(
|
||||
__('User detail editor'),
|
||||
'images/op_workspace.png',
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
''
|
||||
);
|
||||
$url = 'index.php?sec=workspace&sec2=operation/users/user_edit';
|
||||
}
|
||||
|
||||
|
||||
// Update user info.
|
||||
// Update user info
|
||||
if (isset($_GET['modified']) && !$view_mode) {
|
||||
if (html_print_csrf_error()) {
|
||||
return;
|
||||
|
@ -441,11 +382,11 @@ $table->data[] = $data;
|
|||
|
||||
// Double auth.
|
||||
$double_auth_enabled = (bool) db_get_value('id', 'tuser_double_auth', 'id_user', $config['id_user']);
|
||||
$data = array();
|
||||
$data = [];
|
||||
if ($config['double_auth_enabled']) {
|
||||
$data[0] = '<span style="width:50%;float:left;">'.__('Double authentication').'</span>';
|
||||
$data[0] .= $jump;
|
||||
$data[0] .= '<span style="width:20%;float:left;line-height:20px;">'.html_print_checkbox('double_auth', 1, $double_auth_enabled, true).'</span>';
|
||||
$data[0] = '<span style="width:50%;float:left;">'.__('Double authentication').'</span>';
|
||||
$data[0] .= $jump;
|
||||
$data[0] .= '<span style="width:20%;float:left;line-height:20px;">'.html_print_checkbox('double_auth', 1, $double_auth_enabled, true).'</span>';
|
||||
}
|
||||
|
||||
if ($double_auth_enabled) {
|
||||
|
@ -659,7 +600,7 @@ $table->rowclass[] = '';
|
|||
$table->rowstyle[] = '';
|
||||
$table->data[] = $data;
|
||||
|
||||
echo '<form name="user_mod" method="post" action="'.$url.'&modified=1&id='.$id.'&pure='.$config['pure'].'">';
|
||||
echo '<form name="user_mod" method="post" action="'.ui_get_full_url().'&modified=1&id='.$id.'&pure='.$config['pure'].'">';
|
||||
|
||||
html_print_table($table);
|
||||
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// Load global vars
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
|
||||
enterprise_hook('open_meta_frame');
|
||||
|
||||
require_once $config['homedir'].'/include/functions_profile.php';
|
||||
require_once $config['homedir'].'/include/functions_users.php';
|
||||
require_once $config['homedir'].'/include/functions_groups.php';
|
||||
require_once $config['homedir'].'/include/functions_visual_map.php';
|
||||
|
||||
$meta = false;
|
||||
if (enterprise_installed() && defined('METACONSOLE')) {
|
||||
$meta = true;
|
||||
}
|
||||
|
||||
$id = get_parameter_get('id', $config['id_user']);
|
||||
// ID given as parameter
|
||||
$status = get_parameter('status', -1);
|
||||
// Flag to print action status message
|
||||
$user_info = get_user_info($id);
|
||||
$id = $user_info['id_user'];
|
||||
// This is done in case there are problems with uppercase/lowercase (MySQL auth has that problem)
|
||||
if ((!check_acl($config['id_user'], users_get_groups($id), 'UM'))
|
||||
and ($id != $config['id_user'])
|
||||
) {
|
||||
db_pandora_audit('ACL Violation', 'Trying to view a user without privileges');
|
||||
include 'general/noaccess.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
// If current user is editing himself or if the user has UM (User Management) rights on any groups the user is part of AND the authorization scheme allows for users/admins to update info
|
||||
if (($config['id_user'] == $id || check_acl($config['id_user'], users_get_groups($id), 'UM')) && $config['user_can_update_info']) {
|
||||
$view_mode = false;
|
||||
} else {
|
||||
$view_mode = true;
|
||||
}
|
||||
|
||||
$urls = [];
|
||||
if (is_metaconsole()) {
|
||||
user_meta_print_header();
|
||||
$urls['main'] = 'index.php?sec=advanced&sec2=advanced/users_setup&tab=user_edit';
|
||||
} else {
|
||||
$urls['main'] = 'index.php?sec=workspace&sec2=operation/users/user_edit';
|
||||
$urls['notifications'] = 'index.php?sec=workspace&sec2=operation/users/user_edit_notifications';
|
||||
$buttons = [
|
||||
'main' => [
|
||||
'active' => $_GET['sec2'] === 'operation/users/user_edit',
|
||||
'text' => "<a href='{$urls['main']}'>".html_print_image(
|
||||
'images/user_green.png',
|
||||
true,
|
||||
['title' => __('User management')]
|
||||
).'</a>',
|
||||
],
|
||||
'notifications' => [
|
||||
'active' => $_GET['sec2'] === 'operation/users/user_edit_notifications',
|
||||
'text' => "<a href='{$urls['notifications']}'>".html_print_image(
|
||||
'images/alerts_template.png',
|
||||
true,
|
||||
['title' => __('User notifications')]
|
||||
).'</a>',
|
||||
],
|
||||
];
|
||||
|
||||
ui_print_page_header(
|
||||
__('User detail editor'),
|
||||
'images/op_workspace.png',
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
$buttons
|
||||
);
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// Load global vars
|
||||
global $config;
|
||||
|
||||
// Includes.
|
||||
require_once $config['homedir'].'/include/functions_notifications.php';
|
||||
|
||||
// Load the header
|
||||
require $config['homedir'].'/operation/users/user_edit_header.php';
|
||||
|
||||
if (get_parameter('change_label', 0)) {
|
||||
$label = get_parameter('label', '');
|
||||
$source = get_parameter('source', 0);
|
||||
$user = get_parameter('user', '');
|
||||
$value = get_parameter('value', 0) ? 1 : 0;
|
||||
|
||||
// Update the label value.
|
||||
ob_clean();
|
||||
echo json_encode(
|
||||
[
|
||||
'result' => notifications_set_user_label_status(
|
||||
$source,
|
||||
$user,
|
||||
$label,
|
||||
$value
|
||||
),
|
||||
]
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// User notification table. It is just a wrapper.
|
||||
$table_content = new StdClass();
|
||||
$table_content->data = [];
|
||||
$table_content->width = '100%';
|
||||
$table_content->id = 'user-notifications-wrapper';
|
||||
$table_content->class = 'databox filters';
|
||||
$table_content->size[0] = '33%';
|
||||
$table_content->size[1] = '33%';
|
||||
$table_content->size[2] = '33%';
|
||||
|
||||
// Print the header.
|
||||
$table_content->data[] = [
|
||||
'',
|
||||
__('Enable'),
|
||||
__('Also receive an email'),
|
||||
];
|
||||
|
||||
$sources = notifications_get_all_sources();
|
||||
foreach ($sources as $source) {
|
||||
$table_content->data[] = [
|
||||
$source['description'],
|
||||
notifications_print_user_switch($source, $id, 'enabled'),
|
||||
notifications_print_user_switch($source, $id, 'also_mail'),
|
||||
];
|
||||
}
|
||||
|
||||
html_print_table($table_content);
|
||||
|
||||
// Print id user to handle it on js.
|
||||
html_print_input_hidden('id_user', $id);
|
||||
|
||||
?>
|
||||
<script>
|
||||
// Encapsulate the code
|
||||
(function() {
|
||||
function notifications_change_label(event) {
|
||||
event.preventDefault();
|
||||
var check = document.getElementById(event.target.id);
|
||||
if (check === null) return;
|
||||
|
||||
var match = /notifications-user-([0-9]+)-label-(.*)/
|
||||
.exec(event.target.id);
|
||||
|
||||
jQuery.post ("ajax.php",
|
||||
{
|
||||
"page" : "operation/users/user_edit_notifications",
|
||||
"change_label" : 1,
|
||||
"label" : match[2],
|
||||
"source" : match[1],
|
||||
"user" : document.getElementById('hidden-id_user').value,
|
||||
"value": check.checked ? 1 : 0
|
||||
},
|
||||
function (data, status) {
|
||||
if (!data.result) {
|
||||
console.error("Error changing configuration in database.");
|
||||
} else {
|
||||
check.checked = !check.checked;
|
||||
}
|
||||
},
|
||||
"json"
|
||||
).done(function(m){})
|
||||
.fail(function(xhr, textStatus, errorThrown){
|
||||
console.error(
|
||||
"Cannot change configuration in database. Server error.",
|
||||
xhr.responseText
|
||||
);
|
||||
});
|
||||
|
||||
}
|
||||
var all_labels = document.getElementsByClassName(
|
||||
'notifications-user-label_individual'
|
||||
);
|
||||
for (var i = 0; i < all_labels.length; i++) {
|
||||
all_labels[i].addEventListener(
|
||||
'click', notifications_change_label, false
|
||||
);
|
||||
}
|
||||
}());
|
||||
</script>
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.731
|
||||
%define release 190225
|
||||
%define release 190226
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.731
|
||||
%define release 190225
|
||||
%define release 190226
|
||||
%define httpd_name httpd
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name apache2
|
||||
|
|
|
@ -655,6 +655,19 @@ CREATE TABLE IF NOT EXISTS `tevento` (
|
|||
-- Criticity: 3 - Warning (yellow) (status 2)
|
||||
-- Criticity: 4 - Critical (red) (status 1)
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tevent_extended`
|
||||
-- ---------------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tevent_extended` (
|
||||
`id` serial PRIMARY KEY,
|
||||
`id_evento` bigint(20) unsigned NOT NULL,
|
||||
`external_id` bigint(20) unsigned,
|
||||
`utimestamp` bigint(20) NOT NULL default '0',
|
||||
`description` text,
|
||||
FOREIGN KEY `tevent_ext_fk`(`id_evento`) REFERENCES `tevento`(`id_evento`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tgrupo`
|
||||
-- ---------------------------------------------------------------------
|
||||
|
@ -719,20 +732,6 @@ CREATE TABLE IF NOT EXISTS `tlink` (
|
|||
PRIMARY KEY (`id_link`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `tmensajes`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tmensajes` (
|
||||
`id_mensaje` int(10) unsigned NOT NULL auto_increment,
|
||||
`id_usuario_origen` varchar(60) NOT NULL default '',
|
||||
`id_usuario_destino` varchar(60) NOT NULL default '',
|
||||
`mensaje` text NOT NULL,
|
||||
`timestamp` bigint (20) unsigned NOT NULL default '0',
|
||||
`subject` varchar(255) NOT NULL default '',
|
||||
`estado` int(4) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`id_mensaje`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Table `tmodule_group`
|
||||
-- ----------------------------------------------------------------------
|
||||
|
@ -783,6 +782,9 @@ CREATE TABLE IF NOT EXISTS `trecon_task` (
|
|||
`snmp_privacy_method` varchar(25) NOT NULL default '',
|
||||
`snmp_privacy_pass` varchar(255) NOT NULL default '',
|
||||
`snmp_security_level` varchar(25) NOT NULL default '',
|
||||
`wmi_enabled` tinyint(1) unsigned DEFAULT '0',
|
||||
`auth_strings` text,
|
||||
`autoconfiguration_enabled` tinyint(1) unsigned default '0',
|
||||
PRIMARY KEY (`id_rt`),
|
||||
KEY `recon_task_daemon` (`id_recon_server`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
@ -1177,6 +1179,113 @@ CREATE TABLE IF NOT EXISTS `treset_pass_history` (
|
|||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `tnotification_source`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE `tnotification_source` (
|
||||
`id` serial,
|
||||
`description` VARCHAR(255) DEFAULT NULL,
|
||||
`icon` text,
|
||||
`max_postpone_time` int(11) DEFAULT NULL,
|
||||
`enabled` int(1) DEFAULT NULL,
|
||||
`user_editable` int(1) DEFAULT NULL,
|
||||
`also_mail` int(1) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `tmensajes`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tmensajes` (
|
||||
`id_mensaje` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_usuario_origen` VARCHAR(60) NOT NULL DEFAULT '',
|
||||
`mensaje` TEXT NOT NULL,
|
||||
`timestamp` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`subject` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`estado` INT(4) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`url` TEXT,
|
||||
`response_mode` VARCHAR(200) DEFAULT NULL,
|
||||
`citicity` INT(10) UNSIGNED DEFAULT '0',
|
||||
`id_source` BIGINT(20) UNSIGNED NOT NULL,
|
||||
`subtype` VARCHAR(255) DEFAULT '',
|
||||
PRIMARY KEY (`id_mensaje`),
|
||||
UNIQUE KEY `id_mensaje` (`id_mensaje`),
|
||||
KEY `tsource_fk` (`id_source`),
|
||||
CONSTRAINT `tsource_fk` FOREIGN KEY (`id_source`) REFERENCES `tnotification_source` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Table `tnotification_user`
|
||||
-- ----------------------------------------------------------------------
|
||||
CREATE TABLE `tnotification_user` (
|
||||
`id_mensaje` INT(10) UNSIGNED NOT NULL,
|
||||
`id_user` VARCHAR(60) NOT NULL,
|
||||
`utimestamp_read` BIGINT(20),
|
||||
`utimestamp_erased` BIGINT(20),
|
||||
`postpone` INT,
|
||||
PRIMARY KEY (`id_mensaje`,`id_user`),
|
||||
FOREIGN KEY (`id_mensaje`) REFERENCES `tmensajes`(`id_mensaje`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Table `tnotification_group`
|
||||
-- ----------------------------------------------------------------------
|
||||
CREATE TABLE `tnotification_group` (
|
||||
`id_mensaje` INT(10) UNSIGNED NOT NULL,
|
||||
`id_group` mediumint(4) UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (`id_mensaje`,`id_group`),
|
||||
FOREIGN KEY (`id_mensaje`) REFERENCES `tmensajes`(`id_mensaje`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Table `tnotification_source_user`
|
||||
-- ----------------------------------------------------------------------
|
||||
CREATE TABLE `tnotification_source_user` (
|
||||
`id_source` BIGINT(20) UNSIGNED NOT NULL,
|
||||
`id_user` VARCHAR(60),
|
||||
`enabled` INT(1) DEFAULT NULL,
|
||||
`also_mail` INT(1) DEFAULT NULL,
|
||||
PRIMARY KEY (`id_source`,`id_user`),
|
||||
FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Table `tnotification_source_group`
|
||||
-- ----------------------------------------------------------------------
|
||||
CREATE TABLE `tnotification_source_group` (
|
||||
`id_source` BIGINT(20) UNSIGNED NOT NULL,
|
||||
`id_group` mediumint(4) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id_source`,`id_group`),
|
||||
INDEX (`id_group`),
|
||||
FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Table `tnotification_source_user`
|
||||
-- ----------------------------------------------------------------------
|
||||
CREATE TABLE `tnotification_source_group_user` (
|
||||
`id_source` BIGINT(20) UNSIGNED NOT NULL,
|
||||
`id_group` mediumint(4) unsigned NOT NULL,
|
||||
`id_user` VARCHAR(60),
|
||||
`enabled` INT(1) DEFAULT NULL,
|
||||
`also_mail` INT(1) DEFAULT NULL,
|
||||
PRIMARY KEY (`id_source`,`id_user`),
|
||||
FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
FOREIGN KEY (`id_group`) REFERENCES `tnotification_source_group`(`id_group`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Table `tnews`
|
||||
-- ----------------------------------------------------------------------
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-server
|
||||
Version: 7.0NG.731-190225
|
||||
Version: 7.0NG.731-190226
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.731-190225"
|
||||
pandora_version="7.0NG.731-190226"
|
||||
|
||||
package_cpan=0
|
||||
package_pandora=1
|
||||
|
|
|
@ -33,7 +33,7 @@ use PandoraFMS::Core;
|
|||
use PandoraFMS::DataServer;
|
||||
use PandoraFMS::NetworkServer;
|
||||
use PandoraFMS::SNMPServer;
|
||||
use PandoraFMS::ReconServer;
|
||||
use PandoraFMS::DiscoveryServer;
|
||||
use PandoraFMS::WMIServer;
|
||||
use PandoraFMS::PluginServer;
|
||||
use PandoraFMS::PredictionServer;
|
||||
|
@ -123,7 +123,7 @@ sub pandora_startup () {
|
|||
pandora_reset_server (\%Config, $DBH);
|
||||
push (@Servers, new PandoraFMS::DataServer (\%Config, $DBH));
|
||||
push (@Servers, new PandoraFMS::NetworkServer (\%Config, $DBH));
|
||||
push (@Servers, new PandoraFMS::ReconServer (\%Config, $DBH));
|
||||
push (@Servers, new PandoraFMS::DiscoveryServer (\%Config, $DBH));
|
||||
push (@Servers, new PandoraFMS::SNMPServer (\%Config, $DBH));
|
||||
push (@Servers, new PandoraFMS::WMIServer (\%Config, $DBH));
|
||||
push (@Servers, new PandoraFMS::PluginServer (\%Config, $DBH));
|
||||
|
|
|
@ -45,7 +45,7 @@ our @EXPORT = qw(
|
|||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "7.0NG.731";
|
||||
my $pandora_build = "190225";
|
||||
my $pandora_build = "190226";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
# Setup hash
|
||||
|
@ -226,7 +226,7 @@ sub pandora_load_config {
|
|||
$pa_config->{"dataserver"} = 1; # default
|
||||
$pa_config->{"networkserver"} = 1; # default
|
||||
$pa_config->{"snmpconsole"} = 1; # default
|
||||
$pa_config->{"reconserver"} = 1; # default
|
||||
$pa_config->{"discoveryserver"} = 1; # default
|
||||
$pa_config->{"wmiserver"} = 1; # default
|
||||
$pa_config->{"pluginserver"} = 1; # default
|
||||
$pa_config->{"predictionserver"} = 1; # default
|
||||
|
@ -254,6 +254,7 @@ sub pandora_load_config {
|
|||
$pa_config->{"plugin_threads"} = 2; # Introduced on 2.0
|
||||
$pa_config->{"plugin_exec"} = '/usr/bin/timeout'; # 3.0
|
||||
$pa_config->{"recon_threads"} = 2; # Introduced on 2.0
|
||||
$pa_config->{"discovery_threads"} = 2; # Introduced on 732
|
||||
$pa_config->{"prediction_threads"} = 1; # Introduced on 2.0
|
||||
$pa_config->{"plugin_timeout"} = 5; # Introduced on 2.0
|
||||
$pa_config->{"wmi_threads"} = 2; # Introduced on 2.0
|
||||
|
@ -659,8 +660,8 @@ sub pandora_load_config {
|
|||
elsif ($parametro =~ m/^predictionserver\s+([0-9]*)/i){
|
||||
$pa_config->{'predictionserver'}= clean_blank($1);
|
||||
}
|
||||
elsif ($parametro =~ m/^reconserver\s+([0-9]*)/i) {
|
||||
$pa_config->{'reconserver'}= clean_blank($1);
|
||||
elsif ($parametro =~ m/^discoveryserver\s+([0-9]*)/i) {
|
||||
$pa_config->{'discoveryserver'}= clean_blank($1);
|
||||
}
|
||||
elsif ($parametro =~ m/^reconserver\s+([0-9]*)/i) {
|
||||
$pa_config->{'reconserver'}= clean_blank($1);
|
||||
|
@ -809,6 +810,9 @@ sub pandora_load_config {
|
|||
elsif ($parametro =~ m/^autocreate_group\s+([0-9*]*)/i) {
|
||||
$pa_config->{'autocreate_group'}= clean_blank($1);
|
||||
}
|
||||
elsif ($parametro =~ m/^discovery_threads\s+([0-9]*)/i) {
|
||||
$pa_config->{'discovery_threads'}= clean_blank($1);
|
||||
}
|
||||
elsif ($parametro =~ m/^recon_threads\s+([0-9]*)/i) {
|
||||
$pa_config->{'recon_threads'}= clean_blank($1);
|
||||
}
|
||||
|
|
|
@ -179,6 +179,7 @@ our @EXPORT = qw(
|
|||
pandora_evaluate_alert
|
||||
pandora_evaluate_snmp_alerts
|
||||
pandora_event
|
||||
pandora_extended_event
|
||||
pandora_execute_alert
|
||||
pandora_execute_action
|
||||
pandora_exec_forced_alerts
|
||||
|
@ -250,6 +251,7 @@ our @EXPORT = qw(
|
|||
pandora_delete_graph_source
|
||||
pandora_delete_custom_graph
|
||||
pandora_edit_custom_graph
|
||||
notification_set_targets
|
||||
);
|
||||
|
||||
# Some global variables
|
||||
|
@ -1460,6 +1462,35 @@ sub pandora_execute_action ($$$$$$$$$;$) {
|
|||
|
||||
pandora_create_integria_ticket($pa_config, $api_path, $api_pass, $integria_user, $integria_user_pass, $ticket_name, $ticket_group_id, $ticket_priority, $ticket_email, $ticket_owner, $ticket_description);
|
||||
|
||||
|
||||
# Generate notification
|
||||
} elsif ($clean_name eq "Generate Notification") {
|
||||
|
||||
# Translate macros
|
||||
$field3 = subst_alert_macros($field3, \%macros, $pa_config, $dbh, $agent, $module);
|
||||
$field4 = subst_alert_macros($field4, \%macros, $pa_config, $dbh, $agent, $module);
|
||||
|
||||
# If no targets ignore notification
|
||||
if (defined($field1) && defined($field2) && ($field1 ne "" || $field2 ne "")) {
|
||||
my @user_list = map {clean_blank($_)} split /,/, $field1;
|
||||
my @group_list = map {clean_blank($_)} split /,/, $field2;
|
||||
|
||||
my $notification = {};
|
||||
$notification->{'subject'} = safe_input($field3);
|
||||
$notification->{'mensaje'} = safe_input($field4);
|
||||
$notification->{'id_source'} = get_db_value($dbh, 'SELECT id FROM tnotification_source WHERE description = ?', safe_input('System status'));
|
||||
|
||||
# Create message
|
||||
my $notification_id = db_process_insert($dbh,'id_mensaje','tmensajes',$notification);
|
||||
if (!$notification_id) {
|
||||
logger($pa_config, "Failed action '" . $action->{'name'} . "' for alert '". $alert->{'name'} . "' agent '" . (defined($agent) ? $agent->{'alias'} : 'N/A') . "'.", 3);
|
||||
} else {
|
||||
notification_set_targets($pa_config, $dbh, $notification_id, \@user_list, \@group_list);
|
||||
}
|
||||
} else {
|
||||
logger($pa_config, "Failed action '" . $action->{'name'} . "' for alert '". $alert->{'name'} . "' agent '" . (defined($agent) ? $agent->{'alias'} : 'N/A') . "' Empty targets. Ignored.", 3);
|
||||
}
|
||||
|
||||
# Unknown
|
||||
} else {
|
||||
logger($pa_config, "Unknown action '" . $action->{'name'} . "' for alert '". $alert->{'name'} . "' agent '" . (defined ($agent) ? $agent->{'alias'} : 'N/A') . "'.", 3);
|
||||
|
@ -3241,11 +3272,11 @@ sub pandora_event ($$$$$$$$$$;$$$$$$$$$$$) {
|
|||
|
||||
# Create the event
|
||||
logger($pa_config, "Generating event '$evento' for agent ID $id_agente module ID $id_agentmodule.", 10);
|
||||
db_do ($dbh, 'INSERT INTO ' . $event_table . ' (id_agente, id_grupo, evento, timestamp, estado, utimestamp, event_type, id_agentmodule, id_alert_am, criticity, user_comment, tags, source, id_extra, id_usuario, critical_instructions, warning_instructions, unknown_instructions, ack_utimestamp, custom_data, data, module_status)
|
||||
my $event_id = db_insert ($dbh, 'id_evento','INSERT INTO ' . $event_table . ' (id_agente, id_grupo, evento, timestamp, estado, utimestamp, event_type, id_agentmodule, id_alert_am, criticity, user_comment, tags, source, id_extra, id_usuario, critical_instructions, warning_instructions, unknown_instructions, ack_utimestamp, custom_data, data, module_status)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id_agente, $id_grupo, safe_input ($evento), $timestamp, $event_status, $utimestamp, $event_type, $id_agentmodule, $id_alert_am, $severity, $comment, $module_tags, $source, $id_extra, $user_name, $critical_instructions, $warning_instructions, $unknown_instructions, $ack_utimestamp, $custom_data, $module_data, $module_status);
|
||||
|
||||
|
||||
# Do not write to the event file
|
||||
return if ($pa_config->{'event_file'} eq '');
|
||||
return $event_id if ($pa_config->{'event_file'} eq '');
|
||||
|
||||
# Add a header when the event file is created
|
||||
my $header = undef;
|
||||
|
@ -3256,7 +3287,7 @@ sub pandora_event ($$$$$$$$$$;$$$$$$$$$$$) {
|
|||
# Open the event file for writing
|
||||
if (! open (EVENT_FILE, '>>' . $pa_config->{'event_file'})) {
|
||||
logger($pa_config, "Error opening event file " . $pa_config->{'event_file'} . ": $!", 10);
|
||||
return;
|
||||
return $event_id;
|
||||
}
|
||||
|
||||
# Resolve ids
|
||||
|
@ -3279,6 +3310,29 @@ sub pandora_event ($$$$$$$$$$;$$$$$$$$$$$) {
|
|||
print EVENT_FILE "$agent_name,".safe_output($group_name)."," . safe_output ($evento) . ",$timestamp,$event_status,$utimestamp,$event_type,".safe_output($module_name).",".safe_output($alert_name).",$severity,".safe_output($comment).",".safe_output($module_tags).",$source,$id_extra,$user_name,".safe_output($critical_instructions).",".safe_output($warning_instructions).",".safe_output($unknown_instructions).",$ack_utimestamp\n";
|
||||
|
||||
close (EVENT_FILE);
|
||||
|
||||
return $event_id;
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
=head2 C<< pandora_extended_event (I<$pa_config>, I<$dbh>, I<$event_id>, I<$description>) >>
|
||||
|
||||
Creates an extended event linked to an existing main event id.
|
||||
|
||||
=cut
|
||||
##########################################################################
|
||||
sub pandora_extended_event($$$$) {
|
||||
my ($pa_config, $dbh, $event_id, $description) = @_;
|
||||
|
||||
return unless defined($event_id) && "$event_id" ne "" && $event_id > 0;
|
||||
|
||||
return db_do(
|
||||
$dbh,
|
||||
'INSERT INTO tevent_extended (id_evento, utimestamp, description) VALUES (?,?,?)',
|
||||
$event_id,
|
||||
time(),
|
||||
safe_input($description)
|
||||
);
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
|
@ -4544,7 +4598,7 @@ sub pandora_server_statistics ($$) {
|
|||
$server->{"lag"} = 0;
|
||||
$server->{"module_lag"} = 0;
|
||||
# Recon server
|
||||
} elsif ($server->{"server_type"} == RECONSERVER) {
|
||||
} elsif ($server->{"server_type"} == DISCOVERYSERVER) {
|
||||
|
||||
# Total jobs running on this recon server
|
||||
$server->{"modules"} = get_db_value ($dbh, "SELECT COUNT(id_rt) FROM trecon_task WHERE id_recon_server = ?", $server->{"id_server"});
|
||||
|
@ -5776,6 +5830,62 @@ sub pandora_safe_mode_modules_update {
|
|||
}
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
|
||||
=head2 C<< message_set_targets (I<$dbh>, I<$pa_config>, I<$notification_id>, I<$users>, I<$groups>) >>
|
||||
Set targets for given messaje (users and groups in hash ref)
|
||||
=cut
|
||||
|
||||
##########################################################################
|
||||
sub notification_set_targets {
|
||||
my ($pa_config, $dbh, $notification_id, $users, $groups) = @_;
|
||||
my $ret = undef;
|
||||
|
||||
if (!defined($pa_config)) {
|
||||
return undef;
|
||||
}
|
||||
|
||||
if (!defined($notification_id)) {
|
||||
return undef;
|
||||
}
|
||||
|
||||
if (ref($users) eq "ARRAY") {
|
||||
my $values = {};
|
||||
foreach my $user (@{$users}) {
|
||||
if (defined($user) && $user eq "") {
|
||||
next;
|
||||
}
|
||||
|
||||
$values->{'id_mensaje'} = $notification_id;
|
||||
$values->{'id_user'} = $user;
|
||||
}
|
||||
|
||||
$ret = db_process_insert($dbh, '', 'tnotification_user', $values);
|
||||
if (!$ret) {
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
|
||||
if (ref($groups) eq "ARRAY") {
|
||||
my $values = {};
|
||||
foreach my $group (@{$groups}) {
|
||||
if ($group != 0 && empty($group)) {
|
||||
next;
|
||||
}
|
||||
|
||||
$values->{'id_mensaje'} = $notification_id;
|
||||
$values->{'id_group'} = $group;
|
||||
}
|
||||
|
||||
$ret = db_process_insert($dbh, '', 'tnotification_group', $values);
|
||||
if (!$ret) {
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
# End of function declaration
|
||||
# End of defined Code
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ package PandoraFMS::DB;
|
|||
use strict;
|
||||
use warnings;
|
||||
use DBI;
|
||||
|
||||
use lib '/usr/lib/perl5';
|
||||
use PandoraFMS::Tools;
|
||||
|
||||
#use Data::Dumper;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package PandoraFMS::ReconServer;
|
||||
package PandoraFMS::DiscoveryServer;
|
||||
##########################################################################
|
||||
# Pandora FMS Recon Server.
|
||||
# Pandora FMS Discovery Server.
|
||||
# Pandora FMS. the Flexible Monitoring System. http://www.pandorafms.org
|
||||
##########################################################################
|
||||
# Copyright (c) 2005-2009 Artica Soluciones Tecnologicas S.L
|
||||
|
@ -28,6 +28,7 @@ use IO::Socket::INET;
|
|||
use POSIX qw(strftime ceil);
|
||||
use JSON qw(decode_json encode_json);
|
||||
use Encode qw(encode_utf8);
|
||||
use MIME::Base64;
|
||||
|
||||
# Default lib dir for RPM and DEB packages
|
||||
use lib '/usr/lib/perl5';
|
||||
|
@ -57,16 +58,16 @@ use constant OS_ROUTER => 17;
|
|||
use constant OS_SWITCH => 18;
|
||||
|
||||
########################################################################################
|
||||
# Recon Server class constructor.
|
||||
# Discovery Server class constructor.
|
||||
########################################################################################
|
||||
sub new ($$$$$$) {
|
||||
my ($class, $config, $dbh) = @_;
|
||||
|
||||
return undef unless $config->{'reconserver'} == 1;
|
||||
return undef unless $config->{'reconserver'} == 1 || $config->{'discoveryserver'} == 1;
|
||||
|
||||
if (! -e $config->{'nmap'}) {
|
||||
logger ($config, ' [E] ' . $config->{'nmap'} . " needed by " . $config->{'rb_product_name'} . " Recon Server not found.", 1);
|
||||
print_message ($config, ' [E] ' . $config->{'nmap'} . " needed by " . $config->{'rb_product_name'} . " Recon Server not found.", 1);
|
||||
logger ($config, ' [E] ' . $config->{'nmap'} . " needed by " . $config->{'rb_product_name'} . " Discovery Server not found.", 1);
|
||||
print_message ($config, ' [E] ' . $config->{'nmap'} . " needed by " . $config->{'rb_product_name'} . " Discovery Server not found.", 1);
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
@ -78,14 +79,14 @@ sub new ($$$$$$) {
|
|||
|
||||
# Restart automatic recon tasks.
|
||||
db_do ($dbh, 'UPDATE trecon_task SET utimestamp = 0 WHERE id_recon_server = ? AND status <> -1 AND interval_sweep > 0',
|
||||
get_server_id ($dbh, $config->{'servername'}, RECONSERVER));
|
||||
get_server_id ($dbh, $config->{'servername'}, DISCOVERYSERVER));
|
||||
|
||||
# Reset (but do not restart) manual recon tasks.
|
||||
db_do ($dbh, 'UPDATE trecon_task SET status = -1 WHERE id_recon_server = ? AND status <> -1 AND interval_sweep = 0',
|
||||
get_server_id ($dbh, $config->{'servername'}, RECONSERVER));
|
||||
get_server_id ($dbh, $config->{'servername'}, DISCOVERYSERVER));
|
||||
|
||||
# Call the constructor of the parent class
|
||||
my $self = $class->SUPER::new($config, RECONSERVER, \&PandoraFMS::ReconServer::data_producer, \&PandoraFMS::ReconServer::data_consumer, $dbh);
|
||||
my $self = $class->SUPER::new($config, DISCOVERYSERVER, \&PandoraFMS::DiscoveryServer::data_producer, \&PandoraFMS::DiscoveryServer::data_consumer, $dbh);
|
||||
|
||||
bless $self, $class;
|
||||
return $self;
|
||||
|
@ -98,8 +99,14 @@ sub run ($) {
|
|||
my $self = shift;
|
||||
my $pa_config = $self->getConfig ();
|
||||
|
||||
print_message ($pa_config, " [*] Starting " . $pa_config->{'rb_product_name'} . " Recon Server.", 1);
|
||||
$self->setNumThreads ($pa_config->{'recon_threads'});
|
||||
print_message ($pa_config, " [*] Starting " . $pa_config->{'rb_product_name'} . " Discovery Server.", 1);
|
||||
my $threads = $pa_config->{'recon_threads'};
|
||||
|
||||
# Use hightest value
|
||||
if ($pa_config->{'discovery_threads'} > $pa_config->{'recon_threads'}) {
|
||||
$threads = $pa_config->{'discovery_threads'};
|
||||
}
|
||||
$self->setNumThreads($threads);
|
||||
$self->SUPER::run (\@TaskQueue, \%PendingTasks, $Sem, $TaskSem);
|
||||
}
|
||||
|
||||
|
@ -121,9 +128,10 @@ sub data_producer ($) {
|
|||
# Status -1 means "done".
|
||||
|
||||
my @rows = get_db_rows ($dbh, 'SELECT * FROM trecon_task
|
||||
WHERE id_recon_server = ?
|
||||
AND disabled = 0
|
||||
AND utimestamp = 0 OR (status = -1 AND interval_sweep > 0 AND (utimestamp + interval_sweep) < UNIX_TIMESTAMP())', $server_id);
|
||||
WHERE id_recon_server = ?
|
||||
AND disabled = 0
|
||||
AND ((utimestamp = 0 AND interval_sweep != 0 OR status = 1)
|
||||
OR (status = -1 AND interval_sweep > 0 AND (utimestamp + interval_sweep) < UNIX_TIMESTAMP()))', $server_id);
|
||||
foreach my $row (@rows) {
|
||||
|
||||
# Update task status
|
||||
|
@ -154,12 +162,15 @@ sub data_consumer ($$) {
|
|||
logger($pa_config, 'Starting recon task for net ' . $task->{'subnet'} . '.', 10);
|
||||
}
|
||||
|
||||
# Call nmap
|
||||
my $nmap_args = '-nsP -PE --max-retries '.$pa_config->{'icmp_checks'}.' --host-timeout '.$pa_config->{'networktimeout'}.'s -T'.$pa_config->{'recon_timing_template'};
|
||||
my $np = new PandoraFMS::NmapParser;
|
||||
eval {
|
||||
my @subnets = split(/,/, safe_output($task->{'subnet'}));
|
||||
my @communities = split(/,/, safe_output($task->{'snmp_community'}));
|
||||
my @auth_strings = ();
|
||||
if(defined($task->{'auth_strings'})) {
|
||||
@auth_strings = split(/,/, safe_output($task->{'auth_strings'}));
|
||||
}
|
||||
|
||||
my $main_event = pandora_event($pa_config, "[Discovery] Execution summary",$task->{'id_group'}, 0, 0, 0, 0, 'system', 0, $dbh);
|
||||
|
||||
my $recon = new PandoraFMS::Recon::Base(
|
||||
communities => \@communities,
|
||||
|
@ -186,6 +197,10 @@ sub data_consumer ($$) {
|
|||
subnets => \@subnets,
|
||||
task_id => $task->{'id_rt'},
|
||||
vlan_cache_enabled => $task->{'vlan_enabled'},
|
||||
wmi_enabled => $task->{'wmi_enabled'},
|
||||
auth_strings_array => \@auth_strings,
|
||||
autoconfiguration_enabled => $task->{'autoconfiguration_enabled'},
|
||||
main_event_id => $main_event,
|
||||
%{$pa_config}
|
||||
);
|
||||
|
||||
|
@ -225,7 +240,13 @@ sub exec_recon_script ($$$) {
|
|||
# \r and \n should be escaped for decode_json().
|
||||
$macros =~ s/\n/\\n/g;
|
||||
$macros =~ s/\r/\\r/g;
|
||||
my $decoded_macros = decode_json (encode_utf8($macros));
|
||||
my $decoded_macros;
|
||||
|
||||
if ($macros) {
|
||||
eval {
|
||||
$decoded_macros = decode_json(encode_utf8($macros));
|
||||
};
|
||||
}
|
||||
|
||||
my $macros_parameters = '';
|
||||
|
||||
|
@ -244,15 +265,28 @@ sub exec_recon_script ($$$) {
|
|||
$macros_parameters = $macros_parameters . ' "' . $m->{"value"} . '"';
|
||||
}
|
||||
}
|
||||
|
||||
my $ent_script = 0;
|
||||
my $args = enterprise_hook('discovery_custom_recon_scripts',[$pa_config, $dbh, $task, $script]);
|
||||
if (!$args) {
|
||||
$args = "$task->{'id_rt'} $task->{'id_group'} $task->{'create_incident'} $macros_parameters";
|
||||
} else {
|
||||
$ent_script = 1;
|
||||
}
|
||||
|
||||
if (-x $command) {
|
||||
`$command $task->{'id_rt'} $task->{'id_group'} $task->{'create_incident'} $macros_parameters`;
|
||||
my $exec_output = `$command $args`;
|
||||
logger($pa_config, "Execution output: \n". $exec_output, 10);
|
||||
} else {
|
||||
logger ($pa_config, "Cannot execute recon task command $command.");
|
||||
logger($pa_config, "Cannot execute recon task command $command.", 10);
|
||||
}
|
||||
|
||||
# Only update the timestamp in case something went wrong. The script should set the status.
|
||||
db_do ($dbh, 'UPDATE trecon_task SET utimestamp = ? WHERE id_rt = ?', time (), $task->{'id_rt'});
|
||||
|
||||
if ($ent_script == 1) {
|
||||
enterprise_hook('discovery_clean_custom_recon',[$pa_config, $dbh, $task, $script]);
|
||||
}
|
||||
|
||||
logger($pa_config, 'Done executing recon script ' . safe_output($script->{'name'}), 10);
|
||||
return 0;
|
||||
|
@ -441,7 +475,23 @@ sub PandoraFMS::Recon::Base::create_agent($$) {
|
|||
$location->{'longitude'}, $location->{'latitude'}
|
||||
);
|
||||
return undef unless defined ($agent_id) and ($agent_id > 0);
|
||||
pandora_event($self->{'pa_config'}, "[RECON] New " . safe_output($self->get_device_type($device)) . " found (" . join(',', safe_output($self->get_addresses($device))) . ").", $self->{'group_id'}, $agent_id, 2, 0, 0, 'recon_host_detected', 0, $self->{'dbh'});
|
||||
|
||||
# Autoconfigure agent
|
||||
if (defined($self->{'autoconfiguration_enabled'}) && $self->{'autoconfiguration_enabled'} == 1) {
|
||||
my $agent_data = PandoraFMS::DB::get_db_single_row($self->{'dbh'}, 'SELECT * FROM tagente WHERE id_agente = ?', $agent_id);
|
||||
# Update agent configuration once, after create agent.
|
||||
enterprise_hook('autoconfigure_agent', [$self->{'pa_config'}, $host_name, $agent_id, $agent_data, $self->{'dbh'}, 1]);
|
||||
}
|
||||
|
||||
if (defined($self->{'main_event_id'})) {
|
||||
my $addresses_str = join(',', safe_output($self->get_addresses($device)));
|
||||
pandora_extended_event(
|
||||
$self->{'pa_config'}, $self->{'dbh'}, $self->{'main_event_id'},
|
||||
"[Discovery] New " . safe_output($self->get_device_type($device)) . " found " . $host_name . " (" . $addresses_str . ") Agent $agent_id."
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
$agent_learning = 1;
|
||||
|
||||
# Create network profile modules for the agent
|
||||
|
@ -748,6 +798,35 @@ sub PandoraFMS::Recon::Base::set_parent($$$) {
|
|||
db_do($self->{'dbh'}, 'UPDATE tagente SET id_parent=? WHERE id_agente=?', $agent_parent->{'id_agente'}, $agent->{'id_agente'});
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# Create a WMI module for the given agent.
|
||||
##########################################################################
|
||||
sub PandoraFMS::Recon::Base::wmi_module {
|
||||
my ($self, $agent_id, $target, $wmi_query, $wmi_auth, $column,
|
||||
$module_name, $module_description, $module_type, $unit) = @_;
|
||||
|
||||
# Check whether the module already exists.
|
||||
my $module_id = get_agent_module_id($self->{'dbh'}, $module_name, $agent_id);
|
||||
return if ($module_id > 0);
|
||||
|
||||
my ($user, $pass) = ($wmi_auth ne '') ? split('%', $wmi_auth) : (undef, undef);
|
||||
my %module = (
|
||||
'descripcion' => safe_input($module_description),
|
||||
'id_agente' => $agent_id,
|
||||
'id_modulo' => 6,
|
||||
'id_tipo_modulo' => get_module_id($self->{'dbh'}, $module_type),
|
||||
'ip_target' => $target,
|
||||
'nombre' => safe_input($module_name),
|
||||
'plugin_pass' => defined($pass) ? $pass : '',
|
||||
'plugin_user' => defined($user) ? $user : '',
|
||||
'snmp_oid' => $wmi_query,
|
||||
'tcp_port' => $column,
|
||||
'unit' => defined($unit) ? $unit : ''
|
||||
);
|
||||
|
||||
pandora_create_module_from_hash($self->{'pa_config'}, \%module, $self->{'dbh'});
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# Update recon task status.
|
||||
##########################################################################
|
|
@ -32,7 +32,7 @@ our @ISA = qw(Exporter);
|
|||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "7.0NG.731";
|
||||
my $pandora_build = "190225";
|
||||
my $pandora_build = "190226";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
|
||||
|
@ -163,6 +163,8 @@ sub csv_to_obj {
|
|||
@hr_headers = map { $_ =~ s/\"//g; trim($_); } @hr_headers;
|
||||
|
||||
foreach my $line (@lines) {
|
||||
next if empty($line);
|
||||
|
||||
my $i = 0;
|
||||
my %hr = map { $_ =~ s/\"//g; $hr_headers[$i++] => trim($_) } split /,/, $line;
|
||||
|
||||
|
|
|
@ -123,6 +123,12 @@ sub new {
|
|||
# Globally enable/disable SNMP scans.
|
||||
snmp_enabled => 1,
|
||||
|
||||
# Globally enable/disable WMI scans.
|
||||
wmi_enabled => 0,
|
||||
auth_strings_array => [],
|
||||
wmi_timeout => 3,
|
||||
timeout_cmd => '',
|
||||
|
||||
# Switch to switch connections. Used to properly connect hosts
|
||||
# that are connected to a switch wich is in turn connected to another switch,
|
||||
# since the hosts will show up in the latter's switch AFT too.
|
||||
|
@ -160,6 +166,7 @@ sub new {
|
|||
snmp_timeout => 2,
|
||||
snmp_version => 1,
|
||||
subnets => [],
|
||||
autoconfiguration_enabled => 0,
|
||||
@_,
|
||||
|
||||
};
|
||||
|
@ -217,6 +224,19 @@ sub new {
|
|||
}
|
||||
}
|
||||
|
||||
# Prepare auth array.
|
||||
# WMI could be launched with '-N' - no pass - argument.
|
||||
if ($self->{'wmi_enabled'} == 1){
|
||||
if (defined($self->{'auth_strings_str'})) {
|
||||
@{$self->{'auth_strings_array'}} = split(',', $self->{'auth_strings_str'});
|
||||
}
|
||||
|
||||
# Timeout available only in linux environments.
|
||||
if ($^O =~ /lin/i && defined($self->{'plugin_exec'}) && defined($self->{'wmi_timeout'})) {
|
||||
$self->{'timeout_cmd'} = $self->{'plugin_exec'}.' '.$self->{'wmi_timeout'}.' ';
|
||||
}
|
||||
}
|
||||
|
||||
# Remove all snmp related values if disabled
|
||||
if (!$self->{'snmp_enabled'}) {
|
||||
$self->{'communities'} = [];
|
||||
|
@ -1312,6 +1332,9 @@ sub scan_subnet($) {
|
|||
$progress += $step;
|
||||
|
||||
$self->snmp_discovery($host);
|
||||
|
||||
# Add wmi scan if enabled.
|
||||
$self->wmi_scan($host) if ($self->{'wmi_enabled'} == 1);
|
||||
}
|
||||
}
|
||||
# ping scan.
|
||||
|
@ -1330,6 +1353,9 @@ sub scan_subnet($) {
|
|||
next if ($self->ping($host) == 0);
|
||||
|
||||
$self->snmp_discovery($host);
|
||||
|
||||
# Add wmi scan if enabled.
|
||||
$self->wmi_scan($host) if ($self->{'wmi_enabled'} == 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1475,6 +1501,9 @@ sub snmp_get_command {
|
|||
|
||||
my $command = "snmpwalk -M/dev/null -r$self->{'snmp_checks'} -t$self->{'snmp_timeout'} -v$self->{'snmp_version'} -On -Oe ";
|
||||
if ($self->{'snmp_version'} eq "3") {
|
||||
if ($self->{'community'}) { # Context
|
||||
$command .= " -N $self->{'community'} ";
|
||||
}
|
||||
$command .= " -l$self->{'snmp_security_level'} ";
|
||||
if ($self->{'snmp_security_level'} ne "noAuthNoPriv") {
|
||||
$command .= " -u$self->{'snmp_auth_user'} -a$self->{'snmp_auth_method'} -A$self->{'snmp_auth_pass'} ";
|
||||
|
@ -1579,6 +1608,168 @@ sub traceroute_connectivity($$) {
|
|||
}
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# Returns the credentials with which the host responds to WMI queries or
|
||||
# undef if it does not respond to WMI.
|
||||
##########################################################################
|
||||
sub responds_to_wmi {
|
||||
my ($self, $target) = @_;
|
||||
|
||||
foreach my $auth (@{$self->{'auth_strings_array'}}) {
|
||||
my @output;
|
||||
if ($auth ne '') {
|
||||
@output = `$self->{'timeout_cmd'}$self->{'wmi_client'} -U $auth //$target "SELECT * FROM Win32_ComputerSystem" 2>&1`;
|
||||
} else {
|
||||
@output = `$self->{'timeout_cmd'}$self->{'wmi_client'} -N //$target "SELECT * FROM Win32_ComputerSystem" 2>&1`;
|
||||
}
|
||||
|
||||
foreach my $line (@output) {
|
||||
chomp($line);
|
||||
return $auth if ($line =~ m/^CLASS: Win32_ComputerSystem$/);
|
||||
}
|
||||
}
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# Add wmi modules to the given host.
|
||||
##########################################################################
|
||||
sub wmi_scan {
|
||||
my ($self, $target) = @_;
|
||||
|
||||
$self->call('message', "[".$target."] Checking WMI.", 5);
|
||||
|
||||
my $auth = $self->responds_to_wmi($target);
|
||||
return unless defined($auth);
|
||||
|
||||
$self->call('message', "[".$target."] WMI available.", 10);
|
||||
# Create the agent if it does not exist.
|
||||
my $agent_id = $self->call('create_agent', $target);
|
||||
next unless defined($agent_id);
|
||||
|
||||
# CPU.
|
||||
my @cpus = $self->wmi_get_value_array($target, $auth, 'SELECT DeviceId FROM Win32_Processor', 0);
|
||||
foreach my $cpu (@cpus) {
|
||||
$self->call(
|
||||
'wmi_module',
|
||||
(
|
||||
$agent_id,
|
||||
$target,
|
||||
"SELECT LoadPercentage FROM Win32_Processor WHERE DeviceId='$cpu'",
|
||||
$auth,
|
||||
1,
|
||||
"CPU Load $cpu",
|
||||
"Load for $cpu (%)",
|
||||
'generic_data'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
# Memory.
|
||||
my $mem = $self->wmi_get_value($target, $auth, 'SELECT FreePhysicalMemory FROM Win32_OperatingSystem', 0);
|
||||
if (defined($mem)) {
|
||||
$self->call('wmi_module',
|
||||
(
|
||||
$agent_id,
|
||||
$target,
|
||||
"SELECT FreePhysicalMemory, TotalVisibleMemorySize FROM Win32_OperatingSystem",
|
||||
$auth,
|
||||
0,
|
||||
'FreeMemory',
|
||||
'Free memory',
|
||||
'generic_data',
|
||||
'KB'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
# Disk.
|
||||
my @units = $self->wmi_get_value_array($target, $auth, 'SELECT DeviceID FROM Win32_LogicalDisk', 0);
|
||||
foreach my $unit (@units) {
|
||||
$self->call(
|
||||
'wmi_module',
|
||||
(
|
||||
$agent_id,
|
||||
$target,
|
||||
"SELECT FreeSpace FROM Win32_LogicalDisk WHERE DeviceID='$unit'",
|
||||
$auth,
|
||||
1,
|
||||
"FreeDisk $unit",
|
||||
'Available disk space in kilobytes',
|
||||
'generic_data',
|
||||
'KB'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# Extra: WMI imported methods. DO NOT EXPORT TO AVOID DOUBLE DEF.
|
||||
##########################################################################
|
||||
|
||||
##########################################################################
|
||||
# Performs a wmi get requests and returns the response as an array.
|
||||
##########################################################################
|
||||
sub wmi_get {
|
||||
my ($self, $target, $auth, $query) = @_;
|
||||
|
||||
my @output;
|
||||
if (defined($auth) && $auth ne '') {
|
||||
@output = `$self->{'timeout_cmd'}"$self->{'wmi_client'}" -U $auth //$target "$query" 2>&1`;
|
||||
}else {
|
||||
@output = `$self->{'timeout_cmd'}"$self->{'wmi_client'}" -N //$target "$query" 2>&1`;
|
||||
}
|
||||
|
||||
# Something went wrong.
|
||||
return () if ($? != 0);
|
||||
|
||||
return @output;
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# Performs a WMI request and returns the requested column of the first row.
|
||||
# Returns undef on error.
|
||||
##########################################################################
|
||||
sub wmi_get_value {
|
||||
my ($self, $target, $auth, $query, $column) = @_;
|
||||
my @result;
|
||||
|
||||
my @output = $self->wmi_get($target, $auth, $query);
|
||||
return undef unless defined($output[2]);
|
||||
|
||||
my $line = $output[2];
|
||||
chomp($line);
|
||||
my @columns = split(/\|/, $line);
|
||||
return undef unless defined($columns[$column]);
|
||||
|
||||
return $columns[$column];
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# Performs a WMI request and returns row values for the requested column
|
||||
# in an array.
|
||||
##########################################################################
|
||||
sub wmi_get_value_array {
|
||||
my ($self, $target, $auth, $query, $column) = @_;
|
||||
my @result;
|
||||
|
||||
my @output = $self->wmi_get($target, $auth, $query);
|
||||
foreach (my $i = 2; defined($output[$i]); $i++) {
|
||||
my $line = $output[$i];
|
||||
chomp($line);
|
||||
my @columns = split(/\|/, $line);
|
||||
next unless defined($columns[$column]);
|
||||
push(@result, $columns[$column]);
|
||||
}
|
||||
|
||||
return @result;
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# END: WMI imported methods.
|
||||
##########################################################################
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ our @EXPORT = qw(
|
|||
DATASERVER
|
||||
NETWORKSERVER
|
||||
SNMPCONSOLE
|
||||
RECONSERVER
|
||||
DISCOVERYSERVER
|
||||
PLUGINSERVER
|
||||
PREDICTIONSERVER
|
||||
WMISERVER
|
||||
|
@ -134,7 +134,7 @@ our @EXPORT = qw(
|
|||
use constant DATASERVER => 0;
|
||||
use constant NETWORKSERVER => 1;
|
||||
use constant SNMPCONSOLE => 2;
|
||||
use constant RECONSERVER => 3;
|
||||
use constant DISCOVERYSERVER => 3;
|
||||
use constant PLUGINSERVER => 4;
|
||||
use constant PREDICTIONSERVER => 5;
|
||||
use constant WMISERVER => 6;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.731
|
||||
%define release 190225
|
||||
%define release 190226
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.731
|
||||
%define release 190225
|
||||
%define release 190226
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.731"
|
||||
PI_BUILD="190225"
|
||||
PI_BUILD="190226"
|
||||
|
||||
MODE=$1
|
||||
if [ $# -gt 1 ]; then
|
||||
|
|
|
@ -34,7 +34,7 @@ use PandoraFMS::Config;
|
|||
use PandoraFMS::DB;
|
||||
|
||||
# version: define current version
|
||||
my $version = "7.0NG.731 PS190225";
|
||||
my $version = "7.0NG.731 PS190226";
|
||||
|
||||
# Pandora server configuration
|
||||
my %conf;
|
||||
|
@ -432,6 +432,13 @@ sub pandora_purgedb ($$) {
|
|||
|
||||
# Delete old tgraph_source data
|
||||
db_do ($dbh,"DELETE FROM tgraph_source WHERE id_graph NOT IN (SELECT id_graph FROM tgraph)");
|
||||
|
||||
# Delete old messages
|
||||
log_message ('PURGE', "Deleting old messages.");
|
||||
if ($conf->{'_delete_old_messages'} > 0) {
|
||||
my $message_limit = time() - 86400 * $conf->{'_delete_old_messages'};
|
||||
db_do ($dbh, "DELETE FROM tmensajes WHERE timestamp < ?", $message_limit);
|
||||
}
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
|
@ -651,6 +658,7 @@ sub pandora_load_config_pdb ($) {
|
|||
$conf->{'_history_db_delay'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_delay'");
|
||||
$conf->{'_days_delete_unknown'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'days_delete_unknown'");
|
||||
$conf->{'_inventory_purge'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'inventory_purge'");
|
||||
$conf->{'_delete_old_messages'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'delete_old_messages'");
|
||||
$conf->{'_enterprise_installed'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'enterprise_installed'");
|
||||
$conf->{'_metaconsole'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'metaconsole'");
|
||||
$conf->{'_metaconsole_events_history'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'metaconsole_events_history'");
|
||||
|
|
|
@ -36,7 +36,7 @@ use Encode::Locale;
|
|||
Encode::Locale::decode_argv;
|
||||
|
||||
# version: define current version
|
||||
my $version = "7.0NG.731 PS190225";
|
||||
my $version = "7.0NG.731 PS190226";
|
||||
|
||||
# save program name for logging
|
||||
my $progname = basename($0);
|
||||
|
|