Merge remote-tracking branch 'origin/develop' into ent-2561-llamadas-api-para-modulos-de-politicas

Conflicts:
	pandora_console/include/functions_api.php
	visual_console_client/src/Item.ts
This commit is contained in:
fbsanchez 2021-03-11 14:37:06 +01:00
commit 6df9870f92
139 changed files with 3573 additions and 1836 deletions

View File

@ -71,7 +71,7 @@ check_pre_pandora () {
check_repo_connection () { check_repo_connection () {
execute_cmd "ping -c 2 8.8.8.8" "Checking internet connection" execute_cmd "ping -c 2 8.8.8.8" "Checking internet connection"
execute_cmd "ping -c 2 firefly.artica.es" "Checking Community repo" execute_cmd "ping -c 2 firefly.artica.es" "Checking Community repo"
execute_cmd "ping -c 2 support.artica.es" "Checking Enterprise repo" execute_cmd "ping -c 2 support.pandorafms.com" "Checking Enterprise repo"
} }
check_root_permissions () { check_root_permissions () {

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.752-210224 Version: 7.0NG.752-210311
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

@ -1016,7 +1016,7 @@ my $Sem = undef;
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.752'; use constant AGENT_VERSION => '7.0NG.752';
use constant AGENT_BUILD => '210224'; use constant AGENT_BUILD => '210311';
# Agent log default file size maximum and instances # Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000; use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.752 %define version 7.0NG.752
%define release 210224 %define release 210311
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.752 %define version 7.0NG.752
%define release 210224 %define release 210311
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -10,7 +10,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.752" PI_VERSION="7.0NG.752"
PI_BUILD="210224" PI_BUILD="210311"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{210224} {210311}
ViewReadme ViewReadme
{Yes} {Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils; using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1 #define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.752(Build 210224)") #define PANDORA_VERSION ("7.0NG.752(Build 210311)")
string pandora_path; string pandora_path;
string pandora_dir; string pandora_dir;

View File

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

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 7.0NG.752-210224 Version: 7.0NG.752-210311
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

@ -98,13 +98,45 @@ function users_extension_main_god($god=true)
$table->head = []; $table->head = [];
$table->head[0] = __('User'); $table->head[0] = __('User');
$table->head[1] = __('Date'); $table->head[1] = __('IP');
$table->head[2] = __('Last login');
$table->head[3] = __('Last contact');
$rowPair = true; $rowPair = true;
$iterator = 0; $iterator = 0;
// Get data // Get data
foreach ($rows as $row) { foreach ($rows as $row) {
// Get data of user's last login.
switch ($config['dbtype']) {
case 'mysql':
case 'postgresql':
$last_login_data = db_get_row_sql(
sprintf(
"SELECT ip_origen, utimestamp
FROM tsesion
WHERE id_usuario = '%s'
AND descripcion = '".io_safe_input('Logged in')."'
ORDER BY fecha DESC",
$row['id_user']
)
);
break;
case 'oracle':
$last_login_data = db_get_row_sql(
sprintf(
"SELECT ip_origen, utimestamp
FROM tsesion
WHERE id_usuario = '%s'
AND to_char(descripcion) = '".io_safe_input('Logged in')."'
ORDER BY fecha DESC",
$row['id_user']
)
);
break;
}
if ($rowPair) { if ($rowPair) {
$table->rowclass[$iterator] = 'rowPair'; $table->rowclass[$iterator] = 'rowPair';
} else { } else {
@ -116,7 +148,9 @@ function users_extension_main_god($god=true)
$data = []; $data = [];
$data[0] = '<a href="index.php?sec=gusuarios&amp;sec2=godmode/users/configure_user&amp;id='.$row['id_user'].'">'.$row['id_user'].'</a>'; $data[0] = '<a href="index.php?sec=gusuarios&amp;sec2=godmode/users/configure_user&amp;id='.$row['id_user'].'">'.$row['id_user'].'</a>';
$data[1] = date($config['date_format'], $row['last_connect']); $data[1] = $last_login_data['ip_origin'];
$data[2] = date($config['date_format'], $last_login_data['utimestamp']);
$data[3] = date($config['date_format'], $row['last_connect']);
array_push($table->data, $data); array_push($table->data, $data);
} }
@ -125,7 +159,6 @@ function users_extension_main_god($god=true)
} }
extensions_add_godmode_menu_option(__('Users connected'), 'UM', 'gusuarios', 'users/icon.png', 'v1r1');
extensions_add_operation_menu_option(__('Users connected'), 'workspace', 'users/icon.png', 'v1r1', '', 'UM'); extensions_add_operation_menu_option(__('Users connected'), 'workspace', 'users/icon.png', 'v1r1', '', 'UM');
extensions_add_godmode_function('users_extension_main_god'); extensions_add_godmode_function('users_extension_main_god');

View File

@ -1,6 +1,7 @@
operation/servers/recon_view.php operation/servers/recon_view.php
operation/users/webchat.php operation/users/webchat.php
operation/events/event_statistics.php operation/events/event_statistics.php
operation/events/events_marquee.php
include/javascript/webchat.js include/javascript/webchat.js
attachment/pandora_chat.log.json.txt attachment/pandora_chat.log.json.txt
attachment/pandora_chat.user_list.json.txt attachment/pandora_chat.user_list.json.txt
@ -71,4 +72,4 @@ enterprise/extensions/ipam/ipam_action.php
enterprise/extensions/ipam.php enterprise/extensions/ipam.php
enterprise/extensions/ipam enterprise/extensions/ipam
enterprise/extensions/disabled/visual_console_manager.php enterprise/extensions/disabled/visual_console_manager.php
enterprise/extensions/visual_console_manager.php enterprise/extensions/visual_console_manager.php

View File

@ -0,0 +1,11 @@
START TRANSACTION;
ALTER TABLE `treport_content` ADD COLUMN `summary` tinyint(1) DEFAULT 0;
ALTER TABLE `treport_content_template` ADD COLUMN `summary` tinyint(1) DEFAULT 0;
ALTER TABLE `tinventory_alert` ADD COLUMN `alert_groups` TEXT NOT NULL;
UPDATE `tinventory_alert` t1 INNER JOIN `tinventory_alert` t2 ON t1.id = t2.id SET t1.alert_groups = t2.id_group;
ALTER TABLE `tnotification_source` ADD COLUMN `subtype_blacklist` TEXT;
COMMIT;

View File

@ -363,6 +363,7 @@ CREATE TABLE IF NOT EXISTS `tinventory_alert`(
`last_fired` text NOT NULL default '', `last_fired` text NOT NULL default '',
`disable_event` tinyint(1) UNSIGNED default 0, `disable_event` tinyint(1) UNSIGNED default 0,
`enabled` tinyint(1) UNSIGNED default 1, `enabled` tinyint(1) UNSIGNED default 1,
`alert_groups` text NOT NULL default '',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
FOREIGN KEY (`id_module_inventory`) REFERENCES tmodule_inventory(`id_module_inventory`) FOREIGN KEY (`id_module_inventory`) REFERENCES tmodule_inventory(`id_module_inventory`)
ON DELETE CASCADE ON UPDATE CASCADE ON DELETE CASCADE ON UPDATE CASCADE
@ -864,6 +865,7 @@ ALTER TABLE `treport_content_template` ADD COLUMN `agent_min_value` TINYINT(1) D
ALTER TABLE `treport_content_template` ADD COLUMN `current_month` TINYINT(1) DEFAULT '1'; ALTER TABLE `treport_content_template` ADD COLUMN `current_month` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content_template` ADD COLUMN `failover_mode` tinyint(1) DEFAULT '1'; ALTER TABLE `treport_content_template` ADD COLUMN `failover_mode` tinyint(1) DEFAULT '1';
ALTER TABLE `treport_content_template` ADD COLUMN `failover_type` tinyint(1) DEFAULT '1'; ALTER TABLE `treport_content_template` ADD COLUMN `failover_type` tinyint(1) DEFAULT '1';
ALTER TABLE `treport_content_template` ADD COLUMN `summary` tinyint(1) DEFAULT 0;
ALTER TABLE `treport_content_template` ADD COLUMN `uncompressed_module` TINYINT DEFAULT '0'; ALTER TABLE `treport_content_template` ADD COLUMN `uncompressed_module` TINYINT DEFAULT '0';
ALTER TABLE `treport_content_template` MODIFY COLUMN `historical_db` tinyint(1) unsigned NOT NULL DEFAULT '0', ALTER TABLE `treport_content_template` MODIFY COLUMN `historical_db` tinyint(1) unsigned NOT NULL DEFAULT '0',
MODIFY COLUMN `lapse_calc` tinyint(1) unsigned NOT NULL DEFAULT '0', MODIFY COLUMN `lapse_calc` tinyint(1) unsigned NOT NULL DEFAULT '0',
@ -1724,6 +1726,7 @@ ALTER TABLE `treport_content` ADD COLUMN `agent_min_value` TINYINT(1) DEFAULT '1
ALTER TABLE `treport_content` ADD COLUMN `current_month` TINYINT(1) DEFAULT '1'; ALTER TABLE `treport_content` ADD COLUMN `current_month` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content` ADD COLUMN `failover_mode` tinyint(1) DEFAULT '0'; ALTER TABLE `treport_content` ADD COLUMN `failover_mode` tinyint(1) DEFAULT '0';
ALTER TABLE `treport_content` ADD COLUMN `failover_type` tinyint(1) DEFAULT '0'; ALTER TABLE `treport_content` ADD COLUMN `failover_type` tinyint(1) DEFAULT '0';
ALTER TABLE `treport_content` ADD COLUMN `summary` tinyint(1) DEFAULT 0;
ALTER table `treport_content` MODIFY COLUMN `name` varchar(300) NULL; ALTER table `treport_content` MODIFY COLUMN `name` varchar(300) NULL;
ALTER TABLE `treport_content` ADD COLUMN `uncompressed_module` TINYINT DEFAULT '0'; ALTER TABLE `treport_content` ADD COLUMN `uncompressed_module` TINYINT DEFAULT '0';
ALTER TABLE `treport_content` MODIFY COLUMN `historical_db` tinyint(1) unsigned NOT NULL DEFAULT '0', ALTER TABLE `treport_content` MODIFY COLUMN `historical_db` tinyint(1) unsigned NOT NULL DEFAULT '0',
@ -2392,6 +2395,7 @@ CREATE TABLE `tnotification_source` (
`enabled` int(1) DEFAULT NULL, `enabled` int(1) DEFAULT NULL,
`user_editable` int(1) DEFAULT NULL, `user_editable` int(1) DEFAULT NULL,
`also_mail` int(1) DEFAULT NULL, `also_mail` int(1) DEFAULT NULL,
`subtype_blacklist` TEXT,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -146,8 +146,8 @@ if (isset($config['custom_support_url'])) {
echo '<li>'.__('Support').'</li>'; echo '<li>'.__('Support').'</li>';
} }
} else if (!$custom_conf_enabled) { } else if (!$custom_conf_enabled) {
echo '<li id="li_margin_left"><a href="https://support.artica.es" target="_blank"><img src="'.$support_logo.'" alt="support"></a></li>'; echo '<li id="li_margin_left"><a href="https://support.pandorafms.com" target="_blank"><img src="'.$support_logo.'" alt="support"></a></li>';
echo '<li><a href="https://support.artica.es" target="_blank">'.__('Docs').'</li>'; echo '<li><a href="https://support.pandorafms.com" target="_blank">'.__('Docs').'</li>';
} }
echo '</ul></div>'; echo '</ul></div>';

View File

@ -1404,6 +1404,10 @@ if ($update_module || $create_module) {
$each_ff = (int) get_parameter('each_ff', $module['each_ff']); $each_ff = (int) get_parameter('each_ff', $module['each_ff']);
$ff_timeout = (int) get_parameter('ff_timeout'); $ff_timeout = (int) get_parameter('ff_timeout');
$unit = (string) get_parameter('unit'); $unit = (string) get_parameter('unit');
if ($unit === '0') {
$unit = '';
}
$id_tag = (array) get_parameter('id_tag_selected'); $id_tag = (array) get_parameter('id_tag_selected');
$serialize_ops = (string) get_parameter('serialize_ops'); $serialize_ops = (string) get_parameter('serialize_ops');
$critical_instructions = (string) get_parameter('critical_instructions'); $critical_instructions = (string) get_parameter('critical_instructions');
@ -1570,24 +1574,43 @@ if ($update_module) {
'module_macros' => $module_macros, 'module_macros' => $module_macros,
]; ];
if ($id_module_type == 30 || $id_module_type == 31 || $id_module_type == 32 || $id_module_type == 33) { if (preg_match('/http_auth_user/m', $values['plugin_parameter'])) {
$plugin_parameter_split = explode('&#x0a;', $values['plugin_parameter']); $http_user_conf = true;
}
$values['plugin_parameter'] = ''; if (preg_match('/http_auth_pass/m', $values['plugin_parameter'])) {
$http_pass_conf = true;
}
foreach ($plugin_parameter_split as $key => $value) {
if ($key == 1) { if (!$http_user_conf || !$http_pass_conf) {
if ($http_user) { if ($id_module_type == 30 || $id_module_type == 31 || $id_module_type == 32 || $id_module_type == 33) {
$values['plugin_parameter'] .= 'http_auth_user&#x20;'.$http_user.'&#x0a;'; $plugin_parameter_split = explode('&#x0a;', $values['plugin_parameter']);
$values['plugin_parameter'] = '';
foreach ($plugin_parameter_split as $key => $value) {
if ($key == 1) {
if ($http_user) {
if ($http_user_conf) {
continue;
}
$values['plugin_parameter'] .= 'http_auth_user&#x20;'.$http_user.'&#x0a;';
}
if ($http_pass) {
if ($http_user_pass) {
continue;
}
$values['plugin_parameter'] .= 'http_auth_pass&#x20;'.$http_pass.'&#x0a;';
}
$values['plugin_parameter'] .= $value.'&#x0a;';
} else {
$values['plugin_parameter'] .= $value.'&#x0a;';
} }
if ($http_pass) {
$values['plugin_parameter'] .= 'http_auth_pass&#x20;'.$http_pass.'&#x0a;';
}
$values['plugin_parameter'] .= $value.'&#x0a;';
} else {
$values['plugin_parameter'] .= $value.'&#x0a;';
} }
} }
} }

View File

@ -567,12 +567,12 @@ if ($agents !== false) {
$url = ui_get_full_url( $url = ui_get_full_url(
$url.'&op=update&id='.$cluster->id() $url.'&op=update&id='.$cluster->id()
); );
echo '<a href="'.$url.'">'.$agent['alias'].'</a>'; echo '<a href="'.$url.'">'.ui_print_truncate_text($agent['alias'], 'agent_medium').'</a>';
} }
} else { } else {
echo '<a alt ='.$agent['nombre']." href='index.php?sec=gagente& echo '<a alt ='.$agent['nombre']." href='index.php?sec=gagente&
sec2=godmode/agentes/configurar_agente&tab=$main_tab& sec2=godmode/agentes/configurar_agente&tab=$main_tab&
id_agente=".$agent['id_agente']."'>".'<span class="'.$custom_font_size.' title ="'.$agent['nombre'].'">'.$agent['alias'].'</span>'.'</a>'; id_agente=".$agent['id_agente']."'>".'<span class="'.$custom_font_size.' title ="'.$agent['nombre'].'">'.ui_print_truncate_text($agent['alias'], 'agent_medium').'</span>'.'</a>';
} }
echo '</strong>'; echo '</strong>';

View File

@ -222,9 +222,9 @@ if (! isset($id_agente)) {
} }
$multiple_delete = (bool) get_parameter('multiple_delete'); $module_action = (string) get_parameter('module_action');
if ($multiple_delete) { if ($module_action === 'delete') {
$id_agent_modules_delete = (array) get_parameter('id_delete'); $id_agent_modules_delete = (array) get_parameter('id_delete');
$count_correct_delete_modules = 0; $count_correct_delete_modules = 0;
@ -400,23 +400,63 @@ if ($multiple_delete) {
if ($count_correct_delete_modules == 0) { if ($count_correct_delete_modules == 0) {
ui_print_error_message( ui_print_error_message(
sprintf( sprintf(
__('There was a problem deleting %s modules, none deleted.'), __('There was a problem completing the operation. Applied to 0/%d modules.'),
$count_modules_to_delete $count_modules_to_delete
) )
); );
} else { } else {
if ($count_correct_delete_modules == $count_modules_to_delete) { if ($count_correct_delete_modules == $count_modules_to_delete) {
ui_print_success_message(__('All Modules deleted succesfully')); ui_print_success_message(__('Operation finished successfully.'));
} else { } else {
ui_print_error_message( ui_print_error_message(
sprintf( sprintf(
__('There was a problem only deleted %s modules of %s total.'), __('There was a problem completing the operation. Applied to %d/%d modules.'),
count_correct_delete_modules, $count_correct_delete_modules,
$count_modules_to_delete $count_modules_to_delete
) )
); );
} }
} }
} else if ($module_action === 'disable') {
$id_agent_modules_disable = (array) get_parameter('id_delete');
$count_correct_delete_modules = 0;
$updated_count = 0;
foreach ($id_agent_modules_disable as $id_agent_module_disable) {
$sql = sprintf(
'UPDATE tagente_modulo
SET disabled = 1
WHERE id_agente_modulo = %d',
$id_agent_module_disable
);
if (db_process_sql($sql)) {
$updated_count++;
}
}
$count_modules_to_disable = count($id_agent_modules_disable);
if ($updated_count === 0) {
ui_print_error_message(
sprintf(
__('There was a problem completing the operation. Applied to 0/%d modules.'),
$count_modules_to_disable
)
);
} else {
if ($updated_count == $count_modules_to_disable) {
ui_print_success_message(__('Operation finished successfully.'));
} else {
ui_print_error_message(
sprintf(
__('There was a problem completing the operation. Applied to %d/%d modules.'),
$updated_count,
$count_modules_to_disable
)
);
}
}
} }
@ -845,6 +885,9 @@ foreach ($modules as $module) {
'id_delete[]', 'id_delete[]',
$module['id_agente_modulo'], $module['id_agente_modulo'],
false, false,
true,
false,
'',
true true
); );
} }
@ -1123,12 +1166,29 @@ html_print_table($table);
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) { if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) {
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_input_hidden('multiple_delete', 1);
html_print_submit_button( html_print_input_hidden('submit_modules_action', 1);
__('Delete'),
'multiple_delete', html_print_select(
[
'disable' => 'Disable selected modules',
'delete' => 'Delete selected modules',
],
'module_action',
'',
'',
'',
0,
false, false,
'class="sub delete"' false,
false
);
html_print_submit_button(
__('Execute action'),
'submit_modules_action',
false,
'class="sub next"'
); );
echo '</div>'; echo '</div>';
echo '</form>'; echo '</form>';

View File

@ -548,17 +548,17 @@ $table_advanced->data[0][4] = html_print_input_text(
$classdisabledBecauseInPolicy $classdisabledBecauseInPolicy
); );
// $table_advanced->colspan[1][4] = 3; // $table_advanced->colspan[1][4] = 3;
// $table_advanced->data[0][4] = html_print_extended_select_for_unit( $table_advanced->data[0][4] = html_print_extended_select_for_unit(
// 'unit', 'unit',
// $unit, $unit,
// '', '',
// '', 'none',
// '0', '0',
// false, false,
// true, true,
// false, false,
// false false
// ); );
$table_advanced->colspan[0][4] = 3; $table_advanced->colspan[0][4] = 3;
$module_id_policy_module = 0; $module_id_policy_module = 0;

View File

