ICMP (pings),
SNMP (detecting the topology of networks and their interfaces), and other customized
@@ -33,8 +33,8 @@ ui_require_css_file('firts_task');
);
?>
-
diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php
index 846f20677b..e35d401502 100644
--- a/pandora_console/general/header.php
+++ b/pandora_console/general/header.php
@@ -1,5 +1,4 @@
cellspacing = 0;
$table->head = [];
$table->data = [];
- $table->style[0] = $table->style['clippy'] = $table->style[1] = $table->style[3] = $table->style[4] = $table->style[5] = $table->style[6] = $table->style[8] = $table->style[9] = $table->style['qr'] = 'width: 22px; text-align:center; height: 22px; padding-right: 9px;padding-left: 9px;';
+ $table->style['clippy'] = $table->style[1] = $table->style[4] = $table->style[5] = $table->style[6] = $table->style[8] = $table->style[9] = $table->style['qr'] = $table->style['notifications'] = 'width: 22px; text-align:center; height: 22px; padding-right: 9px;padding-left: 9px;';
$table->style[7] = 'width: 20px; padding-right: 9px;';
$table->style['searchbar'] = 'width: 180px; min-width: 180px;';
$table->style[11] = 'padding-left: 10px; padding-right: 5px;width: 16px;';
@@ -110,27 +110,6 @@ config_check();
$table->data[0]['searchbar'] = $search_bar;
}
- // Servers check
- $servers = [];
- $servers['all'] = (int) db_get_value('COUNT(id_server)', 'tserver');
- $servers['up'] = (int) servers_check_status();
- $servers['down'] = ($servers['all'] - $servers['up']);
- if ($servers['up'] == 0) {
- // All Servers down or no servers at all
- $servers_check_img = html_print_image('images/header_down.png', true, ['alt' => 'cross', 'class' => 'bot', 'title' => __('All systems').': '.__('Down')]);
- } else if ($servers['down'] != 0) {
- // Some servers down
- $servers_check_img = html_print_image('images/header_warning.png', true, ['alt' => 'error', 'class' => 'bot', 'title' => $servers['down'].' '.__('servers down')]);
- } else {
- // All servers up
- $servers_check_img = html_print_image('images/header_ready.png', true, ['alt' => 'ok', 'class' => 'bot', 'title' => __('All systems').': '.__('Ready')]);
- }
-
- unset($servers);
- // Since this is the header, we don't like to trickle down variables.
- $servers_link_open = '';
- $servers_link_close = '';
-
if ($config['show_qr_code_header'] == 0) {
$show_qr_code_header = 'display: none;';
} else {
@@ -175,12 +154,6 @@ config_check();
).'';
}
-
- $table->data[0][0] = $servers_link_open.$servers_check_img.$servers_link_close;
-
-
-
-
// ======= Autorefresh code =============================
$autorefresh_txt = '';
$autorefresh_additional = '';
@@ -254,57 +227,8 @@ config_check();
$table->data[0][1] = $autorefresh_link_open_img.$autorefresh_img.$autorefresh_link_close;
$table->data[0][2] = $autorefresh_link_open_txt.$autorefresh_txt.$autorefresh_link_close.$autorefresh_additional;
// ======================================================
- $check_minor_release_available = false;
$pandora_management = check_acl($config['id_user'], 0, 'PM');
- $check_minor_release_available = db_check_minor_relase_available();
-
- if ($check_minor_release_available) {
- if (users_is_admin($config['id_user'])) {
- if ($config['language'] == 'es') {
- set_pandora_error_for_header('Hay una o mas revisiones menores en espera para ser actualizadas. '.__('Sobre actualización de revisión menor').'', 'Revisión/es menor/es disponible/s');
- } else {
- set_pandora_error_for_header('There are one or more minor releases waiting for update. '.__('About minor release update').'', 'minor release/s available');
- }
- }
- }
-
- echo '';
-
- if ($config['alert_cnt'] > 0) {
- $maintenance_link = 'javascript:';
- $maintenance_title = __('System alerts detected - Please fix as soon as possible');
- $maintenance_class = $maintenance_id = 'show_systemalert_dialog white';
-
- $maintenance_link_open_txt = '';
- $maintenance_link_open_img = '';
- $maintenance_link_close = '';
- if (!$pandora_management) {
- $maintenance_img = '';
- } else {
- $maintenance_img = $maintenance_link_open_img.html_print_image(
- 'images/header_yellow.png',
- true,
- [
- 'title' => __(
- 'You have %d warning(s)',
- $config['alert_cnt']
- ),
- 'id' => 'yougotalert',
- 'class' => 'bot',
- ]
- ).$maintenance_link_close;
- }
- } else {
- if (!$pandora_management) {
- $maintenance_img = '';
- } else {
- $maintenance_img = html_print_image('images/header_ready.png', true, ['title' => __('There are not warnings'), 'id' => 'yougotalert', 'class' => 'bot']);
- }
- }
-
- $table->data[0][3] = $maintenance_img;
-
// Main help icon
if (!$config['disable_help']) {
$table->data[0][4] = ''.html_print_image(
@@ -318,6 +242,12 @@ config_check();
).'';
}
+ $notifications_numbers = notifications_get_counters();
+ $table->data[0]['notifications'] = notifications_print_ball(
+ $notifications_numbers['notifications'],
+ $notifications_numbers['last_id']
+ );
+
// Logout
$table->data[0][5] = '';
$table->data[0][5] .= html_print_image('images/header_logout.png', true, ['alt' => __('Logout'), 'class' => 'bot', 'title' => __('Logout')]);
@@ -341,18 +271,6 @@ config_check();
$table->data[0][8] .= '';
$table->data[0][8] .= '';
- // Messages
- $msg_cnt = messages_get_count($config['id_user']);
- if ($msg_cnt > 0) {
- echo '';
-
- $table->data[0][9] = '';
- $table->data[0][9] .= html_print_image('images/header_email.png', true, ['title' => __('You have %d unread message(s)', $msg_cnt), 'id' => 'yougotmail', 'class' => 'bot', 'style' => 'width:24px;']);
- $table->data[0][9] .= '';
- }
-
-
-
html_print_table($table);
unset($table);
@@ -373,6 +291,9 @@ config_check();
+
+
+
+
\ No newline at end of file
diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php
index 5b3a91d0d7..9c10099042 100644
--- a/pandora_console/godmode/agentes/configurar_agente.php
+++ b/pandora_console/godmode/agentes/configurar_agente.php
@@ -159,8 +159,8 @@ $module_macros = [];
// Create agent
if ($create_agent) {
$mssg_warning = 0;
- $alias_safe_output = io_safe_output(get_parameter("alias",""));
- $alias = io_safe_input(trim (preg_replace('/[\/\\\|%#&$-]/', '', $alias_safe_output)));
+ $alias_safe_output = io_safe_output(get_parameter('alias', ''));
+ $alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$-]/', '', $alias_safe_output)));
$alias_as_name = (int) get_parameter_post('alias_as_name', 0);
$direccion_agente = (string) get_parameter_post('direccion', '');
$unique_ip = (int) get_parameter_post('unique_ip', 0);
@@ -765,8 +765,8 @@ if ($update_agent) {
$mssg_warning = 0;
$id_agente = (int) get_parameter_post('id_agente');
$nombre_agente = str_replace('`', '‘', (string) get_parameter_post('agente', ''));
- $alias_safe_output = io_safe_output(get_parameter("alias",""));
- $alias = io_safe_input(trim (preg_replace('/[\/\\\|%#&$-]/', '', $alias_safe_output)));
+ $alias_safe_output = io_safe_output(get_parameter('alias', ''));
+ $alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$-]/', '', $alias_safe_output)));
$alias_as_name = (int) get_parameter_post('alias_as_name', 0);
$direccion_agente = (string) get_parameter_post('direccion', '');
$unique_ip = (int) get_parameter_post('unique_ip', 0);
diff --git a/pandora_console/godmode/agentes/status_monitor_custom_fields.php b/pandora_console/godmode/agentes/status_monitor_custom_fields.php
index 2c82c1e4f7..7e9ae48bdd 100644
--- a/pandora_console/godmode/agentes/status_monitor_custom_fields.php
+++ b/pandora_console/godmode/agentes/status_monitor_custom_fields.php
@@ -4,27 +4,27 @@
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
-
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
-
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-
global $config;
-check_login ();
+check_login();
-if (! check_acl ($config['id_user'], 0, 'AR')
- && ! check_acl ($config['id_user'], 0, 'AW') &&
- ! check_acl ($config['id_user'], 0, 'AM')) {
- db_pandora_audit('ACL Violation',
- 'Trying to access Agent Management');
- require ('general/noaccess.php');
- return;
+if (! check_acl($config['id_user'], 0, 'AR')
+ && ! check_acl($config['id_user'], 0, 'AW')
+ && ! check_acl($config['id_user'], 0, 'AM')
+) {
+ db_pandora_audit(
+ 'ACL Violation',
+ 'Trying to access Agent Management'
+ );
+ include 'general/noaccess.php';
+ return;
}
$update = get_parameter('upd_button', '');
@@ -32,81 +32,94 @@ $default = (int) get_parameter('default', 0);
if ($default != 0) {
- $fields_selected = explode (',', $config['status_monitor_fields']);
-}
-else if ($update != '') {
- $fields_selected = (array)get_parameter('fields_selected');
-
- if ($fields_selected[0] == '') {
- $fields_selected = explode (',', $config['status_monitor_fields']);
- }
- else {
- $status_monitor_fields = implode (',', $fields_selected);
- }
-
- $values = array(
- 'token' => 'status_monitor_fields',
- 'value' => $status_monitor_fields
- );
+ $fields_selected = explode(',', $config['status_monitor_fields']);
+} else if ($update != '') {
+ $fields_selected = (array) get_parameter('fields_selected');
- //update 'status_monitor_fields' in tconfig table to keep the value at update.
- $result = db_process_sql_update('tconfig', $values,
- array ('token' => 'status_monitor_fields'));
+ if ($fields_selected[0] == '') {
+ $fields_selected = explode(',', $config['status_monitor_fields']);
+ } else {
+ $status_monitor_fields = implode(',', $fields_selected);
+ }
- ui_print_result_message ($result, __('Successfully updated'), __('Could not be updated'));
+ $values = [
+ 'token' => 'status_monitor_fields',
+ 'value' => $status_monitor_fields,
+ ];
- $config['status_monitor_fields'] = $status_monitor_fields;
+ // update 'status_monitor_fields' in tconfig table to keep the value at update.
+ $result = db_process_sql_update(
+ 'tconfig',
+ $values,
+ ['token' => 'status_monitor_fields']
+ );
+
+ ui_print_result_message($result, __('Successfully updated'), __('Could not be updated'));
+
+ $config['status_monitor_fields'] = $status_monitor_fields;
}
-$fields_selected = array();
+$fields_selected = [];
$status_monitor_fields = '';
-$fields_selected = explode (',', $config['status_monitor_fields']);
+$fields_selected = explode(',', $config['status_monitor_fields']);
-$result_selected = array();
+$result_selected = [];
-//show list of fields selected.
-if ($fields_selected[0]!='') {
- foreach ($fields_selected as $field_selected) {
- switch ($field_selected) {
- case 'policy':
- $result = __('Policy');
- break;
- case 'agent':
- $result = __('Agent');
- break;
- case 'data_type':
- $result = __('Data type');
- break;
- case 'module_name':
- $result = __('Module name');
- break;
- case 'server_type':
- $result = __('Server type');
- break;
- case 'interval':
- $result = __('Interval');
- break;
- case 'status':
- $result = __('Status');
- break;
- case 'graph':
- $result = __('Graph');
- break;
- case 'warn':
- $result = __('Warn');
- break;
- case 'data':
- $result = __('Data');
- break;
- case 'timestamp':
- $result = __('Timestamp');
- break;
- case 'to_critical':
- $result = __('Last status change');
- break;
- }
- $result_selected[$field_selected] = $result;
- }
+// show list of fields selected.
+if ($fields_selected[0] != '') {
+ foreach ($fields_selected as $field_selected) {
+ switch ($field_selected) {
+ case 'policy':
+ $result = __('Policy');
+ break;
+
+ case 'agent':
+ $result = __('Agent');
+ break;
+
+ case 'data_type':
+ $result = __('Data type');
+ break;
+
+ case 'module_name':
+ $result = __('Module name');
+ break;
+
+ case 'server_type':
+ $result = __('Server type');
+ break;
+
+ case 'interval':
+ $result = __('Interval');
+ break;
+
+ case 'status':
+ $result = __('Status');
+ break;
+
+ case 'graph':
+ $result = __('Graph');
+ break;
+
+ case 'warn':
+ $result = __('Warn');
+ break;
+
+ case 'data':
+ $result = __('Data');
+ break;
+
+ case 'timestamp':
+ $result = __('Timestamp');
+ break;
+
+ case 'to_critical':
+ $result = __('Last status change');
+ break;
+ }
+
+ $result_selected[$field_selected] = $result;
+ }
}
echo '
';
@@ -241,7 +259,11 @@ if ($dialogue_event_response) {
case 'url':
$command = str_replace('localhost', $_SERVER['SERVER_NAME'], $command);
- echo "";
+ echo "";
+ break;
+
+ default:
+ // Ignore.
break;
}
}
@@ -318,10 +340,10 @@ if ($get_extended_event) {
$readonly = true;
}
- // Clean url from events and store in array
+ // Clean url from events and store in array.
$event['clean_tags'] = events_clean_tags($event['tags']);
- // If the event is not found, we abort
+ // If the event is not found, we abort.
if (empty($event)) {
ui_print_error_message('Event not found');
return false;
@@ -340,42 +362,62 @@ if ($get_extended_event) {
$event['timestamp_last'] = $timestamp_last;
$event['event_rep'] = $event_rep;
- // Check ACLs
+ // Check ACLs.
if (is_user_admin($config['id_user'])) {
- // Do nothing if you're admin, you get full access
+ // Do nothing if you're admin, you get full access.
+ $__ignored_line = 0;
} else if ($config['id_user'] == $event['owner_user']) {
- // Do nothing if you're the owner user, you get access
+ // Do nothing if you're the owner user, you get access.
+ $__ignored_line = 0;
} else if ($event['id_grupo'] == 0) {
- // If the event has access to all groups, you get access
+ // If the event has access to all groups, you get access.
+ $__ignored_line = 0;
} else {
- // Get your groups
+ // Get your groups.
$groups = users_get_groups($config['id_user'], 'ER');
if (in_array($event['id_grupo'], array_keys($groups))) {
- // If the event group is among the groups of the user, you get access
+ // If event group is among the groups of the user, you get access.
+ $__ignored_line = 0;
} else {
- // If all the access types fail, abort
+ // If all the access types fail, abort.
echo 'Access denied';
return false;
}
}
- // Print group_rep in a hidden field to recover it from javascript
+ // Print group_rep in a hidden field to recover it from javascript.
html_print_input_hidden('group_rep', (int) $group_rep);
if ($event === false) {
return;
}
- // Tabs
+ // Tabs.
$tabs = "
';
+ }
+
+ if (isset($config['cron_last_run']) === true) {
+ $message_conf_cron .= __('Last execution').': ';
+ $message_conf_cron .= date('Y/m/d H:i:s', $config['cron_last_run']);
+ $message_conf_cron .= __('Please check process is no locked.');
+ }
+
+ $this->notify(
+ [
+ 'type' => 'NOTIF.CRON.CONFIGURED',
+ 'title' => __('DiscoveryConsoleTasks is not configured.'),
+ 'message' => __($message_conf_cron),
+ 'url' => 'index.php?extension_in_menu=gservers&sec=extensions&sec2=enterprise/extensions/cron',
+ ]
+ );
+ } else {
+ $this->cleanNotifications('NOTIF.CRON.CONFIGURED');
+ }
+
+ }
+
+
+}
diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php
index 42306dbfc1..81ddb9f336 100644
--- a/pandora_console/include/config_process.php
+++ b/pandora_console/include/config_process.php
@@ -20,7 +20,7 @@
/**
* Pandora build version and version
*/
-$build_version = 'PC190225';
+$build_version = 'PC190226';
$pandora_version = 'v7.0NG.731';
// Do not overwrite default timezone set if defined.
diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php
index ce7b91735c..b472f98ad8 100644
--- a/pandora_console/include/constants.php
+++ b/pandora_console/include/constants.php
@@ -1,47 +1,57 @@
$value) {
+ $negative = false;
if (is_numeric($field)) {
// User provide the exact operation to do
$query .= $value;
@@ -718,6 +719,11 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa
continue;
}
+ if ($field[0] == '!') {
+ $negative = true;
+ $field = substr($field, 1);
+ }
+
if ($field[0] != '`') {
// If the field is as
., don't scape.
if (strstr($field, '.') === false) {
@@ -732,7 +738,8 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa
} else if (is_float($value) || is_double($value)) {
$query .= sprintf('%s = %f', $field, $value);
} else if (is_array($value)) {
- $query .= sprintf('%s IN ("%s")', $field, implode('", "', $value));
+ $not = $negative ? ' NOT ' : '';
+ $query .= sprintf('%s %sIN ("%s")', $field, $not, implode('", "', $value));
} else {
if ($value === '') {
// Search empty string
diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php
index 6f13388fc0..e1861e70a3 100644
--- a/pandora_console/include/functions.php
+++ b/pandora_console/include/functions.php
@@ -852,6 +852,28 @@ function get_parameter_checkbox($name, $default='')
}
+/**
+ * Transforms a swicth data (on - non present) to a int value.
+ *
+ * @param string $name Variable, switch name.
+ * @param string $default Default value.
+ *
+ * @return integer Value, 1 on, 0 off.
+ */
+function get_parameter_switch($name, $default='')
+{
+ $data = get_parameter($name, null);
+
+ if ($data === null) {
+ return 0;
+ } else if ($data == 'on') {
+ return 1;
+ }
+
+ return 0;
+}
+
+
function get_cookie($name, $default='')
{
if (isset($_COOKIE[$name])) {
diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php
index 714005f821..475ef2db79 100644
--- a/pandora_console/include/functions_config.php
+++ b/pandora_console/include/functions_config.php
@@ -1,26 +1,39 @@
0) {
@@ -1154,7 +1166,7 @@ function config_update_config()
}
}
- // Delete interval value if is required
+ // Delete interval value if is required.
$interval_to_delete = (float) get_parameter('interval_to_delete');
if ($interval_to_delete > 0) {
$interval_values_array = explode(',', $interval_values);
@@ -1176,7 +1188,7 @@ function config_update_config()
$error_update[] = __('Custom report info');
}
- // Juanma (06/05/2014) New feature: Custom front page for reports
+ // Juanma (06/05/2014) New feature: Custom front page for reports.
if (!config_update_value('custom_report_front', get_parameter('custom_report_front'))) {
$error_update[] = __('Custom report front');
}
@@ -1337,7 +1349,15 @@ function config_update_config()
$error_update[] = __('eHorus id custom field');
}
break;
+
+ default:
+ // Ignore.
+ break;
}
+
+ default:
+ // Ignore.
+ break;
}
if (count($error_update) > 0) {
@@ -1359,7 +1379,9 @@ function config_update_config()
/**
- * Process config variables
+ * Process config variables.
+ *
+ * @return void
*/
function config_process_config()
{
@@ -1377,7 +1399,7 @@ function config_process_config()
$is_windows = true;
}
- // Compatibility fix
+ // Compatibility fix.
foreach ($configs as $c) {
$config[$c['token']] = $c['value'];
}
@@ -1434,18 +1456,18 @@ function config_process_config()
if (!isset($config['prominent_time'])) {
// Prominent time tells us what to show prominently when a timestamp is
- // displayed. The comparation (... days ago) or the timestamp (full date)
+ // displayed. The comparation (... days ago) or the timestamp (full date).
config_update_value('prominent_time', 'comparation');
}
if (!isset($config['timesource'])) {
- // Timesource says where time comes from (system or mysql)
+ // Timesource says where time comes from (system or mysql).
config_update_value('timesource', 'system');
}
if (!isset($config['https'])) {
// Sets whether or not we want to enforce https. We don't want to go to a
- // potentially unexisting config by default
+ // potentially unexisting config by default.
config_update_value('https', false);
}
@@ -1454,7 +1476,7 @@ function config_process_config()
}
if (!isset($config['cert_path'])) {
- // Sets name and path of ssl path for use in application
+ // Sets name and path of ssl path for use in application.
config_update_value('cert_path', '/etc/ssl/certs/pandorafms.pem');
}
@@ -1466,7 +1488,7 @@ function config_process_config()
config_update_value('status_images_set', 'default');
}
- // Load user session
+ // Load user session.
if (isset($_SESSION['id_usuario'])) {
$config['id_user'] = $_SESSION['id_usuario'];
}
@@ -1517,12 +1539,12 @@ function config_process_config()
}
}
- if (!isset($config['max_graph_container'])) {
- config_update_value('max_graph_container', 10);
+ if (!isset($config['delete_old_messages'])) {
+ config_update_value('delete_old_messages', 21);
}
- if (!isset($config['max_execution_event_response'])) {
- config_update_value('max_execution_event_response', 10);
+ if (!isset($config['max_graph_container'])) {
+ config_update_value('max_graph_container', 10);
}
if (!isset($config['max_macro_fields'])) {
@@ -1669,13 +1691,10 @@ function config_process_config()
config_update_value('limit_parameters_massive', (ini_get('max_input_vars') / 2));
}
- if (!isset($config['unique_ip'])) {
- config_update_value('unique_ip', 0);
- }
-
/*
- *Parse the ACL IP list for access API
+ * Parse the ACL IP list for access API
*/
+
$temp_list_ACL_IPs_for_API = [];
if (isset($config['list_ACL_IPs_for_API'])) {
if (!empty($config['list_ACL_IPs_for_API'])) {
@@ -1691,8 +1710,7 @@ function config_process_config()
// the first time make a conenction and disable itself
// Not Managed here !
// if (!isset ($config["autoupdate"])) {
- // config_update_value ('autoupdate', true);
- // }
+ // config_update_value ('autoupdate', true);.
include_once $config['homedir'].'/include/auth/mysql.php';
include_once $config['homedir'].'/include/functions_io.php';
@@ -2287,7 +2305,7 @@ function config_process_config()
}
if (defined('METACONSOLE')) {
- // Customizable sections (Metaconsole)
+ // Customizable sections (Metaconsole).
enterprise_include_once('include/functions_enterprise.php');
$customizable_sections = enterprise_hook('enterprise_get_customizable_sections');
@@ -2309,15 +2327,15 @@ function config_process_config()
) {
$isFunctionSkins = enterprise_include_once('include/functions_skins.php');
if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) {
- // Try to update user table in order to refresh skin inmediatly
+ // Try to update user table in order to refresh skin inmediatly.
$is_user_updating = get_parameter('sec2', '');
if ($is_user_updating == 'operation/users/user_edit') {
$id = get_parameter_get('id', $config['id_user']);
- // ID given as parameter
+ // ID given as parameter.
$user_info = get_user_info($id);
- // If current user is editing himself or if the user has UM (User Management) rights on any groups the user is part of AND the authorization scheme allows for users/admins to update info
+ // If current user is editing himself or if the user has UM (User Management) rights on any groups the user is part of AND the authorization scheme allows for users/admins to update info.
if (($config['id_user'] == $id || check_acl($config['id_user'], users_get_groups($id), 'UM')) && $config['user_can_update_info']) {
$view_mode = false;
} else {
@@ -2331,7 +2349,7 @@ function config_process_config()
}
if (!is_metaconsole()) {
- // Skins are available only in console mode
+ // Skins are available only in console mode.
if (isset($config['id_user'])) {
$relative_path = enterprise_hook('skins_set_image_skin_path', [$config['id_user']]);
} else {
@@ -2461,12 +2479,12 @@ function config_process_config()
config_update_value('render_proc_fail', __('Fail'));
}
- // Daniel maya 02/06/2016 Display menu with click --INI
+ // Daniel maya 02/06/2016 Display menu with click --INI.
if (!isset($config['click_display'])) {
config_update_value('click_display', 1);
}
- // Daniel maya 02/06/2016 Display menu with click --END
+ // Daniel maya 02/06/2016 Display menu with click --END.
if (isset($config['enterprise_installed']) && $config['enterprise_installed'] == 1) {
if (!isset($config['service_label_font_size'])) {
config_update_value('service_label_font_size', 20);
@@ -2493,7 +2511,7 @@ function config_process_config()
config_update_value('custom_report_info', 1);
}
- // Juanma (06/05/2014) New feature: Custom front page for reports
+ // Juanma (06/05/2014) New feature: Custom front page for reports.
if (!isset($config['custom_report_front'])) {
config_update_value('custom_report_front', 0);
}
@@ -2603,7 +2621,7 @@ function config_process_config()
config_update_value('instance_registered', 0);
}
- // eHorus
+ // Ehorus.
if (!isset($config['ehorus_enabled'])) {
config_update_value('ehorus_enabled', 0);
}
@@ -2638,285 +2656,77 @@ function config_process_config()
}
}
- // Finally, check if any value was overwritten in a form
+ // Finally, check if any value was overwritten in a form.
config_update_config();
}
+/**
+ * Start supervisor.
+ *
+ * @return void
+ */
function config_check()
{
global $config;
- // At this first version I'm passing errors using session variables, because the error management
- // is done by an AJAX request. Better solutions could be implemented in the future :-)
- if (license_free() && users_is_admin($config['id_user'])) {
- $login = get_parameter('login', false);
- // Registration advice
- if ((!isset($config['instance_registered']) || ($config['instance_registered'] != 1)) && ($login === false)) {
- set_pandora_error_for_header(
- __('Click here to start the registration process'),
- __('This instance is not registered in the Update manager')
- );
- }
+ include_once __DIR__.'/class/ConsoleSupervisor.php';
- // Newsletter advice
- $newsletter = db_get_value('middlename', 'tusuario', 'id_user', $config['id_user']);
- if ($newsletter != 1 && $login === false) {
- set_pandora_error_for_header(
- __('Click here to start the newsletter subscription process'),
- __('Not subscribed to the newsletter')
- );
- }
+ // Enterprise customers launch supervisor using discovery task.
+ if (enterprise_installed() === false) {
+ $supervisor = new ConsoleSupervisor(false);
+ $supervisor->run();
+ } else if ($config['cron_last_run'] == 0
+ || (get_system_time() - $config['cron_last_run']) > 3600
+ ) {
+ $supervisor = new ConsoleSupervisor(false);
+ $supervisor->runBasic();
}
- // Check default password for "admin"
- $is_admin = db_get_value('is_admin', 'tusuario', 'id_user', $config['id_user']);
- if ($is_admin) {
- $hashpass = db_get_sql(
- "SELECT password
- FROM tusuario WHERE id_user = 'admin'"
- );
- if ($hashpass == '1da7ee7d45b96d0e1f45ee4ee23da560') {
- set_pandora_error_for_header(
- __('Default password for "Admin" user has not been changed.'),
- __('Please change the default password because is a common vulnerability reported.')
- );
- }
- }
-
- if (isset($config['license_expired'])) {
- set_pandora_error_for_header(
- __('You can not get updates until you renew the license.'),
- __('This license has expired.')
- );
- }
-
- if (!is_writable('attachment')) {
- set_pandora_error_for_header(
- __('Please check that the web server has write rights on the {HOMEDIR}/attachment directory'),
- __('Attachment directory is not writable by HTTP Server')
- );
- }
-
- // Get remote file dir.
- $remote_config = io_safe_output(
- db_get_value_filter(
- 'value',
- 'tconfig',
- ['token' => 'remote_config']
- )
- );
-
- if (enterprise_installed()) {
- if (!is_readable($remote_config)) {
- set_pandora_error_for_header(
- __('Remote configuration directory is not readble for the console').' - '.$remote_config
- );
- }
-
- $remote_config_conf = $remote_config.'/conf';
- if (!is_writable($remote_config_conf)) {
- set_pandora_error_for_header(
- __('Remote configuration directory is not writtable for the console').' - '.$remote_config.'/conf'
- );
- }
-
- $remote_config_col = $remote_config.'/collections';
- if (!is_writable($remote_config_col)) {
- set_pandora_error_for_header(
- __('Remote configuration directory is not writtable for the console').' - '.$remote_config.'/collections'
- );
- }
- }
-
- // Check attachment directory (too much files?)
- $filecount = count(glob($config['homedir'].'/attachment/*'));
- // N temporal files of trash should be enough for most people.
- if ($filecount > $config['num_files_attachment']) {
- set_pandora_error_for_header(
- __('There are too much files in attachment directory. This is not fatal, but you should consider cleaning up your attachment directory manually')." ( $filecount ".__('files').' )',
- __('Too much files in your tempora/attachment directory')
- );
- }
-
- // Check database maintance
- $db_maintance = db_get_value_filter(
- 'value',
- 'tconfig',
- ['token' => 'db_maintance']
- );
-
- // If never was executed, it means we are in the first Pandora FMS execution. Set current timestamp
- if (empty($db_maintance)) {
- config_update_value('db_maintance', date('U'));
- }
-
- $last_maintance = (date('U') - $db_maintance);
-
- // ~ about 50 hr
- if ($last_maintance > 190000) {
- set_pandora_error_for_header(
- __('Your database is not maintained correctly. It seems that more than 48hrs have passed without proper maintenance. Please review documents of %s on how to perform this maintenance process (DB Tool) and enable it as soon as possible.', get_product_name()),
- __('Database maintance problem')
- );
- }
-
- $fontpath = io_safe_output(db_get_value_filter('value', 'tconfig', ['token' => 'fontpath']));
- if (($fontpath == '') or (!file_exists($fontpath))) {
- set_pandora_error_for_header(
- __('Your defined font doesnt exist or is not defined. Please check font parameters in your config'),
- __('Default font doesnt exist')
- );
- }
-
- if ($config['event_storm_protection']) {
- set_pandora_error_for_header(
- __('You need to restart server after altering this configuration setting.'),
- __('Event storm protection is activated. No events will be generated during this mode.')
- );
- }
-
- global $develop_bypass;
-
- if ($develop_bypass == 1) {
- set_pandora_error_for_header(
- __('Your %s has the "develop_bypass" mode enabled. This is a developer mode and should be disabled in a production system. This value is written in the main index.php file', get_product_name()),
- __('Developer mode is enabled')
- );
- }
-
- if (isset($_SESSION['new_update'])) {
- if (!empty($_SESSION['return_installation_open'])) {
- if (!$_SESSION['return_installation_open']['return']) {
- foreach ($_SESSION['return_installation_open']['text'] as $message) {
- set_pandora_error_for_header(
- $message,
- __('Error first setup Open update')
- );
- }
- }
- }
-
- if ($_SESSION['new_update'] == 'new') {
- set_pandora_error_for_header(
- __('There is a new update available. Please go to Administration:Setup:Update Manager for more details.'),
- __('New %s Console update', get_product_name())
- );
- }
- }
-
- // PHP configuration values
- $PHPupload_max_filesize = config_return_in_bytes(ini_get('upload_max_filesize'));
- $PHPmax_input_time = ini_get('max_input_time');
- $PHPmemory_limit = config_return_in_bytes(ini_get('memory_limit'));
- $PHPmax_execution_time = ini_get('max_execution_time');
- $PHPsafe_mode = ini_get('safe_mode');
- $PHPdisable_functions = ini_get('disable_functions');
-
- if ($PHPsafe_mode === '1') {
- set_pandora_error_for_header(
- __('To disable, change it on your PHP configuration file (php.ini) and put safe_mode = Off (Dont forget restart apache process after changes)'),
- sprintf(__('PHP safe mode is enabled. Some features may not properly work.'))
- );
- }
-
- if ($PHPmax_input_time !== '-1') {
- set_pandora_error_for_header(
- sprintf(__('Recommended value is %s'), '-1 ('.__('Unlimited').')').'
'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'),
- sprintf(__("Not recommended '%s' value in PHP configuration"), 'max_input_time')
- );
- }
-
- if ($PHPmax_execution_time !== '0') {
- set_pandora_error_for_header(
- sprintf(__('Recommended value is: %s'), '0 ('.__('Unlimited').')').'
'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'),
- sprintf(__("Not recommended '%s' value in PHP configuration"), 'max_execution_time')
- );
- }
-
- $PHPupload_max_filesize_min = config_return_in_bytes('800M');
-
- if ($PHPupload_max_filesize < $PHPupload_max_filesize_min) {
- set_pandora_error_for_header(
- sprintf(__('Recommended value is: %s'), sprintf(__('%s or greater'), '800M')).'
'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'),
- sprintf(__("Not recommended '%s' value in PHP configuration"), 'upload_max_filesize')
- );
- }
-
- $PHPmemory_limit_min = config_return_in_bytes('500M');
-
- if ($PHPmemory_limit < $PHPmemory_limit_min && $PHPmemory_limit !== '-1') {
- set_pandora_error_for_header(
- sprintf(__('Recommended value is: %s'), sprintf(__('%s or greater'), '500M')).'
'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator'),
- sprintf(__("Not recommended '%s' value in PHP configuration"), 'memory_limit')
- );
- }
-
- if (preg_match('/system/', $PHPdisable_functions) or preg_match('/exec/', $PHPdisable_functions)) {
- set_pandora_error_for_header(
- __('Variable disable_functions containts functions system() or exec(), in PHP configuration file (php.ini)').'
'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'),
- __('Problems with disable functions in PHP.INI')
- );
- }
-
- $result_ejecution = exec('"'.io_safe_output($config['phantomjs_bin']).'/phantomjs" --version');
- if (!isset($result_ejecution) || $result_ejecution == '') {
- if ($config['language'] == 'es') {
- set_pandora_error_for_header(
- __('To be able to create images of the graphs for PDFs, please install the phantom.js extension. For that, it is necessary to follow these steps:').'Click here',
- __('phantomjs is not installed')
- );
- } else {
- set_pandora_error_for_header(
- __('To be able to create images of the graphs for PDFs, please install the phantom.js extension. For that, it is necessary to follow these steps:').'Click here',
- __('phantomjs is not installed')
- );
- }
- }
-
- $php_version = phpversion();
- $php_version_array = explode('.', $php_version);
- if ($php_version_array[0] < 7) {
- if ($config['language'] == 'es') {
- $url_help = 'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Instalaci%C3%B3n_y_actualizaci%C3%B3n_PHP_7';
- } else {
- $url_help = 'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:_PHP_7';
- }
-
- set_pandora_error_for_header(
- __('For a correct operation of PandoraFMS, PHP must be updated to version 7.0 or higher.').' '.__('Otherwise, functionalities will be lost.').' '."
".__('Report download in PDF format').'
'."
".__('Emails Sending').'
'."
".__('Metaconsole Collections').'
'."
".'...'.'
'.''.''.__('Access Help').'',
- __('PHP UPDATE REQUIRED')
- );
- }
}
+/**
+ * Return in bytes
+ *
+ * @param string $val Value to convert.
+ *
+ * @return integer
+ */
function config_return_in_bytes($val)
{
$val = trim($val);
$last = strtolower($val[(strlen($val) - 1)]);
switch ($last) {
- // The 'G' modifier is available since PHP 5.1.0
+ // The 'G' modifier is available since PHP 5.1.0.
case 'g':
$val *= 1024;
case 'm':
$val *= 1024;
case 'k':
$val *= 1024;
+ default:
+ // Ignore.
+ break;
}
return $val;
}
+/**
+ * Undocumented function
+ *
+ * @return void
+ */
function config_user_set_custom_config()
{
global $config;
$userinfo = get_user_info($config['id_user']);
- // Refresh the last_connect info in the user table
- // if last update was more than 5 minutes ago
+ // Refresh the last_connect info in the user table.
+ // if last update was more than 5 minutes ago.
if ($userinfo['last_connect'] < (time() - SECONDS_1MINUTE)) {
update_user($config['id_user'], ['last_connect' => time()]);
}
@@ -2925,7 +2735,7 @@ function config_user_set_custom_config()
$config['block_size'] = $userinfo['block_size'];
}
- // Each user could have it's own timezone)
+ // Each user could have it's own timezone).
if (isset($userinfo['timezone'])) {
if ($userinfo['timezone'] != '') {
date_default_timezone_set($userinfo['timezone']);
@@ -2938,6 +2748,11 @@ function config_user_set_custom_config()
}
+/**
+ * Undocumented function
+ *
+ * @return void
+ */
function config_prepare_session()
{
global $config;
@@ -2950,10 +2765,10 @@ function config_prepare_session()
}
if ($user_sesion_time == 0) {
- // Change the session timeout value to session_timeout minutes // 8*60*60 = 8 hours
+ // Change the session timeout value to session_timeout minutes // 8*60*60 = 8 hours.
$sessionCookieExpireTime = $config['session_timeout'];
} else {
- // Change the session timeout value to session_timeout minutes // 8*60*60 = 8 hours
+ // Change the session timeout value to session_timeout minutes // 8*60*60 = 8 hours.
$sessionCookieExpireTime = $user_sesion_time;
}
@@ -2963,7 +2778,7 @@ function config_prepare_session()
$sessionCookieExpireTime *= 60;
}
- // Reset the expiration time upon page load //session_name() is default name of session PHPSESSID
+ // Reset the expiration time upon page load //session_name() is default name of session PHPSESSID.
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), $_COOKIE[session_name()], (time() + $sessionCookieExpireTime), '/');
}
diff --git a/pandora_console/include/functions_cron.php b/pandora_console/include/functions_cron.php
index f67204d5ba..e56a3d4a52 100644
--- a/pandora_console/include/functions_cron.php
+++ b/pandora_console/include/functions_cron.php
@@ -15,17 +15,23 @@ global $config;
require_once $config['homedir'].'/include/functions_db.php';
-// Update the execution interval of the given module
+// Update the execution interval of the given module.
function cron_update_module_interval($module_id, $cron)
{
- // Check for a valid cron
+ // Check for a valid cron.
if (!cron_check_syntax($cron)) {
return;
}
if ($cron == '* * * * *') {
- $module_interval = db_get_value_filter('module_interval', 'tagente_modulo', ['id_agente_modulo' => $module_id]);
- return db_process_sql('UPDATE tagente_estado SET current_interval = '.$module_interval.' WHERE id_agente_modulo = '.(int) $module_id);
+ $module_interval = db_get_value_filter(
+ 'module_interval',
+ 'tagente_modulo',
+ ['id_agente_modulo' => $module_id]
+ );
+ return db_process_sql(
+ 'UPDATE tagente_estado SET current_interval = '.$module_interval.' WHERE id_agente_modulo = '.(int) $module_id
+ );
} else {
return db_process_sql(
'UPDATE tagente_estado SET current_interval = '.cron_next_execution($cron, $module_interval, $module_id).' WHERE id_agente_modulo = '.(int) $module_id
@@ -38,7 +44,7 @@ function cron_update_module_interval($module_id, $cron)
// Get the number of seconds left to the next execution of the given cron entry.
function cron_next_execution($cron, $module_interval, $module_id)
{
- // Get day of the week and month from cron config
+ // Get day of the week and month from cron config.
$cron_array = explode(' ', $cron);
$minute = $cron_array[0];
$hour = $cron_array[1];
@@ -46,21 +52,34 @@ function cron_next_execution($cron, $module_interval, $module_id)
$month = $cron_array[3];
$wday = $cron_array[4];
- // Get last execution time
- $last_execution = db_get_value('utimestamp', 'tagente_estado', 'id_agente_modulo', $module_id);
+ // Get last execution time.
+ $last_execution = db_get_value(
+ 'utimestamp',
+ 'tagente_estado',
+ 'id_agente_modulo',
+ $module_id
+ );
$cur_time = ($last_execution !== false) ? $last_execution : time();
- // Any day of the way
+ // Any day of the way.
if ($wday == '*') {
- $nex_time = cron_next_execution_date($cron, $cur_time, $module_interval);
+ $nex_time = cron_next_execution_date(
+ $cron,
+ $cur_time,
+ $module_interval
+ );
return ($nex_time - $cur_time);
}
- // A specific day of the week
+ // A specific day of the week.
$count = 0;
$nex_time = $cur_time;
do {
- $nex_time = cron_next_execution_date($cron, $nex_time, $module_interval);
+ $nex_time = cron_next_execution_date(
+ $cron,
+ $nex_time,
+ $module_interval
+ );
$nex_time_wd = $nex_time;
$array_nex = explode(' ', date('m w', $nex_time_wd));
@@ -68,12 +87,12 @@ function cron_next_execution($cron, $module_interval, $module_id)
$nex_wday = $array_nex[1];
do {
- // Check the day of the week
+ // Check the day of the week.
if ($nex_wday == $wday) {
return ($nex_time_wd - $cur_time);
}
- // Move to the next day of the month
+ // Move to the next day of the month.
$nex_time_wd += SECONDS_1DAY;
$array_nex_w = explode(' ', date('m w', $nex_time_wd));
@@ -84,7 +103,7 @@ function cron_next_execution($cron, $module_interval, $module_id)
$count++;
} while ($count < SECONDS_1MINUTE);
- // Something went wrong, default to 5 minutes
+ // Something went wrong, default to 5 minutes.
return SECONDS_5MINUTES;
}
@@ -92,11 +111,11 @@ function cron_next_execution($cron, $module_interval, $module_id)
// Get the next execution date for the given cron entry in seconds since epoch.
function cron_next_execution_date($cron, $cur_time=false, $module_interval=300)
{
- // Get cron configuration
+ // Get cron configuration.
$cron_array = explode(' ', $cron);
// REMARKS: Months start from 1 in php (different to server)
- // Get current time
+ // Get current time.
if ($cur_time === false) {
$cur_time = time();
}
@@ -107,7 +126,7 @@ function cron_next_execution_date($cron, $cur_time=false, $module_interval=300)
return $nex_time;
}
- // Update minutes
+ // Update minutes.
$min_s = cron_get_interval($cron_array[0]);
$nex_time_array[0] = ($min_s['down'] == '*') ? 0 : $min_s['down'];
@@ -118,22 +137,22 @@ function cron_next_execution_date($cron, $cur_time=false, $module_interval=300)
}
}
- // Check if next hour is in cron
+ // Check if next hour is in cron.
$nex_time_array[1]++;
$nex_time = cron_valid_date($nex_time_array);
if ($nex_time === false) {
- // Update the month day if overflow
+ // Update the month day if overflow.
$nex_time_array[1] = 0;
$nex_time_array[2]++;
$nex_time = cron_valid_date($nex_time_array);
if ($nex_time === false) {
- // Update the month if overflow
+ // Update the month if overflow.
$nex_time_array[2] = 1;
$nex_time_array[3]++;
$nex_time = cron_valid_date($nex_time_array);
if ($nex_time === false) {
- // Update the year if overflow
+ // Update the year if overflow.
$nex_time_array[3] = 1;
$nex_time_array[4]++;
$nex_time = cron_valid_date($nex_time_array);
@@ -141,16 +160,16 @@ function cron_next_execution_date($cron, $cur_time=false, $module_interval=300)
}
}
- // Check the hour
+ // Check the hour.
if (cron_is_in_cron($cron_array, $nex_time_array) && $nex_time) {
return $nex_time;
}
- // Update the hour if fails
+ // Update the hour if fails.
$hour_s = cron_get_interval($cron_array[1]);
$nex_time_array[1] = ($hour_s['down'] == '*') ? 0 : $hour_s['down'];
- // When an overflow is passed check the hour update again
+ // When an overflow is passed check the hour update again.
$nex_time = cron_valid_date($nex_time_array);
if ($nex_time >= $cur_time) {
if (cron_is_in_cron($cron_array, $nex_time_array) && $nex_time) {
@@ -158,32 +177,32 @@ function cron_next_execution_date($cron, $cur_time=false, $module_interval=300)
}
}
- // Check if next day is in cron
+ // Check if next day is in cron.
$nex_time_array[2]++;
$nex_time = cron_valid_date($nex_time_array);
if ($nex_time === false) {
- // Update the month if overflow
+ // Update the month if overflow.
$nex_time_array[2] = 1;
$nex_time_array[3]++;
$nex_time = cron_valid_date($nex_time_array);
if ($nex_time === false) {
- // Update the year if overflow
+ // Update the year if overflow.
$nex_time_array[3] = 1;
$nex_time_array[4]++;
$nex_time = cron_valid_date($nex_time_array);
}
}
- // Check the day
+ // Check the day.
if (cron_is_in_cron($cron_array, $nex_time_array) && $nex_time) {
return $nex_time;
}
- // Update the day if fails
+ // Update the day if fails.
$mday_s = cron_get_interval($cron_array[2]);
$nex_time_array[2] = ($mday_s['down'] == '*') ? 1 : $mday_s['down'];
- // When an overflow is passed check the hour update in the next execution
+ // When an overflow is passed check the hour update in the next execution.
$nex_time = cron_valid_date($nex_time_array);
if ($nex_time >= $cur_time) {
if (cron_is_in_cron($cron_array, $nex_time_array) && $nex_time) {
@@ -191,26 +210,26 @@ function cron_next_execution_date($cron, $cur_time=false, $module_interval=300)
}
}
- // Check if next month is in cron
+ // Check if next month is in cron.
$nex_time_array[3]++;
$nex_time = cron_valid_date($nex_time_array);
if ($nex_time === false) {
- // Update the year if overflow
+ // Update the year if overflow.
$nex_time_array[3] = 1;
$nex_time_array[4]++;
$nex_time = cron_valid_date($nex_time_array);
}
- // Check the month
+ // Check the month.
if (cron_is_in_cron($cron_array, $nex_time_array) && $nex_time) {
return $nex_time;
}
- // Update the month if fails
+ // Update the month if fails.
$mon_s = cron_get_interval($cron_array[3]);
$nex_time_array[3] = ($mon_s['down'] == '*') ? 1 : $mon_s['down'];
- // When an overflow is passed check the hour update in the next execution
+ // When an overflow is passed check the hour update in the next execution.
$nex_time = cron_valid_date($nex_time_array);
if ($nex_time >= $cur_time) {
if (cron_is_in_cron($cron_array, $nex_time_array) && $nex_time) {
@@ -218,7 +237,7 @@ function cron_next_execution_date($cron, $cur_time=false, $module_interval=300)
}
}
- // Update the year
+ // Update the year.
$nex_time_array[4]++;
$nex_time = cron_valid_date($nex_time_array);
@@ -226,10 +245,10 @@ function cron_next_execution_date($cron, $cur_time=false, $module_interval=300)
}
-// Get an array with the cron interval
+// Get an array with the cron interval.
function cron_get_interval($element)
{
- // Not a range
+ // Not a range.
if (!preg_match('/(\d+)\-(\d+)/', $element, $capture)) {
return [
'down' => $element,
@@ -250,12 +269,12 @@ function cron_is_in_cron($elems_cron, $elems_curr_time)
$elem_cron = array_shift($elems_cron);
$elem_curr_time = array_shift($elems_curr_time);
- // If there is no elements means that is in cron
+ // If there is no elements means that is in cron.
if ($elem_cron === null || $elem_curr_time === null) {
return true;
}
- // Go to last element if current is a wild card
+ // Go to last element if current is a wild card.
if ($elem_cron != '*') {
$elem_s = cron_get_interval($elem_cron);
// Check if there is no a range
@@ -263,7 +282,7 @@ function cron_is_in_cron($elems_cron, $elems_curr_time)
return false;
}
- // Check if there is on the range
+ // Check if there is on the range.
if ($elem_s['up'] !== false) {
if ($elem_s['down'] < $elem_s['up']) {
if ($elem_curr_time < $elem_s['down'] || $elem_curr_time > $elem_s['up']) {
@@ -283,14 +302,365 @@ function cron_is_in_cron($elems_cron, $elems_curr_time)
function cron_valid_date($da)
{
- $st = sprintf('%04d:%02d:%02d %02d:%02d:00', $da[4], $da[3], $da[2], $da[1], $da[0]);
+ $st = sprintf(
+ '%04d:%02d:%02d %02d:%02d:00',
+ $da[4],
+ $da[3],
+ $da[2],
+ $da[1],
+ $da[0]
+ );
$time = strtotime($st);
return $time;
}
-// Check if cron is properly constructed
+// Check if cron is properly constructed.
function cron_check_syntax($cron)
{
- return preg_match('/^[\d|\*].* .*[\d|\*].* .*[\d|\*].* .*[\d|\*].* .*[\d|\*]$/', $cron);
+ return preg_match(
+ '/^[\d|\*].* .*[\d|\*].* .*[\d|\*].* .*[\d|\*].* .*[\d|\*]$/',
+ $cron
+ );
+}
+
+
+function cron_list_table()
+{
+ global $config;
+
+ $read_perms = check_acl($config['id_user'], 0, 'RR');
+ $write_perms = check_acl($config['id_user'], 0, 'RW');
+ $manage_perms = check_acl($config['id_user'], 0, 'RM');
+ $manage_pandora = check_acl($config['id_user'], 0, 'PM');
+
+ $url = 'index.php?extension_in_menu=gservers&sec=extensions&sec2=enterprise/extensions/cron&';
+
+ $user_groups = implode(
+ ',',
+ array_keys(users_get_groups())
+ );
+
+ $defined_tasks = db_get_all_rows_filter(
+ 'tuser_task_scheduled',
+ 'id_grupo IN ('.$user_groups.')'
+ );
+
+ if (!check_acl($config['id_user'], 0, 'PM')) {
+ $read_tasks = [];
+ foreach ($defined_tasks as $task) {
+ $function_name = db_get_value(
+ 'function_name',
+ 'tuser_task',
+ 'id',
+ $task['id_user_task']
+ );
+
+ if (($function_name != 'cron_task_execute_custom_script')
+ && ($function_name != 'cron_task_do_backup')
+ ) {
+ $read_tasks[] = $task;
+ }
+ }
+
+ $defined_tasks = $read_tasks;
+
+ if (empty($defined_tasks)) {
+ $defined_tasks = false;
+ }
+ }
+
+ if ($defined_tasks !== false) {
+ echo '
'.__('Scheduled jobs').'
';
+
+ $table = new stdClass();
+ $table->class = 'databox data';
+ $table->width = '100%';
+ $table->data = [];
+ $table->head = [];
+ $table->head[0] = '';
+ $table->head[1] = __('User');
+ $table->head[2] = __('Task');
+ $table->head[3] = __('Scheduled');
+ $table->head[4] = __('Next execution');
+ $table->head[5] = __('Last run');
+ $table->head[6] = __('Group');
+ $table->head[7] = __('Actions');
+ $table->align[7] = 'left';
+
+ foreach ($defined_tasks as $task) {
+ $data = [];
+
+ $function_name = db_get_value(
+ 'function_name',
+ 'tuser_task',
+ 'id',
+ $task['id_user_task']
+ );
+
+ switch ($function_name) {
+ case 'cron_task_generate_report':
+ if ($write_perms || $manage_pandora) {
+ $data[0] = '';
+ $data[0] .= html_print_image(
+ 'images/target.png',
+ true,
+ ['title' => __('Force run')]
+ );
+ $data[0] .= '';
+ } else {
+ $data[0] = '';
+ }
+
+ $data[1] = $task['id_usuario'];
+ $data[2] = db_get_value(
+ 'name',
+ 'tuser_task',
+ 'id',
+ $task['id_user_task']
+ );
+ $args = unserialize($task['args']);
+ $report = reports_get_report($args[0]);
+
+ // Check ACL in reports_get_report return false.
+ if ($report === false) {
+ continue;
+ }
+
+ $email = $args[1];
+ $data[2] .= ' - '.__('Report').": ";
+ $data[2] .= $report['name'].'';
+ $data[2] .= ' - '.__('Email').": ";
+ $data[2] .= ui_print_truncate_text($email, 60, false).'';
+ break;
+
+ case 'cron_task_generate_report_by_template':
+ if ($write_perms || $manage_pandora) {
+ $data[0] = '';
+ $data[0] .= html_print_image(
+ 'images/target.png',
+ true,
+ ['title' => __('Force run')]
+ );
+ $data[0] .= '';
+ } else {
+ $data[0] = '';
+ }
+
+ $data[1] = $task['id_usuario'];
+ $data[2] = db_get_value(
+ 'name',
+ 'tuser_task',
+ 'id',
+ $task['id_user_task']
+ );
+
+ $args = unserialize($task['args']);
+
+ $filter = [];
+ $filter['id_report'] = $args[0];
+ $template = db_get_row_filter(
+ 'treport_template',
+ $filter,
+ false
+ );
+
+ // Check ACL in reports_get_report return false.
+ if ($template === false) {
+ continue;
+ }
+
+ $agents_id = $args[1];
+ $id_group = $args[2];
+ $report_per_agent = $args[0];
+ $report_name = $args[3];
+ $email = $args[4];
+ $data[2] .= ' - '.__('Template').": ".$template['name'].'';
+ $data[2] .= ' - '.__('Agents').': '.$agents_id.'';
+ $data[2] .= ' - '.__('Report per agent').': '.$report_per_agent.'';
+ $data[2] .= ' - '.__('Report name').': '.$report_name.'';
+ $data[2] .= ' - '.__('Email').": ".$email.'';
+ break;
+
+ case 'cron_task_execute_custom_script':
+ if ($manage_pandora) {
+ $data[0] = '';
+ $data[0] .= html_print_image(
+ 'images/target.png',
+ true,
+ ['title' => __('Force run')]
+ );
+ $data[0] .= '';
+ } else {
+ $data[0] = '';
+ }
+
+ $data[1] = $task['id_usuario'];
+ $data[2] = db_get_value(
+ 'name',
+ 'tuser_task',
+ 'id',
+ $task['id_user_task']
+ );
+
+ $args = unserialize($task['args']);
+ $data[2] .= ' - '.__('Custom script').': '.$args[0];
+ break;
+
+ case 'cron_task_save_report_to_disk':
+ if ($write_perms || $manage_pandora) {
+ $data[0] = '';
+ $data[0] .= html_print_image(
+ 'images/target.png',
+ true,
+ ['title' => __('Force run')]
+ );
+ $data[0] .= '';
+ } else {
+ $data[0] = '';
+ }
+
+ $data[1] = $task['id_usuario'];
+ $data[2] = db_get_value(
+ 'name',
+ 'tuser_task',
+ 'id',
+ $task['id_user_task']
+ );
+
+ $args = unserialize($task['args']);
+ $report = reports_get_report($args[0]);
+
+ // Check ACL in reports_get_report return false.
+ if ($report === false) {
+ continue;
+ }
+
+ $path = $args[1];
+ $data[2] .= ' - '.__('Report').": ".$report['name'].'';
+ $data[2] .= ' - '.__('Path').': '.$path.'';
+ break;
+
+ case 'cron_task_save_xml_report_to_disk':
+ if ($write_perms || $manage_pandora) {
+ $data[0] = '';
+ $data[0] .= html_print_image(
+ 'images/target.png',
+ true,
+ ['title' => __('Force run')]
+ );
+ $data[0] .= '';
+ } else {
+ $data[0] = '';
+ }
+
+ $data[1] = $task['id_usuario'];
+ $data[2] = db_get_value('name', 'tuser_task', 'id', $task['id_user_task']);
+ $args = unserialize($task['args']);
+ $report = reports_get_report($args[0]);
+
+ // Check ACL in reports_get_report return false.
+ if ($report === false) {
+ continue;
+ }
+
+ $path = $args[1];
+ $data[2] .= ' - '.__('Report').": ".$report['name'].'';
+ $data[2] .= ' - '.__('Path').': '.$path.'';
+ break;
+
+ case 'cron_task_do_backup':
+ if ($manage_pandora) {
+ $data[0] = '';
+ $data[0] .= html_print_image(
+ 'images/target.png',
+ true,
+ ['title' => __('Force run')]
+ );
+ $data[0] .= '';
+ } else {
+ $data[0] = '';
+ }
+
+ $data[1] = $task['id_usuario'];
+ $data[2] = db_get_value(
+ 'name',
+ 'tuser_task',
+ 'id',
+ $task['id_user_task']
+ );
+ $args = unserialize($task['args']);
+ break;
+
+ default:
+ // Ignore.
+ break;
+ }
+
+ $data[3] = cron_get_scheduled_string($task['scheduled']);
+ $data[4] = date('Y/m/d H:i:s', $args['first_execution']);
+ $data[5] = empty($task['last_run']) ? __('Never') : date('Y/m/d H:i:s', $task['last_run']);
+
+ $data[6] = ui_print_group_icon($task['id_grupo'], true);
+
+ if ($function_name == 'cron_task_do_backup' || $function_name == 'cron_task_execute_custom_script') {
+ if ($manage_pandora) {
+ $data[7] = '';
+ $data[7] .= html_print_image(
+ 'images/config.png',
+ true,
+ ['title' => __('Edit')]
+ );
+ $data[7] .= '';
+ }
+
+ if ($manage_pandora) {
+ $data[7] .= '';
+ $data[7] .= html_print_image(
+ 'images/cross.png',
+ true,
+ ['title' => __('Delete')]
+ );
+ $data[7] .= '';
+ }
+ } else {
+ if ($write_perms || $manage_pandora) {
+ $data[7] = '';
+ $data[7] .= html_print_image(
+ 'images/config.png',
+ true,
+ ['title' => __('Edit')]
+ );
+ $data[7] .= '';
+ }
+
+ if ($manage_perms || $manage_pandora) {
+ $data[7] .= '';
+ $data[7] .= html_print_image(
+ 'images/cross.png',
+ true,
+ ['title' => __('Delete')]
+ );
+ $data[7] .= '';
+ }
+ }
+
+ array_push($table->data, $data);
+ }
+
+ html_print_table($table);
+ }
}
diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php
index 476f0f158a..15570de763 100644
--- a/pandora_console/include/functions_events.php
+++ b/pandora_console/include/functions_events.php
@@ -1,17 +1,32 @@
- * Both are similars:
- * db_get_all_rows_filter ('table', array ('disabled', 0));
- * db_get_all_rows_filter ('table', 'disabled = 0');
+ * @param mixed $filter Filters elements. It can be an indexed array
+ * (keys would be the field name and value the expected
+ * value, and would be joined with an AND operator) or a
+ * string, including any SQL clause (without the WHERE
+ * keyword). Example:
+ *
+ * Both are similars:
+ * db_get_all_rows_filter ('table', ['disabled', 0]);
+ * db_get_all_rows_filter ('table', 'disabled = 0');
+ * Both are similars:
+ * db_get_all_rows_filter (
+ * 'table',
+ * [
+ * 'disabled' => 0,
+ * 'history_data' => 0
+ * ],
+ * 'name',
+ * 'OR'
+ * );
+ * db_get_all_rows_filter (
+ * 'table',
+ * 'disabled = 0 OR history_data = 0', 'name'
+ * );
+ * .
+ * @param mixed $fields Fields of the table to retrieve. Can be an array or a
+ * coma separated string. All fields are retrieved by
+ * default.
*
- * Both are similars:
- * db_get_all_rows_filter ('table', array ('disabled' => 0, 'history_data' => 0), 'name', 'OR');
- * db_get_all_rows_filter ('table', 'disabled = 0 OR history_data = 0', 'name');
- *
- * @param mixed Fields of the table to retrieve. Can be an array or a coma
- * separated string. All fields are retrieved by default
- *
- * @return mixed False in case of error or invalid values passed. Affected rows otherwise
+ * @return mixed False in case of error or invalid values passed.
+ * Affected rows otherwise
*/
function events_get_events($filter=false, $fields=false)
{
@@ -93,10 +120,13 @@ function events_get_events($filter=false, $fields=false)
/**
* Get the event with the id pass as parameter.
*
- * @param integer $id Event id
- * @param mixed $fields The fields to show or by default all with false.
+ * @param integer $id Event id.
+ * @param mixed $fields The fields to show or by default all with false.
+ * @param boolean $meta Metaconsole environment or not.
+ * @param boolean $history Retrieve also historical data.
*
- * @return mixed False in case of error or invalid values passed. Event row otherwise
+ * @return mixed False in case of error or invalid values passed.
+ * Event row otherwise.
*/
function events_get_event($id, $fields=false, $meta=false, $history=false)
{
@@ -123,6 +153,20 @@ function events_get_event($id, $fields=false, $meta=false, $history=false)
}
+/**
+ * Retrieve all events ungrouped.
+ *
+ * @param string $sql_post Sql_post.
+ * @param integer $offset Offset.
+ * @param integer $pagination Pagination.
+ * @param boolean $meta Meta.
+ * @param boolean $history History.
+ * @param boolean $total Total.
+ * @param boolean $history_db History_db.
+ * @param string $order Order.
+ *
+ * @return mixed Array of events or false.
+ */
function events_get_events_no_grouped(
$sql_post,
$offset=0,
@@ -137,7 +181,7 @@ function events_get_events_no_grouped(
$table = events_get_events_table($meta, $history);
- $sql = "SELECT * FROM $table te WHERE 1=1 ".$sql_post;
+ $sql = 'SELECT * FROM '.$table.' te WHERE 1=1 '.$sql_post;
$events = db_get_all_rows_sql($sql, $history_db);
@@ -145,6 +189,21 @@ function events_get_events_no_grouped(
}
+/**
+ * Return all events matching sql_post grouped.
+ *
+ * @param [type] $sql_post Sql_post.
+ * @param integer $offset Offset.
+ * @param integer $pagination Pagination.
+ * @param boolean $meta Meta.
+ * @param boolean $history History.
+ * @param boolean $total Total.
+ * @param boolean $history_db History_db.
+ * @param string $order Order.
+ * @param string $sort_field Sort_field.
+ *
+ * @return mixed Array of events or false.
+ */
function events_get_events_grouped(
$sql_post,
$offset=0,
@@ -203,6 +262,15 @@ function events_get_events_grouped(
}
+/**
+ * Return count of events grouped.
+ *
+ * @param string $sql_post Sql_post.
+ * @param boolean $meta Meta.
+ * @param boolean $history History.
+ *
+ * @return integer Number of events or false if failed.
+ */
function events_get_total_events_grouped($sql_post, $meta=false, $history=false)
{
return events_get_events_grouped($sql_post, 0, 0, $meta, $history, true);
@@ -215,9 +283,9 @@ function events_get_total_events_grouped($sql_post, $meta=false, $history=false)
* An event is similar then the event text (evento) and the id_agentmodule are
* the same.
*
- * @param int Event id to get similar events.
- * @param bool Metaconsole mode flag
- * @param bool History mode flag
+ * @param integer $id Event id to get similar events.
+ * @param boolean $meta Metaconsole mode flag.
+ * @param boolean $history History mode flag.
*
* @return array A list of events ids.
*/
@@ -227,7 +295,14 @@ function events_get_similar_ids($id, $meta=false, $history=false)
$ids = [];
if ($meta) {
- $event = events_meta_get_event($id, ['evento', 'id_agentmodule'], $history);
+ $event = events_meta_get_event(
+ $id,
+ [
+ 'evento',
+ 'id_agentmodule',
+ ],
+ $history
+ );
} else {
$event = events_get_event($id, ['evento', 'id_agentmodule']);
}
@@ -259,26 +334,33 @@ function events_get_similar_ids($id, $meta=false, $history=false)
/**
* Delete events in a transresponse
*
- * @param mixed Event ID or array of events
- * @param bool Whether to delete similar events too.
- * @param bool Metaconsole mode flag
- * @param bool History mode flag
+ * @param mixed $id_event Event ID or array of events.
+ * @param boolean $similar Whether to delete similar events too.
+ * @param boolean $meta Metaconsole mode flag.
+ * @param boolean $history History mode flag.
*
* @return boolean Whether or not it was successful
*/
-function events_delete_event($id_event, $similar=true, $meta=false, $history=false)
-{
+function events_delete_event(
+ $id_event,
+ $similar=true,
+ $meta=false,
+ $history=false
+) {
global $config;
$table_event = events_get_events_table($meta, $history);
- // Cleans up the selection for all unwanted values also casts any single values as an array
+ // Cleans up the selection for all unwanted values also casts any single values as an array.
$id_event = (array) safe_int($id_event, 1);
- // We must delete all events like the selected
+ // We must delete all events like the selected.
if ($similar) {
foreach ($id_event as $id) {
- $id_event = array_merge($id_event, events_get_similar_ids($id, $meta, $history));
+ $id_event = array_merge(
+ $id_event,
+ events_get_similar_ids($id, $meta, $history)
+ );
}
$id_event = array_unique($id_event);
@@ -294,7 +376,7 @@ function events_delete_event($id_event, $similar=true, $meta=false, $history=fal
}
if (check_acl($config['id_user'], $event_group, 'EM') == 0) {
- // Check ACL
+ // Check ACL.
db_pandora_audit('ACL Violation', 'Attempted deleting event #'.$event);
$errors++;
} else {
@@ -304,7 +386,7 @@ function events_delete_event($id_event, $similar=true, $meta=false, $history=fal
$errors++;
} else {
db_pandora_audit('Event deleted', 'Deleted event #'.$event);
- // ACL didn't fail nor did return
+ // ACL didn't fail nor did return.
continue;
}
}
@@ -321,25 +403,29 @@ function events_delete_event($id_event, $similar=true, $meta=false, $history=fal
/**
- * Change the status of one or various events
+ * Change the status of one or multiple events.
*
- * @param mixed Event ID or array of events
- * @param int new status of the event
- * @param bool metaconsole mode flag
- * @param bool history mode flag
+ * @param mixed $id_event Event ID or array of events.
+ * @param integer $new_status New status of the event.
+ * @param boolean $meta Metaconsole mode flag.
+ * @param boolean $history History mode flag.
*
* @return boolean Whether or not it was successful
*/
-function events_change_status($id_event, $new_status, $meta=false, $history=false)
-{
+function events_change_status(
+ $id_event,
+ $new_status,
+ $meta=false,
+ $history=false
+) {
global $config;
$event_table = events_get_events_table($meta, $history);
- // Cleans up the selection for all unwanted values also casts any single values as an array
+ // Cleans up the selection for all unwanted values also casts any single values as an array.
$id_event = (array) safe_int($id_event, 1);
- // Update ack info if the new status is validated
+ // Update ack info if the new status is validated.
if ($new_status == EVENT_STATUS_VALIDATED) {
$ack_utimestamp = time();
$ack_user = $config['id_user'];
@@ -409,14 +495,20 @@ function events_change_status($id_event, $new_status, $meta=false, $history=fals
return false;
}
- events_comment($id_event, '', "Change status to $status_string", $meta, $history);
+ events_comment(
+ $id_event,
+ '',
+ 'Change status to '.$status_string,
+ $meta,
+ $history
+ );
if ($meta && !empty($alerts)) {
$server = metaconsole_get_connection_by_id($server_id);
metaconsole_connect($server);
}
- // Put the alerts in standby or not depends the new status
+ // Put the alerts in standby or not depends the new status.
foreach ($alerts as $alert) {
switch ($new_status) {
case EVENT_NEW:
@@ -427,6 +519,10 @@ function events_change_status($id_event, $new_status, $meta=false, $history=fals
case EVENT_PROCESS:
alerts_agent_module_standby($alert, 1);
break;
+
+ default:
+ // Ignore.
+ break;
}
}
@@ -439,23 +535,31 @@ function events_change_status($id_event, $new_status, $meta=false, $history=fals
/**
- * Change the owner of an event if the event hasn't owner
+ * Change the owner of an event if the event hasn't owner.
*
- * @param mixed Event ID or array of events
- * @param string id_user of the new owner. If is false, the current owner will be setted
- * @param bool flag to force the change or not (not force is change only when it hasn't owner)
- * @param bool metaconsole mode flag
- * @param bool history mode flag
+ * @param mixed $id_event Event ID or array of events.
+ * @param string $new_owner Id_user of the new owner. If is false, the current
+ * owner will be setted.
+ * @param boolean $force Flag to force the change or not (not force is
+ * change only when it hasn't owner).
+ * @param boolean $meta Metaconsole mode flag.
+ * @param boolean $history History mode flag.
*
- * @return boolean Whether or not it was successful
+ * @return boolean Whether or not it was successful.
*/
-function events_change_owner($id_event, $new_owner=false, $force=false, $meta=false, $history=false)
-{
+function events_change_owner(
+ $id_event,
+ $new_owner=false,
+ $force=false,
+ $meta=false,
+ $history=false
+) {
global $config;
$event_table = events_get_events_table($meta, $history);
- // Cleans up the selection for all unwanted values also casts any single values as an array
+ // Cleans up the selection for all unwanted values also casts any single
+ // values as an array.
$id_event = (array) safe_int($id_event, 1);
foreach ($id_event as $k => $id) {
@@ -476,20 +580,27 @@ function events_change_owner($id_event, $new_owner=false, $force=false, $meta=fa
}
// If no new_owner is provided, the current user will be the owner
- // ** Comment this lines because if possible selected None owner in owner event. TIQUET: #2250***
+ // * #2250: Comment this lines because if possible selected None owner.
// if (empty($new_owner)) {
// $new_owner = $config['id_user'];
// }
- // Only generate comment when is forced (sometimes is changed the owner when comment)
+ // Only generate comment when is forced (sometimes is owner changes when
+ // comment).
if ($force) {
- events_comment($id_event, '', "Change owner to $new_owner", $meta, $history);
+ events_comment(
+ $id_event,
+ '',
+ 'Change owner to '.$new_owner,
+ $meta,
+ $history
+ );
}
$values = ['owner_user' => $new_owner];
$where = ['id_evento' => $id_event];
- // If not force, add to where if owner_user = ''
+ // If not force, add to where if owner_user = ''.
if (!$force) {
$where['owner_user'] = '';
}
@@ -510,6 +621,14 @@ function events_change_owner($id_event, $new_owner=false, $force=false, $meta=fa
}
+/**
+ * Returns proper event table based on environment.
+ *
+ * @param boolean $meta Metaconsole environment or not.
+ * @param boolean $history Historical data or not.
+ *
+ * @return string Table name.
+ */
function events_get_events_table($meta, $history)
{
if ($meta) {
@@ -529,21 +648,30 @@ function events_get_events_table($meta, $history)
/**
* Comment events in a transresponse
*
- * @param mixed Event ID or array of events
- * @param string comment to be registered
- * @param string action performed with the comment. Bu default just Added comment
- * @param bool Flag of metaconsole mode
- * @param bool Flag of history mode
+ * @param mixed $id_event Event ID or array of events.
+ * @param string $comment Comment to be registered.
+ * @param string $action Action performed with comment. By default just add
+ * a comment.
+ * @param boolean $meta Flag of metaconsole mode.
+ * @param boolean $history Flag of history mode.
+ * @param boolean $similars Similars.
*
* @return boolean Whether or not it was successful
*/
-function events_comment($id_event, $comment='', $action='Added comment', $meta=false, $history=false, $similars=true)
-{
+function events_comment(
+ $id_event,
+ $comment='',
+ $action='Added comment',
+ $meta=false,
+ $history=false,
+ $similars=true
+) {
global $config;
$event_table = events_get_events_table($meta, $history);
- // Cleans up the selection for all unwanted values also casts any single values as an array
+ // Cleans up the selection for all unwanted values also casts any single
+ // values as an array.
$id_event = (array) safe_int($id_event, 1);
foreach ($id_event as $k => $id) {
@@ -564,25 +692,30 @@ function events_comment($id_event, $comment='', $action='Added comment', $meta=f
return false;
}
- // If the event hasn't owner, assign the user as owner
+ // If the event hasn't owner, assign the user as owner.
events_change_owner($id_event);
- // Get the current event comments
+ // Get the current event comments.
$first_event = $id_event;
if (is_array($id_event)) {
$first_event = reset($id_event);
}
- $event_comments = db_get_value('user_comment', $event_table, 'id_evento', $first_event);
+ $event_comments = db_get_value(
+ 'user_comment',
+ $event_table,
+ 'id_evento',
+ $first_event
+ );
$event_comments_array = [];
if ($event_comments == '') {
$comments_format = 'new';
} else {
- // If comments are not stored in json, the format is old
+ // If comments are not stored in json, the format is old.
$event_comments_array = json_decode($event_comments);
- if (is_null($event_comments_array)) {
+ if (empty($event_comments_array)) {
$comments_format = 'old';
} else {
$comments_format = 'new';
@@ -600,12 +733,17 @@ function events_comment($id_event, $comment='', $action='Added comment', $meta=f
$event_comments = io_json_mb_encode($event_comments_array);
- // Update comment
- $ret = db_process_sql_update($event_table, ['user_comment' => $event_comments], ['id_evento' => implode(',', $id_event)]);
+ // Update comment.
+ $ret = db_process_sql_update(
+ $event_table,
+ ['user_comment' => $event_comments],
+ ['id_evento' => implode(',', $id_event)]
+ );
break;
case 'old':
- // Give old ugly format to comment. TODO: Change this method for aux table or json
+ // Give old ugly format to comment. TODO: Change this method for
+ // aux table or json.
$comment = str_replace(["\r\n", "\r", "\n"], ' ', $comment);
if ($comment != '') {
@@ -614,30 +752,26 @@ function events_comment($id_event, $comment='', $action='Added comment', $meta=f
$commentbox = '';
}
- // Don't translate 'by' word because if various users with different languages
- // make comments in the same console will be a mess
- $comment = '-- '.$action.' by '.$config['id_user'].' '.'['.date($config['date_format']).'] -- '.$commentbox.' ';
+ // Don't translate 'by' word because if multiple users with
+ // different languages make comments in the same console
+ // will be a mess.
+ $comment = '-- '.$action.' by '.$config['id_user'].' ['.date($config['date_format']).'] -- '.$commentbox.' ';
- // Update comment
- switch ($config['dbtype']) {
- // Oldstyle SQL to avoid innecesary PHP foreach
- case 'mysql':
- $sql_validation = "UPDATE $event_table
- SET user_comment = concat('".$comment."', user_comment)
- WHERE id_evento in (".implode(',', $id_event).')';
+ // Update comment.
+ $sql_validation = sprintf(
+ 'UPDATE %s
+ SET user_comment = concat("%s", user_comment)
+ WHERE id_evento in (%s)',
+ $event_table,
+ $comment,
+ implode(',', $id_event)
+ );
- $ret = db_process_sql($sql_validation);
- break;
+ $ret = db_process_sql($sql_validation);
+ break;
- case 'postgresql':
- case 'oracle':
- $sql_validation = "UPDATE $event_table
- SET user_comment='".$comment."' || user_comment)
- WHERE id_evento in (".implode(',', $id_event).')';
-
- $ret = db_process_sql($sql_validation);
- break;
- }
+ default:
+ // Ignore.
break;
}
@@ -652,13 +786,18 @@ function events_comment($id_event, $comment='', $action='Added comment', $meta=f
/**
* Get group id of an event.
*
- * @param integer $id_event Event id
+ * @param integer $id_event Event id.
*
* @return integer Group id of the given event.
*/
function events_get_group($id_event)
{
- return (int) db_get_value('id_grupo', 'tevento', 'id_evento', (int) $id_event);
+ return (int) db_get_value(
+ 'id_grupo',
+ 'tevento',
+ 'id_evento',
+ (int) $id_event
+ );
}
@@ -671,24 +810,37 @@ function events_get_group($id_event)
*/
function events_get_description($id_event)
{
- return (string) db_get_value('evento', 'tevento', 'id_evento', (int) $id_event);
+ return (string) db_get_value(
+ 'evento',
+ 'tevento',
+ 'id_evento',
+ (int) $id_event
+ );
}
/**
* Insert a event in the event log system.
*
- * @param integer $event
- * @param integer $id_group
- * @param integer $id_agent
- * @param integer $status
- * @param string $id_user
- * @param string $event_type
- * @param integer $priority
- * @param integer $id_agent_module
- * @param integer $id_aam
+ * @param integer $event Event.
+ * @param integer $id_group Id_group.
+ * @param integer $id_agent Id_agent.
+ * @param integer $status Status.
+ * @param string $id_user Id_user.
+ * @param string $event_type Event_type.
+ * @param integer $priority Priority.
+ * @param integer $id_agent_module Id_agent_module.
+ * @param integer $id_aam Id_aam.
+ * @param string $critical_instructions Critical_instructions.
+ * @param string $warning_instructions Warning_instructions.
+ * @param string $unknown_instructions Unknown_instructions.
+ * @param boolean $source Source.
+ * @param string $tags Tags.
+ * @param string $custom_data Custom_data.
+ * @param integer $server_id Server_id.
+ * @param string $id_extra Id_extra.
*
- * @return integer event id
+ * @return integer Event id.
*/
function events_create_event(
$event,
@@ -719,206 +871,64 @@ function events_create_event(
if (defined('METACONSOLE')) {
$table_events = 'tmetaconsole_event';
- switch ($config['dbtype']) {
- case 'mysql':
- $sql = sprintf(
- '
- INSERT INTO '.$table_events.' (id_agente, id_grupo, evento,
- timestamp, estado, utimestamp, id_usuario,
- event_type, criticity, id_agentmodule, id_alert_am,
- critical_instructions, warning_instructions,
- unknown_instructions, source, tags, custom_data,
- server_id, id_extra, data, module_status)
- VALUES (%d, %d, "%s", NOW(), %d, UNIX_TIMESTAMP(NOW()),
- "%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s",
- "%s", "%s", %d, "%s", %d, %d)',
- $id_agent,
- $id_group,
- $event,
- $status,
- $id_user,
- $event_type,
- $priority,
- $id_agent_module,
- $id_aam,
- $critical_instructions,
- $warning_instructions,
- $unknown_instructions,
- $source,
- $tags,
- $custom_data,
- $server_id,
- $id_extra,
- $data,
- $module_status
- );
- break;
-
- case 'postgresql':
- $sql = sprintf(
- '
- INSERT INTO '.$table_events.' (id_agente, id_grupo, evento,
- timestamp, estado, utimestamp, id_usuario,
- event_type, criticity, id_agentmodule, id_alert_am,
- critical_instructions, warning_instructions,
- unknown_instructions, source, tags, custom_data,
- server_id, id_extra, data, module_status)
- VALUES (%d, %d, "%s", NOW(), %d,
- ceil(date_part(\'epoch\', CURRENT_TIMESTAMP)), "%s",
- "%s", %d, %d, %d, "%s", "%s", "%s", "%s", "%s",
- "%s", %d, "%s", %d, %d)',
- $id_agent,
- $id_group,
- $event,
- $status,
- $id_user,
- $event_type,
- $priority,
- $id_agent_module,
- $id_aam,
- $critical_instructions,
- $warning_instructions,
- $unknown_instructions,
- $source,
- $tags,
- $custom_data,
- $server_id,
- $id_extra,
- $data,
- $module_status
- );
- break;
-
- case 'oracle':
- $sql = sprintf(
- '
- INSERT INTO '.$table_events.' (id_agente, id_grupo, evento,
- timestamp, estado, utimestamp, id_usuario,
- event_type, criticity, id_agentmodule, id_alert_am,
- critical_instructions, warning_instructions,
- unknown_instructions, source, tags, custom_data,
- server_id, id_extra, data, module_status)
- VALUES (%d, %d, "%s", CURRENT_TIMESTAMP, %d, UNIX_TIMESTAMP,
- "%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s",
- "%s", "%s", %d, "%s", %d, %d)',
- $id_agent,
- $id_group,
- $event,
- $status,
- $id_user,
- $event_type,
- $priority,
- $id_agent_module,
- $id_aam,
- $critical_instructions,
- $warning_instructions,
- $unknown_instructions,
- $source,
- $tags,
- $custom_data,
- $server_id,
- $id_extra,
- $data,
- $module_status
- );
- break;
- }
+ $sql = sprintf(
+ 'INSERT INTO '.$table_events.' (id_agente, id_grupo, evento,
+ timestamp, estado, utimestamp, id_usuario,
+ event_type, criticity, id_agentmodule, id_alert_am,
+ critical_instructions, warning_instructions,
+ unknown_instructions, source, tags, custom_data,
+ server_id, id_extra, data, module_status)
+ VALUES (%d, %d, "%s", NOW(), %d, UNIX_TIMESTAMP(NOW()),
+ "%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s",
+ "%s", "%s", %d, "%s", %d, %d)',
+ $id_agent,
+ $id_group,
+ $event,
+ $status,
+ $id_user,
+ $event_type,
+ $priority,
+ $id_agent_module,
+ $id_aam,
+ $critical_instructions,
+ $warning_instructions,
+ $unknown_instructions,
+ $source,
+ $tags,
+ $custom_data,
+ $server_id,
+ $id_extra,
+ $data,
+ $module_status
+ );
} else {
- switch ($config['dbtype']) {
- case 'mysql':
- $sql = sprintf(
- '
- INSERT INTO '.$table_events.' (id_agente, id_grupo, evento,
- timestamp, estado, utimestamp, id_usuario,
- event_type, criticity, id_agentmodule, id_alert_am,
- critical_instructions, warning_instructions,
- unknown_instructions, source, tags, custom_data, id_extra, data, module_status)
- VALUES (%d, %d, "%s", NOW(), %d, UNIX_TIMESTAMP(NOW()),
- "%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s", "%s", "%s", "%s", %d, %d)',
- $id_agent,
- $id_group,
- $event,
- $status,
- $id_user,
- $event_type,
- $priority,
- $id_agent_module,
- $id_aam,
- $critical_instructions,
- $warning_instructions,
- $unknown_instructions,
- $source,
- $tags,
- $custom_data,
- $id_extra,
- $data,
- $module_status
- );
- break;
-
- case 'postgresql':
- $sql = sprintf(
- '
- INSERT INTO '.$table_events.' (id_agente, id_grupo, evento,
- timestamp, estado, utimestamp, id_usuario,
- event_type, criticity, id_agentmodule, id_alert_am,
- critical_instructions, warning_instructions,
- unknown_instructions, source, tags, custom_data, id_extra, data, module_status)
- VALUES (%d, %d, "%s", NOW(), %d,
- ceil(date_part(\'epoch\', CURRENT_TIMESTAMP)), "%s",
- "%s", %d, %d, %d, "%s", "%s", "%s", "%s", "%s", "%s", "%s", %d, %d)',
- $id_agent,
- $id_group,
- $event,
- $status,
- $id_user,
- $event_type,
- $priority,
- $id_agent_module,
- $id_aam,
- $critical_instructions,
- $warning_instructions,
- $unknown_instructions,
- $source,
- $tags,
- $custom_data,
- $id_extra,
- $data,
- $module_status
- );
- break;
-
- case 'oracle':
- $sql = sprintf(
- '
- INSERT INTO '.$table_events." (id_agente, id_grupo, evento,
- timestamp, estado, utimestamp, id_usuario,
- event_type, criticity, id_agentmodule, id_alert_am,
- critical_instructions, warning_instructions,
- unknown_instructions, source, tags, custom_data, id_extra, data, module_status)
- VALUES (%d, %d, '%s', CURRENT_TIMESTAMP, %d, UNIX_TIMESTAMP,
- '%s', '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d)",
- $id_agent,
- $id_group,
- $event,
- $status,
- $id_user,
- $event_type,
- $priority,
- $id_agent_module,
- $id_aam,
- $critical_instructions,
- $warning_instructions,
- $unknown_instructions,
- $source,
- $tags,
- $custom_data,
- $id_extra,
- $data,
- $module_status
- );
- break;
- }
+ $sql = sprintf(
+ 'INSERT INTO '.$table_events.' (id_agente, id_grupo, evento,
+ timestamp, estado, utimestamp, id_usuario,
+ event_type, criticity, id_agentmodule, id_alert_am,
+ critical_instructions, warning_instructions,
+ unknown_instructions, source, tags, custom_data, id_extra, data, module_status)
+ VALUES (%d, %d, "%s", NOW(), %d, UNIX_TIMESTAMP(NOW()),
+ "%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s", "%s", "%s", "%s", %d, %d)',
+ $id_agent,
+ $id_group,
+ $event,
+ $status,
+ $id_user,
+ $event_type,
+ $priority,
+ $id_agent_module,
+ $id_aam,
+ $critical_instructions,
+ $warning_instructions,
+ $unknown_instructions,
+ $source,
+ $tags,
+ $custom_data,
+ $id_extra,
+ $data,
+ $module_status
+ );
}
return (int) db_process_sql($sql, 'insert_id');
@@ -926,24 +936,32 @@ function events_create_event(
/**
- * Prints a small event table
+ * Prints a small event table.
*
- * @param string $filter SQL WHERE clause
- * @param integer $limit How many events to show
- * @param integer $width How wide the table should be
- * @param boolean $return Prints out HTML if false
- * @param int agent id if is the table of one agent. 0 otherwise
+ * @param string $filter SQL WHERE clause.
+ * @param integer $limit How many events to show.
+ * @param integer $width How wide the table should be.
+ * @param boolean $return Prints out HTML if false.
+ * @param integer $agent_id Agent id if is the table of one agent.
+ * 0 otherwise.
+ * @param boolean $tactical_view Be shown in tactical view or not.
*
- * @return string HTML with table element
+ * @return string HTML with table element.
*/
-function events_print_event_table($filter='', $limit=10, $width=440, $return=false, $agent_id=0, $tactical_view=false)
-{
+function events_print_event_table(
+ $filter='',
+ $limit=10,
+ $width=440,
+ $return=false,
+ $agent_id=0,
+ $tactical_view=false
+) {
global $config;
if ($agent_id == 0) {
$agent_condition = '';
} else {
- $agent_condition = " id_agente = $agent_id AND ";
+ $agent_condition = ' id_agente = '.$agent_id.' AND ';
}
if ($filter == '') {
@@ -991,7 +1009,9 @@ function events_print_event_table($filter='', $limit=10, $width=440, $return=fal
$table->cellclass = [];
$table->data = [];
$table->align = [];
- $table->style[0] = $table->style[1] = $table->style[2] = 'width:25px;';
+ $table->style[0] = 'width:25px;';
+ $table->style[1] = 'width:25px;';
+ $table->style[2] = 'width:25px;';
if ($agent_id == 0) {
$table->style[3] = 'word-break: break-all;';
}
@@ -1026,7 +1046,7 @@ function events_print_event_table($filter='', $limit=10, $width=440, $return=fal
}
foreach ($result as $event) {
- // Copy all groups of the agent and append the event group
+ // Copy all groups of the agent and append the event group.
$check_events = $all_groups;
$check_events[] = $event['id_grupo'];
if (! check_acl_one_of_groups($config['id_user'], $check_events, 'ER')) {
@@ -1035,7 +1055,7 @@ function events_print_event_table($filter='', $limit=10, $width=440, $return=fal
$data = [];
- // Colored box
+ // Colored box.
switch ($event['estado']) {
case 0:
$img = 'images/star.png';
@@ -1051,6 +1071,10 @@ function events_print_event_table($filter='', $limit=10, $width=440, $return=fal
$img = 'images/hourglass.png';
$title = __('Event in process');
break;
+
+ default:
+ // Ignore.
+ break;
}
$data[0] = html_print_image(
@@ -1095,20 +1119,25 @@ function events_print_event_table($filter='', $limit=10, $width=440, $return=fal
]
);
- // Event type
+ // Event type.
$data[2] = events_print_type_img($event['event_type'], true);
- // Event text
- $data[3] = ui_print_string_substr(strip_tags(io_safe_output($event['evento'])), 75, true, '7.5');
+ // Event text.
+ $data[3] = ui_print_string_substr(
+ strip_tags(io_safe_output($event['evento'])),
+ 75,
+ true,
+ '7.5'
+ );
if ($agent_id == 0) {
if ($event['id_agente'] > 0) {
- // Agent name
- // Get class name, for the link color...
+ // Agent name.
+ // Get class name, for the link color, etc.
$myclass = get_priority_class($event['criticity']);
- $data[4] = "".agents_get_alias($event['id_agente']).'';
- // for System or SNMP generated alerts
+ $data[4] = "".agents_get_alias($event['id_agente']).'';
+ // For System or SNMP generated alerts.
} else if ($event['event_type'] == 'system') {
$data[4] = __('System');
} else {
@@ -1116,13 +1145,21 @@ function events_print_event_table($filter='', $limit=10, $width=440, $return=fal
}
}
- // Timestamp
+ // Timestamp.
$data[5] = ui_print_timestamp($event['timestamp'], true, ['style' => 'font-size: 7.5pt; letter-spacing: 0.3pt;']);
$class = get_priority_class($event['criticity']);
- $cell_classes[3] = $cell_classes[4] = $cell_classes[5] = $class;
+ $cell_classes[3] = $class;
+ $cell_classes[4] = $class;
+ $cell_classes[5] = $class;
+
array_push($table->cellclass, $cell_classes);
- // array_push ($table->rowclass, get_priority_class ($event["criticity"]));
+
+ /*
+ Commented out (old).
+ // array_push ($table->rowclass, get_priority_class ($event["criticity"]));
+ */
+
array_push($table->data, $data);
}
@@ -1162,16 +1199,19 @@ function events_print_event_table($filter='', $limit=10, $width=440, $return=fal
/**
- * Prints the event type image
+ * Prints the event type image.
*
- * @param string $type Event type from SQL
- * @param boolean $return Whether to return or print
+ * @param string $type Event type from SQL.
+ * @param boolean $return Whether to return or print.
* @param boolean $only_url Flag to return only url of image, by default false.
*
- * @return string HTML with img
+ * @return string HTML with img.
*/
-function events_print_type_img($type, $return=false, $only_url=false)
-{
+function events_print_type_img(
+ $type,
+ $return=false,
+ $only_url=false
+) {
global $config;
$output = '';
@@ -1189,13 +1229,13 @@ function events_print_type_img($type, $return=false, $only_url=false)
case 'going_down_critical':
case 'going_up_critical':
- // This is to be backwards compatible
+ // This is to be backwards compatible.
$icon = 'module_critical.png';
break;
case 'going_up_normal':
case 'going_down_normal':
- // This is to be backwards compatible
+ // This is to be backwards compatible.
$icon = 'module_ok.png';
break;
@@ -1235,7 +1275,7 @@ function events_print_type_img($type, $return=false, $only_url=false)
}
if ($only_url) {
- $output = $urlImage.'/'.'images/'.$icon;
+ $output = $urlImage.'/images/'.$icon;
} else {
$output .= html_print_image(
'images/'.$icon,
@@ -1255,8 +1295,8 @@ function events_print_type_img($type, $return=false, $only_url=false)
/**
* Prints the event type description
*
- * @param string $type Event type from SQL
- * @param boolean $return Whether to return or print
+ * @param string $type Event type from SQL.
+ * @param boolean $return Whether to return or print.
*
* @return string HTML with img
*/
@@ -1283,13 +1323,13 @@ function events_print_type_description($type, $return=false)
case 'going_down_critical':
case 'going_up_critical':
- // This is to be backwards compatible
+ // This is to be backwards compatible.
$output .= __('Going up to critical state');
break;
case 'going_up_normal':
case 'going_down_normal':
- // This is to be backwards compatible
+ // This is to be backwards compatible.
$output .= __('Going up to normal state');
break;
@@ -1306,7 +1346,7 @@ function events_print_type_description($type, $return=false)
break;
case 'recon_host_detected';
- $output .= __('Recon server detected a new host');
+ $output .= __('Discovery server detected a new host');
break;
case 'new_agent';
@@ -1344,9 +1384,15 @@ function events_print_type_description($type, $return=false)
*
* The returned events will be in the time interval ($date - $period, $date]
*
- * @param mixed $id_group Group id to get events for.
- * @param integer $period Period of time in seconds to get events.
- * @param integer $date Beginning date to get events.
+ * @param mixed $begin Begin.
+ * @param mixed $result Result.
+ * @param mixed $id_group Group id to get events for.
+ * @param integer $period Period in seconds to get events.
+ * @param integer $date Beginning date to get events.
+ * @param boolean $filter_event_validated Filter_event_validated.
+ * @param boolean $filter_event_critical Filter_event_critical.
+ * @param boolean $filter_event_warning Filter_event_warning.
+ * @param boolean $filter_event_no_validated Filter_event_no_validated.
*
* @return array An array with all the events happened.
*/
@@ -1366,7 +1412,7 @@ function events_get_group_events_steps(
$id_group = groups_safe_acl($config['id_user'], $id_group, 'ER');
if (empty($id_group)) {
- // An empty array means the user doesn't have access
+ // An empty array means the user doesn't have access.
return false;
}
@@ -1420,9 +1466,20 @@ function events_get_group_events_steps(
*
* The returned events will be in the time interval ($date - $period, $date]
*
- * @param integer $id_agent Agent id to get events.
- * @param integer $period Period of time in seconds to get events.
- * @param integer $date Beginning date to get events.
+ * @param integer $id_agent Agent id to get events.
+ * @param integer $period Period in seconds to get events.
+ * @param integer $date Beginning date to get events.
+ * @param boolean $history History.
+ * @param boolean $show_summary_group Show_summary_group.
+ * @param boolean $filter_event_severity Filter_event_severity.
+ * @param boolean $filter_event_type Filter_event_type.
+ * @param boolean $filter_event_status Filter_event_status.
+ * @param boolean $filter_event_filter_search Filter_event_filter_search.
+ * @param boolean $id_group Id_group.
+ * @param boolean $events_group Events_group.
+ * @param boolean $id_agent_module Id_agent_module.
+ * @param boolean $events_module Events_module.
+ * @param boolean $id_server Id_server.
*
* @return array An array with all the events happened.
*/
@@ -1456,7 +1513,7 @@ function events_get_agent(
$id_group = groups_safe_acl($config['id_user'], $id_group, 'ER');
if (empty($id_group)) {
- // An empty array means the user doesn't have access
+ // An empty array means the user doesn't have access.
return false;
}
}
@@ -1485,6 +1542,7 @@ function events_get_agent(
break;
default:
+ // Ignore.
break;
}
}
@@ -1505,12 +1563,16 @@ function events_get_agent(
case 3:
$filter_event_status[$key] = ('0, 2');
default:
+ // Ignore.
break;
}
}
if (!$status_all) {
- $sql_where .= ' AND estado IN ('.implode(', ', $filter_event_status).')';
+ $sql_where .= ' AND estado IN ('.implode(
+ ', ',
+ $filter_event_status
+ ).')';
}
}
@@ -1519,10 +1581,10 @@ function events_get_agent(
$type = [];
foreach ($filter_event_type as $event_type) {
if ($event_type != '') {
- // If normal, warning, could be several (going_up_warning, going_down_warning... too complex
- // for the user so for him is presented only "warning, critical and normal"
+ // If normal, warning, could be several (going_up_warning, going_down_warning... too complex.
+ // Shown to user only "warning, critical and normal".
if ($event_type == 'warning' || $event_type == 'critical' || $event_type == 'normal') {
- $type[] = " event_type LIKE '%$event_type%' ";
+ $type[] = " event_type LIKE '%".$event_type."%' ";
} else if ($event_type == 'not_normal') {
$type[] = " (event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%') ";
} else if ($event_type != 'all') {
@@ -1535,7 +1597,7 @@ function events_get_agent(
}
if (!empty($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).'%")';
+ $sql_where .= ' AND (evento LIKE "%'.io_safe_input($filter_event_filter_search).'%" OR id_evento LIKE "%'.io_safe_input($filter_event_filter_search).'%")';
}
if ($events_group) {
@@ -1729,6 +1791,8 @@ function events_get_severity_types($severity_id)
/**
* Return all descriptions of event status.
*
+ * @param boolean $report Show in report or not.
+ *
* @return array Status description array.
*/
function events_get_all_status($report=false)
@@ -1781,6 +1845,10 @@ function events_get_status($status_id)
case 3:
$status_desc = __('Only not validated');
break;
+
+ default:
+ // Ignore.
+ break;
}
return $status_desc;
@@ -1800,10 +1868,10 @@ function events_check_event_filter_group($id_filter)
$id_group = db_get_value('id_group_filter', 'tevent_filter', 'id_filter', $id_filter);
$own_info = get_user_info($config['id_user']);
- // Get group list that user has access
+ // Get group list that user has access.
$groups_user = users_get_groups($config['id_user'], 'EW', $own_info['is_admin'], true);
- // Permissions in any group allow to edit "All group" filters
+ // Permissions in any group allow to edit "All group" filters.
if ($id_group == 0 && !empty($groups_user)) {
return true;
}
@@ -1824,9 +1892,9 @@ function events_check_event_filter_group($id_filter)
/**
* Get a event filter.
*
- * @param int Filter id to be fetched.
- * @param array Extra filter.
- * @param array Fields to be fetched.
+ * @param integer $id_filter Filter id to be fetched.
+ * @param array $filter Extra filter.
+ * @param array $fields Fields to be fetched.
*
* @return array A event filter matching id and filter or false.
*/
@@ -1848,7 +1916,9 @@ function events_get_event_filter($id_filter, $filter=false, $fields=false)
/**
* Get a event filters in select format.
*
- * @param boolean If event filters are used for manage/view operations (non admin users can see group ALL for manage) # Fix
+ * @param boolean $manage If event filters are used for manage/view operations
+ * (non admin users can see group ALL for manage) # Fix.
+ *
* @return array A event filter matching id and filter or false.
*/
function events_get_event_filter_select($manage=true)
@@ -1895,13 +1965,20 @@ function events_get_event_filter_select($manage=true)
}
-// Events pages functions to load modal window with advanced view of an event.
-// Called from include/ajax/events.php
+/**
+ * Events pages functions to load modal window with advanced view of an event.
+ * Called from include/ajax/events.php.
+ *
+ * @param mixed $event Event.
+ * @param array $childrens_ids Children_ids.
+ *
+ * @return string HTML.
+ */
function events_page_responses($event, $childrens_ids=[])
{
global $config;
//
- // Responses
+ // Responses.
//
$table_responses->cellspacing = 2;
$table_responses->cellpadding = 2;
@@ -1914,26 +1991,43 @@ function events_page_responses($event, $childrens_ids=[])
$table_responses->class = 'alternate rounded_cells';
if (tags_checks_event_acl($config['id_user'], $event['id_grupo'], 'EM', $event['clean_tags'], $childrens_ids)) {
- // Owner
+ // Owner.
$data = [];
$data[0] = __('Change owner');
- // Owner change can be done to users that belong to the event group with ER permission
+ // Owner change can be done to users that belong to the event group
+ // with ER permission.
$profiles_view_events = db_get_all_rows_filter('tperfil', ['event_view' => '1'], 'id_perfil');
foreach ($profiles_view_events as $k => $v) {
$profiles_view_events[$k] = reset($v);
}
- // Juanma (05/05/2014) Fix : Propagate ACL hell!
- $_user_groups = array_keys(users_get_groups($config['id_user'], 'ER', users_can_manage_group_all()));
- $strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
+ // Juanma (05/05/2014) Fix : Propagate ACL.
+ $_user_groups = array_keys(
+ users_get_groups($config['id_user'], 'ER', users_can_manage_group_all())
+ );
+ $strict_user = db_get_value(
+ 'strict_acl',
+ 'tusuario',
+ 'id_user',
+ $config['id_user']
+ );
if ($strict_user) {
- $user_name = db_get_value('fullname', 'tusuario', 'id_user', $config['id_user']);
+ $user_name = db_get_value(
+ 'fullname',
+ 'tusuario',
+ 'id_user',
+ $config['id_user']
+ );
$users = [];
$users[0]['id_user'] = $config['id_user'];
$users[0]['fullname'] = $user_name;
} else {
- $users = groups_get_users($_user_groups, ['id_perfil' => $profiles_view_events], true);
+ $users = groups_get_users(
+ $_user_groups,
+ ['id_perfil' => $profiles_view_events],
+ true
+ );
}
foreach ($users as $u) {
@@ -1943,24 +2037,52 @@ function events_page_responses($event, $childrens_ids=[])
if ($event['owner_user'] == '') {
$owner_name = __('None');
} else {
- $owner_name = db_get_value('fullname', 'tusuario', 'id_user', $event['owner_user']);
+ $owner_name = db_get_value(
+ 'fullname',
+ 'tusuario',
+ 'id_user',
+ $event['owner_user']
+ );
$owners[$event['owner_user']] = $owner_name;
}
- $data[1] = html_print_select($owners, 'id_owner', $event['owner_user'], '', __('None'), -1, true);
- $data[1] .= html_print_button(__('Update'), 'owner_button', false, 'event_change_owner();', 'class="sub next"', true);
+ $data[1] = html_print_select(
+ $owners,
+ 'id_owner',
+ $event['owner_user'],
+ '',
+ __('None'),
+ -1,
+ true
+ );
+ $data[1] .= html_print_button(
+ __('Update'),
+ 'owner_button',
+ false,
+ 'event_change_owner();',
+ 'class="sub next"',
+ true
+ );
$table_responses->data[] = $data;
}
- // Status
+ // Status.
$data = [];
$data[0] = __('Change status');
$status_blocked = false;
- if (tags_checks_event_acl($config['id_user'], $event['id_grupo'], 'EM', $event['clean_tags'], $childrens_ids)) {
- // If the user has manager acls, the status can be changed to all possibilities always
+ if (tags_checks_event_acl(
+ $config['id_user'],
+ $event['id_grupo'],
+ 'EM',
+ $event['clean_tags'],
+ $childrens_ids
+ )
+ ) {
+ // If the user has manager acls, the status can be changed to all
+ // possibilities always.
$status = [
0 => __('New'),
2 => __('In process'),
@@ -1969,7 +2091,8 @@ function events_page_responses($event, $childrens_ids=[])
} else {
switch ($event['estado']) {
case 0:
- // If the user hasnt manager acls and the event is new. The status can be changed
+ // If the user hasnt manager acls and the event is new.
+ // The status can be changed.
$status = [
2 => __('In process'),
1 => __('Validated'),
@@ -1977,48 +2100,99 @@ function events_page_responses($event, $childrens_ids=[])
break;
case 1:
- // If the user hasnt manager acls and the event is validated. The status cannot be changed
+ // If the user hasnt manager acls and the event is validated.
+ // The status cannot be changed.
$status = [1 => __('Validated')];
$status_blocked = true;
break;
case 2:
- // If the user hasnt manager acls and the event is in process. The status only can be changed to validated
+ // If the user hasnt manager acls and the event is in process.
+ // The status only can be changed to validated.
$status = [1 => __('Validated')];
break;
+
+ default:
+ // Ignored.
+ break;
}
}
- // The change status option will be enabled only when is possible change the status
- $data[1] = html_print_select($status, 'estado', $event['estado'], '', '', 0, true, false, false, '', $status_blocked);
+ // The change status option will be enabled only when is possible change
+ // the status.
+ $data[1] = html_print_select(
+ $status,
+ 'estado',
+ $event['estado'],
+ '',
+ '',
+ 0,
+ true,
+ false,
+ false,
+ '',
+ $status_blocked
+ );
if (!$status_blocked) {
- $data[1] .= html_print_button(__('Update'), 'status_button', false, 'event_change_status(\''.$event['similar_ids'].'\');', 'class="sub next"', true);
+ $data[1] .= html_print_button(
+ __('Update'),
+ 'status_button',
+ false,
+ 'event_change_status(\''.$event['similar_ids'].'\');',
+ 'class="sub next"',
+ true
+ );
}
$table_responses->data[] = $data;
- // Comments
+ // Comments.
$data = [];
$data[0] = __('Comment');
- $data[1] = html_print_button(__('Add comment'), 'comment_button', false, '$(\'#link_comments\').trigger(\'click\');', 'class="sub next"', true);
+ $data[1] = html_print_button(
+ __('Add comment'),
+ 'comment_button',
+ false,
+ '$(\'#link_comments\').trigger(\'click\');',
+ 'class="sub next"',
+ true
+ );
$table_responses->data[] = $data;
- if (tags_checks_event_acl($config['id_user'], $event['id_grupo'], 'EM', $event['clean_tags'], $childrens_ids)) {
- // Delete
+ if (tags_checks_event_acl(
+ $config['id_user'],
+ $event['id_grupo'],
+ 'EM',
+ $event['clean_tags'],
+ $childrens_ids
+ )
+ ) {
+ // Delete.
$data = [];
$data[0] = __('Delete event');
$data[1] = '';
$table_responses->data[] = $data;
}
- // Custom responses
+ // Custom responses.
$data = [];
$data[0] = __('Custom responses');
@@ -2054,7 +2228,14 @@ function events_page_responses($event, $childrens_ids=[])
$server_id = 0;
}
- $data[1] .= html_print_button(__('Execute'), 'custom_response_button', false, 'execute_response('.$event['id_evento'].','.$server_id.')', "class='sub next'", true);
+ $data[1] .= html_print_button(
+ __('Execute'),
+ 'custom_response_button',
+ false,
+ 'execute_response('.$event['id_evento'].','.$server_id.')',
+ "class='sub next'",
+ true
+ );
}
$table_responses->data[] = $data;
@@ -2091,29 +2272,35 @@ function events_page_responses($event, $childrens_ids=[])
/**
* Replace macros in the target of a response and return it.
- * If server_id > 0, it's a metaconsole query.
+ * If server_id > 0, is a metaconsole query.
*
- * @param integer $event_id Event identifier.
- * @param integer $response_id Event response identifier.
- * @param integer $server_id Node identifier (for metaconsole).
- * @param boolean $history Use the history database or not.
+ * @param integer $event_id Event_id.
+ * @param integer $response_id Response_id.
+ * @param integer $server_id Server_id.
+ * @param boolean $history History.
*
- * @return string The response text with the macros applied.
+ * @return string Target.
*/
function events_get_response_target(
- int $event_id,
- int $response_id,
- int $server_id=0,
- bool $history=false
+ $event_id,
+ $response_id,
+ $server_id,
+ $history=false
) {
global $config;
- // If server_id > 0, it's a metaconsole query.
- $meta = $server_id > 0;
+ $event_response = db_get_row('tevent_response', 'id', $response_id);
+
+ if ($server_id > 0) {
+ $meta = true;
+ } else {
+ $meta = false;
+ }
+
$event_table = events_get_events_table($meta, $history);
+
$event = db_get_row($event_table, 'id_evento', $event_id);
- $event_response = db_get_row('tevent_response', 'id', $response_id);
$target = io_safe_output($event_response['target']);
// Substitute each macro.
@@ -2130,7 +2317,7 @@ function events_get_response_target(
}
$ip = db_get_value_filter('direccion', $agente_table_name, $filter);
- // If agent has not an IP, display N/A.
+ // If agent has not an ip, display N/A.
if ($ip === false) {
$ip = __('N/A');
}
@@ -2201,7 +2388,11 @@ function events_get_response_target(
}
if (strpos($target, '_event_utimestamp_') !== false) {
- $target = str_replace('_event_utimestamp_', $event['utimestamp'], $target);
+ $target = str_replace(
+ '_event_utimestamp_',
+ $event['utimestamp'],
+ $target
+ );
}
if (strpos($target, '_event_date_') !== false) {
@@ -2290,7 +2481,12 @@ function events_get_response_target(
}
if (strpos($target, '_group_custom_id_') !== false) {
- $group_custom_id = db_get_value($dbh, 'SELECT custom_id FROM tgrupo WHERE id_grupo=?', $event['id_grupo']);
+ $group_custom_id = db_get_value_sql(
+ sprintf(
+ 'SELECT custom_id FROM tgrupo WHERE id_grupo=%s',
+ $event['id_grupo']
+ )
+ );
$event_st = events_display_status($event['estado']);
$target = str_replace('_group_custom_id_', $group_custom_id, $target);
}
@@ -2303,21 +2499,23 @@ function events_get_response_target(
}
}
- // This will replace the macro with the current logged user.
- if (strpos($target, '_current_user_') !== false) {
- $target = str_replace('_current_user_', $config['id_user'], $target);
- }
-
return $target;
}
+/**
+ * Generates 'custom field' page for event viewer.
+ *
+ * @param array $event Event to be displayed.
+ *
+ * @return string HTML.
+ */
function events_page_custom_fields($event)
{
global $config;
//
- // Custom fields
+ // Custom fields.
//
$table->cellspacing = 2;
$table->cellpadding = 2;
@@ -2358,7 +2556,7 @@ function events_page_custom_fields($event)
}
foreach ($fields as $field) {
- // Owner
+ // Owner.
$data = [];
$data[0] = $field['name'];
@@ -2383,15 +2581,82 @@ function events_page_custom_fields($event)
}
+/**
+ * Retrieves extended information of given event.
+ *
+ * @param integer $id_evento Target event.
+ *
+ * @return mixed array Of extended events or false if error.
+ */
+function events_get_extended_events(int $id_evento)
+{
+ return db_get_all_rows_sql(
+ sprintf(
+ 'SELECT * FROM tevent_extended
+ WHERE id_evento=%d ORDER BY utimestamp DESC',
+ $id_evento
+ )
+ );
+
+}
+
+
+/**
+ * Return if event has extended info or not.
+ *
+ * @param integer $id_event Target event.
+ *
+ * @return boolean Has extended info or not
+ */
+function events_has_extended_info(int $id_event)
+{
+ return (bool) db_get_value_sql(
+ sprintf(
+ 'SELECT count(*) as "n" FROM (
+ SELECT *
+ FROM tevent_extended WHERE id_evento=%d LIMIT 1) t',
+ $id_event
+ )
+ );
+}
+
+
+/**
+ * Generates the 'related' page in event view.
+ *
+ * @param array $event To be displayed.
+ * @param string $server Server (if in metaconsole environment).
+ *
+ * @return string HTML to be displayed.
+ */
+function events_page_related($event, $server='')
+{
+ $html = '
';
+ $html .= '
'.__('Extended information').'
';
+ $html .= '
'.__('Loading').'...
';
+ $html .= '
';
+
+ return $html;
+}
+
+
+/**
+ * Generates the 'details' page in event view.
+ *
+ * @param array $event To be displayed.
+ * @param string $server Server (if in metaconsole environment).
+ *
+ * @return string HTML to be displayed.
+ */
function events_page_details($event, $server='')
{
global $img_sev;
global $config;
- // If server is provided, get the hash parameters
+ // If server is provided, get the hash parameters.
if (!empty($server) && defined('METACONSOLE')) {
$hashdata = metaconsole_get_server_hashdata($server);
- $hashstring = '&'.'loginhash=auto&'.'loginhash_data='.$hashdata.'&'.'loginhash_user='.str_rot13($config['id_user']);
+ $hashstring = '&loginhash=auto&loginhash_data='.$hashdata.'&loginhash_user='.str_rot13($config['id_user']);
$serverstring = $server['server_url'].'/';
if (metaconsole_connect($server) !== NOERR) {
@@ -2403,7 +2668,7 @@ function events_page_details($event, $server='')
}
//
- // Details
+ // Details.
//
$table_details->width = '100%';
$table_details->data = [];
@@ -2414,15 +2679,20 @@ function events_page_details($event, $server='')
$table_details->style[1] = 'text-align: left; height: 23px;';
$table_details->class = 'alternate rounded_cells';
- switch ($event['event_type']) {
+ /*
+ * Useless switch.
+
+ switch ($event['event_type']) {
case 'going_unknown':
case 'going_up_warning':
case 'going_down_warning':
case 'going_up_critical':
case 'going_down_critical':
-
+ default:
+ // Ignore.
break;
- }
+ }
+ */
if ($event['id_agente'] != 0) {
$agent = db_get_row('tagente', 'id_agente', $event['id_agente']);
@@ -2430,7 +2700,6 @@ function events_page_details($event, $server='')
$agent = [];
}
- $data = [];
$data[0] = __('Agent details');
$data[1] = empty($agent) ? ''.__('N/A').'' : '';
$table_details->data[] = $data;
@@ -2439,9 +2708,24 @@ function events_page_details($event, $server='')
$data = [];
$data[0] = '
+ ",
+ $message_info['id_mensaje'],
+ messages_get_url($message_info['id_mensaje']),
+ html_print_image('images/'.$message_info['icon'], true),
+ $message_info['subject'],
+ str_replace([io_safe_input(' ')], ' ', $message_info['mensaje'])
+ );
+}
diff --git a/pandora_console/include/functions_servers.php b/pandora_console/include/functions_servers.php
index 3081e076b6..ba6659ddc1 100644
--- a/pandora_console/include/functions_servers.php
+++ b/pandora_console/include/functions_servers.php
@@ -1,22 +1,33 @@
__('Recon server')]);
+ case SERVER_TYPE_DISCOVERY:
+ $server['img'] = html_print_image('images/recon.png', true, ['title' => __('Discovery server')]);
$server['type'] = 'recon';
$id_modulo = 0;
break;
@@ -589,11 +600,11 @@ function servers_get_info($id_server=-1)
$server['lag'] = 0;
$server['module_lag'] = 0;
}
- // Recon server
- else if ($server['server_type'] == SERVER_TYPE_RECON) {
+ // Discovery server
+ else if ($server['server_type'] == SERVER_TYPE_DISCOVERY) {
$server['name'] = ''.$server['name'].'';
- // Total jobs running on this recon server
+ // Total jobs running on this Discovery server
$server['modules'] = db_get_sql(
'SELECT COUNT(id_rt)
FROM trecon_task
@@ -921,3 +932,64 @@ function servers_get_status($id_server)
$serverinfo = servers_get_info($id_server);
return $serverinfo[$id_server];
}
+
+
+/**
+ * Return server name based on identifier.
+ *
+ * @param integer $server Server identifier.
+ *
+ * @return string Server name
+ */
+function servers_get_server_string_name(int $server)
+{
+ switch ($server) {
+ case SERVER_TYPE_DATA:
+ return __('Data server');
+
+ case SERVER_TYPE_NETWORK:
+ return __('Network server');
+
+ case SERVER_TYPE_SNMP:
+ return __('SNMP server');
+
+ case SERVER_TYPE_ENTERPRISE_ICMP:
+ return __('Enterprise ICMP server');
+
+ case SERVER_TYPE_ENTERPRISE_SNMP:
+ return __('Enterprise SNMP server');
+
+ case SERVER_TYPE_PLUGIN:
+ return __('Plugin server');
+
+ case SERVER_TYPE_PREDICTION:
+ return __('Prediction Server');
+
+ case SERVER_TYPE_WMI:
+ return __('WMI server');
+
+ case SERVER_TYPE_WEB:
+ return __('Web server');
+
+ case SERVER_TYPE_EXPORT:
+ return __('Export server');
+
+ case SERVER_TYPE_INVENTORY:
+ return __('Inventory server');
+
+ case SERVER_TYPE_EVENT:
+ return __('Event server');
+
+ case SERVER_TYPE_DISCOVERY:
+ return __('Discovery server');
+
+ case SERVER_TYPE_SYSLOG:
+ return __('Syslog server');
+
+ case SERVER_TYPE_WUX:
+ return __('WUX server');
+
+ default:
+ return __('N/A');
+ }
+}
diff --git a/pandora_console/include/functions_snmp_browser.php b/pandora_console/include/functions_snmp_browser.php
index 57bc416c76..4920816c89 100644
--- a/pandora_console/include/functions_snmp_browser.php
+++ b/pandora_console/include/functions_snmp_browser.php
@@ -27,7 +27,7 @@ $nfdump_date_format = 'Y/m/d.H:i:s';
* @param id string Level ID. Do not set, used for recursion.
* @param depth string Branch depth. Do not set, used for recursion.
*/
-function snmp_browser_print_tree($tree, $id=0, $depth=0, $last=0, $last_array=[])
+function snmp_browser_print_tree($tree, $id=0, $depth=0, $last=0, $last_array=[], $sufix=false, $checked=[])
{
static $url = false;
@@ -52,13 +52,13 @@ function snmp_browser_print_tree($tree, $id=0, $depth=0, $last=0, $last_array=[]
}
foreach ($tree['__LEAVES__'] as $level => $sub_level) {
- // Id used to expand leafs
+ // Id used to expand leafs.
$sub_id = time().rand(0, getrandmax());
- // Display the branch
+ // Display the branch.
echo "
";
- // Indent sub branches
+ // Indent sub branches.
for ($i = 1; $i <= $depth; $i++) {
if ($last_array[$i] == 1) {
echo '';
@@ -67,7 +67,7 @@ function snmp_browser_print_tree($tree, $id=0, $depth=0, $last=0, $last_array=[]
}
}
- // Branch
+ // Branch.
if (! empty($sub_level['__LEAVES__'])) {
echo "";
if ($depth == 0 && $count == 0) {
@@ -84,7 +84,7 @@ function snmp_browser_print_tree($tree, $id=0, $depth=0, $last=0, $last_array=[]
echo '';
}
- // Leave
+ // Leave.
else {
if ($depth == 0 && $count == 0) {
if ($count == $total) {
@@ -106,15 +106,18 @@ function snmp_browser_print_tree($tree, $id=0, $depth=0, $last=0, $last_array=[]
echo '
';
}
- echo html_print_checkbox("create_$sub_id", 0, false, true, false, '').' '.$level.'';
+ $checkbox_name_sufix = ($sufix === true) ? '_'.$level : '';
+ $checkbox_name = 'create_'.$sub_id.$checkbox_name_sufix;
+ $status = (!empty($checked) && isset($checked[$level]));
+ echo html_print_checkbox($checkbox_name, 0, $status, true, false, '').' '.$level.'';
if (isset($sub_level['__VALUE__'])) {
echo ' = '.$sub_level['__VALUE__'].'';
}
echo '';
- // Recursively print sub levels
- snmp_browser_print_tree($sub_level, $sub_id, ($depth + 1), ($count == $total ? 1 : 0), $last_array);
+ // Recursively print sub levels.
+ snmp_browser_print_tree($sub_level, $sub_id, ($depth + 1), ($count == $total ? 1 : 0), $last_array, $sufix, $checked);
$count++;
}
@@ -838,7 +841,7 @@ function snmp_browser_print_container($return=false, $width='100%', $height='500
if ($(this).is(':checked') ) {
$('input[name*=create_network_component]').show();
var id_input = $(this).attr("id");
- id_input = id_input.split("checkbox-create_");
+ id_input = id_input.match("checkbox-create_([0-9]+)");
var checks = $('#ul_'+id_input[1]).find('input').map(function(){
if(this.id.indexOf('checkbox-create_')!=-1){
return this.id;
@@ -851,7 +854,7 @@ function snmp_browser_print_container($return=false, $width='100%', $height='500
} else {
var id_input = $(this).attr("id");
- id_input = id_input.split("checkbox-create_");
+ id_input = id_input.match("checkbox-create_([0-9]+)");
var checks = $('#ul_'+id_input[1]).find('input').map(function(){
if(this.id.indexOf('checkbox-create_')!=-1){
return this.id;
diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js
index 3561581f49..dd6fb0645e 100644
--- a/pandora_console/include/graphs/flot/pandora.flot.js
+++ b/pandora_console/include/graphs/flot/pandora.flot.js
@@ -857,11 +857,11 @@ function pandoraFlotSlicebar(
var font_size = parseInt(font_size);
if (font != undefined)
- var font = font
- .split("/")
- .pop()
- .split(".")
- .shift();
+ var font = font
+ .split("/")
+ .pop()
+ .split(".")
+ .shift();
// Check possible adapt_keys on classes
check_adaptions(graph_id);
diff --git a/pandora_console/include/help/en/help_reconscript_definition.php b/pandora_console/include/help/en/help_reconscript_definition.php
index 3259b34dd2..f7562acbfc 100644
--- a/pandora_console/include/help/en/help_reconscript_definition.php
+++ b/pandora_console/include/help/en/help_reconscript_definition.php
@@ -7,7 +7,7 @@
The "ReconScripts" allows to work with more flexible capabilities. The recon scripts are developped in an individual way with completely specific targets, such as the network plugins or the agent plugins. Each ReconScript is different and has one purpose.
-
Its basic idea consist on "detect" things in the system it recognizes and automatically log in one monitoring (network, plugin or wmi) so in a completely customized way we could automatically log in requests in an Oracle database, new virtual host in a VmWare that is managed with VirtualCenter or we also can detect new requests in an WebLogic application Server. It is possible to do an script or application that does the task that are wanted and schedule its execution through the Recon Server.
+
Its basic idea consist on "detect" things in the system it recognizes and automatically log in one monitoring (network, plugin or wmi) so in a completely customized way we could automatically log in requests in an Oracle database, new virtual host in a VmWare that is managed with VirtualCenter or we also can detect new requests in an WebLogic application Server. It is possible to do an script or application that does the task that are wanted and schedule its execution through the Discovery Server.
A field with importance is:
diff --git a/pandora_console/include/help/en/help_recontask.php b/pandora_console/include/help/en/help_recontask.php
index 0223d66e5b..b56a0a85c6 100644
--- a/pandora_console/include/help/en/help_recontask.php
+++ b/pandora_console/include/help/en/help_recontask.php
@@ -11,9 +11,9 @@ If you choose to edit or create a new task of network recon, then you should fil
Name of the discovery task. It's only a descriptive value to could distinguish the task in case it would have several of them with different values of filter or template.
-Recon server
+Discovery server
-Recon Server assigned to the task. If you have several Recon Servers, then you have to select here which of them you want to do the recon task.
+Discovery Server assigned to the task. If you have several Discovery Servers, then you have to select here which of them you want to do the recon task.
+ Attention, you are going to overwrite the data of your current installation.
This means that if you do not have a backup you will irremissibly LOSE ALL THE STORED DATA, the configuration and everything relevant to your installation.
";
+
+ return $header;
+}
+
+
+//
+// This function adjusts path settings in pandora db for FreeBSD.
+//
+// All packages and configuration files except operating system's base files
+// are installed under /usr/local in FreeBSD. So, path settings in pandora db
+// for some programs should be changed from the Linux default.
+//
+function adjust_paths_for_freebsd($engine, $connection=false)
+{
+ $adjust_sql = [
+ "update trecon_script set script = REPLACE(script,'/usr/share','/usr/local/share');",
+ "update tconfig set value = REPLACE(value,'/usr/bin','/usr/local/bin') where token='netflow_daemon' OR token='netflow_nfdump' OR token='netflow_nfexpire';",
+ "update talert_commands set command = REPLACE(command,'/usr/bin','/usr/local/bin');",
+ "update talert_commands set command = REPLACE(command,'/usr/share', '/usr/local/share');",
+ "update tplugin set execute = REPLACE(execute,'/usr/share','/usr/local/share');",
+ "update tevent_response set target = REPLACE(target,'/usr/share','/usr/local/share');",
+ "insert into tconfig (token, value) VALUES ('graphviz_bin_dir', '/usr/local/bin');",
+ ];
+
+ for ($i = 0; $i < count($adjust_sql); $i++) {
+ switch ($engine) {
+ case 'mysql':
+ $result = mysql_query($adjust_sql[$i]);
+ break;
+
+ case 'mysqli':
+ $result = mysqli_query($connection, $adjust_sql[$i]);
+ break;
+
+ case 'oracle':
+ // Delete the last semicolon from current query
+ $query = substr($adjust_sql[$i], 0, (strlen($adjust_sql[$i]) - 1));
+ $sql = oci_parse($connection, $query);
+ $result = oci_execute($sql);
+ break;
+
+ case 'pgsql':
+ pg_send_query($connection, $adjust_sql[$i]);
+ $result = pg_get_result($connection);
+ break;
+ }
+
+ if (!$result) {
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+
+function install_step1()
+{
+ global $banner;
+
+ echo "
+
+
+ ".print_logo_status(1, 6)."
+
+
Welcome to Pandora FMS installation Wizard
+
This wizard helps you to quick install Pandora FMS console and main database in your system.
+
In four steps, this installer will check all dependencies and will create your configuration, ready to use.
+
For more information, please refer to documentation.
+ Pandora FMS Development Team
+ ";
+ if (file_exists('include/config.php')) {
+ echo "
Warning: You already have a config.php file.
+ Configuration and database would be overwritten if you continued.
";
+ }
+
+ echo ' ';
+ echo '
';
+ $writable = check_writable('include', 'Checking if ./include is writable');
+ if (file_exists('include/config.php')) {
+ $writable += check_writable('include/config.php', 'Checking if include/config.php is writable');
+ }
+
+ echo '
';
+
+ echo "
Warning: This installer will overwrite and destroy
+ your existing Pandora FMS configuration and Database. Before continue,
+ please be sure that you have no valuable Pandora FMS data in your Database.
+
";
+
+ echo "
Upgrade:
+ If you want to upgrade from Pandora FMS 4.x to 5.0 version, please use the migration tool inside /extras directory in this setup.
+
Pandora FMS is an OpenSource software project licensed under the GPL2 licence. Pandora FMS includes, as well, another software also licensed under LGPL and BSD licenses. Before continue, you must accept the licence terms..
+
For more information, please refer to our website at http://pandorafms.org and contact us if you have any kind of question about the usage of Pandora FMS
+
If you dont accept the licence terms, please, close your browser and delete Pandora FMS files.
+ ";
+
+ if (!file_exists('COPYING')) {
+ echo "
Licence file 'COPYING' is not present in your distribution. This means you have some 'partial' Pandora FMS distribution. We cannot continue without accepting the licence file.";
+ echo '
';
+ } else {
+ echo "
';
+
+ echo "
+
+
+ Pandora FMS is an OpenSource Software project registered at
+ SourceForge
+
You have some incomplete
+ dependencies. Please correct them or this installer
+ will not be able to finish your installation.
+
+
+ Remember, if you install any PHP module to comply
+ with these dependences, you need to restart
+ your HTTP/Apache server after it to use the new
+ modules.
+
+ This wizard will create your Pandora FMS database,
+ and populate it with all the data needed to run for the first time.
+
+
+ You need a privileged user to create database schema, this is usually root user.
+ Information about root user will not be used or stored anymore.
+
+
+ You can also deploy the scheme into an existing Database.
+ In this case you need a privileged Database user and password of that instance.
+
+
+ Now, please, complete all details to configure your database and environment setup.
+
+
+ Warning: This installer will overwrite and destroy your existing
+ Pandora FMS configuration and Database. Before continue,
+ please be sure that you have no valuable Pandora FMS data in your Database.
+
+
";
+
+ if (extension_loaded('oci8')) {
+ echo "
For Oracle installation an existing Database with a privileged user is needed.
'.__('This message does not exist in the system').'
';
return;
- // Move out of this page and go processing other pages
+ // Move out of this page and go processing other pages.
}
$user_name = get_user_fullname($message['id_usuario_origen']);
@@ -72,19 +106,70 @@ if ($read_message) {
$dst_name = $message['id_usuario_destino'];
}
- $table = new stdClass();
- $table->width = '100%';
- $table->class = 'databox filters';
- $table->data = [];
+ if (isset($user_name) !== true || empty($user_name) === true) {
+ echo '