Fixed conflict in CLI apply_policy
Former-commit-id: ab512d9c2b88cd7042d6ae065251cd116b2ea5af
|
@ -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-190215
|
||||
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-190215"
|
||||
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 => '190215';
|
||||
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 190215
|
||||
%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 190215
|
||||
%define release 190226
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.731"
|
||||
PI_BUILD="190215"
|
||||
PI_BUILD="190226"
|
||||
OS_NAME=`uname -s`
|
||||
|
||||
FORCE=0
|
||||
|
|
|
@ -186,7 +186,7 @@ UpgradeApplicationID
|
|||
{}
|
||||
|
||||
Version
|
||||
{190215}
|
||||
{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 190215)")
|
||||
#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 190215))"
|
||||
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-190215
|
||||
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-190215"
|
||||
pandora_version="7.0NG.731-190226"
|
||||
|
||||
package_pear=0
|
||||
package_pandora=1
|
||||
|
|
|
@ -0,0 +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');
|
||||
|
||||
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;
|
|
@ -137,8 +137,8 @@ function get_logs_size($file)
|
|||
function get_status_logs($path)
|
||||
{
|
||||
$status_server_log = '';
|
||||
$size_server_log = get_logs_size($path);
|
||||
if ($size_server_log <= 10240) {
|
||||
$size_server_log = number_format(get_logs_size($path));
|
||||
if ($size_server_log <= 1048576) {
|
||||
$status_server_log = "<a style ='color: green;text-decoration: none;'>Normal Status</a><a style ='text-decoration: none;'>   You have less than 10 MB of logs</a>";
|
||||
} else {
|
||||
$status_server_log = "<a class= 'content' style= 'color: red;text-decoration: none;'>Warning Status</a><a style ='text-decoration: none;'>   You have more than 10 MB of logs</a>";
|
||||
|
@ -412,11 +412,7 @@ render_info_data(
|
|||
render_info_data('SELECT COUNT(*) FROM tagente_modulo', 'Total modules');
|
||||
render_info_data('SELECT COUNT(*) FROM tgrupo', 'Total groups');
|
||||
render_info_data('SELECT COUNT(*) FROM tagente_datos', 'Total module data records');
|
||||
// render_info_data ("SELECT COUNT(*) FROM tagente_datos_string","Total module string data records");
|
||||
// render_info_data ("SELECT COUNT(*) FROM tagente_datos_log4x","Total module log4x data records");
|
||||
render_info_data('SELECT COUNT(*) FROM tagent_access', 'Total agent access record');
|
||||
// render_info ("tagente_estado");
|
||||
// render_info ("talert_template_modules");
|
||||
render_info_data('SELECT COUNT(*) FROM tevento', 'Total events');
|
||||
|
||||
if ($config['enterprise_installed']) {
|
||||
|
@ -700,7 +696,7 @@ render_info_data(
|
|||
render_row(status_values($read_rnd_buffer_size_min_rec_value, $read_rnd_buffer_size), 'Read rnd-buffer size ', 'Read rnd-buffer size ');
|
||||
render_row(status_values($query_cache_min_res_unit_min_rec_value, $query_cache_min_res_unit), 'Query cache min-res-unit ', 'Query cache min-res-unit ');
|
||||
render_row(status_values($innodb_file_per_table_min_rec_value, $innodb_file_per_table), 'InnoDB file per table ', 'InnoDB file per table ');
|
||||
echo "<tr><th style='background-color:#b1b1b1;font-weight:bold;font-style:italic;border-radius:2px;' align=center colspan='2'>".__('Tables fragmentation in the PandoraFMS database').'</th></tr>';
|
||||
echo "<tr><th style='background-color:#b1b1b1;font-weight:bold;font-style:italic;border-radius:2px;' align=center colspan='2'>".__('Tables fragmentation in the Pandora FMS database').'</th></tr>';
|
||||
|
||||
|
||||
|
||||
|
@ -708,14 +704,14 @@ render_info_data(
|
|||
render_row(number_format($tables_fragmentation, 2).'%', 'Tables fragmentation (current value)');
|
||||
render_row(status_fragmentation_tables($tables_fragmentation_max_rec_value, $tables_fragmentation), 'Status fragmentation tables');
|
||||
|
||||
echo "<tr><th style='background-color:#b1b1b1;font-weight:bold;font-style:italic;border-radius:2px;' align=center colspan='2'>".__(' PandoraFMS logs dates').'</th></tr>';
|
||||
echo "<tr><th style='background-color:#b1b1b1;font-weight:bold;font-style:italic;border-radius:2px;' align=center colspan='2'>".__(' Pandora FMS logs dates').'</th></tr>';
|
||||
|
||||
render_row(number_format((get_logs_size($path_server_logs) / 1024), 2).'M', 'Size server logs (current value)');
|
||||
render_row(number_format((get_logs_size($path_server_logs) / 1048576), 3).'M', 'Size server logs (current value)');
|
||||
render_row(get_status_logs($path_server_logs), 'Status server logs');
|
||||
render_row(number_format((get_logs_size($path_console_logs) / 1024), 2).'M', 'Size console logs (current value)');
|
||||
render_row(number_format((get_logs_size($path_console_logs) / 1048576), 3).'M', 'Size console logs (current value)');
|
||||
render_row(get_status_logs($path_console_logs), 'Status console logs');
|
||||
|
||||
echo "<tr><th style='background-color:#b1b1b1;font-weight:bold;font-style:italic;border-radius:2px;' align=center colspan='2'>".__(' PandoraFMS Licence Information').'</th></tr>';
|
||||
echo "<tr><th style='background-color:#b1b1b1;font-weight:bold;font-style:italic;border-radius:2px;' align=center colspan='2'>".__(' Pandora FMS Licence Information').'</th></tr>';
|
||||
|
||||
render_row(html_print_textarea('keys[customer_key]', 10, 255, $settings->customer_key, 'style="height:40px; width:450px;"', true), 'Customer key');
|
||||
render_row($license['expiry_date'], 'Expires');
|
||||
|
|
|
@ -1206,6 +1206,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview',
|
|||
UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager';
|
||||
DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise';
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '731');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp');
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tconfig_os`
|
||||
|
@ -1406,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)
|
||||
|
@ -1816,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`
|
||||
-- -----------------------------------------------------
|
||||
|
@ -1856,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`
|
||||
-- -----------------------------------------------------
|
||||
|
@ -1868,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>
|
|
@ -229,14 +229,14 @@ if (!$new_agent) {
|
|||
$table->data[0][1] .= " <span align='right'><a onClick=\"if (!confirm('".__('Are you sure?')."')) return false;\" href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente=$id_agente&search=&offset=0&sort_field=&sort=none'>".html_print_image('images/cross.png', true, ['title' => __('Delete agent')]).'</a>';
|
||||
}
|
||||
|
||||
$table->data[1][0] = __('Alias');
|
||||
$table->data[1][0] = __('Alias').ui_print_help_tip(__('Characters /,\,|,%,#,&,$ will be ignored'), true).'</span>';
|
||||
$table->data[1][1] = html_print_input_text('alias', $alias, '', 50, 100, true);
|
||||
if ($new_agent) {
|
||||
$table->data[1][1] .= html_print_checkbox('alias_as_name', 1, $config['alias_as_name'], true).__('Use alias as name');
|
||||
}
|
||||
|
||||
$table->data[2][0] = __('IP Address');
|
||||
$table->data[2][1] = html_print_input_text('direccion', $direccion_agente, '', 16, 100, true);
|
||||
$table->data[2][1] = html_print_input_text('direccion', $direccion_agente, '', 16, 100, true).html_print_checkbox('unique_ip', 1, $config['unique_ip'], true).__('Unique IP').ui_print_help_tip(__('Set the primary IP address as the unique IP, preventing the same primary IP address from being used in more than one agent'), true);
|
||||
|
||||
if ($id_agente) {
|
||||
$table->data[2][1] .= ' ';
|
||||
|
|
|
@ -81,6 +81,7 @@ $alias_as_name = 0;
|
|||
$direccion_agente = get_parameter('direccion', '');
|
||||
$direccion_agente = trim(io_safe_output($direccion_agente));
|
||||
$direccion_agente = io_safe_input($direccion_agente);
|
||||
$unique_ip = 0;
|
||||
$intervalo = SECONDS_5MINUTES;
|
||||
$ff_interval = 0;
|
||||
$quiet_module = 0;
|
||||
|
@ -158,9 +159,11 @@ $module_macros = [];
|
|||
// Create agent
|
||||
if ($create_agent) {
|
||||
$mssg_warning = 0;
|
||||
$alias = (string) get_parameter_post('alias', '');
|
||||
$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);
|
||||
|
||||
// safe_output only validate ip
|
||||
$direccion_agente = trim(io_safe_output($direccion_agente));
|
||||
|
@ -216,7 +219,12 @@ if ($create_agent) {
|
|||
$nombre_agente = $alias;
|
||||
}
|
||||
|
||||
if (!$exists_alias) {
|
||||
if ($unique_ip && $direccion_agente != '') {
|
||||
$sql = 'SELECT direccion FROM tagente WHERE direccion = "'.$direccion_agente.'"';
|
||||
$exists_ip = db_get_row_sql($sql);
|
||||
}
|
||||
|
||||
if (!$exists_alias && !$exists_ip) {
|
||||
$id_agente = db_process_sql_insert(
|
||||
'tagente',
|
||||
[
|
||||
|
@ -326,6 +334,8 @@ if ($create_agent) {
|
|||
$agent_creation_error = __('Could not be created');
|
||||
if ($exists_alias) {
|
||||
$agent_creation_error = __('Could not be created, because name already exists');
|
||||
} else if ($exists_ip) {
|
||||
$agent_creation_error = __('Could not be created, because IP already exists');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -755,9 +765,11 @@ if ($update_agent) {
|
|||
$mssg_warning = 0;
|
||||
$id_agente = (int) get_parameter_post('id_agente');
|
||||
$nombre_agente = str_replace('`', '‘', (string) get_parameter_post('agente', ''));
|
||||
$alias = str_replace('`', '‘', (string) get_parameter_post('alias', ''));
|
||||
$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);
|
||||
// safe_output only validate ip
|
||||
$direccion_agente = trim(io_safe_output($direccion_agente));
|
||||
|
||||
|
@ -860,8 +872,15 @@ if ($update_agent) {
|
|||
// If there is an agent with the same name, but a different ID
|
||||
}
|
||||
|
||||
if ($unique_ip && $direccion_agente != '') {
|
||||
$sql = 'SELECT direccion FROM tagente WHERE direccion = "'.$direccion_agente.'"';
|
||||
$exists_ip = db_get_row_sql($sql);
|
||||
}
|
||||
|
||||
if ($grupo <= 0) {
|
||||
ui_print_error_message(__('The group id %d is incorrect.', $grupo));
|
||||
} else if ($exists_ip) {
|
||||
ui_print_error_message(__('Duplicate main IP address'));
|
||||
} else {
|
||||
// If different IP is specified than previous, add the IP
|
||||
if ($direccion_agente != ''
|
||||
|
@ -915,7 +934,7 @@ if ($update_agent) {
|
|||
|
||||
$result = db_process_sql_update('tagente', $values, ['id_agente' => $id_agente]);
|
||||
|
||||
if ($result == false && $update_custom_result == false) {
|
||||
if ($result === false && $update_custom_result == false) {
|
||||
ui_print_error_message(
|
||||
__('There was a problem updating the agent')
|
||||
);
|
||||
|
|
|
@ -128,7 +128,7 @@ $snmp_versions['2c'] = 'v. 2c';
|
|||
$snmp_versions['3'] = 'v. 3';
|
||||
|
||||
$data = [];
|
||||
$data[0] = __('SNMP community');
|
||||
$data[0] = __('SNMP community').ui_print_help_icon('column_macros', true);
|
||||
$adopt = false;
|
||||
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK && isset($id_agent_module)) {
|
||||
$adopt = policies_is_module_adopt($id_agent_module);
|
||||
|
@ -277,7 +277,7 @@ if (!isset($id_agent_module)) {
|
|||
}
|
||||
|
||||
$data = [];
|
||||
$data[0] = __('Auth user');
|
||||
$data[0] = __('Auth user').ui_print_help_icon('column_macros', true);
|
||||
$data[1] = html_print_input_text(
|
||||
'snmp3_auth_user',
|
||||
$snmp3_auth_user,
|
||||
|
@ -290,7 +290,7 @@ $data[1] = html_print_input_text(
|
|||
'',
|
||||
$classdisabledBecauseInPolicy
|
||||
);
|
||||
$data[2] = __('Auth password').ui_print_help_tip(__('The pass length must be eight character minimum.'), true);
|
||||
$data[2] = __('Auth password').ui_print_help_icon('column_macros', true).ui_print_help_tip(__('The pass length must be eight character minimum.'), true);
|
||||
$data[3] = html_print_input_password(
|
||||
'snmp3_auth_pass',
|
||||
$snmp3_auth_pass,
|
||||
|
@ -312,7 +312,7 @@ push_table_simple($data, 'field_snmpv3_row1');
|
|||
$data = [];
|
||||
$data[0] = __('Privacy method');
|
||||
$data[1] = html_print_select(['DES' => __('DES'), 'AES' => __('AES')], 'snmp3_privacy_method', $snmp3_privacy_method, '', '', '', true, false, false, '', $disabledBecauseInPolicy);
|
||||
$data[2] = __('Privacy pass').ui_print_help_tip(__('The pass length must be eight character minimum.'), true);
|
||||
$data[2] = __('Privacy pass').ui_print_help_icon('column_macros', true).ui_print_help_tip(__('The pass length must be eight character minimum.'), true);
|
||||
$data[3] = html_print_input_password(
|
||||
'snmp3_privacy_pass',
|
||||
$snmp3_privacy_pass,
|
||||
|
|
|
@ -60,7 +60,7 @@ $data[3] = html_print_input_text(
|
|||
push_table_simple($data, 'target_ip');
|
||||
|
||||
$data = [];
|
||||
$data[0] = __('Username');
|
||||
$data[0] = __('Username').ui_print_help_icon('column_macros', true);
|
||||
$data[1] = html_print_input_text(
|
||||
'plugin_user',
|
||||
$plugin_user,
|
||||
|
@ -73,7 +73,7 @@ $data[1] = html_print_input_text(
|
|||
'',
|
||||
$classdisabledBecauseInPolicy
|
||||
);
|
||||
$data[2] = __('Password');
|
||||
$data[2] = __('Password').ui_print_help_icon('column_macros', true);
|
||||
$data[3] = html_print_input_password(
|
||||
'plugin_pass',
|
||||
$plugin_pass,
|
||||
|
|
|
@ -0,0 +1,272 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// 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();
|
||||
|
||||
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', '');
|
||||
$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 = [
|
||||
'token' => 'status_monitor_fields',
|
||||
'value' => $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 = [];
|
||||
$status_monitor_fields = '';
|
||||
$fields_selected = explode(',', $config['status_monitor_fields']);
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
echo '<h3>'.__('Show monitor detail fields').'</h3>';
|
||||
|
||||
$table = new stdClass();
|
||||
$table->width = '100%';
|
||||
$table->class = 'databox filters';
|
||||
|
||||
$table->size = [];
|
||||
// ~ $table->size[0] = '20%';
|
||||
$table->size[1] = '10px';
|
||||
// ~ $table->size[2] = '20%';
|
||||
$table->style[0] = 'text-align:center;';
|
||||
$table->style[2] = 'text-align:center;';
|
||||
|
||||
$table->data = [];
|
||||
|
||||
$fields_available = [];
|
||||
|
||||
$fields_available['policy'] = __('Policy');
|
||||
$fields_available['agent'] = __('Agent');
|
||||
$fields_available['data_type'] = __('Data type');
|
||||
$fields_available['module_name'] = __('Module name');
|
||||
$fields_available['server_type'] = __('Server type');
|
||||
$fields_available['interval'] = __('Interval');
|
||||
$fields_available['status'] = __('Status');
|
||||
$fields_available['graph'] = __('Graph');
|
||||
$fields_available['warn'] = __('Warn');
|
||||
$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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$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'
|
||||
);
|
||||
|
||||
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"');
|
||||
echo '</form>';
|
||||
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 = '';
|
||||
|
||||
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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
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();
|
||||
}
|
||||
});
|
||||
}
|
||||
</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');
|
||||
}
|
||||
|
|
|
@ -57,16 +57,16 @@ $data = [];
|
|||
$data[0] = __('SNMP Enterprise String');
|
||||
$data[1] = html_print_input_text('snmp_oid', $snmp_oid, '', 30, 400, true);
|
||||
// $table->colspan['snmp_2'][1] = 3;
|
||||
$data[2] = __('SNMP community');
|
||||
$data[2] = __('SNMP community').ui_print_help_icon('column_macros', true);
|
||||
$data[3] = html_print_input_text('snmp_community', $snmp_community, '', 15, 60, true);
|
||||
|
||||
push_table_row($data, 'snmp_2');
|
||||
|
||||
|
||||
$data = [];
|
||||
$data[0] = __('Auth user');
|
||||
$data[0] = __('Auth user').ui_print_help_icon('column_macros', true);
|
||||
$data[1] = html_print_input_text('snmp3_auth_user', $snmp3_auth_user, '', 15, 60, true);
|
||||
$data[2] = __('Auth password');
|
||||
$data[2] = __('Auth password').ui_print_help_icon('column_macros', true);
|
||||
$data[3] = html_print_input_password('snmp3_auth_pass', $snmp3_auth_pass, '', 15, 60, true);
|
||||
$data[3] .= html_print_input_hidden_extended('active_snmp_v3', 0, 'active_snmp_v3_mncfn', true);
|
||||
push_table_row($data, 'field_snmpv3_row1');
|
||||
|
@ -74,7 +74,7 @@ push_table_row($data, 'field_snmpv3_row1');
|
|||
$data = [];
|
||||
$data[0] = __('Privacy method');
|
||||
$data[1] = html_print_select(['DES' => __('DES'), 'AES' => __('AES')], 'snmp3_privacy_method', $snmp3_privacy_method, '', '', '', true);
|
||||
$data[2] = __('Privacy pass');
|
||||
$data[2] = __('Privacy pass').ui_print_help_icon('column_macros', true);
|
||||
$data[3] = html_print_input_password('snmp3_privacy_pass', $snmp3_privacy_pass, '', 15, 60, true);
|
||||
push_table_row($data, 'field_snmpv3_row2');
|
||||
|
||||
|
|
|
@ -44,9 +44,9 @@ $data[3] = html_print_input_text('tcp_send', $tcp_send, '', 25, 255, true);
|
|||
push_table_row($data, 'wmi_2');
|
||||
|
||||
$data = [];
|
||||
$data[0] = __('Username');
|
||||
$data[0] = __('Username').ui_print_help_icon('column_macros', true);
|
||||
$data[1] = html_print_input_text('plugin_user', $plugin_user, '', 15, 255, true);
|
||||
$data[2] = __('Password');
|
||||
$data[2] = __('Password').ui_print_help_icon('column_macros', true);
|
||||
$data[3] = html_print_input_password('plugin_pass', $plugin_pass, '', 25, 255, true);
|
||||
|
||||
push_table_row($data, 'wmi_3');
|
||||
|
|
|
@ -2720,7 +2720,7 @@ function edit_custom_graph() {
|
|||
}
|
||||
});
|
||||
|
||||
window.location.href = server_url + "/index.php?sec=reporting&sec2=godmode/reporting/graph_builder&edit_graph=1&id=" + id_element_graph + hash_data;
|
||||
window.location.href = server_url + "index.php?sec=reporting&sec2=godmode/reporting/graph_builder&edit_graph=1&id=" + id_element_graph + hash_data;
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
|
|
|
@ -1116,8 +1116,13 @@ switch ($action) {
|
|||
$name_it = (string) get_parameter('name');
|
||||
$values['name'] = reporting_label_macro($items_label, $name_it);
|
||||
|
||||
// Added support for projection graphs, prediction date and SLA reports
|
||||
// 'top_n_value','top_n' and 'text' fields will be reused for these types of report
|
||||
/*
|
||||
Added support for projection graphs,
|
||||
prediction date and SLA reports
|
||||
'top_n_value','top_n' and 'text'
|
||||
fields will be reused for these types of report
|
||||
*/
|
||||
|
||||
switch ($values['type']) {
|
||||
case 'projection_graph':
|
||||
$values['period'] = get_parameter('period1');
|
||||
|
@ -1127,7 +1132,8 @@ switch ($action) {
|
|||
break;
|
||||
|
||||
case 'event_report_log':
|
||||
$agents_to_report = get_parameter('id_agents2');
|
||||
|
||||
$agents_to_report = get_parameter('id_agents3');
|
||||
$source = get_parameter('source', '');
|
||||
$search = get_parameter('search', '');
|
||||
$log_number = get_parameter('log_number', '');
|
||||
|
@ -1525,7 +1531,7 @@ switch ($action) {
|
|||
break;
|
||||
|
||||
case 'event_report_log':
|
||||
$agents_to_report = get_parameter('id_agents2');
|
||||
$agents_to_report = get_parameter('id_agents3');
|
||||
$source = get_parameter('source', '');
|
||||
$search = get_parameter('search', '');
|
||||
$log_number = get_parameter('log_number', '');
|
||||
|
@ -1632,17 +1638,6 @@ switch ($action) {
|
|||
$values['server_name'] = get_parameter('combo_server');
|
||||
}
|
||||
|
||||
|
||||
if (is_metaconsole()) {
|
||||
// For SQL Query check if it is setted in the meta
|
||||
if ($values['type'] == 'sql') {
|
||||
if (empty($values['server_name'])) {
|
||||
$good_format = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$values['id_agent'] = get_parameter('id_agent');
|
||||
$values['id_gs'] = get_parameter('id_custom_graph');
|
||||
if (($values['type'] == 'alert_report_agent') or ($values['type'] == 'event_report_agent') or ($values['type'] == 'agent_configuration') or ($values['type'] == 'group_configuration')) {
|
||||
|
|
|
@ -231,6 +231,21 @@ function is_metaconsole() {
|
|||
else return false;
|
||||
}
|
||||
|
||||
function dialog_message(message_id) {
|
||||
$(message_id)
|
||||
.css("display", "inline")
|
||||
.dialog({
|
||||
modal: true,
|
||||
show: "blind",
|
||||
hide: "blind",
|
||||
buttons: {
|
||||
Close: function() {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function update_button_palette_callback() {
|
||||
var values = {};
|
||||
|
||||
|
@ -240,14 +255,11 @@ function update_button_palette_callback() {
|
|||
switch (selectedItem) {
|
||||
case "background":
|
||||
if (values["width"] < 1024 || values["height"] < 768) {
|
||||
alert("Min allowed size is 1024x768");
|
||||
dialog_message("#message_min_allowed_size");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (values["width"] == 0 && values["height"] == 0) {
|
||||
values["width"] = $("#hidden-background_original_width").val();
|
||||
values["height"] = $("#hidden-background_original_height").val();
|
||||
}
|
||||
$("#hidden-background_width").val(values["width"]);
|
||||
$("#hidden-background_height").val(values["height"]);
|
||||
$("#background").css("width", values["width"]);
|
||||
$("#background").css("height", values["height"]);
|
||||
|
||||
|
@ -259,11 +271,25 @@ function update_button_palette_callback() {
|
|||
break;
|
||||
case "box_item":
|
||||
if ($("input[name=width_box]").val() == "") {
|
||||
alert("Undefined width");
|
||||
dialog_message("#message_alert_no_width");
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
parseInt($("input[name='width_box']").val()) >
|
||||
parseInt($("#hidden-background_width").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_width");
|
||||
return false;
|
||||
}
|
||||
if ($("input[name=height_box]").val() == "") {
|
||||
alert("Undefined height");
|
||||
dialog_message("#message_alert_no_height");
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
parseInt($("input[name='height_box']").val()) >
|
||||
parseInt($("#hidden-background_width").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_height");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -288,7 +314,7 @@ function update_button_palette_callback() {
|
|||
values["label"] == "" &&
|
||||
values["show_statistics"] == false
|
||||
) {
|
||||
alert("Undefined image");
|
||||
dialog_message("#message_alert_no_image");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -428,18 +454,32 @@ function update_button_palette_callback() {
|
|||
break;
|
||||
case "static_graph":
|
||||
if ($("input[name=width]").val() == "") {
|
||||
alert("Undefined width");
|
||||
dialog_message("#message_alert_no_width");
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
parseInt($("input[name='width']").val()) >
|
||||
parseInt($("#hidden-background_width").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_width");
|
||||
return false;
|
||||
}
|
||||
if ($("input[name=height]").val() == "") {
|
||||
alert("Undefined height");
|
||||
dialog_message("#message_alert_no_height");
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
parseInt($("input[name='height']").val()) >
|
||||
parseInt($("#hidden-background_width").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_height");
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
(values["image"] == "" || values["image"] == "none") &&
|
||||
values["label"] == ""
|
||||
) {
|
||||
alert("Undefined image");
|
||||
dialog_message("#message_alert_no_image");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -555,13 +595,27 @@ function update_button_palette_callback() {
|
|||
break;
|
||||
case "percentile_bar":
|
||||
case "percentile_item":
|
||||
if ($("input[name=width_percentile]").val() == "") {
|
||||
alert("Undefined width");
|
||||
if ($("input[name=height_percentile]").val() == "") {
|
||||
dialog_message("#message_alert_no_height");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($("input[name=height_percentile]").val() == "") {
|
||||
alert("Undefined height");
|
||||
if ($("input[name=width_percentile]").val() == "") {
|
||||
dialog_message("#message_alert_no_width");
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
$("input[name=width_percentile]").val() >
|
||||
parseInt($("#hidden-background_width").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_width");
|
||||
return false;
|
||||
}
|
||||
if (values["module"] == 0) {
|
||||
dialog_message("#message_alert_no_module");
|
||||
return false;
|
||||
}
|
||||
if (values["agent"] == "") {
|
||||
dialog_message("#message_alert_no_agent");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -604,7 +658,6 @@ function update_button_palette_callback() {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($("#dir_items").html() == "vertical") {
|
||||
if (
|
||||
parseInt($("#text-top").val()) +
|
||||
|
@ -621,20 +674,41 @@ function update_button_palette_callback() {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (values["module"] == 0) {
|
||||
dialog_message("#message_alert_no_module");
|
||||
return false;
|
||||
}
|
||||
if (values["agent"] == "") {
|
||||
dialog_message("#message_alert_no_agent");
|
||||
return false;
|
||||
}
|
||||
if ($("input[name=width_module_graph]").val() == "") {
|
||||
alert("Undefined width");
|
||||
dialog_message("#message_alert_no_width");
|
||||
return false;
|
||||
}
|
||||
if ($("input[name=height_module_graph]").val() == "") {
|
||||
alert("Undefined height");
|
||||
dialog_message("#message_alert_no_height");
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
parseInt(values["width_module_graph"]) >
|
||||
parseInt($("#hidden-background_width").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_width");
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
parseInt($("input[name=height_module_graph]").val()) >
|
||||
parseInt($("#hidden-background_height").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_height");
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
$("#custom_graph_row").css("display") != "none" &&
|
||||
$("#custom_graph option:selected").html() == "None"
|
||||
) {
|
||||
alert("Undefined graph");
|
||||
dialog_message("#message_alert_no_custom_graph");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -644,12 +718,19 @@ function update_button_palette_callback() {
|
|||
break;
|
||||
case "bars_graph":
|
||||
if ($("input[name=width_percentile]").val() == "") {
|
||||
alert("Undefined width");
|
||||
dialog_message("#message_alert_no_width");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($("input[name=bars_graph_height]").val() == "") {
|
||||
alert("Undefined height");
|
||||
dialog_message("#message_alert_no_height");
|
||||
return false;
|
||||
}
|
||||
if (values["module"] == 0) {
|
||||
dialog_message("#message_alert_no_module");
|
||||
return false;
|
||||
}
|
||||
if (values["agent_string"] == "") {
|
||||
dialog_message("#message_alert_no_agent");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -660,18 +741,48 @@ function update_button_palette_callback() {
|
|||
break;
|
||||
|
||||
case "clock":
|
||||
if (
|
||||
parseInt(values["width_percentile"]) >
|
||||
parseInt($("#hidden-background_width").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_width");
|
||||
return false;
|
||||
}
|
||||
|
||||
$("#text_" + idItem).html(values["label"]);
|
||||
$("#image_" + idItem).attr("src", "images/spinner.gif");
|
||||
setClock(idItem, values);
|
||||
break;
|
||||
|
||||
case "auto_sla_graph":
|
||||
if ($("input[name=width]").val() == "") {
|
||||
alert("Undefined width");
|
||||
if (values["height"] == "") {
|
||||
dialog_message("#message_alert_no_height");
|
||||
return false;
|
||||
}
|
||||
if ($("input[name=height]").val() == "") {
|
||||
alert("Undefined height");
|
||||
if (
|
||||
parseInt(values["height"]) >
|
||||
parseInt($("#hidden-background_height").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_height");
|
||||
return false;
|
||||
}
|
||||
if (values["width"] == "") {
|
||||
dialog_message("#message_alert_no_width");
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
parseInt(values["width"]) >
|
||||
parseInt($("#hidden-background_width").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_width");
|
||||
return false;
|
||||
}
|
||||
if (values["module"] == 0) {
|
||||
dialog_message("#message_alert_no_module");
|
||||
return false;
|
||||
}
|
||||
if (values["agent"] == "") {
|
||||
dialog_message("#message_alert_no_agent");
|
||||
return false;
|
||||
}
|
||||
$("#text_" + idItem).html(values["label"]);
|
||||
|
@ -680,8 +791,22 @@ function update_button_palette_callback() {
|
|||
setEventsBar(idItem, values);
|
||||
break;
|
||||
case "donut_graph":
|
||||
if (
|
||||
parseInt(values["width_percentile"]) >
|
||||
parseInt($("#hidden-background_width").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_width");
|
||||
return false;
|
||||
}
|
||||
if (values["module"] == 0) {
|
||||
dialog_message("#message_alert_no_module_string_type");
|
||||
return false;
|
||||
}
|
||||
if (values["agent_string"] == "") {
|
||||
dialog_message("#message_alert_no_agent");
|
||||
return false;
|
||||
}
|
||||
$("#image_" + idItem).attr("src", "images/spinner.gif");
|
||||
|
||||
setDonutsGraph(idItem, values);
|
||||
break;
|
||||
case "simple_value":
|
||||
|
@ -718,21 +843,47 @@ function update_button_palette_callback() {
|
|||
"</span></td></tr><tr><td></td></tr></tbody></table>"
|
||||
);
|
||||
}
|
||||
if (values["module"] == 0) {
|
||||
dialog_message("#message_alert_no_module");
|
||||
return false;
|
||||
}
|
||||
if (values["agent"] == "") {
|
||||
dialog_message("#message_alert_no_agent");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case "label":
|
||||
if (values["label"] == "") {
|
||||
dialog_message("#message_alert_no_label");
|
||||
return false;
|
||||
}
|
||||
$("#text_" + idItem).html(values["label"]);
|
||||
break;
|
||||
case "icon":
|
||||
if ($("input[name=width]").val() == "") {
|
||||
alert("Undefined width");
|
||||
dialog_message("#message_alert_no_width");
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
parseInt($("input[name=width]").val()) >
|
||||
parseInt($("#hidden-background_width").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_width");
|
||||
return false;
|
||||
}
|
||||
if ($("input[name=height]").val() == "") {
|
||||
alert("Undefined height");
|
||||
dialog_message("#message_alert_no_height");
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
parseInt($("input[name=height]").val()) >
|
||||
parseInt($("#hidden-background_height").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_height");
|
||||
return false;
|
||||
}
|
||||
if (values["image"] == "" || values["image"] == "none") {
|
||||
alert("Undefined image");
|
||||
dialog_message("#message_alert_no_image");
|
||||
return false;
|
||||
}
|
||||
$("#image_" + idItem).attr("src", "images/spinner.gif");
|
||||
|
@ -779,13 +930,70 @@ function update_button_palette_callback() {
|
|||
var image = values["image"] + ".png";
|
||||
set_image("image", idItem, image);
|
||||
break;
|
||||
case "line_item":
|
||||
if (
|
||||
parseInt(values["line_width"]) >
|
||||
parseInt($("#hidden-background_width").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_width");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case "color_cloud":
|
||||
if (
|
||||
parseInt(values["diameter"]) >
|
||||
parseInt($("#hidden-background_height").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_height");
|
||||
return false;
|
||||
}
|
||||
if (values["module"] == 0) {
|
||||
dialog_message("#message_alert_no_module");
|
||||
return false;
|
||||
}
|
||||
if (values["agent"] == "") {
|
||||
dialog_message("#message_alert_no_agent");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case "service":
|
||||
if (values["height"] == "" || values["height_module_graph"] == 0) {
|
||||
dialog_message("#message_alert_no_height");
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
parseInt(values["height"]) >
|
||||
parseInt($("#hidden-background_height").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_height");
|
||||
return false;
|
||||
}
|
||||
if (values["width"] == "" || values["width_module_graph"] == 0) {
|
||||
dialog_message("#message_alert_no_width");
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
parseInt(values["width"]) >
|
||||
parseInt($("#hidden-background_width").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_width");
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
$("select[name=service]").val() == "" ||
|
||||
$("select[name=service]").val() == "none"
|
||||
) {
|
||||
dialog_message("#message_alert_no_service");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if ($("input[name=width]").val() == "") {
|
||||
alert("Undefined width");
|
||||
dialog_message("#message_alert_no_width");
|
||||
return false;
|
||||
}
|
||||
if ($("input[name=height]").val() == "") {
|
||||
alert("Undefined height");
|
||||
dialog_message("#message_alert_no_height");
|
||||
return false;
|
||||
}
|
||||
//Maybe save in any Enterprise item.
|
||||
|
@ -1018,149 +1226,356 @@ function create_button_palette_callback() {
|
|||
switch (creationItem) {
|
||||
case "box_item":
|
||||
if ($("input[name='width_box']").val() == "") {
|
||||
alert("Undefined width");
|
||||
dialog_message("#message_alert_no_width");
|
||||
validate = false;
|
||||
}
|
||||
if (
|
||||
parseInt($("input[name='width_box']").val()) >
|
||||
parseInt($("#hidden-background_width").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_width");
|
||||
validate = false;
|
||||
}
|
||||
if ($("input[name='height_box']").val() == "") {
|
||||
alert("Undefined height");
|
||||
dialog_message("#message_alert_no_height");
|
||||
validate = false;
|
||||
}
|
||||
if (
|
||||
parseInt($("input[name='height_box']").val()) >
|
||||
parseInt($("#hidden-background_height").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_height");
|
||||
validate = false;
|
||||
}
|
||||
break;
|
||||
case "group_item":
|
||||
if (values["height"] == "") {
|
||||
dialog_message("#message_alert_no_height");
|
||||
validate = false;
|
||||
}
|
||||
if (
|
||||
parseInt(values["height"]) >
|
||||
parseInt($("#hidden-background_height").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_height");
|
||||
validate = false;
|
||||
}
|
||||
if (values["width"] == "") {
|
||||
dialog_message("#message_alert_no_width");
|
||||
validate = false;
|
||||
}
|
||||
if (
|
||||
parseInt(values["width"]) >
|
||||
parseInt($("#hidden-background_width").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_width");
|
||||
validate = false;
|
||||
}
|
||||
if (
|
||||
(values["image"] == "" || values["image"] == "none") &&
|
||||
values["label"] == "" &&
|
||||
values["show_statistics"] == false
|
||||
) {
|
||||
alert("Undefined images");
|
||||
dialog_message("#message_alert_no_image");
|
||||
validate = false;
|
||||
}
|
||||
break;
|
||||
case "static_graph":
|
||||
if (values["width"] == "") {
|
||||
alert("Undefined width");
|
||||
if (values["height"] == "") {
|
||||
dialog_message("#message_alert_no_height");
|
||||
validate = false;
|
||||
}
|
||||
if (values["height"] == "") {
|
||||
alert("Undefined height");
|
||||
if (
|
||||
parseInt(values["height"]) >
|
||||
parseInt($("#hidden-background_height").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_height");
|
||||
validate = false;
|
||||
}
|
||||
if (values["width"] == "") {
|
||||
dialog_message("#message_alert_no_width");
|
||||
validate = false;
|
||||
}
|
||||
if (
|
||||
parseInt(values["width"]) >
|
||||
parseInt($("#hidden-background_width").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_width");
|
||||
validate = false;
|
||||
}
|
||||
if (
|
||||
(values["image"] == "" || values["image"] == "none") &&
|
||||
values["label"] == false
|
||||
) {
|
||||
alert("Undefined image");
|
||||
dialog_message("#message_alert_no_image");
|
||||
validate = false;
|
||||
}
|
||||
|
||||
break;
|
||||
case "auto_sla_graph":
|
||||
if (values["height"] == "") {
|
||||
dialog_message("#message_alert_no_height");
|
||||
validate = false;
|
||||
}
|
||||
if (
|
||||
parseInt(values["height"]) >
|
||||
parseInt($("#hidden-background_height").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_height");
|
||||
validate = false;
|
||||
}
|
||||
if (values["width"] == "") {
|
||||
dialog_message("#message_alert_no_width");
|
||||
validate = false;
|
||||
}
|
||||
if (
|
||||
parseInt(values["width"]) >
|
||||
parseInt($("#hidden-background_width").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_width");
|
||||
validate = false;
|
||||
}
|
||||
if (values["module"] == 0) {
|
||||
dialog_message("#message_alert_no_module");
|
||||
validate = false;
|
||||
}
|
||||
if (values["agent"] == "") {
|
||||
alert($("#message_alert_no_agent").html());
|
||||
dialog_message("#message_alert_no_agent");
|
||||
validate = false;
|
||||
}
|
||||
break;
|
||||
case "donut_graph":
|
||||
if (
|
||||
parseInt(values["width_percentile"]) >
|
||||
parseInt($("#hidden-background_width").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_width");
|
||||
validate = false;
|
||||
}
|
||||
if (values["module"] == 0) {
|
||||
dialog_message("#message_alert_no_module_string_type");
|
||||
validate = false;
|
||||
}
|
||||
if (values["agent_string"] == "") {
|
||||
alert($("#message_alert_no_agent").html());
|
||||
dialog_message("#message_alert_no_agent");
|
||||
validate = false;
|
||||
}
|
||||
break;
|
||||
case "label":
|
||||
if (values["label"] == "") {
|
||||
alert($("#message_alert_no_label").html());
|
||||
dialog_message("#message_alert_no_label");
|
||||
validate = false;
|
||||
}
|
||||
break;
|
||||
case "icon":
|
||||
if (values["width"] == "") {
|
||||
alert("Undefined width");
|
||||
dialog_message("#message_alert_no_width");
|
||||
validate = false;
|
||||
}
|
||||
if (
|
||||
parseInt(values["width"]) >
|
||||
parseInt($("#hidden-background_width").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_width");
|
||||
validate = false;
|
||||
}
|
||||
if (values["height"] == "") {
|
||||
alert("Undefined height");
|
||||
dialog_message("#message_alert_no_height");
|
||||
validate = false;
|
||||
}
|
||||
if (
|
||||
parseInt(values["height"]) >
|
||||
parseInt($("#hidden-background_height").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_height");
|
||||
validate = false;
|
||||
}
|
||||
if (values["image"] == "" || values["image"] == "none") {
|
||||
alert($("#message_alert_no_image").html());
|
||||
dialog_message("#message_alert_no_image");
|
||||
validate = false;
|
||||
}
|
||||
break;
|
||||
case "percentile_bar":
|
||||
case "percentile_item":
|
||||
if (values["width"] == "") {
|
||||
alert("Undefined width");
|
||||
validate = false;
|
||||
}
|
||||
if (values["agent"] == "") {
|
||||
alert($("#message_alert_no_agent").html());
|
||||
validate = false;
|
||||
}
|
||||
if (values["module"] == 0) {
|
||||
alert($("#message_alert_no_module").html());
|
||||
validate = false;
|
||||
}
|
||||
if (values["max_percentile"] == "") {
|
||||
alert($("#message_alert_no_max_percentile").html());
|
||||
if (
|
||||
parseInt(values["width_percentile"]) >
|
||||
parseInt($("#hidden-background_width").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_width");
|
||||
validate = false;
|
||||
}
|
||||
if (values["width_percentile"] == "") {
|
||||
alert($("#message_alert_no_width_percentile").html());
|
||||
dialog_message("#message_alert_no_width");
|
||||
validate = false;
|
||||
}
|
||||
if (values["module"] == 0) {
|
||||
dialog_message("#message_alert_no_module");
|
||||
validate = false;
|
||||
}
|
||||
if (values["agent"] == "") {
|
||||
dialog_message("#message_alert_no_agent");
|
||||
validate = false;
|
||||
}
|
||||
|
||||
if (values["max_percentile"] == "") {
|
||||
dialog_message("#message_alert_no_max_percentile");
|
||||
validate = false;
|
||||
}
|
||||
|
||||
break;
|
||||
case "module_graph":
|
||||
if (values["width_module_graph"] == "") {
|
||||
alert("Undefined width");
|
||||
validate = false;
|
||||
}
|
||||
if (values["height_module_graph"] == "") {
|
||||
alert("Undefined height");
|
||||
if (values["module"] == 0) {
|
||||
dialog_message("#message_alert_no_module");
|
||||
validate = false;
|
||||
}
|
||||
if (values["id_custom_graph"] == 0) {
|
||||
if (values["agent"] == "") {
|
||||
alert($("#message_alert_no_agent").html());
|
||||
validate = false;
|
||||
}
|
||||
if (values["module"] == 0) {
|
||||
alert($("#message_alert_no_module").html());
|
||||
dialog_message("#message_alert_no_agent");
|
||||
validate = false;
|
||||
}
|
||||
if (values["period"] == 0) {
|
||||
alert($("#message_alert_no_period").html());
|
||||
dialog_message("#message_alert_no_period");
|
||||
validate = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "bars_graph":
|
||||
if (values["agent_string"] == "") {
|
||||
alert($("#message_alert_no_agent").html());
|
||||
if (
|
||||
values["height_module_graph"] == "" ||
|
||||
values["height_module_graph"] == 0
|
||||
) {
|
||||
dialog_message("#message_alert_no_height");
|
||||
validate = false;
|
||||
}
|
||||
if (values["module"] == 0) {
|
||||
alert($("#message_alert_no_module").html());
|
||||
if (
|
||||
parseInt(values["height_module_graph"]) >
|
||||
parseInt($("#hidden-background_height").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_height");
|
||||
validate = false;
|
||||
}
|
||||
if (
|
||||
values["width_module_graph"] == "" ||
|
||||
values["width_module_graph"] == 0
|
||||
) {
|
||||
dialog_message("#message_alert_no_width");
|
||||
validate = false;
|
||||
}
|
||||
if (
|
||||
parseInt(values["width_module_graph"]) >
|
||||
parseInt($("#hidden-background_width").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_width");
|
||||
validate = false;
|
||||
}
|
||||
break;
|
||||
case "bars_graph":
|
||||
if (values["bars_graph_height"] == "") {
|
||||
dialog_message("#message_alert_no_height");
|
||||
validate = false;
|
||||
}
|
||||
if (
|
||||
parseInt(values["bars_graph_height"]) >
|
||||
parseInt($("#hidden-background_height").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_height");
|
||||
validate = false;
|
||||
}
|
||||
if (values["width_percentile"] == "") {
|
||||
alert($("#message_alert_no_width_percentile").html());
|
||||
dialog_message("#message_alert_no_width");
|
||||
validate = false;
|
||||
}
|
||||
if (values["bars_graph_height"] == "") {
|
||||
alert($("#message_alert_no_bars_graph_height").html());
|
||||
if (
|
||||
parseInt(values["width_percentile"]) >
|
||||
parseInt($("#hidden-background_width").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_width");
|
||||
validate = false;
|
||||
}
|
||||
if (values["module"] == 0) {
|
||||
dialog_message("#message_alert_no_module");
|
||||
validate = false;
|
||||
}
|
||||
if (values["agent_string"] == "") {
|
||||
dialog_message("#message_alert_no_agent");
|
||||
validate = false;
|
||||
}
|
||||
break;
|
||||
case "simple_value":
|
||||
if (values["agent"] == "") {
|
||||
alert($("#message_alert_no_agent").html());
|
||||
if (values["module"] == 0) {
|
||||
dialog_message("#message_alert_no_module");
|
||||
validate = false;
|
||||
}
|
||||
if (values["module"] == 0) {
|
||||
alert($("#message_alert_no_module").html());
|
||||
if (values["agent"] == "") {
|
||||
dialog_message("#message_alert_no_agent");
|
||||
validate = false;
|
||||
}
|
||||
break;
|
||||
case "clock":
|
||||
if (
|
||||
parseInt(values["width_percentile"]) >
|
||||
parseInt($("#hidden-background_width").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_width");
|
||||
validate = false;
|
||||
}
|
||||
break;
|
||||
case "line_item":
|
||||
if (
|
||||
parseInt(values["line_width"]) >
|
||||
parseInt($("#hidden-background_width").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_width");
|
||||
validate = false;
|
||||
}
|
||||
break;
|
||||
case "color_cloud":
|
||||
if (
|
||||
parseInt(values["diameter"]) >
|
||||
parseInt($("#hidden-background_height").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_height");
|
||||
validate = false;
|
||||
}
|
||||
if (values["module"] == 0) {
|
||||
dialog_message("#message_alert_no_module");
|
||||
validate = false;
|
||||
}
|
||||
if (values["agent"] == "") {
|
||||
dialog_message("#message_alert_no_agent");
|
||||
validate = false;
|
||||
}
|
||||
break;
|
||||
case "service":
|
||||
if (values["height"] == "" || values["height_module_graph"] == 0) {
|
||||
dialog_message("#message_alert_no_height");
|
||||
validate = false;
|
||||
}
|
||||
if (
|
||||
parseInt(values["height"]) >
|
||||
parseInt($("#hidden-background_height").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_height");
|
||||
validate = false;
|
||||
}
|
||||
if (values["width"] == "" || values["width_module_graph"] == 0) {
|
||||
dialog_message("#message_alert_no_width");
|
||||
validate = false;
|
||||
}
|
||||
if (
|
||||
parseInt(values["width"]) >
|
||||
parseInt($("#hidden-background_width").val())
|
||||
) {
|
||||
dialog_message("#message_alert_max_width");
|
||||
validate = false;
|
||||
}
|
||||
if (
|
||||
$("select[name=service]").val() == "" ||
|
||||
$("select[name=service]").val() == "none"
|
||||
) {
|
||||
dialog_message("#message_alert_no_service");
|
||||
validate = false;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
//Maybe save in any Enterprise item.
|
||||
if (typeof enterprise_create_button_palette_callback == "function") {
|
||||
|
@ -3714,17 +4129,7 @@ function createItem(type, values, id_data) {
|
|||
.attr("height", values["height"]);
|
||||
}
|
||||
}
|
||||
// else{
|
||||
// $('#image_'+id_data).css('width', values['width']+'px');
|
||||
// $('#image_'+id_data).css('height', values['height']+'px');
|
||||
// }
|
||||
/*
|
||||
var $span = $('<span></span>')
|
||||
.attr('id', 'text_' + id_data)
|
||||
.attr('class', 'text')
|
||||
.append(values['label']);
|
||||
|
||||
*/
|
||||
|
||||
var $input = $("<input></input>")
|
||||
.attr("id", "hidden-status_" + id_data)
|
||||
.attr("type", "hidden")
|
||||
|
@ -4489,7 +4894,6 @@ function createItem(type, values, id_data) {
|
|||
case "clock":
|
||||
sizeStyle = "";
|
||||
imageSize = "";
|
||||
|
||||
if (values["label_position"] == "up") {
|
||||
item = $(
|
||||
'<div id="' +
|
||||
|
|
|
@ -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';
|
||||
|
@ -665,6 +677,20 @@ $table_other->data[12][1] = html_print_input_text(
|
|||
true
|
||||
);
|
||||
|
||||
$table_other->data[13][0] = __('Events response max. execution');
|
||||
$table_other->data[13][0] .= ui_print_help_tip(
|
||||
__('Number of events that will perform the desired action at the same time'),
|
||||
true
|
||||
);
|
||||
$table_other->data[13][1] = html_print_input_text(
|
||||
'max_execution_event_response',
|
||||
$config['max_execution_event_response'],
|
||||
'',
|
||||
5,
|
||||
5,
|
||||
true
|
||||
);
|
||||
|
||||
echo '<form id="form_setup" method="post">';
|
||||
|
||||
echo '<fieldset>';
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -134,7 +134,8 @@ if (is_ajax()) {
|
|||
set_unless_defined($config['double_auth_enabled'], false);
|
||||
$row = [];
|
||||
$row['name'] = __('Double authentication').ui_print_help_tip(__('If this option is enabled, the users can use double authentication with their accounts'), true);
|
||||
$row['control'] = html_print_checkbox_toogle_switch('double_auth_enabled', 1, $config['double_auth_enabled'], true);
|
||||
$row['control'] = html_print_input_hidden('double_auth_enabled', 0);
|
||||
$row['control'] .= html_print_checkbox_toogle_switch('double_auth_enabled', 1, $config['double_auth_enabled'], true);
|
||||
$table->data['double_auth_enabled'] = $row;
|
||||
|
||||
// Session timeout
|
||||
|
|
|
@ -269,7 +269,13 @@ $table->data[37][0] = __('Audit log directory').ui_print_help_tip(__('Directory
|
|||
$table->data[37][1] = html_print_input_text('auditdir', io_safe_output($config['auditdir']), '', 30, 100, true);
|
||||
|
||||
$table->data[38][0] = __('Set alias as name by default in agent creation');
|
||||
$table->data[38][1] = html_print_checkbox_toogle_switch('alias_as_name', 1, $config['alias_as_name'], true);
|
||||
$table->data[38][1] = __('Yes').' '.html_print_radio_button('alias_as_name', 1, '', $config['alias_as_name'], true).' ';
|
||||
$table->data[38][1] .= __('No').' '.html_print_radio_button('alias_as_name', 0, '', $config['alias_as_name'], true);
|
||||
|
||||
$table->data[39][0] = __('Unique IP').ui_print_help_tip(__('Set the primary IP address as the unique IP, preventing the same primary IP address from being used in more than one agent'), true);
|
||||
$table->data[39][1] = __('Yes').' '.html_print_radio_button('unique_ip', 1, '', $config['unique_ip'], true).' ';
|
||||
$table->data[39][1] .= __('No').' '.html_print_radio_button('unique_ip', 0, '', $config['unique_ip'], true);
|
||||
|
||||
echo '<form id="form_setup" method="post" action="index.php?sec=gsetup&sec2=godmode/setup/setup&section=general&pure='.$config['pure'].'">';
|
||||
|
||||
echo '<fieldset>';
|
||||
|
@ -332,6 +338,11 @@ $(document).ready (function () {
|
|||
$("#zone").attr("hidden", false);
|
||||
$("#timezone").attr("hidden", false);
|
||||
});
|
||||
|
||||
if ($("input[name=use_cert]").is(':checked')) {
|
||||
$('#setup_general-13').show();
|
||||
}
|
||||
|
||||
$("input[name=use_cert]").change(function () {
|
||||
if( $(this).is(":checked") )
|
||||
$('#setup_general-13').show();
|
||||
|
|
|
@ -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').'</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: 329 B |
After Width: | Height: | Size: 401 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';
|
||||
|
@ -90,9 +105,9 @@ if ($get_response_params) {
|
|||
}
|
||||
|
||||
if ($get_response_target) {
|
||||
$response_id = get_parameter('response_id');
|
||||
$event_id = get_parameter('event_id');
|
||||
$server_id = get_parameter('server_id', 0);
|
||||
$response_id = (int) get_parameter('response_id');
|
||||
$event_id = (int) get_parameter('event_id');
|
||||
$server_id = (int) get_parameter('server_id');
|
||||
|
||||
$event_response = db_get_row('tevent_response', 'id', $response_id);
|
||||
|
||||
|
@ -101,7 +116,6 @@ if ($get_response_target) {
|
|||
}
|
||||
|
||||
echo events_get_response_target($event_id, $response_id, $server_id);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -210,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>';
|
||||
|
@ -242,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;
|
||||
}
|
||||
}
|
||||
|
@ -319,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;
|
||||
|
@ -341,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>';
|
||||
}
|
||||
|
@ -387,7 +428,7 @@ if ($get_extended_event) {
|
|||
|
||||
$tabs .= '</ul>';
|
||||
|
||||
// Get criticity image
|
||||
// Get criticity image.
|
||||
switch ($event['criticity']) {
|
||||
default:
|
||||
case 0:
|
||||
|
@ -419,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 {
|
||||
|
@ -427,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);
|
||||
|
@ -437,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);
|
||||
|
@ -464,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() {
|
||||
|
@ -472,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);';
|
||||
|
@ -482,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;
|
||||
}
|
||||
|
@ -543,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;">';
|
||||
|
@ -594,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(
|
||||
|
@ -612,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,
|
||||
|
@ -621,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);
|
||||
}
|
|
@ -198,12 +198,7 @@ if ($get_metaconsole_hash_data) {
|
|||
$console_password = $auth_serialized['console_password'];
|
||||
}
|
||||
|
||||
$pwd = $auth_token;
|
||||
// Create HASH login info
|
||||
$user = str_rot13($config['id_user']);
|
||||
$hashdata = $user.$pwd;
|
||||
$hashdata = md5($hashdata);
|
||||
$url_hash = "&loginhash=auto&loginhash_data=$hashdata&loginhash_user=$user";
|
||||
$url_hash = metaconsole_get_servers_url_hash($server);
|
||||
|
||||
echo $url_hash;
|
||||
return;
|
||||
|
|
|
@ -43,6 +43,7 @@ if (is_ajax()) {
|
|||
include_once $config['homedir'].'/include/class/TreeModule.class.php';
|
||||
include_once $config['homedir'].'/include/class/TreeTag.class.php';
|
||||
include_once $config['homedir'].'/include/class/TreeGroup.class.php';
|
||||
include_once $config['homedir'].'/include/class/TreeService.class.php';
|
||||
include_once $config['homedir'].'/include/class/TreeGroupEdition.class.php';
|
||||
enterprise_include_once('include/class/TreePolicies.class.php');
|
||||
enterprise_include_once('include/class/TreeGroupMeta.class.php');
|
||||
|
@ -120,6 +121,10 @@ if (is_ajax()) {
|
|||
$tree = new TreeGroupEdition($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
break;
|
||||
|
||||
case 'services':
|
||||
$tree = new TreeService($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
break;
|
||||
|
||||
default:
|
||||
// FIXME. No error handler
|
||||
return;
|
||||
|
@ -127,6 +132,7 @@ if (is_ajax()) {
|
|||
|
||||
$tree->setFilter($filter);
|
||||
ob_clean();
|
||||
|
||||
echo json_encode(['success' => 1, 'tree' => $tree->getArray()]);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1369,8 +1369,12 @@ function local_ldap_search($ldap_host, $ldap_port=389, $ldap_version=3, $dn, $ac
|
|||
$tls = ' -ZZ ';
|
||||
}
|
||||
|
||||
$ldap_host = ' -h '.$ldap_host;
|
||||
$ldap_port = ' -p '.$ldap_port;
|
||||
if (stripos($ldap_host, 'ldap') !== false) {
|
||||
$ldap_host = ' -H '.$ldap_host.':'.$ldap_port;
|
||||
} else {
|
||||
$ldap_host = ' -h '.$ldap_host.' -p '.$ldap_port;
|
||||
}
|
||||
|
||||
$ldap_version = ' -P '.$ldap_version;
|
||||
if (!empty($ldap_admin_user)) {
|
||||
$ldap_admin_user = " -D '".$ldap_admin_user."'";
|
||||
|
@ -1382,7 +1386,7 @@ function local_ldap_search($ldap_host, $ldap_port=389, $ldap_version=3, $dn, $ac
|
|||
|
||||
$dn = " -b '".$dn."'";
|
||||
|
||||
$shell_ldap_search = explode("\n", shell_exec('ldapsearch -LLL -o ldif-wrap=no -x'.$ldap_host.$ldap_port.$ldap_version.' -E pr=10000/noprompt '.$ldap_admin_user.$ldap_admin_pass.$dn.$filter.$tls.' | grep -v "^#\|^$" | sed "s/:\+ /=>/g"'));
|
||||
$shell_ldap_search = explode("\n", shell_exec('ldapsearch -LLL -o ldif-wrap=no -x'.$ldap_host.$ldap_version.' -E pr=10000/noprompt '.$ldap_admin_user.$ldap_admin_pass.$dn.$filter.$tls.' | grep -v "^#\|^$" | sed "s/:\+ /=>/g"'));
|
||||
foreach ($shell_ldap_search as $line) {
|
||||
$values = explode('=>', $line);
|
||||
if (!empty($values[0]) && !empty($values[1])) {
|
||||
|
|
|
@ -88,16 +88,13 @@ if (file_exists('languages/'.$user_language.'.mo')) {
|
|||
$params['menu'] = false;
|
||||
|
||||
if ((!isset($params['width']) || ($params['width'] <= 0))) {
|
||||
$params['width'] = 1048;
|
||||
$params['width'] = 650;
|
||||
}
|
||||
|
||||
$params_combined = json_decode($_REQUEST['data_combined'], true);
|
||||
$module_list = json_decode($_REQUEST['data_module_list'], true);
|
||||
$type_graph_pdf = $_REQUEST['type_graph_pdf'];
|
||||
|
||||
$aux_font_size = $config['font_size'];
|
||||
$config['font_size'] = ($config['font_size'] + 3);
|
||||
|
||||
echo '<div>';
|
||||
switch ($type_graph_pdf) {
|
||||
case 'combined':
|
||||
|
@ -216,7 +213,6 @@ if (file_exists('languages/'.$user_language.'.mo')) {
|
|||
|
||||
echo '</div>';
|
||||
|
||||
$config['font_size'] = $aux_font_size;
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
|
|
@ -57,6 +57,8 @@ class Tree
|
|||
|
||||
protected $L2inner = '';
|
||||
|
||||
protected $avoid_condition = false;
|
||||
|
||||
protected $L3forceTagCondition = false;
|
||||
|
||||
const TV_DEFAULT_AGENT_STATUS = -1;
|
||||
|
@ -77,6 +79,7 @@ class Tree
|
|||
$this->access = $access;
|
||||
|
||||
$userGroupsACL = users_get_groups(false, $this->access);
|
||||
|
||||
$this->userGroupsACL = empty($userGroupsACL) ? false : $userGroupsACL;
|
||||
$this->userGroups = $this->userGroupsACL;
|
||||
$this->userGroupsArray = array_keys($this->userGroups);
|
||||
|
@ -947,7 +950,6 @@ class Tree
|
|||
}
|
||||
|
||||
$this->processAgents($data);
|
||||
|
||||
$this->tree = $data;
|
||||
}
|
||||
|
||||
|
@ -1032,7 +1034,6 @@ class Tree
|
|||
|
||||
$data = $this->getProcessedModules($data);
|
||||
$this->processModules($data);
|
||||
|
||||
$this->tree = $data;
|
||||
}
|
||||
|
||||
|
@ -1051,8 +1052,13 @@ class Tree
|
|||
$tag_condition = $this->getTagCondition();
|
||||
$tag_join = empty($tag_condition) && (!$this->L3forceTagCondition) ? '' : $this->getTagJoin();
|
||||
|
||||
$condition = $this->L2condition;
|
||||
$inner = $this->L2inner;
|
||||
if ($this->avoid_condition === true) {
|
||||
$condition = '';
|
||||
$inner = '';
|
||||
} else {
|
||||
$condition = $this->L2condition;
|
||||
$inner = $this->L2inner;
|
||||
}
|
||||
|
||||
$columns = 'DISTINCT(tam.id_agente_modulo) AS id, tam.nombre AS name,
|
||||
tam.id_tipo_modulo, tam.id_modulo, tae.estado, tae.datos,
|
||||
|
@ -1076,10 +1082,10 @@ class Tree
|
|||
$group_acl
|
||||
$agent_search_filter
|
||||
$agent_status_filter
|
||||
$module_status_filter
|
||||
$module_search_filter
|
||||
$tag_condition
|
||||
ORDER BY tam.nombre ASC, tam.id_agente_modulo ASC";
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,9 +36,9 @@ class TreeGroup extends Tree
|
|||
];
|
||||
|
||||
$this->L2conditionInside = 'AND (
|
||||
ta.id_grupo = '.$this->id.'
|
||||
OR tasg.id_group = '.$this->id.'
|
||||
)';
|
||||
ta.id_grupo = '.$this->id.'
|
||||
OR tasg.id_group = '.$this->id.'
|
||||
)';
|
||||
}
|
||||
|
||||
|
||||
|
@ -198,44 +198,44 @@ class TreeGroup extends Tree
|
|||
$module_search_filter = '';
|
||||
if (!empty($this->filter['searchModule'])) {
|
||||
$module_search_inner = '
|
||||
INNER JOIN tagente_modulo tam
|
||||
ON ta.id_agente = tam.id_agente
|
||||
INNER JOIN tagente_estado tae
|
||||
ON tae.id_agente_modulo = tam.id_agente_modulo';
|
||||
INNER JOIN tagente_modulo tam
|
||||
ON ta.id_agente = tam.id_agente
|
||||
INNER JOIN tagente_estado tae
|
||||
ON tae.id_agente_modulo = tam.id_agente_modulo';
|
||||
$module_search_filter = "AND tam.disabled = 0
|
||||
AND tam.nombre LIKE '%%".$this->filter['searchModule']."%%' ".$this->getModuleStatusFilterFromTestado();
|
||||
AND tam.nombre LIKE '%%".$this->filter['searchModule']."%%' ".$this->getModuleStatusFilterFromTestado();
|
||||
}
|
||||
|
||||
$table = is_metaconsole() ? 'tmetaconsole_agent' : 'tagente';
|
||||
$table_sec = is_metaconsole() ? 'tmetaconsole_agent_secondary_group' : 'tagent_secondary_group';
|
||||
|
||||
$sql_model = "SELECT %s FROM
|
||||
(
|
||||
SELECT COUNT(DISTINCT(ta.id_agente)) AS total, id_grupo AS g
|
||||
FROM $table ta
|
||||
$module_search_inner
|
||||
WHERE ta.disabled = 0
|
||||
%s
|
||||
$agent_search_filter
|
||||
$agent_status_filter
|
||||
$module_status_filter
|
||||
$module_search_filter
|
||||
$group_acl
|
||||
GROUP BY id_grupo
|
||||
UNION ALL
|
||||
SELECT COUNT(DISTINCT(ta.id_agente)) AS total, id_group AS g
|
||||
FROM $table ta INNER JOIN $table_sec tasg
|
||||
ON ta.id_agente = tasg.id_agent
|
||||
$module_search_inner
|
||||
WHERE ta.disabled = 0
|
||||
%s
|
||||
$agent_search_filter
|
||||
$agent_status_filter
|
||||
$module_status_filter
|
||||
$module_search_filter
|
||||
$secondary_group_acl
|
||||
GROUP BY id_group
|
||||
) x GROUP BY g";
|
||||
(
|
||||
SELECT COUNT(DISTINCT(ta.id_agente)) AS total, id_grupo AS g
|
||||
FROM $table ta
|
||||
$module_search_inner
|
||||
WHERE ta.disabled = 0
|
||||
%s
|
||||
$agent_search_filter
|
||||
$agent_status_filter
|
||||
$module_status_filter
|
||||
$module_search_filter
|
||||
$group_acl
|
||||
GROUP BY id_grupo
|
||||
UNION ALL
|
||||
SELECT COUNT(DISTINCT(ta.id_agente)) AS total, id_group AS g
|
||||
FROM $table ta INNER JOIN $table_sec tasg
|
||||
ON ta.id_agente = tasg.id_agent
|
||||
$module_search_inner
|
||||
WHERE ta.disabled = 0
|
||||
%s
|
||||
$agent_search_filter
|
||||
$agent_status_filter
|
||||
$module_status_filter
|
||||
$module_search_filter
|
||||
$secondary_group_acl
|
||||
GROUP BY id_group
|
||||
) x GROUP BY g";
|
||||
$sql_array = [];
|
||||
foreach ($inside_fields as $inside_field) {
|
||||
$sql_array[] = sprintf(
|
||||
|
@ -247,9 +247,9 @@ class TreeGroup extends Tree
|
|||
}
|
||||
|
||||
$sql = "SELECT $fields FROM (".implode(' UNION ALL ', $sql_array).') x2
|
||||
RIGHT JOIN tgrupo tg
|
||||
ON x2.g = tg.id_grupo
|
||||
GROUP BY tg.id_grupo';
|
||||
RIGHT JOIN tgrupo tg
|
||||
ON x2.g = tg.id_grupo
|
||||
GROUP BY tg.id_grupo';
|
||||
$stats = db_get_all_rows_sql($sql);
|
||||
|
||||
$group_stats = [];
|
||||
|
|
|
@ -0,0 +1,352 @@
|
|||
<?php
|
||||
// Pandora FMS- http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2018 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.
|
||||
global $config;
|
||||
|
||||
require_once $config['homedir'].'/include/class/Tree.class.php';
|
||||
|
||||
class TreeService extends Tree
|
||||
{
|
||||
|
||||
protected $propagateCounters = true;
|
||||
|
||||
protected $displayAllGroups = false;
|
||||
|
||||
|
||||
public function __construct($type, $rootType='', $id=-1, $rootID=-1, $serverID=false, $childrenMethod='on_demand', $access='AR')
|
||||
{
|
||||
global $config;
|
||||
|
||||
parent::__construct($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access);
|
||||
|
||||
$this->L1fieldName = 'id_group';
|
||||
$this->L1extraFields = [
|
||||
'ts.name AS `name`',
|
||||
'ts.id AS `sid`',
|
||||
];
|
||||
|
||||
$this->filter['statusAgent'] = AGENT_STATUS_ALL;
|
||||
|
||||
$this->avoid_condition = true;
|
||||
|
||||
$this->L2inner = 'LEFT JOIN tservice_element tse
|
||||
ON tse.id_agent = ta.id_agente';
|
||||
|
||||
$this->L2condition = 'AND tse.id_service='.$this->id;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function setPropagateCounters($value)
|
||||
{
|
||||
$this->propagateCounters = (bool) $value;
|
||||
}
|
||||
|
||||
|
||||
public function setDisplayAllGroups($value)
|
||||
{
|
||||
$this->displayAllGroups = (bool) $value;
|
||||
}
|
||||
|
||||
|
||||
protected function getData()
|
||||
{
|
||||
if ($this->id == -1) {
|
||||
$this->getFirstLevel();
|
||||
} else if ($this->type == 'services') {
|
||||
$this->getSecondLevel();
|
||||
} else if ($this->type == 'agent') {
|
||||
$this->getThirdLevel();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function getFirstLevel()
|
||||
{
|
||||
$processed_items = $this->getProcessedServices();
|
||||
$ids = array_keys($processed_items);
|
||||
|
||||
$filter = ['id' => $ids];
|
||||
|
||||
$own_info = get_user_info($config['id_user']);
|
||||
|
||||
if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) {
|
||||
$display_all_services = true;
|
||||
} else {
|
||||
$display_all_services = false;
|
||||
}
|
||||
|
||||
$this->tree = [];
|
||||
|
||||
$services = services_get_services($filter, false, $display_all_services);
|
||||
|
||||
foreach ($services as $row) {
|
||||
$status = services_get_status($row, true);
|
||||
|
||||
switch ($status) {
|
||||
case SERVICE_STATUS_NORMAL:
|
||||
$processed_items[$row['id']]['statusImageHTML'] = '<img src="images/status_sets/default/agent_ok_ball.png" data-title="NORMAL status." data-use_title_for_force_title="1" class="forced_title" alt="NORMAL status." />';
|
||||
break;
|
||||
|
||||
case SERVICE_STATUS_CRITICAL:
|
||||
$processed_items[$row['id']]['statusImageHTML'] = '<img src="images/status_sets/default/agent_critical_ball.png" data-title="CRITICAL status." data-use_title_for_force_title="1" class="forced_title" alt="CRITICAL status." />';
|
||||
break;
|
||||
|
||||
case SERVICE_STATUS_WARNING:
|
||||
$processed_items[$row['id']][$key]['statusImageHTML'] = '<img src="images/status_sets/default/agent_warning_ball.png" data-title="WARNING status." data-use_title_for_force_title="1" class="forced_title" alt="WARNING status." />';
|
||||
break;
|
||||
|
||||
case SERVICE_STATUS_UNKNOWN:
|
||||
default:
|
||||
$processed_items[$row['id']]['statusImageHTML'] = '<img src="images/status_sets/default/agent_no_data_ball.png" data-title="UNKNOWN status." data-use_title_for_force_title="1" class="forced_title" alt="UNKNOWN status." />';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->tree = $processed_items;
|
||||
}
|
||||
|
||||
|
||||
protected function getProcessedServices()
|
||||
{
|
||||
$fields = $this->getFirstLevelFields();
|
||||
|
||||
if (users_can_manage_group_all('AR')) {
|
||||
$groups_acl = '';
|
||||
} else {
|
||||
$groups_acl = 'AND ts.id_group IN ('.implode(',', $this->userGroupsArray).')';
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
"SELECT t1.*
|
||||
FROM tservice_element tss
|
||||
RIGHT JOIN
|
||||
(SELECT ts.id, ts.id_agent_module, ts.name, ts.name AS `alias`, ts.id AS `rootID`,
|
||||
'services' AS rootType, 'services' AS type,
|
||||
0 AS quiet,
|
||||
SUM(if((tse.id_agent<>0), 1, 0)) AS `total_agents`,
|
||||
SUM(if((tse.id_agente_modulo<>0), 1, 0)) AS `total_modules`,
|
||||
SUM(if((tse.id_service_child<>0), 1, 0)) AS `total_services`
|
||||
FROM tservice ts
|
||||
LEFT JOIN tservice_element tse
|
||||
ON ts.id=tse.id_service
|
||||
GROUP BY id
|
||||
) as t1
|
||||
ON tss.id_service_child = t1.id
|
||||
WHERE tss.id_service_child IS NULL
|
||||
%s
|
||||
",
|
||||
$groups_acl
|
||||
);
|
||||
|
||||
$stats = db_get_all_rows_sql($sql);
|
||||
|
||||
$services = [];
|
||||
|
||||
foreach ($stats as $service) {
|
||||
$services[$service['id']] = $this->getProcessedItem($services[$service['id']]);
|
||||
if (($service['total_services'] + $service['total_agents'] + $service['total_modules']) > 0) {
|
||||
$services[$service['id']]['searchChildren'] = 1;
|
||||
} else {
|
||||
$services[$service['id']]['searchChildren'] = 0;
|
||||
}
|
||||
|
||||
$services[$service['id']]['counters'] = [
|
||||
'total_services' => $service['total_services'],
|
||||
'total_agents' => $service['total_agents'],
|
||||
'total_modules' => $service['total_modules'],
|
||||
];
|
||||
$services[$service['id']]['name'] = $service['name'];
|
||||
$services[$service['id']]['id'] = $service['id'];
|
||||
$services[$service['id']]['serviceDetail'] = 'index.php?sec=network&sec2=enterprise/operation/services/services&tab=service_map&id_service='.(int) $service['id'];
|
||||
}
|
||||
|
||||
return $services;
|
||||
}
|
||||
|
||||
|
||||
protected function getFirstLevelFields()
|
||||
{
|
||||
$fields = [];
|
||||
|
||||
return implode(',', array_merge($fields, $this->L1extraFields));
|
||||
}
|
||||
|
||||
|
||||
protected function getSecondLevel()
|
||||
{
|
||||
$data = [];
|
||||
$data_agents = [];
|
||||
$data_modules = [];
|
||||
$data_services = [];
|
||||
|
||||
$sql = $this->getSecondLevelSql();
|
||||
$data_agents = db_process_sql($sql);
|
||||
|
||||
if (empty($data_agents)) {
|
||||
$data_agents = [];
|
||||
}
|
||||
|
||||
$this->processAgents($data_agents);
|
||||
|
||||
foreach ($data_agents as $key => $agent) {
|
||||
$data_agents[$key]['showEventsBtn'] = 1;
|
||||
$data_agents[$key]['eventAgent'] = $agent['id'];
|
||||
}
|
||||
|
||||
$sql = $this->getSecondLevelModulesSql();
|
||||
$data_modules = db_process_sql($sql);
|
||||
|
||||
if (empty($data_modules)) {
|
||||
$data_modules = [];
|
||||
} else {
|
||||
foreach ($data_modules as $key => $module) {
|
||||
switch ($module['estado']) {
|
||||
case '0':
|
||||
$data_modules[$key]['statusImageHTML'] = '<img src="images/status_sets/default/agent_ok_ball.png" data-title="NORMAL status." data-use_title_for_force_title="1" class="forced_title" alt="NORMAL status." />';
|
||||
break;
|
||||
|
||||
case '1':
|
||||
$data_modules[$key]['statusImageHTML'] = '<img src="images/status_sets/default/agent_critical_ball.png" data-title="NORMAL status." data-use_title_for_force_title="1" class="forced_title" alt="CRITICAL status." />';
|
||||
break;
|
||||
|
||||
case '2':
|
||||
$data_modules[$key]['statusImageHTML'] = '<img src="images/status_sets/default/agent_warning_ball.png" data-title="NORMAL status." data-use_title_for_force_title="1" class="forced_title" alt="WARNING status." />';
|
||||
break;
|
||||
|
||||
case '4':
|
||||
$data_modules[$key]['statusImageHTML'] = '<img src="images/status_sets/default/agent_no_data_ball.png" data-title="NORMAL status." data-use_title_for_force_title="1" class="forced_title" alt="UNKNOWN status." />';
|
||||
break;
|
||||
|
||||
default:
|
||||
// code...
|
||||
break;
|
||||
}
|
||||
|
||||
$data_modules[$key]['showEventsBtn'] = 1;
|
||||
$data_modules[$key]['eventModule'] = $module['id_agente_modulo'];
|
||||
}
|
||||
}
|
||||
|
||||
$sql = $this->getSecondLevelServicesSql();
|
||||
$data_services = db_process_sql($sql);
|
||||
|
||||
$service_stats = [];
|
||||
|
||||
foreach ($data_services as $service) {
|
||||
$service_stats[$service['id']]['id'] = (int) $service['id'];
|
||||
$service_stats[$service['id']]['name'] = $service['name'];
|
||||
$service_stats[$service['id']]['alias'] = $service['name'];
|
||||
if (($service['total_services'] + $service['total_agents'] + $service['total_modules']) > 0) {
|
||||
$service_stats[$service['id']]['searchChildren'] = 1;
|
||||
} else {
|
||||
$services[$service['id']]['searchChildren'] = 0;
|
||||
}
|
||||
|
||||
$service_stats[$service['id']]['rootID'] = $service['rootID'];
|
||||
$service_stats[$service['id']]['rootType'] = $service['rootType'];
|
||||
$service_stats[$service['id']]['type'] = 'services';
|
||||
$service_stats[$service['id']]['children'] = [];
|
||||
$service_stats[$service['id']]['serviceDetail'] = 'index.php?sec=network&sec2=enterprise/operation/services/services&tab=service_map&id_service='.(int) $service['id'];
|
||||
$service_stats[$service['id']]['counters'] = [
|
||||
'total_services' => $service['total_services'],
|
||||
'total_agents' => $service['total_agents'],
|
||||
'total_modules' => $service['total_modules'],
|
||||
];
|
||||
}
|
||||
|
||||
$own_info = get_user_info($config['id_user']);
|
||||
|
||||
if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) {
|
||||
$display_all_services = true;
|
||||
} else {
|
||||
$display_all_services = false;
|
||||
}
|
||||
|
||||
$services = services_get_services($filter, false, $display_all_services);
|
||||
|
||||
foreach ($services as $row) {
|
||||
if (!array_key_exists($row['id'], $service_stats)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$status = services_get_status($row, true);
|
||||
|
||||
switch ($status) {
|
||||
case SERVICE_STATUS_NORMAL:
|
||||
$service_stats[$row['id']]['statusImageHTML'] = '<img src="images/status_sets/default/agent_ok_ball.png" data-title="NORMAL status." data-use_title_for_force_title="1" class="forced_title" alt="NORMAL status." />';
|
||||
break;
|
||||
|
||||
case SERVICE_STATUS_CRITICAL:
|
||||
$service_stats[$row['id']]['statusImageHTML'] = '<img src="images/status_sets/default/agent_critical_ball.png" data-title="CRITICAL status." data-use_title_for_force_title="1" class="forced_title" alt="CRITICAL status." />';
|
||||
break;
|
||||
|
||||
case SERVICE_STATUS_WARNING:
|
||||
$service_stats[$row['id']][$key]['statusImageHTML'] = '<img src="images/status_sets/default/agent_warning_ball.png" data-title="WARNING status." data-use_title_for_force_title="1" class="forced_title" alt="WARNING status." />';
|
||||
break;
|
||||
|
||||
case SERVICE_STATUS_UNKNOWN:
|
||||
default:
|
||||
$service_stats[$row['id']]['statusImageHTML'] = '<img src="images/status_sets/default/agent_no_data_ball.png" data-title="UNKNOWN status." data-use_title_for_force_title="1" class="forced_title" alt="UNKNOWN status." />';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$data_services = array_values($service_stats);
|
||||
|
||||
$data = array_merge($data_services, $data_agents, $data_modules);
|
||||
|
||||
if (empty($data)) {
|
||||
$this->tree = [];
|
||||
return;
|
||||
}
|
||||
|
||||
$this->tree = $data;
|
||||
}
|
||||
|
||||
|
||||
protected function getSecondLevelServicesSql()
|
||||
{
|
||||
$group_acl = $this->getGroupAclCondition();
|
||||
|
||||
$sql = "SELECT ts.id, ts.name, tse1.id_service AS `rootID`, 'services' AS rootType, 'services' AS type, 0 AS quiet, SUM(if((tse2.id_agent<>0), 1, 0)) AS `total_agents`, SUM(if((tse2.id_agente_modulo<>0), 1, 0)) AS `total_modules`, SUM(if((tse2.id_service_child<>0), 1, 0)) AS `total_services`, 0 AS fired_count, 0 AS normal_count, 0 AS warning_count, 0 AS critical_count, 0 AS unknown_count, 0 AS notinit_count, 0 AS state_critical, 0 AS state_warning, 0 AS state_unknown, 0 AS state_notinit, 0 AS state_normal, 0 AS state_total, '' AS statusImageHTML, '' AS alertImageHTML
|
||||
FROM tservice_element tse1
|
||||
LEFT JOIN tservice_element tse2 ON tse1.id_service_child=tse2.id_service
|
||||
LEFT JOIN tservice ts ON tse1.id_service_child=ts.id
|
||||
WHERE tse1.id_service=$this->id AND tse1.id_service_child<>0
|
||||
GROUP BY tse1.id_service_child
|
||||
";
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
||||
protected function getSecondLevelModulesSql()
|
||||
{
|
||||
$sql = "SELECT tse.id_agente_modulo, nombre AS `name`, nombre AS `alias`, tse.id_service AS `rootID`, 'services' AS `rootType`, 'modules' AS `type`, estado
|
||||
FROM tservice_element tse
|
||||
INNER JOIN tagente_modulo tam ON tse.id_agente_modulo=tam.id_agente_modulo
|
||||
INNER JOIN tagente_estado tae ON tam.id_agente_modulo=tae.id_agente_estado
|
||||
WHERE tse.id_service=$this->id AND tse.id_agente_modulo<>0
|
||||
";
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
||||
protected function getAgentStatusFilter($status=self::TV_DEFAULT_AGENT_STATUS)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -20,7 +20,7 @@
|
|||
/**
|
||||
* Pandora build version and version
|
||||
*/
|
||||
$build_version = 'PC190215';
|
||||
$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])) {
|
||||
|
|
|
@ -949,11 +949,11 @@ function agents_get_group_agents(
|
|||
|
||||
$filter = [];
|
||||
|
||||
// check available groups for target user only if asking for 'All' group
|
||||
// Check available groups for target user only if asking for 'All' group.
|
||||
if (!$noACL && $id_group == 0) {
|
||||
$id_group = $id_group == 0 ? array_keys(users_get_groups(false, 'AR', false)) : groups_safe_acl($config['id_user'], $id_group, 'AR');
|
||||
$id_group = ($id_group == 0) ? array_keys(users_get_groups(false, 'AR', false)) : groups_safe_acl($config['id_user'], $id_group, 'AR');
|
||||
if (empty($id_group)) {
|
||||
// An empty array means the user doesn't have access
|
||||
// An empty array means the user doesn't have access.
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
@ -970,7 +970,7 @@ function agents_get_group_agents(
|
|||
$id_group = groups_get_id_recursive($id_group, true);
|
||||
}
|
||||
|
||||
// check available groups for target user only if asking for 'All' group
|
||||
// Check available groups for target user only if asking for 'All' group.
|
||||
if (!$noACL && $id_group == 0) {
|
||||
$id_group = array_keys(
|
||||
users_get_groups(false, 'AR', true, false, (array) $id_group)
|
||||
|
@ -978,7 +978,7 @@ function agents_get_group_agents(
|
|||
}
|
||||
}
|
||||
|
||||
// Search for primary and secondary groups
|
||||
// Search for primary and secondary groups.
|
||||
if (!empty($id_group)) {
|
||||
$filter[] = '('.db_format_array_where_clause_sql(
|
||||
[
|
||||
|
@ -990,7 +990,7 @@ function agents_get_group_agents(
|
|||
}
|
||||
|
||||
if ($search === true) {
|
||||
// No added search. Show both disabled and non-disabled
|
||||
// No added search. Show both disabled and non-disabled.
|
||||
} else if (is_array($search)) {
|
||||
if (!$search['all_agents']) {
|
||||
$filter['disabled'] = 0;
|
||||
|
@ -3102,7 +3102,7 @@ function select_agents_for_module_group(
|
|||
'AND',
|
||||
'tagente_modulo',
|
||||
true,
|
||||
[],
|
||||
$filter['tags'],
|
||||
false
|
||||
);
|
||||
$sql_tags_inner = 'INNER JOIN ttag_module
|
||||
|
|
|
@ -363,23 +363,18 @@ function api_get_test_event_replication_db()
|
|||
// -------------------------DEFINED OPERATIONS FUNCTIONS-----------------
|
||||
function api_get_groups($thrash1, $thrash2, $other, $returnType, $user_in_db)
|
||||
{
|
||||
if (defined('METACONSOLE')) {
|
||||
return;
|
||||
$returnAllGroup = true;
|
||||
$returnAllColumns = false;
|
||||
|
||||
if (isset($other['data'][1])) {
|
||||
$returnAllGroup = ( $other['data'][1] == '1' ? true : false);
|
||||
}
|
||||
|
||||
if ($other['type'] == 'string') {
|
||||
if ($other['data'] != '') {
|
||||
returnError('error_parameter', 'Error in the parameters.');
|
||||
return;
|
||||
} else {
|
||||
// Default values
|
||||
$separator = ';';
|
||||
}
|
||||
} else if ($other['type'] == 'array') {
|
||||
$separator = $other['data'][0];
|
||||
if (isset($other['data'][2])) {
|
||||
$returnAllColumns = ( $other['data'][2] == '1' ? true : false);
|
||||
}
|
||||
|
||||
$groups = users_get_groups($user_in_db, 'IR');
|
||||
$groups = users_get_groups($user_in_db, 'IR', $returnAllGroup, $returnAllColumns);
|
||||
|
||||
$data_groups = [];
|
||||
foreach ($groups as $id => $group) {
|
||||
|
@ -389,6 +384,13 @@ function api_get_groups($thrash1, $thrash2, $other, $returnType, $user_in_db)
|
|||
];
|
||||
}
|
||||
|
||||
if (!isset($other['data'][0])) {
|
||||
$separator = ';';
|
||||
// by default
|
||||
} else {
|
||||
$separator = $other['data'][0];
|
||||
}
|
||||
|
||||
$data['type'] = 'array';
|
||||
$data['data'] = $data_groups;
|
||||
|
||||
|
@ -6173,17 +6175,29 @@ function api_set_planned_downtimes_deleted($id, $thrash1, $thrash2, $returnType)
|
|||
|
||||
/**
|
||||
* Create a new planned downtime.
|
||||
* e.g.: api.php?op=set&op2=planned_downtimes_created&id=pepito&other=testing|08-22-2015|08-31-2015|0|1|1|1|1|1|1|1|17:06:00|19:06:00|1|31|quiet|periodically|weekly&other_mode=url_encode_separator_|
|
||||
*
|
||||
* @param $id name of planned downtime.
|
||||
* @param $thrash1 Don't use.
|
||||
* @param array $other it's array, $other as param is <description>;<date_from>;<date_to>;<id_group>;<monday>;
|
||||
* <tuesday>;<wednesday>;<thursday>;<friday>;<saturday>;<sunday>;<periodically_time_from>;<periodically_time_to>;
|
||||
* <periodically_day_from>;<periodically_day_to>;<type_downtime>;<type_execution>;<type_periodicity>; in this order
|
||||
* and separator char (after text ; ) and separator (pass in param othermode as othermode=url_encode_separator_<separator>)
|
||||
* example:
|
||||
*
|
||||
* api.php?op=set&op2=planned_downtimes_created&id=pepito&other=testing|08-22-2015|08-31-2015|0|1|1|1|1|1|1|1|17:06:00|19:06:00|1|31|quiet|periodically|weekly&other_mode=url_encode_separator_|
|
||||
*
|
||||
* @param array $other Contains the following elements (in order):
|
||||
* <description>
|
||||
* <date_from>
|
||||
* <date_to>
|
||||
* <id_group>
|
||||
* <monday>
|
||||
* <tuesday>
|
||||
* <wednesday>
|
||||
* <thursday>
|
||||
* <friday>
|
||||
* <saturday>
|
||||
* <sunday>
|
||||
* <periodically_time_from>
|
||||
* <periodically_time_to>
|
||||
* <periodically_day_from>
|
||||
* <periodically_day_to>
|
||||
* <type_downtime>
|
||||
* <type_execution>
|
||||
* <type_periodicity>
|
||||
* @param $thrash3 Don't use.
|
||||
*/
|
||||
|
||||
|
@ -6247,20 +6261,16 @@ function api_set_planned_downtimes_created($id, $thrash1, $other, $thrash3)
|
|||
|
||||
/**
|
||||
* Add new items to planned Downtime.
|
||||
* e.g.: api.php?op=set&op2=planned_downtimes_additem&id=123&other=1;2;3;4|Status;Unkown_modules&other_mode=url_encode_separator_|
|
||||
*
|
||||
* @param $id id of planned downtime.
|
||||
* @param $thrash1 Don't use.
|
||||
* @param array $other it's array, $other as param is <id_agent1;id_agent2;id_agent3;....id_agentn;>;
|
||||
* <name_module1;name_module2;name_module3;......name_modulen;> in this order
|
||||
* and separator char (after text ; ) and separator (pass in param othermode as othermode=url_encode_separator_<separator>)
|
||||
* example:
|
||||
*
|
||||
* api.php?op=set&op2=planned_downtimes_additem&id=123&other=1;2;3;4|Status;Unkown_modules&other_mode=url_encode_separator_|
|
||||
*
|
||||
* @param array $other
|
||||
* The first index contains a list of agent Ids.
|
||||
* The second index contains a list of module names.
|
||||
* The list separator is the character ';'.
|
||||
* @param $thrash3 Don't use.
|
||||
*/
|
||||
|
||||
|
||||
function api_set_planned_downtimes_additem($id, $thrash1, $other, $thrash3)
|
||||
{
|
||||
if (defined('METACONSOLE')) {
|
||||
|
|
|
@ -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'))) {
|
||||
|
@ -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) {
|
||||
|
@ -468,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');
|
||||
}
|
||||
|
@ -635,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) {
|
||||
|
@ -732,13 +748,17 @@ function config_update_config()
|
|||
}
|
||||
}
|
||||
|
||||
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_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');
|
||||
}
|
||||
|
@ -1052,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');
|
||||
|
@ -1128,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) {
|
||||
|
@ -1146,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);
|
||||
|
@ -1168,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');
|
||||
}
|
||||
|
@ -1329,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) {
|
||||
|
@ -1351,7 +1379,9 @@ function config_update_config()
|
|||
|
||||
|
||||
/**
|
||||
* Process config variables
|
||||
* Process config variables.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function config_process_config()
|
||||
{
|
||||
|
@ -1369,7 +1399,7 @@ function config_process_config()
|
|||
$is_windows = true;
|
||||
}
|
||||
|
||||
// Compatibility fix
|
||||
// Compatibility fix.
|
||||
foreach ($configs as $c) {
|
||||
$config[$c['token']] = $c['value'];
|
||||
}
|
||||
|
@ -1426,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);
|
||||
}
|
||||
|
||||
|
@ -1446,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');
|
||||
}
|
||||
|
||||
|
@ -1458,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'];
|
||||
}
|
||||
|
@ -1509,6 +1539,10 @@ function config_process_config()
|
|||
}
|
||||
}
|
||||
|
||||
if (!isset($config['delete_old_messages'])) {
|
||||
config_update_value('delete_old_messages', 21);
|
||||
}
|
||||
|
||||
if (!isset($config['max_graph_container'])) {
|
||||
config_update_value('max_graph_container', 10);
|
||||
}
|
||||
|
@ -1658,8 +1692,9 @@ function config_process_config()
|
|||
}
|
||||
|
||||
/*
|
||||
*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'])) {
|
||||
|
@ -1675,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';
|
||||
|
||||
|
@ -2271,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');
|
||||
|
||||
|
@ -2293,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 {
|
||||
|
@ -2315,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 {
|
||||
|
@ -2445,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);
|
||||
|
@ -2477,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);
|
||||
}
|
||||
|
@ -2587,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);
|
||||
}
|
||||
|
@ -2622,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($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()]);
|
||||
}
|
||||
|
@ -2909,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']);
|
||||
|
@ -2922,6 +2748,11 @@ function config_user_set_custom_config()
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function config_prepare_session()
|
||||
{
|
||||
global $config;
|
||||
|
@ -2934,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;
|
||||
}
|
||||
|
||||
|
@ -2947,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']);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -126,6 +126,12 @@ if (isset($config['homedir_filemanager'])) {
|
|||
$homedir_filemanager = $config['homedir'];
|
||||
}
|
||||
|
||||
$sec2 = get_parameter('sec2');
|
||||
if ($sec2 == 'enterprise/godmode/agentes/collections') {
|
||||
$homedir_filemanager .= '/attachment/collection/';
|
||||
}
|
||||
|
||||
|
||||
$upload_file_or_zip = (bool) get_parameter('upload_file_or_zip');
|
||||
|
||||
if ($upload_file_or_zip) {
|
||||
|
@ -499,12 +505,6 @@ function filemanager_file_explorer(
|
|||
$homedir_filemanager = $config['homedir'];
|
||||
}
|
||||
|
||||
unset($config['homedir_filemanager']);
|
||||
config_update_value(
|
||||
'homedir_filemanager',
|
||||
$homedir_filemanager
|
||||
);
|
||||
|
||||
$hack_metaconsole = '';
|
||||
if (defined('METACONSOLE')) {
|
||||
$hack_metaconsole = '../../';
|
||||
|
@ -938,4 +938,3 @@ function filemanager_list_dir($dirpath)
|
|||
|
||||
return array_merge($dirs, $files);
|
||||
}
|
||||
|
||||
|
|
|
@ -245,7 +245,9 @@ function grafico_modulo_sparse_data(
|
|||
}
|
||||
}
|
||||
|
||||
if ($array_data === false || (!$params['graph_combined'] && !isset($array_data['sum1']['data'][0][1]))) {
|
||||
if ($array_data === false || (!$params['graph_combined']
|
||||
&& !isset($array_data['sum1']['data'][0][1]) && !$params['baseline'])
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -547,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;
|
||||
}
|
||||
|
@ -708,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';
|
||||
|
@ -1316,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) {
|
||||
|
@ -1392,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) {
|
||||
|
@ -4918,21 +4933,19 @@ function get_baseline_data($agent_module_id, $date_array, $data_module_graph, $p
|
|||
$period = $date_array['period'];
|
||||
$date = $date_array['final_date'];
|
||||
$array_data = [];
|
||||
|
||||
for ($i = 0; $i < 4; $i++) {
|
||||
$date_array = [];
|
||||
$date_array['period'] = $period;
|
||||
$date_array['final_date'] = ($date - $period * $i);
|
||||
$date_array['start_date'] = ($date - $period * ($i + 1));
|
||||
|
||||
$data = grafico_modulo_sparse_data(
|
||||
$date_array['final_date'] = ($date - ($period * $i));
|
||||
$date_array['start_date'] = ($date - ($period * ($i + 1)));
|
||||
$array_data[] = grafico_modulo_sparse_data(
|
||||
$agent_module_id,
|
||||
$date_array,
|
||||
$data_module_graph,
|
||||
$params,
|
||||
$i
|
||||
);
|
||||
|
||||
$array_data[] = $data;
|
||||
}
|
||||
|
||||
$result = [];
|
||||
|
|
|
@ -3073,3 +3073,45 @@ function html_print_csrf_error()
|
|||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print an swith button
|
||||
*
|
||||
* @param array $atributes. Valid params:
|
||||
* name: Usefull to handle in forms
|
||||
* value: If is checked or not
|
||||
* disabled: Disabled. Cannot be pressed.
|
||||
* id: Optional id for the switch.
|
||||
* class: Additional classes (string).
|
||||
* @return string with HTML of button
|
||||
*/
|
||||
function html_print_switch($attributes=[])
|
||||
{
|
||||
$html_expand = '';
|
||||
|
||||
// Check the load values on status.
|
||||
$html_expand .= (bool) $attributes['value'] ? ' checked' : '';
|
||||
$html_expand .= (bool) $attributes['disabled'] ? ' disabled' : '';
|
||||
|
||||
// Only load the valid attributes.
|
||||
$valid_attrs = [
|
||||
'id',
|
||||
'class',
|
||||
'name',
|
||||
'onclick',
|
||||
];
|
||||
foreach ($valid_attrs as $va) {
|
||||
if (!isset($attributes[$va])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$html_expand .= ' '.$va.'="'.$attributes[$va].'"';
|
||||
}
|
||||
|
||||
return "<label class='p-switch'>
|
||||
<input type='checkbox' $html_expand>
|
||||
<span class='p-slider'></span>
|
||||
</label>";
|
||||
}
|
||||
|
||||
|
|
|
@ -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'])
|
||||
);
|
||||
}
|
|
@ -725,8 +725,6 @@ function planned_downtimes_created($values)
|
|||
$check_group = (bool) db_get_value('id_grupo', 'tgrupo', 'id_grupo', $values['id_group']);
|
||||
$check = (bool) db_get_value('name', 'tplanned_downtime', 'name', $values['name']);
|
||||
|
||||
$datetime_from = strtotime($values['once_date_from'].' '.$values['once_time_from']);
|
||||
$datetime_to = strtotime($values['once_date_to'].' '.$values['once_time_to']);
|
||||
$now = time();
|
||||
$result = false;
|
||||
|
||||
|
@ -735,16 +733,16 @@ function planned_downtimes_created($values)
|
|||
'return' => false,
|
||||
'message' => __('Not created. Error inserting data. Start time must be higher than the current time'),
|
||||
];
|
||||
} else if ($values['type_execution'] == 'once' && !$config['past_planned_downtimes'] && $values['date_to'] <= $now) {
|
||||
return [
|
||||
'return' => false,
|
||||
'message' => __('Not created. Error inserting data').'. '.__('The end date must be higher than the current time'),
|
||||
];
|
||||
} else if ($values['type_execution'] == 'once' && $values['date_from'] >= $values['date_to']) {
|
||||
return [
|
||||
'return' => false,
|
||||
'message' => __('Not created. Error inserting data').'. '.__('The end date must be higher than the start date'),
|
||||
];
|
||||
} else if ($values['type_execution'] == 'once' && $values['date_to'] <= $now) {
|
||||
return [
|
||||
'return' => false,
|
||||
'message' => __('Not created. Error inserting data').'. '.__('The end date must be higher than the current time'),
|
||||
];
|
||||
} else if ($values['type_execution'] == 'periodically'
|
||||
&& (($values['type_periodicity'] == 'weekly' && $values['periodically_time_from'] >= $values['periodically_time_to'])
|
||||
|| ($values['type_periodicity'] == 'monthly' && $values['periodically_day_from'] == $values['periodically_day_to'] && $values['periodically_time_from'] >= $values['periodically_time_to']))
|
||||
|
|
|
@ -142,7 +142,6 @@ function reporting_make_reporting_data(
|
|||
enterprise_include_once('include/functions_metaconsole.php');
|
||||
|
||||
$return = [];
|
||||
|
||||
if (!empty($report)) {
|
||||
$contents = $report['contents'];
|
||||
} else {
|
||||
|
@ -261,7 +260,7 @@ function reporting_make_reporting_data(
|
|||
}
|
||||
|
||||
if (isset($content['style']['name_label'])) {
|
||||
// Add macros name
|
||||
// Add macros name.
|
||||
$items_label = [];
|
||||
$items_label['type'] = $content['type'];
|
||||
$items_label['id_agent'] = $content['id_agent'];
|
||||
|
@ -272,11 +271,10 @@ function reporting_make_reporting_data(
|
|||
$metaconsole_on = is_metaconsole();
|
||||
$server_name = $content['server_name'];
|
||||
|
||||
// Metaconsole connection
|
||||
// Metaconsole connection.
|
||||
if ($metaconsole_on && $server_name != '') {
|
||||
$connection = metaconsole_get_connection($server_name);
|
||||
if (!metaconsole_load_external_db($connection)) {
|
||||
// ui_print_error_message ("Error connecting to ".$server_name);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -889,7 +887,6 @@ function reporting_SLA(
|
|||
if ($metaconsole_on && $server_name != '') {
|
||||
$connection = metaconsole_get_connection($server_name);
|
||||
if (!metaconsole_load_external_db($connection)) {
|
||||
// ui_print_error_message ("Error connecting to ".$server_name);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -898,7 +895,7 @@ function reporting_SLA(
|
|||
|| modules_is_not_init($sla['id_agent_module'])
|
||||
) {
|
||||
if ($metaconsole_on) {
|
||||
// Restore db connection
|
||||
// Restore db connection.
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
|
||||
|
@ -6794,7 +6791,6 @@ function reporting_general($report, $content)
|
|||
if (!is_numeric($data_res[$index])) {
|
||||
$return['data'][$ag_name][$mod_name] = $data_res[$index];
|
||||
} else {
|
||||
hd($data_res[$index], true);
|
||||
$return['data'][$ag_name][$mod_name] = format_for_graph($data_res[$index], 2).' '.$unit;
|
||||
}
|
||||
}
|
||||
|
@ -11336,3 +11332,27 @@ function reporting_translate_sla_status_for_graph($status)
|
|||
];
|
||||
return $sts[$status];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print header to report pdf and add page break
|
||||
*
|
||||
* @param string $title Title of report.
|
||||
* @param string $description Description of report.
|
||||
*
|
||||
* @return html Return table of header.
|
||||
*/
|
||||
function reporting_header_table_for_pdf(string $title='', string $description='')
|
||||
{
|
||||
$result_pdf .= '<pagebreak>';
|
||||
$result_pdf .= '<table class="header_table databox">';
|
||||
$result_pdf .= '<thead class="header_tr"><tr>';
|
||||
$result_pdf .= '<th class="th_first" colspan="2">';
|
||||
$result_pdf .= $title;
|
||||
$result_pdf .= '</th><th style="font-size: 15px;" align="right">';
|
||||
$result_pdf .= '</th></tr><tr><th colspan="3" class="th_description">';
|
||||
$result_pdf .= $description;
|
||||
$result_pdf .= '</th></tr></thead></table>';
|
||||
|
||||
return $result_pdf;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -748,7 +748,7 @@ function tags_get_acl_tags(
|
|||
$id_user = $config['id_user'];
|
||||
}
|
||||
|
||||
if (is_user_admin($id_user)) {
|
||||
if (is_user_admin($id_user) && empty($childrens_ids)) {
|
||||
switch ($return_mode) {
|
||||
case 'data':
|
||||
return [];
|
||||
|
@ -797,7 +797,8 @@ function tags_get_acl_tags(
|
|||
// Return the condition of the tags for tagente_modulo table
|
||||
$condition = tags_get_acl_tags_module_condition(
|
||||
$acltags,
|
||||
$query_table
|
||||
$query_table,
|
||||
empty($childrens_ids) ? [] : $childrens_ids
|
||||
);
|
||||
if (!empty($condition)) {
|
||||
return " $query_prefix ".$condition;
|
||||
|
@ -825,7 +826,7 @@ function tags_get_acl_tags(
|
|||
*
|
||||
* @return string SQL condition for tagente_module
|
||||
*/
|
||||
function tags_get_acl_tags_module_condition($acltags, $modules_table='')
|
||||
function tags_get_acl_tags_module_condition($acltags, $modules_table='', $force_tags=[])
|
||||
{
|
||||
if (!empty($modules_table)) {
|
||||
$modules_table .= '.';
|
||||
|
@ -839,6 +840,17 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table='')
|
|||
// The acltags array contains the groups with the acl propagation applied
|
||||
// after the changes done into the 'tags_get_user_groups_and_tags' function.
|
||||
foreach ($acltags as $group_id => $group_tags) {
|
||||
if (empty($group_tags)) {
|
||||
$group_tags = [];
|
||||
if (!empty($force_tags)) {
|
||||
$group_tags = $force_tags;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($group_tags)) {
|
||||
$group_tags = array_intersect($force_tags, $group_tags);
|
||||
}
|
||||
|
||||
$tag_join = '';
|
||||
if (!empty($group_tags)) {
|
||||
$tag_join = sprintf('AND ttag_module.id_tag IN (%s)', is_array($group_tags) ? implode(',', $group_tags) : $group_tags);
|
||||
|
@ -849,7 +861,7 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table='')
|
|||
}
|
||||
|
||||
$group_conditions[] = $agent_condition;
|
||||
} else {
|
||||
} else if (!empty($force_tags)) {
|
||||
$without_tags[] = $group_id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1313,20 +1313,79 @@ function visual_map_editor_print_hack_translate_strings()
|
|||
echo '<span id="any_text" style="display: none;">'.__('Any').'</span>';
|
||||
echo '<span id="ip_text" style="display: none;">'.__('IP').'</span>';
|
||||
|
||||
// Hack to translate messages in javascript
|
||||
echo '<span style="display: none" id="message_alert_no_label_no_image">'.__('No image or name defined.').'</span>';
|
||||
echo '<span style="display: none" id="message_alert_no_label">'.__('No label defined.').'</span>';
|
||||
echo '<span style="display: none" id="message_alert_no_image">'.__('No image defined.').'</span>';
|
||||
echo '<span style="display: none" id="message_alert_no_process">'.__('No process defined.').'</span>';
|
||||
echo '<span style="display: none" id="message_alert_no_max_percentile">'.__('No Max value defined.').'</span>';
|
||||
echo '<span style="display: none" id="message_alert_no_width_percentile">'.__('No width defined.').'</span>';
|
||||
echo '<span style="display: none" id="message_alert_no_bars_graph_height">'.__('No height defined.').'</span>';
|
||||
echo '<span style="display: none" id="message_alert_no_period">'.__('No period defined.').'</span>';
|
||||
echo '<span style="display: none" id="message_alert_no_agent">'.__('No agent defined.').'</span>';
|
||||
echo '<span style="display: none" id="message_alert_no_module">'.__('No module defined.').'</span>';
|
||||
// Hack to translate messages in javascript.
|
||||
echo "<div id='message_min_allowed_size' title='".__('Visual Console Builder Information')."' style='display:none;'>";
|
||||
echo "<p style='text-align: center;font-weight: bold;'>".__('Min allowed size is 1024x768.').'</p>';
|
||||
echo '</div>';
|
||||
|
||||
echo "<div id='message_alert_no_custom_graph' title='".__('Visual Console Builder Information')."' style='display:none;'>";
|
||||
echo "<p style='text-align: center;font-weight: bold;'>".__('No custom graph defined.').'</p>';
|
||||
echo '</div>';
|
||||
|
||||
echo "<div id='message_alert_no_label_no_image' title='".__('Visual Console Builder Information')."' style='display:none;'>";
|
||||
echo "<p style='text-align: center;font-weight: bold;'>".__('No image or name defined.').'</p>';
|
||||
echo '</div>';
|
||||
|
||||
echo "<div id='message_alert_no_label' title='".__('Visual Console Builder Information')."' style='display:none;'>";
|
||||
echo "<p style='text-align: center;font-weight: bold;'>".__('No label defined.').'</p>';
|
||||
echo '</div>';
|
||||
|
||||
echo "<div id='message_alert_no_service' title='".__('Visual Console Builder Information')."' style='display:none;'>";
|
||||
echo "<p style='text-align: center;font-weight: bold;'>".__('No service defined.').'</p>';
|
||||
echo '</div>';
|
||||
|
||||
echo "<div id='message_alert_no_image' title='".__('Visual Console Builder Information')."' style='display:none;'>";
|
||||
echo "<p style='text-align: center;font-weight: bold;'>".__('No image defined.').'</p>';
|
||||
echo '</div>';
|
||||
|
||||
echo "<div id='message_alert_no_process' title='".__('Visual Console Builder Information')."' style='display:none;'>";
|
||||
echo "<p style='text-align: center;font-weight: bold;'>".__('No process defined.').'</p>';
|
||||
echo '</div>';
|
||||
|
||||
echo "<div id='message_alert_no_max_percentile' title='".__('Visual Console Builder Information')."' style='display:none;'>";
|
||||
echo "<p style='text-align: center;font-weight: bold;'>".__('No Max value defined.').'</p>';
|
||||
echo '</div>';
|
||||
|
||||
echo "<div id='message_alert_no_width' title='".__('Visual Console Builder Information')."' style='display:none;'>";
|
||||
echo "<p style='text-align: center;font-weight: bold;'>".__('No width defined.').'</p>';
|
||||
echo '</div>';
|
||||
|
||||
echo "<div id='message_alert_no_height' title='".__('Visual Console Builder Information')."' style='display:none;'>";
|
||||
echo "<p style='text-align: center;font-weight: bold;'>".__('No height defined.').'</p>';
|
||||
echo '</div>';
|
||||
|
||||
echo "<div id='message_alert_max_width' title='".__('Visual Console Builder Information')."' style='display:none;'>";
|
||||
echo "<p style='text-align: center;font-weight: bold;'>".__('The width must not exceed the size of the visual console container.').'</p>';
|
||||
echo '</div>';
|
||||
|
||||
echo "<div id='message_alert_max_height' title='".__('Visual Console Builder Information')."' style='display:none;'>";
|
||||
echo "<p style='text-align: center;font-weight: bold;'>".__('The height must not exceed the size of the visual console container.').'</p>';
|
||||
echo '</div>';
|
||||
|
||||
echo "<div id='message_alert_no_period' title='".__('Visual Console Builder Information')."' style='display:none;'>";
|
||||
echo "<p style='text-align: center;font-weight: bold;'>".__('No period defined.').'</p>';
|
||||
echo '</div>';
|
||||
|
||||
echo "<div id='message_alert_no_agent' title='".__('Visual Console Builder Information')."' style='display:none;'>";
|
||||
echo "<p style='text-align: center;font-weight: bold;'>".__('No agent defined.').'</p>';
|
||||
echo '</div>';
|
||||
|
||||
echo "<div id='message_alert_no_module' title='".__('Visual Console Builder Information')."' style='display:none;'>";
|
||||
echo "<p style='text-align: center;font-weight: bold;'>".__('No module defined.').'</p>';
|
||||
echo '</div>';
|
||||
|
||||
echo "<div id='message_alert_no_module_string_type' title='".__('Visual Console Builder Information')."' style='display:none;'>";
|
||||
echo "<p style='text-align: center;font-weight: bold;'>".__('No module defined. This module must be string type.').'</p>';
|
||||
echo '</div>';
|
||||
|
||||
echo "<div id='hack_translation_correct_save' title='".__('Visual Console Builder Information')."' style='display:none;'>";
|
||||
echo "<p style='text-align: center;font-weight: bold;'>".__('Successfully save the changes.').'</p>';
|
||||
echo '</div>';
|
||||
|
||||
echo "<div id='hack_translation_incorrect_save' title='".__('Visual Console Builder Information')."' style='display:none;'>";
|
||||
echo "<p style='text-align: center;font-weight: bold;'>".__('Could not be save.').'</p>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<span style="display: none" id="hack_translation_correct_save">'.__('Successfully save the changes.').'</span>';
|
||||
echo '<span style="display: none" id="hack_translation_incorrect_save">'.__('Could not be save').'</span>';
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -856,11 +856,12 @@ function pandoraFlotSlicebar(
|
|||
}
|
||||
|
||||
var font_size = parseInt(font_size);
|
||||
var font = font
|
||||
.split("/")
|
||||
.pop()
|
||||
.split(".")
|
||||
.shift();
|
||||
if (font != undefined)
|
||||
var font = font
|
||||
.split("/")
|
||||
.pop()
|
||||
.split(".")
|
||||
.shift();
|
||||
// Check possible adapt_keys on classes
|
||||
check_adaptions(graph_id);
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
/**
|
||||
* @package Include/help/en
|
||||
*/
|
||||
?>
|
||||
<h1>Module macros</h1>
|
||||
|
||||
<p>
|
||||
The following macros are available:
|
||||
<ul>
|
||||
<li>_agentcustomfield_<i>n</i>_: Agent custom field number <i>n</i> (eg. _agentcustomfield_9_).</li>
|
||||
</ul>
|
||||
<p>
|
||||
</p>
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -32,7 +32,8 @@ The accepted macros are:
|
|||
<li><b>Event associated module name:</b> _module_name_</li>
|
||||
<li><b>Event owner user:</b> _owner_user_</li>
|
||||
<li><b>User ID:</b> _user_id_</li>
|
||||
</ul>
|
||||
<li><b>Id of the user who fires the response:</b> _current_user_</li>
|
||||
</ul>
|
||||
|
||||
<h4>Custom fields</h4>
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* @package Include/help/en
|
||||
*/
|
||||
?>
|
||||
<h1>Macros de módulos</h1>
|
||||
|
||||
<p>
|
||||
Las siguientes macros están disponibles:
|
||||
</p>
|
||||
<ul>
|
||||
<li>_agentcustomfield_<i>n</i>_: Campo personalizado número <i>n</i> del agente (eg. _agentcustomfield_9_). </li>
|
||||
</ul>
|
|
@ -33,6 +33,7 @@ Las macros aceptadas son las siguientes:
|
|||
<li><b>Nombre del módulo asociado al evento:</b> _module_name_</li>
|
||||
<li><b>Usuario propietario del evento:</b> _owner_user_</li>
|
||||
<li><b>Id del usuario:</b> _user_id_</li>
|
||||
<li><b>Id del usuario que ejecuta la respuesta:</b> _current_user_</li>
|
||||
</ul>
|
||||
|
||||
<h4>Campos personalizados</h4>
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
/**
|
||||
* @package Include/help/ja
|
||||
*/
|
||||
?>
|
||||
<h1>モジュールマクロ</h1>
|
||||
|
||||
<p>
|
||||
次のマクロが利用できます:
|
||||
</p>
|
||||
<ul>
|
||||
<li>_agentcustomfield_<i>n</i>_ : エージェントカスタムフィールド番号<i>n</i> (例: _agentcustomfield_9_). </li>
|
||||
</ul>
|
||||
<p>
|
||||
</p>
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
検出タスクの名前です。フィルターやテンプレートとは異なり、タスクを区別しやすい説明を入れるだけです。<br><br>
|
||||
|
||||
<b>自動検出サーバ(Recon server)</b><br>
|
||||
<b>自動検出サーバ(Discovery server)</b><br>
|
||||
|
||||
タスクを割り当てる自動検出サーバです。複数の自動検出サーバがある場合は、自動検出タスクをどのサーバで実行するかを選択します。<br><br>
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
<li><b>Event associated module name:</b> _module_name_</li>
|
||||
<li><b>Event owner user:</b> _owner_user_</li>
|
||||
<li><b>User ID:</b> _user_id_</li>
|
||||
<li><b>Id of the user who fires the response:</b> _current_user_</li>
|
||||
</ul>
|
||||
|
||||
<h4>Custom fields</h4>
|
||||
|
|
|
@ -503,6 +503,14 @@ function module_changed_by_multiple_modules(event, id_module, selected) {
|
|||
selection_mode = "common";
|
||||
}
|
||||
|
||||
var tags_selected = [];
|
||||
|
||||
var tags_to_search = $("#tags").val();
|
||||
if (tags_to_search != null) {
|
||||
if (tags_to_search[0] != -1) {
|
||||
tags_selected = tags_to_search;
|
||||
}
|
||||
}
|
||||
jQuery.post(
|
||||
"ajax.php",
|
||||
{
|
||||
|
@ -510,7 +518,8 @@ function module_changed_by_multiple_modules(event, id_module, selected) {
|
|||
get_agents_json_for_multiple_modules: 1,
|
||||
status_module: status_module,
|
||||
"module_name[]": idModules,
|
||||
selection_mode: selection_mode
|
||||
selection_mode: selection_mode,
|
||||
tags: tags_selected
|
||||
},
|
||||
function(data) {
|
||||
$("#agents").append(
|
||||
|
|
|
@ -115,8 +115,21 @@ var TreeController = {
|
|||
}
|
||||
};
|
||||
|
||||
var serviceCounterTitles = {
|
||||
total_services: {
|
||||
totals: "Services"
|
||||
},
|
||||
total_agents: {
|
||||
totals: "Agents"
|
||||
},
|
||||
total_modules: {
|
||||
totals: "Modules"
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
var title = "";
|
||||
|
||||
switch (elementType) {
|
||||
case "group":
|
||||
if (
|
||||
|
@ -144,6 +157,9 @@ var TreeController = {
|
|||
title = defaultCounterTitles[counterType].modules;
|
||||
}
|
||||
break;
|
||||
case "services":
|
||||
title = serviceCounterTitles[counterType].totals;
|
||||
break;
|
||||
default:
|
||||
if (
|
||||
typeof controller.counterTitles != "undefined" &&
|
||||
|
@ -169,109 +185,227 @@ var TreeController = {
|
|||
}
|
||||
}
|
||||
|
||||
var $counters = $("<div></div>");
|
||||
$counters.addClass("tree-node-counters");
|
||||
|
||||
if (typeof counters.total != "undefined" && counters.total >= 0) {
|
||||
var $totalCounter = $("<div></div>");
|
||||
$totalCounter
|
||||
.addClass("tree-node-counter")
|
||||
.addClass("total")
|
||||
.html(counters.total);
|
||||
|
||||
_processNodeCounterTitle($totalCounter, type, "total");
|
||||
|
||||
// Open the parentheses
|
||||
$counters.append(" (");
|
||||
|
||||
$counters.append($totalCounter);
|
||||
if (type == "services") {
|
||||
var $counters = $("<div></div>");
|
||||
$counters.addClass("tree-node-counters");
|
||||
|
||||
if (
|
||||
typeof counters.alerts != "undefined" &&
|
||||
counters.alerts > 0
|
||||
counters.total_services +
|
||||
counters.total_agents +
|
||||
counters.total_modules >
|
||||
0
|
||||
) {
|
||||
var $firedCounter = $("<div></div>");
|
||||
$firedCounter
|
||||
.addClass("tree-node-counter")
|
||||
.addClass("alerts")
|
||||
.addClass("orange")
|
||||
.html(counters.alerts);
|
||||
// Open the parentheses
|
||||
$counters.append(" (");
|
||||
|
||||
_processNodeCounterTitle($firedCounter, type, "alerts");
|
||||
if (
|
||||
typeof counters.total_services != "undefined" &&
|
||||
counters.total_services >= 0
|
||||
) {
|
||||
var $servicesCounter = $("<div></div>");
|
||||
$servicesCounter
|
||||
.addClass("tree-node-counter")
|
||||
.addClass("total")
|
||||
.html(counters.total_services);
|
||||
|
||||
$counters.append(" : ").append($firedCounter);
|
||||
_processNodeCounterTitle(
|
||||
$servicesCounter,
|
||||
type,
|
||||
"total_services"
|
||||
);
|
||||
|
||||
$counters.append($servicesCounter);
|
||||
} else {
|
||||
var $servicesCounter = $("<div></div>");
|
||||
$servicesCounter
|
||||
.addClass("tree-node-counter")
|
||||
.addClass("total")
|
||||
.html("0");
|
||||
|
||||
_processNodeCounterTitle(
|
||||
$servicesCounter,
|
||||
type,
|
||||
"total_services"
|
||||
);
|
||||
|
||||
$counters.append($servicesCounter);
|
||||
}
|
||||
|
||||
if (
|
||||
typeof counters.total_agents != "undefined" &&
|
||||
counters.total_agents > 0
|
||||
) {
|
||||
var $agentsCounter = $("<div></div>");
|
||||
$agentsCounter
|
||||
.addClass("tree-node-counter")
|
||||
.html(counters.total_agents);
|
||||
|
||||
_processNodeCounterTitle(
|
||||
$agentsCounter,
|
||||
type,
|
||||
"total_agents"
|
||||
);
|
||||
|
||||
$counters.append(" : ").append($agentsCounter);
|
||||
} else {
|
||||
var $agentsCounter = $("<div></div>");
|
||||
$agentsCounter
|
||||
.addClass("tree-node-counter")
|
||||
.addClass("total")
|
||||
.html("0");
|
||||
|
||||
_processNodeCounterTitle(
|
||||
$agentsCounter,
|
||||
type,
|
||||
"total_agents"
|
||||
);
|
||||
|
||||
$counters.append(" : ").append($agentsCounter);
|
||||
}
|
||||
|
||||
if (
|
||||
typeof counters.total_modules != "undefined" &&
|
||||
counters.total_modules > 0
|
||||
) {
|
||||
var $modulesCounter = $("<div></div>");
|
||||
$modulesCounter
|
||||
.addClass("tree-node-counter")
|
||||
.addClass("total")
|
||||
.html(counters.total_modules);
|
||||
|
||||
_processNodeCounterTitle(
|
||||
$modulesCounter,
|
||||
type,
|
||||
"total_modules"
|
||||
);
|
||||
|
||||
$counters.append(" : ").append($modulesCounter);
|
||||
} else {
|
||||
var $modulesCounter = $("<div></div>");
|
||||
$modulesCounter
|
||||
.addClass("tree-node-counter")
|
||||
.addClass("total")
|
||||
.html("0");
|
||||
|
||||
_processNodeCounterTitle(
|
||||
$modulesCounter,
|
||||
type,
|
||||
"total_modules"
|
||||
);
|
||||
|
||||
$counters.append(" : ").append($modulesCounter);
|
||||
}
|
||||
|
||||
// Close the parentheses
|
||||
$counters.append(")");
|
||||
|
||||
hasCounters = true;
|
||||
}
|
||||
if (
|
||||
typeof counters.critical != "undefined" &&
|
||||
counters.critical > 0
|
||||
) {
|
||||
var $criticalCounter = $("<div></div>");
|
||||
$criticalCounter
|
||||
} else {
|
||||
var $counters = $("<div></div>");
|
||||
$counters.addClass("tree-node-counters");
|
||||
|
||||
if (typeof counters.total != "undefined" && counters.total >= 0) {
|
||||
var $totalCounter = $("<div></div>");
|
||||
$totalCounter
|
||||
.addClass("tree-node-counter")
|
||||
.addClass("critical")
|
||||
.addClass("red")
|
||||
.html(counters.critical);
|
||||
.addClass("total")
|
||||
.html(counters.total);
|
||||
|
||||
_processNodeCounterTitle($criticalCounter, type, "critical");
|
||||
_processNodeCounterTitle($totalCounter, type, "total");
|
||||
|
||||
$counters.append(" : ").append($criticalCounter);
|
||||
}
|
||||
if (
|
||||
typeof counters.warning != "undefined" &&
|
||||
counters.warning > 0
|
||||
) {
|
||||
var $warningCounter = $("<div></div>");
|
||||
$warningCounter
|
||||
.addClass("tree-node-counter")
|
||||
.addClass("warning")
|
||||
.addClass("yellow")
|
||||
.html(counters.warning);
|
||||
// Open the parentheses
|
||||
$counters.append(" (");
|
||||
|
||||
_processNodeCounterTitle($warningCounter, type, "warning");
|
||||
$counters.append($totalCounter);
|
||||
|
||||
$counters.append(" : ").append($warningCounter);
|
||||
}
|
||||
if (
|
||||
typeof counters.unknown != "undefined" &&
|
||||
counters.unknown > 0
|
||||
) {
|
||||
var $unknownCounter = $("<div></div>");
|
||||
$unknownCounter
|
||||
.addClass("tree-node-counter")
|
||||
.addClass("unknown")
|
||||
.addClass("grey")
|
||||
.html(counters.unknown);
|
||||
if (
|
||||
typeof counters.alerts != "undefined" &&
|
||||
counters.alerts > 0
|
||||
) {
|
||||
var $firedCounter = $("<div></div>");
|
||||
$firedCounter
|
||||
.addClass("tree-node-counter")
|
||||
.addClass("alerts")
|
||||
.addClass("orange")
|
||||
.html(counters.alerts);
|
||||
|
||||
_processNodeCounterTitle($unknownCounter, type, "unknown");
|
||||
_processNodeCounterTitle($firedCounter, type, "alerts");
|
||||
|
||||
$counters.append(" : ").append($unknownCounter);
|
||||
}
|
||||
if (
|
||||
typeof counters.not_init != "undefined" &&
|
||||
counters.not_init > 0
|
||||
) {
|
||||
var $notInitCounter = $("<div></div>");
|
||||
$notInitCounter
|
||||
.addClass("tree-node-counter")
|
||||
.addClass("not_init")
|
||||
.addClass("blue")
|
||||
.html(counters.not_init);
|
||||
$counters.append(" : ").append($firedCounter);
|
||||
}
|
||||
if (
|
||||
typeof counters.critical != "undefined" &&
|
||||
counters.critical > 0
|
||||
) {
|
||||
var $criticalCounter = $("<div></div>");
|
||||
$criticalCounter
|
||||
.addClass("tree-node-counter")
|
||||
.addClass("critical")
|
||||
.addClass("red")
|
||||
.html(counters.critical);
|
||||
|
||||
_processNodeCounterTitle($notInitCounter, type, "not_init");
|
||||
_processNodeCounterTitle($criticalCounter, type, "critical");
|
||||
|
||||
$counters.append(" : ").append($notInitCounter);
|
||||
}
|
||||
if (typeof counters.ok != "undefined" && counters.ok > 0) {
|
||||
var $okCounter = $("<div></div>");
|
||||
$okCounter
|
||||
.addClass("tree-node-counter")
|
||||
.addClass("ok")
|
||||
.addClass("green")
|
||||
.html(counters.ok);
|
||||
$counters.append(" : ").append($criticalCounter);
|
||||
}
|
||||
if (
|
||||
typeof counters.warning != "undefined" &&
|
||||
counters.warning > 0
|
||||
) {
|
||||
var $warningCounter = $("<div></div>");
|
||||
$warningCounter
|
||||
.addClass("tree-node-counter")
|
||||
.addClass("warning")
|
||||
.addClass("yellow")
|
||||
.html(counters.warning);
|
||||
|
||||
_processNodeCounterTitle($okCounter, type, "ok");
|
||||
_processNodeCounterTitle($warningCounter, type, "warning");
|
||||
|
||||
$counters.append(" : ").append($okCounter);
|
||||
$counters.append(" : ").append($warningCounter);
|
||||
}
|
||||
if (
|
||||
typeof counters.unknown != "undefined" &&
|
||||
counters.unknown > 0
|
||||
) {
|
||||
var $unknownCounter = $("<div></div>");
|
||||
$unknownCounter
|
||||
.addClass("tree-node-counter")
|
||||
.addClass("unknown")
|
||||
.addClass("grey")
|
||||
.html(counters.unknown);
|
||||
|
||||
_processNodeCounterTitle($unknownCounter, type, "unknown");
|
||||
|
||||
$counters.append(" : ").append($unknownCounter);
|
||||
}
|
||||
if (
|
||||
typeof counters.not_init != "undefined" &&
|
||||
counters.not_init > 0
|
||||
) {
|
||||
var $notInitCounter = $("<div></div>");
|
||||
$notInitCounter
|
||||
.addClass("tree-node-counter")
|
||||
.addClass("not_init")
|
||||
.addClass("blue")
|
||||
.html(counters.not_init);
|
||||
|
||||
_processNodeCounterTitle($notInitCounter, type, "not_init");
|
||||
|
||||
$counters.append(" : ").append($notInitCounter);
|
||||
}
|
||||
if (typeof counters.ok != "undefined" && counters.ok > 0) {
|
||||
var $okCounter = $("<div></div>");
|
||||
$okCounter
|
||||
.addClass("tree-node-counter")
|
||||
.addClass("ok")
|
||||
.addClass("green")
|
||||
.html(counters.ok);
|
||||
|
||||
_processNodeCounterTitle($okCounter, type, "ok");
|
||||
|
||||
$counters.append(" : ").append($okCounter);
|
||||
}
|
||||
}
|
||||
|
||||
// Close the parentheses
|
||||
|
@ -436,7 +570,120 @@ var TreeController = {
|
|||
|
||||
$content.append($alertImage);
|
||||
}
|
||||
$content.append(element.alias);
|
||||
|
||||
// Events by agent
|
||||
if (element.showEventsBtn == 1) {
|
||||
if (typeof element.eventAgent != "undefined") {
|
||||
$content.append(
|
||||
'<form method="post" id="hiddenAgentsEventsForm-' +
|
||||
element.eventAgent +
|
||||
'" style="display: none;" action="index.php?sec=eventos&sec2=operation/events/events&refr=0&pure=§ion=list&history=0"><input type="hidden" name="id_agent" value="' +
|
||||
element.eventAgent +
|
||||
'"></form>'
|
||||
);
|
||||
var $eventImage = $(
|
||||
'<img src="' +
|
||||
(controller.baseURL.length > 0
|
||||
? controller.baseURL
|
||||
: "") +
|
||||
'images/tree_events.png" /> '
|
||||
);
|
||||
$eventImage.addClass("agent-alerts-fired");
|
||||
$eventImage
|
||||
.click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
document
|
||||
.getElementById(
|
||||
"hiddenAgentsEventsForm-" + element.eventAgent
|
||||
)
|
||||
.submit();
|
||||
})
|
||||
.css("cursor", "pointer");
|
||||
|
||||
$content.append($eventImage);
|
||||
}
|
||||
}
|
||||
|
||||
$content.append(" " + element.alias);
|
||||
break;
|
||||
case "services":
|
||||
if (
|
||||
typeof element.statusImageHTML != "undefined" &&
|
||||
element.statusImageHTML.length > 0
|
||||
) {
|
||||
var $statusImage = $(element.statusImageHTML);
|
||||
$statusImage.addClass("agent-status");
|
||||
|
||||
$content.append($statusImage);
|
||||
}
|
||||
|
||||
var $serviceDetailImage = $(
|
||||
'<img src="' +
|
||||
(controller.baseURL.length > 0 ? controller.baseURL : "") +
|
||||
'images/tree_service_map.png" /> '
|
||||
);
|
||||
|
||||
if (typeof element.serviceDetail != "undefined") {
|
||||
$serviceDetailImage
|
||||
.click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
window.location.href = element.serviceDetail;
|
||||
})
|
||||
.css("cursor", "pointer");
|
||||
|
||||
$content.append($serviceDetailImage);
|
||||
}
|
||||
|
||||
$content.append(" " + element.name);
|
||||
|
||||
break;
|
||||
case "modules":
|
||||
if (
|
||||
typeof element.statusImageHTML != "undefined" &&
|
||||
element.statusImageHTML.length > 0
|
||||
) {
|
||||
var $statusImage = $(element.statusImageHTML);
|
||||
$statusImage.addClass("agent-status");
|
||||
|
||||
$content.append($statusImage);
|
||||
}
|
||||
|
||||
// Events by module
|
||||
if (element.showEventsBtn == 1) {
|
||||
if (typeof element.eventModule != "undefined") {
|
||||
$content.append(
|
||||
'<form method="post" id="hiddenModulesEventsForm-' +
|
||||
element.eventModule +
|
||||
'" style="display: none;" action="index.php?sec=eventos&sec2=operation/events/events&refr=0&pure=§ion=list&history=0"><input type="hidden" name="module_search_hidden" value="' +
|
||||
element.eventModule +
|
||||
'"></form>'
|
||||
);
|
||||
var $moduleImage = $(
|
||||
'<img src="' +
|
||||
(controller.baseURL.length > 0
|
||||
? controller.baseURL
|
||||
: "") +
|
||||
'images/tree_events.png" /> '
|
||||
);
|
||||
$moduleImage
|
||||
.click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
document
|
||||
.getElementById(
|
||||
"hiddenModulesEventsForm-" + element.eventModule
|
||||
)
|
||||
.submit();
|
||||
})
|
||||
.css("cursor", "pointer");
|
||||
|
||||
$content.append($moduleImage);
|
||||
}
|
||||
}
|
||||
|
||||
$content.append(" " + element.name);
|
||||
break;
|
||||
case "module":
|
||||
// Status image
|
||||
|
@ -617,6 +864,19 @@ var TreeController = {
|
|||
}
|
||||
$content.append(element.name);
|
||||
break;
|
||||
case "services":
|
||||
// Status image
|
||||
if (
|
||||
typeof element.statusImageHTML != "undefined" &&
|
||||
element.statusImageHTML.length > 0
|
||||
) {
|
||||
var $statusImage = $(element.statusImageHTML);
|
||||
$statusImage.addClass("agent-status");
|
||||
|
||||
$content.append($statusImage);
|
||||
}
|
||||
$content.append(element.name);
|
||||
break;
|
||||
default:
|
||||
$content.append(element.name);
|
||||
break;
|
||||
|
@ -820,14 +1080,16 @@ var TreeController = {
|
|||
}
|
||||
|
||||
controller.recipient.empty();
|
||||
controller.recipient.html(
|
||||
"<div> " +
|
||||
controller.foundMessage +
|
||||
": " +
|
||||
controller.tree.length +
|
||||
"</div>" +
|
||||
"<br/>"
|
||||
);
|
||||
if (controller.tree.length !== undefined) {
|
||||
controller.recipient.html(
|
||||
"<div> " +
|
||||
controller.foundMessage +
|
||||
": " +
|
||||
controller.tree.length +
|
||||
"</div>" +
|
||||
"<br/>"
|
||||
);
|
||||
}
|
||||
|
||||
var $children = _processGroup(this.recipient, this.tree, true);
|
||||
$children.show();
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -1,24 +1,30 @@
|
|||
/*
|
||||
Author: The Pandora FMS team
|
||||
Name: Default theme
|
||||
Description: The default Pandora FMS theme layout
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==========================================================
|
||||
// Copyright (c) 2004-2019 Artica Soluciones Tecnológicas S.L
|
||||
|
||||
// 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.
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
/**
|
||||
* 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.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
/* Tree view styles */
|
||||
/*@import url(tree.css);
|
||||
|
@ -911,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;
|
||||
|
@ -1490,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;
|
||||
|
@ -2053,82 +2064,58 @@ div#logo_text3 {
|
|||
|
||||
/* TABLAS */
|
||||
/* Cells divs to set individual styles with the table objects */
|
||||
div.cellBold {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
td.cellBold {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
div.cellRight {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
td.cellRight {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
div.cellCenter {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
td.cellCenter {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
div.cellWhite {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
td.cellWhite {
|
||||
background: #fff;
|
||||
color: #111;
|
||||
}
|
||||
|
||||
div.cellNormal {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
td.cellNormal {
|
||||
background: #6eb432;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
div.cellCritical {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
td.cellCritical {
|
||||
background: #f85858;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
div.cellWarning {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
td.cellWarning {
|
||||
background: #ffea59;
|
||||
color: #111;
|
||||
}
|
||||
|
||||
div.cellUnknown {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
td.cellUnknown {
|
||||
background: #aaaaaa;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
div.cellNotInit {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
td.cellNotInit {
|
||||
background: #3ba0ff;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
div.cellAlert {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
td.cellAlert {
|
||||
background: #ff8800;
|
||||
color: #111;
|
||||
}
|
||||
|
||||
div.cellBorder1 {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
td.cellBorder1 {
|
||||
border: 1px solid #666;
|
||||
}
|
||||
|
||||
div.cellBig {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
td.cellBig {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
|
@ -4268,293 +4255,168 @@ 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;
|
||||
}
|
||||
.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 {
|
||||
background-color: #82b92e;
|
||||
}
|
||||
.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;
|
||||
}
|
||||
/*
|
||||
* ---------------------------------------------------------------------
|
||||
* - Notifications
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
.ui-dialog-title {
|
||||
color: #ffffff;
|
||||
font-size: 9pt;
|
||||
}
|
||||
.ui-widget input,
|
||||
.ui-widget select,
|
||||
.ui-widget textarea,
|
||||
.ui-widget button {
|
||||
font-family: Verdana, Arial, sans-serif !important;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
ul.ui-front {
|
||||
z-index: 1000000 !important;
|
||||
padding-right: 0px !important;
|
||||
}
|
||||
|
||||
ul.ui-front li {
|
||||
padding: 3px !important;
|
||||
}
|
||||
|
||||
ul.ui-front li:hover {
|
||||
background-color: #e1e3e1 !important;
|
||||
}
|
||||
|
||||
ul.ui-front li a.ui-menu-item-wrapper {
|
||||
background: transparent !important;
|
||||
border: none !important;
|
||||
}
|
||||
|
||||
ul.ui-front li a.ui-menu-item-wrapper span {
|
||||
padding-left: 5px !important;
|
||||
}
|
||||
|
||||
ul.ui-front li a.ui-menu-item-wrapper:hover {
|
||||
text-decoration: none !important;
|
||||
}
|
||||
/* --- END - JQUERY-UI --- */
|
||||
|
||||
.toogle_switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 47px;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
.toogle_switch input {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.slider {
|
||||
position: absolute;
|
||||
.notification-ball {
|
||||
border: white solid 2px;
|
||||
border-radius: 50px;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #ccc;
|
||||
-webkit-transition: 0.7s;
|
||||
transition: 0.7s;
|
||||
border-radius: 34px;
|
||||
}
|
||||
|
||||
.slider:before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: 16px;
|
||||
width: 16px;
|
||||
left: 4px;
|
||||
bottom: 4px;
|
||||
background-color: white;
|
||||
-webkit-transition: 0.7s;
|
||||
transition: 0.7s;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
input:checked + .slider {
|
||||
.notification-ball-no-messages {
|
||||
background-color: #82b92e;
|
||||
cursor: pointer;
|
||||
}
|
||||
.notification-ball-new-messages {
|
||||
background-color: #fc4444;
|
||||
}
|
||||
|
||||
input:focus + .slider {
|
||||
box-shadow: 0 0 1px #82b92e;
|
||||
#notification-wrapper {
|
||||
background: white;
|
||||
border: #a5a5a5 solid 1px;
|
||||
z-index: 900000;
|
||||
position: absolute;
|
||||
width: 400px;
|
||||
margin-top: -5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
#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;
|
||||
}
|
||||
|
||||
input:checked + .slider:before {
|
||||
-webkit-transform: translateX(26px);
|
||||
-ms-transform: translateX(26px);
|
||||
transform: translateX(26px);
|
||||
background-color: rgb(197, 235, 192);
|
||||
.notification-item:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
.global-config-notification-title {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.global-config-notification-title h2 {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.global-config-notification-checkboxes :first-child {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.global-config-notification-selectors {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.global-config-notification-selectors h4 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.global-config-notification-single-selector,
|
||||
.global_config_notifications_dialog_add select {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
.global-config-notification-single-selector :first-child,
|
||||
.global-config-notification-single-selector :first-child select {
|
||||
width: 99%;
|
||||
}
|
||||
|
||||
.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 */
|
||||
|
@ -4562,3 +4424,146 @@ input:checked + .slider:before {
|
|||
display: none;
|
||||
}
|
||||
/* jQuery dialog */
|
||||
|
||||
/* --- SWITCH --- */
|
||||
.p-switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 30px;
|
||||
height: 17px;
|
||||
}
|
||||
|
||||
.p-switch input {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.p-slider {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #ccc;
|
||||
-webkit-transition: 0.4s;
|
||||
transition: 0.4s;
|
||||
border-radius: 34px;
|
||||
}
|
||||
|
||||
.p-slider:before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: 13px;
|
||||
width: 13px;
|
||||
left: 2px;
|
||||
bottom: 2px;
|
||||
background-color: white;
|
||||
-webkit-transition: 0.4s;
|
||||
transition: 0.4s;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
input:checked + .p-slider {
|
||||
background-color: #82b92e;
|
||||
}
|
||||
|
||||
input:focus + .p-slider {
|
||||
box-shadow: 0 0 1px #82b92e;
|
||||
}
|
||||
|
||||
input:checked + .p-slider:before {
|
||||
-webkit-transform: translateX(13px);
|
||||
-ms-transform: translateX(13px);
|
||||
transform: translateX(13px);
|
||||
}
|
||||
|
||||
/* --- END SWITCH --- */
|
||||
|
||||
/* --- TOAST --- */
|
||||
#notifications-toasts-wrapper {
|
||||
position: fixed;
|
||||
right: 20px;
|
||||
top: 70px;
|
||||
width: 270px;
|
||||
height: 100%;
|
||||
z-index: 6;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.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 --- */
|
||||
|
|