@ -70,7 +70,6 @@ ui_print_page_header(
// Recursion group filter. // Recursion group filter.
$recursion = get_parameter('recursion', $_POST['recursion']); $recursion = get_parameter('recursion', $_POST['recursion']);
// Initialize data. // Initialize data.
$id_group = (int) get_parameter('id_group'); $id_group = (int) get_parameter('id_group');
$name = (string) get_parameter('name'); $name = (string) get_parameter('name');
@ -180,7 +179,12 @@ if ($insert_downtime_agent === 1) {
$agents = (array) get_parameter('id_agents'); $agents = (array) get_parameter('id_agents');
$module_names = (array) get_parameter('module'); $module_names = (array) get_parameter('module');
$all_modules = (empty($module_names) || ($module_names[0] === '0')); $all_modules = ($modules_selection_mode === 'all' && (empty($module_names) || (int) $modules[0] === 0));
$all_common_modules = ($modules_selection_mode === 'common' && (empty($module_names) || (int) $modules[0] === 0));
if ($all_common_modules === true) {
$module_names = explode(',', get_parameter('all_common_modules'));
}
// 'Is running' check. // 'Is running' check.
$is_running = (bool) db_get_value( $is_running = (bool) db_get_value(
@ -194,9 +198,15 @@ if ($insert_downtime_agent === 1) {
__('This elements cannot be modified while the downtime is being executed') __('This elements cannot be modified while the downtime is being executed')
); );
} else { } else {
// If is selected 'Any', get all the agents.
if (count($agents) === 1 && (int) $agents[0] === -2) {
$all_agents = get_parameter('all_agents');
$agents = explode(',', $all_agents);
}
foreach ($agents as $agent_id) { foreach ($agents as $agent_id) {
// Check module belongs to the agent. // Check module belongs to the agent.
if ($modules_selection_mode == 'all') { if ($modules_selection_mode == 'all' && $all_modules === false) {
$check = false; $check = false;
foreach ($module_names as $module_name) { foreach ($module_names as $module_name) {
$check_module = modules_get_agentmodule_id( $check_module = modules_get_agentmodule_id(
@ -918,33 +928,7 @@ if ($id_downtime > 0) {
} }
} }
$sql = sprintf( $agents = get_planned_downtime_agents_list($id_downtime, $filter_cond, $id_groups_str);
'SELECT tagente.id_agente, tagente.alias
FROM tagente
WHERE tagente.id_agente NOT IN (
SELECT tagente.id_agente
FROM tagente, tplanned_downtime_agents
WHERE tplanned_downtime_agents.id_agent = tagente.id_agente
AND tplanned_downtime_agents.id_downtime = %d
) AND disabled = 0 %s
AND tagente.id_grupo IN (%s)
ORDER BY tagente.nombre',
$id_downtime,
$filter_cond,
$id_groups_str
);
$agents = db_get_all_rows_sql($sql);
if (empty($agents)) {
$agents = [];
}
$agent_ids = extract_column($agents, 'id_agente');
$agent_names = extract_column($agents, 'alias');
$agents = array_combine($agent_ids, $agent_names);
if ($agents === false) {
$agents = [];
}
$disabled_add_button = false; $disabled_add_button = false;
if (empty($agents) || $disabled_in_execution) { if (empty($agents) || $disabled_in_execution) {
@ -962,7 +946,7 @@ if ($id_downtime > 0) {
// Show available agents to include into downtime // Show available agents to include into downtime
echo '<h4>'.__('Available agents').':</h4>'; echo '<h4>'.__('Available agents').':</h4>';
echo "<form method=post action='index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&insert_downtime_agent=1&id_downtime=$id_downtime'>"; echo "<form method=post action='index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&insert_downtime_agent=1&id_downtime=$id_downtime'>";
html_print_input_hidden('all_agents', implode(',', array_keys($agents)));
echo html_print_select($agents, 'id_agents[]', -1, '', _('Any'), -2, false, true, true, '', false, 'width: 180px;'); echo html_print_select($agents, 'id_agents[]', -1, '', _('Any'), -2, false, true, true, '', false, 'width: 180px;');
if ($type_downtime != 'quiet') { if ($type_downtime != 'quiet') {
@ -971,6 +955,7 @@ if ($id_downtime > 0) {
echo '<div id="available_modules_selection_mode" style="padding-top:20px">'; echo '<div id="available_modules_selection_mode" style="padding-top:20px">';
} }
html_print_input_hidden('all_common_modules', '');
echo html_print_select( echo html_print_select(
[ [
'common' => __('Show common modules'), 'common' => __('Show common modules'),

View File

@ -28,6 +28,12 @@ if (! check_acl($config['id_user'], 0, 'LM')) {
exit; exit;
} }
if (!check_acl($config['id_user'], 0, 'PM') && !is_user_admin($config['id_user'])) {
echo "<div id='message_permissions' title='".__('Permissions warning')."' style='display:none;'>";
echo "<p style='text-align: center;font-weight: bold;'>".__('Command management is limited to administrator users or user profiles with permissions over Pandora FMS management').'</p>';
echo '</div>';
}
if (is_metaconsole()) { if (is_metaconsole()) {
$sec = 'advanced'; $sec = 'advanced';
} else { } else {
@ -558,7 +564,7 @@ foreach ($commands as $command) {
$data['name'] = '<span style="font-size: 7.5pt">'; $data['name'] = '<span style="font-size: 7.5pt">';
// (IMPORTANT, DO NOT CHANGE!) only users with permissions over "All" group have access to edition of commands belonging to "All" group. // (IMPORTANT, DO NOT CHANGE!) only users with permissions over "All" group have access to edition of commands belonging to "All" group.
if (!$command['internal'] && check_acl_restricted_all($config['id_user'], $command['id_group'], 'LM')) { if (!$command['internal'] && check_acl_restricted_all($config['id_user'], $command['id_group'], 'PM')) {
$data['name'] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_command&id='.$command['id'].'&pure='.$pure.'">'.$command['name'].'</a>'; $data['name'] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_command&id='.$command['id'].'&pure='.$pure.'">'.$command['name'].'</a>';
} else { } else {
$data['name'] .= $command['name']; $data['name'] .= $command['name'];
@ -584,7 +590,7 @@ foreach ($commands as $command) {
$table->cellclass[]['action'] = 'action_buttons'; $table->cellclass[]['action'] = 'action_buttons';
// (IMPORTANT, DO NOT CHANGE!) only users with permissions over "All" group have access to edition of commands belonging to "All" group. // (IMPORTANT, DO NOT CHANGE!) only users with permissions over "All" group have access to edition of commands belonging to "All" group.
if ($is_central_policies_on_node === false && !$command['internal'] && check_acl_restricted_all($config['id_user'], $command['id_group'], 'LM')) { if ($is_central_policies_on_node === false && !$command['internal'] && check_acl_restricted_all($config['id_user'], $command['id_group'], 'PM')) {
$data['action'] = '<span style="display: inline-flex">'; $data['action'] = '<span style="display: inline-flex">';
$data['action'] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_commands&amp;copy_command=1&id='.$command['id'].'&pure='.$pure.'" $data['action'] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_commands&amp;copy_command=1&id='.$command['id'].'&pure='.$pure.'"
onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/copy.png', true).'</a>'; onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/copy.png', true).'</a>';
@ -602,7 +608,7 @@ if (count($table->data) > 0) {
ui_print_info_message(['no_close' => true, 'message' => __('No alert commands configured') ]); ui_print_info_message(['no_close' => true, 'message' => __('No alert commands configured') ]);
} }
if ($is_central_policies_on_node === false) { if ($is_central_policies_on_node === false && check_acl_restricted_all($config['id_user'], $command['id_group'], 'PM')) {
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<div class="action-buttons" style="width: '.$table->width.'">';
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_command&pure='.$pure.'">'; echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_command&pure='.$pure.'">';
html_print_submit_button(__('Create'), 'create', false, 'class="sub next"'); html_print_submit_button(__('Create'), 'create', false, 'class="sub next"');
@ -612,3 +618,26 @@ if ($is_central_policies_on_node === false) {
} }
enterprise_hook('close_meta_frame'); enterprise_hook('close_meta_frame');
?>
<script type="text/javascript">
$(document).ready(function () {
dialog_message("#message_permissions");
});
function dialog_message(message) {
$(message)
.css("display", "inline")
.dialog({
modal: true,
width: "400px",
buttons: {
Close: function() {
$(this).dialog("close");
}
}
});
}
</script>

View File

@ -123,11 +123,15 @@ $form_filter .= "</td style='font-weight: bold;'>";
$form_filter .= '</tr>'; $form_filter .= '</tr>';
$form_filter .= '<tr>'; $form_filter .= '<tr>';
$form_filter .= "<td style='font-weight: bold;'>".__('Enabled / Disabled').'</td><td>'; $form_filter .= "<td style='font-weight: bold;'>".__('Status').'</td><td>';
$ed_list = []; $ed_list = [];
$ed_list[0] = __('Enabled'); $alert_status_filter = [];
$ed_list[1] = __('Disabled'); $alert_status_filter['all_enabled'] = __('All (Enabled)');
$form_filter .= html_print_select($ed_list, 'enabledisable', $enabledisable, '', __('All'), -1, true); $alert_status_filter['all'] = __('All');
$alert_status_filter['fired'] = __('Fired');
$alert_status_filter['notfired'] = __('Not fired');
$alert_status_filter['disabled'] = __('Disabled');
$form_filter .= html_print_select($alert_status_filter, 'status_alert', $status_alert, '', '', '', true);
$form_filter .= "</td><td style='font-weight: bold;'>".__('Standby').'</td><td>'; $form_filter .= "</td><td style='font-weight: bold;'>".__('Standby').'</td><td>';
$sb_list = []; $sb_list = [];
$sb_list[1] = __('Standby on'); $sb_list[1] = __('Standby on');
@ -144,6 +148,7 @@ if (!$own_info['is_admin'] && !check_acl($config['id_user'], 0, 'AR') && !check_
$form_filter .= html_print_select_groups(false, 'AR', $return_all_group, 'ag_group', $ag_group, '', '', 0, true, false, true, '', false); $form_filter .= html_print_select_groups(false, 'AR', $return_all_group, 'ag_group', $ag_group, '', '', 0, true, false, true, '', false);
$form_filter .= '</td></tr>'; $form_filter .= '</td></tr>';
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
$form_filter .= '<tr>'; $form_filter .= '<tr>';
$form_filter .= "<td colspan='6' align='right'>"; $form_filter .= "<td colspan='6' align='right'>";
@ -174,8 +179,15 @@ $simple_alerts = [];
$total = 0; $total = 0;
$where = ''; $where = '';
if ($searchFlag) { if ($searchFlag) {
if ($status_alert === 'fired') {
$where .= ' AND talert_template_modules.times_fired > 0';
}
if ($status_alert === 'notfired') {
$where .= ' AND talert_template_modules.times_fired = 0';
}
if ($priority != -1 && $priority != '') { if ($priority != -1 && $priority != '') {
$where .= ' AND id_alert_template IN (SELECT id FROM talert_templates WHERE priority = '.$priority.')'; $where .= ' AND id_alert_template IN (SELECT id FROM talert_templates WHERE priority = '.$priority.')';
} }
@ -206,8 +218,12 @@ if ($searchFlag) {
$where .= ' AND talert_template_modules.id IN (SELECT id_alert_template_module FROM talert_template_module_actions WHERE id_alert_action = '.$actionID.') OR talert_template_modules.id IN (SELECT id FROM talert_template_modules ttm WHERE ttm.id_alert_template IN (SELECT tat.id FROM talert_templates tat WHERE tat.id_alert_action = '.$actionID.'))'; $where .= ' AND talert_template_modules.id IN (SELECT id_alert_template_module FROM talert_template_module_actions WHERE id_alert_action = '.$actionID.') OR talert_template_modules.id IN (SELECT id FROM talert_template_modules ttm WHERE ttm.id_alert_template IN (SELECT tat.id FROM talert_templates tat WHERE tat.id_alert_action = '.$actionID.'))';
} }
if ($enabledisable != -1 && $enabledisable != '') { if ($status_alert === 'disabled') {
$where .= ' AND talert_template_modules.disabled ='.$enabledisable; $where .= ' AND talert_template_modules.disabled = 1';
}
if ($status_alert === 'all_enabled') {
$where .= ' AND talert_template_modules.disabled = 0';
} }
if ($standby != -1 && $standby != '') { if ($standby != -1 && $standby != '') {
@ -385,7 +401,7 @@ switch ($sortField) {
break; break;
} }
$form_params = '&template_name='.$templateName.'&agent_name='.$agentName.'&module_name='.$moduleName.'&action_id='.$actionID.'&field_content='.$fieldContent.'&priority='.$priority.'&enabledisable='.$enabledisable.'&standby='.$standby.'&ag_group='.$ag_group; $form_params = '&template_name='.$templateName.'&agent_name='.$agentName.'&module_name='.$moduleName.'&action_id='.$actionID.'&field_content='.$fieldContent.'&priority='.$priority.'&enabledisable='.$enabledisable.'&standby='.$standby.'&ag_group='.$ag_group.'&status_alert='.$status_alert;
$sort_params = '&sort_field='.$sortField.'&sort='.$sort; $sort_params = '&sort_field='.$sortField.'&sort='.$sort;
if ($id_agente) { if ($id_agente) {

View File

@ -65,6 +65,7 @@ $searchType = get_parameter('search_type', '');
$priority = get_parameter('priority', ''); $priority = get_parameter('priority', '');
$searchFlag = get_parameter('search', 0); $searchFlag = get_parameter('search', 0);
$enabledisable = get_parameter('enabledisable', ''); $enabledisable = get_parameter('enabledisable', '');
$status_alert = get_parameter('status_alert', '');
$standby = get_parameter('standby', ''); $standby = get_parameter('standby', '');
$pure = get_parameter('pure', 0); $pure = get_parameter('pure', 0);
$ag_group = get_parameter('ag_group', 0); $ag_group = get_parameter('ag_group', 0);

View File

@ -21,7 +21,7 @@ check_login();
enterprise_hook('open_meta_frame'); enterprise_hook('open_meta_frame');
if (! check_acl($config['id_user'], 0, 'LM')) { if (! check_acl($config['id_user'], 0, 'PM')) {
db_pandora_audit( db_pandora_audit(
'ACL Violation', 'ACL Violation',
'Trying to access Alert Management' 'Trying to access Alert Management'
@ -51,7 +51,7 @@ if (is_metaconsole() === true) {
if ($id > 0) { if ($id > 0) {
$alert = alerts_get_alert_command($id); $alert = alerts_get_alert_command($id);
if ($alert['internal'] || !check_acl_restricted_all($config['id_user'], $alert['id_group'], 'LM')) { if ($alert['internal'] || !check_acl_restricted_all($config['id_user'], $alert['id_group'], 'PM')) {
db_pandora_audit('ACL Violation', 'Trying to access Alert Management'); db_pandora_audit('ACL Violation', 'Trying to access Alert Management');
include 'general/noaccess.php'; include 'general/noaccess.php';
exit; exit;

View File

@ -469,7 +469,29 @@ if (users_can_manage_group_all('MM') === true) {
} }
$table->data[2][0] = __('Group'); $table->data[2][0] = __('Group');
$table->data[2][1] = html_print_select_groups(false, 'IW', $return_all_group, 'map_group_id', $map_group_id, '', '', '', true); $table->data[2][1] = html_print_select_groups(
false,
'IW',
$return_all_group,
'map_group_id',
$map_group_id,
'',
'',
'',
true,
false,
true,
'',
false,
false,
false,
false,
'id_grupo',
false,
false,
false,
'250px'
);
$table->data[3][0] = __('Default zoom'); $table->data[3][0] = __('Default zoom');
$table->data[3][1] = html_print_input_text('map_zoom_level', $map_zoom_level, '', 2, 4, true).html_print_input_hidden('map_levels_zoom', $map_levels_zoom, true); $table->data[3][1] = html_print_input_text('map_zoom_level', $map_zoom_level, '', 2, 4, true).html_print_input_hidden('map_levels_zoom', $map_levels_zoom, true);

View File

@ -251,7 +251,16 @@ if (is_ajax()) {
$tab = (string) get_parameter('tab', 'groups'); $tab = (string) get_parameter('tab', 'groups');
if ($tab != 'credbox' && ! check_acl($config['id_user'], 0, 'PM')) { if ($tab != 'credbox' && ! check_acl(
$config['id_user'],
0,
'PM'
) && ! check_acl(
$config['id_user'],
0,
'AW'
)
) {
db_pandora_audit( db_pandora_audit(
'ACL Violation', 'ACL Violation',
'Trying to access Group Management' 'Trying to access Group Management'

View File

@ -1,17 +1,32 @@
<?php <?php
/**
* View for Add actions alerts in Massive Operations
*
* @category Configuration
* @package Pandora FMS
* @subpackage Massive Operations
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com // Begin.
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
check_login(); check_login();
if (! check_acl($config['id_user'], 0, 'AW')) { if (! check_acl($config['id_user'], 0, 'AW')) {
@ -195,9 +210,6 @@ $table->data[1][0] .= '</span>';
$table->data[1][1] = html_print_select([], 'id_agents[]', 0, false, __('Any'), '', true, true); $table->data[1][1] = html_print_select([], 'id_agents[]', 0, false, __('Any'), '', true, true);
$table->data[2][0] = __('Alert templates'); $table->data[2][0] = __('Alert templates');
$table->data[2][0] .= '<span id="template_loading" class="invisible">';
$table->data[2][0] .= html_print_image('images/spinner.png', true);
$table->data[2][0] .= '</span>';
$table->data[2][1] = html_print_select([], 'id_alert_templates[]', '', '', '', '', true, true, true, '', $alert_templates == 0); $table->data[2][1] = html_print_select([], 'id_alert_templates[]', '', '', '', '', true, true, true, '', $alert_templates == 0);
$table->data[2][2] = __('When select agents'); $table->data[2][2] = __('When select agents');
$table->data[2][2] .= '<br>'; $table->data[2][2] .= '<br>';
@ -251,36 +263,20 @@ $agents_with_templates_json = json_encode($agents_with_templates_json);
echo "<input type='hidden' id='hidden-agents_with_templates' value='$agents_with_templates_json'>"; echo "<input type='hidden' id='hidden-agents_with_templates' value='$agents_with_templates_json'>";
echo '<div class="action-buttons" style="width: '.$table->width.'" onsubmit="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'; attachActionButton('add', 'create', $table->width);
html_print_input_hidden('add', 1);
html_print_submit_button(__('Add'), 'go', false, 'class="sub add"');
echo '</div>';
echo '</form>'; echo '</form>';
echo '<h3 class="error invisible" id="message"> </h3>'; echo '<h3 class="error invisible" id="message"> </h3>';
ui_require_javascript_file('massive_operations');
ui_require_jquery_file('form'); ui_require_jquery_file('form');
ui_require_jquery_file('pandora.controls'); ui_require_jquery_file('pandora.controls');
?> ?>
<script type="text/javascript"> <script type="text/javascript">
var limit_parameters_massive = <?php echo $config['limit_parameters_massive']; ?>;
$(document).ready (function () { $(document).ready (function () {
$("#form_alerts").submit(function() {
var get_parameters_count = window.location.href.slice(
window.location.href.indexOf('?') + 1).split('&').length;
var post_parameters_count = $("#form_alerts").serializeArray().length;
var count_parameters =
get_parameters_count + post_parameters_count;
if (count_parameters > limit_parameters_massive) {
alert("<?php echo __('Unsucessful sending the data, please contact with your administrator or make with less elements.'); ?>");
return false;
}
});
update_alerts(); update_alerts();
@ -319,7 +315,7 @@ $(document).ready (function () {
jQuery.each ($("#id_agents option:selected"), function (i, val) { jQuery.each ($("#id_agents option:selected"), function (i, val) {
idAgents.push($(val).val()); idAgents.push($(val).val());
}); });
$("#template_loading").show(); showSpinner();
var $select_template = $("#id_alert_templates").disable (); var $select_template = $("#id_alert_templates").disable ();
@ -340,7 +336,7 @@ $(document).ready (function () {
} }
$("#id_alert_templates").append (options); $("#id_alert_templates").append (options);
$("#template_loading").hide (); hideSpinner();
$select_template.enable (); $select_template.enable ();
}, },
"json" "json"

View File

@ -278,10 +278,8 @@ $table->data[2][3] = '';
echo '<form method="post" id="form_alerts" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=add_alerts">'; echo '<form method="post" id="form_alerts" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=add_alerts">';
html_print_table($table); html_print_table($table);
echo '<div class="action-buttons" style="width: '.$table->width.'" onsubmit="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'; attachActionButton('add', 'add', $table->width);
html_print_input_hidden('add', 1);
html_print_submit_button(__('Add'), 'go', false, 'class="sub add"');
echo '</div>';
echo '</form>'; echo '</form>';
// TODO: Change to iu_print_error system. // TODO: Change to iu_print_error system.
@ -299,7 +297,7 @@ ui_require_jquery_file('pandora.controls');
var limit_parameters_massive = <?php echo $config['limit_parameters_massive']; ?>; var limit_parameters_massive = <?php echo $config['limit_parameters_massive']; ?>;
$(document).ready (function () { $(document).ready (function () {
$("#form_alerts").submit(function() { /* $("#form_alerts").submit(function() {
var get_parameters_count = window.location.href.slice( var get_parameters_count = window.location.href.slice(
window.location.href.indexOf('?') + 1).split('&').length; window.location.href.indexOf('?') + 1).split('&').length;
var post_parameters_count = $("#form_alerts").serializeArray().length; var post_parameters_count = $("#form_alerts").serializeArray().length;
@ -311,7 +309,7 @@ $(document).ready (function () {
alert("<?php echo __('Unsucessful sending the data, please contact with your administrator or make with less elements.'); ?>"); alert("<?php echo __('Unsucessful sending the data, please contact with your administrator or make with less elements.'); ?>");
return false; return false;
} }
}); }); */
$("#checkbox-recursion").click(function () { $("#checkbox-recursion").click(function () {
$("#id_group").trigger("change"); $("#id_group").trigger("change");
@ -321,7 +319,7 @@ $(document).ready (function () {
$("#id_group").change (function () { $("#id_group").change (function () {
var $select = $("#id_agents").enable (); var $select = $("#id_agents").enable ();
$("#agent_loading").show (); showSpinner();
$("option", $select).remove (); $("option", $select).remove ();
jQuery.post ("ajax.php", jQuery.post ("ajax.php",
@ -340,7 +338,7 @@ $(document).ready (function () {
options += "<option value=\""+id+"\">"+value+"</option>"; options += "<option value=\""+id+"\">"+value+"</option>";
}); });
$("#id_agents").append (options); $("#id_agents").append (options);
$("#agent_loading").hide (); hideSpinner();
$select.enable (); $select.enable ();
}, },
"json" "json"

View File

@ -1,20 +1,34 @@
<?php <?php
/**
* View for Add profiles in Massive Operations
*
* @category Configuration
* @package Pandora FMS
* @subpackage Massive Operations
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com // Begin.
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
check_login(); check_login();
if (!check_acl($config['id_user'], 0, 'UM')) { if (!check_acl($config['id_user'], 0, 'UM')) {
db_pandora_audit( db_pandora_audit(
'ACL Violation', 'ACL Violation',
@ -219,14 +233,14 @@ $data[2] .= html_print_select(
'width: 100%' 'width: 100%'
); );
// Waiting spinner.
ui_print_spinner(__('Loading'));
array_push($table->data, $data); array_push($table->data, $data);
html_print_table($table); html_print_table($table);
echo '<div class="action-buttons" style="width: '.$table->width.'" onsubmit="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'; attachActionButton('create_profiles', 'update', $table->width);
html_print_input_hidden('create_profiles', 1);
html_print_submit_button(__('Create'), 'go', false, 'class="sub add"');
echo '</div>';
echo '</form>'; echo '</form>';

View File

@ -1,17 +1,32 @@
<?php <?php
/**
* View for copy modules in Massive Operations
*
* @category Configuration
* @package Pandora FMS
* @subpackage Massive Operations
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com // Begin.
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
check_login(); check_login();
if (! check_acl($config['id_user'], 0, 'AW')) { if (! check_acl($config['id_user'], 0, 'AW')) {
@ -294,22 +309,17 @@ echo '<legend><span>'.__('To agent(s)').'</span></legend>';
html_print_table($table); html_print_table($table);
echo '</fieldset>'; echo '</fieldset>';
echo '<div class="action-buttons" style="width: '.$table->width.'">'; attachActionButton('do_operation', 'copy', $table->width);
html_print_input_hidden('do_operation', 1);
html_print_submit_button(__('Copy'), 'go', false, 'class="sub wand"');
echo '</div>';
echo '</form>'; echo '</form>';
echo '<h3 class="error invisible" id="message">&nbsp;</h3>'; echo '<h3 class="error invisible" id="message">&nbsp;</h3>';
// Load JS files.
ui_require_javascript_file('pandora_modules');
ui_require_jquery_file('form'); ui_require_jquery_file('form');
ui_require_jquery_file('pandora.controls'); ui_require_jquery_file('pandora.controls');
?> ?>
<script type="text/javascript" src="include/javascript/pandora_modules.js"></script>
<script type="text/javascript"> <script type="text/javascript">
/* <![CDATA[ */ /* <![CDATA[ */
var module_alerts; var module_alerts;
@ -514,7 +524,7 @@ $(document).ready (function () {
}); });
$("#manage_config_form").submit (function () { $("#manage_config_form").submit (function () {
var get_parameters_count = window.location.href.slice( /* var get_parameters_count = window.location.href.slice(
window.location.href.indexOf('?') + 1).split('&').length; window.location.href.indexOf('?') + 1).split('&').length;
var post_parameters_count = $("#manage_config_form").serializeArray().length; var post_parameters_count = $("#manage_config_form").serializeArray().length;
@ -522,9 +532,13 @@ $(document).ready (function () {
get_parameters_count + post_parameters_count; get_parameters_count + post_parameters_count;
if (count_parameters > limit_parameters_massive) { if (count_parameters > limit_parameters_massive) {
alert("<?php echo __('Unsucessful sending the data, please contact with your administrator or make with less elements.'); ?>"); alert("
<?php
// echo __('Unsucessful sending the data, please contact with your administrator or make with less elements.');
?>
");
return false; return false;
} } */

View File

@ -1,17 +1,32 @@
<?php <?php
/**
* View for delete action alerts in Massive Operations
*
* @category Configuration
* @package Pandora FMS
* @subpackage Massive Operations
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com // Begin.
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
check_login(); check_login();
if (! check_acl($config['id_user'], 0, 'AW')) { if (! check_acl($config['id_user'], 0, 'AW')) {
@ -270,10 +285,8 @@ $agents_with_templates_json = json_encode($agents_with_templates_json);
echo "<input type='hidden' id='hidden-agents_with_templates' value='".$agents_with_templates_json."'>"; echo "<input type='hidden' id='hidden-agents_with_templates' value='".$agents_with_templates_json."'>";
echo '<div class="action-buttons" style="width: '.$table->width.'" onsubmit="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'; attachActionButton('delete', 'delete', $table->width);
html_print_input_hidden('delete', 1);
html_print_submit_button(__('Delete'), 'go', false, 'class="sub delete"');
echo '</div>';
echo '</form>'; echo '</form>';
echo '<h3 class="error invisible" id="message"></h3>'; echo '<h3 class="error invisible" id="message"></h3>';

View File

@ -1,17 +1,32 @@
<?php <?php
/**
* View for delete agents in Massive Operations
*
* @category Configuration
* @package Pandora FMS
* @subpackage Massive Operations
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com // Begin.
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
check_login(); check_login();
if (! check_acl($config['id_user'], 0, 'AW')) { if (! check_acl($config['id_user'], 0, 'AW')) {
@ -186,11 +201,8 @@ $table->data[2][1] = html_print_select(
echo '<form method="post" id="form_agents" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=delete_agents">'; echo '<form method="post" id="form_agents" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=delete_agents">';
html_print_table($table); html_print_table($table);
if (!is_central_policies_on_node()) { if (is_central_policies_on_node() === false) {
echo '<div class="action-buttons" style="width: '.$table->width.'" onsubmit="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'; attachActionButton('delete', 'delete', $table->width);
html_print_input_hidden('delete', 1);
html_print_submit_button(__('Delete'), 'go', false, 'class="sub delete"');
echo '</div>';
} }
echo '</form>'; echo '</form>';
@ -202,24 +214,8 @@ ui_require_jquery_file('pandora.controls');
?> ?>
<script type="text/javascript"> <script type="text/javascript">
var limit_parameters_massive = <?php echo $config['limit_parameters_massive']; ?>;
$(document).ready (function () { $(document).ready (function () {
$("#form_agents").submit(function() {
var get_parameters_count = window.location.href.slice(
window.location.href.indexOf('?') + 1).split('&').length;
var post_parameters_count = $("#form_agents").serializeArray().length;
var count_parameters =
get_parameters_count + post_parameters_count;
if (count_parameters > limit_parameters_massive) {
alert("<?php echo __('Unsucessful sending the data, please contact with your administrator or make with less elements.'); ?>");
return false;
}
});
var recursion; var recursion;
$("#checkbox-recursion").click(function () { $("#checkbox-recursion").click(function () {

View File

@ -1,17 +1,32 @@
<?php <?php
/**
* View for Delete alerts in Massive Operations
*
* @category Configuration
* @package Pandora FMS
* @subpackage Massive Operations
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com // Begin.
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
check_login(); check_login();
if (! check_acl($config['id_user'], 0, 'AW')) { if (! check_acl($config['id_user'], 0, 'AW')) {
@ -321,10 +336,8 @@ $table->data[2][3] = html_print_select([], 'module[]', '', false, '', '', true,
echo '<form method="post" id="form_alerts" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=delete_alerts" >'; echo '<form method="post" id="form_alerts" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=delete_alerts" >';
html_print_table($table); html_print_table($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">'; attachActionButton('delete', 'delete', $table->width);
html_print_input_hidden('delete', 1);
html_print_submit_button(__('Delete'), 'go', false, 'class="sub delete"');
echo '</div>';
echo '</form>'; echo '</form>';
// Hack to translate text "none" in PHP to javascript // Hack to translate text "none" in PHP to javascript
@ -371,7 +384,7 @@ $(document).ready (function () {
$("#id_group").change (function () { $("#id_group").change (function () {
var $select = $("#id_agents").disable (); var $select = $("#id_agents").disable ();
$("#agent_loading").show (); showSpinner();
$("option", $select).remove (); $("option", $select).remove ();
jQuery.post ("ajax.php", jQuery.post ("ajax.php",
@ -393,7 +406,7 @@ $(document).ready (function () {
options += "<option value=\""+id+"\">"+value+"</option>"; options += "<option value=\""+id+"\">"+value+"</option>";
}); });
$("#id_agents").append (options); $("#id_agents").append (options);
$("#agent_loading").hide (); hideSpinner();
$select.enable (); $select.enable ();
}, },
"json" "json"

View File

@ -1,17 +1,32 @@
<?php <?php
/**
* View for delete modules in Massive Operations
*
* @category Configuration
* @package Pandora FMS
* @subpackage Massive Operations
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com // Begin.
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
check_login(); check_login();
if (! check_acl($config['id_user'], 0, 'AW')) { if (! check_acl($config['id_user'], 0, 'AW')) {
@ -563,10 +578,8 @@ $table->data['form_agents_3'][3] = html_print_select(
echo '<form method="post" id="form_modules" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=delete_modules" >'; echo '<form method="post" id="form_modules" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=delete_modules" >';
html_print_table($table); html_print_table($table);
echo '<div class="action-buttons" style="width: '.$table->width.'" onsubmit="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'; attachActionButton('delete', 'delete', $table->width);
html_print_input_hidden('delete', 1);
html_print_submit_button(__('Delete'), 'go', false, 'class="sub delete"');
echo '</div>';
echo '</form>'; echo '</form>';
echo '<h3 class="error invisible" id="message"> </h3>'; echo '<h3 class="error invisible" id="message"> </h3>';
@ -575,6 +588,9 @@ ui_require_jquery_file('form');
// Hack to translate text "none" in PHP to javascript // Hack to translate text "none" in PHP to javascript
echo '<span id ="none_text" style="display: none;">'.__('None').'</span>'; echo '<span id ="none_text" style="display: none;">'.__('None').'</span>';
echo '<span id ="select_agent_first_text" style="display: none;">'.__('Please, select an agent first').'</span>'; echo '<span id ="select_agent_first_text" style="display: none;">'.__('Please, select an agent first').'</span>';
// Load JS files.
ui_require_javascript_file('pandora_modules');
ui_require_jquery_file('pandora.controls'); ui_require_jquery_file('pandora.controls');
if ($selection_mode == 'modules') { if ($selection_mode == 'modules') {
@ -586,13 +602,10 @@ if ($selection_mode == 'modules') {
} }
?> ?>
<script type="text/javascript" src="include/javascript/pandora_modules.js"></script>
<script type="text/javascript"> <script type="text/javascript">
/* <![CDATA[ */ /* <![CDATA[ */
var limit_parameters_massive = <?php echo $config['limit_parameters_massive']; ?>;
$(document).ready (function () { $(document).ready (function () {
$("#checkbox-select_all_modules").change(function() { $("#checkbox-select_all_modules").change(function() {
if( $('#checkbox-select_all_modules').prop('checked')) { if( $('#checkbox-select_all_modules').prop('checked')) {
$("#module_name option").prop('selected', 'selected'); $("#module_name option").prop('selected', 'selected');
@ -689,7 +702,7 @@ $(document).ready (function () {
} }
} }
$("#module_loading").show (); showSpinner();
$("tr#delete_table-edit1, tr#delete_table-edit2").hide (); $("tr#delete_table-edit1, tr#delete_table-edit2").hide ();
$("#module_name").attr ("disabled", "disabled") $("#module_name").attr ("disabled", "disabled")
$("#module_name option[value!=0]").remove (); $("#module_name option[value!=0]").remove ();
@ -702,7 +715,7 @@ $(document).ready (function () {
.html(value["nombre"]); .html(value["nombre"]);
$("#module_name").append (option); $("#module_name").append (option);
}); });
$("#module_loading").hide(); hideSpinner();
$("#module_name").removeAttr ("disabled"); $("#module_name").removeAttr ("disabled");
//Filter modules. Call the function when the select is fully loaded. //Filter modules. Call the function when the select is fully loaded.
var textNoData = "<?php echo __('None'); ?>"; var textNoData = "<?php echo __('None'); ?>";
@ -832,21 +845,7 @@ $(document).ready (function () {
selector = $("#form_edit input[name=selection_mode]:checked").val(); selector = $("#form_edit input[name=selection_mode]:checked").val();
$("#id_agents").trigger("change"); $("#id_agents").trigger("change");
}); });
$("#form_modules").submit(function() {
var get_parameters_count = window.location.href.slice(
window.location.href.indexOf('?') + 1).split('&').length;
var post_parameters_count = $("#form_modules").serializeArray().length;
var count_parameters =
get_parameters_count + post_parameters_count;
if (count_parameters > limit_parameters_massive) {
alert("<?php echo __('Unsucessful sending the data, please contact with your administrator or make with less elements.'); ?>");
return false;
}
});
if("<?php echo $delete; ?>"){ if("<?php echo $delete; ?>"){
if("<?php echo $selection_mode; ?>" == 'agents'){ if("<?php echo $selection_mode; ?>" == 'agents'){
$("#groups_select").trigger("change"); $("#groups_select").trigger("change");

View File

@ -1,17 +1,32 @@
<?php <?php
/**
* View for delete profiles in Massive Operations
*
* @category Configuration
* @package Pandora FMS
* @subpackage Massive Operations
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com // Begin.
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
check_login(); check_login();
if (! check_acl($config['id_user'], 0, 'UM')) { if (! check_acl($config['id_user'], 0, 'UM')) {
@ -199,16 +214,13 @@ array_push($table->data, $data);
html_print_table($table); html_print_table($table);
echo '<div class="action-buttons" style="width: '.$table->width.'" onsubmit="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'; attachActionButton('delete_profiles', 'delete', $table->width);
html_print_input_hidden('delete_profiles', 1);
html_print_submit_button(__('Delete'), 'del', false, 'class="sub delete"');
echo '</div>';
echo '</form>'; echo '</form>';
unset($table); unset($table);
// TODO: Change to iu_print_error system // TODO: Change to iu_print_error system.
echo '<h3 class="error invisible" id="message"> </h3>'; echo '<h3 class="error invisible" id="message"> </h3>';
ui_require_jquery_file('form'); ui_require_jquery_file('form');
@ -224,7 +236,7 @@ $(document).ready (function () {
var $select = $("#users_id").disable (); var $select = $("#users_id").disable ();
$("#users_loading").show (); $("#users_loading").show ();
$("option", $select).remove (); $("option", $select).remove ();
console.log($("#groups_id").val());
jQuery.post ("ajax.php", jQuery.post ("ajax.php",
{"page" : "godmode/massive/massive_delete_profiles", {"page" : "godmode/massive/massive_delete_profiles",
"get_users" : 1, "get_users" : 1,

View File

@ -1,17 +1,32 @@
<?php <?php
/**
* View for edit agents in Massive Operations
*
* @category Configuration
* @package Pandora FMS
* @subpackage Massive Operations
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com // Begin.
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
check_login(); check_login();
if (! check_acl($config['id_user'], 0, 'AW')) { if (! check_acl($config['id_user'], 0, 'AW')) {
@ -327,13 +342,16 @@ if ($update_agents) {
// Update Custom Fields // Update Custom Fields
foreach ($fields as $field) { foreach ($fields as $field) {
$info[$field['id_field']] = $field['name']; $info[$field['id_field']] = $field['name'];
if (get_parameter_post('customvalue_'.$field['id_field'], '') != '') { $value = get_parameter('customvalue_'.$field['id_field']);
if (empty($value) === false) {
$key = $field['id_field']; $key = $field['id_field'];
$value = get_parameter_post('customvalue_'.$field['id_field'], ''); $old_value = db_get_all_rows_filter(
'tagent_custom_data',
$old_value = db_get_all_rows_filter('tagent_custom_data', ['id_agent' => $id_agent, 'id_field' => $key]); [
'id_agent' => $id_agent,
'id_field' => $key,
]
);
if ($old_value === false) { if ($old_value === false) {
// Create custom field if not exist // Create custom field if not exist
@ -346,14 +364,16 @@ if ($update_agents) {
] ]
); );
} else { } else {
$result = db_process_sql_update( if ($old_value[0]['description'] !== $value) {
'tagent_custom_data', $result = db_process_sql_update(
['description' => $value], 'tagent_custom_data',
[ ['description' => $value],
'id_field' => $key, [
'id_agent' => $id_agent, 'id_field' => $key,
] 'id_agent' => $id_agent,
); ]
);
}
} }
} }
} }
@ -373,7 +393,7 @@ if ($update_agents) {
ui_print_result_message( ui_print_result_message(
$result !== false, $result !== false,
__('Agents updated successfully').'('.$n_edited.')', __('Agents updated successfully (%d)', $n_edited),
__('Agents cannot be updated (maybe there was no field to update)') __('Agents cannot be updated (maybe there was no field to update)')
); );
} }
@ -830,19 +850,16 @@ if (!empty($fields)) {
echo '<h3 class="error invisible" id="message"> </h3>'; echo '<h3 class="error invisible" id="message"> </h3>';
echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_submit_button(__('Update'), 'updbutton', false, 'class="sub upd"');
html_print_input_hidden('update_agents', 1);
html_print_input_hidden('id_agente', $id_agente); html_print_input_hidden('id_agente', $id_agente);
echo '</div>'; if (is_central_policies_on_node() === false) {
attachActionButton('update_agents', 'update', $table->width);
}
// Shown and hide div // Shown and hide div
echo '</div></form>'; echo '</div></form>';
ui_require_jquery_file('form'); ui_require_jquery_file('form');
ui_require_jquery_file('pandora.controls');
ui_require_jquery_file('pandora.controls'); ui_require_jquery_file('pandora.controls');
ui_require_jquery_file('ajaxqueue'); ui_require_jquery_file('ajaxqueue');

View File

@ -1,17 +1,32 @@
<?php <?php
/**
* View for edit modules in Massive Operations
*
* @category Configuration
* @package Pandora FMS
* @subpackage Massive Operations
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com // Begin.
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
check_login(); check_login();
if (! check_acl($config['id_user'], 0, 'AW')) { if (! check_acl($config['id_user'], 0, 'AW')) {
@ -280,9 +295,6 @@ $table->data['selection_mode'][1] .= '<span style="width:110px;display:inline-bl
$table->rowclass['form_modules_1'] = 'select_modules_row'; $table->rowclass['form_modules_1'] = 'select_modules_row';
$table->data['form_modules_1'][0] = __('Module type'); $table->data['form_modules_1'][0] = __('Module type');
$table->data['form_modules_1'][0] .= '<span id="module_loading" class="invisible">';
$table->data['form_modules_1'][0] .= html_print_image('images/spinner.png', true);
$table->data['form_modules_1'][0] .= '</span>';
$types[0] = __('All'); $types[0] = __('All');
$table->colspan['form_modules_1'][1] = 2; $table->colspan['form_modules_1'][1] = 2;
@ -1161,30 +1173,37 @@ $table->data['edit1'][1] = '<table width="100%">';
'' ''
); );
if (!empty($id_plugin)) { if (empty($id_plugin) === false) {
$preload = db_get_sql("SELECT description FROM tplugin WHERE id = $id_plugin"); $preload = db_get_sql(
sprintf(
'SELECT description FROM tplugin WHERE id = %s',
$id_plugin
)
);
$preload = io_safe_output($preload); $preload = io_safe_output($preload);
$preload = str_replace("\n", '<br>', $preload); $preload = str_replace("\n", '<br>', $preload);
} else { } else {
$preload = ''; $preload = '';
} }
$table->data['edit21'][1] = '<span style="font-weight: normal;" id="plugin_description">'.$preload.'</span>'; $table->data['edit21'][1] = sprintf(
'<span style="font-weight: normal;" id="plugin_description">%s</span>',
$preload
);
echo '<form method="post" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=edit_modules" id="form_edit">';
echo '<form method="post" '.'action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=edit_modules" '.'id="form_edit">';
html_print_table($table); html_print_table($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">'; attachActionButton('update', 'update', $table->width);
html_print_input_hidden('update', 1);
html_print_submit_button(__('Update'), 'go', false, 'class="sub upd"');
echo '</div>';
echo '</form>'; echo '</form>';
echo '<h3 class="error invisible" id="message"> </h3>'; echo '<h3 class="error invisible" id="message"> </h3>';
// Hack to translate text "none" in PHP to javascript // Hack to translate text "none" in PHP to javascript.
echo '<span id ="none_text" style="display: none;">'.__('None').'</span>'; echo '<span id ="none_text" style="display: none;">'.__('None').'</span>';
echo '<span id ="select_agent_first_text" style="display: none;">'.__('Please, select an agent first').'</span>'; echo '<span id ="select_agent_first_text" style="display: none;">'.__('Please, select an agent first').'</span>';
// Load JS files.
ui_require_javascript_file('pandora_modules');
ui_require_jquery_file('pandora.controls'); ui_require_jquery_file('pandora.controls');
if ($selection_mode == 'modules') { if ($selection_mode == 'modules') {
@ -1196,27 +1215,11 @@ $table->data['edit1'][1] = '<table width="100%">';
} }
?> ?>
<script type="text/javascript">flag_load_plugin_component = false;</script>
<script type="text/javascript" src="include/javascript/pandora_modules.js"></script>
<script type="text/javascript"> <script type="text/javascript">
/* <![CDATA[ */ /* <![CDATA[ */
var limit_parameters_massive = <?php echo $config['limit_parameters_massive']; ?>; flag_load_plugin_component = false;
$(document).ready (function () { $(document).ready (function () {
$("#form_edit").submit(function() {
var get_parameters_count = window.location.href.slice(
window.location.href.indexOf('?') + 1).split('&').length;
var post_parameters_count = $("#form_edit").serializeArray().length;
var count_parameters =
get_parameters_count + post_parameters_count;
if (count_parameters > limit_parameters_massive) {
alert("<?php echo __('Unsucessful sending the data, please contact with your administrator or make with less elements.'); ?>");
return false;
}
});
$("#checkbox-select_all_modules").change(function() { $("#checkbox-select_all_modules").change(function() {
if( $('#checkbox-select_all_modules').prop('checked')) { if( $('#checkbox-select_all_modules').prop('checked')) {
@ -1340,7 +1343,7 @@ $(document).ready (function () {
} }
} }
$("#module_loading").show (); showSpinner();
$("tr#delete_table-edit1, tr#delete_table-edit0, tr#delete_table-edit2").hide (); $("tr#delete_table-edit1, tr#delete_table-edit0, tr#delete_table-edit2").hide ();
$("#module_name").attr ("disabled", "disabled") $("#module_name").attr ("disabled", "disabled")
$("#module_name option[value!=0]").remove (); $("#module_name option[value!=0]").remove ();
@ -1351,7 +1354,7 @@ $(document).ready (function () {
option = $("<option></option>").attr ("value", value["nombre"]).html (value["nombre"]); option = $("<option></option>").attr ("value", value["nombre"]).html (value["nombre"]);
$("#module_name").append (option); $("#module_name").append (option);
}); });
$("#module_loading").hide (); hideSpinner();
$("#module_name").removeAttr ("disabled"); $("#module_name").removeAttr ("disabled");
//Filter modules. Call the function when the select is fully loaded. //Filter modules. Call the function when the select is fully loaded.
var textNoData = "<?php echo __('None'); ?>"; var textNoData = "<?php echo __('None'); ?>";
@ -1864,7 +1867,6 @@ function changePluginSelect() {
$('#hidden-macros').val(data['base64']); $('#hidden-macros').val(data['base64']);
jQuery.each (data['array'], function (i, macro) { jQuery.each (data['array'], function (i, macro) {
console.log(macro);
if (macro['desc'] != '') { if (macro['desc'] != '') {
$("#delete_table-edit21").after("<tr class='macro_field' id='delete_table-edit"+(80+parseInt(i))+"'><td style='font-weight:bold;'>"+macro['desc']+"<input type='hidden' name='desc"+macro['macro']+"' value='"+macro['desc']+"'></td><td><input type='text' name='"+macro['macro']+"'></td></tr>"); $("#delete_table-edit21").after("<tr class='macro_field' id='delete_table-edit"+(80+parseInt(i))+"'><td style='font-weight:bold;'>"+macro['desc']+"<input type='hidden' name='desc"+macro['macro']+"' value='"+macro['desc']+"'></td><td><input type='text' name='"+macro['macro']+"'></td></tr>");
} }

View File

@ -1,17 +1,32 @@
<?php <?php
/**
* View for edit plugins in Massive Operations
*
* @category Configuration
* @package Pandora FMS
* @subpackage Massive Operations
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com // Begin.
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
global $config; global $config;
check_login(); check_login();
@ -371,10 +386,7 @@ echo '<form method="POST" id="form-massive_plugin_edition"
html_print_table($table); html_print_table($table);
echo "<div style='text-align: right; width: ".$table->width."'>"; attachActionButton('update', 'update', $table->width);
html_print_input_hidden('update', 1);
html_print_submit_button(__('Update'), 'upd-btn', false, 'class="sub upd"');
echo '</div>';
echo '</form>'; echo '</form>';
@ -405,35 +417,6 @@ echo '</form>';
canSubmit = val; canSubmit = val;
$submitButton.prop('disabled', !val); $submitButton.prop('disabled', !val);
} }
var showSpinner = function () {
var $loadingSpinner = $pluginsSelect.siblings('img#loading_spinner');
if ($loadingSpinner.length > 0) {
// Display inline instead using the show function
// cause its absolute positioning.
$loadingSpinner.css('display', 'inline');
return;
}
$loadingSpinner = $('<img />');
$loadingSpinner
.prop('id', 'loading_spinner')
.css('padding-left', '5px')
.css('position', 'absolute')
.css('top', $pluginsSelect.position().top + 'px')
.prop('src', "<?php echo $config['homeurl'].'/'; ?>images/spinner.gif");
$pluginsSelect.parent().append($loadingSpinner);
}
var hideSpinner = function () {
var $loadingSpinner = $pluginsSelect.siblings('img#loading_spinner');
if ($loadingSpinner.length > 0)
$loadingSpinner.hide();
}
var clearModulePluginMacrosValues = function () { var clearModulePluginMacrosValues = function () {
$('input.plugin-macro') $('input.plugin-macro')
@ -864,6 +847,7 @@ echo '</form>';
} }
var errorHandler = function (error) { var errorHandler = function (error) {
hideSpinner();
console.log("<?php echo __('Error'); ?>: " + error.message); console.log("<?php echo __('Error'); ?>: " + error.message);
// alert("<?php echo __('Error'); ?>: " + err.message); // alert("<?php echo __('Error'); ?>: " + err.message);
@ -927,7 +911,10 @@ echo '</form>';
$agentModulesRow.show(); $agentModulesRow.show();
} }
else { else {
alert("<?php echo __('There are no modules using this plugin'); ?>"); var contents = {};
contents.html = '<?php echo __('There are no modules using this plugin'); ?>';
contents.title = '<?php echo __('Massive operations'); ?>';
showMassiveModal(contents);
// Abort the another call // Abort the another call
if (typeof pluginXHR !== 'undefined') { if (typeof pluginXHR !== 'undefined') {

View File

@ -1,17 +1,32 @@
<?php <?php
/**
* View for enable/disable alerts in Massive Operations
*
* @category Configuration
* @package Pandora FMS
* @subpackage Massive Operations
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com // Begin.
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
check_login(); check_login();
if (! check_acl($config['id_user'], 0, 'AW')) { if (! check_acl($config['id_user'], 0, 'AW')) {

View File

@ -1,17 +1,32 @@
<?php <?php
/**
* Main view for Massive Operations
*
* @category Configuration
* @package Pandora FMS
* @subpackage Massive Operations
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com // Begin.
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars.
check_login(); check_login();
if (! check_acl($config['id_user'], 0, 'AW')) { if (! check_acl($config['id_user'], 0, 'AW')) {
@ -26,6 +41,7 @@ if (! check_acl($config['id_user'], 0, 'AW')) {
require_once 'include/functions_agents.php'; require_once 'include/functions_agents.php';
require_once 'include/functions_alerts.php'; require_once 'include/functions_alerts.php';
require_once 'include/functions_modules.php'; require_once 'include/functions_modules.php';
require_once 'include/functions_massive_operations.php';
enterprise_include('godmode/massive/massive_operations.php'); enterprise_include('godmode/massive/massive_operations.php');
@ -316,35 +332,49 @@ $submit_template_enabled = get_parameter('id_alert_template_enabled');
$submit_template_not_standby = get_parameter('id_alert_template_not_standby'); $submit_template_not_standby = get_parameter('id_alert_template_not_standby');
$submit_template_standby = get_parameter('id_alert_template_standby'); $submit_template_standby = get_parameter('id_alert_template_standby');
$submit_add = get_parameter('crtbutton'); $submit_add = get_parameter('crtbutton');
// Waiting spinner.
ui_print_spinner(__('Loading'));
// Modal for show messages.
html_print_div(
[
'id' => 'massive_modal',
'content' => '',
]
);
// Load common JS files.
ui_require_javascript_file('massive_operations');
echo '<div id="loading" display="none">';
echo html_print_image('images/wait.gif', true, ['border' => '0']).'<br />';
echo '<strong>'.__('Please wait...').'</strong>';
echo '</div>';
?> ?>
<script language="javascript" type="text/javascript"> <script language="javascript" type="text/javascript">
/* <![CDATA[ */
$(document).ready (function () { $(document).ready (function () {
$('#manage_config_form').submit( function() { $('#button-go').click( function(e) {
confirm_status = var limitParametersMassive = <?php echo $config['limit_parameters_massive']; ?>;
confirm("<?php echo __('Are you sure?'); ?>"); var thisForm = e.target.form.id;
if (confirm_status)
$("#loading").css("display", ""); var get_parameters_count = window.location.href.slice(
else window.location.href.indexOf('?') + 1).split('&').length;
var post_parameters_count = $('#'+thisForm).serializeArray().length;
var totalCount = get_parameters_count + post_parameters_count;
var contents = {};
contents.html = '<?php echo __('No changes have been made because they exceed the maximum allowed (%d). Make fewer changes or contact the administrator.', $config['limit_parameters_massive']); ?>';
contents.title = '<?php echo __('Massive operations'); ?>';
contents.question = '<?php echo __('Are you sure?'); ?>';
contents.ok = '<?php echo __('OK'); ?>';
contents.cancel = '<?php echo __('Cancel'); ?>';
var operation = massiveOperationValidation(contents, totalCount, limitParametersMassive, thisForm);
if (operation == false) {
return false; return false;
}
}); });
$('[id^=form]').submit( function() {
confirm_status =
confirm("<?php echo __('Are you sure?'); ?>");
if (confirm_status)
$("#loading").css("display", "");
else
return false;
});
$("#loading").css("display", "none");
}); });
/* ]]> */
</script> </script>
<?php <?php

View File

@ -1,17 +1,32 @@
<?php <?php
/**
* View for delete action alerts in Massive Operations
*
* @category Configuration
* @package Pandora FMS
* @subpackage Massive Operations
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com // Begin.
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
check_login(); check_login();
if (! check_acl($config['id_user'], 0, 'AW')) { if (! check_acl($config['id_user'], 0, 'AW')) {
@ -285,7 +300,7 @@ $(document).ready (function () {
jQuery.each ($("#id_agents option:selected"), function (i, val) { jQuery.each ($("#id_agents option:selected"), function (i, val) {
idAgents.push($(val).val()); idAgents.push($(val).val());
}); });
$("#template_loading").show(); showSpinner();
var $select_template = $("#id_alert_templates").disable (); var $select_template = $("#id_alert_templates").disable ();
$("option", $select_template).remove (); $("option", $select_template).remove ();
@ -302,7 +317,7 @@ $(document).ready (function () {
options += "<option value=\""+id+"\">"+value+"</option>"; options += "<option value=\""+id+"\">"+value+"</option>";
}); });
$("#id_alert_templates").append (options); $("#id_alert_templates").append (options);
$("#template_loading").hide (); hideSpinner();
$select_template.enable (); $select_template.enable ();
}, },
"json" "json"

View File

@ -64,19 +64,6 @@ if (defined('METACONSOLE')) {
$help_header = 'network_component_tab'; $help_header = 'network_component_tab';
} }
ui_print_page_header(
__('Remote components'),
'',
false,
$help_header,
true,
'',
false,
'modulemodal',
GENERIC_SIZE_TEXT,
'',
__('Configuration').'&nbsp;/&nbsp;'.__('Templates').'&nbsp;/&nbsp;'.__('Remote components')
);
$sec = 'gmodules'; $sec = 'gmodules';
} }

View File

@ -48,7 +48,9 @@ if (enterprise_installed()) {
'basic' => __('Basic'), 'basic' => __('Basic'),
'advanced' => __('Advanced'), 'advanced' => __('Advanced'),
]; ];
$table->data[0][3] = html_print_select($wizard_levels, 'wizard_level', $wizard_level, '', '', -1, true, false, false).' '.ui_print_help_icon('meta_access', true); // TODO review help tips on meta.
$table->data[0][3] = html_print_select($wizard_levels, 'wizard_level', $wizard_level, '', '', -1, true, false, false).' ';
// .ui_print_help_icon('meta_access', true)
} else { } else {
$table->data[0][2] = ''; $table->data[0][2] = '';
$table->data[0][3] = html_print_input_hidden('wizard_level', $wizard_level, true); $table->data[0][3] = html_print_input_hidden('wizard_level', $wizard_level, true);

View File

@ -212,7 +212,17 @@ $table->data[1][1] = html_print_select_groups(
-1, -1,
true, true,
false, false,
false false,
'',
false,
false,
false,
false,
'id_grupo',
false,
false,
false,
'250px'
); );
if ($advanced_filter != '') { if ($advanced_filter != '') {

View File

@ -235,7 +235,7 @@ if ($count_module_array > 0) {
echo '<table><tr>'; echo '<table><tr>';
echo "<form method='post' action='index.php?sec=reporting&sec2=godmode/reporting/graph_builder&edit_graph=1&tab=graph_editor&change_label=1&id=".$id_graph.'&graph='.$idgs_array[$a]."'>"; echo "<form method='post' action='index.php?sec=reporting&sec2=godmode/reporting/graph_builder&edit_graph=1&tab=graph_editor&change_label=1&id=".$id_graph.'&graph='.$idgs_array[$a]."'>";
html_print_input_text('label', $label_array[$a], '', 20, 30, false, false); html_print_input_text('label', $label_array[$a], '', 30, 80, false, false);
html_print_submit_button('Ok', 'btn', false, '', false); html_print_submit_button('Ok', 'btn', false, '', false);
echo '</form>'; echo '</form>';

View File

@ -140,6 +140,8 @@ $visual_format = 0;
// Others. // Others.
$filter_search = ''; $filter_search = '';
$filter_exclude = '';
// Added for select fields. // Added for select fields.
$total_time = true; $total_time = true;
@ -183,6 +185,7 @@ switch ($action) {
$dyn_height = 230; $dyn_height = 230;
$landscape = false; $landscape = false;
$pagebreak = false; $pagebreak = false;
$summary = 0;
break; break;
case 'save': case 'save':
@ -312,11 +315,12 @@ switch ($action) {
$idCustomGraph = $item['id_gs']; $idCustomGraph = $item['id_gs'];
break; break;
case 'availability_graph':
$summary = $item['summary'];
case 'SLA': case 'SLA':
case 'SLA_weekly': case 'SLA_weekly':
case 'SLA_monthly': case 'SLA_monthly':
case 'SLA_hourly': case 'SLA_hourly':
case 'availability_graph':
$description = $item['description']; $description = $item['description'];
$only_display_wrong = $item['only_display_wrong']; $only_display_wrong = $item['only_display_wrong'];
$monday = $item['monday']; $monday = $item['monday'];
@ -556,6 +560,8 @@ switch ($action) {
$include_extended_events = $item['show_extended_events']; $include_extended_events = $item['show_extended_events'];
$filter_search = $style['event_filter_search']; $filter_search = $style['event_filter_search'];
$filter_exclude = $style['event_filter_exclude'];
break; break;
case 'event_report_group': case 'event_report_group':
@ -570,6 +576,7 @@ switch ($action) {
$event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated']; $event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated'];
$filter_search = $style['event_filter_search']; $filter_search = $style['event_filter_search'];
$filter_exclude = $style['event_filter_exclude'];
$filter_event_severity = json_decode($style['filter_event_severity'], true); $filter_event_severity = json_decode($style['filter_event_severity'], true);
$filter_event_status = json_decode($style['filter_event_status'], true); $filter_event_status = json_decode($style['filter_event_status'], true);
@ -607,6 +614,8 @@ switch ($action) {
$event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated']; $event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated'];
$filter_search = $style['event_filter_search']; $filter_search = $style['event_filter_search'];
$filter_exclude = $style['event_filter_exclude'];
$include_extended_events = $item['show_extended_events']; $include_extended_events = $item['show_extended_events'];
break; break;
@ -2743,11 +2752,42 @@ $class = 'databox filters';
</td> </td>
</tr> </tr>
<tr id="row_summary" style="" class="datos">
<td style="font-weight:bold;">
<?php
echo __('Summary');
?>
</td>
<td style="">
<?php
html_print_checkbox_switch(
'summary',
1,
$summary,
false,
false,
'',
false
);
?>
</td>
</tr>
<tr id="row_filter_search" style="" class="datos"> <tr id="row_filter_search" style="" class="datos">
<td style="font-weight:bold;"><?php echo __('Free search'); ?></td> <td style="font-weight:bold;"><?php echo __('Include filter'); ?></td>
<td> <td>
<?php <?php
html_print_input_text('filter_search', $filter_search); html_print_input_text('filter_search', $filter_search);
ui_print_help_tip(__('Free text string search on event description'));
?>
</td>
</tr>
<tr id="row_filter_exclude" style="" class="datos">
<td style="font-weight:bold;"><?php echo __('Exclude filter'); ?></td>
<td>
<?php
html_print_input_text('filter_exclude', $filter_exclude);
ui_print_help_tip(__('Free text string search on event description'));
?> ?>
</td> </td>
</tr> </tr>
@ -5099,6 +5139,7 @@ function chooseType() {
$("#row_current_month").hide(); $("#row_current_month").hide();
$("#row_failover_mode").hide(); $("#row_failover_mode").hide();
$("#row_failover_type").hide(); $("#row_failover_type").hide();
$("#row_summary").hide();
$("#row_working_time").hide(); $("#row_working_time").hide();
$("#row_working_time_compare").hide(); $("#row_working_time_compare").hide();
$("#row_only_display_wrong").hide(); $("#row_only_display_wrong").hide();
@ -5141,6 +5182,7 @@ function chooseType() {
$("#row_resolution").hide(); $("#row_resolution").hide();
$("#row_last_value").hide(); $("#row_last_value").hide();
$("#row_filter_search").hide(); $("#row_filter_search").hide();
$("#row_filter_exclude").hide();
$("#row_percentil").hide(); $("#row_percentil").hide();
$("#log_help_tip").css("visibility", "hidden"); $("#log_help_tip").css("visibility", "hidden");
$("#agents_row").hide(); $("#agents_row").hide();
@ -5191,6 +5233,8 @@ function chooseType() {
$("#row_extended_events").show(); $("#row_extended_events").show();
$("#row_filter_search").show(); $("#row_filter_search").show();
$("#row_filter_exclude").show();
$("#row_event_severity").show(); $("#row_event_severity").show();
$("#row_event_status").show(); $("#row_event_status").show();
@ -5290,6 +5334,7 @@ function chooseType() {
if(failover_checked){ if(failover_checked){
$("#row_failover_type").show(); $("#row_failover_type").show();
} }
$("#row_summary").show();
break; break;
case 'module_histogram_graph': case 'module_histogram_graph':
@ -5403,11 +5448,9 @@ function chooseType() {
case 'sql': case 'sql':
$("#row_description").show(); $("#row_description").show();
$("#row_query").show(); $("#row_query").show();
$("#row_max_items").show();
$("#row_header").show(); $("#row_header").show();
$("#row_custom").show(); $("#row_custom").show();
$("#row_custom_example").show(); $("#row_custom_example").show();
$("#row_dyn_height").show();
$("#row_servers").show(); $("#row_servers").show();
$("#row_historical_db_check").show(); $("#row_historical_db_check").show();
break; break;
@ -5486,6 +5529,8 @@ function chooseType() {
$("#row_extended_events").show(); $("#row_extended_events").show();
$("#row_filter_search").show(); $("#row_filter_search").show();
$("#row_filter_exclude").show();
$("#row_historical_db_check").hide(); $("#row_historical_db_check").hide();
break; break;
@ -5509,6 +5554,8 @@ function chooseType() {
$('#agent_autocomplete').hide(); $('#agent_autocomplete').hide();
$('#agent_autocomplete_events').show(); $('#agent_autocomplete_events').show();
$("#row_filter_search").show(); $("#row_filter_search").show();
$("#row_filter_exclude").show();
$("#row_historical_db_check").hide(); $("#row_historical_db_check").hide();
break; break;
@ -5531,6 +5578,8 @@ function chooseType() {
$('#agent_autocomplete').hide(); $('#agent_autocomplete').hide();
$('#agent_autocomplete_events').show(); $('#agent_autocomplete_events').show();
$("#row_filter_search").show(); $("#row_filter_search").show();
$("#row_filter_exclude").show();
$("#row_historical_db_check").hide(); $("#row_historical_db_check").hide();
break; break;

View File

@ -515,18 +515,68 @@ foreach ($items as $item) {
$style = json_decode(io_safe_output($item['style']), true); $style = json_decode(io_safe_output($item['style']), true);
// Macros
$items_macro = [];
if (!empty($item['id_agent'])) {
$id_agent = $item['id_agent'];
// Add macros name.
$agent_description = agents_get_description($id_agent);
$agent_group = agents_get_agent_group($id_agent);
$agent_address = agents_get_address($id_agent);
$agent_alias = agents_get_alias($id_agent);
$items_macro_agent = [
'id_agent' => $id_agent,
'agent_description' => $agent_description,
'agent_group' => $agent_group,
'agent_address' => $agent_address,
'agent_alias' => $agent_alias,
];
$items_macro = array_merge($items_macro, $items_macro_agent);
}
if (!empty($item['id_agent_module'])) {
$id_agent_module = $item['id_agent_module'];
$module_name = modules_get_agentmodule_name(
$id_agent_module
);
$module_description = modules_get_agentmodule_descripcion(
$id_agent_module
);
$items_macro_module = [
'id_agent_module' => $id_agent_module,
'module_name' => $module_name,
'module_description' => $module_description,
];
$items_macro = array_merge($items_macro, $items_macro_module);
}
if ($style['name_label'] != '') { if ($style['name_label'] != '') {
$text = empty($style['name_label']) ? $item['description'] : $style['name_label']; $text = empty($style['name_label']) ? $item['description'] : $style['name_label'];
$row[5] = ui_print_truncate_text($text, 'description', true, true);
} else { } else {
if ($item['name'] == '' && $item['description'] == '') { if ($item['name'] == '' && $item['description'] == '') {
$row[5] = '-'; $text = '-';
} else { } else {
$text = empty($item['name']) ? $item['description'] : $item['name']; $text = empty($item['name']) ? $item['description'] : $item['name'];
$row[5] = ui_print_truncate_text($text, 'description', true, true);
} }
} }
// Apply macros
$items_macro['type'] = $item['type'];
$text = reporting_label_macro(
$items_macro,
$text
);
$row[5] = ui_print_truncate_text($text, 'description', true, true);
$row[6] = ''; $row[6] = '';
if (check_acl($config['id_user'], $item['id_group'], 'RM')) { if (check_acl($config['id_user'], $item['id_group'], 'RM')) {

View File

@ -1518,12 +1518,16 @@ switch ($action) {
$values['text'] = $intervals; $values['text'] = $intervals;
break; break;
case 'availability_graph':
$values['summary'] = get_parameter(
'summary',
0
);
case 'SLA_monthly': case 'SLA_monthly':
case 'SLA_weekly': case 'SLA_weekly':
case 'SLA_hourly': case 'SLA_hourly':
case 'SLA_services': case 'SLA_services':
case 'SLA': case 'SLA':
case 'availability_graph':
$values['period'] = get_parameter('period'); $values['period'] = get_parameter('period');
$values['top_n'] = get_parameter( $values['top_n'] = get_parameter(
'combo_sla_sort_options', 'combo_sla_sort_options',
@ -1881,6 +1885,11 @@ switch ($action) {
'' ''
); );
$event_filter_exclude = get_parameter(
'filter_exclude',
''
);
// If metaconsole is activated. // If metaconsole is activated.
if (is_metaconsole() === true) { if (is_metaconsole() === true) {
if (($values['type'] == 'custom_graph') if (($values['type'] == 'custom_graph')
@ -2018,6 +2027,8 @@ switch ($action) {
$style['event_graph_by_criticity'] = $event_graph_by_criticity; $style['event_graph_by_criticity'] = $event_graph_by_criticity;
$style['event_graph_validated_vs_unvalidated'] = $event_graph_validated_vs_unvalidated; $style['event_graph_validated_vs_unvalidated'] = $event_graph_validated_vs_unvalidated;
$style['event_filter_search'] = $event_filter_search; $style['event_filter_search'] = $event_filter_search;
$style['event_filter_exclude'] = $event_filter_exclude;
if ($label != '') { if ($label != '') {
$style['label'] = $label; $style['label'] = $label;
@ -2563,6 +2574,11 @@ switch ($action) {
REPORT_FAILOVER_TYPE_NORMAL REPORT_FAILOVER_TYPE_NORMAL
); );
$values['summary'] = get_parameter(
'summary',
0
);
$style = []; $style = [];
$style['show_in_same_row'] = get_parameter( $style['show_in_same_row'] = get_parameter(
'show_in_same_row', 'show_in_same_row',
@ -2622,6 +2638,12 @@ switch ($action) {
'' ''
); );
$event_filter_exclude = get_parameter(
'filter_exclude',
''
);
// Added for events items. // Added for events items.
$style['show_summary_group'] = $show_summary_group; $style['show_summary_group'] = $show_summary_group;
$style['filter_event_severity'] = json_encode( $style['filter_event_severity'] = json_encode(
@ -2639,6 +2661,8 @@ switch ($action) {
$style['event_graph_by_criticity'] = $event_graph_by_criticity; $style['event_graph_by_criticity'] = $event_graph_by_criticity;
$style['event_graph_validated_vs_unvalidated'] = $event_graph_validated_vs_unvalidated; $style['event_graph_validated_vs_unvalidated'] = $event_graph_validated_vs_unvalidated;
$style['event_filter_search'] = $event_filter_search; $style['event_filter_search'] = $event_filter_search;
$style['event_filter_exclude'] = $event_filter_exclude;
if ($label != '') { if ($label != '') {
$style['label'] = $label; $style['label'] = $label;
} else { } else {

View File

@ -79,6 +79,13 @@ if (check_acl($config['id_user'], 0, 'PM')) {
$table->data = []; $table->data = [];
$names_servers = []; $names_servers = [];
$master = 1;
// The server with the highest number in master, will be the real master.
foreach ($servers as $server) {
if ($server['master'] > $master) {
$master = $server['master'];
}
}
foreach ($servers as $server) { foreach ($servers as $server) {
$data = []; $data = [];
@ -109,7 +116,7 @@ foreach ($servers as $server) {
// Type // Type
$data[2] = '<span style="white-space:nowrap;">'.$server['img']; $data[2] = '<span style="white-space:nowrap;">'.$server['img'];
if ($server['master'] == 1) { if ($server['master'] == $master) {
$data[2] .= ui_print_help_tip(__('This is a master server'), true); $data[2] .= ui_print_help_tip(__('This is a master server'), true);
} }

View File

@ -759,7 +759,7 @@ echo '<legend>'.__('Mail configuration').'</legend>';
'', '',
'class="sub next"', 'class="sub next"',
true true
).'&nbsp&nbsp<span id="email_test_sent_message" style="display:none;">Email sent</span><span id="email_test_failure_message" style="display:none;">Email could not been sent</span>'; ).'&nbsp&nbsp<span id="email_test_sent_message" style="display:none;">Email sent</span><span id="email_test_failure_message" style="display:none;">Email could not be sent</span>';
echo '<div id="email_test_'.$id.'" title="'.__('Check mail configuration').'" style="display:none">'.html_print_table($table_mail_test, true).'</div>'; echo '<div id="email_test_'.$id.'" title="'.__('Check mail configuration').'" style="display:none">'.html_print_table($table_mail_test, true).'</div>';
} }

View File

@ -65,6 +65,7 @@ if (get_parameter('remove_source_on_database', 0)) {
if (get_parameter('update_config', 0)) { if (get_parameter('update_config', 0)) {
$element = (string) get_parameter('element', ''); $element = (string) get_parameter('element', '');
$value = (int) get_parameter('value', 0); $value = (int) get_parameter('value', 0);
$source = (string) get_parameter('source');
// Update the label value. // Update the label value.
ob_clean(); ob_clean();
@ -75,6 +76,37 @@ if (get_parameter('update_config', 0)) {
$res = ($value) ? notifications_add_group_to_source($source, [0]) : notifications_remove_group_from_source($source, [0]); $res = ($value) ? notifications_add_group_to_source($source, [0]) : notifications_remove_group_from_source($source, [0]);
break; break;
case 'subtype':
$data = explode('.', $source, 2);
$source_id = $data[0];
$subtype = $data[1];
$source = notifications_get_all_sources(
[ 'id' => $source_id ]
);
if ($source !== false && is_array($source[0]) === true) {
$source = $source[0];
$blacklist = json_decode($source['subtype_blacklist'], 1);
if (json_last_error() !== JSON_ERROR_NONE) {
$blacklist = [];
}
if ((bool) $value === true) {
unset($blacklist[$subtype]);
} else {
$blacklist[$subtype] = 1;
}
$source['subtype_blacklist'] = json_encode($blacklist, 1);
$res = (bool) db_process_sql_update(
'tnotification_source',
['subtype_blacklist' => $source['subtype_blacklist']],
['id' => $source['id']]
);
}
break;
default: default:
$res = (bool) db_process_sql_update( $res = (bool) db_process_sql_update(
'tnotification_source', 'tnotification_source',
@ -337,7 +369,7 @@ function remove_source_elements(id, source_id) {
function notifications_handle_change_element(event) { function notifications_handle_change_element(event) {
event.preventDefault(); event.preventDefault();
var match = /nt-([0-9]+)-(.*)/.exec(event.target.id); var match = /nt-(.+)-(.*)/.exec(event.target.id);
if (!match) { if (!match) {
console.error( console.error(
"Cannot handle change element. Id not valid: ", event.target.id "Cannot handle change element. Id not valid: ", event.target.id
@ -356,6 +388,7 @@ function notifications_handle_change_element(event) {
var value; var value;
switch (action.bit) { switch (action.bit) {
case 'enabled': case 'enabled':
case 'subtype':
case 'also_mail': case 'also_mail':
case 'user_editable': case 'user_editable':
case 'all_users': case 'all_users':
@ -383,6 +416,7 @@ function notifications_handle_change_element(event) {
} else { } else {
switch (action.bit) { switch (action.bit) {
case 'enabled': case 'enabled':
case 'subtype':
case 'also_mail': case 'also_mail':
case 'user_editable': case 'user_editable':
case 'all_users': case 'all_users':

View File

@ -803,7 +803,7 @@ if (defined('METACONSOLE')) {
} }
if (!$new_user) { if (!$new_user) {
$user_id = '<div class="label_select_simple"><p class="edit_user_labels">'.__('User ID').'</p>'; $user_id = '<div class="label_select_simple"><p class="edit_user_labels">'.__('User ID').': </p>';
$user_id .= '<span>'.$id.'</span>'; $user_id .= '<span>'.$id.'</span>';
$user_id .= html_print_input_hidden('id_user', $id, true); $user_id .= html_print_input_hidden('id_user', $id, true);
$user_id .= '</div>'; $user_id .= '</div>';
@ -1102,7 +1102,8 @@ if (enterprise_installed() && defined('METACONSOLE')) {
$user_info_metaconsole_access = $user_info['metaconsole_access']; $user_info_metaconsole_access = $user_info['metaconsole_access'];
} }
$meta_access = '<div class="label_select"><p class="edit_user_labels">'.__('Metaconsole access').' '.ui_print_help_icon('meta_access', true).'</p>'; // TODO review help tips on meta.
$meta_access = '<div class="label_select"><p class="edit_user_labels">'.__('Metaconsole access').' './* ui_print_help_icon('meta_access', true). */'</p>';
$metaconsole_accesses = [ $metaconsole_accesses = [
'basic' => __('Basic'), 'basic' => __('Basic'),
'advanced' => __('Advanced'), 'advanced' => __('Advanced'),
@ -1175,7 +1176,11 @@ if ($config['double_auth_enabled'] && check_acl($config['id_user'], 0, 'PM')) {
|| ($config['double_auth_enabled'] == '' && $double_auth_enabled) || ($config['double_auth_enabled'] == '' && $double_auth_enabled)
|| check_acl($config['id_user'], 0, 'PM') || check_acl($config['id_user'], 0, 'PM')
) { ) {
$double_authentication .= html_print_checkbox_switch('double_auth', 1, $double_auth_enabled, true); if ($new_user === false) {
$double_authentication .= html_print_checkbox_switch('double_auth', 1, $double_auth_enabled, true);
} else {
$double_authentication .= ui_print_help_tip(__('User must be created before activating double authentication.'), true);
}
} }
// Dialog. // Dialog.
@ -1581,6 +1586,7 @@ console.log(userID);
data: { data: {
page: 'include/ajax/double_auth.ajax', page: 'include/ajax/double_auth.ajax',
id_user: userID, id_user: userID,
id_user_auth: userID,
get_double_auth_data_page: 1, get_double_auth_data_page: 1,
FA_forced: 1, FA_forced: 1,
containerID: $dialogContainer.prop('id') containerID: $dialogContainer.prop('id')
@ -1637,6 +1643,8 @@ function show_double_auth_activation () {
var $loadingSpinner = $("<img src=\"<?php echo $config['homeurl']; ?>/images/spinner.gif\" />"); var $loadingSpinner = $("<img src=\"<?php echo $config['homeurl']; ?>/images/spinner.gif\" />");
var $dialogContainer = $("div#dialog-double_auth-container"); var $dialogContainer = $("div#dialog-double_auth-container");
// Uncheck until completed successfully.
$("input#checkbox-double_auth").prop( "checked", false );
$dialogContainer.html($loadingSpinner); $dialogContainer.html($loadingSpinner);
@ -1648,6 +1656,7 @@ function show_double_auth_activation () {
data: { data: {
page: 'include/ajax/double_auth.ajax', page: 'include/ajax/double_auth.ajax',
id_user: userID, id_user: userID,
id_user_auth: userID,
FA_forced: 1, FA_forced: 1,
get_double_auth_info_page: 1, get_double_auth_info_page: 1,
containerID: $dialogContainer.prop('id') containerID: $dialogContainer.prop('id')
@ -1690,8 +1699,6 @@ function show_double_auth_activation () {
request.abort(); request.abort();
// Remove the contained html // Remove the contained html
$dialogContainer.empty(); $dialogContainer.empty();
document.location.reload();
} }
}) })
.show(); .show();
@ -1705,6 +1712,9 @@ function show_double_auth_deactivation () {
var message = "<p><?php echo __('Are you sure?').'<br>'.__('The double authentication will be deactivated'); ?></p>"; var message = "<p><?php echo __('Are you sure?').'<br>'.__('The double authentication will be deactivated'); ?></p>";
var $button = $("<input type=\"button\" value=\"<?php echo __('Deactivate'); ?>\" />"); var $button = $("<input type=\"button\" value=\"<?php echo __('Deactivate'); ?>\" />");
// Prevent switch deactivaction until proceess is done
$("input#checkbox-double_auth").prop( "checked", true );
$dialogContainer $dialogContainer
.empty() .empty()
@ -1739,6 +1749,7 @@ function show_double_auth_deactivation () {
} }
else if (data) { else if (data) {
$dialogContainer.html("<?php echo '<b><div class=\"green\">'.__('The double autentication was deactivated successfully').'</div></b>'; ?>"); $dialogContainer.html("<?php echo '<b><div class=\"green\">'.__('The double autentication was deactivated successfully').'</div></b>'; ?>");
$("input#checkbox-double_auth").prop( "checked", false );
} }
else { else {
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('There was an error deactivating the double autentication').'</div></b>'; ?>"); $dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('There was an error deactivating the double autentication').'</div></b>'; ?>");
@ -1769,7 +1780,6 @@ function show_double_auth_deactivation () {
// Remove the contained html // Remove the contained html
$dialogContainer.empty(); $dialogContainer.empty();
document.location.reload();
} }
}) })
.show(); .show();

View File

@ -138,6 +138,16 @@ class DiscoveryTaskList extends HTML
return $this->deleteTask(); return $this->deleteTask();
} }
$disable = (bool) get_parameter('disabled', false);
if ($disable === true) {
return $this->disableTask();
}
$enable = (bool) get_parameter('enabled', false);
if ($enable === true) {
return $this->enableTask();
}
if (enterprise_installed()) { if (enterprise_installed()) {
// This check only applies to enterprise users. // This check only applies to enterprise users.
enterprise_hook('tasklist_checkrunning'); enterprise_hook('tasklist_checkrunning');
@ -351,6 +361,93 @@ class DiscoveryTaskList extends HTML
} }
/**
* Disable a recon task.
*
* @return void
*/
public function disableTask()
{
global $config;
if (! check_acl($config['id_user'], 0, 'AW')) {
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_update(
'trecon_task',
['disabled' => 1],
['id_rt' => $task]
);
if ($result == 1) {
return [
'result' => 0,
'msg' => __('Task successfully disabled'),
'id' => false,
];
}
// Trick to avoid double execution.
header('Location: '.$this->url);
}
}
/**
* Enable a recon task.
*
* @return void
*/
public function enableTask()
{
global $config;
if (! check_acl($config['id_user'], 0, 'AW')) {
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_update(
'trecon_task',
[
'disabled' => 0,
'status' => 0,
],
['id_rt' => $task]
);
if ($result == 1) {
return [
'result' => 0,
'msg' => __('Task successfully enabled'),
'id' => false,
];
}
// Trick to avoid double execution.
header('Location: '.$this->url);
}
}
/** /**
* Show complete list of running tasks. * Show complete list of running tasks.
* *
@ -379,7 +476,22 @@ class DiscoveryTaskList extends HTML
include_once $config['homedir'].'/include/functions_servers.php'; include_once $config['homedir'].'/include/functions_servers.php';
include_once $config['homedir'].'/include/functions_network_profiles.php'; include_once $config['homedir'].'/include/functions_network_profiles.php';
$recon_tasks = db_get_all_rows_sql('SELECT * FROM trecon_task'); if (users_is_admin()) {
$recon_tasks = db_get_all_rows_sql('SELECT * FROM trecon_task');
} else {
$user_groups = implode(
',',
array_keys(users_get_groups())
);
$recon_tasks = db_get_all_rows_sql(
sprintf(
'SELECT * FROM trecon_task
WHERE id_group IN (%s)',
$user_groups
)
);
}
// Show network tasks for Recon Server. // Show network tasks for Recon Server.
if ($recon_tasks === false) { if ($recon_tasks === false) {
$recon_tasks = []; $recon_tasks = [];
@ -494,7 +606,7 @@ class DiscoveryTaskList extends HTML
if (check_acl($config['id_user'], 0, 'AW')) { if (check_acl($config['id_user'], 0, 'AW')) {
$data[0] = '<span class="link" onclick="force_task(\''; $data[0] = '<span class="link" onclick="force_task(\'';
$data[0] .= ui_get_full_url( $data[0] .= ui_get_full_url(
'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist&server_id='.$id_server.'&force='.$task['id_rt'] 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist&server_id='.$task['id_recon_server'].'&force='.$task['id_rt']
); );
$data[0] .= '\''; $data[0] .= '\'';
if ($task['type'] == DISCOVERY_HOSTDEVICES) { if ($task['type'] == DISCOVERY_HOSTDEVICES) {
@ -522,7 +634,12 @@ class DiscoveryTaskList extends HTML
$data[1] .= '<span class="link" onclick="progress_task_list('.$task['id_rt'].',\''.$task['name'].'\')">'; $data[1] .= '<span class="link" onclick="progress_task_list('.$task['id_rt'].',\''.$task['name'].'\')">';
} }
$data[1] .= '<b>'.$task['name'].'</b>'; if ($task['disabled'] == 1) {
$data[1] .= '<b><em>'.$task['name'].'</em></b>';
} else {
$data[1] .= '<b>'.$task['name'].'</b>';
}
if ($task['disabled'] != 2) { if ($task['disabled'] != 2) {
$data[1] .= '</span>'; $data[1] .= '</span>';
} }
@ -809,6 +926,24 @@ class DiscoveryTaskList extends HTML
['title' => __('Delete task')] ['title' => __('Delete task')]
).'</a>'; ).'</a>';
} }
if ($task['disabled'] == 1) {
$data[9] .= '<a href="'.ui_get_full_url(
'index.php?sec=gservers&sec2=godmode/servers/discovery&enabled=1&wiz=tasklist&task='.$task['id_rt']
).'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image(
'images/lightbulb_off.png',
true,
['title' => __('enable task')]
).'</a>';
} else if ($task['disabled'] == 0) {
$data[9] .= '<a href="'.ui_get_full_url(
'index.php?sec=gservers&sec2=godmode/servers/discovery&disabled=1&wiz=tasklist&task='.$task['id_rt']
).'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image(
'images/lightbulb.png',
true,
['title' => __('Disable task')]
).'</a>';
}
} else { } else {
$data[9] = ''; $data[9] = '';
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

View File

@ -54,6 +54,16 @@ if (check_login()) {
$update_filter_cf = (bool) get_parameter('update_filter_cf', 0); $update_filter_cf = (bool) get_parameter('update_filter_cf', 0);
$delete_filter_cf = (bool) get_parameter('delete_filter_cf', 0); $delete_filter_cf = (bool) get_parameter('delete_filter_cf', 0);
$change_name_filter = (bool) get_parameter('change_name_filter', 0); $change_name_filter = (bool) get_parameter('change_name_filter', 0);
$check_csv_button = (bool) get_parameter('check_csv_button', 0);
if ($check_csv_button) {
if (check_acl($config['id_user'], 0, 'PM')) {
echo json_encode($permission);
return;
} else {
exit;
}
}
if ($get_custom_fields_data) { if ($get_custom_fields_data) {
$name_custom_fields = get_parameter('name_custom_fields', 0); $name_custom_fields = get_parameter('name_custom_fields', 0);

View File

@ -18,6 +18,8 @@ check_login();
// Security check // Security check
$id_user = (string) get_parameter('id_user'); $id_user = (string) get_parameter('id_user');
$FA_forced = (int) get_parameter('FA_forced'); $FA_forced = (int) get_parameter('FA_forced');
$id_user_auth = (string) get_parameter('id_user_auth', $config['id_user']);
if ($id_user !== $config['id_user'] && $FA_forced != 1) { if ($id_user !== $config['id_user'] && $FA_forced != 1) {
db_pandora_audit( db_pandora_audit(
@ -70,12 +72,12 @@ if ($validate_double_auth_code) {
if ($result && $save) { if ($result && $save) {
// Delete the actual value (if exists) // Delete the actual value (if exists)
$where = ['id_user' => $id_user]; $where = ['id_user' => $id_user_auth];
db_process_sql_delete('tuser_double_auth', $where); db_process_sql_delete('tuser_double_auth', $where);
// Insert the new value // Insert the new value
$values = [ $values = [
'id_user' => $id_user, 'id_user' => $id_user_auth,
'secret' => $secret, 'secret' => $secret,
]; ];
$result = (bool) db_process_sql_insert('tuser_double_auth', $values); $result = (bool) db_process_sql_insert('tuser_double_auth', $values);
@ -152,12 +154,15 @@ if ($get_double_auth_data_page) {
ob_clean(); ob_clean();
?> ?>
<script type="text/javascript" src="../../include/javascript/qrcode.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var secret = "<?php echo $secret; ?>"; var secret = "<?php echo $secret; ?>";
var userID = "<?php echo $config['id_user']; ?>"; var id_user_auth = "<?php echo $id_user_auth; ?>";
// QR code with the secret to add it to the app // QR code with the secret to add it to the app
paint_qrcode("otpauth://totp/"+userID+"?secret="+secret, $("div#qr-container").get(0), 200, 200); paint_qrcode("otpauth://totp/"+id_user_auth+"?secret="+secret, $("div#qr-container").get(0), 200, 200);
$("div#qr-container").attr("title", "").find("canvas").remove(); $("div#qr-container").attr("title", "").find("canvas").remove();
// Don't delete this timeout. It's necessary to perform the style change. // Don't delete this timeout. It's necessary to perform the style change.
@ -219,6 +224,7 @@ if ($get_double_auth_info_page) {
} }
var containerID = "<?php echo $container_id; ?>"; var containerID = "<?php echo $container_id; ?>";
var id_user_auth = "<?php echo $id_user_auth; ?>";
$("#"+containerID).html("<img src=\"<?php echo $config['homeurl']; ?>/images/spinner.gif\" />"); $("#"+containerID).html("<img src=\"<?php echo $config['homeurl']; ?>/images/spinner.gif\" />");
@ -229,6 +235,7 @@ if ($get_double_auth_info_page) {
data: { data: {
page: 'include/ajax/double_auth.ajax', page: 'include/ajax/double_auth.ajax',
id_user: "<?php echo $config['id_user']; ?>", id_user: "<?php echo $config['id_user']; ?>",
id_user_auth: id_user_auth,
get_double_auth_generation_page: 1, get_double_auth_generation_page: 1,
containerID: containerID containerID: containerID
}, },
@ -298,10 +305,10 @@ if ($get_double_auth_generation_page) {
<script type="text/javascript" src="../../include/javascript/qrcode.js"></script> <script type="text/javascript" src="../../include/javascript/qrcode.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var secret = "<?php echo $secret; ?>"; var secret = "<?php echo $secret; ?>";
var userID = "<?php echo $config['id_user']; ?>"; var id_user_auth = "<?php echo $id_user_auth; ?>";
// QR code with the secret to add it to the app // QR code with the secret to add it to the app
paint_qrcode("otpauth://totp/"+userID+"?secret="+secret, $("div#qr-container").get(0), 200, 200); paint_qrcode("otpauth://totp/"+id_user_auth+"?secret="+secret, $("div#qr-container").get(0), 200, 200);
$("div#qr-container").attr("title", "").find("canvas").remove(); $("div#qr-container").attr("title", "").find("canvas").remove();
// Don't delete this timeout. It's necessary to perform the style change. // Don't delete this timeout. It's necessary to perform the style change.
@ -325,7 +332,8 @@ if ($get_double_auth_generation_page) {
dataType: 'html', dataType: 'html',
data: { data: {
page: 'include/ajax/double_auth.ajax', page: 'include/ajax/double_auth.ajax',
id_user: userID, id_user: "<?php echo $config['id_user']; ?>",
id_user_auth, id_user_auth,
get_double_auth_generation_page: 1, get_double_auth_generation_page: 1,
containerID: containerID containerID: containerID
}, },
@ -370,6 +378,7 @@ if ($get_double_auth_generation_page) {
data: { data: {
page: 'include/ajax/double_auth.ajax', page: 'include/ajax/double_auth.ajax',
id_user: "<?php echo $config['id_user']; ?>", id_user: "<?php echo $config['id_user']; ?>",
id_user_auth: id_user_auth,
get_double_auth_validation_page: 1, get_double_auth_validation_page: 1,
secret: secret, secret: secret,
containerID: containerID containerID: containerID
@ -464,6 +473,7 @@ if ($get_double_auth_validation_page) {
data: { data: {
page: 'include/ajax/double_auth.ajax', page: 'include/ajax/double_auth.ajax',
id_user: "<?php echo $config['id_user']; ?>", id_user: "<?php echo $config['id_user']; ?>",
id_user_auth: id_user_auth,
validate_double_auth_code: 1, validate_double_auth_code: 1,
save: 1, save: 1,
secret: secret, secret: secret,
@ -479,6 +489,7 @@ if ($get_double_auth_validation_page) {
// Valid code // Valid code
if (data === true) { if (data === true) {
$("#"+containerID).html("<b><?php echo '<b><div class=\"green\">'.__('The code is valid, you can exit now').'</div></b>'; ?></b>"); $("#"+containerID).html("<b><?php echo '<b><div class=\"green\">'.__('The code is valid, you can exit now').'</div></b>'; ?></b>");
$("input#checkbox-double_auth").prop( "checked", true );
} }
// Invalid code // Invalid code
else if (data === false) { else if (data === false) {

View File

@ -55,9 +55,15 @@ if ($save_custom_graph) {
if ($print_custom_graph) { if ($print_custom_graph) {
ob_clean(); ob_clean();
$width_value = (int) get_parameter('width', CHART_DEFAULT_WIDTH);
if ($width_value === -1) {
$width_value = '';
}
$params = [ $params = [
'period' => (int) get_parameter('period', SECONDS_5MINUTES), 'period' => (int) get_parameter('period', SECONDS_5MINUTES),
'width' => (int) get_parameter('width', CHART_DEFAULT_WIDTH), 'width' => $width_value,
'height' => (int) get_parameter('height', CHART_DEFAULT_HEIGHT), 'height' => (int) get_parameter('height', CHART_DEFAULT_HEIGHT),
'unit_name' => get_parameter('unit_list', []), 'unit_name' => get_parameter('unit_list', []),
'date' => (int) get_parameter('date', time()), 'date' => (int) get_parameter('date', time()),
@ -253,7 +259,12 @@ if ($get_graphs) {
case 'dynamic_graph': case 'dynamic_graph':
if ($value['agent'] != '') { if ($value['agent'] != '') {
$alias = " AND alias REGEXP '".$value['agent']."'"; if (@preg_match($value['agent'], '') !== false) {
$alias = " AND alias REGEXP '".$value['agent']."'";
} else {
// Not a valid REGEXP.
$alias = " AND alias LIKE '".$value['agent']."'";
}
} }
if ($value['id_group'] === '0') { if ($value['id_group'] === '0') {
@ -277,7 +288,11 @@ if ($get_graphs) {
} }
if ($value['module'] != '') { if ($value['module'] != '') {
$module_name = " AND nombre REGEXP '".$value['module']."'"; if (@preg_match($value['module'], '') !== false) {
$module_name = " AND nombre REGEXP '".$value['module']."'";
} else {
$module_name = " AND nombre LIKE '".$value['module']."'";
}
} }
$id_agent_module = db_get_all_rows_sql( $id_agent_module = db_get_all_rows_sql(

View File

@ -38,23 +38,36 @@ if (check_login()) {
$get_plugin_macros = get_parameter('get_plugin_macros'); $get_plugin_macros = get_parameter('get_plugin_macros');
$search_modules = get_parameter('search_modules'); $search_modules = get_parameter('search_modules');
$get_module_detail = get_parameter('get_module_detail', 0); $get_module_detail = get_parameter('get_module_detail', 0);
$get_module_autocomplete_input = (bool) get_parameter('get_module_autocomplete_input'); $get_module_autocomplete_input = (bool) get_parameter(
'get_module_autocomplete_input'
);
$add_module_relation = (bool) get_parameter('add_module_relation'); $add_module_relation = (bool) get_parameter('add_module_relation');
$remove_module_relation = (bool) get_parameter('remove_module_relation'); $remove_module_relation = (bool) get_parameter('remove_module_relation');
$change_module_relation_updates = (bool) get_parameter('change_module_relation_updates'); $change_module_relation_updates = (bool) get_parameter(
'change_module_relation_updates'
);
$get_id_tag = (bool) get_parameter('get_id_tag', 0); $get_id_tag = (bool) get_parameter('get_id_tag', 0);
$get_type = (bool) get_parameter('get_type', 0); $get_type = (bool) get_parameter('get_type', 0);
$list_modules = (bool) get_parameter('list_modules', 0); $list_modules = (bool) get_parameter('list_modules', 0);
$get_agent_modules_json_by_name = (bool) get_parameter('get_agent_modules_json_by_name', 0); $get_agent_modules_json_by_name = (bool) get_parameter(
'get_agent_modules_json_by_name',
0
);
$get_graph_module = (bool) get_parameter('get_graph_module', 0);
$get_graph_module_interfaces = (bool) get_parameter(
'get_graph_module_interfaces',
0
);
if ($get_agent_modules_json_by_name) { if ($get_agent_modules_json_by_name === true) {
$agent_name = get_parameter('agent_name'); $agent_name = get_parameter('agent_name');
$agent_id = agents_get_agent_id($agent_name); $agent_id = agents_get_agent_id($agent_name);
$agent_modules = db_get_all_rows_sql( $agent_modules = db_get_all_rows_sql(
'SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo 'SELECT id_agente_modulo as id_module,
WHERE id_agente = '.$agent_id nombre as name FROM tagente_modulo
WHERE id_agente = '.$agent_id
); );
echo json_encode($agent_modules); echo json_encode($agent_modules);
@ -91,7 +104,10 @@ if (check_login()) {
$id_agents = json_decode(io_safe_output(get_parameter('id_agents'))); $id_agents = json_decode(io_safe_output(get_parameter('id_agents')));
$filter = '%'.get_parameter('q', '').'%'; $filter = '%'.get_parameter('q', '').'%';
$other_filter = json_decode(io_safe_output(get_parameter('other_filter')), true); $other_filter = json_decode(
io_safe_output(get_parameter('other_filter')),
true
);
// TODO TAGS agents_get_modules. // TODO TAGS agents_get_modules.
$modules = agents_get_modules( $modules = agents_get_modules(
$id_agents, $id_agents,
@ -112,9 +128,13 @@ if (check_login()) {
} }
if ($get_module_detail) { if ($get_module_detail) {
// This script is included manually to be included after jquery and avoid error. // This script is included manually to be
// included after jquery and avoid error.
ui_include_time_picker(); ui_include_time_picker();
ui_require_jquery_file('ui.datepicker-'.get_user_language(), 'include/javascript/i18n/'); ui_require_jquery_file(
'ui.datepicker-'.get_user_language(),
'include/javascript/i18n/'
);
$module_id = (int) get_parameter('id_module'); $module_id = (int) get_parameter('id_module');
$period = get_parameter('period', SECONDS_1DAY); $period = get_parameter('period', SECONDS_1DAY);
@ -145,10 +165,22 @@ if (check_login()) {
$free_checkbox = (bool) get_parameter('free_checkbox', false); $free_checkbox = (bool) get_parameter('free_checkbox', false);
$selection_mode = get_parameter('selection_mode', 'fromnow'); $selection_mode = get_parameter('selection_mode', 'fromnow');
$utimestamp = get_system_time(); $utimestamp = get_system_time();
$date_from = (string) get_parameter('date_from', date(DATE_FORMAT, ($utimestamp - SECONDS_1DAY))); $date_from = (string) get_parameter(
$time_from = (string) get_parameter('time_from', date(TIME_FORMAT, ($utimestamp - SECONDS_1DAY))); 'date_from',
$date_to = (string) get_parameter('date_to', date(DATE_FORMAT, $utimestamp)); date(DATE_FORMAT, ($utimestamp - SECONDS_1DAY))
$time_to = (string) get_parameter('time_to', date(TIME_FORMAT, $utimestamp)); );
$time_from = (string) get_parameter(
'time_from',
date(TIME_FORMAT, ($utimestamp - SECONDS_1DAY))
);
$date_to = (string) get_parameter(
'date_to',
date(DATE_FORMAT, $utimestamp)
);
$time_to = (string) get_parameter(
'time_to',
date(TIME_FORMAT, $utimestamp)
);
// Definition of new table. // Definition of new table.
$formtable = new stdClass(); $formtable = new stdClass();
@ -189,7 +221,17 @@ if (check_login()) {
'style="margin-right: 15px;"', 'style="margin-right: 15px;"',
true true
).__('Choose a time from now'); ).__('Choose a time from now');
$formtable->data[0][1] = html_print_select($periods, 'period', $period, '', '', 0, true, false, false); $formtable->data[0][1] = html_print_select(
$periods,
'period',
$period,
'',
'',
0,
true,
false,
false
);
$formtable->data[0][2] = ''; $formtable->data[0][2] = '';
$formtable->data[0][3] = "<a href='javascript: show_module_detail_dialog(".$module_id.', '.$agentId.', "'.$server_name.'", 0, -1,"'.modules_get_agentmodule_name($module_id)."\")'>".html_print_image('images/refresh.png', true, ['style' => 'vertical-align: middle;', 'border' => '0' ]).'</a>'; $formtable->data[0][3] = "<a href='javascript: show_module_detail_dialog(".$module_id.', '.$agentId.', "'.$server_name.'", 0, -1,"'.modules_get_agentmodule_name($module_id)."\")'>".html_print_image('images/refresh.png', true, ['style' => 'vertical-align: middle;', 'border' => '0' ]).'</a>';
$formtable->rowspan[0][3] = 2; $formtable->rowspan[0][3] = 2;
@ -248,8 +290,20 @@ if (check_login()) {
$freesearch_object = ''; $freesearch_object = '';
if (preg_match('/_string/', $moduletype_name)) { if (preg_match('/_string/', $moduletype_name)) {
$formtable->data[2][0] = __('Free search').' '; $formtable->data[2][0] = __('Free search').' ';
$formtable->data[2][1] = html_print_input_text('freesearch', $freesearch, '', 20, null, true); $formtable->data[2][1] = html_print_input_text(
$formtable->data[2][2] = html_print_checkbox('free_checkbox', 1, $free_checkbox, true); 'freesearch',
$freesearch,
'',
20,
null,
true
);
$formtable->data[2][2] = html_print_checkbox(
'free_checkbox',
1,
$free_checkbox,
true
);
$formtable->data[2][2] .= ' '.__('Exact phrase'); $formtable->data[2][2] .= ' '.__('Exact phrase');
$freesearch_object = json_encode( $freesearch_object = json_encode(
[ [
@ -340,6 +394,12 @@ if (check_login()) {
$index = 0; $index = 0;
foreach ($columns as $col => $attr) { foreach ($columns as $col => $attr) {
$table->head[$index] = $col; $table->head[$index] = $col;
if ($col === 'Data') {
$table->head[$index] .= ui_print_help_tip(
__('In Pandora FMS, data is stored compressed. The data visualization in database, charts or CSV exported data won\'t match, because is interpreted at runtime. Please check \'Pandora FMS Engineering\' chapter from documentation.'),
true
);
}
if (isset($attr['align'])) { if (isset($attr['align'])) {
$table->align[$index] = $attr['align']; $table->align[$index] = $attr['align'];
@ -359,8 +419,16 @@ if (check_login()) {
'web_content_string' 'web_content_string'
); );
$post_process = db_get_value_filter('post_process', 'tagente_modulo', ['id_agente_modulo' => $module_id]); $post_process = db_get_value_filter(
$unit = db_get_value_filter('unit', 'tagente_modulo', ['id_agente_modulo' => $module_id]); 'post_process',
'tagente_modulo',
['id_agente_modulo' => $module_id]
);
$unit = db_get_value_filter(
'unit',
'tagente_modulo',
['id_agente_modulo' => $module_id]
);
foreach ($result as $row) { foreach ($result as $row) {
$data = []; $data = [];
@ -400,32 +468,65 @@ if (check_login()) {
// Fixed the data from Selenium Plugin. // Fixed the data from Selenium Plugin.
if ($row[$attr[0]] != strip_tags($row[$attr[0]])) { if ($row[$attr[0]] != strip_tags($row[$attr[0]])) {
$data[] = html_print_result_div($row[$attr[0]]); $data[] = html_print_result_div($row[$attr[0]]);
} else if (is_numeric($row[$attr[0]]) && !modules_is_string_type($row['module_type'])) { } else if (is_numeric($row[$attr[0]])
&& !modules_is_string_type($row['module_type'])
) {
switch ($row['module_type']) { switch ($row['module_type']) {
case 15: case 15:
$value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module_id); $value = db_get_value(
'snmp_oid',
'tagente_modulo',
'id_agente_modulo',
$module_id
);
// System Uptime: // System Uptime:
// In case of System Uptime module, shows data in format "Days hours minutes seconds" if and only if // In case of System Uptime module,
// shows data in format
// "Days hours minutes seconds" if and only if
// selected module unit is "_timeticks_" // selected module unit is "_timeticks_"
// Take notice that selected unit may not be postrocess unit // Take notice that selected unit
if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') { // may not be postrocess unit.
$data_macro = modules_get_unit_macro($row[$attr[0]], $unit); if ($value == '.1.3.6.1.2.1.1.3.0'
|| $value == '.1.3.6.1.2.1.25.1.1.0'
) {
$data_macro = modules_get_unit_macro(
$row[$attr[0]],
$unit
);
if ($data_macro) { if ($data_macro) {
$data[] = $data_macro; $data[] = $data_macro;
} else { } else {
$data[] = remove_right_zeros(number_format($row[$attr[0]], $config['graph_precision'])); $data[] = remove_right_zeros(
number_format(
$row[$attr[0]],
$config['graph_precision']
)
);
} }
} else { } else {
$data[] = remove_right_zeros(number_format($row[$attr[0]], $config['graph_precision'])); $data[] = remove_right_zeros(
number_format(
$row[$attr[0]],
$config['graph_precision']
)
);
} }
break; break;
default: default:
$data_macro = modules_get_unit_macro($row[$attr[0]], $unit); $data_macro = modules_get_unit_macro(
$row[$attr[0]],
$unit
);
if ($data_macro) { if ($data_macro) {
$data[] = $data_macro; $data[] = $data_macro;
} else { } else {
$data[] = remove_right_zeros(number_format($row[$attr[0]], $config['graph_precision'])); $data[] = remove_right_zeros(
number_format(
$row[$attr[0]],
$config['graph_precision']
)
);
} }
break; break;
} }
@ -433,11 +534,16 @@ if (check_login()) {
if ($row[$attr[0]] == '') { if ($row[$attr[0]] == '') {
$data[] = 'No data'; $data[] = 'No data';
} else { } else {
$data_macro = modules_get_unit_macro($row[$attr[0]], $unit); $data_macro = modules_get_unit_macro(
$row[$attr[0]],
$unit
);
if ($data_macro) { if ($data_macro) {
$data[] = $data_macro; $data[] = $data_macro;
} else { } else {
$data[] = html_print_result_div($row[$attr[0]]); $data[] = html_print_result_div(
$row[$attr[0]]
);
} }
} }
} }
@ -453,7 +559,16 @@ if (check_login()) {
if (empty($table->data)) { if (empty($table->data)) {
ui_print_error_message(__('No available data to show')); ui_print_error_message(__('No available data to show'));
} else { } else {
ui_pagination(count($count), false, $offset, 0, false, 'offset', true, 'binary_dialog'); ui_pagination(
count($count),
false,
$offset,
0,
false,
'offset',
true,
'binary_dialog'
);
html_print_table($table); html_print_table($table);
} }
@ -727,11 +842,17 @@ if (check_login()) {
} }
} }
$status_filter_monitor = (int) get_parameter('status_filter_monitor', -1); $status_filter_monitor = (int) get_parameter(
'status_filter_monitor',
-1
);
$status_text_monitor = get_parameter('status_text_monitor', ''); $status_text_monitor = get_parameter('status_text_monitor', '');
$filter_monitors = (bool) get_parameter('filter_monitors', false); $filter_monitors = (bool) get_parameter('filter_monitors', false);
$status_module_group = get_parameter('status_module_group', -1); $status_module_group = get_parameter('status_module_group', -1);
$monitors_change_filter = (bool) get_parameter('monitors_change_filter', false); $monitors_change_filter = (bool) get_parameter(
'monitors_change_filter',
false
);
$status_filter_sql = '1 = 1'; $status_filter_sql = '1 = 1';
if ($status_filter_monitor == AGENT_MODULE_STATUS_NOT_NORMAL) { if ($status_filter_monitor == AGENT_MODULE_STATUS_NOT_NORMAL) {
@ -787,7 +908,9 @@ if (check_login()) {
AND tagente_estado.estado != $monitor_filter AND tagente_estado.estado != $monitor_filter
"; ";
$count_modules = db_get_all_rows_sql('SELECT COUNT(DISTINCT tagente_modulo.id_agente_modulo)'.$sql_condition); $count_modules = db_get_all_rows_sql(
'SELECT COUNT(DISTINCT tagente_modulo.id_agente_modulo)'.$sql_condition
);
if (isset($count_modules[0])) { if (isset($count_modules[0])) {
$count_modules = reset($count_modules[0]); $count_modules = reset($count_modules[0]);
@ -796,7 +919,7 @@ if (check_login()) {
} }
// Get monitors/modules // Get monitors/modules
// Get all module from agent // Get all module from agent.
$sql_modules_info = "SELECT tagente_estado.*, tagente_modulo.*, tmodule_group.* $sql_modules_info = "SELECT tagente_estado.*, tagente_modulo.*, tmodule_group.*
$sql_condition $sql_condition
GROUP BY tagente_modulo.id_agente_modulo ORDER BY $order_sql"; GROUP BY tagente_modulo.id_agente_modulo ORDER BY $order_sql";
@ -1195,4 +1318,55 @@ if (check_login()) {
echo $graph_type; echo $graph_type;
return; return;
} }
if ($get_graph_module === true) {
global $config;
$output = '';
$graph_data = get_parameter('graph_data', '');
$params = json_decode(base64_decode($graph_data), true);
$server_id = (int) get_parameter('server_id', 0);
include_once $config['homedir'].'/include/functions_graph.php';
// Metaconsole connection to the node.
if (is_metaconsole() === true && empty($server_id) === false) {
$server = metaconsole_get_connection_by_id($server_id);
metaconsole_connect($server);
}
$output .= grafico_modulo_sparse($params);
echo $output;
if (is_metaconsole() === true && empty($server_id) === false) {
metaconsole_restore_db();
}
return;
}
if ($get_graph_module_interfaces === true) {
global $config;
include_once $config['homedir'].'/include/functions_graph.php';
$output = '';
$graph_data = get_parameter('graph_data', '');
$params = json_decode(base64_decode($graph_data), true);
$modules = get_parameter('modules', '');
$modules = json_decode(base64_decode($modules), true);
$graph_data_combined = get_parameter('graph_data_combined', '');
$params_combined = json_decode(
base64_decode($graph_data_combined),
true
);
$output .= graphic_combined_module(
$modules,
$params,
$params_combined
);
echo $output;
return;
}
} }

View File

@ -178,14 +178,19 @@ if (file_exists('languages/'.$user_language.'.mo') === true) {
$params_combined = json_decode($data_combined, true); $params_combined = json_decode($data_combined, true);
$module_list = json_decode($data_module_list, true); $module_list = json_decode($data_module_list, true);
$type_graph_pdf = $type_graph_pdf;
if (isset($params['vconsole']) === false || $params['vconsole'] === false) { if (isset($params['vconsole']) === false || $params['vconsole'] === false) {
$params['width'] = (int) $viewport_width; if ((int) $viewport_width > 0) {
$params['width'] = (int) $viewport_width;
}
if ((isset($params['width']) === false if ((isset($params['width']) === false
|| ($params['width'] <= 0)) || ($params['width'] <= 0))
) { ) {
$params['width'] = 650; if ((int) $params['width'] <= 0) {
$params['width'] = 650;
}
if ((int) $params['landscape'] === 1) { if ((int) $params['landscape'] === 1) {
$params['width'] = 850; $params['width'] = 850;
} }

View File

@ -346,8 +346,8 @@ class AgentWizard extends HTML
// Capture the parameters. // Capture the parameters.
$this->protocol = get_parameter('protocol'); $this->protocol = get_parameter('protocol');
$this->targetPort = get_parameter('targetPort', '161');
if ($this->protocol === 'snmp') { if ($this->protocol === 'snmp') {
$this->targetPort = get_parameter('targetPort', '161');
$this->community = get_parameter('community', 'public'); $this->community = get_parameter('community', 'public');
$this->version = get_parameter('version', '1'); $this->version = get_parameter('version', '1');

View File

@ -45,6 +45,11 @@ enterprise_include_once('include/functions_cron.php');
class ConsoleSupervisor class ConsoleSupervisor
{ {
/**
* Minimum modules to check performance.
*/
public const MIN_PERFORMANCE_MODULES = 100;
/** /**
* Show if console supervisor is enabled or not. * Show if console supervisor is enabled or not.
* *
@ -115,12 +120,6 @@ class ConsoleSupervisor
} else { } else {
$this->enabled = (bool) $source['enabled']; $this->enabled = (bool) $source['enabled'];
$this->sourceId = $source['id']; $this->sourceId = $source['id'];
// Assign targets.
$targets = get_notification_source_targets($this->sourceId);
$this->targetGroups = $targets['groups'];
$this->targetUsers = $targets['users'];
$this->targetUpdated = true;
} }
return $this; return $this;
@ -620,20 +619,28 @@ class ConsoleSupervisor
return; return;
} }
if ($this->targetUpdated === false) {
$targets = get_notification_source_targets($this->sourceId);
$this->targetGroups = $targets['groups'];
$this->targetUsers = $targets['users'];
$this->targetUpdated = false;
}
if ($source_id === 0) { if ($source_id === 0) {
$source_id = $this->sourceId; $source_id = $this->sourceId;
// Assign targets. }
$targets = get_notification_source_targets($source_id);
static $_cache_targets;
$key = $source_id.'|'.$data['type'];
if ($_cache_targets === null) {
$_cache_targets = [];
}
if ($_cache_targets[$key] !== null) {
$targets = $_cache_targets[$key];
} else {
$targets = get_notification_source_targets(
$source_id,
$data['type']
);
$this->targetGroups = $targets['groups']; $this->targetGroups = $targets['groups'];
$this->targetUsers = $targets['users']; $this->targetUsers = $targets['users'];
$this->targetUpdated = false;
$_cache_targets[$key] = $targets;
} }
switch ($data['type']) { switch ($data['type']) {
@ -1141,6 +1148,12 @@ class ConsoleSupervisor
$max_grown = ($total_modules[$queue['server_type']] * 0.40); $max_grown = ($total_modules[$queue['server_type']] * 0.40);
} }
if ($total_modules[$queue['server_type']] < self::MIN_PERFORMANCE_MODULES) {
$this->cleanNotifications('NOTIF.SERVER.QUEUE.'.$key);
// Skip.
continue;
}
// Compare queue increments in a not over 900 seconds. // Compare queue increments in a not over 900 seconds.
if (empty($previous[$key]['modules']) if (empty($previous[$key]['modules'])
|| ($time - $previous[$key]['utime']) > 900 || ($time - $previous[$key]['utime']) > 900

View File

@ -342,6 +342,8 @@ class TreeService extends Tree
*/ */
protected function getSecondLevel() protected function getSecondLevel()
{ {
global $config;
$service = new Service($this->id, true); $service = new Service($this->id, true);
$output = []; $output = [];
@ -422,7 +424,13 @@ class TreeService extends Tree
} }
$tmp['children'] = []; $tmp['children'] = [];
$tmp['searchChildren'] = 1;
if (check_acl($config['id_user'], $item->agent()->id_grupo(), 'AR')) {
$tmp['searchChildren'] = 1;
} else {
$tmp['searchChildren'] = 0;
}
$tmp['showEventsBtn'] = 1; $tmp['showEventsBtn'] = 1;
$tmp['eventAgent'] = $item->agent()->id_agente(); $tmp['eventAgent'] = $item->agent()->id_agente();
break; break;
@ -532,7 +540,9 @@ class TreeService extends Tree
); );
} }
$grandchildren = $item->service()->children(); if (check_acl($config['id_user'], $item->service()->id_group(), 'AR')) {
$grandchildren = $item->service()->children();
}
if ($this->connectedToNode === false if ($this->connectedToNode === false
&& is_metaconsole() === true && is_metaconsole() === true

View File

@ -20,7 +20,7 @@
/** /**
* Pandora build version and version * Pandora build version and version
*/ */
$build_version = 'PC210224'; $build_version = 'PC210311';
$pandora_version = 'v7.0NG.752'; $pandora_version = 'v7.0NG.752';
// Do not overwrite default timezone set if defined. // Do not overwrite default timezone set if defined.

View File

@ -424,16 +424,6 @@ function get_user_language($id_user=null)
if ($quick_language) { if ($quick_language) {
$language = get_parameter('language', 0); $language = get_parameter('language', 0);
if (defined('METACONSOLE')) {
if ($id_user == null) {
$id_user = $config['id_user'];
}
if ($language !== 0) {
update_user($id_user, ['language' => $language]);
}
}
if ($language === 'default') { if ($language === 'default') {
return $config['language']; return $config['language'];
} }
@ -1798,7 +1788,7 @@ function is_ajax()
*/ */
function is_error($code) function is_error($code)
{ {
if ($code !== true and ($code <= ERR_GENERIC || $code === false)) { if ($code !== true && ($code <= ERR_GENERIC || $code === false)) {
return true; return true;
} else { } else {
return false; return false;
@ -3920,6 +3910,18 @@ function series_type_graph_array($data, $show_elements_graph)
$name_legend = $show_elements_graph['labels'][$value['agent_module_id']][$label_interfaces[$value['agent_module_id']]].': '; $name_legend = $show_elements_graph['labels'][$value['agent_module_id']][$label_interfaces[$value['agent_module_id']]].': ';
} else if (is_array($show_elements_graph['labels'][$value['agent_module_id']]) === true) { } else if (is_array($show_elements_graph['labels'][$value['agent_module_id']]) === true) {
$name_legend = 'Avg: '; $name_legend = 'Avg: ';
if (array_key_exists('agent_alias', $value)
&& array_key_exists('module_name', $value)
&& array_key_exists('unit', $value)
) {
$name_legend .= $value['agent_alias'];
$name_legend .= ' / ';
$name_legend .= $value['module_name'];
$name_legend .= ' / ';
$name_legend .= __('Unit ').' ';
$name_legend .= $value['unit'].': ';
}
} else { } else {
$name_legend = $show_elements_graph['labels'][$value['agent_module_id']].': '; $name_legend = $show_elements_graph['labels'][$value['agent_module_id']].': ';
} }

View File

@ -21,6 +21,8 @@ require_once $config['homedir'].'/include/functions.php';
require_once $config['homedir'].'/include/functions_modules.php'; require_once $config['homedir'].'/include/functions_modules.php';
require_once $config['homedir'].'/include/functions_users.php'; require_once $config['homedir'].'/include/functions_users.php';
use PandoraFMS\Enterprise\RCMDFile as RCMDFile;
/** /**
* Return the agent if exists in the DB. * Return the agent if exists in the DB.
@ -2410,10 +2412,31 @@ function agents_delete_agent($id_agents, $disableACL=false)
enterprise_include_once('include/functions_policies.php'); enterprise_include_once('include/functions_policies.php');
enterprise_hook('policies_delete_agent', [$id_agent]); enterprise_hook('policies_delete_agent', [$id_agent]);
// Delete agent in networkmap enterprise
if (enterprise_installed()) { if (enterprise_installed()) {
// Delete agent in networkmap.
enterprise_include_once('include/functions_networkmap.php'); enterprise_include_once('include/functions_networkmap.php');
networkmap_delete_nodes_by_agent([$id_agent]); networkmap_delete_nodes_by_agent([$id_agent]);
// Delete command targets with agent.
enterprise_include_once('include/lib/RCMDFile.class.php');
$target_filter = ['id_agent' => $id_agent];
// Retrieve all commands that have targets with specific agent id.
$commands = RCMDFile::getAll(
['rct.rcmd_id'],
$target_filter
);
foreach ($commands as $command) {
$rcmd_id = $command['rcmd_id'];
$rcmd = new RCMDFile($rcmd_id);
$command_targets = [];
$command_targets = $rcmd->getTargets(false, $target_filter);
$rcmd->deleteTargets(array_keys($command_targets));
}
} }
// tagente_datos_inc // tagente_datos_inc
@ -3723,9 +3746,12 @@ function agents_get_agent_id_by_alias_regex($alias_regex, $flag='i', $limit=0)
*/ */
function agents_get_sap_agents($id_agent) function agents_get_sap_agents($id_agent)
{ {
global $config;
// Available modules. // Available modules.
// If you add more modules, please update SAP.pm. // If you add more modules, please update SAP.pm.
$sap_modules = [ $sap_modules = [
0 => 'SAP connection',
160 => __('SAP Login OK'), 160 => __('SAP Login OK'),
109 => __('SAP Dumps'), 109 => __('SAP Dumps'),
111 => __('SAP lock entry list'), 111 => __('SAP lock entry list'),
@ -3735,9 +3761,9 @@ function agents_get_sap_agents($id_agent)
105 => __('SAP IDOC OK'), 105 => __('SAP IDOC OK'),
150 => __('SAP WP without active restart'), 150 => __('SAP WP without active restart'),
151 => __('SAP WP stopped'), 151 => __('SAP WP stopped'),
102 => __('Average time of SAPGUI response '), 102 => __('Average time of SAPGUI response'),
180 => __('Dialog response time'), 180 => __('Dialog response time'),
103 => __('Dialog Logged users '), 103 => __('Dialog Logged users'),
192 => __('TRFC in error'), 192 => __('TRFC in error'),
195 => __('QRFC in error SMQ2'), 195 => __('QRFC in error SMQ2'),
116 => __('Number of Update WPs in error'), 116 => __('Number of Update WPs in error'),
@ -3745,15 +3771,28 @@ function agents_get_sap_agents($id_agent)
$array_agents = []; $array_agents = [];
foreach ($sap_modules as $module => $key) { foreach ($sap_modules as $module => $key) {
$new_ones = db_get_all_rows_sql( $sql = sprintf(
'SELECT ta.id_agente,ta.alias 'SELECT ta.id_agente,ta.alias, ta.id_grupo
FROM tagente ta FROM tagente ta
INNER JOIN tagente_modulo tam INNER JOIN tagente_modulo tam
ON tam.id_agente = ta.id_agente ON tam.id_agente = ta.id_agente
WHERE tam.nombre WHERE tam.nombre
LIKE "%SAP%" LIKE "%s"
GROUP BY ta.id_agente' GROUP BY ta.id_agente',
io_safe_input($key)
); );
// ACL groups.
$agent_groups = array_keys(users_get_groups($config['id_user']));
if (!empty($agent_groups)) {
$sql .= sprintf(
' HAVING ta.id_grupo IN (%s)',
implode(',', $agent_groups)
);
}
$new_ones = db_get_all_rows_sql($sql);
if ($new_ones === false) { if ($new_ones === false) {
continue; continue;
} }
@ -3800,3 +3839,51 @@ function agents_get_last_status_change($id_agent)
return $row['last_status_change']; return $row['last_status_change'];
} }
/**
* Return the list of agents for a planned downtime
*
* @param integer $id_downtime Id of planned downtime.
* @param string $filter_cond String-based filters.
* @param string $id_groups_str String-based list of id group, separated with commas.
*
* @return array
*/
function get_planned_downtime_agents_list($id_downtime, $filter_cond, $id_groups_str)
{
$agents = [];
$sql = sprintf(
'SELECT tagente.id_agente, tagente.alias
FROM tagente
WHERE tagente.id_agente NOT IN (
SELECT tagente.id_agente
FROM tagente, tplanned_downtime_agents
WHERE tplanned_downtime_agents.id_agent = tagente.id_agente
AND tplanned_downtime_agents.id_downtime = %d
) AND disabled = 0 %s
AND tagente.id_grupo IN (%s)
ORDER BY tagente.nombre',
$id_downtime,
$filter_cond,
$id_groups_str
);
$agents = db_get_all_rows_sql($sql);
if (empty($agents)) {
$agents = [];
}
$agent_ids = extract_column($agents, 'id_agente');
$agent_names = extract_column($agents, 'alias');
$agents = array_combine($agent_ids, $agent_names);
if ($agents === false) {
$agents = [];
}
return $agents;
}

File diff suppressed because it is too large Load Diff

View File

@ -1639,12 +1639,12 @@ function config_update_config()
case 'module_library': case 'module_library':
$module_library_user = get_parameter('module_library_user'); $module_library_user = get_parameter('module_library_user');
if ($module_library_user == '' || !config_update_value('module_library_user', $module_library_user)) { if (!config_update_value('module_library_user', $module_library_user)) {
$error_update[] = __('User'); $error_update[] = __('User');
} }
$module_library_password = get_parameter('module_library_password'); $module_library_password = get_parameter('module_library_password');
if ($module_library_password == '' || !config_update_value('module_library_password', $module_library_password)) { if (!config_update_value('module_library_password', $module_library_password)) {
$error_update[] = __('Password'); $error_update[] = __('Password');
} }
break; break;
@ -2224,7 +2224,7 @@ function config_process_config()
} }
if (!isset($config['custom_support_url'])) { if (!isset($config['custom_support_url'])) {
config_update_value('custom_support_url', 'https://support.artica.es'); config_update_value('custom_support_url', 'https://support.pandorafms.com');
} }
if (!isset($config['rb_product_name'])) { if (!isset($config['rb_product_name'])) {
@ -2240,7 +2240,7 @@ function config_process_config()
} }
if (!isset($config['meta_custom_support_url'])) { if (!isset($config['meta_custom_support_url'])) {
config_update_value('meta_custom_support_url', 'https://support.artica.es'); config_update_value('meta_custom_support_url', 'https://support.pandorafms.com');
} }
if (!isset($config['meta_custom_logo'])) { if (!isset($config['meta_custom_logo'])) {

View File

@ -2878,20 +2878,21 @@ function events_get_group_events_steps(
* *
* The returned events will be in the time interval ($date - $period, $date] * The returned events will be in the time interval ($date - $period, $date]
* *
* @param integer $id_agent Agent id to get events. * @param integer $id_agent Agent id to get events.
* @param integer $period Period in seconds to get events. * @param integer $period Period in seconds to get events.
* @param integer $date Beginning date to get events. * @param integer $date Beginning date to get events.
* @param boolean $history History. * @param boolean $history History.
* @param boolean $show_summary_group Show_summary_group. * @param boolean $show_summary_group Show_summary_group.
* @param boolean $filter_event_severity Filter_event_severity. * @param boolean $filter_event_severity Filter_event_severity.
* @param boolean $filter_event_type Filter_event_type. * @param boolean $filter_event_type Filter_event_type.
* @param boolean $filter_event_status Filter_event_status. * @param boolean $filter_event_status Filter_event_status.
* @param boolean $filter_event_filter_search Filter_event_filter_search. * @param boolean $filter_event_filter_search Filter_event_filter_search.
* @param boolean $id_group Id_group. * @param boolean $id_group Id_group.
* @param boolean $events_group Events_group. * @param boolean $events_group Events_group.
* @param boolean $id_agent_module Id_agent_module. * @param boolean $id_agent_module Id_agent_module.
* @param boolean $events_module Events_module. * @param boolean $events_module Events_module.
* @param boolean $id_server Id_server. * @param boolean $id_server Id_server.
* @param boolean $filter_event_filter_exclude Filter_event_filter_exclude.
* *
* @return array An array with all the events happened. * @return array An array with all the events happened.
*/ */
@ -2909,7 +2910,8 @@ function events_get_agent(
$events_group=false, $events_group=false,
$id_agent_module=false, $id_agent_module=false,
$events_module=false, $events_module=false,
$id_server=false $id_server=false,
$filter_event_filter_exclude=false
) { ) {
global $config; global $config;
@ -3017,6 +3019,10 @@ function events_get_agent(
$sql_where .= ' AND (evento LIKE "%'.io_safe_input($filter_event_filter_search).'%" OR id_evento LIKE "%'.io_safe_input($filter_event_filter_search).'%")'; $sql_where .= ' AND (evento LIKE "%'.io_safe_input($filter_event_filter_search).'%" OR id_evento LIKE "%'.io_safe_input($filter_event_filter_search).'%")';
} }
if (!empty($filter_event_filter_exclude)) {
$sql_where .= ' AND (evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%" AND id_evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%")';
}
if ($events_group) { if ($events_group) {
$secondary_groups = sprintf( $secondary_groups = sprintf(
' INNER JOIN tgrupo tg ' INNER JOIN tgrupo tg
@ -4833,19 +4839,22 @@ function events_page_general($event)
$data[0] = __('Acknowledged by'); $data[0] = __('Acknowledged by');
if ($event['estado'] == 1) { if ($event['estado'] == 1) {
$user_ack = db_get_value( if (empty($event['id_usuario']) === true) {
'fullname', $user_ack = __('Autovalidated');
'tusuario', } else {
'id_user', $user_ack = db_get_value(
$event['id_usuario'] 'fullname',
); 'tusuario',
'id_user',
$event['id_usuario']
);
if (empty($user_ack) === true) { if (empty($user_ack) === true) {
$user_ack = $event['id_usuario']; $user_ack = $event['id_usuario'];
}
} }
$date_ack = io_safe_output($event['ack_utimestamp']); $data[1] = $user_ack.'&nbsp;(&nbsp;'.date($config['date_format'], $event['ack_utimestamp_raw']).'&nbsp;)&nbsp;';
$data[1] = $user_ack.' ('.$date_ack.')';
} else { } else {
$data[1] = '<i>'.__('N/A').'</i>'; $data[1] = '<i>'.__('N/A').'</i>';
} }
@ -5114,14 +5123,15 @@ function events_clean_tags($tags)
* *
* The returned events will be in the time interval ($date - $period, $date] * The returned events will be in the time interval ($date - $period, $date]
* *
* @param mixed $id_group Group id to get events for. * @param mixed $id_group Group id to get events for.
* @param integer $period Period in seconds to get events. * @param integer $period Period in seconds to get events.
* @param integer $date Beginning date to get events. * @param integer $date Beginning date to get events.
* @param boolean $filter_event_severity Filter_event_severity. * @param boolean $filter_event_severity Filter_event_severity.
* @param boolean $filter_event_type Filter_event_type. * @param boolean $filter_event_type Filter_event_type.
* @param boolean $filter_event_status Filter_event_status. * @param boolean $filter_event_status Filter_event_status.
* @param boolean $filter_event_filter_search Filter_event_filter_search. * @param boolean $filter_event_filter_search Filter_event_filter_search.
* @param boolean $dbmeta Dbmeta. * @param boolean $dbmeta Dbmeta.
* @param boolean $filter_event_filter_exclude Filter_event_filter_exclude.
* *
* @return array An array with all the events happened. * @return array An array with all the events happened.
*/ */
@ -5133,7 +5143,8 @@ function events_get_count_events_by_agent(
$filter_event_type=false, $filter_event_type=false,
$filter_event_status=false, $filter_event_status=false,
$filter_event_filter_search=false, $filter_event_filter_search=false,
$dbmeta=false $dbmeta=false,
$filter_event_filter_exclude=false
) { ) {
global $config; global $config;
@ -5233,6 +5244,10 @@ function events_get_count_events_by_agent(
$sql_where .= ' AND (evento LIKE "%'.io_safe_input($filter_event_filter_search).'%" OR id_evento LIKE "%'.io_safe_input($filter_event_filter_search).'%")'; $sql_where .= ' AND (evento LIKE "%'.io_safe_input($filter_event_filter_search).'%" OR id_evento LIKE "%'.io_safe_input($filter_event_filter_search).'%")';
} }
if (!empty($filter_event_filter_exclude)) {
$sql_where .= ' AND (evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%" AND id_evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%")';
}
$tagente = 'tagente'; $tagente = 'tagente';
$tevento = 'tevento'; $tevento = 'tevento';
@ -5285,14 +5300,15 @@ function events_get_count_events_by_agent(
* *
* The returned events will be in the time interval ($date - $period, $date] * The returned events will be in the time interval ($date - $period, $date]
* *
* @param array $filter Use target filter. * @param array $filter Use target filter.
* @param integer $period Period in seconds to get events. * @param integer $period Period in seconds to get events.
* @param integer $date Beginning date to get events. * @param integer $date Beginning date to get events.
* @param boolean $filter_event_severity Filter_event_severity. * @param boolean $filter_event_severity Filter_event_severity.
* @param boolean $filter_event_type Filter_event_type. * @param boolean $filter_event_type Filter_event_type.
* @param boolean $filter_event_status Filter_event_status. * @param boolean $filter_event_status Filter_event_status.
* @param boolean $filter_event_filter_search Filter_event_filter_search. * @param boolean $filter_event_filter_search Filter_event_filter_search.
* @param boolean $dbmeta Dbmeta. * @param boolean $dbmeta Dbmeta.
* @param boolean $filter_event_filter_exclude Filter_event_filter_exclude.
* *
* @return array An array with all the events happened. * @return array An array with all the events happened.
*/ */
@ -5304,7 +5320,8 @@ function events_get_count_events_validated_by_user(
$filter_event_type=false, $filter_event_type=false,
$filter_event_status=false, $filter_event_status=false,
$filter_event_filter_search=false, $filter_event_filter_search=false,
$dbmeta=false $dbmeta=false,
$filter_event_filter_exclude=false
) { ) {
global $config; global $config;
$tevento = 'tevento'; $tevento = 'tevento';
@ -5426,6 +5443,10 @@ function events_get_count_events_validated_by_user(
$sql_where .= ' AND (evento LIKE "%'.io_safe_input($filter_event_filter_search).'%" OR id_evento LIKE "%'.io_safe_input($filter_event_filter_search).'%")'; $sql_where .= ' AND (evento LIKE "%'.io_safe_input($filter_event_filter_search).'%" OR id_evento LIKE "%'.io_safe_input($filter_event_filter_search).'%")';
} }
if (!empty($filter_event_filter_exclude)) {
$sql_where .= ' AND (evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%" AND id_evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%")';
}
$sql = sprintf( $sql = sprintf(
'SELECT 'SELECT
te.id_usuario, te.id_usuario,
@ -5474,14 +5495,15 @@ function events_get_count_events_validated_by_user(
* *
* The returned events will be in the time interval ($date - $period, $date] * The returned events will be in the time interval ($date - $period, $date]
* *
* @param mixed $filter Target filter. * @param mixed $filter Target filter.
* @param integer $period Period in seconds to get events. * @param integer $period Period in seconds to get events.
* @param integer $date Beginning date to get events. * @param integer $date Beginning date to get events.
* @param boolean $filter_event_severity Filter_event_severity. * @param boolean $filter_event_severity Filter_event_severity.
* @param boolean $filter_event_type Filter_event_type. * @param boolean $filter_event_type Filter_event_type.
* @param boolean $filter_event_status Filter_event_status. * @param boolean $filter_event_status Filter_event_status.
* @param boolean $filter_event_filter_search Filter_event_filter_search. * @param boolean $filter_event_filter_search Filter_event_filter_search.
* @param boolean $dbmeta Dbmeta. * @param boolean $dbmeta Dbmeta.
* @param boolean $filter_event_filter_exclude Filter_event_filter_exclude.
* *
* @return array An array with all the events happened. * @return array An array with all the events happened.
*/ */
@ -5493,7 +5515,8 @@ function events_get_count_events_by_criticity(
$filter_event_type=false, $filter_event_type=false,
$filter_event_status=false, $filter_event_status=false,
$filter_event_filter_search=false, $filter_event_filter_search=false,
$dbmeta=false $dbmeta=false,
$filter_event_filter_exclude=false
) { ) {
global $config; global $config;
@ -5617,6 +5640,10 @@ function events_get_count_events_by_criticity(
$sql_where .= ' AND (evento LIKE "%'.io_safe_input($filter_event_filter_search).'%" OR id_evento LIKE "%'.io_safe_input($filter_event_filter_search).'%")'; $sql_where .= ' AND (evento LIKE "%'.io_safe_input($filter_event_filter_search).'%" OR id_evento LIKE "%'.io_safe_input($filter_event_filter_search).'%")';
} }
if (!empty($filter_event_filter_exclude)) {
$sql_where .= ' AND (evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%" AND id_evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%")';
}
$sql = sprintf( $sql = sprintf(
'SELECT 'SELECT
te.criticity, te.criticity,
@ -5656,14 +5683,15 @@ function events_get_count_events_by_criticity(
* *
* The returned events will be in the time interval ($date - $period, $date] * The returned events will be in the time interval ($date - $period, $date]
* *
* @param mixed $filter Target filter. * @param mixed $filter Target filter.
* @param integer $period Period in seconds to get events. * @param integer $period Period in seconds to get events.
* @param integer $date Beginning date to get events. * @param integer $date Beginning date to get events.
* @param boolean $filter_event_severity Filter_event_severity. * @param boolean $filter_event_severity Filter_event_severity.
* @param boolean $filter_event_type Filter_event_type. * @param boolean $filter_event_type Filter_event_type.
* @param boolean $filter_event_status Filter_event_status. * @param boolean $filter_event_status Filter_event_status.
* @param boolean $filter_event_filter_search Filter_event_filter_search. * @param boolean $filter_event_filter_search Filter_event_filter_search.
* @param boolean $dbmeta Dbmeta. * @param boolean $dbmeta Dbmeta.
* @param boolean $filter_event_filter_exclude Filter_event_filter_exclude.
* *
* @return array An array with all the events happened. * @return array An array with all the events happened.
*/ */
@ -5675,7 +5703,8 @@ function events_get_count_events_validated(
$filter_event_type=false, $filter_event_type=false,
$filter_event_status=false, $filter_event_status=false,
$filter_event_filter_search=false, $filter_event_filter_search=false,
$dbmeta=false $dbmeta=false,
$filter_event_filter_exclude=false
) { ) {
global $config; global $config;
$tevento = 'tevento'; $tevento = 'tevento';
@ -5828,6 +5857,10 @@ function events_get_count_events_validated(
$sql_where .= ' AND (evento LIKE "%'.io_safe_input($filter_event_filter_search).'%" OR id_evento LIKE "%'.io_safe_input($filter_event_filter_search).'%")'; $sql_where .= ' AND (evento LIKE "%'.io_safe_input($filter_event_filter_search).'%" OR id_evento LIKE "%'.io_safe_input($filter_event_filter_search).'%")';
} }
if (!empty($filter_event_filter_exclude)) {
$sql_where .= ' AND (evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%" AND id_evento NOT LIKE "%'.io_safe_input($filter_event_filter_exclude).'%")';
}
$sql = sprintf( $sql = sprintf(
'SELECT 'SELECT
te.estado, te.estado,

View File

@ -595,178 +595,187 @@ function filemanager_file_explorer(
$files = filemanager_list_dir($real_directory); $files = filemanager_list_dir($real_directory);
$table = new stdClass(); if (!empty($files)) {
$table->width = '100%'; $table = new stdClass();
$table->id = 'table_filemanager'; $table->width = '100%';
if (!defined('METACONSOLE')) { $table->id = 'table_filemanager';
$table->class = 'info_table'; if (!defined('METACONSOLE')) {
$table->title = '<span>'.__('Index of %s', $relative_directory).'</span>'; $table->class = 'info_table';
} $table->title = '<span>'.__('Index of %s', $relative_directory).'</span>';
if (defined('METACONSOLE')) {
$table->class = 'databox_tactical';
$table->title = '<span>'.__('Index of %s', $relative_directory).'</span>';
}
$table->colspan = [];
$table->data = [];
$table->head = [];
$table->size = [];
$table->align[1] = 'left';
$table->align[2] = 'left';
$table->align[3] = 'left';
$table->align[4] = 'left';
$table->size[0] = '24px';
$table->head[0] = '';
$table->head[1] = __('Name');
$table->head[2] = __('Last modification');
$table->head[3] = __('Size');
$table->head[4] = __('Actions');
$prev_dir = explode('/', $relative_directory);
$prev_dir_str = '';
for ($i = 0; $i < (count($prev_dir) - 1); $i++) {
$prev_dir_str .= $prev_dir[$i];
if ($i < (count($prev_dir) - 2)) {
$prev_dir_str .= '/';
} }
}
if (($prev_dir_str != '') && ($father != $relative_directory)) { if (defined('METACONSOLE')) {
$table->data[0][0] = html_print_image('images/go_previous.png', true); $table->class = 'databox_tactical';
$table->data[0][1] = '<a href="'.$url.'&directory='.$prev_dir_str.'&hash2='.md5($prev_dir_str.$config['dbpass']).'">'; $table->title = '<span>'.__('Index of %s', $relative_directory).'</span>';
$table->data[0][1] .= __('Parent directory'); }
$table->data[0][1] .= '</a>';
$table->colspan[0][1] = 5; $table->colspan = [];
} $table->data = [];
$table->head = [];
$table->size = [];
foreach ($files as $fileinfo) { $table->align[1] = 'left';
$fileinfo['realpath'] = str_replace('\\', '/', $fileinfo['realpath']); $table->align[2] = 'left';
$relative_path = str_replace($_SERVER['DOCUMENT_ROOT'], '', $fileinfo['realpath']); $table->align[3] = 'left';
$table->align[4] = 'left';
$data = []; $table->size[0] = '24px';
switch ($fileinfo['mime']) { $table->head[0] = '';
case MIME_DIR: $table->head[1] = __('Name');
$data[0] = html_print_image('images/mimetypes/directory.png', true, ['title' => __('Directory')]); $table->head[2] = __('Last modification');
break; $table->head[3] = __('Size');
$table->head[4] = __('Actions');
case MIME_IMAGE: $prev_dir = explode('/', $relative_directory);
$data[0] = html_print_image('images/mimetypes/image.png', true, ['title' => __('Image')]); $prev_dir_str = '';
break; for ($i = 0; $i < (count($prev_dir) - 1); $i++) {
$prev_dir_str .= $prev_dir[$i];
if ($i < (count($prev_dir) - 2)) {
$prev_dir_str .= '/';
}
}
case MIME_ZIP: if (($prev_dir_str != '') && ($father != $relative_directory)) {
$data[0] = html_print_image('images/mimetypes/zip.png', true, ['title' => __('Compressed file')]); $table->data[0][0] = html_print_image('images/go_previous.png', true);
break; $table->data[0][1] = '<a href="'.$url.'&directory='.$prev_dir_str.'&hash2='.md5($prev_dir_str.$config['dbpass']).'">';
$table->data[0][1] .= __('Parent directory');
$table->data[0][1] .= '</a>';
case MIME_TEXT: $table->colspan[0][1] = 5;
$data[0] = html_print_image('images/mimetypes/text.png', true, ['title' => __('Text file')]); }
break;
case MIME_UNKNOWN: foreach ($files as $fileinfo) {
if ($fileinfo['size'] == 0) { $fileinfo['realpath'] = str_replace('\\', '/', $fileinfo['realpath']);
if ((strstr($fileinfo['name'], '.txt') !== false) || (strstr($fileinfo['name'], '.conf') !== false) || (strstr($fileinfo['name'], '.sql') !== false) || (strstr($fileinfo['name'], '.pl') !== false)) { $relative_path = str_replace($_SERVER['DOCUMENT_ROOT'], '', $fileinfo['realpath']);
$fileinfo['mime'] = MIME_TEXT;
$data[0] = html_print_image('images/mimetypes/text.png', true, ['title' => __('Text file')]); $data = [];
switch ($fileinfo['mime']) {
case MIME_DIR:
$data[0] = html_print_image('images/mimetypes/directory.png', true, ['title' => __('Directory')]);
break;
case MIME_IMAGE:
$data[0] = html_print_image('images/mimetypes/image.png', true, ['title' => __('Image')]);
break;
case MIME_ZIP:
$data[0] = html_print_image('images/mimetypes/zip.png', true, ['title' => __('Compressed file')]);
break;
case MIME_TEXT:
$data[0] = html_print_image('images/mimetypes/text.png', true, ['title' => __('Text file')]);
break;
case MIME_UNKNOWN:
if ($fileinfo['size'] == 0) {
if ((strstr($fileinfo['name'], '.txt') !== false) || (strstr($fileinfo['name'], '.conf') !== false) || (strstr($fileinfo['name'], '.sql') !== false) || (strstr($fileinfo['name'], '.pl') !== false)) {
$fileinfo['mime'] = MIME_TEXT;
$data[0] = html_print_image('images/mimetypes/text.png', true, ['title' => __('Text file')]);
} else {
// unknow
$data[0] = '';
}
} else { } else {
// unknow // pdf
$data[0] = ''; $data[0] = '';
} }
} else { break;
// pdf
$data[0] = ''; default:
$data[0] = html_print_image('images/mimetypes/unknown.png', true, ['title' => __('Unknown')]);
break;
}
if ($fileinfo['is_dir']) {
$data[1] = '<a href="'.$url.'&directory='.$relative_directory.'/'.$fileinfo['name'].'&hash2='.md5($relative_directory.'/'.$fileinfo['name'].$config['dbpass']).'">'.$fileinfo['name'].'</a>';
} else if (!empty($url_file)) {
// Set the custom url file
$url_file_clean = str_replace('[FILE_FULLPATH]', $fileinfo['realpath'], $url_file);
$data[1] = '<a href="'.$url_file_clean.'">'.$fileinfo['name'].'</a>';
} else {
$filename = base64_encode($relative_directory.'/'.$fileinfo['name']);
$hash = md5($filename.$config['dbpass']);
$data[1] = '<a href="'.$hack_metaconsole.'include/get_file.php?file='.urlencode($filename).'&hash='.$hash.'">'.$fileinfo['name'].'</a>';
}
// Notice that uploaded php files could be dangerous
if (pathinfo($fileinfo['realpath'], PATHINFO_EXTENSION) == 'php'
&& (is_readable($fileinfo['realpath']) || is_executable($fileinfo['realpath']))
) {
$error_message = __('This file could be executed by any user');
$error_message .= '. '.__('Make sure it can\'t perform dangerous tasks');
$data[1] = '<span class="error forced_title" data-title="'.$error_message.'" data-use_title_for_force_title="1">'.$data[1].'</span>';
}
$data[2] = ui_print_timestamp(
$fileinfo['last_modified'],
true,
['prominent' => true]
);
if ($fileinfo['is_dir']) {
$data[3] = '';
} else {
$data[3] = ui_format_filesize($fileinfo['size']);
}
// Actions buttons
// Delete button
$data[4] = '';
$data[4] .= '<span style="display: flex">';
$typefile = array_pop(explode('.', $fileinfo['name']));
if (is_writable($fileinfo['realpath'])
&& (! is_dir($fileinfo['realpath']) || count(scandir($fileinfo['realpath'])) < 3) && (!$readOnly)
) {
$data[4] .= '<form method="post" action="'.$url.'" style="">';
$data[4] .= '<input type="image" src="images/cross.png" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
$data[4] .= html_print_input_hidden('filename', $fileinfo['realpath'], true);
$data[4] .= html_print_input_hidden('hash', md5($fileinfo['realpath'].$config['dbpass']), true);
$data[4] .= html_print_input_hidden('delete_file', 1, true);
$relative_dir = str_replace($homedir_filemanager, '', str_replace('\\', '/', dirname($fileinfo['realpath'])));
if ($relative_dir[0] == '/') {
$relative_dir = substr($relative_dir, 1);
} }
break;
default: $hash2 = md5($relative_dir.$config['dbpass']);
$data[0] = html_print_image('images/mimetypes/unknown.png', true, ['title' => __('Unknown')]);
break; $data[4] .= html_print_input_hidden('directory', $relative_dir, true);
$data[4] .= html_print_input_hidden('hash2', $hash2, true);
$data[4] .= '</form>';
if (($editor) && (!$readOnly)) {
if (($typefile != 'bin') && ($typefile != 'pdf') && ($typefile != 'png') && ($typefile != 'jpg')
&& ($typefile != 'iso') && ($typefile != 'docx') && ($typefile != 'doc') && ($fileinfo['mime'] != MIME_DIR)
) {
$hash = md5($fileinfo['realpath'].$config['dbpass']);
$data[4] .= "<a style='vertical-align: top;' href='$url&edit_file=1&hash=".$hash.'&location_file='.$fileinfo['realpath']."' style='float: left;'>".html_print_image('images/edit.png', true, ['style' => 'margin-top: 2px;', 'title' => __('Edit file')]).'</a>';
}
}
}
if ((!$fileinfo['is_dir']) && ($download_button)) {
$filename = base64_encode($fileinfo['name']);
$hash = md5($filename.$config['dbpass']);
$data[4] .= '<a href="include/get_file.php?file='.urlencode($filename).'&hash='.$hash.'" style="vertical-align: 25%;">';
$data[4] .= html_print_image('images/file.png', true);
$data[4] .= '</a>';
}
$data[4] .= '</span>';
array_push($table->data, $data);
} }
} else {
if ($fileinfo['is_dir']) { ui_print_info_message(
$data[1] = '<a href="'.$url.'&directory='.$relative_directory.'/'.$fileinfo['name'].'&hash2='.md5($relative_directory.'/'.$fileinfo['name'].$config['dbpass']).'">'.$fileinfo['name'].'</a>'; [
} else if (!empty($url_file)) { 'no_close' => true,
// Set the custom url file 'message' => __('No files or directories to show.'),
$url_file_clean = str_replace('[FILE_FULLPATH]', $fileinfo['realpath'], $url_file); ]
$data[1] = '<a href="'.$url_file_clean.'">'.$fileinfo['name'].'</a>';
} else {
$filename = base64_encode($relative_directory.'/'.$fileinfo['name']);
$hash = md5($filename.$config['dbpass']);
$data[1] = '<a href="'.$hack_metaconsole.'include/get_file.php?file='.urlencode($filename).'&hash='.$hash.'">'.$fileinfo['name'].'</a>';
}
// Notice that uploaded php files could be dangerous
if (pathinfo($fileinfo['realpath'], PATHINFO_EXTENSION) == 'php'
&& (is_readable($fileinfo['realpath']) || is_executable($fileinfo['realpath']))
) {
$error_message = __('This file could be executed by any user');
$error_message .= '. '.__('Make sure it can\'t perform dangerous tasks');
$data[1] = '<span class="error forced_title" data-title="'.$error_message.'" data-use_title_for_force_title="1">'.$data[1].'</span>';
}
$data[2] = ui_print_timestamp(
$fileinfo['last_modified'],
true,
['prominent' => true]
); );
if ($fileinfo['is_dir']) {
$data[3] = '';
} else {
$data[3] = ui_format_filesize($fileinfo['size']);
}
// Actions buttons
// Delete button
$data[4] = '';
$data[4] .= '<span style="display: flex">';
$typefile = array_pop(explode('.', $fileinfo['name']));
if (is_writable($fileinfo['realpath'])
&& (! is_dir($fileinfo['realpath']) || count(scandir($fileinfo['realpath'])) < 3) && (!$readOnly)
) {
$data[4] .= '<form method="post" action="'.$url.'" style="">';
$data[4] .= '<input type="image" src="images/cross.png" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
$data[4] .= html_print_input_hidden('filename', $fileinfo['realpath'], true);
$data[4] .= html_print_input_hidden('hash', md5($fileinfo['realpath'].$config['dbpass']), true);
$data[4] .= html_print_input_hidden('delete_file', 1, true);
$relative_dir = str_replace($homedir_filemanager, '', str_replace('\\', '/', dirname($fileinfo['realpath'])));
if ($relative_dir[0] == '/') {
$relative_dir = substr($relative_dir, 1);
}
$hash2 = md5($relative_dir.$config['dbpass']);
$data[4] .= html_print_input_hidden('directory', $relative_dir, true);
$data[4] .= html_print_input_hidden('hash2', $hash2, true);
$data[4] .= '</form>';
if (($editor) && (!$readOnly)) {
if (($typefile != 'bin') && ($typefile != 'pdf') && ($typefile != 'png') && ($typefile != 'jpg')
&& ($typefile != 'iso') && ($typefile != 'docx') && ($typefile != 'doc') && ($fileinfo['mime'] != MIME_DIR)
) {
$hash = md5($fileinfo['realpath'].$config['dbpass']);
$data[4] .= "<a style='vertical-align: top;' href='$url&edit_file=1&hash=".$hash.'&location_file='.$fileinfo['realpath']."' style='float: left;'>".html_print_image('images/edit.png', true, ['style' => 'margin-top: 2px;', 'title' => __('Edit file')]).'</a>';
}
}
}
if ((!$fileinfo['is_dir']) && ($download_button)) {
$filename = base64_encode($fileinfo['name']);
$hash = md5($filename.$config['dbpass']);
$data[4] .= '<a href="include/get_file.php?file='.urlencode($filename).'&hash='.$hash.'" style="vertical-align: 25%;">';
$data[4] .= html_print_image('images/file.png', true);
$data[4] .= '</a>';
}
$data[4] .= '</span>';
array_push($table->data, $data);
} }
if (!$readOnly) { if (!$readOnly) {

View File

@ -4008,7 +4008,7 @@ function graph_graphic_agentevents(
$width, $width,
$height, $height,
$period=0, $period=0,
$homeurl, $homeurl='',
$return=false, $return=false,
$from_agent_view=false, $from_agent_view=false,
$widgets=false, $widgets=false,

View File

@ -1505,7 +1505,6 @@ function html_print_extended_select_for_unit(
// $fields = post_process_get_custom_values(); // $fields = post_process_get_custom_values();
$fields['_timeticks_'] = 'Timeticks'; $fields['_timeticks_'] = 'Timeticks';
$fields['none'] = __('none');
$default_module_custom_units = get_custom_module_units(); $default_module_custom_units = get_custom_module_units();

View File

@ -0,0 +1,97 @@
<?php
/**
* Massive Operations Functions
*
* @category Configuration
* @package Pandora FMS
* @subpackage Massive Operations
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
/**
* Generate a action button for submit the form.
*
* @param string $action Action to send in form.
* @param string $buttonAction Action of the button: Create, Update or Delete.
* @param string $tableWidth Set the table width for the container.
* @param boolean $return If true, return a formed string.
*
* @return string
*/
function attachActionButton(
string $action,
string $buttonAction,
string $tableWidth,
bool $return=false
) {
switch ($buttonAction) {
case 'add':
$caption = 'Add';
$class = 'add';
break;
case 'copy':
$caption = 'Copy';
$class = 'wand';
break;
case 'create':
$caption = 'Create';
$class = 'upd';
break;
case 'update':
$caption = 'Update';
$class = 'upd';
break;
case 'delete':
$caption = 'Delete';
$class = 'delete';
break;
default:
// Do none.
break;
}
return html_print_div(
[
'class' => 'action-buttons',
'style' => sprintf('width: %s', $tableWidth),
'content' => html_print_input_hidden(
$action,
1
).html_print_button(
__($caption),
'go',
false,
'',
sprintf('class="sub %s"', $class),
true
),
],
$return
);
}

View File

@ -497,11 +497,7 @@ function messages_get_overview(
if ($incl_source_info) { if ($incl_source_info) {
$source_fields = ', tns.*'; $source_fields = ', tns.*';
$source_join = 'INNER JOIN tnotification_source tns $source_join = 'INNER JOIN tnotification_source tns
ON tns.id=tm.id_source 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';
} }
// Using distinct because could be double assignment due group/user. // Using distinct because could be double assignment due group/user.

View File

@ -116,6 +116,68 @@ function get_notification_targets(int $id_message)
} }
/**
* Return subtypes.
*
* @param string|null $source Source filter or all.
*
* @return array
*/
function notifications_get_subtypes(?string $source=null)
{
$subtypes = [
'System status' => [
'NOTIF.LICENSE.LIMITED',
'NOTIF.LICENSE.EXPIRATION',
'NOTIF.FILES.ATTACHMENT',
'NOTIF.FILES.DATAIN',
'NOTIF.FILES.DATAIN.BADXML',
'NOTIF.PHP.SAFE_MODE',
'NOTIF.PHP.INPUT_TIME',
'NOTIF.PHP.EXECUTION_TIME',
'NOTIF.PHP.UPLOAD_MAX_FILESIZE',
'NOTIF.PHP.MEMORY_LIMIT',
'NOTIF.PHP.DISABLE_FUNCTIONS',
'NOTIF.PHP.PHANTOMJS',
'NOTIF.PHP.VERSION',
'NOTIF.HISTORYDB',
'NOTIF.PANDORADB',
'NOTIF.PANDORADB.HISTORICAL',
'NOTIF.HISTORYDB.MR',
'NOTIF.EXT.ELASTICSEARCH',
'NOTIF.EXT.LOGSTASH',
'NOTIF.METACONSOLE.DB_CONNECTION',
'NOTIF.DOWNTIME',
'NOTIF.UPDATEMANAGER.REGISTRATION',
'NOTIF.MISC.EVENTSTORMPROTECTION',
'NOTIF.MISC.DEVELOPBYPASS',
'NOTIF.MISC.FONTPATH',
'NOTIF.SECURITY.DEFAULT_PASSWORD',
'NOTIF.UPDATEMANAGER.OPENSETUP',
'NOTIF.UPDATEMANAGER.UPDATE',
'NOTIF.UPDATEMANAGER.MINOR',
'NOTIF.UPDATEMANAGER.MESSAGES',
'NOTIF.CRON.CONFIGURED',
'NOTIF.ALLOWOVERRIDE.MESSAGE',
'NOTIF.HAMASTER.MESSAGE',
'NOTIF.SERVER.STATUS',
'NOTIF.SERVER.QUEUE',
'NOTIF.SERVER.MASTER',
],
];
if ($source === null) {
return $subtypes;
}
if (isset($subtypes[$source]) === true) {
return $subtypes[$source];
}
return [];
}
/** /**
* Check if current user has grants to read this notification * Check if current user has grants to read this notification
* *
@ -160,14 +222,28 @@ function check_notification_readable(int $id_message)
* Returns the target users and groups assigned to be notified on * Returns the target users and groups assigned to be notified on
* desired source. * desired source.
* *
* @param integer $id_source Source identificator. * @param integer $id_source Source identificator.
* @param string|null $subtype Subtype identification.
* *
* @return array [users] and [groups] with the targets. * @return array [users] and [groups] with the targets.
*/ */
function get_notification_source_targets(int $id_source) function get_notification_source_targets(int $id_source, ?string $subtype=null)
{ {
$ret = []; $ret = [];
$filter = '';
if ($subtype !== null) {
$matches = [];
if (preg_match('/(.*)\.\d+$/', $subtype, $matches) > 0) {
$subtype = $matches[1];
}
$filter = sprintf(
' AND ns.`subtype_blacklist` NOT LIKE "%%%s%%"',
$subtype
);
}
$users = db_get_all_rows_sql( $users = db_get_all_rows_sql(
sprintf( sprintf(
'SELECT 'SELECT
@ -176,9 +252,11 @@ function get_notification_source_targets(int $id_source)
FROM tnotification_source_user nsu FROM tnotification_source_user nsu
INNER JOIN tnotification_source ns INNER JOIN tnotification_source ns
ON ns.id=nsu.id_source ON ns.id=nsu.id_source
%s
WHERE ns.id = %d WHERE ns.id = %d
AND ((ns.enabled is NULL OR ns.enabled != 0) AND ((ns.enabled is NULL OR ns.enabled != 0)
OR (nsu.enabled is NULL OR nsu.enabled != 0))', OR (nsu.enabled is NULL OR nsu.enabled != 0))',
$filter,
$id_source $id_source
) )
); );
@ -197,8 +275,10 @@ function get_notification_source_targets(int $id_source)
FROM tnotification_source_group nsg FROM tnotification_source_group nsg
INNER JOIN tnotification_source ns INNER JOIN tnotification_source ns
ON ns.id=nsg.id_source ON ns.id=nsg.id_source
%s
WHERE ns.id = %d WHERE ns.id = %d
AND (ns.enabled is NULL OR ns.enabled != 0)', AND (ns.enabled is NULL OR ns.enabled != 0)',
$filter,
$id_source $id_source
) )
); );
@ -700,8 +780,47 @@ function notifications_print_global_source_configuration($source)
); );
$html_selectors .= '</div>'; $html_selectors .= '</div>';
$html_checkboxes = '';
$blacklist = json_decode($source['subtype_blacklist'], 1);
if (json_last_error() !== JSON_ERROR_NONE) {
$blacklist = [];
}
if ($source['description'] === io_safe_input('System status')) {
$system_subtypes = notifications_get_subtypes('System status');
foreach ($system_subtypes as $type) {
$html_checkboxes .= html_print_input(
[
'input_class' => 'flex flex-row w290px margin-soft',
'label' => $type,
'name' => 'check-'.$type,
'type' => 'switch',
'id' => 'nt-'.$source['id'].'.'.$type.'-subtype',
'class' => 'elem-clickable',
'value' => (isset($blacklist[$type]) === false),
'return' => true,
]
);
}
$html_checkboxes = ui_print_toggle(
[
'content' => $html_checkboxes,
'name' => __('Subtype customization'),
'hidden_default' => false,
'return' => true,
'toggle_class' => '',
'container_class' => 'flex flex-row flex-start w100p',
'main_class' => '',
'clean' => true,
]
);
}
// Return all html. // Return all html.
return $html_title.$html_selectors.$html_checkboxes.$html_select_pospone; return $html_title.$html_selectors.$html_checkboxes;
} }

View File

@ -1868,6 +1868,10 @@ function reporting_event_report_group(
$return['subtitle'] .= ' ('.$content['style']['event_filter_search'].')'; $return['subtitle'] .= ' ('.$content['style']['event_filter_search'].')';
} }
if (!empty($content['style']['event_filter_exclude'])) {
$return['subtitle'] .= ' ('.__('Exclude ').$content['style']['event_filter_exclude'].')';
}
$return['description'] = $content['description']; $return['description'] = $content['description'];
$return['show_extended_events'] = $content['show_extended_events']; $return['show_extended_events'] = $content['show_extended_events'];
$return['date'] = reporting_get_date_text($report, $content); $return['date'] = reporting_get_date_text($report, $content);
@ -1880,6 +1884,7 @@ function reporting_event_report_group(
$filter_event_type = json_decode($event_filter['filter_event_type'], true); $filter_event_type = json_decode($event_filter['filter_event_type'], true);
$filter_event_status = json_decode($event_filter['filter_event_status'], true); $filter_event_status = json_decode($event_filter['filter_event_status'], true);
$filter_event_filter_search = $event_filter['event_filter_search']; $filter_event_filter_search = $event_filter['event_filter_search'];
$filter_event_filter_exclude = $event_filter['event_filter_exclude'];
// Graphs. // Graphs.
$event_graph_by_agent = $event_filter['event_graph_by_agent']; $event_graph_by_agent = $event_filter['event_graph_by_agent'];
@ -1919,7 +1924,11 @@ function reporting_event_report_group(
$filter_event_status, $filter_event_status,
$filter_event_filter_search, $filter_event_filter_search,
$content['id_group'], $content['id_group'],
true true,
false,
false,
false,
$filter_event_filter_exclude
); );
if (empty($data)) { if (empty($data)) {
@ -1965,7 +1974,8 @@ function reporting_event_report_group(
$filter_event_type, $filter_event_type,
$filter_event_status, $filter_event_status,
$filter_event_filter_search, $filter_event_filter_search,
$metaconsole_dbtable $metaconsole_dbtable,
$filter_event_filter_exclude
); );
$return['chart']['by_agent'] = pie_graph( $return['chart']['by_agent'] = pie_graph(
@ -1990,7 +2000,8 @@ function reporting_event_report_group(
$filter_event_type, $filter_event_type,
$filter_event_status, $filter_event_status,
$filter_event_filter_search, $filter_event_filter_search,
$metaconsole_dbtable $metaconsole_dbtable,
$filter_event_filter_exclude
); );
$return['chart']['by_user_validator'] = pie_graph( $return['chart']['by_user_validator'] = pie_graph(
@ -2044,7 +2055,8 @@ function reporting_event_report_group(
$filter_event_type, $filter_event_type,
$filter_event_status, $filter_event_status,
$filter_event_filter_search, $filter_event_filter_search,
$metaconsole_dbtable $metaconsole_dbtable,
$filter_event_filter_exclude
); );
$return['chart']['validated_vs_unvalidated'] = pie_graph( $return['chart']['validated_vs_unvalidated'] = pie_graph(
@ -2189,6 +2201,7 @@ function reporting_event_report_module(
true true
); );
$filter_event_filter_search = $event_filter['event_filter_search']; $filter_event_filter_search = $event_filter['event_filter_search'];
$filter_event_filter_exclude = $event_filter['event_filter_exclude'];
// Graphs. // Graphs.
$event_graph_by_user_validator = $event_filter['event_graph_by_user_validator']; $event_graph_by_user_validator = $event_filter['event_graph_by_user_validator'];
@ -2218,7 +2231,8 @@ function reporting_event_report_module(
$event_graph_validated_vs_unvalidated, $event_graph_validated_vs_unvalidated,
$ttl, $ttl,
$id_server, $id_server,
$metaconsole_dbtable $metaconsole_dbtable,
$filter_event_filter_exclude
); );
if (empty($data)) { if (empty($data)) {
@ -3259,6 +3273,7 @@ function reporting_event_report_agent(
$filter_event_type = json_decode($style['filter_event_type'], true); $filter_event_type = json_decode($style['filter_event_type'], true);
$filter_event_status = json_decode($style['filter_event_status'], true); $filter_event_status = json_decode($style['filter_event_status'], true);
$filter_event_filter_search = $style['event_filter_search']; $filter_event_filter_search = $style['event_filter_search'];
$filter_event_filter_exclude = $style['event_filter_exclude'];
// Graph. // Graph.
$event_graph_by_user_validator = $style['event_graph_by_user_validator']; $event_graph_by_user_validator = $style['event_graph_by_user_validator'];
@ -3276,7 +3291,8 @@ function reporting_event_report_agent(
$filter_event_severity, $filter_event_severity,
$filter_event_type, $filter_event_type,
$filter_event_status, $filter_event_status,
$filter_event_filter_search $filter_event_filter_search,
$filter_event_filter_exclude
); );
reporting_set_conf_charts( reporting_set_conf_charts(
@ -3316,7 +3332,8 @@ function reporting_event_report_agent(
$filter_event_type, $filter_event_type,
$filter_event_status, $filter_event_status,
$filter_event_filter_search, $filter_event_filter_search,
$metaconsole_dbtable $metaconsole_dbtable,
$filter_event_filter_exclude
); );
$return['chart']['by_user_validator'] = pie_graph( $return['chart']['by_user_validator'] = pie_graph(
@ -3341,7 +3358,8 @@ function reporting_event_report_agent(
$filter_event_type, $filter_event_type,
$filter_event_status, $filter_event_status,
$filter_event_filter_search, $filter_event_filter_search,
$metaconsole_dbtable $metaconsole_dbtable,
$filter_event_filter_exclude
); );
$colors = get_criticity_pie_colors($data_graph); $colors = get_criticity_pie_colors($data_graph);
@ -3370,7 +3388,8 @@ function reporting_event_report_agent(
$filter_event_type, $filter_event_type,
$filter_event_status, $filter_event_status,
$filter_event_filter_search, $filter_event_filter_search,
$metaconsole_dbtable $metaconsole_dbtable,
$filter_event_filter_exclude
); );
$return['chart']['validated_vs_unvalidated'] = pie_graph( $return['chart']['validated_vs_unvalidated'] = pie_graph(
@ -7532,6 +7551,7 @@ function reporting_availability_graph(
$return['pagebreak'] = $content['pagebreak']; $return['pagebreak'] = $content['pagebreak'];
$return['description'] = $content['description']; $return['description'] = $content['description'];
$return['failover_type'] = $content['failover_type']; $return['failover_type'] = $content['failover_type'];
$return['summary'] = $content['summary'];
$return['date'] = reporting_get_date_text($report, $content); $return['date'] = reporting_get_date_text($report, $content);
// Get chart. // Get chart.
@ -7650,24 +7670,22 @@ function reporting_availability_graph(
} }
foreach ($sla_failover as $k_sla => $v_sla) { foreach ($sla_failover as $k_sla => $v_sla) {
if ($content['failover_type'] == REPORT_FAILOVER_TYPE_NORMAL) { $sla_array = data_compare_24x7(
$sla_array = data_compare_24x7( $v_sla,
$v_sla, $content,
$content, $report['datetime'],
$report['datetime'], $slice
$slice );
);
$return = prepare_data_for_paint( $return = prepare_data_for_paint(
$v_sla, $v_sla,
$sla_array, $sla_array,
$content, $content,
$report['datetime'], $report['datetime'],
$return, $return,
$k_sla, $k_sla,
$pdf $pdf
); );
}
if (isset($v_sla['compare']) === true if (isset($v_sla['compare']) === true
&& empty($v_sla['compare']) === false && empty($v_sla['compare']) === false
@ -9406,7 +9424,8 @@ function reporting_get_module_detailed_event(
$event_graph_validated_vs_unvalidated=false, $event_graph_validated_vs_unvalidated=false,
$ttl=1, $ttl=1,
$id_server=false, $id_server=false,
$metaconsole_dbtable=false $metaconsole_dbtable=false,
$filter_event_filter_exclude=false
) { ) {
global $config; global $config;
@ -9442,7 +9461,8 @@ function reporting_get_module_detailed_event(
false, false,
$id_module, $id_module,
true, true,
$id_server $id_server,
$filter_event_filter_exclude
); );
// total_events // total_events
@ -9470,7 +9490,8 @@ function reporting_get_module_detailed_event(
$filter_event_type, $filter_event_type,
$filter_event_status, $filter_event_status,
$filter_event_filter_search, $filter_event_filter_search,
$metaconsole_dbtable $metaconsole_dbtable,
$filter_event_filter_exclude
); );
$event['chart']['by_user_validator'] = pie_graph( $event['chart']['by_user_validator'] = pie_graph(
@ -9495,7 +9516,8 @@ function reporting_get_module_detailed_event(
$filter_event_type, $filter_event_type,
$filter_event_status, $filter_event_status,
$filter_event_filter_search, $filter_event_filter_search,
$metaconsole_dbtable $metaconsole_dbtable,
$filter_event_filter_exclude
); );
$colors = get_criticity_pie_colors($data_graph); $colors = get_criticity_pie_colors($data_graph);
@ -9524,7 +9546,8 @@ function reporting_get_module_detailed_event(
$filter_event_type, $filter_event_type,
$filter_event_status, $filter_event_status,
$filter_event_filter_search, $filter_event_filter_search,
$metaconsole_dbtable $metaconsole_dbtable,
$filter_event_filter_exclude
); );
$event['chart']['validated_vs_unvalidated'] = pie_graph( $event['chart']['validated_vs_unvalidated'] = pie_graph(
@ -9573,7 +9596,8 @@ function reporting_get_agents_detailed_event(
$filter_event_severity=false, $filter_event_severity=false,
$filter_event_type=false, $filter_event_type=false,
$filter_event_status=false, $filter_event_status=false,
$filter_event_filter_search=false $filter_event_filter_search=false,
$filter_event_filter_exclude=false
) { ) {
global $config; global $config;
@ -9605,7 +9629,11 @@ function reporting_get_agents_detailed_event(
$filter_event_status, $filter_event_status,
$filter_event_filter_search, $filter_event_filter_search,
false, false,
false false,
false,
false,
false,
$filter_event_filter_exclude
); );
if (empty($event)) { if (empty($event)) {

View File

@ -3835,6 +3835,10 @@ function reporting_html_availability_graph($table, $item, $pdf=0)
$tables_chart = ''; $tables_chart = '';
$total_values = 0;
$count_total_charts = 0;
if (isset($item['failed']) === true && empty($item['failed']) === false) { if (isset($item['failed']) === true && empty($item['failed']) === false) {
$tables_chart .= $item['failed']; $tables_chart .= $item['failed'];
} else { } else {
@ -3896,6 +3900,8 @@ function reporting_html_availability_graph($table, $item, $pdf=0)
$table1->data[$k_chart][0] .= ' (24 x 7)'; $table1->data[$k_chart][0] .= ' (24 x 7)';
} }
$total_values += $sla_value;
$count_total_charts++;
$table1->data[$k_chart][1] = $chart['chart']; $table1->data[$k_chart][1] = $chart['chart'];
$table1->data[$k_chart][2] = "<span style = 'font-weight: bold; font-size: ".$font_size.'; color: '.$color."'>".$sla_value.'</span><br/>'; $table1->data[$k_chart][2] = "<span style = 'font-weight: bold; font-size: ".$font_size.'; color: '.$color."'>".$sla_value.'</span><br/>';
@ -3922,7 +3928,7 @@ function reporting_html_availability_graph($table, $item, $pdf=0)
|| $item['data'][$k_chart]['compare'] === 1) || $item['data'][$k_chart]['compare'] === 1)
) { ) {
$table1 = new stdClass(); $table1 = new stdClass();
$table1->width = '99%'; $table1->width = '100%';
$table1->data = []; $table1->data = [];
$table1->size = []; $table1->size = [];
$table1->size[0] = '10%'; $table1->size[0] = '10%';
@ -3971,6 +3977,8 @@ function reporting_html_availability_graph($table, $item, $pdf=0)
case 'result': case 'result':
default: default:
$total_values += $sla_value;
$count_total_charts++;
$title = '<b>'.__('Result').'</b>'; $title = '<b>'.__('Result').'</b>';
$sla_value_text = "<span style = 'font-weight: bold; font-size: ".$font_size.' !important; color: '.$color."'>".$sla_value.'</span>'; $sla_value_text = "<span style = 'font-weight: bold; font-size: ".$font_size.' !important; color: '.$color."'>".$sla_value.'</span>';
$checks_resume_text = '<span style = "font-size: '.$font_mini.';">'; $checks_resume_text = '<span style = "font-size: '.$font_mini.';">';
@ -3996,6 +4004,27 @@ function reporting_html_availability_graph($table, $item, $pdf=0)
} }
} }
if ((bool) $item['summary'] === true) {
$table_summary = new stdClass();
$table_summary->width = '20%';
$table_summary->size = [];
$table_summary->size[0] = '50%';
$table_summary->size[1] = '50%';
$table_summary->data = [];
$table_summary->data[0][0] = '<b>'.__('Summary').'</b>';
$table_summary->data[0][1] = '<span style = "font-weight: bold; font-size: '.$font_size.' !important;">';
$table_summary->data[0][1] .= sla_truncate($total_values / $count_total_charts);
$table_summary->data[0][1] .= ' %';
$table_summary->data[0][1] .= '</span>';
$tables_chart .= html_print_table(
$table_summary,
true
);
}
if ($item['type'] == 'availability_graph') { if ($item['type'] == 'availability_graph') {
// Table_legend_graphs. // Table_legend_graphs.
$table2 = new stdClass(); $table2 = new stdClass();

View File

@ -1391,7 +1391,7 @@ function snmp_browser_create_modules_snmp(
'min_ff_event_critical' => 0, 'min_ff_event_critical' => 0,
'ff_type' => 0, 'ff_type' => 0,
'each_ff' => 0, 'each_ff' => 0,
'ip_target' => $target_ip, 'ip_target' => '',
'configuration_data' => '', 'configuration_data' => '',
'history_data' => 1, 'history_data' => 1,
]; ];
@ -1492,9 +1492,9 @@ function snmp_browser_print_create_module_massive($target='agent', $snmp_conf, $
true true
); );
$table->data[2][0] = __($target_item.' available').html_print_input_image('select_all_left', 'images/tick.png', 1, '', true, ['title' => __('Select all')]); $table->data[2][0] = '<b>'.__($target_item.' available').'</b><br> '.__('Select all').html_print_checkbox_switch('select_all_left', 1, false, true);
$table->data[2][1] = ''; $table->data[2][1] = '';
$table->data[2][2] = __($target_item.' to apply').html_print_input_image('select_all_right', 'images/tick.png', 1, '', true, ['title' => __('Select all')]); $table->data[2][2] = '<b>'.__($target_item.' to apply').'</b><br> '.__('Select all').html_print_checkbox_switch('select_all_right', 1, false, true);
$table->data[3][0] = html_print_select( $table->data[3][0] = html_print_select(
[], [],

View File

@ -92,6 +92,7 @@ function tactical_get_data($id_user=false, $user_strict=false, $acltags, $return
$list['_monitors_unknown_'] = 0; $list['_monitors_unknown_'] = 0;
$list['_monitors_not_init_'] = 0; $list['_monitors_not_init_'] = 0;
$list['_monitors_ok_'] = 0; $list['_monitors_ok_'] = 0;
$list['_monitors_alerts_fired_'] = 0;
if (empty($list_groups)) { if (empty($list_groups)) {
$list_groups = []; $list_groups = [];

View File

@ -3821,7 +3821,9 @@ function ui_toggle(
$main_class = ''; $main_class = '';
} }
$container_class = 'white-box-content-clean'; if (empty($container_class) === true) {
$container_class = 'white-box-content-clean';
}
} }
// Link to toggle. // Link to toggle.
@ -3943,7 +3945,24 @@ function ui_toggle(
/** /**
* Simplified way of ui_toggle ussage. * Simplified way of ui_toggle ussage.
* *
* @param array $data Arguments. * @param array $data Arguments:
* 'content'
* 'name'
* 'title'
* 'id'
* 'hidden_default'
* 'return'
* 'toggle_class'
* 'container_class'
* 'main_class'
* 'img_a'
* 'img_b'
* 'clean'
* 'reverseImg'
* 'switch'
* 'attributes_switch'
* 'toggl_attr'
* 'switch_on'.
* *
* @return string HTML code with toggle content. * @return string HTML code with toggle content.
*/ */
@ -4850,6 +4869,7 @@ function ui_print_agent_autocomplete_input($parameters)
$get_only_string_modules = true; $get_only_string_modules = true;
} }
$no_disabled_modules = true;
if (isset($parameters['no_disabled_modules'])) { if (isset($parameters['no_disabled_modules'])) {
$no_disabled_modules = $parameters['no_disabled_modules']; $no_disabled_modules = $parameters['no_disabled_modules'];
} }
@ -6282,3 +6302,56 @@ function ui_print_reveal_password(string $name, bool $return=false)
echo $output; echo $output;
} }
/**
* Generate a spinner box for waiting times
* TIP: It's made for Massive Operations, but it migth used in entire project.
*
* @param string $text Text for show in spinner. English term Loading for default.
* @param boolean $return If true, return the string with the formed element.
*
* @return string
*/
function ui_print_spinner(string $text='Loading', bool $return=false)
{
$output = '';
$output .= '<center>';
$output .= html_print_div(
[
'id' => 'loading_spinner',
'class' => 'white_box invisible',
'content' => '<span style="font-size:25px;">'.$text.'...</span>'.html_print_image(
'images/spinner.gif',
true,
[
'border' => '0',
'width' => '25px',
'heigth' => '25px',
]
),
],
true
);
$output .= '</center>';
$output .= '
<script type="text/javascript">
function hideSpinner() {
document.getElementById("loading_spinner").classList.add("invisible");
}
function showSpinner() {
document.getElementById("loading_spinner").classList.remove("invisible");
}
</script>
';
if ($return === true) {
return $output;
} else {
echo $output;
}
}

View File

@ -1,18 +1,32 @@
<?php <?php
/**
* CSV charts.
*
* @category CSV charts
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com // Load files.
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Don't use authentication methods.
// This file only uses data retrieved in a request.
require_once '../../include/config.php'; require_once '../../include/config.php';
require_once '../../include/functions.php'; require_once '../../include/functions.php';
enterprise_include_once('include/functions_reporting_csv.php'); enterprise_include_once('include/functions_reporting_csv.php');
@ -21,12 +35,14 @@ global $config;
$user_language = get_user_language($config['id_user']); $user_language = get_user_language($config['id_user']);
$l10n = null; $l10n = null;
if (file_exists('../languages/'.$user_language.'.mo')) { if (file_exists('../languages/'.$user_language.'.mo') === true) {
$l10n = new gettext_reader(new CachedFileReader('../languages/'.$user_language.'.mo')); $l10n = new gettext_reader(
new CachedFileReader('../languages/'.$user_language.'.mo')
);
$l10n->load_tables(); $l10n->load_tables();
} }
// Get data // Get data.
$type = (string) get_parameter('type', 'csv'); $type = (string) get_parameter('type', 'csv');
$data = (string) get_parameter('data'); $data = (string) get_parameter('data');
@ -36,10 +52,8 @@ $default_filename = 'data_exported - '.date($config['date_format']);
$filename = (string) get_parameter('filename', $default_filename); $filename = (string) get_parameter('filename', $default_filename);
$filename = io_safe_output($filename); $filename = io_safe_output($filename);
// Using first-class functions to avoid namespace conflicts
// Type: 'csv'
/* /*
$data = array( * $data = array(
* 'head' => array(<column>,<column>,...,<column>), * 'head' => array(<column>,<column>,...,<column>),
* 'data' => array( * 'data' => array(
* array(<data>,<data>,...,<data>), * array(<data>,<data>,...,<data>),
@ -49,6 +63,7 @@ $filename = io_safe_output($filename);
* ) * )
* ); * );
*/ */
$output_csv = function ($data, $filename) { $output_csv = function ($data, $filename) {
global $config; global $config;
@ -56,20 +71,22 @@ $output_csv = function ($data, $filename) {
$excel_encoding = (bool) get_parameter('excel_encoding', false); $excel_encoding = (bool) get_parameter('excel_encoding', false);
// CSV Output // CSV Output.
header('Content-Type: text/csv; charset=UTF-8'); header('Content-Type: text/csv; charset=UTF-8');
header('Content-Disposition: attachment; filename="'.$filename.'.csv"'); header('Content-Disposition: attachment; filename="'.$filename.'.csv"');
// BOM // BOM.
if (!$excel_encoding) { if ($excel_encoding === false) {
print pack('C*', 0xEF, 0xBB, 0xBF); echo pack('C*', 0xEF, 0xBB, 0xBF);
} }
// Header // Header
// Item / data // Item / data.
foreach ($data as $items) { foreach ($data as $items) {
if (!isset($items['head']) || !isset($items['data'])) { if (isset($items['head']) === false
throw new Exception(__('An error occured exporting the data')); || isset($items['data']) === false
) {
throw new Exception(__('An error occured exporting the data'));
} }
// Get key for item value. // Get key for item value.
@ -84,7 +101,7 @@ $output_csv = function ($data, $filename) {
$item = str_replace('--> '.__('Selected'), '', $item); $item = str_replace('--> '.__('Selected'), '', $item);
$line = implode($separator, $item); $line = implode($separator, $item);
if ($excel_encoding) { if ($excel_encoding === true) {
echo mb_convert_encoding($line, 'UTF-16LE', 'UTF-8')."\n"; echo mb_convert_encoding($line, 'UTF-16LE', 'UTF-8')."\n";
} else { } else {
echo $line."\n"; echo $line."\n";
@ -93,9 +110,8 @@ $output_csv = function ($data, $filename) {
} }
}; };
// Type: 'json'
/* /*
$data = array( * $data = array(
* array( * array(
* 'key' => <value>, * 'key' => <value>,
* 'key' => <value>, * 'key' => <value>,
@ -117,8 +133,9 @@ $output_csv = function ($data, $filename) {
* ) * )
* ); * );
*/ */
$output_json = function ($data, $filename) { $output_json = function ($data, $filename) {
// JSON Output // JSON Output.
header('Content-Type: application/json; charset=UTF-8'); header('Content-Type: application/json; charset=UTF-8');
header('Content-Disposition: attachment; filename="'.$filename.'.json"'); header('Content-Disposition: attachment; filename="'.$filename.'.json"');
@ -134,7 +151,7 @@ $output_json = function ($data, $filename) {
}; };
try { try {
if (!$data) { if (empty($data) === true) {
throw new Exception(__('An error occured exporting the data')); throw new Exception(__('An error occured exporting the data'));
} }

View File

@ -960,7 +960,6 @@ function pandoraFlotArea(
legend, legend,
series_type, series_type,
color, color,
water_mark,
date_array, date_array,
data_module_graph, data_module_graph,
params, params,
@ -977,7 +976,6 @@ function pandoraFlotArea(
.shift(); .shift();
var width = params.width; var width = params.width;
var vconsole = params.vconsole; var vconsole = params.vconsole;
var dashboard = params.dashboard;
var menu = params.menu; var menu = params.menu;
var min_x = date_array["start_date"] * 1000; var min_x = date_array["start_date"] * 1000;
var max_x = date_array["final_date"] * 1000; var max_x = date_array["final_date"] * 1000;
@ -2392,7 +2390,7 @@ function pandoraFlotArea(
if (series.data[j]) { if (series.data[j]) {
var y = series.data[j][1]; var y = series.data[j][1];
var x = Math.round(series.data[j][0]) - 1; var x = Math.round(series.data[j][0]);
} }
} }
@ -2799,17 +2797,6 @@ function pandoraFlotArea(
); );
adjust_menu(graph_id, plot, parent_height, width, show_legend); adjust_menu(graph_id, plot, parent_height, width, show_legend);
} }
if (!dashboard) {
if (water_mark) {
set_watermark(
graph_id,
plot,
$("#watermark_image_" + graph_id).attr("src")
);
}
//adjust_menu(graph_id, plot, parent_height, width, show_legend);
}
} }
function format_unit_yaxes(y) { function format_unit_yaxes(y) {

View File

@ -262,15 +262,17 @@ function flot_area_graph(
$params['height'] = 1; $params['height'] = 1;
} }
if (!$vconsole) { if ((bool) $params['vconsole'] === false) {
$return .= "<div id='overview_$graph_id' class='overview_graph' $return .= '<div id="overview_'.$graph_id.'" class="overview_graph" style="margin:0px; margin-top:30px; margin-bottom:50px; width:'.$params['width'].'px; height: 200px;"></div>';
style='margin:0px; margin-top:30px; margin-bottom:50px; width: ".$params['width']."px; height: 200px;'></div>"; $legend_top = 10;
if (empty($params['show_legend']) === false) {
$legend_top = (20 + (count($legend) * 18));
}
if ($water_mark != '') { if ($water_mark != '' && (bool) $params['dashboard'] === false) {
$return .= "<div id='watermark_$graph_id' style='display:none; position:absolute;'><img id='watermark_image_$graph_id' src='".$water_mark['url']."'></div>"; $return .= '<div id="watermark_'.$graph_id.'" style="position:absolute; top: '.$legend_top.'px; left: calc(100% - 100px);">';
$watermark = 'true'; $return .= '<img id="watermark_image_'.$graph_id.'" src="'.$water_mark['url'].'">';
} else { $return .= '</div>';
$watermark = 'false';
} }
} }
@ -314,7 +316,6 @@ function flot_area_graph(
$return .= $legend.", \n"; $return .= $legend.", \n";
$return .= $series_type.", \n"; $return .= $series_type.", \n";
$return .= $color.", \n"; $return .= $color.", \n";
$return .= $watermark.", \n";
$return .= $date_array.", \n"; $return .= $date_array.", \n";
$return .= $data_module_graph.", \n"; $return .= $data_module_graph.", \n";
$return .= $params.", \n"; $return .= $params.", \n";

View File

@ -35,11 +35,23 @@
$("option[value!=0]", $select).remove (); $("option[value!=0]", $select).remove ();
if (! config.callbackBefore (this)) if (! config.callbackBefore (this))
return; return;
if (typeof config.recursion === "function") {
// Perform this for those cases where recursion parameter is obtained through a function that returns a variable that is set in the lexical environment where this constructor is called.
var recursion_value = config.recursion();
if (typeof recursion_value === "boolean") {
recursion_value = recursion_value ? 1 : 0;
}
} else {
var recursion_value = config.recursion;
}
var opts = { var opts = {
"page" : "godmode/groups/group_list", "page" : "godmode/groups/group_list",
"get_group_agents" : 1, "get_group_agents" : 1,
"id_group" : this.value, "id_group" : this.value,
"recursion" : config.recursion, "recursion" : recursion_value,
"filter_agents_json" : config.filter_agents_json, "filter_agents_json" : config.filter_agents_json,
"disabled" : (typeof config.disabled === "function") "disabled" : (typeof config.disabled === "function")
? (config.disabled()) ? (config.disabled())

View File

@ -45,7 +45,7 @@ $(document).ready(function() {
jQuery.post( jQuery.post(
"ajax.php", "ajax.php",
{ {
page: "operation/messages/message_list", page: "operation/messages/message_list"
}, },
function(data, status) { function(data, status) {
$("#dialog_messages") $("#dialog_messages")
@ -58,10 +58,10 @@ $(document).ready(function() {
modal: true, modal: true,
overlay: { overlay: {
opacity: 0.5, opacity: 0.5,
background: "black", background: "black"
}, },
width: 700, width: 700,
height: 300, height: 300
}) })
.show(); .show();
}, },
@ -80,7 +80,7 @@ $(document).ready(function() {
jQuery.post( jQuery.post(
"ajax.php", "ajax.php",
{ {
page: "operation/system_alert", page: "operation/system_alert"
}, },
function(data, status) { function(data, status) {
$("#alert_messages").show(); $("#alert_messages").show();
@ -104,7 +104,7 @@ $(document).ready(function() {
"ajax.php", "ajax.php",
{ {
page: "general/alert_enterprise", page: "general/alert_enterprise",
message: elem, message: elem
}, },
function(data, status) { function(data, status) {
$("#alert_messages").show(); $("#alert_messages").show();
@ -130,7 +130,7 @@ $(document).ready(function() {
"ajax.php", "ajax.php",
{ {
page: "general/alert_enterprise", page: "general/alert_enterprise",
message: elem, message: elem
}, },
function(data, status) { function(data, status) {
$("#alert_messages").show(); $("#alert_messages").show();
@ -155,7 +155,7 @@ $(document).ready(function() {
"ajax.php", "ajax.php",
{ {
page: "general/alert_enterprise", page: "general/alert_enterprise",
message: elem, message: elem
}, },
function(data, status) { function(data, status) {
$("#alert_messages").show(); $("#alert_messages").show();
@ -190,7 +190,7 @@ $(document).ready(function() {
width: 850, width: 850,
overlay: { overlay: {
opacity: 0.5, opacity: 0.5,
background: "black", background: "black"
}, },
open: function() { open: function() {
if (hide_counter != 1) { if (hide_counter != 1) {
@ -212,7 +212,7 @@ $(document).ready(function() {
} else { } else {
$("#ok_buttom").show(); $("#ok_buttom").show();
} }
}, }
}); });
$("#submit-hide-license-error-msg").click(function() { $("#submit-hide-license-error-msg").click(function() {
@ -230,8 +230,8 @@ $(document).ready(function() {
width: 620, width: 620,
overlay: { overlay: {
opacity: 0.5, opacity: 0.5,
background: "black", background: "black"
}, }
}); });
} }
@ -244,8 +244,8 @@ $(document).ready(function() {
width: 520, width: 520,
overlay: { overlay: {
opacity: 0.5, opacity: 0.5,
background: "black", background: "black"
}, }
}); });
} }
@ -258,8 +258,8 @@ $(document).ready(function() {
width: 520, width: 520,
overlay: { overlay: {
opacity: 0.5, opacity: 0.5,
background: "black", background: "black"
}, }
}); });
} }
@ -327,7 +327,7 @@ $(document).ready(function() {
left: left:
+parseInt(screen.width / 2) - +parseInt(screen.width / 2) -
parseInt($("#alert_messages").css("width")) / 2 + parseInt($("#alert_messages").css("width")) / 2 +
"px", "px"
}); });
}); });

View File

@ -0,0 +1,96 @@
/** global $ */
function massiveOperationValidation(contents, totalCount, limit, thisForm) {
var output = false;
// If the amount of changes exceed the limit, the operation stops.
if (totalCount > limit) {
showMassiveModal(contents);
return false;
} else {
confirmDialog({
title: contents.title,
message: contents.question,
ok: contents.ok,
cancel: contents.cancel,
onAccept: function() {
showSpinner();
output = true;
$("#" + thisForm).submit();
},
onDeny: function() {
hideSpinner();
return false;
}
});
}
return output;
}
function showMassiveModal(contents) {
$("#massive_modal")
.empty()
.html(contents.html);
// Set the title.
$("#massive_modal").prop("title", contents.title);
// Build the dialog for show the mesage.
$("#massive_modal").dialog({
resizable: true,
draggable: true,
modal: true,
width: 800,
buttons: [
{
text: "OK",
click: function() {
hideSpinner();
$(this).dialog("close");
return false;
}
}
],
overlay: {
opacity: 0.5,
background: "black"
},
closeOnEscape: false,
open: function(event, ui) {
$(".ui-dialog-titlebar-close").hide();
}
});
}
/*
function showMassiveOperationMessage(message) {
$("#massive_modal")
.empty()
.html(message);
$("#massive_modal").prop("title", "Massive operations");
$("#massive_modal").dialog({
resizable: true,
draggable: true,
modal: true,
width: 800,
buttons: [
{
text: "OK",
click: function() {
$(this).dialog("close");
hideSpinner();
}
}
],
overlay: {
opacity: 0.5,
background: "black"
},
closeOnEscape: false,
open: function(event, ui) {
$(".ui-dialog-titlebar-close").hide();
}
});
}
*/

View File

@ -275,7 +275,10 @@ function agent_changed_by_multiple_agents(event, id_agent, selected) {
); );
} }
} }
jQuery.each(data, function(i, val) {
var all_common_modules = [];
$.each(data, function(i, val) {
var s = js_html_entity_decode(val); var s = js_html_entity_decode(val);
$("#module").append( $("#module").append(
@ -285,8 +288,12 @@ function agent_changed_by_multiple_agents(event, id_agent, selected) {
.attr("title", s) .attr("title", s)
); );
all_common_modules.push(i);
$("#module").fadeIn("normal"); $("#module").fadeIn("normal");
}); });
$("#hidden-all_common_modules").val(all_common_modules.toString());
if (typeof selected !== "undefined") $("#module").attr("value", selected); if (typeof selected !== "undefined") $("#module").attr("value", selected);
$("#module") $("#module")
@ -724,12 +731,14 @@ function post_process_select_init_unit(name, selected) {
); );
$("#text-" + name + "_text").val(""); $("#text-" + name + "_text").val("");
} else { } else {
$("#" + name + "_select option[value=none]").attr("selected", true); $("#" + name + "_select option[value=0]").attr("selected", true);
$("#" + name + "_default").hide(); $("#" + name + "_default").hide();
$("#" + name + "_manual").show(); $("#" + name + "_manual").show();
} }
} else { } else {
$("#" + name + "_select option[value=none]").attr("selected", true); $("#" + name + "_select option[value=0]").attr("selected", true);
$("#" + name + "_default").hide();
$("#" + name + "_manual").show();
} }
$("#" + name + "_select").change(function() { $("#" + name + "_select").change(function() {

View File

@ -1,4 +1,5 @@
var original_command = ""; /* globals $ */
function parse_alert_command(command, classs) { function parse_alert_command(command, classs) {
if (classs == "recovery") { if (classs == "recovery") {
classs = "fields_recovery"; classs = "fields_recovery";
@ -9,16 +10,20 @@ function parse_alert_command(command, classs) {
var nfield = 1; var nfield = 1;
$("." + classs).each(function() { $("." + classs).each(function() {
// Only render values different from '' // Only render values different from ''
if ($(this).val() == "") {
nfield++;
return;
}
var field = "_field" + nfield + "_"; var field = "_field" + nfield + "_";
var regex = new RegExp(field, "gi"); var regex = new RegExp(field, "gi");
console.log($(this).val());
if ($(this).css("-webkit-text-security") == "disc") { if ($(this).val() == "") {
if (
classs == "fields_recovery" &&
$($(".fields")[nfield - 1]).val() != ""
) {
command = command.replace(
regex,
"[RECOVER]" + $($(".fields")[nfield - 1]).val()
);
}
} else if ($(this).css("-webkit-text-security") == "disc") {
var hidden_character = "*"; var hidden_character = "*";
var hidden_string = hidden_character.repeat($(this).val().length); var hidden_string = hidden_character.repeat($(this).val().length);

View File

@ -70,8 +70,7 @@ function initialiceLayout(data) {
draggable: false draggable: false
}); });
var positionGrid = 0; //grid[0].getBoundingClientRect(); var positionGrid = grid.el.getBoundingClientRect();
// var gridHeight = positionGrid.height;
var gridWidth = positionGrid.width; var gridWidth = positionGrid.width;
getCellsLayout(); getCellsLayout();

View File

@ -1073,7 +1073,25 @@ var TreeController = {
$node.append($group); $node.append($group);
} }
_.each(data.tree, function(element) { // Get the main values of the tree.
var rawTree = Object.values(data.tree);
// Sorting tree by description (services.treeview_services.php).
rawTree.sort(function(a, b) {
// Only the services are ordered since only they have the elementDescription property.
if (a.elementDescription && b.elementDescription) {
var x = a.elementDescription.toLowerCase();
var y = b.elementDescription.toLowerCase();
if (x < y) {
return -1;
}
if (x > y) {
return 1;
}
}
return 0;
});
_.each(rawTree, function(element) {
element.jqObject = _processNode($group, element); element.jqObject = _processNode($group, element);
}); });

View File

@ -571,9 +571,9 @@ class Widget
} }
if ($this->width === 0) { if ($this->width === 0) {
$width = (((int) $this->position['width'] / 12 * $gridWidth) - 50); $width = (((int) $this->position['width'] / 12 * $gridWidth) - 60);
} else { } else {
$width = (((int) $this->width / 12 * $gridWidth) - 50); $width = (((int) $this->width / 12 * $gridWidth) - 60);
} }
if ($this->height === 0) { if ($this->height === 0) {

View File

@ -366,11 +366,10 @@ class CustomGraphWidget extends Widget
); );
$hackLegendHight = (30 * count($sources)); $hackLegendHight = (30 * count($sources));
if ($hackLegendHight < ($size['height'] - 10 - $hackLegendHight)) { if ($hackLegendHight > ($size['height'] - 10 - $hackLegendHight)) {
$height = ($size['height'] - 10 - $hackLegendHight); $height = ($size['height'] - $hackLegendHight);
} else { } else {
$height = ($size['height'] - 10); $height = ($size['height'] - 10);
$this->values['showLegend'] = 0;
} }
} else { } else {
$height = ($size['height'] - 10); $height = ($size['height'] - 10);
@ -396,6 +395,11 @@ class CustomGraphWidget extends Widget
break; break;
} }
// Not posible height < 0.
if ($height <= 0) {
$height = 10;
}
$params = [ $params = [
'period' => $this->values['period'], 'period' => $this->values['period'],
'width' => ($size['width'] - 10), 'width' => ($size['width'] - 10),
@ -407,6 +411,7 @@ class CustomGraphWidget extends Widget
'menu' => false, 'menu' => false,
'show_legend' => $this->values['showLegend'], 'show_legend' => $this->values['showLegend'],
'vconsole' => true, 'vconsole' => true,
'dashboard' => true,
]; ];
$params_combined = [ $params_combined = [

View File

@ -372,32 +372,54 @@ class MapsMadeByUser extends Widget
// it is necessary to modify specific classes of each // it is necessary to modify specific classes of each
// of the visual consoles. // of the visual consoles.
$output .= '<style type="text/css">'; $output .= '<style type="text/css">';
$output .= '.c-'.$uniq.', .c-'.$uniq.' *:not(.parent_graph p table tr td span) { font-size: '.(8 * $ratio_t).'pt; line-height:'.(8 * ($ratio_t) * 1.5).'pt; }'; // $output .= '.c-'.$uniq.', .c-'.$uniq.' *:not(.parent_graph p table tr td span) { font-size: '.(8 * $ratio_t).'pt; line-height:'.(8 * ($ratio_t) * 1.5).'pt; }';
$output .= '.c-'.$uniq.' .visual-console-item-label table tr td span { font-size: '.(4 * $ratio_t).'pt; line-height:'.(4 * $ratio_t * 1.8).'pt; }'; $output .= '.c-'.$uniq.' .visual-console-item div.label > strong { font-size: '.(8 * $ratio_t).'pt; line-height:'.(8 * ($ratio_t) * 1.5).'pt;}';
$output .= '.c-'.$uniq.' .visual_font_size_4pt, .c-'.$uniq.' .visual_font_size_4pt * { font-size: '.(4 * $ratio_t).'pt; line-height:'.(4 * ($ratio_t) * 1.8).'pt; }'; $output .= '.c-'.$uniq.' .visual-console-item div.label > strong > span { font-size: '.(10 * $ratio_t).'pt;}';
$output .= '.c-'.$uniq.' .visual_font_size_6pt, .c-'.$uniq.' .visual_font_size_6pt * { font-size: '.(6 * $ratio_t).'pt; line-height:'.(6 * ($ratio_t) * 1.8).'pt; }'; $output .= '.c-'.$uniq.' .visual-console-item div.label p { overflow:initial !important; margin:0px;}';
$output .= '.c-'.$uniq.' .visual_font_size_8pt, .c-'.$uniq.' .visual_font_size_8pt * { font-size: '.(8 * $ratio_t).'pt; line-height:'.(8 * ($ratio_t) * 1.8).'pt; }'; $output .= '.c-'.$uniq.' .visual-console-item div.label img { height: 100%; width: 100%; object-fit: contain;}';
$output .= '.c-'.$uniq.' .visual_font_size_10pt, .c-'.$uniq.' .visual_font_size_10pt * { font-size: '.(10 * $ratio_t).'pt; line-height:'.(10 * ($ratio_t) * 1.8).'pt; }'; $output .= '.c-'.$uniq.' .visual_font_size_4pt, .c-'.$uniq.' .visual_font_size_4pt * { font-size: '.(4 * $ratio_t).'pt !important; line-height:'.(4 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual_font_size_12pt, .c-'.$uniq.' .visual_font_size_12pt * { font-size: '.(12 * $ratio_t).'pt; line-height:'.(12 * ($ratio_t) * 1.8).'pt; }'; $output .= '.c-'.$uniq.' .visual_font_size_6pt, .c-'.$uniq.' .visual_font_size_6pt * { font-size: '.(6 * $ratio_t).'pt !important; line-height:'.(6 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual_font_size_14pt, .c-'.$uniq.' .visual_font_size_14pt * { font-size: '.(14 * $ratio_t).'pt; line-height:'.(14 * ($ratio_t) * 1.8).'pt; }'; $output .= '.c-'.$uniq.' .visual_font_size_8pt, .c-'.$uniq.' .visual_font_size_8pt * { font-size: '.(8 * $ratio_t).'pt !important; line-height:'.(8 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual_font_size_18pt, .c-'.$uniq.' .visual_font_size_18pt * { font-size: '.(18 * $ratio_t).'pt; line-height:'.(18 * ($ratio_t) * 1.8).'pt; }'; $output .= '.c-'.$uniq.' .visual_font_size_10pt, .c-'.$uniq.' .visual_font_size_10pt * { font-size: '.(10 * $ratio_t).'pt !important; line-height:'.(10 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual_font_size_24pt, .c-'.$uniq.' .visual_font_size_24pt * { font-size: '.(24 * $ratio_t).'pt; line-height:'.(24 * ($ratio_t) * 1.8).'pt; }'; $output .= '.c-'.$uniq.' .visual_font_size_12pt, .c-'.$uniq.' .visual_font_size_12pt * { font-size: '.(12 * $ratio_t).'pt !important; line-height:'.(12 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual_font_size_28pt, .c-'.$uniq.' .visual_font_size_28pt * { font-size: '.(28 * $ratio_t).'pt; line-height:'.(28 * ($ratio_t) * 1.8).'pt; }'; $output .= '.c-'.$uniq.' .visual_font_size_14pt, .c-'.$uniq.' .visual_font_size_14pt * { font-size: '.(14 * $ratio_t).'pt !important; line-height:'.(14 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual_font_size_36pt, .c-'.$uniq.' .visual_font_size_36pt * { font-size: '.(36 * $ratio_t).'pt; line-height:'.(36 * ($ratio_t) * 1.8).'pt; }'; $output .= '.c-'.$uniq.' .visual_font_size_18pt, .c-'.$uniq.' .visual_font_size_18pt * { font-size: '.(18 * $ratio_t).'pt !important; line-height:'.(18 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual_font_size_48pt, .c-'.$uniq.' .visual_font_size_48pt * { font-size: '.(48 * $ratio_t).'pt; line-height:'.(48 * ($ratio_t) * 1.8).'pt; }'; $output .= '.c-'.$uniq.' .visual_font_size_24pt, .c-'.$uniq.' .visual_font_size_24pt * { font-size: '.(24 * $ratio_t).'pt !important; line-height:'.(24 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual_font_size_60pt, .c-'.$uniq.' .visual_font_size_60pt * { font-size: '.(60 * $ratio_t).'pt; line-height:'.(60 * ($ratio_t) * 1.8).'pt; }'; $output .= '.c-'.$uniq.' .visual_font_size_28pt, .c-'.$uniq.' .visual_font_size_28pt * { font-size: '.(28 * $ratio_t).'pt !important; line-height:'.(28 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual_font_size_72pt, .c-'.$uniq.' .visual_font_size_72pt * { font-size: '.(72 * $ratio_t).'pt; line-height:'.(72 * ($ratio_t) * 1.8).'pt; }'; $output .= '.c-'.$uniq.' .visual_font_size_36pt, .c-'.$uniq.' .visual_font_size_36pt * { font-size: '.(36 * $ratio_t).'pt !important; line-height:'.(36 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual_font_size_84pt, .c-'.$uniq.' .visual_font_size_84pt * { font-size: '.(84 * $ratio_t).'pt; line-height:'.(84 * ($ratio_t) * 1.8).'pt; }'; $output .= '.c-'.$uniq.' .visual_font_size_48pt, .c-'.$uniq.' .visual_font_size_48pt * { font-size: '.(48 * $ratio_t).'pt !important; line-height:'.(48 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual_font_size_96pt, .c-'.$uniq.' .visual_font_size_96pt * { font-size: '.(96 * $ratio_t).'pt; line-height:'.(96 * ($ratio_t) * 1.8).'pt; }'; $output .= '.c-'.$uniq.' .visual_font_size_60pt, .c-'.$uniq.' .visual_font_size_60pt * { font-size: '.(60 * $ratio_t).'pt !important; line-height:'.(60 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual_font_size_116pt, .c-'.$uniq.' .visual_font_size_116pt * { font-size: '.(116 * $ratio_t).'pt; line-height:'.(116 * ($ratio_t) * 1.8).'pt; }'; $output .= '.c-'.$uniq.' .visual_font_size_72pt, .c-'.$uniq.' .visual_font_size_72pt * { font-size: '.(72 * $ratio_t).'pt !important; line-height:'.(72 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual_font_size_128pt, .c-'.$uniq.' .visual_font_size_128pt * { font-size: '.(128 * $ratio_t).'pt; line-height:'.(128 * ($ratio_t) * 1.8).'pt; }'; $output .= '.c-'.$uniq.' .visual_font_size_84pt, .c-'.$uniq.' .visual_font_size_84pt * { font-size: '.(84 * $ratio_t).'pt !important; line-height:'.(84 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual_font_size_140pt, .c-'.$uniq.' .visual_font_size_140pt * { font-size: '.(140 * $ratio_t).'pt; line-height:'.(140 * ($ratio_t) * 1.8).'pt; }'; $output .= '.c-'.$uniq.' .visual_font_size_96pt, .c-'.$uniq.' .visual_font_size_96pt * { font-size: '.(96 * $ratio_t).'pt !important; line-height:'.(96 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual_font_size_154pt, .c-'.$uniq.' .visual_font_size_154pt * { font-size: '.(154 * $ratio_t).'pt; line-height:'.(154 * ($ratio_t) * 1.8).'pt; }'; $output .= '.c-'.$uniq.' .visual_font_size_116pt, .c-'.$uniq.' .visual_font_size_116pt * { font-size: '.(116 * $ratio_t).'pt !important; line-height:'.(116 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual_font_size_196pt, .c-'.$uniq.' .visual_font_size_196pt * { font-size: '.(196 * $ratio_t).'pt; line-height:'.(196 * ($ratio_t) * 1.8).'pt; }'; $output .= '.c-'.$uniq.' .visual_font_size_128pt, .c-'.$uniq.' .visual_font_size_128pt * { font-size: '.(128 * $ratio_t).'pt !important; line-height:'.(128 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual_font_size_140pt, .c-'.$uniq.' .visual_font_size_140pt * { font-size: '.(140 * $ratio_t).'pt !important; line-height:'.(140 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual_font_size_154pt, .c-'.$uniq.' .visual_font_size_154pt * { font-size: '.(154 * $ratio_t).'pt !important; line-height:'.(154 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual_font_size_196pt, .c-'.$uniq.' .visual_font_size_196pt * { font-size: '.(196 * $ratio_t).'pt !important; line-height:'.(196 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual-console-item-label table tr td p { overflow:initial !important; margin:0px; font-size: '.(10 * $ratio_t).'pt !important; line-height:'.(10 * $ratio_t * 1.5).'pt !important;}';
$output .= '.c-'.$uniq.' .visual-console-item-label table tr td span { font-size: '.(10 * $ratio_t).'pt !important; line-height:'.(10 * $ratio_t * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_4pt, .c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_4pt * { font-size: '.(4 * $ratio_t).'pt !important; line-height:'.(4 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_6pt, .c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_6pt * { font-size: '.(6 * $ratio_t).'pt !important; line-height:'.(6 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_8pt, .c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_8pt * { font-size: '.(8 * $ratio_t).'pt !important; line-height:'.(8 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_10pt, .c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_10pt * { font-size: '.(10 * $ratio_t).'pt !important; line-height:'.(10 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_12pt, .c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_12pt * { font-size: '.(12 * $ratio_t).'pt !important; line-height:'.(12 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_14pt, .c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_14pt * { font-size: '.(14 * $ratio_t).'pt !important; line-height:'.(14 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_18pt, .c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_18pt * { font-size: '.(18 * $ratio_t).'pt !important; line-height:'.(18 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_24pt, .c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_24pt * { font-size: '.(24 * $ratio_t).'pt !important; line-height:'.(24 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_28pt, .c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_28pt * { font-size: '.(28 * $ratio_t).'pt !important; line-height:'.(28 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_36pt, .c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_36pt * { font-size: '.(36 * $ratio_t).'pt !important; line-height:'.(36 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_48pt, .c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_48pt * { font-size: '.(48 * $ratio_t).'pt !important; line-height:'.(48 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_60pt, .c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_60pt * { font-size: '.(60 * $ratio_t).'pt !important; line-height:'.(60 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_72pt, .c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_72pt * { font-size: '.(72 * $ratio_t).'pt !important; line-height:'.(72 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_84pt, .c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_84pt * { font-size: '.(84 * $ratio_t).'pt !important; line-height:'.(84 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_96pt, .c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_96pt * { font-size: '.(96 * $ratio_t).'pt !important; line-height:'.(96 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_116pt, .c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_116pt * { font-size: '.(116 * $ratio_t).'pt !important; line-height:'.(116 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_128pt, .c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_128pt * { font-size: '.(128 * $ratio_t).'pt !important; line-height:'.(128 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_140pt, .c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_140pt * { font-size: '.(140 * $ratio_t).'pt !important; line-height:'.(140 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_154pt, .c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_154pt * { font-size: '.(154 * $ratio_t).'pt !important; line-height:'.(154 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_196pt, .c-'.$uniq.' .visual-console-item-label table tr td span.visual_font_size_196pt * { font-size: '.(196 * $ratio_t).'pt !important; line-height:'.(196 * ($ratio_t) * 1.5).'pt !important; }';
$output .= '.c-'.$uniq.' .flot-text, .c-'.$uniq.' .flot-text * { font-size: '.(8 * $ratio_t).'pt !important; line-height:'.(8 * ($ratio_t)).'pt !important; }'; $output .= '.c-'.$uniq.' .flot-text, .c-'.$uniq.' .flot-text * { font-size: '.(8 * $ratio_t).'pt !important; line-height:'.(8 * ($ratio_t)).'pt !important; }';
$output .= '.c-'.$uniq.' .visual-console-item .digital-clock span.time {font-size: '.(50 * $ratio_t).'px !important; line-height: '.(50 * $ratio_t).'px !important;}';
$output .= '.c-'.$uniq.' .visual-console-item .digital-clock span.date {font-size: '.(25 * $ratio_t).'px !important; line-height: '.(25 * $ratio_t).'px !important;}';
$output .= '.c-'.$uniq.' .visual-console-item .digital-clock span.timezone {font-size: '.(25 * $ratio_t).'px !important; line-height: '.(25 * $ratio_t).'px !important;}';
$output .= '.c-'.$uniq.' .visual-console-item .donut-graph * {font-size: '.(8 * $ratio_t).'px !important; line-height: '.(8 * $ratio_t).'px !important;}'; $output .= '.c-'.$uniq.' .visual-console-item .donut-graph * {font-size: '.(8 * $ratio_t).'px !important; line-height: '.(8 * $ratio_t).'px !important;}';
$output .= '.c-'.$uniq.' .visual-console-item .donut-graph g rect {width:'.(25 * $ratio_t).' !important; height: '.(15 * $ratio_t).' !important;}'; $output .= '.c-'.$uniq.' .visual-console-item .donut-graph g rect {width:'.(25 * $ratio_t).' !important; height: '.(15 * $ratio_t).' !important;}';
$output .= '</style>'; $output .= '</style>';

View File

@ -373,6 +373,7 @@ class SingleGraphWidget extends Widget
'show_legend' => $this->values['showLegend'], 'show_legend' => $this->values['showLegend'],
'show_title' => $module_name, 'show_title' => $module_name,
'menu' => false, 'menu' => false,
'dashboard' => true,
]; ];
$output = '<div class="container-center">'; $output = '<div class="container-center">';

View File

@ -207,7 +207,7 @@ class Module extends Entity
if (is_numeric($id_agent_module) === true if (is_numeric($id_agent_module) === true
&& $id_agent_module > 0 && $id_agent_module > 0
) { ) {
if ($nodeId !== null) { if ($nodeId > 0) {
$this->nodeId = $nodeId; $this->nodeId = $nodeId;
} }
@ -1022,12 +1022,13 @@ class Module extends Entity
/** /**
* Calculates cascade protection service value for this service. * Calculates cascade protection service value for this service.
* *
* @param integer|null $id_node Meta searching node will use this field. * @param integer|null $id_node Meta searching node will use this field.
* @param boolean $connected Connected to a node.
* *
* @return integer CPS value. * @return integer CPS value.
* @throws \Exception On error. * @throws \Exception On error.
*/ */
public function calculateCPS(?int $id_node=null) public function calculateCPS(?int $id_node=null, bool $connected=false)
{ {
if ($this->cps() < 0) { if ($this->cps() < 0) {
return $this->cps(); return $this->cps();
@ -1047,6 +1048,7 @@ class Module extends Entity
// Here could happen 2 things. // Here could happen 2 things.
// 1. Metaconsole service is using this method impersonating node DB. // 1. Metaconsole service is using this method impersonating node DB.
// 2. Node service is trying to find parents into metaconsole. // 2. Node service is trying to find parents into metaconsole.
// 3. Impersonated node searching metaconsole.
if (empty($id_node) === true if (empty($id_node) === true
&& is_metaconsole() === false && is_metaconsole() === false
&& has_metaconsole() === true && has_metaconsole() === true
@ -1119,6 +1121,38 @@ class Module extends Entity
if ($r !== NOERR) { if ($r !== NOERR) {
throw new \Exception(__('Cannot connect to node %d', $r)); throw new \Exception(__('Cannot connect to node %d', $r));
} }
} else if (is_metaconsole() === true
// True in impersonated nodes.
&& has_metaconsole() === false
&& empty($id_node) === true
) {
// Impersonated node checking metaconsole.
\enterprise_hook('metaconsole_restore_db');
$mc_parents = db_get_all_rows_sql(
sprintf(
'SELECT id_service,
cps,
cascade_protection,
name
FROM `tservice_element` te
INNER JOIN `tservice` t ON te.id_service = t.id
WHERE te.id_agente_modulo = %d',
$this->id_agente_modulo()
),
false,
false
);
// Restore impersonation.
\enterprise_include_once('include/functions_metaconsole.php');
$r = \enterprise_hook(
'metaconsole_connect',
[
null,
$id_node,
]
);
} }
$cps = 0; $cps = 0;

View File

@ -922,7 +922,8 @@ class Item extends CachedModel
// Can't fetch an agent with an invalid Id. // Can't fetch an agent with an invalid Id.
$agentId = static::extractAgentId($itemData); $agentId = static::extractAgentId($itemData);
if ($agentId === null) { if ($agentId === null) {
throw new \InvalidArgumentException('invalid agent Id'); $agentId = 0;
// throw new \InvalidArgumentException('invalid agent Id');
} }
// Staticgraph don't need to have an agent. // Staticgraph don't need to have an agent.
@ -956,7 +957,8 @@ class Item extends CachedModel
$agent = \db_get_row_sql($sql); $agent = \db_get_row_sql($sql);
if ($agent === false) { if ($agent === false) {
throw new \Exception('error fetching the data from the DB'); return $agentData;
// throw new \Exception('error fetching the data from the DB');
} }
// The agent name should be a valid string or a null value. // The agent name should be a valid string or a null value.
@ -996,7 +998,8 @@ class Item extends CachedModel
// Can't fetch an module with a invalid Id. // Can't fetch an module with a invalid Id.
$moduleId = static::extractModuleId($itemData); $moduleId = static::extractModuleId($itemData);
if ($moduleId === null) { if ($moduleId === null) {
throw new \InvalidArgumentException('invalid module Id'); $moduleId = 0;
// throw new \InvalidArgumentException('invalid module Id');
} }
// Staticgraph don't need to have a module. // Staticgraph don't need to have a module.
@ -1037,7 +1040,8 @@ class Item extends CachedModel
} }
if ($moduleName === false) { if ($moduleName === false) {
throw new \Exception('error fetching the data from the DB'); return $moduleData;
// throw new \Exception('error fetching the data from the DB');
} }
$moduleData['moduleName'] = $moduleName['nombre']; $moduleData['moduleName'] = $moduleName['nombre'];

View File

@ -400,11 +400,48 @@ final class Clock extends Item
} }
if (isset($values['height']) === false) { if (isset($values['height']) === false) {
$values['height'] = 100; $values['height'] = 50;
} }
return $values; return $values;
} }
/**
* Fetch a vc item data structure from the database using a filter.
*
* @param array $filter Filter of the Visual Console Item.
*
* @return array The Visual Console Item data structure stored into the DB.
* @throws \InvalidArgumentException When an agent Id cannot be found.
*
* @override Item::fetchDataFromDB.
*/
protected static function fetchDataFromDB(
array $filter,
?float $ratio=0
): array {
// Due to this DB call, this function cannot be unit tested without
// a proper mock.
$data = parent::fetchDataFromDB($filter, $ratio);
// Default values.
if ((int) $data['width'] === 0) {
$data['width'] = 100;
if ($ratio != 0) {
$data['width'] *= $ratio;
}
}
if ((int) $data['height'] === 0) {
$data['height'] = 50;
if ($ratio != 0) {
$data['height'] *= $ratio;
}
}
return $data;
}
} }

View File

@ -73,6 +73,7 @@ final class EventsHistory extends Item
* Fetch a vc item data structure from the database using a filter. * Fetch a vc item data structure from the database using a filter.
* *
* @param array $filter Filter of the Visual Console Item. * @param array $filter Filter of the Visual Console Item.
* @param float $ratio Ratio visual console in dashboards.
* *
* @return array The Visual Console Item data structure stored into the DB. * @return array The Visual Console Item data structure stored into the DB.
* @throws \InvalidArgumentException When an agent Id cannot be found. * @throws \InvalidArgumentException When an agent Id cannot be found.
@ -107,8 +108,15 @@ final class EventsHistory extends Item
if ((int) $data['width'] === 0 && (int) $data['height'] === 0) { if ((int) $data['width'] === 0 && (int) $data['height'] === 0) {
$data['width'] = 420; $data['width'] = 420;
$data['height'] = 80; $data['height'] = 80;
if ($ratio != 0) {
$data['width'] = ($data['width'] * $ratio);
$data['height'] = ($data['height'] * $ratio);
}
} }
$data['height'] = ($data['height'] - 20);
if ((int) $data['width'] < 11) { if ((int) $data['width'] < 11) {
$data['width'] = 11; $data['width'] = 11;
} }
@ -117,18 +125,31 @@ final class EventsHistory extends Item
$data['height'] = 11; $data['height'] = 11;
} }
// Use the same HTML output as the old VC. if (empty($moduleId) === true) {
$html = \graph_graphic_moduleevents( $html = \graph_graphic_agentevents(
$agentId, $agentId,
$moduleId, 100,
100, (int) $data['height'],
((int) $data['height'] - 20), static::extractMaxTime($data),
static::extractMaxTime($data), '',
'', true,
true, false,
1, 500
$data['width'] );
); } else {
// Use the same HTML output as the old VC.
$html = \graph_graphic_moduleevents(
$agentId,
$moduleId,
100,
(int) $data['height'],
static::extractMaxTime($data),
'',
true,
1,
$data['width']
);
}
$data['html'] = $html; $data['html'] = $html;
@ -204,7 +225,7 @@ final class EventsHistory extends Item
'return' => true, 'return' => true,
'module_input' => true, 'module_input' => true,
'module_name' => 'moduleId', 'module_name' => 'moduleId',
'module_none' => false, 'module_none' => true,
], ],
]; ];
@ -220,6 +241,8 @@ final class EventsHistory extends Item
'sort' => false, 'sort' => false,
'agent_id' => $values['agentId'], 'agent_id' => $values['agentId'],
'metaconsole_id' => $values['metaconsoleId'], 'metaconsole_id' => $values['metaconsoleId'],
'nothing' => '--',
'nothing_value' => 0,
], ],
]; ];

View File

@ -218,8 +218,13 @@ final class StaticGraph extends Item
if ($width === 0 || $height === 0) { if ($width === 0 || $height === 0) {
if (isset($imagePath) && $imagePath !== false) { if (isset($imagePath) && $imagePath !== false) {
$sizeImage = getimagesize($config['homedir'].'/'.$imagePath); $sizeImage = getimagesize($config['homedir'].'/'.$imagePath);
$data['width'] = $sizeImage[0]; if ($ratio != 0) {
$data['height'] = $sizeImage[1]; $data['width'] = ($sizeImage[0] * $ratio);
$data['height'] = ($sizeImage[1] * $ratio);
} else {
$data['width'] = $sizeImage[0];
$data['height'] = $sizeImage[1];
}
} }
} }

Some files were not shown because too many files have changed in this diff Show More